Merge branch 'master' into openjpeg-2.1
This commit is contained in:
commit
58320d2f3b
|
@ -21,6 +21,10 @@ matrix:
|
|||
- os: linux
|
||||
compiler: clang
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
||||
- os: linux
|
||||
compiler: clang-3.9
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
sudo: true
|
||||
- os: linux
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
|
|
|
@ -56,7 +56,7 @@ set(PACKAGE_VERSION
|
|||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||
if(NOT OPENJPEG_SOVERSION)
|
||||
SET(OPENJPEG_SOVERSION 7)
|
||||
set(OPENJPEG_SOVERSION 7)
|
||||
endif(NOT OPENJPEG_SOVERSION)
|
||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||
|
@ -190,7 +190,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
|||
# For all builds, make sure openjpeg is std99 compliant:
|
||||
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
|
|
@ -25,6 +25,9 @@ set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
|||
set(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||
|
||||
# Ignore clang's summary warning, assuming prior text has matched some
|
||||
# other warning expression:
|
||||
"[0-9,]+ warnings? generated."
|
||||
# Suppress warning caused by intentional messages about deprecation
|
||||
".*warning,.* is deprecated"
|
||||
# java also warns about deprecated API
|
||||
|
|
|
@ -91,22 +91,24 @@ static void sycc444_to_rgb(opj_image_t *img)
|
|||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max, i;
|
||||
size_t maxw, maxh, max, i;
|
||||
int offset, upb;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
|
@ -116,91 +118,138 @@ static void sycc444_to_rgb(opj_image_t *img)
|
|||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max;
|
||||
size_t maxw, maxh, max, offx, loopmaxw;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
size_t i;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||
offx = img->x0 & 1U;
|
||||
loopmaxw = maxw - offx;
|
||||
|
||||
for(i=0U; i < maxh; ++i)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
size_t j;
|
||||
|
||||
if (offx > 0U) {
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
}
|
||||
|
||||
for(j=0U; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if (j < maxw) {
|
||||
if (j < loopmaxw) {
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
#if defined(USE_JPWL) || defined(USE_MJ2)
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
#else
|
||||
img->comps[1].w = (OPJ_UINT32)maxw; img->comps[1].h = (OPJ_UINT32)maxh;
|
||||
img->comps[2].w = (OPJ_UINT32)maxw; img->comps[2].h = (OPJ_UINT32)maxh;
|
||||
#endif
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
img->comps[1].w = img->comps[2].w = img->comps[0].w;
|
||||
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
unsigned int maxw, maxh, max;
|
||||
size_t maxw, maxh, max, offx, loopmaxw, offy, loopmaxh;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
size_t i;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
|
||||
if (r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||
offx = img->x0 & 1U;
|
||||
loopmaxw = maxw - offx;
|
||||
/* if img->y0 is odd, then first line shall use Cb/Cr = 0 */
|
||||
offy = img->y0 & 1U;
|
||||
loopmaxh = maxh - offy;
|
||||
|
||||
if (offy > 0U) {
|
||||
size_t j;
|
||||
|
||||
for(j=0; j < maxw; ++j)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0U; i < (loopmaxh & ~(size_t)1U); i += 2U)
|
||||
{
|
||||
size_t j;
|
||||
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
for(j=0; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
if (offx > 0U) {
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
}
|
||||
|
||||
for(j=0; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
@ -212,7 +261,7 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
if(j < loopmaxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
@ -222,9 +271,11 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
if(i < maxh)
|
||||
if(i < loopmaxh)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
size_t j;
|
||||
|
||||
for(j=0U; j < (maxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
|
@ -244,18 +295,17 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
#if defined(USE_JPWL) || defined(USE_MJ2)
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
#else
|
||||
img->comps[1].w = (OPJ_UINT32)maxw; img->comps[1].h = (OPJ_UINT32)maxh;
|
||||
img->comps[2].w = (OPJ_UINT32)maxw; img->comps[2].h = (OPJ_UINT32)maxh;
|
||||
#endif
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
img->comps[1].w = img->comps[2].w = img->comps[0].w;
|
||||
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
|
@ -300,8 +350,6 @@ void color_sycc_to_rgb(opj_image_t *img)
|
|||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
}/* color_sycc_to_rgb() */
|
||||
|
||||
#if defined(OPJ_HAVE_LIBLCMS2) || defined(OPJ_HAVE_LIBLCMS1)
|
||||
|
@ -328,13 +376,13 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||
cmsHPROFILE in_prof, out_prof;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsColorSpaceSignature in_space, out_space;
|
||||
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||
cmsUInt32Number intent, in_type, out_type;
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
size_t nr_samples, i, max, max_w, max_h;
|
||||
int prec, ok = 0;
|
||||
OPJ_COLOR_SPACE new_space;
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
in_prof = cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
#ifdef DEBUG_PROFILE
|
||||
FILE *icm = fopen("debug.icm","wb");
|
||||
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||
|
@ -348,10 +396,9 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
|
||||
max_w = (int)image->comps[0].w;
|
||||
max_h = (int)image->comps[0].h;
|
||||
max_w = image->comps[0].w;
|
||||
max_h = image->comps[0].h;
|
||||
prec = (int)image->comps[0].prec;
|
||||
oldspace = image->color_space;
|
||||
|
||||
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||
{
|
||||
|
@ -366,23 +413,21 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
else if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
else if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -393,6 +438,13 @@ __FILE__,__LINE__,out_space,
|
|||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
cmsCloseProfile(in_prof);
|
||||
|
||||
return;
|
||||
}
|
||||
if(out_prof == NULL)
|
||||
{
|
||||
cmsCloseProfile(in_prof);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -420,8 +472,7 @@ fprintf(stderr,"\trender_intent (%u)\n\t"
|
|||
(void)in_space;
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
|
@ -435,7 +486,7 @@ fprintf(stderr,"\trender_intent (%u)\n\t"
|
|||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
|
@ -448,16 +499,19 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned char));
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL) goto fails0;
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
|
@ -470,27 +524,34 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
ok = 1;
|
||||
|
||||
fails0:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
else
|
||||
else /* prec > 8 */
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL) goto fails1;
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
for(i = 0U ; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
|
@ -509,19 +570,34 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
ok = 1;
|
||||
|
||||
fails1:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
else /* image->numcomps <= 2 : GRAY, GRAYA */
|
||||
{
|
||||
if(prec <= 8)
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
opj_image_comp_t *new_comps;
|
||||
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
|
||||
nr_samples = (size_t)(max * 3 * sizeof(unsigned char));
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
g = (int*)calloc((size_t)max, sizeof(int));
|
||||
b = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
image->comps = (opj_image_comp_t*)
|
||||
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails2;
|
||||
|
||||
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(new_comps == NULL) goto fails2;
|
||||
|
||||
image->comps = new_comps;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
@ -529,14 +605,14 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[1].data = g;
|
||||
image->comps[2].data = b;
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
|
@ -546,13 +622,76 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
r = g = b = NULL;
|
||||
ok = 1;
|
||||
|
||||
fails2:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
free(g);
|
||||
free(b);
|
||||
}
|
||||
else /* prec > 8 */
|
||||
{
|
||||
unsigned short *in, *inbuf, *out, *outbuf;
|
||||
opj_image_comp_t *new_comps;
|
||||
|
||||
max = max_w * max_h;
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
g = (int*)calloc((size_t)max, sizeof(int));
|
||||
b = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails3;
|
||||
|
||||
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(new_comps == NULL) goto fails3;
|
||||
|
||||
image->comps = new_comps;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = g;
|
||||
image->comps[2].data = b;
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
r = g = b = NULL;
|
||||
ok = 1;
|
||||
|
||||
}/* if(image->numcomps */
|
||||
fails3:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
free(g);
|
||||
free(b);
|
||||
}
|
||||
}/* if(image->numcomps > 2) */
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
|
@ -560,14 +699,17 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
if(ok)
|
||||
{
|
||||
image->color_space = new_space;
|
||||
}
|
||||
}/* color_apply_icc_profile() */
|
||||
|
||||
void color_cielab_to_rgb(opj_image_t *image)
|
||||
{
|
||||
int *row;
|
||||
int enumcs, numcomps;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
OPJ_COLOR_SPACE new_space;
|
||||
|
||||
numcomps = (int)image->numcomps;
|
||||
|
||||
|
@ -595,8 +737,14 @@ void color_cielab_to_rgb(opj_image_t *image)
|
|||
cmsCIELab Lab;
|
||||
|
||||
in = cmsCreateLab4Profile(NULL);
|
||||
if(in == NULL){
|
||||
return;
|
||||
}
|
||||
out = cmsCreate_sRGBProfile();
|
||||
|
||||
if(out == NULL){
|
||||
cmsCloseProfile(in);
|
||||
return;
|
||||
}
|
||||
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
|
@ -611,6 +759,8 @@ void color_cielab_to_rgb(opj_image_t *image)
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
prec0 = (double)image->comps[0].prec;
|
||||
prec1 = (double)image->comps[1].prec;
|
||||
prec2 = (double)image->comps[2].prec;
|
||||
|
@ -640,6 +790,8 @@ void color_cielab_to_rgb(opj_image_t *image)
|
|||
green = dst1 = (int*)malloc(max * sizeof(int));
|
||||
blue = dst2 = (int*)malloc(max * sizeof(int));
|
||||
|
||||
if(red == NULL || green == NULL || blue == NULL) goto fails;
|
||||
|
||||
minL = -(rl * ol)/(pow(2, prec0)-1);
|
||||
maxL = minL + rl;
|
||||
|
||||
|
@ -670,16 +822,27 @@ void color_cielab_to_rgb(opj_image_t *image)
|
|||
free(src1); image->comps[1].data = dst1;
|
||||
free(src2); image->comps[2].data = dst2;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->color_space = new_space;
|
||||
image->comps[0].prec = 16;
|
||||
image->comps[1].prec = 16;
|
||||
image->comps[2].prec = 16;
|
||||
|
||||
return;
|
||||
|
||||
fails:
|
||||
cmsDeleteTransform(transform);
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
if(red) free(red);
|
||||
if(green) free(green);
|
||||
if(blue) free(blue);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs);
|
||||
}/* color_apply_conversion() */
|
||||
}/* color_cielab_to_rgb() */
|
||||
|
||||
#endif /* OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 */
|
||||
|
||||
|
@ -692,7 +855,14 @@ void color_cmyk_to_rgb(opj_image_t *image)
|
|||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
||||
if(image->numcomps < 4) return;
|
||||
if (
|
||||
(image->numcomps < 4)
|
||||
|| (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx) || (image->comps[0].dx != image->comps[3].dx)
|
||||
|| (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy) || (image->comps[0].dy != image->comps[3].dy)
|
||||
) {
|
||||
fprintf(stderr,"%s:%d:color_cmyk_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
max = w * h;
|
||||
|
||||
|
@ -744,7 +914,14 @@ void color_esycc_to_rgb(opj_image_t *image)
|
|||
int flip_value = (1 << (image->comps[0].prec-1));
|
||||
int max_value = (1 << image->comps[0].prec) - 1;
|
||||
|
||||
if(image->numcomps < 3) return;
|
||||
if (
|
||||
(image->numcomps < 3)
|
||||
|| (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx)
|
||||
|| (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy)
|
||||
) {
|
||||
fprintf(stderr,"%s:%d:color_esycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
|
|
@ -611,6 +611,10 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
|||
if (id_len)
|
||||
{
|
||||
unsigned char *id = (unsigned char *) malloc(id_len);
|
||||
if(id == 0){
|
||||
fprintf(stderr, "tga_readheader: memory out\n");
|
||||
return 0;
|
||||
}
|
||||
if ( !fread(id, id_len, 1, fp) )
|
||||
{
|
||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||
|
@ -1249,6 +1253,7 @@ int imagetopgx(opj_image_t * image, const char *outfile)
|
|||
{
|
||||
name = (char*)malloc(total+1);
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "imagetopgx: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
|
@ -1906,7 +1911,10 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
|||
fprintf(stderr," is written to the file\n");
|
||||
}
|
||||
destname = (char*)malloc(strlen(outfile) + 8);
|
||||
|
||||
if(destname == NULL){
|
||||
fprintf(stderr, "imagetopnm: memory out\n");
|
||||
return 1;
|
||||
}
|
||||
for (compno = 0; compno < ncomp; compno++)
|
||||
{
|
||||
if (ncomp > 1)
|
||||
|
|
|
@ -181,7 +181,7 @@ static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
|
|||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_BOOL hasAlpha;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
|
@ -239,7 +239,7 @@ static void bmpmask16toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
|
|||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_BOOL hasAlpha;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
|
@ -891,7 +891,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
|
|||
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
for (pad = ((3 * w) % 4) ? (4 - (3 * w) % 4) : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
|
@ -967,7 +967,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
|
|||
fprintf(fdest, "%c", (OPJ_UINT8)r);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
for (pad = (w % 4) ? (4 - w % 4) : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,9 +185,17 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
|||
|
||||
|
||||
rows = (OPJ_BYTE**)calloc(height+1, sizeof(OPJ_BYTE*));
|
||||
for(i = 0; i < height; ++i)
|
||||
if(rows == NULL){
|
||||
fprintf(stderr, "pngtoimage: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
for(i = 0; i < height; ++i){
|
||||
rows[i] = (OPJ_BYTE*)malloc(png_get_rowbytes(png,info));
|
||||
|
||||
if(rows[i] == NULL){
|
||||
fprintf(stderr,"pngtoimage: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
png_read_image(png, rows);
|
||||
|
||||
/* Create image */
|
||||
|
@ -235,7 +243,7 @@ fin:
|
|||
if(rows)
|
||||
{
|
||||
for(i = 0; i < height; ++i)
|
||||
free(rows[i]);
|
||||
if(rows[i]) free(rows[i]);
|
||||
free(rows);
|
||||
}
|
||||
if (row32s) {
|
||||
|
|
|
@ -56,6 +56,229 @@
|
|||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
#define PUTBITS2(s, nb) \
|
||||
trailing <<= remaining; \
|
||||
trailing |= (unsigned int)((s) >> (nb - remaining)); \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
trailing = (unsigned int)((s) & ((1U << (nb - remaining)) - 1U)); \
|
||||
if (nb >= (remaining + 8)) { \
|
||||
*pDst++ = (OPJ_BYTE)(trailing >> (nb - (remaining + 8))); \
|
||||
trailing &= (unsigned int)((1U << (nb - (remaining + 8))) - 1U); \
|
||||
remaining += 16 - nb; \
|
||||
} else { \
|
||||
remaining += 8 - nb; \
|
||||
}
|
||||
|
||||
#define PUTBITS(s, nb) \
|
||||
if (nb >= remaining) { \
|
||||
PUTBITS2(s, nb) \
|
||||
} else { \
|
||||
trailing <<= nb; \
|
||||
trailing |= (unsigned int)(s); \
|
||||
remaining -= nb; \
|
||||
}
|
||||
#define FLUSHBITS() \
|
||||
if (remaining != 8) { \
|
||||
trailing <<= remaining; \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
}
|
||||
|
||||
static void tif_32sto3u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 << 2) | (src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 << 4) | (src4 << 1) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 << 3) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 3)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 3)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 3)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 3)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 3)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 3)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto5u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 << 1) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 << 2) | (src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7));
|
||||
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 5)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 5)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 5)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 5)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 5)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 5)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto7u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 7)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 7)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 7)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 7)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 7)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 7)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto9u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 7) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 5) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 3) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 1) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 9)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 9)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 9)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 9)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 9)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 9)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
|
@ -95,6 +318,59 @@ static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto11u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 1) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 3) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 11)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 11)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 11)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 11)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 11)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 11)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -113,6 +389,61 @@ static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
*pDst++ = (OPJ_BYTE)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto13u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 1) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 13)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 13)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 13)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 13)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 13)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 13)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -155,6 +486,63 @@ static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto15u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 14));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 13));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 15)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 15)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 15)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 15)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 15)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 15)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const OPJ_INT32* pSrc, OPJ_UINT16* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -223,10 +611,10 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps > 16) bps = 0;
|
||||
if(bps == 0)
|
||||
{
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1 to 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -248,15 +636,36 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 3:
|
||||
cvt32sToTif = tif_32sto3u;
|
||||
break;
|
||||
case 5:
|
||||
cvt32sToTif = tif_32sto5u;
|
||||
break;
|
||||
case 7:
|
||||
cvt32sToTif = tif_32sto7u;
|
||||
break;
|
||||
case 9:
|
||||
cvt32sToTif = tif_32sto9u;
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 11:
|
||||
cvt32sToTif = tif_32sto11u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 13:
|
||||
cvt32sToTif = tif_32sto13u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 15:
|
||||
cvt32sToTif = tif_32sto15u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
|
@ -313,6 +722,221 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
#define GETBITS(dest, nb) { \
|
||||
int needed = (nb); \
|
||||
unsigned int dst = 0U; \
|
||||
if (available == 0) { \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
while (needed > available) { \
|
||||
dst |= val & ((1U << available) - 1U); \
|
||||
needed -= available; \
|
||||
dst <<= needed; \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
dst |= (val >> (available - needed)) & ((1U << needed) - 1U); \
|
||||
available -= needed; \
|
||||
dest = (OPJ_INT32)dst; \
|
||||
}
|
||||
|
||||
static void tif_3uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1FU) >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val0 & 0x3U) << 1) | (val1 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x7FU) >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val1 & 0xFU) >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val1 & 0x1U) << 2) | (val2 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val2 & 0x3FU) >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val2 & 0x7U)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 3)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 3)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 3)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 3)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 3)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 3)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_5uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x7U) << 2) | (val1 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3FU) >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x1U) << 4) | (val2 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val2 & 0xFU) << 1) | (val3 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val3 & 0x7FU) >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val3 & 0x3U) << 3) | (val4 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val4 & 0x1FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 5)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 5)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 5)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 5)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 5)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 5)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_7uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1U) << 6) | (val1 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3U) << 5) | (val2 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val2 & 0x7U) << 4) | (val3 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val3 & 0xFU) << 3) | (val4 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val4 & 0x1FU) << 2) | (val5 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val5 & 0x3FU) << 1) | (val6 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val6 & 0x7FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 7)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 7)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 7)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 7)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 7)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 7)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_9uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 1) | (val1 >> 7));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7FU) << 2) | (val2 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3FU) << 3) | (val3 >> 5));
|
||||
pDst[i+3] = (OPJ_INT32)(((val3 & 0x1FU) << 4) | (val4 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val4 & 0xFU) << 5) | (val5 >> 3));
|
||||
pDst[i+5] = (OPJ_INT32)(((val5 & 0x7U) << 6) | (val6 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val6 & 0x3U) << 7) | (val7 >> 1));
|
||||
pDst[i+7] = (OPJ_INT32)(((val7 & 0x1U) << 8) | (val8));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 9)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 9)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 9)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 9)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 9)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 9)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -345,6 +969,60 @@ static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_11uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 3) | (val1 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1FU) << 6) | (val2 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3U) << 9) | (val3 << 1) | (val4 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x7FU) << 4) | (val5 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val5 & 0xFU) << 7) | (val6 >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val6 & 0x1U) << 10) | (val7 << 2) | (val8 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val8 & 0x3FU) << 5) | (val9 >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val9 & 0x7U) << 8) | (val10));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 11)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 11)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 11)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 11)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 11)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 11)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -362,6 +1040,62 @@ static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
pDst[i+0] = (OPJ_INT32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_13uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 5) | (val1 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7U) << 10) | (val2 << 2) | (val3 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3FU) << 7) | (val4 >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x1U) << 12) | (val5 << 4) | (val6 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val6 & 0xFU) << 9) | (val7 << 1) | (val8 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val8 & 0x7FU) << 6) | (val9 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val9 & 0x3U) << 11) | (val10 << 3) | (val11 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val11 & 0x1FU) << 8) | (val12));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 13)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 13)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 13)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 13)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 13)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 13)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -398,6 +1132,64 @@ static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_15uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
OPJ_UINT32 val13 = *pSrc++;
|
||||
OPJ_UINT32 val14 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 7) | (val1 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1U) << 14) | (val2 << 6) | (val3 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3U) << 13) | (val4 << 5) | (val5 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val5 & 0x7U) << 12) | (val6 << 4) | (val7 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val7 & 0xFU) << 11) | (val8 << 3) | (val9 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val9 & 0x1FU) << 10) | (val10 << 2) | (val11 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val11 & 0x3FU) << 9) | (val12 << 1) | (val13 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val13 & 0x7FU) << 8) | (val14));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 15)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 15)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 15)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 15)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 15)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 15)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
|
@ -454,8 +1246,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
if(tiBps > 16U) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1 to 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
|
@ -476,15 +1268,36 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 3:
|
||||
cvtTifTo32s = tif_3uto32s;
|
||||
break;
|
||||
case 5:
|
||||
cvtTifTo32s = tif_5uto32s;
|
||||
break;
|
||||
case 7:
|
||||
cvtTifTo32s = tif_7uto32s;
|
||||
break;
|
||||
case 9:
|
||||
cvtTifTo32s = tif_9uto32s;
|
||||
break;
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 11:
|
||||
cvtTifTo32s = tif_11uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 13:
|
||||
cvtTifTo32s = tif_13uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 15:
|
||||
cvtTifTo32s = tif_15uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
|
|
|
@ -69,7 +69,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
if (cstr_info->tile[0].distotile > 0.0)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
|
|
@ -647,6 +647,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||
raw_cp->rawBitDepth = bitdepth;
|
||||
raw_cp->rawSigned = raw_signed;
|
||||
raw_cp->rawComps = (raw_comp_cparameters_t*) malloc(((OPJ_UINT32)(ncomp))*sizeof(raw_comp_cparameters_t));
|
||||
if(raw_cp->rawComps == NULL){
|
||||
free(substr1);
|
||||
return 1;
|
||||
}
|
||||
for (compno = 0; compno < ncomp && !wrong; compno++) {
|
||||
if (substr2 == NULL) {
|
||||
raw_cp->rawComps[compno].dx = lastdx;
|
||||
|
@ -725,6 +729,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||
numresolution = (OPJ_UINT32)parameters->numresolution;
|
||||
matrix_width = numresolution * 3;
|
||||
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||
if(parameters->cp_matrice == NULL){
|
||||
return 1;
|
||||
}
|
||||
s = s + 2;
|
||||
|
||||
for (i = 0; i < numlayers; i++) {
|
||||
|
@ -995,6 +1002,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||
case 'z': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
|
@ -1540,6 +1550,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -1635,7 +1646,7 @@ int main(int argc, char **argv) {
|
|||
/* parse input and get user encoding parameters */
|
||||
parameters.tcp_mct = (char) 255; /* This will be set later according to the input image or the provided option */
|
||||
if(parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, &raw_cp, indexfilename, sizeof(indexfilename)) == 1) {
|
||||
return 1;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read directory if necessary */
|
||||
|
@ -1848,7 +1859,9 @@ int main(int argc, char **argv) {
|
|||
OPJ_BYTE *l_data;
|
||||
OPJ_UINT32 l_data_size = 512*512*3;
|
||||
l_data = (OPJ_BYTE*) calloc( 1,l_data_size);
|
||||
assert( l_data );
|
||||
if(l_data == NULL){
|
||||
goto fails;
|
||||
}
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
|
||||
|
@ -1904,4 +1917,16 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fails:
|
||||
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||
if(raw_cp.rawComps) free(raw_cp.rawComps);
|
||||
if(img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
if(dirptr){
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
free(dirptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -680,6 +680,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
|
|||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
|
@ -1200,8 +1203,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* Initialize reading of directory */
|
||||
|
@ -1210,26 +1212,30 @@ int main(int argc, char **argv)
|
|||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
if(!dirptr){
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
if(!dirptr->filename_buf){
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename){
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
|
@ -1254,8 +1260,7 @@ int main(int argc, char **argv)
|
|||
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
|
||||
if (!l_stream){
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* decode the JPEG2000 stream */
|
||||
|
@ -1297,21 +1302,19 @@ int main(int argc, char **argv)
|
|||
/* Setup the decoder decoding parameters using user parameters */
|
||||
if ( !opj_setup_decoder(l_codec, &(parameters.core)) ){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to setup the decoder\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
|
||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
if (!parameters.nb_tile_to_decode) {
|
||||
|
@ -1319,21 +1322,19 @@ int main(int argc, char **argv)
|
|||
if (!opj_set_decode_area(l_codec, image, (OPJ_INT32)parameters.DA_x0,
|
||||
(OPJ_INT32)parameters.DA_y0, (OPJ_INT32)parameters.DA_x1, (OPJ_INT32)parameters.DA_y1)){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to set the decoded area\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* Get the decoded image */
|
||||
if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
|
||||
fprintf(stderr,"ERROR -> opj_decompress: failed to decode image!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1344,16 +1345,15 @@ int main(int argc, char **argv)
|
|||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}*/
|
||||
|
||||
if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to decode tile!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
|
||||
}
|
||||
|
@ -1432,9 +1432,8 @@ int main(int argc, char **argv)
|
|||
image = upsample_image_components(image);
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to upsample image components!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1456,9 +1455,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to convert to RGB image!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1567,10 +1565,17 @@ int main(int argc, char **argv)
|
|||
|
||||
if(failed) (void)remove(parameters.outfile); /* ignore return value */
|
||||
}
|
||||
fin:
|
||||
destroy_parameters(¶meters);
|
||||
if(failed && img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
if(dirptr){
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
free(dirptr);
|
||||
}
|
||||
if (numDecompressedImages) {
|
||||
fprintf(stdout, "decode time: %d ms\n", (int)( (tCumulative * 1000.0) / (OPJ_FLOAT64)numDecompressedImages));
|
||||
}
|
||||
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
/*end main*/
|
||||
/*end main()*/
|
||||
|
|
|
@ -341,6 +341,9 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
|
|||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
|
@ -433,12 +436,6 @@ int main(int argc, char *argv[])
|
|||
img_fol_t img_fol;
|
||||
dircnt_t *dirptr = NULL;
|
||||
|
||||
#ifdef MSD
|
||||
OPJ_BOOL l_go_on = OPJ_TRUE;
|
||||
OPJ_UINT32 l_max_data_size = 1000;
|
||||
OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
|
||||
#endif
|
||||
|
||||
/* Set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
|
@ -448,6 +445,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
if(img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -457,25 +456,31 @@ int main(int argc, char *argv[])
|
|||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
if(!dirptr){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
if(!dirptr->filename_buf){
|
||||
free(dirptr);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return EXIT_FAILURE;
|
||||
if(!dirptr->filename){
|
||||
goto fails;
|
||||
}
|
||||
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
|
@ -486,7 +491,7 @@ int main(int argc, char *argv[])
|
|||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout){
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -510,7 +515,7 @@ int main(int argc, char *argv[])
|
|||
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
|
||||
if (!l_stream){
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read the JPEG2000 stream */
|
||||
|
@ -552,7 +557,7 @@ int main(int argc, char *argv[])
|
|||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
|
@ -562,7 +567,7 @@ int main(int argc, char *argv[])
|
|||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
opj_dump_codec(l_codec, img_fol.flag, fout );
|
||||
|
@ -594,4 +599,12 @@ int main(int argc, char *argv[])
|
|||
fclose(fout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
fails:
|
||||
if(dirptr){
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
free(dirptr);
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Build the demo app, small examples
|
||||
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
set(common_SRCS
|
||||
convert.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||
)
|
||||
|
@ -26,15 +26,15 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
# Loop over all executables:
|
||||
FOREACH(exe opj_jp3d_compress opj_jp3d_decompress)
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} openjp3d)
|
||||
foreach(exe opj_jp3d_compress opj_jp3d_decompress)
|
||||
add_executable(${exe} ${exe}.c ${common_SRCS})
|
||||
target_link_libraries(${exe} openjp3d)
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} m)
|
||||
ENDIF(UNIX)
|
||||
if(UNIX)
|
||||
target_link_libraries(${exe} m)
|
||||
endif(UNIX)
|
||||
# Install exe
|
||||
INSTALL(TARGETS ${exe}
|
||||
install(TARGETS ${exe}
|
||||
EXPORT OpenJP3DTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
|
|
|
@ -151,19 +151,31 @@ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
|||
bio->ct = 0;
|
||||
}
|
||||
|
||||
OPJ_NOSANITIZE("unsigned-integer-overflow")
|
||||
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
|
||||
assert((n > 0U) && (n <= 32U));
|
||||
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
|
||||
opj_bio_putbit(bio, (v >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
OPJ_NOSANITIZE("unsigned-integer-overflow")
|
||||
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 v;
|
||||
v = 0;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
v += opj_bio_getbit(bio) << i;
|
||||
|
||||
assert((n > 0U) /* && (n <= 32U)*/);
|
||||
#ifdef OPJ_UBSAN_BUILD
|
||||
/* This assert fails for some corrupted images which are gracefully rejected */
|
||||
/* Add this assert only for ubsan build. */
|
||||
/* This is the condition for overflow not to occur below which is needed because of OPJ_NOSANITIZE */
|
||||
assert(n <= 32U);
|
||||
#endif
|
||||
v = 0U;
|
||||
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
|
||||
v |= opj_bio_getbit(bio) << i; /* can't overflow, opj_bio_getbit returns 0 or 1 */
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,9 @@ int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t
|
|||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for (i=0;i<2;i++){
|
||||
|
||||
if(i)
|
||||
|
|
|
@ -2063,17 +2063,17 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
/* testcase 4035.pdf.SIGSEGV.d8b.3375 */
|
||||
/* testcase issue427-null-image-size.jp2 */
|
||||
if ((l_image->x0 >= l_image->x1) || (l_image->y0 >= l_image->y1)) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: negative or zero image size (%d x %d)\n", l_image->x1 - l_image->x0, l_image->y1 - l_image->y0);
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: negative or zero image size (%" PRId64 " x %" PRId64 ")\n", (OPJ_INT64)l_image->x1 - l_image->x0, (OPJ_INT64)l_image->y1 - l_image->y0);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* testcase 2539.pdf.SIGFPE.706.1712 (also 3622.pdf.SIGFPE.706.2916 and 4008.pdf.SIGFPE.706.3345 and maybe more) */
|
||||
if (!(l_cp->tdx * l_cp->tdy)) {
|
||||
if ((l_cp->tdx == 0U) || (l_cp->tdy == 0U)) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: invalid tile size (tdx: %d, tdy: %d)\n", l_cp->tdx, l_cp->tdy);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* testcase 1610.pdf.SIGSEGV.59c.681 */
|
||||
if (((OPJ_UINT64)l_image->x1) * ((OPJ_UINT64)l_image->y1) != (l_image->x1 * l_image->y1)) {
|
||||
if ((0xFFFFFFFFU / l_image->x1) < l_image->y1) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Prevent buffer overflow (x1: %d, y1: %d)\n", l_image->x1, l_image->y1);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -2094,7 +2094,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"JPWL: bad image size (%d x %d)\n",
|
||||
l_image->x1, l_image->y1);
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -2154,10 +2154,16 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
if( l_img_comp->dx < 1 || l_img_comp->dx > 255 ||
|
||||
l_img_comp->dy < 1 || l_img_comp->dy > 255 ) {
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"Invalid values for comp = %d : dx=%u dy=%u\n (should be between 1 and 255 according the JPEG2000 norm)",
|
||||
"Invalid values for comp = %d : dx=%u dy=%u (should be between 1 and 255 according to the JPEG2000 norm)\n",
|
||||
i, l_img_comp->dx, l_img_comp->dy);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if( l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n",
|
||||
i, l_img_comp->prec);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (l_cp->correct) {
|
||||
|
@ -2270,7 +2276,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
if (!l_cp->tcps) {
|
||||
opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
|
||||
"JPWL: could not alloc tcps field of cp\n");
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -2445,7 +2451,7 @@ static OPJ_BOOL opj_j2k_write_cod( opj_j2k_t *p_j2k,
|
|||
opj_write_bytes(l_current_data,l_tcp->csty,1); /* Scod */
|
||||
++l_current_data;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->prg,1); /* SGcod (A) */
|
||||
opj_write_bytes(l_current_data,(OPJ_UINT32)l_tcp->prg,1); /* SGcod (A) */
|
||||
++l_current_data;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->numlayers,2); /* SGcod (B) */
|
||||
|
@ -2578,6 +2584,9 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k,
|
|||
p_j2k->cstr_info->prog = l_tcp->prg;
|
||||
p_j2k->cstr_info->numlayers = l_tcp->numlayers;
|
||||
p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
|
||||
if(!p_j2k->cstr_info->numdecompos){
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
for (i = 0; i < l_image->numcomps; ++i) {
|
||||
p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
|
||||
}
|
||||
|
@ -3165,7 +3174,7 @@ static void opj_j2k_write_poc_in_memory( opj_j2k_t *p_j2k,
|
|||
opj_write_bytes(l_current_data,l_current_poc->compno1,l_poc_room); /* CEpoc_i */
|
||||
l_current_data+=l_poc_room;
|
||||
|
||||
opj_write_bytes(l_current_data,l_current_poc->prg,1); /* Ppoc_i */
|
||||
opj_write_bytes(l_current_data, (OPJ_UINT32)l_current_poc->prg,1); /* Ppoc_i */
|
||||
++l_current_data;
|
||||
|
||||
/* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
|
||||
|
@ -4621,7 +4630,7 @@ static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
|
|||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"JPWL: bad component number in RGN (%d when there are only %d)\n",
|
||||
l_comp_room, l_nb_comp);
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -4706,7 +4715,7 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
|||
l_rates = l_tcp->rates;
|
||||
|
||||
/* Modification of the RATE >> */
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates = (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
|
||||
/
|
||||
((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
|
||||
|
@ -4718,7 +4727,7 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
|||
++l_rates;
|
||||
|
||||
for (k = 1; k < l_tcp->numlayers; ++k) {
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates = (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
|
||||
/
|
||||
((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
|
||||
|
@ -4741,11 +4750,11 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
|||
for (j=0;j<l_cp->tw;++j) {
|
||||
l_rates = l_tcp->rates;
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= l_sot_remove;
|
||||
|
||||
if (*l_rates < 30) {
|
||||
*l_rates = 30;
|
||||
if (*l_rates < 30.0f) {
|
||||
*l_rates = 30.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4755,22 +4764,22 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
|||
|
||||
for (k = 1; k < l_last_res; ++k) {
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= l_sot_remove;
|
||||
|
||||
if (*l_rates < *(l_rates - 1) + 10) {
|
||||
*l_rates = (*(l_rates - 1)) + 20;
|
||||
if (*l_rates < *(l_rates - 1) + 10.0f) {
|
||||
*l_rates = (*(l_rates - 1)) + 20.0f;
|
||||
}
|
||||
}
|
||||
|
||||
++l_rates;
|
||||
}
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= (l_sot_remove + 2.f);
|
||||
|
||||
if (*l_rates < *(l_rates - 1) + 10) {
|
||||
*l_rates = (*(l_rates - 1)) + 20;
|
||||
if (*l_rates < *(l_rates - 1) + 10.0f) {
|
||||
*l_rates = (*(l_rates - 1)) + 20.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5362,7 +5371,7 @@ static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k,
|
|||
l_current_data+=l_nb_bytes_for_comp;
|
||||
}
|
||||
|
||||
l_tmcc = ((!p_mcc_record->m_is_irreversible)&1)<<16;
|
||||
l_tmcc = ((!p_mcc_record->m_is_irreversible) & 1U) << 16;
|
||||
|
||||
if (p_mcc_record->m_decorrelation_array) {
|
||||
l_tmcc |= p_mcc_record->m_decorrelation_array->m_index;
|
||||
|
@ -8880,6 +8889,10 @@ static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k,
|
|||
|
||||
opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1); /* SPcoc (G) */
|
||||
++l_current_ptr;
|
||||
if (l_tccp->cblksty & 0xC0U) { /* 2 msb are reserved, assume we can't read */
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element, Invalid code-block style found\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1); /* SPcoc (H) */
|
||||
++l_current_ptr;
|
||||
|
@ -9334,6 +9347,7 @@ void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream)
|
|||
|
||||
/* Dump the codestream info from main header */
|
||||
if (flag & OPJ_J2K_MH_INFO){
|
||||
if (p_j2k->m_private_image)
|
||||
opj_j2k_dump_MH_info(p_j2k, out_stream);
|
||||
}
|
||||
/* Dump all tile/codestream info */
|
||||
|
@ -9341,11 +9355,13 @@ void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream)
|
|||
OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
|
||||
OPJ_UINT32 i;
|
||||
opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
|
||||
if (p_j2k->m_private_image) {
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
opj_j2k_dump_tile_info( l_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
|
||||
++l_tcp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Dump the codestream info of the current tile */
|
||||
if (flag & OPJ_J2K_TH_INFO){
|
||||
|
|
|
@ -646,12 +646,13 @@ static OPJ_BYTE * opj_jp2_write_bpcc( opj_jp2_t *jp2,
|
|||
{
|
||||
OPJ_UINT32 i;
|
||||
/* room for 8 bytes for box and 1 byte for each component */
|
||||
OPJ_UINT32 l_bpcc_size = 8 + jp2->numcomps;
|
||||
OPJ_UINT32 l_bpcc_size;
|
||||
OPJ_BYTE * l_bpcc_data,* l_current_bpcc_ptr;
|
||||
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_nb_bytes_written != 00);
|
||||
l_bpcc_size = 8 + jp2->numcomps;
|
||||
|
||||
l_bpcc_data = (OPJ_BYTE *) opj_calloc(1,l_bpcc_size);
|
||||
if (l_bpcc_data == 00) {
|
||||
|
@ -1404,6 +1405,10 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
|
|||
OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
|
||||
|
||||
cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
|
||||
if(cielab == NULL){
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for cielab\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
cielab[0] = 14; /* enumcs */
|
||||
|
||||
/* default values */
|
||||
|
@ -1639,7 +1644,7 @@ static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
|
|||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 l_ftyp_size = 16 + 4 * jp2->numcl;
|
||||
OPJ_UINT32 l_ftyp_size;
|
||||
OPJ_BYTE * l_ftyp_data, * l_current_data_ptr;
|
||||
OPJ_BOOL l_result;
|
||||
|
||||
|
@ -1647,6 +1652,7 @@ static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
|
|||
assert(cio != 00);
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
l_ftyp_size = 16 + 4 * jp2->numcl;
|
||||
|
||||
l_ftyp_data = (OPJ_BYTE *) opj_calloc(1,l_ftyp_size);
|
||||
|
||||
|
|
|
@ -203,13 +203,20 @@ static opj_mqc_state_t mqc_states[47 * 2] = {
|
|||
*/
|
||||
|
||||
static void opj_mqc_byteout(opj_mqc_t *mqc) {
|
||||
if (*mqc->bp == 0xff) {
|
||||
/* avoid accessing uninitialized memory*/
|
||||
if (mqc->bp == mqc->start-1) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
|
||||
mqc->c &= 0x7ffff;
|
||||
mqc->ct = 8;
|
||||
}
|
||||
else if (*mqc->bp == 0xff) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
|
||||
mqc->c &= 0xfffff;
|
||||
mqc->ct = 7;
|
||||
} else {
|
||||
if ((mqc->c & 0x8000000) == 0) { /* ((mqc->c&0x8000000)==0) CHANGE */
|
||||
if ((mqc->c & 0x8000000) == 0) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
|
||||
mqc->c &= 0x7ffff;
|
||||
|
@ -395,9 +402,6 @@ void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
|
|||
mqc->c = 0;
|
||||
mqc->bp = bp - 1;
|
||||
mqc->ct = 12;
|
||||
if (*mqc->bp == 0xff) {
|
||||
mqc->ct = 13;
|
||||
}
|
||||
mqc->start = bp;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,12 +102,6 @@
|
|||
==========================================================
|
||||
*/
|
||||
|
||||
/* Ignore GCC attributes if this is not GCC */
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x) /* __attribute__(x) */
|
||||
#endif
|
||||
|
||||
|
||||
/* Are restricted pointers available? (C99) */
|
||||
#if (__STDC_VERSION__ != 199901L)
|
||||
/* Not a C99 compiler */
|
||||
|
@ -118,6 +112,14 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __has_attribute
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind)))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef OPJ_NOSANITIZE
|
||||
#define OPJ_NOSANITIZE(kind)
|
||||
#endif
|
||||
|
||||
|
||||
/* MSVC before 2013 and Borland C do not have lrintf */
|
||||
|
|
|
@ -196,10 +196,10 @@ void * opj_malloc(size_t size)
|
|||
}
|
||||
void * opj_calloc(size_t num, size_t size)
|
||||
{
|
||||
if (size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
if (num == 0 || size == 0) {
|
||||
/* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
/* according to C89 standard, num == 0 shall return a valid pointer */
|
||||
return calloc(num, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
|
|||
OPJ_OFF_T lenp = 0;
|
||||
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for( i=0;i<2;i++){
|
||||
if (i)
|
||||
opj_stream_seek( cio, lenp, p_manager);
|
||||
|
|
|
@ -747,10 +747,12 @@ static void opj_get_all_encoding_parameters( const opj_image_t *p_image,
|
|||
}
|
||||
|
||||
/* use custom size for precincts*/
|
||||
l_level_no = l_tccp->numresolutions - 1;
|
||||
l_level_no = l_tccp->numresolutions;
|
||||
for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
|
||||
OPJ_UINT32 l_dx, l_dy;
|
||||
|
||||
--l_level_no;
|
||||
|
||||
/* precinct width and height*/
|
||||
l_pdx = l_tccp->prcw[resno];
|
||||
l_pdy = l_tccp->prch[resno];
|
||||
|
@ -782,7 +784,6 @@ static void opj_get_all_encoding_parameters( const opj_image_t *p_image,
|
|||
*p_max_prec = l_product;
|
||||
}
|
||||
|
||||
--l_level_no;
|
||||
}
|
||||
++l_tccp;
|
||||
++l_img_comp;
|
||||
|
|
|
@ -61,7 +61,9 @@ int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
|
|||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for (i=0;i<2;i++){
|
||||
if (i)
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ OPJ_UINT32 opj_raw_decode(opj_raw_t *raw) {
|
|||
}
|
||||
}
|
||||
raw->ct--;
|
||||
d = (raw->c >> raw->ct) & 0x01;
|
||||
d = ((OPJ_UINT32)raw->c >> raw->ct) & 0x01U;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ static void opj_t1_enc_sigpass_step( opj_t1_t *t1,
|
|||
|
||||
flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (OPJ_UINT32)(*flagsp);
|
||||
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
||||
v = opj_int_abs(*datap) & one ? 1 : 0;
|
||||
v = (opj_int_abs(*datap) & one) ? 1 : 0;
|
||||
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient)); /* ESSAI */
|
||||
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
|
||||
opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v);
|
||||
|
@ -625,7 +625,7 @@ static void opj_t1_enc_refpass_step( opj_t1_t *t1,
|
|||
flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (OPJ_UINT32)(*flagsp);
|
||||
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
||||
*nmsedec += opj_t1_getnmsedec_ref((OPJ_UINT32)opj_int_abs(*datap), (OPJ_UINT32)(bpno));
|
||||
v = opj_int_abs(*datap) & one ? 1 : 0;
|
||||
v = (opj_int_abs(*datap) & one) ? 1 : 0;
|
||||
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
|
||||
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
|
||||
opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v);
|
||||
|
@ -849,7 +849,7 @@ static void opj_t1_enc_clnpass_step(
|
|||
}
|
||||
if (!(*flagsp & (T1_SIG | T1_VISIT))) {
|
||||
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
||||
v = opj_int_abs(*datap) & one ? 1 : 0;
|
||||
v = (opj_int_abs(*datap) & one) ? 1 : 0;
|
||||
opj_mqc_encode(mqc, (OPJ_UINT32)v);
|
||||
if (v) {
|
||||
LABEL_PARTIAL:
|
||||
|
@ -1180,8 +1180,11 @@ static OPJ_BOOL opj_t1_allocate_buffers(
|
|||
}
|
||||
t1->datasize=datasize;
|
||||
}
|
||||
/* memset first arg is declared to never be null by gcc */
|
||||
if (t1->data != NULL) {
|
||||
memset(t1->data,0,datasize * sizeof(OPJ_INT32));
|
||||
}
|
||||
}
|
||||
t1->flags_stride=w+2;
|
||||
flagssize=t1->flags_stride * (h+2);
|
||||
|
||||
|
@ -1405,7 +1408,7 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
|
|||
}
|
||||
}
|
||||
|
||||
for (passno = 0; passno < seg->real_num_passes; ++passno) {
|
||||
for (passno = 0; (passno < seg->real_num_passes) && (bpno_plus_one >= 1); ++passno) {
|
||||
switch (passtype) {
|
||||
case 0:
|
||||
if (type == T1_TYPE_RAW) {
|
||||
|
@ -1514,7 +1517,7 @@ OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1,
|
|||
if (tccp->qmfbid == 1) {
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
tiledp[tileIndex] <<= T1_NMSEDEC_FRACBITS;
|
||||
tiledp[tileIndex] *= (1 << T1_NMSEDEC_FRACBITS);
|
||||
tileIndex++;
|
||||
}
|
||||
tileIndex += tileLineAdvance;
|
||||
|
|
|
@ -40,10 +40,12 @@
|
|||
|
||||
static int t1_init_ctxno_zc(int f, int orient) {
|
||||
int h, v, d, n, t, hv;
|
||||
n = 0;
|
||||
h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
|
||||
v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
|
||||
d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0);
|
||||
n = 0;
|
||||
t = 0;
|
||||
hv = 0;
|
||||
|
||||
switch (orient) {
|
||||
case 2:
|
||||
|
|
|
@ -868,9 +868,14 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
|||
|
||||
/* reset tagtrees */
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if ( ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) ) {
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
if (!(p_pi->precno < (l_band->precincts_data_size / sizeof(opj_tcd_precinct_t)))) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
||||
opj_tgt_reset(l_prc->incltree);
|
||||
opj_tgt_reset(l_prc->imsbtree);
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
|
|
|
@ -486,8 +486,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
|||
for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
|
||||
OPJ_FLOAT64 lo = min;
|
||||
OPJ_FLOAT64 hi = max;
|
||||
OPJ_BOOL success = OPJ_FALSE;
|
||||
OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
|
||||
OPJ_UINT32 maxlen = tcd_tcp->rates[layno] > 0.0f ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
|
||||
OPJ_FLOAT64 goodthresh = 0;
|
||||
OPJ_FLOAT64 stable_thresh = 0;
|
||||
OPJ_UINT32 i;
|
||||
|
@ -500,7 +499,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
|||
-r xx,yy,zz,0 (disto_alloc == 1 and rates == 0)
|
||||
-q xx,yy,zz,0 (fixed_quality == 1 and distoratio == 0)
|
||||
==> possible to have some lossy layers and the last layer for sure lossless */
|
||||
if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0))) {
|
||||
if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0.0f)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0.0))) {
|
||||
opj_t2_t*t2 = opj_t2_create(tcd->image, cp);
|
||||
OPJ_FLOAT64 thresh = 0;
|
||||
|
||||
|
@ -559,19 +558,13 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
|||
}
|
||||
}
|
||||
|
||||
success = OPJ_TRUE;
|
||||
goodthresh = stable_thresh == 0? thresh : stable_thresh;
|
||||
|
||||
opj_t2_destroy(t2);
|
||||
} else {
|
||||
success = OPJ_TRUE;
|
||||
goodthresh = min;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if(cstr_info) { /* Threshold for Marcela Index */
|
||||
cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
|
||||
}
|
||||
|
@ -727,7 +720,8 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
|||
|
||||
/* compute l_data_size with overflow check */
|
||||
l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
|
||||
if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0)) {
|
||||
/* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
|
||||
if ((l_data_size > 0U) && ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0))) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -778,7 +772,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
|||
l_tilec->resolutions_size = l_data_size;
|
||||
}
|
||||
|
||||
l_level_no = l_tilec->numresolutions - 1;
|
||||
l_level_no = l_tilec->numresolutions;
|
||||
l_res = l_tilec->resolutions;
|
||||
l_step_size = l_tccp->stepsizes;
|
||||
if (l_tccp->qmfbid == 0) {
|
||||
|
@ -795,6 +789,8 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
|||
OPJ_UINT32 cbgwidthexpn, cbgheightexpn;
|
||||
OPJ_UINT32 cblkwidthexpn, cblkheightexpn;
|
||||
|
||||
--l_level_no;
|
||||
|
||||
/* border for each resolution level (global) */
|
||||
l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
|
||||
l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
|
||||
|
@ -1024,7 +1020,6 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
|||
++l_step_size;
|
||||
} /* bandno */
|
||||
++l_res;
|
||||
--l_level_no;
|
||||
} /* resno */
|
||||
++l_tccp;
|
||||
++l_tilec;
|
||||
|
@ -1911,7 +1906,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd )
|
|||
}
|
||||
else {
|
||||
for (i = 0; i < l_nb_elem; ++i) {
|
||||
*l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) << 11 ;
|
||||
*l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) * (1 << 11);
|
||||
++l_current_ptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,9 @@ int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_privat
|
|||
|
||||
lenp = 0;
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)(cstr_info.tw*cstr_info.th), sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for ( i = 0; i < 2 ; i++ ){
|
||||
if (i)
|
||||
opj_stream_seek( cio, lenp, p_manager);
|
||||
|
|
|
@ -5,9 +5,9 @@ include_directories(
|
|||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||
)
|
||||
|
||||
SET(OPENJP3D_LIBRARY_NAME openjp3d)
|
||||
set(OPENJP3D_LIBRARY_NAME openjp3d)
|
||||
# Defines the source code for the library
|
||||
SET(OPENJP3D_SRCS
|
||||
set(OPENJP3D_SRCS
|
||||
bio.c cio.c dwt.c event.c jp3d.c jp3d_lib.c mct.c mqc.c openjp3d.c
|
||||
pi.c raw.c t1.c t1_3d.c t2.c tcd.c tgt.c volume.c
|
||||
)
|
||||
|
|
|
@ -36,6 +36,7 @@ set(OPENJPIP_SRCS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/opj_malloc.c
|
||||
)
|
||||
|
||||
set(SERVER_SRCS
|
||||
|
|
|
@ -58,7 +58,7 @@ install(TARGETS ${OPENMJ2_LIBRARY_NAME}
|
|||
)
|
||||
|
||||
# Install includes files
|
||||
#INSTALL(FILES mj2.h
|
||||
#install(FILES mj2.h
|
||||
# DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir}
|
||||
# COMPONENT Headers
|
||||
#)
|
||||
|
|
|
@ -877,6 +877,8 @@ int main(int argc, char **argv)
|
|||
|
||||
printf("<DartMeasurement name=\"NumberOfPixelsWithDifferences_%d\" type=\"numeric/int\"> %d </DartMeasurement> \n", it_comp, nbPixelDiff);
|
||||
printf("<DartMeasurement name=\"ComponentError_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, sumDiff);
|
||||
printf("<DartMeasurement name=\"PEAK_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, PEAK);
|
||||
printf("<DartMeasurement name=\"MSE_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, MSE);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBPNG
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ set(BLACKLIST_JPEG2000_TMP
|
|||
#edf_c2_20.jp2 #looks ok as per kdu_jp2info
|
||||
edf_c2_1377017.jp2
|
||||
edf_c2_1002767.jp2
|
||||
#edf_c2_10025.jp2
|
||||
edf_c2_10025.jp2
|
||||
edf_c2_1000234.jp2
|
||||
edf_c2_225881.jp2
|
||||
edf_c2_1000671.jp2
|
||||
|
@ -46,9 +46,11 @@ set(BLACKLIST_JPEG2000_TMP
|
|||
edf_c2_101463.jp2
|
||||
edf_c2_1674177.jp2
|
||||
edf_c2_1673169.jp2
|
||||
issue418.jp2
|
||||
issue429.jp2
|
||||
issue427-null-image-size.jp2
|
||||
issue427-illegal-tile-offset.jp2
|
||||
issue495.jp2
|
||||
)
|
||||
|
||||
# Define a list of file which should be gracefully rejected:
|
||||
|
|
|
@ -21,15 +21,15 @@ cccccccccccccccccccccccccccccccc issue104_jpxstream.jp2_2.pgx
|
|||
c74edbb49e132b2cfc1eaf7908197b17 issue134.jp2_0.pgx
|
||||
16fe8ed450da10a6aaae4cf6f467fc21 issue134.jp2_1.pgx
|
||||
c6091c07bf0ff221008dfb60d893cdff issue134.jp2_2.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_0.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_1.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 issue135.j2k_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 issue135.j2k_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da issue135.j2k_2.pgx
|
||||
aa7461b31e14641586803b23b7fb04f2 issue142.j2k_0.pgx
|
||||
a809006e7a0c1eed68bc86c96af43fe3 issue142.j2k_1.pgx
|
||||
74f7a7a194a74a947245b843c62c4054 issue142.j2k_2.pgx
|
||||
c44662b1f7fe01caa2ebf3ad62948e3e issue171.jp2_0.pgx
|
||||
f70e8a4e5dbefeb44d50edd79b6c4cf6 issue171.jp2_1.pgx
|
||||
18bc167a1c851db2fd9f8c7af3289134 issue171.jp2_2.pgx
|
||||
f9d1ada7f0f16c8c4f929217a1924416 issue171.jp2_0.pgx
|
||||
0d4a8507e226130bc44ef7de7e5539f6 issue171.jp2_1.pgx
|
||||
fde95f3c3bd8639b2258332eb6f658e4 issue171.jp2_2.pgx
|
||||
adda4f5e46845b96dd3df14a76aa7229 issue188_beach_64bitsbox.jp2_0.pgx
|
||||
90a9709c166019d1e101e7b96d257ed9 issue188_beach_64bitsbox.jp2_1.pgx
|
||||
37e23d2df06ee60bf0f9f5e1c16054d8 issue188_beach_64bitsbox.jp2_2.pgx
|
||||
|
@ -52,12 +52,12 @@ e58242abc2c6d44df187397c55e6fbff issue254.jp2_2.pgx
|
|||
ce4e556aaa0844b92a92c35c200fc43e j2k32.j2k_1.pgx
|
||||
ea926520f990640862f3fe6616097613 j2k32.j2k_2.pgx
|
||||
66b60e866991e03f9a2de18e80d3102b kakadu_v4-4_openjpegv2_broken.j2k_0.pgx
|
||||
12a8a4668315d9ae27969991251ce85f kodak_2layers_lrcp.j2c_0.pgx
|
||||
56d0b0c547d6d5bb12f0c36e88722b11 kodak_2layers_lrcp.j2c_1.pgx
|
||||
48ba092fb40090c160bbd08bdf7bdbf2 kodak_2layers_lrcp.j2c_2.pgx
|
||||
12a8a4668315d9ae27969991251ce85f kodak_2layers_lrcp-l2.j2c_0.pgx
|
||||
56d0b0c547d6d5bb12f0c36e88722b11 kodak_2layers_lrcp-l2.j2c_1.pgx
|
||||
48ba092fb40090c160bbd08bdf7bdbf2 kodak_2layers_lrcp-l2.j2c_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 kodak_2layers_lrcp.j2c_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 kodak_2layers_lrcp.j2c_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da kodak_2layers_lrcp.j2c_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 kodak_2layers_lrcp-l2.j2c_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 kodak_2layers_lrcp-l2.j2c_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da kodak_2layers_lrcp-l2.j2c_2.pgx
|
||||
05c062aca83d13b8095460f38a690a08 MarkerIsNotCompliant.j2k_0.pgx
|
||||
ff73d2bd32951d9e55b02186aac24aff Marrin.jp2_0.pgx
|
||||
55ce884dd2346af6a5172a434ee578fa Marrin.jp2_1.pgx
|
||||
|
@ -148,7 +148,7 @@ c494419005e8aae82f46d3f48da6caf1 p1_06.j2k.png
|
|||
6ae110e1fb5a869af3dbc5fbc735b0bd relax.jp2_0.pgx
|
||||
518a8f28dacc034982507f43763b88dd relax.jp2_1.pgx
|
||||
c678b04f4d3e59b9d66a8bce37c553c0 relax.jp2_2.pgx
|
||||
cdb1d69eb48ffd8545751326b86d9d7e test_lossless.j2k_0.pgx
|
||||
1090301e16fcfdecf3419bccad61cdeb test_lossless.j2k_0.pgx
|
||||
efc9c7f21a542a7888a9eeb73b0f7092 text_GBR.jp2_0.pgx
|
||||
54790b332b3dcbda28e1bcb31270b946 text_GBR.jp2_1.pgx
|
||||
d9bcbdc818febb8c0a6bc5f940a4ea85 text_GBR.jp2_2.pgx
|
||||
|
@ -163,7 +163,7 @@ a73bec4d6d82c8a64203e8fdf893b86d issue428.jp2_0.pgx
|
|||
8b96a253937c4c7dd6b41b4aa11367d9 issue414.jp2_2.pgx
|
||||
ec6886229ffaeaddfe22ce02b7a75e15 issue414.jp2_3.pgx
|
||||
6aa5c69c83d6f4d5d65968f34f9bc2a3 issue414.jp2_4.pgx
|
||||
00f34217ad2f88f4d4e1c5cd0d2c4329 issue399.j2k_0.pgx
|
||||
296038e047bb6aaf0e6652cb1b301e60 issue399.j2k_0.pgx
|
||||
d8fb69def2a48a3686483c4353544f4b issue411-ycc444.jp2_0.pgx
|
||||
d2911f75ed1758057f9b1bf26bcb2400 issue411-ycc444.jp2_1.pgx
|
||||
f7c23ee589ceda07ffb77a83018606cc issue411-ycc444.jp2_2.pgx
|
||||
|
@ -182,40 +182,68 @@ d33fb5dbddb9b9b4438eb51fa27445a3 issue495.jp2_0.pgx
|
|||
97da625d2f2d0b75bf891d8083ce8bfb issue495.jp2_2.pgx
|
||||
86729c5f2b74b2dfd42cb0d8e47aef79 a1_mono_tif-1.tif
|
||||
fa9b7b896536b25a7a1d8eeeacb59141 a1_mono_tif-10.tif
|
||||
e1f194f69d1c58ce8bed62cd4f1d5b6a a1_mono_tif-11.tif
|
||||
b0ee13aa90ca4421e09a3b7b41f410c0 a1_mono_tif-12.tif
|
||||
de53251a33356e206a793fbdbaf90db2 a1_mono_tif-13.tif
|
||||
4699894fedd3758727d8288cd7adb56c a1_mono_tif-14.tif
|
||||
012958af4207f4a779c0cdc9e18bc9be a1_mono_tif-15.tif
|
||||
4ad682c58e63d3223914c10a6656c8ae a1_mono_tif-16.tif
|
||||
22c2fa09a4d7b9fade6a3cddc6c6a4dc a1_mono_tif-2.tif
|
||||
7aea003d047d6c26475d0d257a0cfdfc a1_mono_tif-3.tif
|
||||
996c5e67a663218be90e86bff8ecad89 a1_mono_tif-4.tif
|
||||
0489a5d490588fa603a8e59af60ef8fc a1_mono_tif-5.tif
|
||||
7f451a5ac89915c5cdc023fd8c813a3c a1_mono_tif-6.tif
|
||||
e164a6c0219737ee05a3d55d6e3a3104 a1_mono_tif-7.tif
|
||||
c3ebfcf478b1c4fc786748813f2b5d53 a1_mono_tif-8.tif
|
||||
67adb084f1fe234f240a1d0b2698507e a1_mono_tif-9.tif
|
||||
31650ec40241737634179fff6ad306f8 basn4a08_tif-1.tif
|
||||
abf884080bcfbf58c044a9d86bfa5e5d basn4a08_tif-10.tif
|
||||
b0d82c12aa2c9b3ecd96c6a5b5663a8c basn4a08_tif-11.tif
|
||||
916d97c098d9792993cc91fee4a83f77 basn4a08_tif-12.tif
|
||||
90cabbb0f401b75dcfa64e4fbb987020 basn4a08_tif-13.tif
|
||||
57643174986481d336db6ddf04b970df basn4a08_tif-14.tif
|
||||
3cbf7868617a0dfdbeddd5c50ea96b31 basn4a08_tif-15.tif
|
||||
fb5cf848d63c61dc485c87c9246ee9c7 basn4a08_tif-16.tif
|
||||
5d7b01d98c82ad563bb28c2d83484a2a basn4a08_tif-2.tif
|
||||
7928de544e7d9731572a625beeb2b3ee basn4a08_tif-3.tif
|
||||
2401cebbb1d5494fcbe0d899484c342d basn4a08_tif-4.tif
|
||||
05ea9dfd48a6cd613bf935394988ec38 basn4a08_tif-5.tif
|
||||
6dbeb5b708bbde76e204c0887da61f6b basn4a08_tif-6.tif
|
||||
18a59ac6036ee64e92af19b7e3cd3d64 basn4a08_tif-7.tif
|
||||
dc40cc1da6de28e7e973c8ba796ca189 basn4a08_tif-8.tif
|
||||
824b776a5aa3459b77894b5f77621311 basn4a08_tif-9.tif
|
||||
59e32c45591fd3bb44fe99381a116ba1 basn6a08_tif-1.tif
|
||||
630e6fb6deba0b3efd93b610561d607a basn6a08_tif-10.tif
|
||||
5419fec92f0e0e5907d838dacf9712b4 basn6a08_tif-11.tif
|
||||
765555e75e59de27f7b2177d04f36bc1 basn6a08_tif-12.tif
|
||||
7d20d3e026fc1ac25be16dd44e9fb2e5 basn6a08_tif-13.tif
|
||||
62384c112d5fe40aefd0a9b0b9a4bcc6 basn6a08_tif-14.tif
|
||||
325de66e18e133f2ad865fc1faa20439 basn6a08_tif-15.tif
|
||||
d725d41557658a28ab31dff74e2467fa basn6a08_tif-16.tif
|
||||
96d91df6b10e866ea26ebbf0b8ddc7da basn6a08_tif-2.tif
|
||||
36690c1fe565b6efc229f5c7e486de31 basn6a08_tif-3.tif
|
||||
a324032339808d5fe85d6e354f14c183 basn6a08_tif-4.tif
|
||||
64dfb6af672ea8e890e24cfb208c6755 basn6a08_tif-5.tif
|
||||
d60864a6a5c8a49a202d98ae6f5165c7 basn6a08_tif-6.tif
|
||||
086fd12fec963995fe2e405dcef7e477 basn6a08_tif-7.tif
|
||||
c3e93f61125f82a9832d0b9440468034 basn6a08_tif-8.tif
|
||||
a9723dcc0732e74c9e8cd2bf93474a7d basn6a08_tif-9.tif
|
||||
cfe04d15cf9d615fc36357dcb3b3956b p0_14_tif-1.tif
|
||||
9ad87e7fddc77ac85e2e92509bee2365 p0_14_tif-10.tif
|
||||
f144e26d6d5aa24d98f0415f10751025 p0_14_tif-11.tif
|
||||
38e67f9d573e61166761d5eee0104448 p0_14_tif-12.tif
|
||||
4e804903537e4c52a7e4c15bd74eb15c p0_14_tif-13.tif
|
||||
77486f0468694b94290d0b55361498a0 p0_14_tif-14.tif
|
||||
2aa3211823a8ee41cc5061f401dfd52d p0_14_tif-15.tif
|
||||
51be675689949dd08b6ee1427af3eb4a p0_14_tif-16.tif
|
||||
3e34e94bd8f7380c8d159676fee9ea57 p0_14_tif-2.tif
|
||||
f623c6b98711ba8582f2b60620c6494a p0_14_tif-3.tif
|
||||
b6f71c941e3a5b8d2547792ccec58d54 p0_14_tif-4.tif
|
||||
5a8498d473cc57318ab9d216fdc5dcc9 p0_14_tif-5.tif
|
||||
81fcdd90917efb95aed94c6522d1c188 p0_14_tif-6.tif
|
||||
951c99efbd922d8f3feb015e9ef8e350 p0_14_tif-7.tif
|
||||
6808377b760b4ef3559ba8b14ed9b91a p0_14_tif-8.tif
|
||||
96aa7dafa873d0ce33f84bb1ff78fa9b p0_14_tif-9.tif
|
||||
dd15b3d487d36a3682be0679300a4319 issue235.jp2_0.pgx
|
||||
b9cd6dc76b141fb1fec15f50c1f70e01 issue235.jp2_1.pgx
|
||||
3edef2ae197ef30b08deda1b28825399 issue235.jp2_2.pgx
|
||||
|
@ -256,17 +284,18 @@ fc2844a9f3c8e924e349180ba9e122dd p0_14_png-2.png
|
|||
0c1cc85c051dd95394d06103c8d9bbef p0_14_png-6.png
|
||||
230e4968cb445b222ee2095014ba1d26 p0_14_png-8.png
|
||||
5a6131ad9ea5d191ffcdf6435be89cb4 v4dwt_interleave_h.gsr105.j2k_0.pgx
|
||||
4426ed46f75a45782c551d82818b9e60 dwt_interleave_h.gsr105.jp2_0.pgx
|
||||
382e7297e062d729a7a7726e964f1a0a dwt_interleave_h.gsr105.jp2_1.pgx
|
||||
64c1027db97421e348f823178b5d9c4b dwt_interleave_h.gsr105.jp2_2.pgx
|
||||
65e41ed91283b5e2f0c79ee1c867a86c dwt_interleave_h.gsr105.jp2_0.pgx
|
||||
8d7685f1569d446787476c0a56c93750 dwt_interleave_h.gsr105.jp2_1.pgx
|
||||
ddfff2ce2df4a9102518c92a362e6d25 dwt_interleave_h.gsr105.jp2_2.pgx
|
||||
63bf755af5a1f8a478d65079dc7c8964 issue205-tif.jp2.tif
|
||||
b01ed87dbac424bc820b2ac590e4884e issue236-ESYCC-CDEF.jp2_0.pgx
|
||||
2635cc00b1e18ef11adcba09e845d459 issue236-ESYCC-CDEF.jp2_1.pgx
|
||||
f9c95d0aec2f6e7b814fa1d09edcdbda issue236-ESYCC-CDEF.jp2_2.pgx
|
||||
5f0c1d5c5127c1eabb86a5e0112f139b issue559-eci-090-CIELab.jp2_0.pgx
|
||||
cdae87485eaada56be3671eec39452e6 issue559-eci-090-CIELab.jp2_1.pgx
|
||||
e163102afcc857cf001337178241f518 issue559-eci-090-CIELab.jp2_2.pgx
|
||||
b004b2e08b0dfb217c131b353cf157eb issue559-eci-091-CIELab.jp2_0.pgx
|
||||
2400da6b8ed6b1747b9913af544580f9 issue559-eci-091-CIELab.jp2_1.pgx
|
||||
cf73dda887967928dbcf5cc87ab204cc issue559-eci-091-CIELab.jp2_2.pgx
|
||||
4c3a5c669aaaa330134c7014b26ed06f issue559-eci-090-CIELab.jp2_0.pgx
|
||||
d6698c71d1ed3861edaadc430af928eb issue559-eci-090-CIELab.jp2_1.pgx
|
||||
04f3ec1fea6049769c43b1ac3b05794e issue559-eci-090-CIELab.jp2_2.pgx
|
||||
a190e10941e6145e69816c909f832c1a issue559-eci-091-CIELab.jp2_0.pgx
|
||||
3fccf3c7ecd3b9de46b94b53a1fa0362 issue559-eci-091-CIELab.jp2_1.pgx
|
||||
f3081c8e9e9a175f223382a7443b480f issue559-eci-091-CIELab.jp2_2.pgx
|
||||
3bf91c974abc17e520c6a5efa883a58a issue653-zero-unknownbox.jp2.png
|
||||
8d7a866d29d5c68dc540b0f0011959a5 issue726.png
|
||||
|
|
|
@ -137,6 +137,16 @@ opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp1n3p08.png -o @TEMP_PATH@/ftp1n3p08.
|
|||
# issue 571 Lossless is not lossless on linux x86
|
||||
opj_compress -i @INPUT_NR_PATH@/issue571.tif -o @TEMP_PATH@/issue571.tif.j2k
|
||||
|
||||
# issue 729 Allow to read 3/5/7/9/11/13/15 bpp tif files
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-03.tif -o @TEMP_PATH@/flower-minisblack-03.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-05.tif -o @TEMP_PATH@/flower-minisblack-05.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-07.tif -o @TEMP_PATH@/flower-minisblack-07.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-09.tif -o @TEMP_PATH@/flower-minisblack-09.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-11.tif -o @TEMP_PATH@/flower-minisblack-11.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-13.tif -o @TEMP_PATH@/flower-minisblack-13.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-15.tif -o @TEMP_PATH@/flower-minisblack-15.tif.jp2
|
||||
|
||||
|
||||
# DECODER TEST SUITE
|
||||
opj_decompress -i @INPUT_NR_PATH@/Bretagne2.j2k -o @TEMP_PATH@/Bretagne2.j2k.pgx
|
||||
opj_decompress -i @INPUT_NR_PATH@/_00042.j2k -o @TEMP_PATH@/_00042.j2k.pgx
|
||||
|
@ -328,7 +338,7 @@ opj_decompress -i @INPUT_NR_PATH@/issue458.jp2 -o @TEMP_PATH@/issue458.jp2.pgx
|
|||
# issue 475 Invalid number of layers
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue475.jp2 -o @TEMP_PATH@/issue475.jp2.pgx
|
||||
# issue 495 Overflow op_image_comp_header_updat
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue495.jp2 -o @TEMP_PATH@/issue495.jp2.pgx
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue495.jp2 -o @TEMP_PATH@/issue495.jp2.pgx
|
||||
|
||||
|
||||
# decode with specific area
|
||||
|
@ -508,3 +518,49 @@ opj_decompress -i @INPUT_NR_PATH@/issue559-eci-091-CIELab.jp2 -o @TEMP_PATH@/iss
|
|||
|
||||
# issue 653 Last box of undefined size byg
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue653-zero-unknownbox.jp2 -o @TEMP_PATH@/issue653-zero-unknownbox.jp2.png -p 8S
|
||||
|
||||
# issue 729 decompress 3/5/7/9/11/13/15 bits precision to tiff
|
||||
# GRAYSCALE
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-15.tif -p 15S
|
||||
# GRAYSCALE ALPHA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-15.tif -p 15S
|
||||
# RGB
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-15.tif -p 15S
|
||||
# RGBA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-15.tif -p 15S
|
||||
|
||||
# issue 725
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue725.jp2 -o @TEMP_PATH@/issue725.png
|
||||
# issue 726
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue726.j2k -o @TEMP_PATH@/issue726.png
|
||||
# issue 733
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue733.jp2 -o @TEMP_PATH@/issue733.png
|
||||
# issue 774
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue774.jp2 -o @TEMP_PATH@/issue774.png
|
||||
# issue 775
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue775.j2k -o @TEMP_PATH@/issue775.png
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue775-2.j2k -o @TEMP_PATH@/issue775-2.png
|
||||
|
|
|
@ -129,7 +129,9 @@ int main (int argc, char *argv[])
|
|||
l_data_size = (OPJ_UINT32)tile_width * (OPJ_UINT32)tile_height * (OPJ_UINT32)num_comps * (OPJ_UINT32)(comp_prec/8);
|
||||
|
||||
l_data = (OPJ_BYTE*) malloc(l_data_size * sizeof(OPJ_BYTE));
|
||||
|
||||
if(l_data == NULL){
|
||||
return 1;
|
||||
}
|
||||
fprintf(stdout, "Encoding random values -> keep in mind that this is very hard to compress\n");
|
||||
for (i=0;i<l_data_size;++i) {
|
||||
l_data[i] = (OPJ_BYTE)i; /*rand();*/
|
||||
|
@ -236,6 +238,7 @@ int main (int argc, char *argv[])
|
|||
l_codec = opj_create_compress(OPJ_CODEC_J2K);
|
||||
}
|
||||
if (!l_codec) {
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -246,6 +249,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
l_image = opj_image_tile_create(num_comps,l_params,OPJ_CLRSPC_SRGB);
|
||||
if (! l_image) {
|
||||
free(l_data);
|
||||
opj_destroy_codec(l_codec);
|
||||
return 1;
|
||||
}
|
||||
|
@ -260,6 +264,7 @@ int main (int argc, char *argv[])
|
|||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to setup the codec!\n");
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -268,6 +273,7 @@ int main (int argc, char *argv[])
|
|||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the stream from the output file %s !\n",output_file );
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -276,6 +282,7 @@ int main (int argc, char *argv[])
|
|||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -285,6 +292,7 @@ int main (int argc, char *argv[])
|
|||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +302,7 @@ int main (int argc, char *argv[])
|
|||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,117 +2,117 @@
|
|||
|
||||
#------------
|
||||
# Try to find lib Z
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build Z lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libz)
|
||||
SET(Z_LIBNAME z PARENT_SCOPE)
|
||||
SET(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)
|
||||
SET(ZLIB_FOUND 1)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
add_subdirectory(libz)
|
||||
set(Z_LIBNAME z PARENT_SCOPE)
|
||||
set(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)
|
||||
set(ZLIB_FOUND 1)
|
||||
else(BUILD_THIRDPARTY)
|
||||
# Try to find lib Z
|
||||
FIND_PACKAGE(ZLIB)
|
||||
IF(ZLIB_FOUND)
|
||||
SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
|
||||
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
set(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
|
||||
set(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
message(STATUS "Your system seems to have a Z lib available, we will use it to generate PNG lib")
|
||||
# message(STATUS "DEBUG: ${ZLIB_INCLUDE_DIRS} vs ${ZLIB_INCLUDE_DIR}")
|
||||
ELSE (ZLIB_FOUND) # not found
|
||||
else(ZLIB_FOUND) # not found
|
||||
message(STATUS "Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
|
||||
ENDIF(ZLIB_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(ZLIB_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
|
||||
#------------
|
||||
# Try to find lib PNG (which depends on zlib)
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build PNG lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libpng)
|
||||
SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
SET(PNG_LIBNAME png PARENT_SCOPE)
|
||||
SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
IF (ZLIB_FOUND)
|
||||
FIND_PACKAGE(PNG)
|
||||
IF(PNG_FOUND)
|
||||
add_subdirectory(libpng)
|
||||
set(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
set(PNG_LIBNAME png PARENT_SCOPE)
|
||||
set(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
if(ZLIB_FOUND)
|
||||
find_package(PNG)
|
||||
if(PNG_FOUND)
|
||||
message(STATUS "Your system seems to have a PNG lib available, we will use it")
|
||||
SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
|
||||
SET(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE)
|
||||
ELSE(PNG_FOUND) # not found
|
||||
SET(OPJ_HAVE_PNG_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
set(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
|
||||
set(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE)
|
||||
else(PNG_FOUND) # not found
|
||||
set(OPJ_HAVE_PNG_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 0 PARENT_SCOPE)
|
||||
message(STATUS "PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF(PNG_FOUND)
|
||||
ENDIF (ZLIB_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(PNG_FOUND)
|
||||
endif(ZLIB_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
#------------
|
||||
# Try to find lib TIFF
|
||||
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build TIFF lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libtiff)
|
||||
SET(TIFF_LIBNAME tiff PARENT_SCOPE)
|
||||
SET(TIFF_INCLUDE_DIRNAME
|
||||
add_subdirectory(libtiff)
|
||||
set(TIFF_LIBNAME tiff PARENT_SCOPE)
|
||||
set(TIFF_INCLUDE_DIRNAME
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff
|
||||
${OPENJPEG_BINARY_DIR}/thirdparty/libtiff
|
||||
PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
FIND_PACKAGE(TIFF)
|
||||
IF(TIFF_FOUND)
|
||||
set(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
find_package(TIFF)
|
||||
if(TIFF_FOUND)
|
||||
message(STATUS "Your system seems to have a TIFF lib available, we will use it")
|
||||
SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
|
||||
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
|
||||
ELSE (TIFF_FOUND) # not found
|
||||
SET(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
set(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
|
||||
set(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
|
||||
else(TIFF_FOUND) # not found
|
||||
set(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
|
||||
message(STATUS "TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF(TIFF_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(TIFF_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
#------------
|
||||
# Try to find lib LCMS2 (or by default LCMS)
|
||||
SET(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
|
||||
|
||||
IF( BUILD_THIRDPARTY)
|
||||
if( BUILD_THIRDPARTY)
|
||||
# Try to build lcms2
|
||||
message(STATUS "We will build LCMS2 lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(liblcms2)
|
||||
SET(LCMS_LIBNAME lcms2 PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
|
||||
SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
FIND_PACKAGE(LCMS2)
|
||||
IF(LCMS2_FOUND)
|
||||
add_subdirectory(liblcms2)
|
||||
set(LCMS_LIBNAME lcms2 PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
|
||||
set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
find_package(LCMS2)
|
||||
if(LCMS2_FOUND)
|
||||
message(STATUS "Your system seems to have a LCMS2 lib available, we will use it")
|
||||
SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
ELSE (LCMS2_FOUND) # not found lcms2
|
||||
set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
set(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
else(LCMS2_FOUND) # not found lcms2
|
||||
# try to find LCMS
|
||||
FIND_PACKAGE(LCMS)
|
||||
IF(LCMS_FOUND)
|
||||
find_package(LCMS)
|
||||
if(LCMS_FOUND)
|
||||
message(STATUS "Your system seems to have a LCMS lib available, we will use it")
|
||||
SET(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
|
||||
SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
ELSE (LCMS_FOUND) # not found lcms
|
||||
SET(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
|
||||
set(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
else(LCMS_FOUND) # not found lcms
|
||||
set(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
|
||||
message(STATUS "LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF (LCMS_FOUND)
|
||||
ENDIF(LCMS2_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(LCMS_FOUND)
|
||||
endif(LCMS2_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
PROJECT(liblcms2 C)
|
||||
project(liblcms2 C)
|
||||
#
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
#
|
||||
FILE(GLOB SRCS src/*.c)
|
||||
FILE(GLOB HDRS include/*.h)
|
||||
file(GLOB SRCS src/*.c)
|
||||
file(GLOB HDRS include/*.h)
|
||||
#
|
||||
SET(LIBTARGET "lcms2")
|
||||
set(LIBTARGET "lcms2")
|
||||
#
|
||||
ADD_LIBRARY(${LIBTARGET} STATIC ${SRCS} ${HDRS})
|
||||
add_library(${LIBTARGET} STATIC ${SRCS} ${HDRS})
|
||||
#
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
ENDIF(MSVC)
|
||||
if(MSVC)
|
||||
set_target_properties(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
endif(MSVC)
|
||||
#
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET}
|
||||
set_target_properties(${LIBTARGET}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${LIBTARGET}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/lib)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Little CMS
|
||||
Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Version 2.6
|
||||
// Version 2.8beta0
|
||||
//
|
||||
|
||||
#ifndef _lcms2_H
|
||||
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
// Version/release
|
||||
#define LCMS_VERSION 2060
|
||||
#define LCMS_VERSION 2080
|
||||
|
||||
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
|
||||
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
|
||||
|
@ -173,9 +173,21 @@ typedef int cmsBool;
|
|||
# define CMS_IS_WINDOWS_ 1
|
||||
#endif
|
||||
|
||||
// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
|
||||
// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
|
||||
// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
|
||||
// on Unix-like systems, and allow it to be set on the compiler command line using
|
||||
// -DCMS_USE_BIG_ENDIAN or something similar
|
||||
#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
|
||||
|
||||
# if CMS_USE_BIG_ENDIAN == 0
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
|
||||
#else // CMS_USE_BIG_ENDIAN
|
||||
|
||||
# ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# else // WORDS_BIGENDIAN
|
||||
// Fall back to platform/compiler specific tests
|
||||
# if defined(__sgi__) || defined(__sgi) || defined(sparc)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
@ -184,27 +196,6 @@ typedef int cmsBool;
|
|||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
||||
# ifdef TARGET_CPU_PPC
|
||||
# if TARGET_CPU_PPC
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
// // Don't use big endian for PowerPC little endian mode
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// WORDS_BIGENDIAN takes precedence
|
||||
#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
# ifdef macintosh
|
||||
# ifdef __BIG_ENDIAN__
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
|
@ -213,6 +204,14 @@ typedef int cmsBool;
|
|||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
# endif // WORDS_BIGENDIAN
|
||||
|
||||
# if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
||||
#endif // CMS_USE_BIG_ENDIAN
|
||||
|
||||
|
||||
// Calling convention -- this is hardly platform and compiler dependent
|
||||
#ifdef CMS_IS_WINDOWS_
|
||||
|
@ -221,7 +220,7 @@ typedef int cmsBool;
|
|||
# define CMSEXPORT __stdcall _export
|
||||
# define CMSAPI
|
||||
# else
|
||||
# define CMSEXPORT _stdcall
|
||||
# define CMSEXPORT __stdcall
|
||||
# ifdef CMS_DLL_BUILD
|
||||
# define CMSAPI __declspec(dllexport)
|
||||
# else
|
||||
|
@ -383,7 +382,8 @@ typedef enum {
|
|||
cmsSigViewingCondDescTag = 0x76756564, // 'vued'
|
||||
cmsSigViewingConditionsTag = 0x76696577, // 'view'
|
||||
cmsSigVcgtTag = 0x76636774, // 'vcgt'
|
||||
cmsSigMetaTag = 0x6D657461 // 'meta'
|
||||
cmsSigMetaTag = 0x6D657461, // 'meta'
|
||||
cmsSigArgyllArtsTag = 0x61727473 // 'arts'
|
||||
|
||||
} cmsTagSignature;
|
||||
|
||||
|
@ -524,7 +524,8 @@ typedef enum {
|
|||
cmsSigLab2FloatPCS = 0x64326C20, // 'd2l '
|
||||
cmsSigFloatPCS2Lab = 0x6C326420, // 'l2d '
|
||||
cmsSigXYZ2FloatPCS = 0x64327820, // 'd2x '
|
||||
cmsSigFloatPCS2XYZ = 0x78326420 // 'x2d '
|
||||
cmsSigFloatPCS2XYZ = 0x78326420, // 'x2d '
|
||||
cmsSigClipNegativesElemType = 0x636c7020 // 'clp '
|
||||
|
||||
} cmsStageSignature;
|
||||
|
||||
|
@ -898,7 +899,7 @@ typedef void* cmsHTRANSFORM;
|
|||
#define TYPE_ARGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1))
|
||||
#define TYPE_BGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
#define TYPE_BGRA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
|
||||
#define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
#define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
|
||||
#define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
|
||||
|
||||
|
@ -1002,6 +1003,10 @@ typedef struct {
|
|||
|
||||
} cmsICCViewingConditions;
|
||||
|
||||
// Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
|
||||
|
||||
CMSAPI int CMSEXPORT cmsGetEncodedCMMversion(void);
|
||||
|
||||
// Support of non-standard functions --------------------------------------------------------------------------------------
|
||||
|
||||
CMSAPI int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
|
||||
|
@ -1480,7 +1485,7 @@ CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignat
|
|||
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
|
||||
|
||||
// Build a suitable formatter for the colorspace of this profile
|
||||
// Build a suitable formatter for the colorspace of this profile. nBytes=1 means 8 bits, nBytes=2 means 16 bits.
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
|
||||
|
||||
|
@ -1509,6 +1514,7 @@ CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID
|
|||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile);
|
||||
CMSAPI cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io);
|
||||
|
||||
// MD5 message digest --------------------------------------------------------------------------------------------------
|
||||
|
@ -1643,6 +1649,12 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID
|
|||
#define cmsFLAGS_CLUT_POST_LINEARIZATION 0x0001 // create postlinearization tables if possible
|
||||
#define cmsFLAGS_CLUT_PRE_LINEARIZATION 0x0010 // create prelinearization tables if possible
|
||||
|
||||
// Specific to unbounded mode
|
||||
#define cmsFLAGS_NONEGATIVES 0x8000 // Prevent negative numbers in floating point transforms
|
||||
|
||||
// Copy alpha channels when transforming
|
||||
#define cmsFLAGS_COPY_ALPHA 0x04000000 // Alpha channels are copied on cmsDoTransform()
|
||||
|
||||
// Fine-tune control over number of gridpoints
|
||||
#define cmsFLAGS_GRIDPOINTS(n) (((n) & 0xFF) << 16)
|
||||
|
||||
|
@ -1720,12 +1732,22 @@ CMSAPI void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
|
|||
void * OutputBuffer,
|
||||
cmsUInt32Number Size);
|
||||
|
||||
CMSAPI void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
|
||||
CMSAPI void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform, // Deprecated
|
||||
const void * InputBuffer,
|
||||
void * OutputBuffer,
|
||||
cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride);
|
||||
|
||||
CMSAPI void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
cmsUInt32Number BytesPerLineIn,
|
||||
cmsUInt32Number BytesPerLineOut,
|
||||
cmsUInt32Number BytesPerPlaneIn,
|
||||
cmsUInt32Number BytesPerPlaneOut);
|
||||
|
||||
|
||||
CMSAPI void CMSEXPORT cmsSetAlarmCodes(const cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
|
||||
CMSAPI void CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -571,11 +571,28 @@ typedef struct {
|
|||
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// Full xform
|
||||
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo,
|
||||
|
||||
typedef struct {
|
||||
cmsUInt32Number BytesPerLineIn;
|
||||
cmsUInt32Number BytesPerLineOut;
|
||||
cmsUInt32Number BytesPerPlaneIn;
|
||||
cmsUInt32Number BytesPerPlaneOut;
|
||||
|
||||
} cmsStride;
|
||||
|
||||
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // Legacy function, handles just ONE scanline.
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride);
|
||||
cmsUInt32Number Stride); // Stride in bytes to the next plana in planar formats
|
||||
|
||||
|
||||
typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride);
|
||||
|
||||
typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
|
||||
void** UserData,
|
||||
|
@ -585,6 +602,14 @@ typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
|
|||
cmsUInt32Number* OutputFormat,
|
||||
cmsUInt32Number* dwFlags);
|
||||
|
||||
typedef cmsBool (* _cmsTransform2Factory)(_cmsTransform2Fn* xform,
|
||||
void** UserData,
|
||||
_cmsFreeUserDataFn* FreePrivateDataFn,
|
||||
cmsPipeline** Lut,
|
||||
cmsUInt32Number* InputFormat,
|
||||
cmsUInt32Number* OutputFormat,
|
||||
cmsUInt32Number* dwFlags);
|
||||
|
||||
|
||||
// Retrieve user data as specified by the factory
|
||||
CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
|
||||
|
@ -599,7 +624,10 @@ typedef struct {
|
|||
cmsPluginBase base;
|
||||
|
||||
// Transform entry point
|
||||
_cmsTransformFactory Factory;
|
||||
union {
|
||||
_cmsTransformFactory legacy_xform;
|
||||
_cmsTransform2Factory xform;
|
||||
} factories;
|
||||
|
||||
} cmsPluginTransform;
|
||||
|
||||
|
|
|
@ -0,0 +1,481 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "lcms2_internal.h"
|
||||
|
||||
|
||||
// Alpha copy ------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Floor to byte, taking care of saturation
|
||||
cmsINLINE cmsUInt8Number _cmsQuickSaturateByte(cmsFloat64Number d)
|
||||
{
|
||||
d += 0.5;
|
||||
if (d <= 0) return 0;
|
||||
if (d >= 255.0) return 255;
|
||||
|
||||
return (cmsUInt8Number) _cmsQuickFloorWord(d);
|
||||
}
|
||||
|
||||
|
||||
// Return the size in bytes of a given formatter
|
||||
static
|
||||
int trueBytesSize(cmsUInt32Number Format)
|
||||
{
|
||||
int fmt_bytes = T_BYTES(Format);
|
||||
|
||||
// For double, the T_BYTES field returns zero
|
||||
if (fmt_bytes == 0)
|
||||
return sizeof(double);
|
||||
|
||||
// Otherwise, it is already correct for all formats
|
||||
return fmt_bytes;
|
||||
}
|
||||
|
||||
|
||||
// Several format converters
|
||||
|
||||
typedef void(*cmsFormatterAlphaFn)(void* dst, const void* src);
|
||||
|
||||
|
||||
// From 8
|
||||
|
||||
static
|
||||
void copy8(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, 1);
|
||||
}
|
||||
|
||||
static
|
||||
void from8to16(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt8Number n = *(cmsUInt8Number*)src;
|
||||
*(cmsUInt16Number*) dst = FROM_8_TO_16(n);
|
||||
}
|
||||
|
||||
static
|
||||
void from8toFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (*(cmsUInt8Number*)src) / 255.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from8toDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (*(cmsUInt8Number*)src) / 255.0;
|
||||
}
|
||||
|
||||
static
|
||||
void from8toHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (*(cmsUInt8Number*)src) / 255.0f;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
// From 16
|
||||
|
||||
static
|
||||
void from16to8(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt16Number n = *(cmsUInt16Number*)src;
|
||||
*(cmsUInt8Number*) dst = FROM_16_TO_8(n);
|
||||
}
|
||||
|
||||
static
|
||||
void copy16(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, 2);
|
||||
}
|
||||
|
||||
void from16toFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
void from16toDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16toHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
// From Float
|
||||
|
||||
static
|
||||
void fromFLTto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void copy32(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, sizeof(cmsFloat32Number));
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTtoDBL(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)n;
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTtoHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
|
||||
// From HALF
|
||||
|
||||
static
|
||||
void fromHLFto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFtoFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFtoDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)_cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
}
|
||||
|
||||
// From double
|
||||
static
|
||||
void fromDBLto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLtoFLT(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsFloat32Number*)dst = (cmsFloat32Number) n;
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLtoHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (cmsFloat32Number) *(cmsFloat64Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
static
|
||||
void copy64(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, sizeof(cmsFloat64Number));
|
||||
}
|
||||
|
||||
|
||||
// Returns the position (x or y) of the formatter in the table of functions
|
||||
static
|
||||
int FormatterPos(cmsUInt32Number frm)
|
||||
{
|
||||
int b = T_BYTES(frm);
|
||||
|
||||
if (b == 0 && T_FLOAT(frm))
|
||||
return 4; // DBL
|
||||
if (b == 2 && T_FLOAT(frm))
|
||||
return 2; // HLF
|
||||
if (b == 4 && T_FLOAT(frm))
|
||||
return 3; // FLT
|
||||
if (b == 2 && !T_FLOAT(frm))
|
||||
return 1; // 16
|
||||
if (b == 1 && !T_FLOAT(frm))
|
||||
return 0; // 8
|
||||
|
||||
return -1; // not recognized
|
||||
|
||||
}
|
||||
|
||||
// Obtains a alpha-to-alpha funmction formatter
|
||||
static
|
||||
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
|
||||
{
|
||||
static cmsFormatterAlphaFn FormattersAlpha[5][5] = {
|
||||
|
||||
/* from 8 */ { copy8, from8to16, from8toHLF, from8toFLT, from8toDBL },
|
||||
/* from 16*/ { from16to8, copy16, from16toHLF, from16toFLT, from16toDBL },
|
||||
/* from HLF*/ { fromHLFto8, fromHLFto16, copy16, fromHLFtoFLT, fromHLFtoDBL },
|
||||
/* from FLT*/ { fromFLTto8, fromFLTto16, fromFLTtoHLF, copy32, fromFLTtoDBL },
|
||||
/* from DBL*/ { fromDBLto8, fromDBLto16, fromDBLtoHLF, fromDBLtoFLT, copy64 }};
|
||||
|
||||
int in_n = FormatterPos(in);
|
||||
int out_n = FormatterPos(out);
|
||||
|
||||
if (in_n < 0 || out_n < 0 || in_n > 4 || out_n > 4) {
|
||||
|
||||
cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized alpha channel width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return FormattersAlpha[in_n][out_n];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function computes the distance from each component to the next one in bytes.
|
||||
static
|
||||
void ComputeIncrementsForChunky(cmsUInt32Number Format,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
cmsUInt32Number channels[cmsMAXCHANNELS];
|
||||
int extra = T_EXTRA(Format);
|
||||
int nchannels = T_CHANNELS(Format);
|
||||
int total_chans = nchannels + extra;
|
||||
int i;
|
||||
int channelSize = trueBytesSize(Format);
|
||||
int pixelSize = channelSize * total_chans;
|
||||
|
||||
// Sanity check
|
||||
if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
|
||||
return;
|
||||
|
||||
memset(channels, 0, sizeof(channels));
|
||||
|
||||
// Separation is independent of starting point and only depends on channel size
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentPointerIncrements[i] = pixelSize;
|
||||
|
||||
// Handle do swap
|
||||
for (i = 0; i < total_chans; i++)
|
||||
{
|
||||
if (T_DOSWAP(Format)) {
|
||||
channels[i] = total_chans - i - 1;
|
||||
}
|
||||
else {
|
||||
channels[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
|
||||
if (T_SWAPFIRST(Format) && total_chans > 1) {
|
||||
|
||||
cmsUInt32Number tmp = channels[0];
|
||||
for (i = 0; i < total_chans-1; i++)
|
||||
channels[i] = channels[i + 1];
|
||||
|
||||
channels[total_chans - 1] = tmp;
|
||||
}
|
||||
|
||||
// Handle size
|
||||
if (channelSize > 1)
|
||||
for (i = 0; i < total_chans; i++) {
|
||||
channels[i] *= channelSize;
|
||||
}
|
||||
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentStartingOrder[i] = channels[i + nchannels];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// On planar configurations, the distance is the stride added to any non-negative
|
||||
static
|
||||
void ComputeIncrementsForPlanar(cmsUInt32Number Format,
|
||||
cmsUInt32Number BytesPerPlane,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
cmsUInt32Number channels[cmsMAXCHANNELS];
|
||||
int extra = T_EXTRA(Format);
|
||||
int nchannels = T_CHANNELS(Format);
|
||||
int total_chans = nchannels + extra;
|
||||
int i;
|
||||
int channelSize = trueBytesSize(Format);
|
||||
|
||||
// Sanity check
|
||||
if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
|
||||
return;
|
||||
|
||||
memset(channels, 0, sizeof(channels));
|
||||
|
||||
// Separation is independent of starting point and only depends on channel size
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentPointerIncrements[i] = channelSize;
|
||||
|
||||
// Handle do swap
|
||||
for (i = 0; i < total_chans; i++)
|
||||
{
|
||||
if (T_DOSWAP(Format)) {
|
||||
channels[i] = total_chans - i - 1;
|
||||
}
|
||||
else {
|
||||
channels[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
|
||||
if (T_SWAPFIRST(Format) && total_chans > 0) {
|
||||
|
||||
cmsUInt32Number tmp = channels[0];
|
||||
for (i = 0; i < total_chans - 1; i++)
|
||||
channels[i] = channels[i + 1];
|
||||
|
||||
channels[total_chans - 1] = tmp;
|
||||
}
|
||||
|
||||
// Handle size
|
||||
for (i = 0; i < total_chans; i++) {
|
||||
channels[i] *= BytesPerPlane;
|
||||
}
|
||||
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentStartingOrder[i] = channels[i + nchannels];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Dispatcher por chunky and planar RGB
|
||||
static
|
||||
void ComputeComponentIncrements(cmsUInt32Number Format,
|
||||
cmsUInt32Number BytesPerPlane,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
if (T_PLANAR(Format)) {
|
||||
|
||||
ComputeIncrementsForPlanar(Format, BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
|
||||
}
|
||||
else {
|
||||
ComputeIncrementsForChunky(Format, ComponentStartingOrder, ComponentPointerIncrements);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handles extra channels copying alpha if requested by the flags
|
||||
void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
size_t i, j, k;
|
||||
cmsUInt32Number nExtra;
|
||||
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
|
||||
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
|
||||
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
|
||||
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
|
||||
cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
|
||||
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];
|
||||
|
||||
cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
|
||||
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];
|
||||
|
||||
cmsFormatterAlphaFn copyValueFn;
|
||||
|
||||
// Make sure we need some copy
|
||||
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
|
||||
return;
|
||||
|
||||
// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
|
||||
nExtra = T_EXTRA(p->InputFormat);
|
||||
if (nExtra != T_EXTRA(p->OutputFormat))
|
||||
return;
|
||||
|
||||
// Anything to do?
|
||||
if (nExtra == 0)
|
||||
return;
|
||||
|
||||
// Compute the increments
|
||||
ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
|
||||
ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);
|
||||
|
||||
// Check for conversions 8, 16, half, float, dbl
|
||||
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
|
||||
|
||||
memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
|
||||
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
|
||||
|
||||
// The loop itself
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
// Prepare pointers for the loop
|
||||
for (j = 0; j < nExtra; j++) {
|
||||
|
||||
SourcePtr[j] = (cmsUInt8Number*)in + SourceStartingOrder[j] + SourceStrideIncrements[j];
|
||||
DestPtr[j] = (cmsUInt8Number*)out + DestStartingOrder[j] + DestStrideIncrements[j];
|
||||
}
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
for (k = 0; k < nExtra; k++) {
|
||||
|
||||
copyValueFn(DestPtr[k], SourcePtr[k]);
|
||||
|
||||
SourcePtr[k] += SourceIncrements[k];
|
||||
DestPtr[k] += DestIncrements[k];
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < nExtra; j++) {
|
||||
|
||||
SourceStrideIncrements[j] += Stride->BytesPerLineIn;
|
||||
DestStrideIncrements[j] += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -48,7 +48,7 @@
|
|||
// Symbols
|
||||
typedef enum {
|
||||
|
||||
SNONE,
|
||||
SUNDEFINED,
|
||||
SINUM, // Integer
|
||||
SDNUM, // Real
|
||||
SIDENT, // Identifier
|
||||
|
@ -324,7 +324,7 @@ static const char* PredefinedSampleID[] = {
|
|||
"XYZ_X", // X component of tristimulus data
|
||||
"XYZ_Y", // Y component of tristimulus data
|
||||
"XYZ_Z", // Z component of tristimulus data
|
||||
"XYY_X" // x component of chromaticity data
|
||||
"XYY_X", // x component of chromaticity data
|
||||
"XYY_Y", // y component of chromaticity data
|
||||
"XYY_CAPY", // Y component of tristimulus data
|
||||
"LAB_L", // L* component of Lab data
|
||||
|
@ -521,7 +521,7 @@ SYMBOL BinSrchKey(const char *id)
|
|||
else l = x + 1;
|
||||
}
|
||||
|
||||
return SNONE;
|
||||
return SUNDEFINED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -706,7 +706,7 @@ void InSymbol(cmsIT8* it8)
|
|||
|
||||
|
||||
key = BinSrchKey(it8->id);
|
||||
if (key == SNONE) it8->sy = SIDENT;
|
||||
if (key == SUNDEFINED) it8->sy = SIDENT;
|
||||
else it8->sy = key;
|
||||
|
||||
}
|
||||
|
@ -801,11 +801,11 @@ void InSymbol(cmsIT8* it8)
|
|||
|
||||
if (it8 ->sy == SINUM) {
|
||||
|
||||
sprintf(it8->id, "%d", it8->inum);
|
||||
snprintf(it8->id, 127, "%d", it8->inum);
|
||||
}
|
||||
else {
|
||||
|
||||
sprintf(it8->id, it8 ->DoubleFormatter, it8->dnum);
|
||||
snprintf(it8->id, 127, it8 ->DoubleFormatter, it8->dnum);
|
||||
}
|
||||
|
||||
k = (int) strlen(it8 ->id);
|
||||
|
@ -1297,7 +1297,7 @@ cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID)
|
|||
it8->ValidKeywords = NULL;
|
||||
it8->ValidSampleID = NULL;
|
||||
|
||||
it8 -> sy = SNONE;
|
||||
it8 -> sy = SUNDEFINED;
|
||||
it8 -> ch = ' ';
|
||||
it8 -> Source = NULL;
|
||||
it8 -> inum = 0;
|
||||
|
@ -1363,7 +1363,7 @@ cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFlo
|
|||
cmsIT8* it8 = (cmsIT8*) hIT8;
|
||||
char Buffer[1024];
|
||||
|
||||
sprintf(Buffer, it8->DoubleFormatter, Val);
|
||||
snprintf(Buffer, 1023, it8->DoubleFormatter, Val);
|
||||
|
||||
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_UNCOOKED) != NULL;
|
||||
}
|
||||
|
@ -1373,7 +1373,7 @@ cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUIn
|
|||
cmsIT8* it8 = (cmsIT8*) hIT8;
|
||||
char Buffer[1024];
|
||||
|
||||
sprintf(Buffer, "%u", Val);
|
||||
snprintf(Buffer, 1023, "%u", Val);
|
||||
|
||||
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_HEXADECIMAL) != NULL;
|
||||
}
|
||||
|
@ -2516,9 +2516,11 @@ int LocateSample(cmsIT8* it8, const char* cSample)
|
|||
for (i=0; i < t->nSamples; i++) {
|
||||
|
||||
fld = GetDataFormat(it8, i);
|
||||
if (fld != NULL) {
|
||||
if (cmsstrcasecmp(fld, cSample) == 0)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
|
@ -2575,7 +2577,7 @@ cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col, cmsFl
|
|||
|
||||
_cmsAssert(hIT8 != NULL);
|
||||
|
||||
sprintf(Buff, it8->DoubleFormatter, Val);
|
||||
snprintf(Buff, 255, it8->DoubleFormatter, Val);
|
||||
|
||||
return SetData(it8, row, col, Buff);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -269,6 +269,9 @@ cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
|
|||
{
|
||||
cmsMAT3 Scale, m1, m2, m3, m4;
|
||||
|
||||
// TODO: Follow Marc Mahy's recommendation to check if CHAD is same by using M1*M2 == M2*M1. If so, do nothing.
|
||||
// TODO: Add support for ArgyllArts tag
|
||||
|
||||
// Adaptation state
|
||||
if (AdaptationState == 1.0) {
|
||||
|
||||
|
@ -530,7 +533,7 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
|||
cmsHPROFILE hProfile;
|
||||
cmsMAT3 m;
|
||||
cmsVEC3 off;
|
||||
cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut, CurrentColorSpace;
|
||||
cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut = cmsSigLabData, CurrentColorSpace;
|
||||
cmsProfileClassSignature ClassSig;
|
||||
cmsUInt32Number i, Intent;
|
||||
|
||||
|
@ -632,6 +635,22 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
|||
CurrentColorSpace = ColorSpaceOut;
|
||||
}
|
||||
|
||||
// Check for non-negatives clip
|
||||
if (dwFlags & cmsFLAGS_NONEGATIVES) {
|
||||
|
||||
if (ColorSpaceOut == cmsSigGrayData ||
|
||||
ColorSpaceOut == cmsSigRgbData ||
|
||||
ColorSpaceOut == cmsSigCmykData) {
|
||||
|
||||
cmsStage* clip = _cmsStageClipNegatives(Result->ContextID, cmsChannelsOf(ColorSpaceOut));
|
||||
if (clip == NULL) goto Error;
|
||||
|
||||
if (!cmsPipelineInsertStage(Result, cmsAT_END, clip))
|
||||
goto Error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
||||
Error:
|
||||
|
@ -1045,7 +1064,7 @@ cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
|
|||
if (TheIntents[i] == INTENT_PERCEPTUAL || TheIntents[i] == INTENT_SATURATION) {
|
||||
|
||||
// Force BPC for V4 profiles in perceptual and saturation
|
||||
if (cmsGetProfileVersion(hProfiles[i]) >= 4.0)
|
||||
if (cmsGetEncodedICCversion(hProfiles[i]) >= 0x4000000)
|
||||
BPC[i] = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -25,6 +25,13 @@
|
|||
|
||||
#include "lcms2_internal.h"
|
||||
|
||||
|
||||
// This function is here to help applications to prevent mixing lcms versions on header and shared objects.
|
||||
int CMSEXPORT cmsGetEncodedCMMversion(void)
|
||||
{
|
||||
return LCMS_VERSION;
|
||||
}
|
||||
|
||||
// I am so tired about incompatibilities on those functions that here are some replacements
|
||||
// that hopefully would be fully portable.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -929,7 +929,7 @@ void Eval4Inputs(register const cmsUInt16Number Input[],
|
|||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
|
||||
Tmp1[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
|
||||
Tmp1[OutChan] = (cmsUInt16Number) ( c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -993,7 +993,7 @@ void Eval4Inputs(register const cmsUInt16Number Input[],
|
|||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
|
||||
Tmp2[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
|
||||
Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -453,6 +453,14 @@ cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io)
|
|||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile)
|
||||
{
|
||||
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*)hProfile;
|
||||
|
||||
if (Icc == NULL) return NULL;
|
||||
return Icc->IOhandler;
|
||||
}
|
||||
|
||||
// Creates an empty structure holding all required parameters
|
||||
cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
|
||||
{
|
||||
|
@ -623,6 +631,32 @@ cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// Enforces that the profile version is per. spec.
|
||||
// Operates on the big endian bytes from the profile.
|
||||
// Called before converting to platform endianness.
|
||||
// Byte 0 is BCD major version, so max 9.
|
||||
// Byte 1 is 2 BCD digits, one per nibble.
|
||||
// Reserved bytes 2 & 3 must be 0.
|
||||
static
|
||||
cmsUInt32Number _validatedVersion(cmsUInt32Number DWord)
|
||||
{
|
||||
cmsUInt8Number* pByte = (cmsUInt8Number*) &DWord;
|
||||
cmsUInt8Number temp1;
|
||||
cmsUInt8Number temp2;
|
||||
|
||||
if (*pByte > 0x09) *pByte = (cmsUInt8Number) 0x09;
|
||||
temp1 = *(pByte+1) & 0xf0;
|
||||
temp2 = *(pByte+1) & 0x0f;
|
||||
if (temp1 > 0x90) temp1 = 0x90;
|
||||
if (temp2 > 0x09) temp2 = 0x09;
|
||||
*(pByte+1) = (cmsUInt8Number)(temp1 | temp2);
|
||||
*(pByte+2) = (cmsUInt8Number)0;
|
||||
*(pByte+3) = (cmsUInt8Number)0;
|
||||
|
||||
return DWord;
|
||||
}
|
||||
|
||||
// Read profile header and validate it
|
||||
cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
|
||||
{
|
||||
|
@ -657,7 +691,7 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
|
|||
Icc -> creator = _cmsAdjustEndianess32(Header.creator);
|
||||
|
||||
_cmsAdjustEndianess64(&Icc -> attributes, &Header.attributes);
|
||||
Icc -> Version = _cmsAdjustEndianess32(Header.version);
|
||||
Icc -> Version = _cmsAdjustEndianess32(_validatedVersion(Header.version));
|
||||
|
||||
// Get size as reported in header
|
||||
HeaderSize = _cmsAdjustEndianess32(Header.size);
|
||||
|
@ -773,7 +807,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
|
|||
|
||||
// Get true count
|
||||
for (i=0; i < Icc -> TagCount; i++) {
|
||||
if (Icc ->TagNames[i] != 0)
|
||||
if (Icc ->TagNames[i] != (cmsTagSignature) 0)
|
||||
Count++;
|
||||
}
|
||||
|
||||
|
@ -782,7 +816,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
|
|||
|
||||
for (i=0; i < Icc -> TagCount; i++) {
|
||||
|
||||
if (Icc ->TagNames[i] == 0) continue; // It is just a placeholder
|
||||
if (Icc ->TagNames[i] == (cmsTagSignature) 0) continue; // It is just a placeholder
|
||||
|
||||
Tag.sig = (cmsTagSignature) _cmsAdjustEndianess32((cmsInt32Number) Icc -> TagNames[i]);
|
||||
Tag.offset = _cmsAdjustEndianess32((cmsInt32Number) Icc -> TagOffsets[i]);
|
||||
|
@ -1132,7 +1166,7 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
|
|||
|
||||
for (i=0; i < Icc -> TagCount; i++) {
|
||||
|
||||
if (Icc ->TagNames[i] == 0) continue;
|
||||
if (Icc ->TagNames[i] == (cmsTagSignature) 0) continue;
|
||||
|
||||
// Linked tags are not written
|
||||
if (Icc ->TagLinked[i] != (cmsTagSignature) 0) continue;
|
||||
|
@ -1266,11 +1300,15 @@ cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOH
|
|||
|
||||
_cmsAssert(hProfile != NULL);
|
||||
|
||||
if (!_cmsLockMutex(Icc->ContextID, Icc->UsrMutex)) return 0;
|
||||
memmove(&Keep, Icc, sizeof(_cmsICCPROFILE));
|
||||
|
||||
ContextID = cmsGetProfileContextID(hProfile);
|
||||
PrevIO = Icc ->IOhandler = cmsOpenIOhandlerFromNULL(ContextID);
|
||||
if (PrevIO == NULL) return 0;
|
||||
if (PrevIO == NULL) {
|
||||
_cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Pass #1 does compute offsets
|
||||
|
||||
|
@ -1290,7 +1328,10 @@ cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOH
|
|||
}
|
||||
|
||||
memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
|
||||
if (!cmsCloseIOhandler(PrevIO)) return 0;
|
||||
if (!cmsCloseIOhandler(PrevIO))
|
||||
UsedSpace = 0; // As a error marker
|
||||
|
||||
_cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
|
||||
|
||||
return UsedSpace;
|
||||
|
||||
|
@ -1298,6 +1339,8 @@ cmsUInt32Number CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOH
|
|||
Error:
|
||||
cmsCloseIOhandler(PrevIO);
|
||||
memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
|
||||
_cmsUnlockMutex(Icc->ContextID, Icc->UsrMutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1794,7 +1837,7 @@ Error:
|
|||
|
||||
// Similar to the anterior. This function allows to write directly to the ICC profile any data, without
|
||||
// checking anything. As a rule, mixing Raw with cooked doesn't work, so writting a tag as raw and then reading
|
||||
// it as cooked without serializing does result into an error. If that is wha you want, you will need to dump
|
||||
// it as cooked without serializing does result into an error. If that is what you want, you will need to dump
|
||||
// the profile to memry or disk and then reopen it.
|
||||
cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size)
|
||||
{
|
||||
|
@ -1818,6 +1861,11 @@ cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, cons
|
|||
Icc ->TagSizes[i] = Size;
|
||||
|
||||
_cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
|
||||
|
||||
if (Icc->TagPtrs[i] == NULL) {
|
||||
Icc->TagNames[i] = (cmsTagSignature) 0;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -310,8 +310,8 @@ Error:
|
|||
cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent)
|
||||
{
|
||||
cmsTagTypeSignature OriginalType;
|
||||
cmsTagSignature tag16 = Device2PCS16[Intent];
|
||||
cmsTagSignature tagFloat = Device2PCSFloat[Intent];
|
||||
cmsTagSignature tag16;
|
||||
cmsTagSignature tagFloat;
|
||||
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
||||
|
||||
// On named color, take the appropiate tag
|
||||
|
@ -340,6 +340,9 @@ cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent)
|
|||
// matter other LUT are present and have precedence. Intent = -1 means just this.
|
||||
if (Intent != -1) {
|
||||
|
||||
tag16 = Device2PCS16[Intent];
|
||||
tagFloat = Device2PCSFloat[Intent];
|
||||
|
||||
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
|
||||
|
||||
// Floating point LUT are always V4, but the encoding range is no
|
||||
|
@ -582,13 +585,16 @@ Error:
|
|||
cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
|
||||
{
|
||||
cmsTagTypeSignature OriginalType;
|
||||
cmsTagSignature tag16 = PCS2Device16[Intent];
|
||||
cmsTagSignature tagFloat = PCS2DeviceFloat[Intent];
|
||||
cmsTagSignature tag16;
|
||||
cmsTagSignature tagFloat;
|
||||
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
||||
|
||||
|
||||
if (Intent != -1) {
|
||||
|
||||
tag16 = PCS2Device16[Intent];
|
||||
tagFloat = PCS2DeviceFloat[Intent];
|
||||
|
||||
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
|
||||
|
||||
// Floating point LUT are always V4
|
||||
|
@ -906,7 +912,7 @@ cmsBool _cmsWriteProfileSequence(cmsHPROFILE hProfile, const cmsSEQ* seq)
|
|||
{
|
||||
if (!cmsWriteTag(hProfile, cmsSigProfileSequenceDescTag, seq)) return FALSE;
|
||||
|
||||
if (cmsGetProfileVersion(hProfile) >= 4.0) {
|
||||
if (cmsGetEncodedICCversion(hProfile) >= 0x4000000) {
|
||||
|
||||
if (!cmsWriteTag(hProfile, cmsSigProfileSequenceIdTag, seq)) return FALSE;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -505,7 +505,7 @@ void* CLUTElemDup(cmsStage* mpe)
|
|||
goto Error;
|
||||
} else {
|
||||
NewElem ->Tab.T = (cmsUInt16Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.T, Data ->nEntries * sizeof (cmsUInt16Number));
|
||||
if (NewElem ->Tab.TFloat == NULL)
|
||||
if (NewElem ->Tab.T == NULL)
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
|
@ -1125,7 +1125,23 @@ cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID)
|
|||
return mpe;
|
||||
}
|
||||
|
||||
// Clips values smaller than zero
|
||||
static
|
||||
void Clipper(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
|
||||
{
|
||||
cmsUInt32Number i;
|
||||
for (i = 0; i < mpe->InputChannels; i++) {
|
||||
|
||||
cmsFloat32Number n = In[i];
|
||||
Out[i] = n < 0 ? 0 : n;
|
||||
}
|
||||
}
|
||||
|
||||
cmsStage* _cmsStageClipNegatives(cmsContext ContextID, int nChannels)
|
||||
{
|
||||
return _cmsStageAllocPlaceholder(ContextID, cmsSigClipNegativesElemType,
|
||||
nChannels, nChannels, Clipper, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Type cmsSigXYZ2LabElemType
|
||||
|
@ -1437,6 +1453,7 @@ cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* lut)
|
|||
First = FALSE;
|
||||
}
|
||||
else {
|
||||
if (Anterior != NULL)
|
||||
Anterior ->Next = NewMPE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -92,7 +92,7 @@ cmsBool GrowMLUpool(cmsMLU* mlu)
|
|||
static
|
||||
cmsBool GrowMLUtable(cmsMLU* mlu)
|
||||
{
|
||||
int AllocatedEntries;
|
||||
cmsUInt32Number AllocatedEntries;
|
||||
_cmsMLUentry *NewPtr;
|
||||
|
||||
// Sanity check
|
||||
|
@ -118,7 +118,7 @@ cmsBool GrowMLUtable(cmsMLU* mlu)
|
|||
static
|
||||
int SearchMLUEntry(cmsMLU* mlu, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode)
|
||||
{
|
||||
int i;
|
||||
cmsUInt32Number i;
|
||||
|
||||
// Sanity check
|
||||
if (mlu == NULL) return -1;
|
||||
|
@ -178,6 +178,33 @@ cmsBool AddMLUBlock(cmsMLU* mlu, cmsUInt32Number size, const wchar_t *Block,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
// Convert from a 3-char code to a cmsUInt16Number. It is done inthis way because some
|
||||
// compilers don't properly align beginning of strings
|
||||
|
||||
static
|
||||
cmsUInt16Number strTo16(const char str[3])
|
||||
{
|
||||
cmsUInt16Number n = ((cmsUInt16Number) str[0] << 8) | str[1];
|
||||
|
||||
return n; // Always big endian in this case
|
||||
}
|
||||
|
||||
static
|
||||
void strFrom16(char str[3], cmsUInt16Number n)
|
||||
{
|
||||
// Assiming this would be aligned
|
||||
union {
|
||||
|
||||
cmsUInt16Number n;
|
||||
char str[2];
|
||||
|
||||
} c;
|
||||
|
||||
c.n = n; // Always big endian in this case
|
||||
|
||||
str[0] = c.str[0]; str[1] = c.str[1]; str[2] = 0;
|
||||
|
||||
}
|
||||
|
||||
// Add an ASCII entry.
|
||||
cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
|
||||
|
@ -185,8 +212,8 @@ cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const
|
|||
cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString)+1;
|
||||
wchar_t* WStr;
|
||||
cmsBool rc;
|
||||
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
|
||||
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
|
||||
cmsUInt16Number Lang = strTo16(LanguageCode);
|
||||
cmsUInt16Number Cntry = strTo16(CountryCode);
|
||||
|
||||
if (mlu == NULL) return FALSE;
|
||||
|
||||
|
@ -220,8 +247,8 @@ cmsUInt32Number mywcslen(const wchar_t *s)
|
|||
// Add a wide entry
|
||||
cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
|
||||
{
|
||||
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) Language);
|
||||
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) Country);
|
||||
cmsUInt16Number Lang = strTo16(Language);
|
||||
cmsUInt16Number Cntry = strTo16(Country);
|
||||
cmsUInt32Number len;
|
||||
|
||||
if (mlu == NULL) return FALSE;
|
||||
|
@ -298,8 +325,8 @@ const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu,
|
|||
cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode,
|
||||
cmsUInt16Number* UsedLanguageCode, cmsUInt16Number* UsedCountryCode)
|
||||
{
|
||||
int i;
|
||||
int Best = -1;
|
||||
cmsUInt32Number i;
|
||||
cmsInt32Number Best = -1;
|
||||
_cmsMLUentry* v;
|
||||
|
||||
if (mlu == NULL) return NULL;
|
||||
|
@ -350,8 +377,8 @@ cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
|
|||
cmsUInt32Number StrLen = 0;
|
||||
cmsUInt32Number ASCIIlen, i;
|
||||
|
||||
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
|
||||
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
|
||||
cmsUInt16Number Lang = strTo16(LanguageCode);
|
||||
cmsUInt16Number Cntry = strTo16(CountryCode);
|
||||
|
||||
// Sanitize
|
||||
if (mlu == NULL) return 0;
|
||||
|
@ -394,8 +421,8 @@ cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
|
|||
const wchar_t *Wide;
|
||||
cmsUInt32Number StrLen = 0;
|
||||
|
||||
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
|
||||
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
|
||||
cmsUInt16Number Lang = strTo16(LanguageCode);
|
||||
cmsUInt16Number Cntry = strTo16(CountryCode);
|
||||
|
||||
// Sanitize
|
||||
if (mlu == NULL) return 0;
|
||||
|
@ -427,8 +454,8 @@ CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
|
|||
{
|
||||
const wchar_t *Wide;
|
||||
|
||||
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
|
||||
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
|
||||
cmsUInt16Number Lang = strTo16(LanguageCode);
|
||||
cmsUInt16Number Cntry = strTo16(CountryCode);
|
||||
cmsUInt16Number ObtLang, ObtCode;
|
||||
|
||||
// Sanitize
|
||||
|
@ -438,10 +465,9 @@ CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
|
|||
if (Wide == NULL) return FALSE;
|
||||
|
||||
// Get used language and code
|
||||
*(cmsUInt16Number *)ObtainedLanguage = _cmsAdjustEndianess16(ObtLang);
|
||||
*(cmsUInt16Number *)ObtainedCountry = _cmsAdjustEndianess16(ObtCode);
|
||||
strFrom16(ObtainedLanguage, ObtLang);
|
||||
strFrom16(ObtainedCountry, ObtCode);
|
||||
|
||||
ObtainedLanguage[2] = ObtainedCountry[2] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -464,12 +490,12 @@ cmsBool CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu,
|
|||
|
||||
if (mlu == NULL) return FALSE;
|
||||
|
||||
if (idx >= (cmsUInt32Number) mlu->UsedEntries) return FALSE;
|
||||
if (idx >= mlu->UsedEntries) return FALSE;
|
||||
|
||||
entry = &mlu->Entries[idx];
|
||||
|
||||
*(cmsUInt16Number *)LanguageCode = _cmsAdjustEndianess16(entry->Language);
|
||||
*(cmsUInt16Number *)CountryCode = _cmsAdjustEndianess16(entry->Country);
|
||||
strFrom16(LanguageCode, entry->Language);
|
||||
strFrom16(CountryCode, entry->Country);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -514,8 +540,9 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
|
|||
v ->nColors = 0;
|
||||
v ->ContextID = ContextID;
|
||||
|
||||
while (v -> Allocated < n)
|
||||
GrowNamedColorList(v);
|
||||
while (v -> Allocated < n){
|
||||
if (!GrowNamedColorList(v)) return NULL;
|
||||
}
|
||||
|
||||
strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1);
|
||||
strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)-1);
|
||||
|
@ -544,8 +571,9 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v)
|
|||
if (NewNC == NULL) return NULL;
|
||||
|
||||
// For really large tables we need this
|
||||
while (NewNC ->Allocated < v ->Allocated)
|
||||
GrowNamedColorList(NewNC);
|
||||
while (NewNC ->Allocated < v ->Allocated){
|
||||
if (!GrowNamedColorList(NewNC)) return NULL;
|
||||
}
|
||||
|
||||
memmove(NewNC ->Prefix, v ->Prefix, sizeof(v ->Prefix));
|
||||
memmove(NewNC ->Suffix, v ->Suffix, sizeof(v ->Suffix));
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -163,6 +162,89 @@ cmsBool _Remove2Op(cmsPipeline* Lut, cmsStageSignature Op1, cmsStageSignature Op
|
|||
return AnyOpt;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
cmsBool CloseEnoughFloat(cmsFloat64Number a, cmsFloat64Number b)
|
||||
{
|
||||
return fabs(b - a) < 0.00001f;
|
||||
}
|
||||
|
||||
static
|
||||
cmsBool isFloatMatrixIdentity(const cmsMAT3* a)
|
||||
{
|
||||
cmsMAT3 Identity;
|
||||
int i, j;
|
||||
|
||||
_cmsMAT3identity(&Identity);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (j = 0; j < 3; j++)
|
||||
if (!CloseEnoughFloat(a->v[i].n[j], Identity.v[i].n[j])) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
// if two adjacent matrices are found, multiply them.
|
||||
static
|
||||
cmsBool _MultiplyMatrix(cmsPipeline* Lut)
|
||||
{
|
||||
cmsStage** pt1;
|
||||
cmsStage** pt2;
|
||||
cmsStage* chain;
|
||||
cmsBool AnyOpt = FALSE;
|
||||
|
||||
pt1 = &Lut->Elements;
|
||||
if (*pt1 == NULL) return AnyOpt;
|
||||
|
||||
while (*pt1 != NULL) {
|
||||
|
||||
pt2 = &((*pt1)->Next);
|
||||
if (*pt2 == NULL) return AnyOpt;
|
||||
|
||||
if ((*pt1)->Implements == cmsSigMatrixElemType && (*pt2)->Implements == cmsSigMatrixElemType) {
|
||||
|
||||
// Get both matrices
|
||||
_cmsStageMatrixData* m1 = (_cmsStageMatrixData*) cmsStageData(*pt1);
|
||||
_cmsStageMatrixData* m2 = (_cmsStageMatrixData*) cmsStageData(*pt2);
|
||||
cmsMAT3 res;
|
||||
|
||||
// Input offset and output offset should be zero to use this optimization
|
||||
if (m1->Offset != NULL || m2 ->Offset != NULL ||
|
||||
cmsStageInputChannels(*pt1) != 3 || cmsStageOutputChannels(*pt1) != 3 ||
|
||||
cmsStageInputChannels(*pt2) != 3 || cmsStageOutputChannels(*pt2) != 3)
|
||||
return FALSE;
|
||||
|
||||
// Multiply both matrices to get the result
|
||||
_cmsMAT3per(&res, (cmsMAT3*)m2->Double, (cmsMAT3*)m1->Double);
|
||||
|
||||
// Get the next in chain afer the matrices
|
||||
chain = (*pt2)->Next;
|
||||
|
||||
// Remove both matrices
|
||||
_RemoveElement(pt2);
|
||||
_RemoveElement(pt1);
|
||||
|
||||
// Now what if the result is a plain identity?
|
||||
if (!isFloatMatrixIdentity(&res)) {
|
||||
|
||||
// We can not get rid of full matrix
|
||||
cmsStage* Multmat = cmsStageAllocMatrix(Lut->ContextID, 3, 3, (const cmsFloat64Number*) &res, NULL);
|
||||
if (Multmat == NULL) return FALSE; // Should never happen
|
||||
|
||||
// Recover the chain
|
||||
Multmat->Next = chain;
|
||||
*pt1 = Multmat;
|
||||
}
|
||||
|
||||
AnyOpt = TRUE;
|
||||
}
|
||||
else
|
||||
pt1 = &((*pt1)->Next);
|
||||
}
|
||||
|
||||
return AnyOpt;
|
||||
}
|
||||
|
||||
|
||||
// Preoptimize just gets rif of no-ops coming paired. Conversion from v2 to v4 followed
|
||||
// by a v4 to v2 and vice-versa. The elements are then discarded.
|
||||
static
|
||||
|
@ -195,6 +277,9 @@ cmsBool PreOptimize(cmsPipeline* Lut)
|
|||
// Remove float pcs Lab conversions
|
||||
Opt |= _Remove2Op(Lut, cmsSigXYZ2FloatPCS, cmsSigFloatPCS2XYZ);
|
||||
|
||||
// Simplify matrix.
|
||||
Opt |= _MultiplyMatrix(Lut);
|
||||
|
||||
if (Opt) AnyOpt = TRUE;
|
||||
|
||||
} while (Opt);
|
||||
|
@ -251,12 +336,12 @@ static
|
|||
void* Prelin16dup(cmsContext ContextID, const void* ptr)
|
||||
{
|
||||
Prelin16Data* p16 = (Prelin16Data*) ptr;
|
||||
Prelin16Data* Duped = _cmsDupMem(ContextID, p16, sizeof(Prelin16Data));
|
||||
Prelin16Data* Duped = (Prelin16Data*) _cmsDupMem(ContextID, p16, sizeof(Prelin16Data));
|
||||
|
||||
if (Duped == NULL) return NULL;
|
||||
|
||||
Duped ->EvalCurveOut16 = _cmsDupMem(ContextID, p16 ->EvalCurveOut16, p16 ->nOutputs * sizeof(_cmsInterpFn16));
|
||||
Duped ->ParamsCurveOut16 = _cmsDupMem(ContextID, p16 ->ParamsCurveOut16, p16 ->nOutputs * sizeof(cmsInterpParams* ));
|
||||
Duped->EvalCurveOut16 = (_cmsInterpFn16*) _cmsDupMem(ContextID, p16->EvalCurveOut16, p16->nOutputs * sizeof(_cmsInterpFn16));
|
||||
Duped->ParamsCurveOut16 = (cmsInterpParams**)_cmsDupMem(ContextID, p16->ParamsCurveOut16, p16->nOutputs * sizeof(cmsInterpParams*));
|
||||
|
||||
return Duped;
|
||||
}
|
||||
|
@ -269,7 +354,7 @@ Prelin16Data* PrelinOpt16alloc(cmsContext ContextID,
|
|||
int nOutputs, cmsToneCurve** Out )
|
||||
{
|
||||
int i;
|
||||
Prelin16Data* p16 = _cmsMallocZero(ContextID, sizeof(Prelin16Data));
|
||||
Prelin16Data* p16 = (Prelin16Data*)_cmsMallocZero(ContextID, sizeof(Prelin16Data));
|
||||
if (p16 == NULL) return NULL;
|
||||
|
||||
p16 ->nInputs = nInputs;
|
||||
|
@ -590,7 +675,7 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
cmsStage* PreLin = cmsPipelineGetPtrToFirstStage(Src);
|
||||
|
||||
// Check if suitable
|
||||
if (PreLin ->Type == cmsSigCurveSetElemType) {
|
||||
if (PreLin && PreLin ->Type == cmsSigCurveSetElemType) {
|
||||
|
||||
// Maybe this is a linear tram, so we can avoid the whole stuff
|
||||
if (!AllCurvesAreLinear(PreLin)) {
|
||||
|
@ -623,7 +708,7 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
cmsStage* PostLin = cmsPipelineGetPtrToLastStage(Src);
|
||||
|
||||
// Check if suitable
|
||||
if (cmsStageType(PostLin) == cmsSigCurveSetElemType) {
|
||||
if (PostLin && cmsStageType(PostLin) == cmsSigCurveSetElemType) {
|
||||
|
||||
// Maybe this is a linear tram, so we can avoid the whole stuff
|
||||
if (!AllCurvesAreLinear(PostLin)) {
|
||||
|
@ -758,7 +843,7 @@ Prelin8Data* PrelinOpt8alloc(cmsContext ContextID, const cmsInterpParams* p, cms
|
|||
cmsS15Fixed16Number v1, v2, v3;
|
||||
Prelin8Data* p8;
|
||||
|
||||
p8 = _cmsMallocZero(ContextID, sizeof(Prelin8Data));
|
||||
p8 = (Prelin8Data*)_cmsMallocZero(ContextID, sizeof(Prelin8Data));
|
||||
if (p8 == NULL) return NULL;
|
||||
|
||||
// Since this only works for 8 bit input, values comes always as x * 257,
|
||||
|
@ -832,7 +917,7 @@ void PrelinEval8(register const cmsUInt16Number Input[],
|
|||
Prelin8Data* p8 = (Prelin8Data*) D;
|
||||
register const cmsInterpParams* p = p8 ->p;
|
||||
int TotalOut = p -> nOutputs;
|
||||
const cmsUInt16Number* LutTable = p -> Table;
|
||||
const cmsUInt16Number* LutTable = (const cmsUInt16Number*) p->Table;
|
||||
|
||||
r = Input[0] >> 8;
|
||||
g = Input[1] >> 8;
|
||||
|
@ -925,8 +1010,8 @@ cmsBool IsDegenerated(const cmsToneCurve* g)
|
|||
}
|
||||
|
||||
if (Zeros == 1 && Poles == 1) return FALSE; // For linear tables
|
||||
if (Zeros > (nEntries / 4)) return TRUE; // Degenerated, mostly zeros
|
||||
if (Poles > (nEntries / 4)) return TRUE; // Degenerated, mostly poles
|
||||
if (Zeros > (nEntries / 20)) return TRUE; // Degenerated, many zeros
|
||||
if (Poles > (nEntries / 20)) return TRUE; // Degenerated, many poles
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -955,10 +1040,12 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
|||
// This is a loosy optimization! does not apply in floating-point cases
|
||||
if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
|
||||
|
||||
// Only on RGB
|
||||
// Only on chunky RGB
|
||||
if (T_COLORSPACE(*InputFormat) != PT_RGB) return FALSE;
|
||||
if (T_COLORSPACE(*OutputFormat) != PT_RGB) return FALSE;
|
||||
if (T_PLANAR(*InputFormat)) return FALSE;
|
||||
|
||||
if (T_COLORSPACE(*OutputFormat) != PT_RGB) return FALSE;
|
||||
if (T_PLANAR(*OutputFormat)) return FALSE;
|
||||
|
||||
// On 16 bits, user has to specify the feature
|
||||
if (!_cmsFormatterIs8bit(*InputFormat)) {
|
||||
|
@ -982,6 +1069,22 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
|||
memset(Trans, 0, sizeof(Trans));
|
||||
memset(TransReverse, 0, sizeof(TransReverse));
|
||||
|
||||
// If the last stage of the original lut are curves, and those curves are
|
||||
// degenerated, it is likely the transform is squeezing and clipping
|
||||
// the output from previous CLUT. We cannot optimize this case
|
||||
{
|
||||
cmsStage* last = cmsPipelineGetPtrToLastStage(OriginalLut);
|
||||
|
||||
if (cmsStageType(last) == cmsSigCurveSetElemType) {
|
||||
|
||||
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*)cmsStageData(last);
|
||||
for (i = 0; i < Data->nCurves; i++) {
|
||||
if (IsDegenerated(Data->TheCurves[i]))
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (t = 0; t < OriginalLut ->InputChannels; t++) {
|
||||
Trans[t] = cmsBuildTabulatedToneCurve16(OriginalLut ->ContextID, PRELINEARIZATION_POINTS, NULL);
|
||||
if (Trans[t] == NULL) goto Error;
|
||||
|
@ -1151,15 +1254,15 @@ void CurvesFree(cmsContext ContextID, void* ptr)
|
|||
static
|
||||
void* CurvesDup(cmsContext ContextID, const void* ptr)
|
||||
{
|
||||
Curves16Data* Data = _cmsDupMem(ContextID, ptr, sizeof(Curves16Data));
|
||||
Curves16Data* Data = (Curves16Data*)_cmsDupMem(ContextID, ptr, sizeof(Curves16Data));
|
||||
int i;
|
||||
|
||||
if (Data == NULL) return NULL;
|
||||
|
||||
Data ->Curves = _cmsDupMem(ContextID, Data ->Curves, Data ->nCurves * sizeof(cmsUInt16Number*));
|
||||
Data->Curves = (cmsUInt16Number**) _cmsDupMem(ContextID, Data->Curves, Data->nCurves * sizeof(cmsUInt16Number*));
|
||||
|
||||
for (i=0; i < Data -> nCurves; i++) {
|
||||
Data ->Curves[i] = _cmsDupMem(ContextID, Data ->Curves[i], Data -> nElements * sizeof(cmsUInt16Number));
|
||||
Data->Curves[i] = (cmsUInt16Number*) _cmsDupMem(ContextID, Data->Curves[i], Data->nElements * sizeof(cmsUInt16Number));
|
||||
}
|
||||
|
||||
return (void*) Data;
|
||||
|
@ -1172,18 +1275,18 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, int nCurves, int nElements, cmsT
|
|||
int i, j;
|
||||
Curves16Data* c16;
|
||||
|
||||
c16 = _cmsMallocZero(ContextID, sizeof(Curves16Data));
|
||||
c16 = (Curves16Data*)_cmsMallocZero(ContextID, sizeof(Curves16Data));
|
||||
if (c16 == NULL) return NULL;
|
||||
|
||||
c16 ->nCurves = nCurves;
|
||||
c16 ->nElements = nElements;
|
||||
|
||||
c16 ->Curves = _cmsCalloc(ContextID, nCurves, sizeof(cmsUInt16Number*));
|
||||
c16->Curves = (cmsUInt16Number**) _cmsCalloc(ContextID, nCurves, sizeof(cmsUInt16Number*));
|
||||
if (c16 ->Curves == NULL) return NULL;
|
||||
|
||||
for (i=0; i < nCurves; i++) {
|
||||
|
||||
c16->Curves[i] = _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number));
|
||||
c16->Curves[i] = (cmsUInt16Number*) _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number));
|
||||
|
||||
if (c16->Curves[i] == NULL) {
|
||||
|
||||
|
@ -1315,7 +1418,10 @@ cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUI
|
|||
GammaTables[i] = NULL;
|
||||
}
|
||||
|
||||
if (GammaTables != NULL) _cmsFree(Src ->ContextID, GammaTables);
|
||||
if (GammaTables != NULL) {
|
||||
_cmsFree(Src->ContextID, GammaTables);
|
||||
GammaTables = NULL;
|
||||
}
|
||||
|
||||
// Maybe the curves are linear at the end
|
||||
if (!AllCurvesAreLinear(ObtainedCurves)) {
|
||||
|
@ -1531,17 +1637,15 @@ cmsBool SetMatShaper(cmsPipeline* Dest, cmsToneCurve* Curve1[3], cmsMAT3* Mat, c
|
|||
}
|
||||
|
||||
// 8 bits on input allows matrix-shaper boot up to 25 Mpixels per second on RGB. That's fast!
|
||||
// TODO: Allow a third matrix for abs. colorimetric
|
||||
static
|
||||
cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt32Number* InputFormat, cmsUInt32Number* OutputFormat, cmsUInt32Number* dwFlags)
|
||||
{
|
||||
cmsStage* Curve1, *Curve2;
|
||||
cmsStage* Matrix1, *Matrix2;
|
||||
_cmsStageMatrixData* Data1;
|
||||
_cmsStageMatrixData* Data2;
|
||||
cmsMAT3 res;
|
||||
cmsBool IdentityMat;
|
||||
cmsPipeline* Dest, *Src;
|
||||
cmsFloat64Number* Offset;
|
||||
|
||||
// Only works on RGB to RGB
|
||||
if (T_CHANNELS(*InputFormat) != 3 || T_CHANNELS(*OutputFormat) != 3) return FALSE;
|
||||
|
@ -1552,14 +1656,22 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
// Seems suitable, proceed
|
||||
Src = *Lut;
|
||||
|
||||
// Check for shaper-matrix-matrix-shaper structure, that is what this optimizer stands for
|
||||
if (!cmsPipelineCheckAndRetreiveStages(Src, 4,
|
||||
// Check for:
|
||||
//
|
||||
// shaper-matrix-matrix-shaper
|
||||
// shaper-matrix-shaper
|
||||
//
|
||||
// Both of those constructs are possible (first because abs. colorimetric).
|
||||
// additionally, In the first case, the input matrix offset should be zero.
|
||||
|
||||
IdentityMat = FALSE;
|
||||
if (cmsPipelineCheckAndRetreiveStages(Src, 4,
|
||||
cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
|
||||
&Curve1, &Matrix1, &Matrix2, &Curve2)) return FALSE;
|
||||
&Curve1, &Matrix1, &Matrix2, &Curve2)) {
|
||||
|
||||
// Get both matrices
|
||||
Data1 = (_cmsStageMatrixData*) cmsStageData(Matrix1);
|
||||
Data2 = (_cmsStageMatrixData*) cmsStageData(Matrix2);
|
||||
_cmsStageMatrixData* Data1 = (_cmsStageMatrixData*)cmsStageData(Matrix1);
|
||||
_cmsStageMatrixData* Data2 = (_cmsStageMatrixData*)cmsStageData(Matrix2);
|
||||
|
||||
// Input offset should be zero
|
||||
if (Data1->Offset != NULL) return FALSE;
|
||||
|
@ -1567,14 +1679,42 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
// Multiply both matrices to get the result
|
||||
_cmsMAT3per(&res, (cmsMAT3*)Data2->Double, (cmsMAT3*)Data1->Double);
|
||||
|
||||
// Only 2nd matrix has offset, or it is zero
|
||||
Offset = Data2->Offset;
|
||||
|
||||
// Now the result is in res + Data2 -> Offset. Maybe is a plain identity?
|
||||
IdentityMat = FALSE;
|
||||
if (_cmsMAT3isIdentity(&res) && Data2 ->Offset == NULL) {
|
||||
if (_cmsMAT3isIdentity(&res) && Offset == NULL) {
|
||||
|
||||
// We can get rid of full matrix
|
||||
IdentityMat = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if (cmsPipelineCheckAndRetreiveStages(Src, 3,
|
||||
cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
|
||||
&Curve1, &Matrix1, &Curve2)) {
|
||||
|
||||
_cmsStageMatrixData* Data = (_cmsStageMatrixData*)cmsStageData(Matrix1);
|
||||
|
||||
// Copy the matrix to our result
|
||||
memcpy(&res, Data->Double, sizeof(res));
|
||||
|
||||
// Preserve the Odffset (may be NULL as a zero offset)
|
||||
Offset = Data->Offset;
|
||||
|
||||
if (_cmsMAT3isIdentity(&res) && Offset == NULL) {
|
||||
|
||||
// We can get rid of full matrix
|
||||
IdentityMat = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
return FALSE; // Not optimizeable this time
|
||||
|
||||
}
|
||||
|
||||
// Allocate an empty LUT
|
||||
Dest = cmsPipelineAlloc(Src ->ContextID, Src ->InputChannels, Src ->OutputChannels);
|
||||
if (!Dest) return FALSE;
|
||||
|
@ -1583,9 +1723,12 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
if (!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, cmsStageDup(Curve1)))
|
||||
goto Error;
|
||||
|
||||
if (!IdentityMat)
|
||||
if (!cmsPipelineInsertStage(Dest, cmsAT_END, cmsStageAllocMatrix(Dest ->ContextID, 3, 3, (const cmsFloat64Number*) &res, Data2 ->Offset)))
|
||||
if (!IdentityMat) {
|
||||
|
||||
if (!cmsPipelineInsertStage(Dest, cmsAT_END, cmsStageAllocMatrix(Dest->ContextID, 3, 3, (const cmsFloat64Number*)&res, Offset)))
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (!cmsPipelineInsertStage(Dest, cmsAT_END, cmsStageDup(Curve2)))
|
||||
goto Error;
|
||||
|
||||
|
@ -1603,7 +1746,7 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
|||
*dwFlags |= cmsFLAGS_NOCACHE;
|
||||
|
||||
// Setup the optimizarion routines
|
||||
SetMatShaper(Dest, mpeC1 ->TheCurves, &res, (cmsVEC3*) Data2 ->Offset, mpeC2->TheCurves, OutputFormat);
|
||||
SetMatShaper(Dest, mpeC1 ->TheCurves, &res, (cmsVEC3*) Offset, mpeC2->TheCurves, OutputFormat);
|
||||
}
|
||||
|
||||
cmsPipelineFree(Src);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -2409,9 +2409,6 @@ cmsUInt8Number* PackDoubleFrom16(register _cmsTRANSFORM* info,
|
|||
((cmsFloat64Number*) output)[i + start] = v;
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsFloat64Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
|
@ -2422,7 +2419,7 @@ cmsUInt8Number* PackDoubleFrom16(register _cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info -> OutputFormat))
|
||||
return output + sizeof(cmsFloat64Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsFloat64Number);
|
||||
return output + (nChan + Extra) * sizeof(cmsFloat64Number);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2463,9 +2460,6 @@ cmsUInt8Number* PackFloatFrom16(register _cmsTRANSFORM* info,
|
|||
((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsFloat32Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
|
@ -2476,7 +2470,7 @@ cmsUInt8Number* PackFloatFrom16(register _cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info->OutputFormat))
|
||||
return output + sizeof(cmsFloat32Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsFloat32Number);
|
||||
return output + (nChan + Extra) * sizeof(cmsFloat32Number);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2519,9 +2513,6 @@ cmsUInt8Number* PackFloatsFromFloat(_cmsTRANSFORM* info,
|
|||
((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsFloat32Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
|
@ -2532,7 +2523,7 @@ cmsUInt8Number* PackFloatsFromFloat(_cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info->OutputFormat))
|
||||
return output + sizeof(cmsFloat32Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsFloat32Number);
|
||||
return output + (nChan + Extra) * sizeof(cmsFloat32Number);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -2571,10 +2562,6 @@ cmsUInt8Number* PackDoublesFromFloat(_cmsTRANSFORM* info,
|
|||
((cmsFloat64Number*)output)[i + start] = v;
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsFloat64Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat64Number));
|
||||
|
@ -2585,7 +2572,7 @@ cmsUInt8Number* PackDoublesFromFloat(_cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info->OutputFormat))
|
||||
return output + sizeof(cmsFloat64Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsFloat64Number);
|
||||
return output + (nChan + Extra) * sizeof(cmsFloat64Number);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2851,9 +2838,6 @@ cmsUInt8Number* PackHalfFrom16(register _cmsTRANSFORM* info,
|
|||
((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsUInt16Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
|
@ -2864,7 +2848,7 @@ cmsUInt8Number* PackHalfFrom16(register _cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info->OutputFormat))
|
||||
return output + sizeof(cmsUInt16Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsUInt16Number);
|
||||
return output + (nChan + Extra) * sizeof(cmsUInt16Number);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2905,9 +2889,6 @@ cmsUInt8Number* PackHalfFromFloat(_cmsTRANSFORM* info,
|
|||
((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
|
||||
}
|
||||
|
||||
if (!ExtraFirst) {
|
||||
output += Extra * sizeof(cmsUInt16Number);
|
||||
}
|
||||
|
||||
if (Extra == 0 && SwapFirst) {
|
||||
|
||||
|
@ -2918,7 +2899,7 @@ cmsUInt8Number* PackHalfFromFloat(_cmsTRANSFORM* info,
|
|||
if (T_PLANAR(info->OutputFormat))
|
||||
return output + sizeof(cmsUInt16Number);
|
||||
else
|
||||
return output + nChan * sizeof(cmsUInt16Number);
|
||||
return output + (nChan + Extra)* sizeof(cmsUInt16Number);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3178,6 +3159,8 @@ cmsFormatter _cmsGetStockOutputFormatter(cmsUInt32Number dwInput, cmsUInt32Numbe
|
|||
cmsUInt32Number i;
|
||||
cmsFormatter fr;
|
||||
|
||||
// Optimization is only a hint
|
||||
dwInput &= ~OPTIMIZED_SH(1);
|
||||
|
||||
switch (dwFlags)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -106,6 +106,15 @@ void CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source)
|
|||
Dest -> Z = ((1 - Source -> x - Source -> y) / Source -> y) * Source -> Y;
|
||||
}
|
||||
|
||||
/*
|
||||
The break point (24/116)^3 = (6/29)^3 is a very small amount of tristimulus
|
||||
primary (0.008856). Generally, this only happens for
|
||||
nearly ideal blacks and for some orange / amber colors in transmission mode.
|
||||
For example, the Z value of the orange turn indicator lamp lens on an
|
||||
automobile will often be below this value. But the Z does not
|
||||
contribute to the perceived color directly.
|
||||
*/
|
||||
|
||||
static
|
||||
cmsFloat64Number f(cmsFloat64Number t)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -215,22 +215,6 @@ cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n
|
|||
}
|
||||
|
||||
|
||||
// Jun-21-2000: Some profiles (those that comes with W2K) comes
|
||||
// with the media white (media black?) x 100. Add a sanity check
|
||||
|
||||
static
|
||||
void NormalizeXYZ(cmsCIEXYZ* Dest)
|
||||
{
|
||||
while (Dest -> X > 2. &&
|
||||
Dest -> Y > 2. &&
|
||||
Dest -> Z > 2.) {
|
||||
|
||||
Dest -> X /= 10.;
|
||||
Dest -> Y /= 10.;
|
||||
Dest -> Z /= 10.;
|
||||
}
|
||||
}
|
||||
|
||||
cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ)
|
||||
{
|
||||
cmsEncodedXYZNumber xyz;
|
||||
|
@ -244,8 +228,6 @@ cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ)
|
|||
XYZ->X = _cms15Fixed16toDouble(_cmsAdjustEndianess32(xyz.X));
|
||||
XYZ->Y = _cms15Fixed16toDouble(_cmsAdjustEndianess32(xyz.Y));
|
||||
XYZ->Z = _cms15Fixed16toDouble(_cmsAdjustEndianess32(xyz.Z));
|
||||
|
||||
NormalizeXYZ(XYZ);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -525,6 +507,7 @@ void* _cmsPluginMalloc(cmsContext ContextID, cmsUInt32Number size)
|
|||
if (ContextID == NULL) {
|
||||
|
||||
ctx->MemPool = _cmsCreateSubAlloc(0, 2*1024);
|
||||
if (ctx->MemPool == NULL) return NULL;
|
||||
}
|
||||
else {
|
||||
cmsSignalError(ContextID, cmsERROR_CORRUPTION_DETECTED, "NULL memory pool on context");
|
||||
|
@ -683,15 +666,21 @@ struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID)
|
|||
|
||||
|
||||
// Internal: get the memory area associanted with each context client
|
||||
// Returns the block assigned to the specific zone.
|
||||
// Returns the block assigned to the specific zone. Never return NULL.
|
||||
void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc)
|
||||
{
|
||||
struct _cmsContext_struct* ctx;
|
||||
void *ptr;
|
||||
|
||||
if (mc < 0 || mc >= MemoryClientMax) {
|
||||
cmsSignalError(ContextID, cmsERROR_RANGE, "Bad context client");
|
||||
return NULL;
|
||||
if ((int) mc < 0 || mc >= MemoryClientMax) {
|
||||
|
||||
cmsSignalError(ContextID, cmsERROR_INTERNAL, "Bad context client -- possible corruption");
|
||||
|
||||
// This is catastrophic. Should never reach here
|
||||
_cmsAssert(0);
|
||||
|
||||
// Reverts to global context
|
||||
return globalContext.chunks[UserPtr];
|
||||
}
|
||||
|
||||
ctx = _cmsGetContext(ContextID);
|
||||
|
@ -880,7 +869,7 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
static
|
||||
struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
|
||||
{
|
||||
|
@ -897,6 +886,7 @@ struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
|
|||
|
||||
return NULL; // List is empty or only one element!
|
||||
}
|
||||
*/
|
||||
|
||||
// Frees any resources associated with the given context,
|
||||
// and destroys the context placeholder.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -1395,7 +1395,8 @@ void BuildColorantList(char *Colorant, int nColorant, cmsUInt16Number Out[])
|
|||
|
||||
for (j = 0; j < nColorant; j++) {
|
||||
|
||||
sprintf(Buff, "%.3f", Out[j] / 65535.0);
|
||||
snprintf(Buff, 31, "%.3f", Out[j] / 65535.0);
|
||||
Buff[31] = 0;
|
||||
strcat(Colorant, Buff);
|
||||
if (j < nColorant - 1)
|
||||
strcat(Colorant, " ");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -340,28 +340,7 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[]
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
static
|
||||
cmsBool IsMonotonic(int n, const cmsFloat64Number Table[])
|
||||
{
|
||||
int i;
|
||||
cmsFloat64Number last;
|
||||
|
||||
last = Table[n-1];
|
||||
|
||||
for (i = n-2; i >= 0; --i) {
|
||||
|
||||
if (Table[i] > last)
|
||||
|
||||
return FALSE;
|
||||
else
|
||||
last = Table[i];
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
// Calculates the black point of a destination profile.
|
||||
// This algorithm comes from the Adobe paper disclosing its black point compensation method.
|
||||
|
@ -486,7 +465,6 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
|
|||
|
||||
|
||||
// Test for mid range straight (only on relative colorimetric)
|
||||
|
||||
NearlyStraightMidrange = TRUE;
|
||||
MinL = outRamp[0]; MaxL = outRamp[255];
|
||||
if (Intent == INTENT_RELATIVE_COLORIMETRIC) {
|
||||
|
@ -502,7 +480,6 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
|
|||
// DestinationBlackPoint shall be the same as initialLab.
|
||||
// Otherwise, the DestinationBlackPoint shall be determined
|
||||
// using curve fitting.
|
||||
|
||||
if (NearlyStraightMidrange) {
|
||||
|
||||
cmsLab2XYZ(NULL, BlackPoint, &InitialLab);
|
||||
|
@ -514,14 +491,12 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
|
|||
|
||||
// curve fitting: The round-trip curve normally looks like a nearly constant section at the black point,
|
||||
// with a corner and a nearly straight line to the white point.
|
||||
|
||||
for (l=0; l < 256; l++) {
|
||||
|
||||
yRamp[l] = (outRamp[l] - MinL) / (MaxL - MinL);
|
||||
}
|
||||
|
||||
// find the black point using the least squares error quadratic curve fitting
|
||||
|
||||
if (Intent == INTENT_RELATIVE_COLORIMETRIC) {
|
||||
lo = 0.1;
|
||||
hi = 0.5;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -218,7 +218,8 @@ cmsBool ClosestLineToLine(cmsVEC3* r, const cmsLine* line1, const cmsLine* line2
|
|||
{
|
||||
cmsFloat64Number a, b, c, d, e, D;
|
||||
cmsFloat64Number sc, sN, sD;
|
||||
cmsFloat64Number tc, tN, tD;
|
||||
//cmsFloat64Number tc; // left for future use
|
||||
cmsFloat64Number tN, tD;
|
||||
cmsVEC3 w0;
|
||||
|
||||
_cmsVEC3minus(&w0, &line1 ->a, &line2 ->a);
|
||||
|
@ -286,7 +287,7 @@ cmsBool ClosestLineToLine(cmsVEC3* r, const cmsLine* line1, const cmsLine* line2
|
|||
}
|
||||
// finally do the division to get sc and tc
|
||||
sc = (fabs(sN) < MATRIX_DET_TOLERANCE ? 0.0 : sN / sD);
|
||||
tc = (fabs(tN) < MATRIX_DET_TOLERANCE ? 0.0 : tN / tD);
|
||||
//tc = (fabs(tN) < MATRIX_DET_TOLERANCE ? 0.0 : tN / tD); // left for future use.
|
||||
|
||||
GetPointOfLine(r, line1, sc);
|
||||
return TRUE;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -951,7 +951,7 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
cmsMLU* mlu = (cmsMLU*) Ptr;
|
||||
char *Text = NULL;
|
||||
wchar_t *Wide = NULL;
|
||||
cmsUInt32Number len, len_aligned, len_filler_alignment;
|
||||
cmsUInt32Number len, len_text, len_tag_requirement, len_aligned;
|
||||
cmsBool rc = FALSE;
|
||||
char Filler[68];
|
||||
|
||||
|
@ -961,17 +961,18 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
// Get the len of string
|
||||
len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
|
||||
|
||||
// From ICC3.4: It has been found that textDescriptionType can contain misaligned data
|
||||
// Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data
|
||||
//(see clause 4.1 for the definition of “aligned”). Because the Unicode language
|
||||
// code and Unicode count immediately follow the ASCII description, their
|
||||
// alignment is not correct if the ASCII count is not a multiple of four. The
|
||||
// ScriptCode code is misaligned when the ASCII count is odd. Profile reading and
|
||||
// writing software must be written carefully in order to handle these alignment
|
||||
// problems.
|
||||
|
||||
// Compute an aligned size
|
||||
len_aligned = _cmsALIGNLONG(len);
|
||||
len_filler_alignment = len_aligned - len;
|
||||
//
|
||||
// The above last sentence suggest to handle alignment issues in the
|
||||
// parser. The provided example (Table 69 on Page 60) makes this clear.
|
||||
// The padding only in the ASCII count is not sufficient for a aligned tag
|
||||
// size, with the same text size in ASCII and Unicode.
|
||||
|
||||
// Null strings
|
||||
if (len <= 0) {
|
||||
|
@ -992,6 +993,12 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
cmsMLUgetWide(mlu, cmsNoLanguage, cmsNoCountry, Wide, len * sizeof(wchar_t));
|
||||
}
|
||||
|
||||
// Tell the real text len including the null terminator and padding
|
||||
len_text = strlen(Text) + 1;
|
||||
// Compute an total tag size requirement
|
||||
len_tag_requirement = (8+4+len_text+4+4+2*len_text+2+1+67);
|
||||
len_aligned = _cmsALIGNLONG(len_tag_requirement);
|
||||
|
||||
// * cmsUInt32Number count; * Description length
|
||||
// * cmsInt8Number desc[count] * NULL terminated ascii string
|
||||
// * cmsUInt32Number ucLangCode; * UniCode language code
|
||||
|
@ -1001,20 +1008,14 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
// * cmsUInt8Number scCount; * ScriptCode count
|
||||
// * cmsInt8Number scDesc[67]; * ScriptCode Description
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, len_aligned)) goto Error;
|
||||
if (!io ->Write(io, len, Text)) goto Error;
|
||||
if (!io ->Write(io, len_filler_alignment, Filler)) goto Error;
|
||||
if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
|
||||
if (!io ->Write(io, len_text, Text)) goto Error;
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // ucLanguageCode
|
||||
|
||||
// This part is tricky: we need an aligned tag size, and the ScriptCode part
|
||||
// takes 70 bytes, so we need 2 extra bytes to do the alignment
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, len_aligned+1)) goto Error;
|
||||
|
||||
if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
|
||||
// Note that in some compilers sizeof(cmsUInt16Number) != sizeof(wchar_t)
|
||||
if (!_cmsWriteWCharArray(io, len, Wide)) goto Error;
|
||||
if (!_cmsWriteUInt16Array(io, len_filler_alignment+1, (cmsUInt16Number*) Filler)) goto Error;
|
||||
if (!_cmsWriteWCharArray(io, len_text, Wide)) goto Error;
|
||||
|
||||
// ScriptCode Code & count (unused)
|
||||
if (!_cmsWriteUInt16Number(io, 0)) goto Error;
|
||||
|
@ -1022,6 +1023,10 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
|
||||
if (!io ->Write(io, 67, Filler)) goto Error;
|
||||
|
||||
// possibly add pad at the end of tag
|
||||
if(len_aligned - len_tag_requirement > 0)
|
||||
if (!io ->Write(io, len_aligned - len_tag_requirement, Filler)) goto Error;
|
||||
|
||||
rc = TRUE;
|
||||
|
||||
Error:
|
||||
|
@ -1503,7 +1508,7 @@ cmsBool Type_MLU_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
|
|||
cmsMLU* mlu =(cmsMLU*) Ptr;
|
||||
cmsUInt32Number HeaderSize;
|
||||
cmsUInt32Number Len, Offset;
|
||||
int i;
|
||||
cmsUInt32Number i;
|
||||
|
||||
if (Ptr == NULL) {
|
||||
|
||||
|
@ -1689,10 +1694,7 @@ cmsBool Write8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsUInt32Number
|
|||
else
|
||||
for (j=0; j < 256; j++) {
|
||||
|
||||
if (Tables != NULL)
|
||||
val = (cmsUInt8Number) FROM_16_TO_8(Tables->TheCurves[i]->Table16[j]);
|
||||
else
|
||||
val = (cmsUInt8Number) j;
|
||||
|
||||
if (!_cmsWriteUInt8Number(io, val)) return FALSE;
|
||||
}
|
||||
|
@ -3107,6 +3109,8 @@ void *Type_NamedColor_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* i
|
|||
|
||||
memset(Colorant, 0, sizeof(Colorant));
|
||||
if (io -> Read(io, Root, 32, 1) != 1) return NULL;
|
||||
Root[32] = 0; // To prevent exploits
|
||||
|
||||
if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
|
||||
if (!_cmsReadUInt16Array(io, nDeviceCoords, Colorant)) goto Error;
|
||||
|
||||
|
@ -3129,8 +3133,8 @@ static
|
|||
cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
||||
{
|
||||
cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
|
||||
char prefix[32]; // Prefix for each color name
|
||||
char suffix[32]; // Suffix for each color name
|
||||
char prefix[33]; // Prefix for each color name
|
||||
char suffix[33]; // Suffix for each color name
|
||||
int i, nColors;
|
||||
|
||||
nColors = cmsNamedColorCount(NamedColorList);
|
||||
|
@ -3142,7 +3146,7 @@ cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER
|
|||
strncpy(prefix, (const char*) NamedColorList->Prefix, 32);
|
||||
strncpy(suffix, (const char*) NamedColorList->Suffix, 32);
|
||||
|
||||
suffix[31] = prefix[31] = 0;
|
||||
suffix[32] = prefix[32] = 0;
|
||||
|
||||
if (!io ->Write(io, 32, prefix)) return FALSE;
|
||||
if (!io ->Write(io, 32, suffix)) return FALSE;
|
||||
|
@ -3154,6 +3158,7 @@ cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER
|
|||
char Root[33];
|
||||
|
||||
if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0;
|
||||
Root[32] = 0;
|
||||
if (!io ->Write(io, 32 , Root)) return FALSE;
|
||||
if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
|
||||
if (!_cmsWriteUInt16Array(io, NamedColorList ->ColorantCount, Colorant)) return FALSE;
|
||||
|
@ -3853,7 +3858,7 @@ cmsBool Type_ViewingConditions_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||
static
|
||||
void* Type_ViewingConditions_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
|
||||
{
|
||||
return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsScreening));
|
||||
return _cmsDupMem(self->ContextID, Ptr, sizeof(cmsICCViewingConditions));
|
||||
|
||||
cmsUNUSED_PARAMETER(n);
|
||||
}
|
||||
|
@ -5452,7 +5457,8 @@ static _cmsTagLinkedList SupportedTags[] = {
|
|||
{ cmsSigVcgtTag, { 1, 1, { cmsSigVcgtType}, NULL }, &SupportedTags[60]},
|
||||
{ cmsSigMetaTag, { 1, 1, { cmsSigDictType}, NULL }, &SupportedTags[61]},
|
||||
{ cmsSigProfileSequenceIdTag, { 1, 1, { cmsSigProfileSequenceIdType}, NULL }, &SupportedTags[62]},
|
||||
{ cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, NULL}
|
||||
{ cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, &SupportedTags[63]},
|
||||
{ cmsSigArgyllArtsTag, { 9, 1, { cmsSigS15Fixed16ArrayType}, NULL}, NULL}
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -642,7 +642,7 @@ cmsToneCurve* Build_sRGBGamma(cmsContext ContextID)
|
|||
// Create the ICC virtual profile for sRGB space
|
||||
cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID)
|
||||
{
|
||||
cmsCIExyY D65;
|
||||
cmsCIExyY D65 = { 0.3127, 0.3290, 1.0 };
|
||||
cmsCIExyYTRIPLE Rec709Primaries = {
|
||||
{0.6400, 0.3300, 1.0},
|
||||
{0.3000, 0.6000, 1.0},
|
||||
|
@ -651,7 +651,7 @@ cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID)
|
|||
cmsToneCurve* Gamma22[3];
|
||||
cmsHPROFILE hsRGB;
|
||||
|
||||
cmsWhitePointFromTemp(&D65, 6504);
|
||||
// cmsWhitePointFromTemp(&D65, 6504);
|
||||
Gamma22[0] = Gamma22[1] = Gamma22[2] = Build_sRGBGamma(ContextID);
|
||||
if (Gamma22[0] == NULL) return NULL;
|
||||
|
||||
|
@ -679,6 +679,7 @@ typedef struct {
|
|||
cmsFloat64Number Contrast;
|
||||
cmsFloat64Number Hue;
|
||||
cmsFloat64Number Saturation;
|
||||
cmsBool lAdjustWP;
|
||||
cmsCIEXYZ WPsrc, WPdest;
|
||||
|
||||
} BCHSWADJUSTS, *LPBCHSWADJUSTS;
|
||||
|
@ -708,9 +709,10 @@ int bchswSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
|
|||
cmsLCh2Lab(&LabOut, &LChOut);
|
||||
|
||||
// Move white point in Lab
|
||||
|
||||
if (bchsw->lAdjustWP) {
|
||||
cmsLab2XYZ(&bchsw->WPsrc, &XYZ, &LabOut);
|
||||
cmsXYZ2Lab(&bchsw->WPdest, &LabOut, &XYZ);
|
||||
}
|
||||
|
||||
// Back to encoded
|
||||
|
||||
|
@ -744,18 +746,23 @@ cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
|
|||
bchsw.Contrast = Contrast;
|
||||
bchsw.Hue = Hue;
|
||||
bchsw.Saturation = Saturation;
|
||||
if (TempSrc == TempDest) {
|
||||
|
||||
bchsw.lAdjustWP = FALSE;
|
||||
}
|
||||
else {
|
||||
bchsw.lAdjustWP = TRUE;
|
||||
cmsWhitePointFromTemp(&WhitePnt, TempSrc);
|
||||
cmsxyY2XYZ(&bchsw.WPsrc, &WhitePnt);
|
||||
|
||||
cmsWhitePointFromTemp(&WhitePnt, TempDest);
|
||||
cmsxyY2XYZ(&bchsw.WPdest, &WhitePnt);
|
||||
|
||||
}
|
||||
|
||||
hICC = cmsCreateProfilePlaceholder(ContextID);
|
||||
if (!hICC) // can't allocate
|
||||
return NULL;
|
||||
|
||||
|
||||
cmsSetDeviceClass(hICC, cmsSigAbstractClass);
|
||||
cmsSetColorSpace(hICC, cmsSigLabData);
|
||||
cmsSetPCS(hICC, cmsSigLabData);
|
||||
|
@ -988,12 +995,14 @@ typedef struct {
|
|||
|
||||
} cmsAllowedLUT;
|
||||
|
||||
#define cmsSig0 ((cmsTagSignature) 0)
|
||||
|
||||
static const cmsAllowedLUT AllowedLUTTypes[] = {
|
||||
|
||||
{ FALSE, 0, cmsSigLut16Type, 4, { cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType}},
|
||||
{ FALSE, 0, cmsSigLut16Type, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType}},
|
||||
{ FALSE, 0, cmsSigLut16Type, 2, { cmsSigCurveSetElemType, cmsSigCLutElemType}},
|
||||
{ TRUE , 0, cmsSigLutAtoBType, 1, { cmsSigCurveSetElemType }},
|
||||
{ FALSE, cmsSig0, cmsSigLut16Type, 4, { cmsSigMatrixElemType, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
|
||||
{ FALSE, cmsSig0, cmsSigLut16Type, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
|
||||
{ FALSE, cmsSig0, cmsSigLut16Type, 2, { cmsSigCurveSetElemType, cmsSigCLutElemType } },
|
||||
{ TRUE, cmsSig0, cmsSigLutAtoBType, 1, { cmsSigCurveSetElemType } },
|
||||
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType } },
|
||||
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 3, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType } },
|
||||
{ TRUE , cmsSigAToB0Tag, cmsSigLutAtoBType, 5, { cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType }},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -179,12 +179,18 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
|
|||
|
||||
{
|
||||
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
|
||||
cmsStride stride;
|
||||
|
||||
p -> xform(p, InputBuffer, OutputBuffer, Size, Size);
|
||||
stride.BytesPerLineIn = 0; // Not used
|
||||
stride.BytesPerLineOut = 0;
|
||||
stride.BytesPerPlaneIn = Size;
|
||||
stride.BytesPerPlaneOut = Size;
|
||||
|
||||
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
|
||||
}
|
||||
|
||||
|
||||
// Apply transform.
|
||||
// This is a legacy stride for planar
|
||||
void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
|
@ -192,10 +198,40 @@ void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
|
|||
|
||||
{
|
||||
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
|
||||
cmsStride stride;
|
||||
|
||||
p -> xform(p, InputBuffer, OutputBuffer, Size, Stride);
|
||||
stride.BytesPerLineIn = 0;
|
||||
stride.BytesPerLineOut = 0;
|
||||
stride.BytesPerPlaneIn = Stride;
|
||||
stride.BytesPerPlaneOut = Stride;
|
||||
|
||||
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
|
||||
}
|
||||
|
||||
// This is the "fast" function for plugins
|
||||
void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
cmsUInt32Number BytesPerLineIn,
|
||||
cmsUInt32Number BytesPerLineOut,
|
||||
cmsUInt32Number BytesPerPlaneIn,
|
||||
cmsUInt32Number BytesPerPlaneOut)
|
||||
|
||||
{
|
||||
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
|
||||
cmsStride stride;
|
||||
|
||||
stride.BytesPerLineIn = BytesPerLineIn;
|
||||
stride.BytesPerLineOut = BytesPerLineOut;
|
||||
stride.BytesPerPlaneIn = BytesPerPlaneIn;
|
||||
stride.BytesPerPlaneOut = BytesPerPlaneOut;
|
||||
|
||||
p->xform(p, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, &stride);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Transform routines ----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -204,20 +240,30 @@ void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
|
|||
static
|
||||
void FloatXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsFloat32Number fIn[cmsMAXCHANNELS], fOut[cmsMAXCHANNELS];
|
||||
cmsFloat32Number OutOfGamut;
|
||||
cmsUInt32Number i, j;
|
||||
cmsUInt32Number i, j, c, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
for (i=0; i < Size; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInputFloat(p, fIn, accum, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInputFloat(p, fIn, accum, Stride->BytesPerPlaneIn);
|
||||
|
||||
// Any gamut chack to do?
|
||||
if (p->GamutCheck != NULL) {
|
||||
|
@ -229,8 +275,8 @@ void FloatXFORM(_cmsTRANSFORM* p,
|
|||
if (OutOfGamut > 0.0) {
|
||||
|
||||
// Certainly, out of gamut
|
||||
for (j=0; j < cmsMAXCHANNELS; j++)
|
||||
fOut[j] = -1.0;
|
||||
for (c = 0; c < cmsMAXCHANNELS; c++)
|
||||
fOut[c] = -1.0;
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -244,9 +290,14 @@ void FloatXFORM(_cmsTRANSFORM* p,
|
|||
cmsPipelineEvalFloat(fIn, fOut, p->Lut);
|
||||
}
|
||||
|
||||
// Back to asked representation
|
||||
output = p -> ToOutputFloat(p, fOut, output, Stride);
|
||||
|
||||
output = p->ToOutputFloat(p, fOut, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,22 +305,34 @@ static
|
|||
void NullFloatXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out,
|
||||
cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride)
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsFloat32Number fIn[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size;
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInputFloat(p, fIn, accum, Stride);
|
||||
output = p -> ToOutputFloat(p, fIn, output, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*) in + strideIn;
|
||||
output = (cmsUInt8Number*) out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInputFloat(p, fIn, accum, Stride ->BytesPerPlaneIn);
|
||||
output = p->ToOutputFloat(p, fIn, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,23 +342,36 @@ void NullFloatXFORM(_cmsTRANSFORM* p,
|
|||
static
|
||||
void NullXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size; // Buffer len
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInput(p, wIn, accum, Stride);
|
||||
output = p -> ToOutput(p, wIn, output, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
|
||||
output = p->ToOutput(p, wIn, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,23 +379,37 @@ void NullXFORM(_cmsTRANSFORM* p,
|
|||
static
|
||||
void PrecalculatedXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
register cmsUInt8Number* accum;
|
||||
register cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size;
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInput(p, wIn, accum, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
|
||||
p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
|
||||
output = p -> ToOutput(p, wOut, output, Stride);
|
||||
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,22 +440,35 @@ void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
|
|||
static
|
||||
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size; // Buffer len
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInput(p, wIn, accum, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
|
||||
TransformOnePixelWithGamutCheck(p, wIn, wOut);
|
||||
output = p -> ToOutput(p, wOut, output, Stride);
|
||||
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,17 +477,18 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
|
|||
static
|
||||
void CachedXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
_cmsCACHE Cache;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size; // Buffer len
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
// Empty buffers for quick memcmp
|
||||
memset(wIn, 0, sizeof(wIn));
|
||||
|
@ -393,75 +497,100 @@ void CachedXFORM(_cmsTRANSFORM* p,
|
|||
// Get copy of zero cache
|
||||
memcpy(&Cache, &p->Cache, sizeof(Cache));
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInput(p, wIn, accum, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
|
||||
|
||||
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
|
||||
|
||||
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
|
||||
}
|
||||
else {
|
||||
|
||||
p->Lut->Eval16Fn(wIn, wOut, p->Lut->Data);
|
||||
|
||||
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
|
||||
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
|
||||
}
|
||||
|
||||
output = p -> ToOutput(p, wOut, output, Stride);
|
||||
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// All those nice features together
|
||||
static
|
||||
void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
void* out, cmsUInt32Number Size, cmsUInt32Number Stride)
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt8Number* accum;
|
||||
cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, n;
|
||||
_cmsCACHE Cache;
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
accum = (cmsUInt8Number*) in;
|
||||
output = (cmsUInt8Number*) out;
|
||||
n = Size; // Buffer len
|
||||
_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
// Empty buffers for quick memcmp
|
||||
memset(wIn, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
|
||||
memset(wOut, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
|
||||
memset(wIn, 0, sizeof(wIn));
|
||||
memset(wOut, 0, sizeof(wOut));
|
||||
|
||||
// Get copy of zero cache
|
||||
memcpy(&Cache, &p->Cache, sizeof(Cache));
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
accum = p -> FromInput(p, wIn, accum, Stride);
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
accum = (cmsUInt8Number*)in + strideIn;
|
||||
output = (cmsUInt8Number*)out + strideOut;
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
|
||||
|
||||
if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
|
||||
|
||||
memcpy(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
|
||||
}
|
||||
else {
|
||||
TransformOnePixelWithGamutCheck(p, wIn, wOut);
|
||||
|
||||
memcpy(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
|
||||
memcpy(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
|
||||
}
|
||||
|
||||
output = p -> ToOutput(p, wOut, output, Stride);
|
||||
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
|
||||
}
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
// Transform plug-ins ----------------------------------------------------------------------------------------------------
|
||||
|
||||
// List of used-defined transform factories
|
||||
typedef struct _cmsTransformCollection_st {
|
||||
|
||||
_cmsTransformFactory Factory;
|
||||
_cmsTransform2Factory Factory;
|
||||
cmsBool OldXform; // Factory returns xform function in the old style
|
||||
|
||||
struct _cmsTransformCollection_st *Next;
|
||||
|
||||
} _cmsTransformCollection;
|
||||
|
@ -504,6 +633,7 @@ void DupPluginTransformList(struct _cmsContext_struct* ctx,
|
|||
ctx ->chunks[TransformPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTransformPluginChunkType));
|
||||
}
|
||||
|
||||
// Allocates memory for transform plugin factory
|
||||
void _cmsAllocTransformPluginChunk(struct _cmsContext_struct* ctx,
|
||||
const struct _cmsContext_struct* src)
|
||||
{
|
||||
|
@ -518,6 +648,35 @@ void _cmsAllocTransformPluginChunk(struct _cmsContext_struct* ctx,
|
|||
}
|
||||
}
|
||||
|
||||
// Adaptor for old versions of plug-in
|
||||
static
|
||||
void _cmsTransform2toTransformAdaptor(struct _cmstransform_struct *CMMcargo,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
|
||||
cmsUInt32Number i, strideIn, strideOut;
|
||||
|
||||
_cmsHandleExtraChannels(CMMcargo, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, Stride);
|
||||
|
||||
strideIn = 0;
|
||||
strideOut = 0;
|
||||
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
void *accum = (cmsUInt8Number*)InputBuffer + strideIn;
|
||||
void *output = (cmsUInt8Number*)OutputBuffer + strideOut;
|
||||
|
||||
CMMcargo->OldXform(CMMcargo, accum, output, PixelsPerLine, Stride->BytesPerPlaneIn);
|
||||
|
||||
strideIn += Stride->BytesPerLineIn;
|
||||
strideOut += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Register new ways to transform
|
||||
|
@ -535,14 +694,22 @@ cmsBool _cmsRegisterTransformPlugin(cmsContext ContextID, cmsPluginBase* Data)
|
|||
}
|
||||
|
||||
// Factory callback is required
|
||||
if (Plugin ->Factory == NULL) return FALSE;
|
||||
if (Plugin->factories.xform == NULL) return FALSE;
|
||||
|
||||
|
||||
fl = (_cmsTransformCollection*) _cmsPluginMalloc(ContextID, sizeof(_cmsTransformCollection));
|
||||
if (fl == NULL) return FALSE;
|
||||
|
||||
// Check for full xform plug-ins previous to 2.8, we would need an adapter in that case
|
||||
if (Plugin->base.ExpectedVersion < 2080) {
|
||||
|
||||
fl->OldXform = TRUE;
|
||||
}
|
||||
else
|
||||
fl->OldXform = FALSE;
|
||||
|
||||
// Copy the parameters
|
||||
fl ->Factory = Plugin ->Factory;
|
||||
fl->Factory = Plugin->factories.xform;
|
||||
|
||||
// Keep linked list
|
||||
fl ->Next = ctx->TransformCollection;
|
||||
|
@ -600,6 +767,8 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
|
|||
p->Lut = lut;
|
||||
|
||||
// Let's see if any plug-in want to do the transform by itself
|
||||
if (p->Lut != NULL) {
|
||||
|
||||
for (Plugin = ctx->TransformCollection;
|
||||
Plugin != NULL;
|
||||
Plugin = Plugin->Next) {
|
||||
|
@ -625,13 +794,19 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
|
|||
p->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
p->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
|
||||
// Save the day?
|
||||
if (Plugin->OldXform) {
|
||||
p->OldXform = (_cmsTransformFn) p->xform;
|
||||
p->xform = _cmsTransform2toTransformAdaptor;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// Not suitable for the transform plug-in, let's check the pipeline plug-in
|
||||
if (p ->Lut != NULL)
|
||||
_cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags);
|
||||
}
|
||||
|
||||
// Check whatever this is a true floating point transform
|
||||
if (_cmsFormatterIsFloat(*InputFormat) && _cmsFormatterIsFloat(*OutputFormat)) {
|
||||
|
@ -785,6 +960,22 @@ cmsBool IsProperColorSpace(cmsColorSpaceSignature Check, cmsUInt32Number dwForm
|
|||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Jun-21-2000: Some profiles (those that comes with W2K) comes
|
||||
// with the media white (media black?) x 100. Add a sanity check
|
||||
|
||||
static
|
||||
void NormalizeXYZ(cmsCIEXYZ* Dest)
|
||||
{
|
||||
while (Dest -> X > 2. &&
|
||||
Dest -> Y > 2. &&
|
||||
Dest -> Z > 2.) {
|
||||
|
||||
Dest -> X /= 10.;
|
||||
Dest -> Y /= 10.;
|
||||
Dest -> Z /= 10.;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void SetWhitePoint(cmsCIEXYZ* wtPt, const cmsCIEXYZ* src)
|
||||
{
|
||||
|
@ -797,6 +988,8 @@ void SetWhitePoint(cmsCIEXYZ* wtPt, const cmsCIEXYZ* src)
|
|||
wtPt ->X = src->X;
|
||||
wtPt ->Y = src->Y;
|
||||
wtPt ->Z = src->Z;
|
||||
|
||||
NormalizeXYZ(wtPt);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1107,7 +1300,6 @@ cmsBool CMSEXPORT cmsChangeBuffersFormat(cmsHTRANSFORM hTransform,
|
|||
cmsUInt32Number InputFormat,
|
||||
cmsUInt32Number OutputFormat)
|
||||
{
|
||||
|
||||
_cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
|
||||
cmsFormatter16 FromInput, ToOutput;
|
||||
|
||||
|
|
|
@ -1,341 +0,0 @@
|
|||
LIBRARY LCMS2.DLL
|
||||
|
||||
EXPORTS
|
||||
|
||||
_cms15Fixed16toDouble = _cms15Fixed16toDouble
|
||||
_cms8Fixed8toDouble = _cms8Fixed8toDouble
|
||||
cmsAdaptToIlluminant = cmsAdaptToIlluminant
|
||||
_cmsAdjustEndianess16 = _cmsAdjustEndianess16
|
||||
_cmsAdjustEndianess32 = _cmsAdjustEndianess32
|
||||
_cmsAdjustEndianess64 = _cmsAdjustEndianess64
|
||||
cmsAllocNamedColorList = cmsAllocNamedColorList
|
||||
cmsAllocProfileSequenceDescription = cmsAllocProfileSequenceDescription
|
||||
cmsAppendNamedColor = cmsAppendNamedColor
|
||||
cmsBFDdeltaE = cmsBFDdeltaE
|
||||
cmsBuildGamma = cmsBuildGamma
|
||||
cmsBuildParametricToneCurve = cmsBuildParametricToneCurve
|
||||
cmsBuildSegmentedToneCurve = cmsBuildSegmentedToneCurve
|
||||
cmsBuildTabulatedToneCurve16 = cmsBuildTabulatedToneCurve16
|
||||
cmsBuildTabulatedToneCurveFloat = cmsBuildTabulatedToneCurveFloat
|
||||
_cmsCalloc = _cmsCalloc
|
||||
cmsChannelsOf = cmsChannelsOf
|
||||
cmsCIE2000DeltaE = cmsCIE2000DeltaE
|
||||
cmsCIE94DeltaE = cmsCIE94DeltaE
|
||||
cmsCIECAM02Done = cmsCIECAM02Done
|
||||
cmsCIECAM02Forward = cmsCIECAM02Forward
|
||||
cmsCIECAM02Init = cmsCIECAM02Init
|
||||
cmsCIECAM02Reverse = cmsCIECAM02Reverse
|
||||
cmsCloseIOhandler = cmsCloseIOhandler
|
||||
cmsCloseProfile = cmsCloseProfile
|
||||
cmsCMCdeltaE = cmsCMCdeltaE
|
||||
cmsCreate_sRGBProfile = cmsCreate_sRGBProfile
|
||||
cmsCreate_sRGBProfileTHR = cmsCreate_sRGBProfileTHR
|
||||
cmsCreateBCHSWabstractProfile = cmsCreateBCHSWabstractProfile
|
||||
cmsCreateBCHSWabstractProfileTHR = cmsCreateBCHSWabstractProfileTHR
|
||||
cmsCreateExtendedTransform = cmsCreateExtendedTransform
|
||||
cmsCreateGrayProfile = cmsCreateGrayProfile
|
||||
cmsCreateGrayProfileTHR = cmsCreateGrayProfileTHR
|
||||
cmsCreateInkLimitingDeviceLink = cmsCreateInkLimitingDeviceLink
|
||||
cmsCreateInkLimitingDeviceLinkTHR = cmsCreateInkLimitingDeviceLinkTHR
|
||||
cmsCreateLab2Profile = cmsCreateLab2Profile
|
||||
cmsCreateLab2ProfileTHR = cmsCreateLab2ProfileTHR
|
||||
cmsCreateLab4Profile = cmsCreateLab4Profile
|
||||
cmsCreateLab4ProfileTHR = cmsCreateLab4ProfileTHR
|
||||
cmsCreateLinearizationDeviceLink = cmsCreateLinearizationDeviceLink
|
||||
cmsCreateLinearizationDeviceLinkTHR = cmsCreateLinearizationDeviceLinkTHR
|
||||
cmsCreateMultiprofileTransform = cmsCreateMultiprofileTransform
|
||||
cmsCreateMultiprofileTransformTHR = cmsCreateMultiprofileTransformTHR
|
||||
cmsCreateNULLProfile = cmsCreateNULLProfile
|
||||
cmsCreateNULLProfileTHR = cmsCreateNULLProfileTHR
|
||||
cmsCreateProfilePlaceholder = cmsCreateProfilePlaceholder
|
||||
cmsCreateProofingTransform = cmsCreateProofingTransform
|
||||
cmsCreateProofingTransformTHR = cmsCreateProofingTransformTHR
|
||||
cmsCreateRGBProfile = cmsCreateRGBProfile
|
||||
cmsCreateRGBProfileTHR = cmsCreateRGBProfileTHR
|
||||
cmsCreateTransform = cmsCreateTransform
|
||||
cmsCreateTransformTHR = cmsCreateTransformTHR
|
||||
cmsCreateXYZProfile = cmsCreateXYZProfile
|
||||
cmsCreateXYZProfileTHR = cmsCreateXYZProfileTHR
|
||||
cmsD50_xyY = cmsD50_xyY
|
||||
cmsD50_XYZ = cmsD50_XYZ
|
||||
_cmsDecodeDateTimeNumber = _cmsDecodeDateTimeNumber
|
||||
_cmsDefaultICCintents = _cmsDefaultICCintents
|
||||
cmsDeleteTransform = cmsDeleteTransform
|
||||
cmsDeltaE = cmsDeltaE
|
||||
cmsDetectBlackPoint = cmsDetectBlackPoint
|
||||
cmsDetectDestinationBlackPoint = cmsDetectDestinationBlackPoint
|
||||
cmsDetectTAC = cmsDetectTAC
|
||||
cmsDesaturateLab = cmsDesaturateLab
|
||||
cmsDoTransform = cmsDoTransform
|
||||
cmsDoTransformStride = cmsDoTransformStride
|
||||
_cmsDoubleTo15Fixed16 = _cmsDoubleTo15Fixed16
|
||||
_cmsDoubleTo8Fixed8 = _cmsDoubleTo8Fixed8
|
||||
_cmsDupMem = _cmsDupMem
|
||||
cmsDupNamedColorList = cmsDupNamedColorList
|
||||
cmsDupProfileSequenceDescription = cmsDupProfileSequenceDescription
|
||||
cmsDupToneCurve = cmsDupToneCurve
|
||||
_cmsEncodeDateTimeNumber = _cmsEncodeDateTimeNumber
|
||||
cmsEstimateGamma = cmsEstimateGamma
|
||||
cmsGetToneCurveEstimatedTableEntries = cmsGetToneCurveEstimatedTableEntries
|
||||
cmsGetToneCurveEstimatedTable = cmsGetToneCurveEstimatedTable
|
||||
cmsEvalToneCurve16 = cmsEvalToneCurve16
|
||||
cmsEvalToneCurveFloat = cmsEvalToneCurveFloat
|
||||
cmsfilelength = cmsfilelength
|
||||
cmsFloat2LabEncoded = cmsFloat2LabEncoded
|
||||
cmsFloat2LabEncodedV2 = cmsFloat2LabEncodedV2
|
||||
cmsFloat2XYZEncoded = cmsFloat2XYZEncoded
|
||||
cmsFormatterForColorspaceOfProfile = cmsFormatterForColorspaceOfProfile
|
||||
cmsFormatterForPCSOfProfile = cmsFormatterForPCSOfProfile
|
||||
_cmsFree = _cmsFree
|
||||
cmsFreeNamedColorList = cmsFreeNamedColorList
|
||||
cmsFreeProfileSequenceDescription = cmsFreeProfileSequenceDescription
|
||||
cmsFreeToneCurve = cmsFreeToneCurve
|
||||
cmsFreeToneCurveTriple = cmsFreeToneCurveTriple
|
||||
cmsGBDAlloc = cmsGBDAlloc
|
||||
cmsGBDFree = cmsGBDFree
|
||||
cmsGDBAddPoint = cmsGDBAddPoint
|
||||
cmsGDBCheckPoint = cmsGDBCheckPoint
|
||||
cmsGDBCompute = cmsGDBCompute
|
||||
cmsGetAlarmCodes = cmsGetAlarmCodes
|
||||
cmsGetColorSpace = cmsGetColorSpace
|
||||
cmsGetDeviceClass = cmsGetDeviceClass
|
||||
cmsGetEncodedICCversion = cmsGetEncodedICCversion
|
||||
cmsGetHeaderAttributes = cmsGetHeaderAttributes
|
||||
cmsGetHeaderCreationDateTime = cmsGetHeaderCreationDateTime
|
||||
cmsGetHeaderFlags = cmsGetHeaderFlags
|
||||
cmsGetHeaderManufacturer = cmsGetHeaderManufacturer
|
||||
cmsGetHeaderModel = cmsGetHeaderModel
|
||||
cmsGetHeaderProfileID = cmsGetHeaderProfileID
|
||||
cmsGetHeaderRenderingIntent = cmsGetHeaderRenderingIntent
|
||||
cmsGetNamedColorList = cmsGetNamedColorList
|
||||
cmsGetPCS = cmsGetPCS
|
||||
cmsGetPostScriptColorResource = cmsGetPostScriptColorResource
|
||||
cmsGetPostScriptCRD = cmsGetPostScriptCRD
|
||||
cmsGetPostScriptCSA = cmsGetPostScriptCSA
|
||||
cmsGetProfileInfo = cmsGetProfileInfo
|
||||
cmsGetProfileInfoASCII = cmsGetProfileInfoASCII
|
||||
cmsGetProfileContextID = cmsGetProfileContextID
|
||||
cmsGetProfileVersion = cmsGetProfileVersion
|
||||
cmsGetSupportedIntents = cmsGetSupportedIntents
|
||||
cmsGetTagCount = cmsGetTagCount
|
||||
cmsGetTagSignature = cmsGetTagSignature
|
||||
cmsGetTransformContextID = cmsGetTransformContextID
|
||||
_cmsICCcolorSpace = _cmsICCcolorSpace
|
||||
_cmsIOPrintf = _cmsIOPrintf
|
||||
cmsIsCLUT = cmsIsCLUT
|
||||
cmsIsIntentSupported = cmsIsIntentSupported
|
||||
cmsIsMatrixShaper = cmsIsMatrixShaper
|
||||
cmsIsTag = cmsIsTag
|
||||
cmsIsToneCurveDescending = cmsIsToneCurveDescending
|
||||
cmsIsToneCurveLinear = cmsIsToneCurveLinear
|
||||
cmsIsToneCurveMonotonic = cmsIsToneCurveMonotonic
|
||||
cmsIsToneCurveMultisegment = cmsIsToneCurveMultisegment
|
||||
cmsGetToneCurveParametricType = cmsGetToneCurveParametricType
|
||||
cmsIT8Alloc = cmsIT8Alloc
|
||||
cmsIT8DefineDblFormat = cmsIT8DefineDblFormat
|
||||
cmsIT8EnumDataFormat = cmsIT8EnumDataFormat
|
||||
cmsIT8EnumProperties = cmsIT8EnumProperties
|
||||
cmsIT8EnumPropertyMulti = cmsIT8EnumPropertyMulti
|
||||
cmsIT8Free = cmsIT8Free
|
||||
cmsIT8GetData = cmsIT8GetData
|
||||
cmsIT8GetDataDbl = cmsIT8GetDataDbl
|
||||
cmsIT8FindDataFormat = cmsIT8FindDataFormat
|
||||
cmsIT8GetDataRowCol = cmsIT8GetDataRowCol
|
||||
cmsIT8GetDataRowColDbl = cmsIT8GetDataRowColDbl
|
||||
cmsIT8GetPatchName = cmsIT8GetPatchName
|
||||
cmsIT8GetPatchByName = cmsIT8GetPatchByName
|
||||
cmsIT8GetProperty = cmsIT8GetProperty
|
||||
cmsIT8GetPropertyDbl = cmsIT8GetPropertyDbl
|
||||
cmsIT8GetPropertyMulti = cmsIT8GetPropertyMulti
|
||||
cmsIT8GetSheetType = cmsIT8GetSheetType
|
||||
cmsIT8LoadFromFile = cmsIT8LoadFromFile
|
||||
cmsIT8LoadFromMem = cmsIT8LoadFromMem
|
||||
cmsIT8SaveToFile = cmsIT8SaveToFile
|
||||
cmsIT8SaveToMem = cmsIT8SaveToMem
|
||||
cmsIT8SetComment = cmsIT8SetComment
|
||||
cmsIT8SetData = cmsIT8SetData
|
||||
cmsIT8SetDataDbl = cmsIT8SetDataDbl
|
||||
cmsIT8SetDataFormat = cmsIT8SetDataFormat
|
||||
cmsIT8SetDataRowCol = cmsIT8SetDataRowCol
|
||||
cmsIT8SetDataRowColDbl = cmsIT8SetDataRowColDbl
|
||||
cmsIT8SetPropertyDbl = cmsIT8SetPropertyDbl
|
||||
cmsIT8SetPropertyHex = cmsIT8SetPropertyHex
|
||||
cmsIT8SetPropertyStr = cmsIT8SetPropertyStr
|
||||
cmsIT8SetPropertyMulti = cmsIT8SetPropertyMulti
|
||||
cmsIT8SetPropertyUncooked = cmsIT8SetPropertyUncooked
|
||||
cmsIT8SetSheetType = cmsIT8SetSheetType
|
||||
cmsIT8SetTable = cmsIT8SetTable
|
||||
cmsIT8SetTableByLabel = cmsIT8SetTableByLabel
|
||||
cmsIT8SetIndexColumn = cmsIT8SetIndexColumn
|
||||
cmsIT8TableCount = cmsIT8TableCount
|
||||
cmsJoinToneCurve = cmsJoinToneCurve
|
||||
cmsLab2LCh = cmsLab2LCh
|
||||
cmsLab2XYZ = cmsLab2XYZ
|
||||
cmsLabEncoded2Float = cmsLabEncoded2Float
|
||||
cmsLabEncoded2FloatV2 = cmsLabEncoded2FloatV2
|
||||
cmsLCh2Lab = cmsLCh2Lab
|
||||
_cmsLCMScolorSpace = _cmsLCMScolorSpace
|
||||
cmsLinkTag = cmsLinkTag
|
||||
cmsTagLinkedTo = cmsTagLinkedTo
|
||||
cmsPipelineAlloc = cmsPipelineAlloc
|
||||
cmsPipelineCat = cmsPipelineCat
|
||||
cmsPipelineCheckAndRetreiveStages = cmsPipelineCheckAndRetreiveStages
|
||||
cmsPipelineDup = cmsPipelineDup
|
||||
cmsPipelineStageCount = cmsPipelineStageCount
|
||||
cmsPipelineEval16 = cmsPipelineEval16
|
||||
cmsPipelineEvalFloat = cmsPipelineEvalFloat
|
||||
cmsPipelineEvalReverseFloat = cmsPipelineEvalReverseFloat
|
||||
cmsPipelineFree = cmsPipelineFree
|
||||
cmsPipelineGetPtrToFirstStage = cmsPipelineGetPtrToFirstStage
|
||||
cmsPipelineGetPtrToLastStage = cmsPipelineGetPtrToLastStage
|
||||
cmsPipelineInputChannels = cmsPipelineInputChannels
|
||||
cmsPipelineInsertStage = cmsPipelineInsertStage
|
||||
cmsPipelineOutputChannels = cmsPipelineOutputChannels
|
||||
cmsPipelineSetSaveAs8bitsFlag = cmsPipelineSetSaveAs8bitsFlag
|
||||
_cmsPipelineSetOptimizationParameters = _cmsPipelineSetOptimizationParameters
|
||||
cmsPipelineUnlinkStage = cmsPipelineUnlinkStage
|
||||
_cmsMalloc = _cmsMalloc
|
||||
_cmsMallocZero = _cmsMallocZero
|
||||
_cmsMAT3eval = _cmsMAT3eval
|
||||
_cmsMAT3identity = _cmsMAT3identity
|
||||
_cmsMAT3inverse = _cmsMAT3inverse
|
||||
_cmsMAT3isIdentity = _cmsMAT3isIdentity
|
||||
_cmsMAT3per = _cmsMAT3per
|
||||
_cmsMAT3solve = _cmsMAT3solve
|
||||
cmsMD5computeID = cmsMD5computeID
|
||||
cmsMLUalloc = cmsMLUalloc
|
||||
cmsMLUdup = cmsMLUdup
|
||||
cmsMLUfree = cmsMLUfree
|
||||
cmsMLUgetASCII = cmsMLUgetASCII
|
||||
cmsMLUgetTranslation = cmsMLUgetTranslation
|
||||
cmsMLUgetWide = cmsMLUgetWide
|
||||
cmsMLUsetASCII = cmsMLUsetASCII
|
||||
cmsMLUsetWide = cmsMLUsetWide
|
||||
cmsStageAllocCLut16bit = cmsStageAllocCLut16bit
|
||||
cmsStageAllocCLut16bitGranular = cmsStageAllocCLut16bitGranular
|
||||
cmsStageAllocCLutFloat = cmsStageAllocCLutFloat
|
||||
cmsStageAllocCLutFloatGranular = cmsStageAllocCLutFloatGranular
|
||||
cmsStageAllocToneCurves = cmsStageAllocToneCurves
|
||||
cmsStageAllocIdentity = cmsStageAllocIdentity
|
||||
cmsStageAllocMatrix = cmsStageAllocMatrix
|
||||
_cmsStageAllocPlaceholder = _cmsStageAllocPlaceholder
|
||||
cmsStageDup = cmsStageDup
|
||||
cmsStageFree = cmsStageFree
|
||||
cmsStageNext = cmsStageNext
|
||||
cmsStageInputChannels = cmsStageInputChannels
|
||||
cmsStageOutputChannels = cmsStageOutputChannels
|
||||
cmsStageSampleCLut16bit = cmsStageSampleCLut16bit
|
||||
cmsStageSampleCLutFloat = cmsStageSampleCLutFloat
|
||||
cmsStageType = cmsStageType
|
||||
cmsStageData = cmsStageData
|
||||
cmsNamedColorCount = cmsNamedColorCount
|
||||
cmsNamedColorIndex = cmsNamedColorIndex
|
||||
cmsNamedColorInfo = cmsNamedColorInfo
|
||||
cmsOpenIOhandlerFromFile = cmsOpenIOhandlerFromFile
|
||||
cmsOpenIOhandlerFromMem = cmsOpenIOhandlerFromMem
|
||||
cmsOpenIOhandlerFromNULL = cmsOpenIOhandlerFromNULL
|
||||
cmsOpenIOhandlerFromStream = cmsOpenIOhandlerFromStream
|
||||
cmsOpenProfileFromFile = cmsOpenProfileFromFile
|
||||
cmsOpenProfileFromFileTHR = cmsOpenProfileFromFileTHR
|
||||
cmsOpenProfileFromIOhandlerTHR = cmsOpenProfileFromIOhandlerTHR
|
||||
cmsOpenProfileFromMem = cmsOpenProfileFromMem
|
||||
cmsOpenProfileFromMemTHR = cmsOpenProfileFromMemTHR
|
||||
cmsOpenProfileFromStream = cmsOpenProfileFromStream
|
||||
cmsOpenProfileFromStreamTHR = cmsOpenProfileFromStreamTHR
|
||||
cmsPlugin = cmsPlugin
|
||||
_cmsRead15Fixed16Number = _cmsRead15Fixed16Number
|
||||
_cmsReadAlignment = _cmsReadAlignment
|
||||
_cmsReadFloat32Number = _cmsReadFloat32Number
|
||||
cmsReadRawTag = cmsReadRawTag
|
||||
cmsReadTag = cmsReadTag
|
||||
_cmsReadTypeBase = _cmsReadTypeBase
|
||||
_cmsReadUInt16Array = _cmsReadUInt16Array
|
||||
_cmsReadUInt16Number = _cmsReadUInt16Number
|
||||
_cmsReadUInt32Number = _cmsReadUInt32Number
|
||||
_cmsReadUInt64Number = _cmsReadUInt64Number
|
||||
_cmsReadUInt8Number = _cmsReadUInt8Number
|
||||
_cmsReadXYZNumber = _cmsReadXYZNumber
|
||||
_cmsRealloc = _cmsRealloc
|
||||
cmsReverseToneCurve = cmsReverseToneCurve
|
||||
cmsReverseToneCurveEx = cmsReverseToneCurveEx
|
||||
cmsSaveProfileToFile = cmsSaveProfileToFile
|
||||
cmsSaveProfileToIOhandler = cmsSaveProfileToIOhandler
|
||||
cmsSaveProfileToMem = cmsSaveProfileToMem
|
||||
cmsSaveProfileToStream = cmsSaveProfileToStream
|
||||
cmsSetAdaptationState = cmsSetAdaptationState
|
||||
cmsSetAlarmCodes = cmsSetAlarmCodes
|
||||
cmsSetColorSpace = cmsSetColorSpace
|
||||
cmsSetDeviceClass = cmsSetDeviceClass
|
||||
cmsSetEncodedICCversion = cmsSetEncodedICCversion
|
||||
cmsSetHeaderAttributes = cmsSetHeaderAttributes
|
||||
cmsSetHeaderFlags = cmsSetHeaderFlags
|
||||
cmsSetHeaderManufacturer = cmsSetHeaderManufacturer
|
||||
cmsSetHeaderModel = cmsSetHeaderModel
|
||||
cmsSetHeaderProfileID = cmsSetHeaderProfileID
|
||||
cmsSetHeaderRenderingIntent = cmsSetHeaderRenderingIntent
|
||||
cmsSetLogErrorHandler = cmsSetLogErrorHandler
|
||||
cmsSetPCS = cmsSetPCS
|
||||
cmsSetProfileVersion = cmsSetProfileVersion
|
||||
cmsSignalError = cmsSignalError
|
||||
cmsSmoothToneCurve = cmsSmoothToneCurve
|
||||
cmsstrcasecmp = cmsstrcasecmp
|
||||
cmsTempFromWhitePoint = cmsTempFromWhitePoint
|
||||
cmsTransform2DeviceLink = cmsTransform2DeviceLink
|
||||
cmsUnregisterPlugins = cmsUnregisterPlugins
|
||||
_cmsVEC3cross = _cmsVEC3cross
|
||||
_cmsVEC3distance = _cmsVEC3distance
|
||||
_cmsVEC3dot = _cmsVEC3dot
|
||||
_cmsVEC3init = _cmsVEC3init
|
||||
_cmsVEC3length = _cmsVEC3length
|
||||
_cmsVEC3minus = _cmsVEC3minus
|
||||
cmsWhitePointFromTemp = cmsWhitePointFromTemp
|
||||
_cmsWrite15Fixed16Number = _cmsWrite15Fixed16Number
|
||||
_cmsWriteAlignment = _cmsWriteAlignment
|
||||
_cmsWriteFloat32Number = _cmsWriteFloat32Number
|
||||
cmsWriteRawTag = cmsWriteRawTag
|
||||
cmsWriteTag = cmsWriteTag
|
||||
_cmsWriteTypeBase = _cmsWriteTypeBase
|
||||
_cmsWriteUInt16Array = _cmsWriteUInt16Array
|
||||
_cmsWriteUInt16Number = _cmsWriteUInt16Number
|
||||
_cmsWriteUInt32Number = _cmsWriteUInt32Number
|
||||
_cmsWriteUInt64Number = _cmsWriteUInt64Number
|
||||
_cmsWriteUInt8Number = _cmsWriteUInt8Number
|
||||
_cmsWriteXYZNumber = _cmsWriteXYZNumber
|
||||
cmsxyY2XYZ = cmsxyY2XYZ
|
||||
cmsXYZ2Lab = cmsXYZ2Lab
|
||||
cmsXYZ2xyY = cmsXYZ2xyY
|
||||
cmsXYZEncoded2Float = cmsXYZEncoded2Float
|
||||
cmsSliceSpace16 = cmsSliceSpace16
|
||||
cmsSliceSpaceFloat = cmsSliceSpaceFloat
|
||||
cmsChangeBuffersFormat = cmsChangeBuffersFormat
|
||||
cmsDictAlloc = cmsDictAlloc
|
||||
cmsDictFree = cmsDictFree
|
||||
cmsDictDup = cmsDictDup
|
||||
cmsDictAddEntry = cmsDictAddEntry
|
||||
cmsDictGetEntryList = cmsDictGetEntryList
|
||||
cmsDictNextEntry = cmsDictNextEntry
|
||||
_cmsGetTransformUserData = _cmsGetTransformUserData
|
||||
_cmsSetTransformUserData = _cmsSetTransformUserData
|
||||
_cmsGetTransformFormatters16 = _cmsGetTransformFormatters16
|
||||
_cmsGetTransformFormattersFloat = _cmsGetTransformFormattersFloat
|
||||
cmsGetHeaderCreator = cmsGetHeaderCreator
|
||||
cmsPluginTHR = cmsPluginTHR
|
||||
cmsGetPipelineContextID = cmsGetPipelineContextID
|
||||
cmsGetTransformInputFormat = cmsGetTransformInputFormat
|
||||
cmsGetTransformOutputFormat = cmsGetTransformOutputFormat
|
||||
cmsCreateContext = cmsCreateContext
|
||||
cmsDupContext = cmsDupContext
|
||||
cmsDeleteContext = cmsDeleteContext
|
||||
cmsGetContextUserData = cmsGetContextUserData
|
||||
cmsUnregisterPluginsTHR = cmsUnregisterPluginsTHR
|
||||
cmsSetAlarmCodesTHR = cmsSetAlarmCodesTHR
|
||||
cmsGetAlarmCodesTHR = cmsGetAlarmCodesTHR
|
||||
cmsSetAdaptationStateTHR = cmsSetAdaptationStateTHR
|
||||
cmsSetLogErrorHandlerTHR = cmsSetLogErrorHandlerTHR
|
||||
cmsGetSupportedIntentsTHR = cmsGetSupportedIntentsTHR
|
||||
cmsMLUtranslationsCount = cmsMLUtranslationsCount
|
||||
cmsMLUtranslationsCodes = cmsMLUtranslationsCodes
|
||||
_cmsCreateMutex = _cmsCreateMutex
|
||||
_cmsDestroyMutex = _cmsDestroyMutex
|
||||
_cmsLockMutex = _cmsLockMutex
|
||||
_cmsUnlockMutex = _cmsUnlockMutex
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -57,7 +57,15 @@
|
|||
#define _cmsALIGNLONG(x) (((x)+(sizeof(cmsUInt32Number)-1)) & ~(sizeof(cmsUInt32Number)-1))
|
||||
|
||||
// Alignment to memory pointer
|
||||
#define _cmsALIGNMEM(x) (((x)+(sizeof(void *) - 1)) & ~(sizeof(void *) - 1))
|
||||
|
||||
// (Ultra)SPARC with gcc requires ptr alignment of 8 bytes
|
||||
// even though sizeof(void *) is only four: for greatest flexibility
|
||||
// allow the build to specify ptr alignment.
|
||||
#ifndef CMS_PTR_ALIGNMENT
|
||||
# define CMS_PTR_ALIGNMENT sizeof(void *)
|
||||
#endif
|
||||
|
||||
#define _cmsALIGNMEM(x) (((x)+(CMS_PTR_ALIGNMENT - 1)) & ~(CMS_PTR_ALIGNMENT - 1))
|
||||
|
||||
// Maximum encodeable values in floating point
|
||||
#define MAX_ENCODEABLE_XYZ (1.0 + 32767.0/32768.0)
|
||||
|
@ -93,7 +101,7 @@
|
|||
|
||||
// A fast way to convert from/to 16 <-> 8 bits
|
||||
#define FROM_8_TO_16(rgb) (cmsUInt16Number) ((((cmsUInt16Number) (rgb)) << 8)|(rgb))
|
||||
#define FROM_16_TO_8(rgb) (cmsUInt8Number) ((((rgb) * 65281 + 8388608) >> 24) & 0xFF)
|
||||
#define FROM_16_TO_8(rgb) (cmsUInt8Number) ((((cmsUInt32Number)(rgb) * 65281U + 8388608U) >> 24) & 0xFFU)
|
||||
|
||||
// Code analysis is broken on asserts
|
||||
#ifdef _MSC_VER
|
||||
|
@ -194,11 +202,17 @@ cmsINLINE cmsUInt16Number _cmsQuickSaturateWord(cmsFloat64Number d)
|
|||
// Microsoft felt that it was necessary to keep it set at -1 for an unlocked critical
|
||||
// section, even when they changed the underlying algorithm to be more scalable.
|
||||
// The final parts of the critical section object are unimportant, and can be set
|
||||
// to zero for their defaults. This yields an initialization macro:
|
||||
// to zero for their defaults. This yields to an initialization macro:
|
||||
|
||||
typedef CRITICAL_SECTION _cmsMutex;
|
||||
|
||||
#define CMS_MUTEX_INITIALIZER {(void*) -1,-1,0,0,0,0}
|
||||
#define CMS_MUTEX_INITIALIZER {(PRTL_CRITICAL_SECTION_DEBUG) -1,-1,0,0,0,0}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if (_MSC_VER >= 1800)
|
||||
# pragma warning(disable : 26135)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
cmsINLINE int _cmsLockPrimitive(_cmsMutex *m)
|
||||
{
|
||||
|
@ -284,38 +298,38 @@ typedef int _cmsMutex;
|
|||
|
||||
cmsINLINE int _cmsLockPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmsINLINE int _cmsUnlockPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmsINLINE int _cmsInitMutexPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmsINLINE int _cmsDestroyMutexPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmsINLINE int _cmsEnterCriticalSectionPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmsINLINE int _cmsLeaveCriticalSectionPrimitive(_cmsMutex *m)
|
||||
{
|
||||
return 0;
|
||||
cmsUNUSED_PARAMETER(m);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -656,8 +670,8 @@ struct _cms_MLU_struct {
|
|||
cmsContext ContextID;
|
||||
|
||||
// The directory
|
||||
int AllocatedEntries;
|
||||
int UsedEntries;
|
||||
cmsUInt32Number AllocatedEntries;
|
||||
cmsUInt32Number UsedEntries;
|
||||
_cmsMLUentry* Entries; // Array of pointers to strings allocated in MemPool
|
||||
|
||||
// The Pool
|
||||
|
@ -823,6 +837,8 @@ cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID);
|
|||
cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID);
|
||||
cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID);
|
||||
cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID);
|
||||
cmsStage* _cmsStageClipNegatives(cmsContext ContextID, int nChannels);
|
||||
|
||||
|
||||
// For curve set only
|
||||
cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe);
|
||||
|
@ -951,7 +967,7 @@ typedef struct _cmstransform_struct {
|
|||
cmsUInt32Number InputFormat, OutputFormat; // Keep formats for further reference
|
||||
|
||||
// Points to transform code
|
||||
_cmsTransformFn xform;
|
||||
_cmsTransform2Fn xform;
|
||||
|
||||
// Formatters, cannot be embedded into LUT because cache
|
||||
cmsFormatter16 FromInput;
|
||||
|
@ -997,9 +1013,20 @@ typedef struct _cmstransform_struct {
|
|||
void* UserData;
|
||||
_cmsFreeUserDataFn FreeUserData;
|
||||
|
||||
// A way to provide backwards compatibility with full xform plugins
|
||||
_cmsTransformFn OldXform;
|
||||
|
||||
} _cmsTRANSFORM;
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
// Copies extra channels from input to output if the original flags in the transform structure
|
||||
// instructs to do so. This function is called on all standard transform functions.
|
||||
void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
|
||||
cmsUInt32Number nProfiles,
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
PROJECT(libpng C)
|
||||
project(libpng C)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/include
|
||||
)
|
||||
|
||||
FILE(GLOB SRCS *.c)
|
||||
FILE(GLOB HDRS *.h)
|
||||
SET(EXT_HDRS
|
||||
file(GLOB SRCS *.c)
|
||||
file(GLOB HDRS *.h)
|
||||
set(EXT_HDRS
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/include/zlib.h
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/include/zconf.h
|
||||
)
|
||||
#
|
||||
SET(LIBTARGET "png")
|
||||
set(LIBTARGET "png")
|
||||
#
|
||||
ADD_LIBRARY(${LIBTARGET} STATIC ${SRCS} ${HDRS} ${EXT_HDRS})
|
||||
add_library(${LIBTARGET} STATIC ${SRCS} ${HDRS} ${EXT_HDRS})
|
||||
#
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
ENDIF(MSVC)
|
||||
if(MSVC)
|
||||
set_target_properties(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
endif(MSVC)
|
||||
#
|
||||
TARGET_LINK_LIBRARIES(${LIBTARGET} ${Z_LIBNAME} ${M_LIBRARY})
|
||||
target_link_libraries(${LIBTARGET} ${Z_LIBNAME} ${M_LIBRARY})
|
||||
#
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET}
|
||||
set_target_properties(${LIBTARGET}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${LIBTARGET}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/lib)
|
||||
|
|
|
@ -10,21 +10,18 @@ this sentence.
|
|||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.17, March 26, 2015, are
|
||||
Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
Cosmin Truta
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
|
@ -36,18 +33,20 @@ and with the following additions to the disclaimer:
|
|||
the user.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.96,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
libpng-0.96, and are distributed according to the same disclaimer and
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
and are distributed according to the same disclaimer and license as
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
|
@ -57,7 +56,7 @@ with the following individuals added to the list of Contributing Authors:
|
|||
Tom Tanner
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
@ -94,6 +93,7 @@ supporting the PNG file format in commercial products. If you use this
|
|||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
|
||||
A "png_get_copyright" function is available, for convenient use in "about"
|
||||
boxes and the like:
|
||||
|
@ -103,9 +103,10 @@ boxes and the like:
|
|||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
March 26, 2015
|
||||
January 15, 2016
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
|||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_17 Your_png_h_is_not_version_1_6_17;
|
||||
typedef png_libpng_version_1_6_21 Your_png_h_is_not_version_1_6_21;
|
||||
|
||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||
* of the PNG file signature. If the PNG data is embedded into another
|
||||
|
@ -26,15 +26,20 @@ typedef png_libpng_version_1_6_17 Your_png_h_is_not_version_1_6_17;
|
|||
void PNGAPI
|
||||
png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
||||
{
|
||||
unsigned int nb = (unsigned int)num_bytes;
|
||||
|
||||
png_debug(1, "in png_set_sig_bytes");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (num_bytes > 8)
|
||||
if (num_bytes < 0)
|
||||
nb = 0;
|
||||
|
||||
if (nb > 8)
|
||||
png_error(png_ptr, "Too many bytes for PNG signature");
|
||||
|
||||
png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff);
|
||||
png_ptr->sig_bytes = (png_byte)nb;
|
||||
}
|
||||
|
||||
/* Checks whether the supplied bytes match the PNG signature. We allow
|
||||
|
@ -101,7 +106,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
|||
void /* PRIVATE */
|
||||
png_reset_crc(png_structrp png_ptr)
|
||||
{
|
||||
/* The cast is safe because the crc is a 32 bit value. */
|
||||
/* The cast is safe because the crc is a 32-bit value. */
|
||||
png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
|
||||
}
|
||||
|
||||
|
@ -129,7 +134,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
|||
}
|
||||
|
||||
/* 'uLong' is defined in zlib.h as unsigned long; this means that on some
|
||||
* systems it is a 64 bit value. crc32, however, returns 32 bits so the
|
||||
* systems it is a 64-bit value. crc32, however, returns 32 bits so the
|
||||
* following cast is safe. 'uInt' may be no more than 16 bits, so it is
|
||||
* necessary to perform a loop here.
|
||||
*/
|
||||
|
@ -275,7 +280,9 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
if (!setjmp(create_jmp_buf))
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
/* Temporarily fake out the longjmp information until we have
|
||||
* successfully completed this function. This only works if we have
|
||||
* setjmp() support compiled in, but it is safe - this stuff should
|
||||
|
@ -284,8 +291,6 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
create_struct.jmp_buf_ptr = &create_jmp_buf;
|
||||
create_struct.jmp_buf_size = 0; /*stack allocation*/
|
||||
create_struct.longjmp_fn = longjmp;
|
||||
# else
|
||||
{
|
||||
# endif
|
||||
/* Call the general version checker (shared with read and write code):
|
||||
*/
|
||||
|
@ -413,6 +418,8 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
|
|||
free(info_ptr);
|
||||
info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
|
||||
(sizeof *info_ptr)));
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
*ptr_ptr = info_ptr;
|
||||
}
|
||||
|
||||
|
@ -664,19 +671,20 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
|||
# endif
|
||||
|
||||
# ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format. Note that,
|
||||
* the following works correctly even if png_int_32 has more than 32 bits
|
||||
* (compare the more complex code required on read for sign extension.)
|
||||
/* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90
|
||||
* defines a cast of a signed integer to an unsigned integer either to preserve
|
||||
* the value, if it is positive, or to calculate:
|
||||
*
|
||||
* (UNSIGNED_MAX+1) + integer
|
||||
*
|
||||
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
|
||||
* negative integral value is added the result will be an unsigned value
|
||||
* correspnding to the 2's complement representation.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
{
|
||||
buf[0] = (png_byte)((i >> 24) & 0xff);
|
||||
buf[1] = (png_byte)((i >> 16) & 0xff);
|
||||
buf[2] = (png_byte)((i >> 8) & 0xff);
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
png_save_uint_32(buf, i);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -722,6 +730,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
|
|||
APPEND(':');
|
||||
APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
|
||||
APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
|
||||
PNG_UNUSED (pos)
|
||||
|
||||
# undef APPEND
|
||||
# undef APPEND_NUMBER
|
||||
|
@ -766,14 +775,15 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.17 - March 26, 2015" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.21 - January 15, 2016" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
||||
PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE;
|
||||
# else
|
||||
return "libpng version 1.6.17 - March 26, 2015\
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
|
||||
return "libpng version 1.6.21 - January 15, 2016\
|
||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
|
@ -1235,7 +1245,8 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
|
|||
|
||||
/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
|
||||
* have end points with 0 tristimulus values (these are impossible end
|
||||
* points, but they are used to cover the possible colors.)
|
||||
* points, but they are used to cover the possible colors). We check
|
||||
* xy->whitey against 5, not 0, to avoid a possible integer overflow.
|
||||
*/
|
||||
if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
|
||||
if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
|
||||
|
@ -1244,7 +1255,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
|
|||
if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
|
||||
if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
|
||||
if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
|
||||
if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
|
||||
if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
|
||||
|
||||
/* The reverse calculation is more difficult because the original tristimulus
|
||||
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
|
||||
|
@ -1702,7 +1713,6 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
|
|||
*/
|
||||
colorspace->flags |= PNG_COLORSPACE_INVALID;
|
||||
png_error(png_ptr, "internal error checking chromaticities");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* failed */
|
||||
|
@ -1730,7 +1740,6 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr,
|
|||
default:
|
||||
colorspace->flags |= PNG_COLORSPACE_INVALID;
|
||||
png_error(png_ptr, "internal error checking chromaticities");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* failed */
|
||||
|
@ -2056,8 +2065,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
temp = png_get_uint_32(profile+12); /* profile/device class */
|
||||
switch (temp)
|
||||
{
|
||||
case 0x73636E72: /* 'scnr' */
|
||||
case 0x6D6E7472: /* 'mntr' */
|
||||
case 0x73636e72: /* 'scnr' */
|
||||
case 0x6d6e7472: /* 'mntr' */
|
||||
case 0x70727472: /* 'prtr' */
|
||||
case 0x73706163: /* 'spac' */
|
||||
/* All supported */
|
||||
|
@ -2068,7 +2077,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"invalid embedded Abstract ICC profile");
|
||||
|
||||
case 0x6C696E6B: /* 'link' */
|
||||
case 0x6c696e6b: /* 'link' */
|
||||
/* DeviceLink profiles cannot be interpreted in a non-device specific
|
||||
* fashion, if an app uses the AToB0Tag in the profile the results are
|
||||
* undefined unless the result is sent to the intended device,
|
||||
|
@ -2078,7 +2087,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"unexpected DeviceLink ICC profile class");
|
||||
|
||||
case 0x6E6D636C: /* 'nmcl' */
|
||||
case 0x6e6d636c: /* 'nmcl' */
|
||||
/* A NamedColor profile is also device specific, however it doesn't
|
||||
* contain an AToB0 tag that is open to misinterpretation. Almost
|
||||
* certainly it will fail the tests below.
|
||||
|
@ -2104,8 +2113,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
temp = png_get_uint_32(profile+20);
|
||||
switch (temp)
|
||||
{
|
||||
case 0x58595A20: /* 'XYZ ' */
|
||||
case 0x4C616220: /* 'Lab ' */
|
||||
case 0x58595a20: /* 'XYZ ' */
|
||||
case 0x4c616220: /* 'Lab ' */
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2275,8 +2284,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
}
|
||||
|
||||
/* Length *and* intent must match */
|
||||
if (length == png_sRGB_checks[i].length &&
|
||||
intent == png_sRGB_checks[i].intent)
|
||||
if (length == (png_uint_32) png_sRGB_checks[i].length &&
|
||||
intent == (png_uint_32) png_sRGB_checks[i].intent)
|
||||
{
|
||||
/* Now calculate the adler32 if not done already. */
|
||||
if (adler == 0)
|
||||
|
@ -2891,7 +2900,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
*/
|
||||
|
||||
{
|
||||
int czero, clead, cdigits;
|
||||
unsigned int czero, clead, cdigits;
|
||||
char exponent[10];
|
||||
|
||||
/* Allow up to two leading zeros - this will not lengthen
|
||||
|
@ -2921,7 +2930,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
* of the loop don't break the number into parts so
|
||||
* that the final digit is rounded.
|
||||
*/
|
||||
if (cdigits+czero-clead+1 < (int)precision)
|
||||
if (cdigits+czero+1 < precision+clead)
|
||||
fp = modf(fp, &d);
|
||||
|
||||
else
|
||||
|
@ -3027,7 +3036,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
*ascii++ = (char)(48 + (int)d), ++cdigits;
|
||||
}
|
||||
}
|
||||
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
|
||||
while (cdigits+czero < precision+clead && fp > DBL_MIN);
|
||||
|
||||
/* The total output count (max) is now 4+precision */
|
||||
|
||||
|
@ -3095,7 +3104,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
/* Need another size check here for the exponent digits, so
|
||||
* this need not be considered above.
|
||||
*/
|
||||
if ((int)size > cdigits)
|
||||
if (size > cdigits)
|
||||
{
|
||||
while (cdigits > 0) *ascii++ = exponent[--cdigits];
|
||||
|
||||
|
@ -3143,7 +3152,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
|||
|
||||
/* Avoid overflow here on the minimum integer. */
|
||||
if (fp < 0)
|
||||
*ascii++ = 45, --size, num = -fp;
|
||||
*ascii++ = 45, num = -fp;
|
||||
else
|
||||
num = fp;
|
||||
|
||||
|
@ -3674,7 +3683,7 @@ png_exp(png_fixed_point x)
|
|||
if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
|
||||
{
|
||||
/* Obtain a 4-bit approximation */
|
||||
png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf];
|
||||
png_uint_32 e = png_32bit_exp[(x >> 12) & 0x0f];
|
||||
|
||||
/* Incorporate the low 12 bits - these decrease the returned value by
|
||||
* multiplying by a number less than 1 if the bit is set. The multiplier
|
||||
|
@ -4236,7 +4245,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
|||
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
|
||||
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
|
||||
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
|
||||
* The sRGB to linear table is exact (to the nearest 16 bit linear fraction).
|
||||
* The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
|
||||
* The inverse (linear to sRGB) table has accuracies as follows:
|
||||
*
|
||||
* For all possible (255*65535+1) input values:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.17, March 26, 2015
|
||||
* libpng version 1.6.21, January 15, 2016
|
||||
*
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -11,11 +11,131 @@
|
|||
*
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.17, March 26, 2015: Glenn
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.21, January 15, 2016:
|
||||
* Glenn Randers-Pehrson.
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
* If you modify libpng you may insert additional notices immediately following
|
||||
* this sentence.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, and are distributed according to the same
|
||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
* added to the list of Contributing Authors:
|
||||
*
|
||||
* Simon-Pierre Cadieux
|
||||
* Eric S. Raymond
|
||||
* Mans Rullgard
|
||||
* Cosmin Truta
|
||||
* Gilles Vollant
|
||||
* James Yu
|
||||
*
|
||||
* and with the following additions to the disclaimer:
|
||||
*
|
||||
* There is no warranty against interference with your enjoyment of the
|
||||
* library or against infringement. There is no warranty that our
|
||||
* efforts or the library will fulfill any of your particular purposes
|
||||
* or needs. This library is provided with all faults, and the entire
|
||||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
* the user.
|
||||
*
|
||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
* libpng-0.96, and are distributed according to the same disclaimer and
|
||||
* license as libpng-0.96, with the following individuals added to the list
|
||||
* of Contributing Authors:
|
||||
*
|
||||
* Tom Lane
|
||||
* Glenn Randers-Pehrson
|
||||
* Willem van Schaik
|
||||
*
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
* and are distributed according to the same disclaimer and license as
|
||||
* libpng-0.88, with the following individuals added to the list of
|
||||
* Contributing Authors:
|
||||
*
|
||||
* John Bowler
|
||||
* Kevin Bracey
|
||||
* Sam Bushell
|
||||
* Magnus Holmgren
|
||||
* Greg Roelofs
|
||||
* Tom Tanner
|
||||
*
|
||||
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
*
|
||||
* Andreas Dilger
|
||||
* Dave Martindale
|
||||
* Guy Eric Schalnat
|
||||
* Paul Schmidt
|
||||
* Tim Wegner
|
||||
*
|
||||
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
* and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
* including, without limitation, the warranties of merchantability and of
|
||||
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
* assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
* or consequential damages, which may result from the use of the PNG
|
||||
* Reference Library, even if advised of the possibility of such damage.
|
||||
*
|
||||
* Permission is hereby granted to use, copy, modify, and distribute this
|
||||
* source code, or portions hereof, for any purpose, without fee, subject
|
||||
* to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this source code must not be misrepresented.
|
||||
*
|
||||
* 2. Altered versions must be plainly marked as such and must not
|
||||
* be misrepresented as being the original source.
|
||||
*
|
||||
* 3. This Copyright notice may not be removed or altered from any
|
||||
* source or altered source distribution.
|
||||
*
|
||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
* fee, and encourage the use of this source code as a component to
|
||||
* supporting the PNG file format in commercial products. If you use this
|
||||
* source code in a product, acknowledgment is not required but would be
|
||||
* appreciated.
|
||||
*
|
||||
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A "png_get_copyright" function is available, for convenient use in "about"
|
||||
* boxes and the like:
|
||||
*
|
||||
* printf("%s", png_get_copyright(NULL));
|
||||
*
|
||||
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
* a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
* the additional disclaimers inserted at version 1.0.7.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The contributing authors would like to thank all those who helped
|
||||
* with testing, bug fixes, and patience. This wouldn't have been
|
||||
* possible without all of you.
|
||||
*
|
||||
* Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
*/
|
||||
|
||||
/* Note about libpng version numbers:
|
||||
*
|
||||
* Due to various miscommunications, unforeseen code incompatibilities
|
||||
* and occasional factors outside the authors' control, version numbering
|
||||
|
@ -59,163 +179,14 @@
|
|||
* 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
|
||||
* 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
|
||||
* 1.0.7 1 10007 (still compatible)
|
||||
* 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
|
||||
* 1.0.8rc1 1 10008 2.1.0.8rc1
|
||||
* 1.0.8 1 10008 2.1.0.8
|
||||
* 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
|
||||
* 1.0.9rc1 1 10009 2.1.0.9rc1
|
||||
* 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
|
||||
* 1.0.9rc2 1 10009 2.1.0.9rc2
|
||||
* 1.0.9 1 10009 2.1.0.9
|
||||
* 1.0.10beta1 1 10010 2.1.0.10beta1
|
||||
* 1.0.10rc1 1 10010 2.1.0.10rc1
|
||||
* 1.0.10 1 10010 2.1.0.10
|
||||
* 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
|
||||
* 1.0.11rc1 1 10011 2.1.0.11rc1
|
||||
* 1.0.11 1 10011 2.1.0.11
|
||||
* 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
|
||||
* 1.0.12rc1 2 10012 2.1.0.12rc1
|
||||
* 1.0.12 2 10012 2.1.0.12
|
||||
* 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned)
|
||||
* 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
|
||||
* 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
|
||||
* 1.2.0rc1 3 10200 3.1.2.0rc1
|
||||
* 1.2.0 3 10200 3.1.2.0
|
||||
* 1.2.1beta1-4 3 10201 3.1.2.1beta1-4
|
||||
* 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
|
||||
* 1.2.1 3 10201 3.1.2.1
|
||||
* 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
|
||||
* 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
|
||||
* 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
|
||||
* 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
|
||||
* 1.0.13 10 10013 10.so.0.1.0.13
|
||||
* 1.2.2 12 10202 12.so.0.1.2.2
|
||||
* 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
|
||||
* 1.2.3 12 10203 12.so.0.1.2.3
|
||||
* 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
|
||||
* 1.0.14rc1 13 10014 10.so.0.1.0.14rc1
|
||||
* 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
|
||||
* 1.0.14 10 10014 10.so.0.1.0.14
|
||||
* 1.2.4 13 10204 12.so.0.1.2.4
|
||||
* 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
|
||||
* 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3
|
||||
* 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3
|
||||
* 1.0.15 10 10015 10.so.0.1.0.15
|
||||
* 1.2.5 13 10205 12.so.0.1.2.5
|
||||
* 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
|
||||
* 1.0.16 10 10016 10.so.0.1.0.16
|
||||
* 1.2.6 13 10206 12.so.0.1.2.6
|
||||
* 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
|
||||
* 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
|
||||
* 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
|
||||
* 1.0.17 10 10017 12.so.0.1.0.17
|
||||
* 1.2.7 13 10207 12.so.0.1.2.7
|
||||
* 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
|
||||
* 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
|
||||
* 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
|
||||
* 1.0.18 10 10018 12.so.0.1.0.18
|
||||
* 1.2.8 13 10208 12.so.0.1.2.8
|
||||
* 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
|
||||
* 1.2.9beta4-11 13 10209 12.so.0.9[.0]
|
||||
* 1.2.9rc1 13 10209 12.so.0.9[.0]
|
||||
* 1.2.9 13 10209 12.so.0.9[.0]
|
||||
* 1.2.10beta1-7 13 10210 12.so.0.10[.0]
|
||||
* 1.2.10rc1-2 13 10210 12.so.0.10[.0]
|
||||
* 1.2.10 13 10210 12.so.0.10[.0]
|
||||
* 1.4.0beta1-5 14 10400 14.so.0.0[.0]
|
||||
* 1.2.11beta1-4 13 10211 12.so.0.11[.0]
|
||||
* 1.4.0beta7-8 14 10400 14.so.0.0[.0]
|
||||
* 1.2.11 13 10211 12.so.0.11[.0]
|
||||
* 1.2.12 13 10212 12.so.0.12[.0]
|
||||
* 1.4.0beta9-14 14 10400 14.so.0.0[.0]
|
||||
* 1.2.13 13 10213 12.so.0.13[.0]
|
||||
* 1.4.0beta15-36 14 10400 14.so.0.0[.0]
|
||||
* 1.4.0beta37-87 14 10400 14.so.14.0[.0]
|
||||
* 1.4.0rc01 14 10400 14.so.14.0[.0]
|
||||
* 1.4.0beta88-109 14 10400 14.so.14.0[.0]
|
||||
* 1.4.0rc02-08 14 10400 14.so.14.0[.0]
|
||||
* 1.4.0 14 10400 14.so.14.0[.0]
|
||||
* 1.4.1beta01-03 14 10401 14.so.14.1[.0]
|
||||
* 1.4.1rc01 14 10401 14.so.14.1[.0]
|
||||
* 1.4.1beta04-12 14 10401 14.so.14.1[.0]
|
||||
* 1.4.1 14 10401 14.so.14.1[.0]
|
||||
* 1.4.2 14 10402 14.so.14.2[.0]
|
||||
* 1.4.3 14 10403 14.so.14.3[.0]
|
||||
* 1.4.4 14 10404 14.so.14.4[.0]
|
||||
* 1.5.0beta01-58 15 10500 15.so.15.0[.0]
|
||||
* 1.5.0rc01-07 15 10500 15.so.15.0[.0]
|
||||
* 1.5.0 15 10500 15.so.15.0[.0]
|
||||
* 1.5.1beta01-11 15 10501 15.so.15.1[.0]
|
||||
* 1.5.1rc01-02 15 10501 15.so.15.1[.0]
|
||||
* 1.5.1 15 10501 15.so.15.1[.0]
|
||||
* 1.5.2beta01-03 15 10502 15.so.15.2[.0]
|
||||
* 1.5.2rc01-03 15 10502 15.so.15.2[.0]
|
||||
* 1.5.2 15 10502 15.so.15.2[.0]
|
||||
* 1.5.3beta01-10 15 10503 15.so.15.3[.0]
|
||||
* 1.5.3rc01-02 15 10503 15.so.15.3[.0]
|
||||
* 1.5.3beta11 15 10503 15.so.15.3[.0]
|
||||
* 1.5.3 [omitted]
|
||||
* 1.5.4beta01-08 15 10504 15.so.15.4[.0]
|
||||
* 1.5.4rc01 15 10504 15.so.15.4[.0]
|
||||
* 1.5.4 15 10504 15.so.15.4[.0]
|
||||
* 1.5.5beta01-08 15 10505 15.so.15.5[.0]
|
||||
* 1.5.5rc01 15 10505 15.so.15.5[.0]
|
||||
* 1.5.5 15 10505 15.so.15.5[.0]
|
||||
* 1.5.6beta01-07 15 10506 15.so.15.6[.0]
|
||||
* 1.5.6rc01-03 15 10506 15.so.15.6[.0]
|
||||
* 1.5.6 15 10506 15.so.15.6[.0]
|
||||
* 1.5.7beta01-05 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7rc01-03 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7 15 10507 15.so.15.7[.0]
|
||||
* 1.6.0beta01-40 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0rc01-08 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0 16 10600 16.so.16.0[.0]
|
||||
* 1.6.1beta01-09 16 10601 16.so.16.1[.0]
|
||||
* 1.6.1rc01 16 10601 16.so.16.1[.0]
|
||||
* 1.6.1 16 10601 16.so.16.1[.0]
|
||||
* 1.6.2beta01 16 10602 16.so.16.2[.0]
|
||||
* 1.6.2rc01-06 16 10602 16.so.16.2[.0]
|
||||
* 1.6.2 16 10602 16.so.16.2[.0]
|
||||
* 1.6.3beta01-11 16 10603 16.so.16.3[.0]
|
||||
* 1.6.3rc01 16 10603 16.so.16.3[.0]
|
||||
* 1.6.3 16 10603 16.so.16.3[.0]
|
||||
* 1.6.4beta01-02 16 10604 16.so.16.4[.0]
|
||||
* 1.6.4rc01 16 10604 16.so.16.4[.0]
|
||||
* 1.6.4 16 10604 16.so.16.4[.0]
|
||||
* 1.6.5 16 10605 16.so.16.5[.0]
|
||||
* 1.6.6 16 10606 16.so.16.6[.0]
|
||||
* 1.6.7beta01-04 16 10607 16.so.16.7[.0]
|
||||
* 1.6.7rc01-03 16 10607 16.so.16.7[.0]
|
||||
* 1.6.7 16 10607 16.so.16.7[.0]
|
||||
* 1.6.8beta01-02 16 10608 16.so.16.8[.0]
|
||||
* 1.6.8rc01-02 16 10608 16.so.16.8[.0]
|
||||
* 1.6.8 16 10608 16.so.16.8[.0]
|
||||
* 1.6.9beta01-04 16 10609 16.so.16.9[.0]
|
||||
* 1.6.9rc01-02 16 10609 16.so.16.9[.0]
|
||||
* 1.6.9 16 10609 16.so.16.9[.0]
|
||||
* 1.6.10beta01-03 16 10610 16.so.16.10[.0]
|
||||
* 1.6.10rc01-03 16 10610 16.so.16.10[.0]
|
||||
* 1.6.10 16 10610 16.so.16.10[.0]
|
||||
* 1.6.11beta01-06 16 10611 16.so.16.11[.0]
|
||||
* 1.6.11rc01-02 16 10611 16.so.16.11[.0]
|
||||
* 1.6.11 16 10611 16.so.16.11[.0]
|
||||
* 1.6.12rc01-03 16 10612 16.so.16.12[.0]
|
||||
* 1.6.12 16 10612 16.so.16.12[.0]
|
||||
* 1.6.13beta01-04 16 10613 16.so.16.13[.0]
|
||||
* 1.6.13rc01-02 16 10613 16.so.16.13[.0]
|
||||
* 1.6.13 16 10613 16.so.16.13[.0]
|
||||
* 1.6.14beta01-07 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14rc01-02 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14 16 10614 16.so.16.14[.0]
|
||||
* 1.6.15beta01-08 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15rc01-03 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15 16 10615 16.so.16.15[.0]
|
||||
* 1.6.16beta01-03 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16rc01-02 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16 16 10616 16.so.16.16[.0]
|
||||
* 1.6.17beta01-06 16 10617 16.so.16.17[.0]
|
||||
* 1.6.17rc01-06 16 10617 16.so.16.17[.0]
|
||||
* 1.6.17 16 10617 16.so.16.17[.0]
|
||||
* ...
|
||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||
* ...
|
||||
* 1.2.53 13 10253 12.so.0.53[.0]
|
||||
* ...
|
||||
* 1.5.23 15 10523 15.so.15.23[.0]
|
||||
* ...
|
||||
* 1.6.21 16 10621 16.so.16.21[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -234,138 +205,22 @@
|
|||
* DLLNUM will change each time there are forward or backward changes
|
||||
* in binary compatibility (e.g., when a new feature is added).
|
||||
*
|
||||
* See libpng-manual.txt or libpng.3 for more information. The PNG
|
||||
* specification is available as a W3C Recommendation and as an ISO
|
||||
* Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
*
|
||||
* If you modify libpng you may insert additional notices immediately following
|
||||
* this sentence.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.17, March 26, 2015, are
|
||||
* Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
*
|
||||
* Cosmin Truta
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
|
||||
* Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* Simon-Pierre Cadieux
|
||||
* Eric S. Raymond
|
||||
* Gilles Vollant
|
||||
*
|
||||
* and with the following additions to the disclaimer:
|
||||
*
|
||||
* There is no warranty against interference with your enjoyment of the
|
||||
* library or against infringement. There is no warranty that our
|
||||
* efforts or the library will fulfill any of your particular purposes
|
||||
* or needs. This library is provided with all faults, and the entire
|
||||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
* the user.
|
||||
*
|
||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-0.96,
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* Tom Lane
|
||||
* Glenn Randers-Pehrson
|
||||
* Willem van Schaik
|
||||
*
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* John Bowler
|
||||
* Kevin Bracey
|
||||
* Sam Bushell
|
||||
* Magnus Holmgren
|
||||
* Greg Roelofs
|
||||
* Tom Tanner
|
||||
*
|
||||
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
*
|
||||
* Andreas Dilger
|
||||
* Dave Martindale
|
||||
* Guy Eric Schalnat
|
||||
* Paul Schmidt
|
||||
* Tim Wegner
|
||||
*
|
||||
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
* and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
* including, without limitation, the warranties of merchantability and of
|
||||
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
* assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
* or consequential damages, which may result from the use of the PNG
|
||||
* Reference Library, even if advised of the possibility of such damage.
|
||||
*
|
||||
* Permission is hereby granted to use, copy, modify, and distribute this
|
||||
* source code, or portions hereof, for any purpose, without fee, subject
|
||||
* to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this source code must not be misrepresented.
|
||||
*
|
||||
* 2. Altered versions must be plainly marked as such and must not
|
||||
* be misrepresented as being the original source.
|
||||
*
|
||||
* 3. This Copyright notice may not be removed or altered from
|
||||
* any source or altered source distribution.
|
||||
*
|
||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
* fee, and encourage the use of this source code as a component to
|
||||
* supporting the PNG file format in commercial products. If you use this
|
||||
* source code in a product, acknowledgment is not required but would be
|
||||
* appreciated.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A "png_get_copyright" function is available, for convenient use in "about"
|
||||
* boxes and the like:
|
||||
*
|
||||
* printf("%s", png_get_copyright(NULL));
|
||||
*
|
||||
* Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
||||
* certification mark of the Open Source Initiative.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The contributing authors would like to thank all those who helped
|
||||
* with testing, bug fixes, and patience. This wouldn't have been
|
||||
* possible without all of you.
|
||||
*
|
||||
* Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as a W3C Recommendation and as an ISO Specification,
|
||||
* <http://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* March 26, 2015
|
||||
* January 15, 2016
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.6.17 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.21 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
@ -427,9 +282,9 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.17"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.21"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.17 - March 26, 2015\n"
|
||||
" libpng version 1.6.21 - January 15, 2016\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
|
@ -437,7 +292,7 @@
|
|||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 17
|
||||
#define PNG_LIBPNG_VER_RELEASE 21
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
|
@ -468,7 +323,7 @@
|
|||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10617 /* 1.6.17 */
|
||||
#define PNG_LIBPNG_VER 10621 /* 1.6.21 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -525,17 +380,22 @@ extern "C" {
|
|||
|
||||
/* This file is arranged in several sections:
|
||||
*
|
||||
* 1. Any configuration options that can be specified by for the application
|
||||
* 1. [omitted]
|
||||
* 2. Any configuration options that can be specified by for the application
|
||||
* code when it is built. (Build time configuration is in pnglibconf.h)
|
||||
* 2. Type definitions (base types are defined in pngconf.h), structure
|
||||
* 3. Type definitions (base types are defined in pngconf.h), structure
|
||||
* definitions.
|
||||
* 3. Exported library functions.
|
||||
* 4. Simplified API.
|
||||
* 4. Exported library functions.
|
||||
* 5. Simplified API.
|
||||
* 6. Implementation options.
|
||||
*
|
||||
* The library source code has additional files (principally pngpriv.h) that
|
||||
* allow configuration of the library.
|
||||
*/
|
||||
/* Section 1: run time configuration
|
||||
|
||||
/* Section 1: [omitted] */
|
||||
|
||||
/* Section 2: run time configuration
|
||||
* See pnglibconf.h for build time configuration
|
||||
*
|
||||
* Run time configuration allows the application to choose between
|
||||
|
@ -565,7 +425,7 @@ extern "C" {
|
|||
* Otherwise the calls are mapped to png_error.
|
||||
*/
|
||||
|
||||
/* Section 2: type definitions, including structures and compile time
|
||||
/* Section 3: type definitions, including structures and compile time
|
||||
* constants.
|
||||
* See pngconf.h for base types that vary by machine/system
|
||||
*/
|
||||
|
@ -573,7 +433,7 @@ extern "C" {
|
|||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_17;
|
||||
typedef char* png_libpng_version_1_6_21;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
@ -889,7 +749,9 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
|
|||
#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
|
||||
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
|
||||
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
|
||||
#if INT_MAX >= 0x8000 /* else this might break */
|
||||
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
|
||||
#endif
|
||||
|
||||
/* This is used for the transformation routines, as some of them
|
||||
* change these values for the row. It also should enable using
|
||||
|
@ -993,7 +855,9 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
|
|||
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
|
||||
/* Added to libpng-1.5.4 */
|
||||
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
|
||||
#if INT_MAX >= 0x8000 /* else this might break */
|
||||
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
|
||||
#endif
|
||||
|
||||
/* Flags for MNG supported features */
|
||||
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
|
||||
|
@ -1010,7 +874,7 @@ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
|
|||
png_alloc_size_t));
|
||||
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
|
||||
|
||||
/* Section 3: exported functions
|
||||
/* Section 4: exported functions
|
||||
* Here are the function definitions most commonly used. This is not
|
||||
* the place to find out how to use libpng. See libpng-manual.txt for the
|
||||
* full explanation, see example.c for the summary. This just provides
|
||||
|
@ -1383,13 +1247,13 @@ PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
|
|||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
|
||||
/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
|
||||
PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
|
||||
int flags));
|
||||
/* The values of the PNG_FILLER_ defines should NOT be changed */
|
||||
# define PNG_FILLER_BEFORE 0
|
||||
# define PNG_FILLER_AFTER 1
|
||||
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
|
||||
/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
|
||||
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
|
||||
png_uint_32 filler, int flags));
|
||||
#endif /* READ_FILLER || WRITE_FILLER */
|
||||
|
@ -1623,35 +1487,7 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
|||
#define PNG_FILTER_VALUE_LAST 5
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
|
||||
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
|
||||
* defines, either the default (minimum-sum-of-absolute-differences), or
|
||||
* the experimental method (weighted-minimum-sum-of-absolute-differences).
|
||||
*
|
||||
* Weights are factors >= 1.0, indicating how important it is to keep the
|
||||
* filter type consistent between rows. Larger numbers mean the current
|
||||
* filter is that many times as likely to be the same as the "num_weights"
|
||||
* previous filters. This is cumulative for each previous row with a weight.
|
||||
* There needs to be "num_weights" values in "filter_weights", or it can be
|
||||
* NULL if the weights aren't being specified. Weights have no influence on
|
||||
* the selection of the first row filter. Well chosen weights can (in theory)
|
||||
* improve the compression for a given image.
|
||||
*
|
||||
* Costs are factors >= 1.0 indicating the relative decoding costs of a
|
||||
* filter type. Higher costs indicate more decoding expense, and are
|
||||
* therefore less likely to be selected over a filter with lower computational
|
||||
* costs. There needs to be a value in "filter_costs" for each valid filter
|
||||
* type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
|
||||
* setting the costs. Costs try to improve the speed of decompression without
|
||||
* unduly increasing the compressed image size.
|
||||
*
|
||||
* A negative weight or cost indicates the default value is to be used, and
|
||||
* values in the range [0.0, 1.0) indicate the value is to remain unchanged.
|
||||
* The default values for both weights and costs are currently 1.0, but may
|
||||
* change if good general weighting/cost heuristics can be found. If both
|
||||
* the weights and costs are set to 1.0, this degenerates the WEIGHTED method
|
||||
* to the UNWEIGHTED method, but with added encoding time/computation.
|
||||
*/
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
|
||||
int heuristic_method, int num_weights, png_const_doublep filter_weights,
|
||||
png_const_doublep filter_costs))
|
||||
|
@ -1661,9 +1497,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
|||
png_const_fixed_point_p filter_costs))
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
/* Heuristic used for row filter selection. These defines should NOT be
|
||||
* changed.
|
||||
*/
|
||||
/* The following are no longer used and will be removed from libpng-1.7: */
|
||||
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
||||
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
||||
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
||||
|
@ -2744,7 +2578,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||
|
||||
# define PNG_get_int_32(buf) \
|
||||
((png_int_32)((*(buf) & 0x80) \
|
||||
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
|
||||
? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
|
||||
: (png_int_32)png_get_uint_32(buf)))
|
||||
|
||||
/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
|
||||
|
@ -2764,10 +2598,17 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
|
||||
png_const_infop info_ptr));
|
||||
# endif
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
/*******************************************************************************
|
||||
* SIMPLIFIED API
|
||||
* Section 5: SIMPLIFIED API
|
||||
*******************************************************************************
|
||||
*
|
||||
* Please read the documentation in libpng-manual.txt (TODO: write said
|
||||
|
@ -2783,8 +2624,9 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||
*
|
||||
* To read a PNG file using the simplified API:
|
||||
*
|
||||
* 1) Declare a 'png_image' structure (see below) on the stack and set the
|
||||
* version field to PNG_IMAGE_VERSION.
|
||||
* 1) Declare a 'png_image' structure (see below) on the stack, set the
|
||||
* version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
|
||||
* (this is REQUIRED, your program may crash if you don't do it.)
|
||||
* 2) Call the appropriate png_image_begin_read... function.
|
||||
* 3) Set the png_image 'format' member to the required sample format.
|
||||
* 4) Allocate a buffer for the image and, if required, the color-map.
|
||||
|
@ -2811,6 +2653,9 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||
* when it is being read or defines the in-memory format of an image that you
|
||||
* need to write:
|
||||
*/
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
|
||||
#define PNG_IMAGE_VERSION 1
|
||||
|
||||
typedef struct png_control *png_controlp;
|
||||
|
@ -2910,7 +2755,7 @@ typedef struct
|
|||
* called to read or write the color-map and set the format correctly for the
|
||||
* image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
|
||||
*
|
||||
* NOTE: libpng can be built with particular features disabled, if you see
|
||||
* NOTE: libpng can be built with particular features disabled. If you see
|
||||
* compiler errors because the definition of one of the following flags has been
|
||||
* compiled out it is because libpng does not have the required support. It is
|
||||
* possible, however, for the libpng configuration to enable the format on just
|
||||
|
@ -2922,7 +2767,7 @@ typedef struct
|
|||
*/
|
||||
#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */
|
||||
#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */
|
||||
#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */
|
||||
#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */
|
||||
#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
|
@ -3209,9 +3054,11 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||
*
|
||||
* With all APIs row_stride is handled as in the read APIs - it is the spacing
|
||||
* from one row to the next in component sized units (1 or 2 bytes) and if
|
||||
* negative indicates a bottom-up row layout in the buffer.
|
||||
* negative indicates a bottom-up row layout in the buffer. If row_stride is zero,
|
||||
* libpng will calculate it for you from the image width and number of channels.
|
||||
*
|
||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
||||
* Note that the write API does not support interlacing, sub-8-bit pixels, indexed
|
||||
* PNG (color_type 3) or most ancillary chunks.
|
||||
*/
|
||||
#endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
|
@ -3220,17 +3067,8 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||
******************************************************************************/
|
||||
#endif /* SIMPLIFIED_{READ|WRITE} */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
|
||||
png_const_infop info_ptr));
|
||||
# endif
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
/*******************************************************************************
|
||||
* IMPLEMENTATION OPTIONS
|
||||
* Section 6: IMPLEMENTATION OPTIONS
|
||||
*******************************************************************************
|
||||
*
|
||||
* Support for arbitrary implementation-specific optimizations. The API allows
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.17, March 26, 2015
|
||||
* libpng version 1.6.21, January 15, 2016
|
||||
*
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -63,7 +63,7 @@
|
|||
*/
|
||||
#define PNG_CONST const /* backward compatibility only */
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
/* This controls optimization of the reading of 16-bit and 32-bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
* just changes whether a macro is used when the function is called.
|
||||
* The library builder sets the default; if read functions are not
|
||||
|
@ -295,11 +295,11 @@
|
|||
* table entries, so we discard it here. See the .dfn files in the
|
||||
* scripts directory.
|
||||
*/
|
||||
#ifndef PNG_EXPORTA
|
||||
|
||||
#ifndef PNG_EXPORTA
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
||||
extern attributes)
|
||||
PNG_LINKAGE_API attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
|
@ -480,7 +480,7 @@
|
|||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
#else
|
||||
# error "libpng requires 8 bit bytes"
|
||||
# error "libpng requires 8-bit bytes"
|
||||
#endif
|
||||
|
||||
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||
|
@ -488,7 +488,7 @@
|
|||
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||
typedef short png_int_16;
|
||||
#else
|
||||
# error "libpng requires a signed 16 bit type"
|
||||
# error "libpng requires a signed 16-bit type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX == 65535
|
||||
|
@ -496,7 +496,7 @@
|
|||
#elif USHRT_MAX == 65535
|
||||
typedef unsigned short png_uint_16;
|
||||
#else
|
||||
# error "libpng requires an unsigned 16 bit type"
|
||||
# error "libpng requires an unsigned 16-bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
|
@ -504,7 +504,7 @@
|
|||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32 bit (or more) type"
|
||||
# error "libpng requires a signed 32-bit (or more) type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294
|
||||
|
@ -512,7 +512,7 @@
|
|||
#elif ULONG_MAX > 4294967294
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32 bit (or more) type"
|
||||
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* libpng 1.6.17 STANDARD API DEFINITION */
|
||||
/* libpng 1.6.21 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.6.17 - March 26, 2015 */
|
||||
/* Libpng version 1.6.21 - January 15, 2016 */
|
||||
|
||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||
|
||||
/* This code is released under the libpng license. */
|
||||
/* For conditions of distribution and use, see the disclaimer */
|
||||
|
@ -101,8 +101,6 @@
|
|||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
@ -187,11 +185,14 @@
|
|||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||
#define PNG_INFLATE_BUF_SIZE 1024
|
||||
#define PNG_LINKAGE_API extern
|
||||
#define PNG_LINKAGE_CALLBACK extern
|
||||
#define PNG_LINKAGE_DATA extern
|
||||
#define PNG_LINKAGE_FUNCTION extern
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
|
@ -202,7 +203,6 @@
|
|||
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0 /* unknown */
|
||||
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -77,6 +77,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
|||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
/* Some compilers complain that this is always true. However, it
|
||||
* can be false when integer overflow happens.
|
||||
*/
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -19,7 +19,6 @@
|
|||
#define PNG_READ_SIG_MODE 0
|
||||
#define PNG_READ_CHUNK_MODE 1
|
||||
#define PNG_READ_IDAT_MODE 2
|
||||
#define PNG_SKIP_MODE 3
|
||||
#define PNG_READ_tEXt_MODE 4
|
||||
#define PNG_READ_zTXt_MODE 5
|
||||
#define PNG_READ_DONE_MODE 6
|
||||
|
@ -78,32 +77,14 @@ png_process_data_pause(png_structrp png_ptr, int save)
|
|||
png_uint_32 PNGAPI
|
||||
png_process_data_skip(png_structrp png_ptr)
|
||||
{
|
||||
png_uint_32 remaining = 0;
|
||||
|
||||
if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
|
||||
png_ptr->skip_length > 0)
|
||||
{
|
||||
/* At the end of png_process_data the buffer size must be 0 (see the loop
|
||||
* above) so we can detect a broken call here:
|
||||
/* TODO: Deprecate and remove this API.
|
||||
* Somewhere the implementation of this seems to have been lost,
|
||||
* or abandoned. It was only to support some internal back-door access
|
||||
* to png_struct) in libpng-1.4.x.
|
||||
*/
|
||||
if (png_ptr->buffer_size != 0)
|
||||
png_error(png_ptr,
|
||||
"png_process_data_skip called inside png_process_data");
|
||||
|
||||
/* If is impossible for there to be a saved buffer at this point -
|
||||
* otherwise we could not be in SKIP mode. This will also happen if
|
||||
* png_process_skip is called inside png_process_data (but only very
|
||||
* rarely.)
|
||||
*/
|
||||
if (png_ptr->save_buffer_size != 0)
|
||||
png_error(png_ptr, "png_process_data_skip called with saved data");
|
||||
|
||||
remaining = png_ptr->skip_length;
|
||||
png_ptr->skip_length = 0;
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
}
|
||||
|
||||
return remaining;
|
||||
png_app_warning(png_ptr,
|
||||
"png_process_data_skip is not implemented in any current version of libpng");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* What we do with the incoming data depends on what we were previously
|
||||
|
@ -135,12 +116,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
|||
break;
|
||||
}
|
||||
|
||||
case PNG_SKIP_MODE:
|
||||
{
|
||||
png_push_crc_finish(png_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
png_ptr->buffer_size = 0;
|
||||
|
@ -439,69 +414,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
||||
png_ptr->skip_length = skip;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
|
||||
/* We want the smaller of 'skip_length' and 'save_buffer_size', but
|
||||
* they are of different types and we don't know which variable has the
|
||||
* fewest bits. Carefully select the smaller and cast it to the type of
|
||||
* the larger - this cannot overflow. Do not cast in the following test
|
||||
* - it will break on either 16 or 64 bit platforms.
|
||||
*/
|
||||
if (skip_length < save_size)
|
||||
save_size = (png_size_t)skip_length;
|
||||
|
||||
else
|
||||
skip_length = (png_uint_32)save_size;
|
||||
|
||||
png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
|
||||
png_ptr->skip_length -= skip_length;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->current_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
|
||||
/* We want the smaller of 'skip_length' and 'current_buffer_size', here,
|
||||
* the same problem exists as above and the same solution.
|
||||
*/
|
||||
if (skip_length < save_size)
|
||||
save_size = (png_size_t)skip_length;
|
||||
|
||||
else
|
||||
skip_length = (png_uint_32)save_size;
|
||||
|
||||
png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
|
||||
png_ptr->skip_length -= skip_length;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->skip_length == 0)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
void PNGCBAPI
|
||||
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
{
|
||||
|
@ -584,13 +496,11 @@ png_push_save_buffer(png_structrp png_ptr)
|
|||
if (png_ptr->save_buffer == NULL)
|
||||
{
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
|
@ -653,7 +563,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
* are of different types and we don't know which variable has the fewest
|
||||
* bits. Carefully select the smaller and cast it to the type of the
|
||||
* larger - this cannot overflow. Do not cast in the following test - it
|
||||
* will break on either 16 or 64 bit platforms.
|
||||
* will break on either 16-bit or 64-bit platforms.
|
||||
*/
|
||||
if (idat_size < save_size)
|
||||
save_size = (png_size_t)idat_size;
|
||||
|
@ -696,6 +606,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size == 0)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
|
@ -751,7 +662,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
|||
* change the current behavior (see comments in inflate.c
|
||||
* for why this doesn't happen at present with zlib 1.2.5).
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH);
|
||||
ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH);
|
||||
|
||||
/* Check for any failure before proceeding. */
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.21 [January 15, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -118,8 +118,12 @@
|
|||
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
||||
* off.
|
||||
*
|
||||
* Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
|
||||
* check both variants.
|
||||
* Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
|
||||
* __ARM_NEON__, so we check both variants.
|
||||
*
|
||||
* To disable ARM_NEON optimizations entirely, and skip compiling the
|
||||
* associated assembler code, pass --enable-arm-neon=no to configure
|
||||
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
|
||||
*/
|
||||
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
|
||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
|
@ -248,17 +252,18 @@
|
|||
* always be used to declare an extern data or function object in this file.
|
||||
*/
|
||||
#ifndef PNG_INTERNAL_DATA
|
||||
# define PNG_INTERNAL_DATA(type, name, array) extern type name array
|
||||
# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array
|
||||
#endif
|
||||
|
||||
#ifndef PNG_INTERNAL_FUNCTION
|
||||
# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
||||
PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
||||
#endif
|
||||
|
||||
#ifndef PNG_INTERNAL_CALLBACK
|
||||
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||
extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
|
||||
PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
|
||||
PNG_EMPTY attributes)
|
||||
#endif
|
||||
|
||||
/* If floating or fixed point APIs are disabled they may still be compiled
|
||||
|
@ -296,6 +301,22 @@
|
|||
# define PNG_DLL_EXPORT
|
||||
#endif
|
||||
|
||||
/* This is a global switch to set the compilation for an installed system
|
||||
* (a release build). It can be set for testing debug builds to ensure that
|
||||
* they will compile when the build type is switched to RC or STABLE, the
|
||||
* default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS
|
||||
* with either:
|
||||
*
|
||||
* -DPNG_RELEASE_BUILD Turns on the release compile path
|
||||
* -DPNG_RELEASE_BUILD=0 Turns it off
|
||||
* or in your pngusr.h with
|
||||
* #define PNG_RELEASE_BUILD=1 Turns on the release compile path
|
||||
* #define PNG_RELEASE_BUILD=0 Turns it off
|
||||
*/
|
||||
#ifndef PNG_RELEASE_BUILD
|
||||
# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
|
||||
#endif
|
||||
|
||||
/* SECURITY and SAFETY:
|
||||
*
|
||||
* libpng is built with support for internal limits on image dimensions and
|
||||
|
@ -554,10 +575,6 @@
|
|||
#define PNG_STRUCT_PNG 0x0001
|
||||
#define PNG_STRUCT_INFO 0x0002
|
||||
|
||||
/* Scaling factor for filter heuristic weighting calculations */
|
||||
#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
|
||||
#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
|
||||
|
||||
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
|
||||
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
|
||||
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */
|
||||
|
@ -648,7 +665,7 @@
|
|||
/* The fixed point conversion performs range checking and evaluates
|
||||
* its argument multiple times, so must be used with care. The
|
||||
* range checking uses the PNG specification values for a signed
|
||||
* 32 bit fixed point value except that the values are deliberately
|
||||
* 32-bit fixed point value except that the values are deliberately
|
||||
* rounded-to-zero to an integral value - 21474 (21474.83 is roughly
|
||||
* (2^31-1) * 100000). 's' is a string that describes the value being
|
||||
* converted.
|
||||
|
@ -795,7 +812,7 @@
|
|||
*/
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||
/* This is used for 16-bit gamma tables -- only the top level pointers are
|
||||
* const; this could be changed:
|
||||
*/
|
||||
typedef const png_uint_16p * png_const_uint_16pp;
|
||||
|
@ -1198,6 +1215,14 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
|||
/* Initialize the row buffers, etc. */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
|
||||
PNG_EMPTY);
|
||||
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
|
||||
#else /* Zlib < 1.2.4 */
|
||||
# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush)
|
||||
#endif /* Zlib < 1.2.4 */
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
/* Optional call to update the users info structure */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
|
||||
|
@ -1372,10 +1397,6 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
|
|||
PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,
|
||||
png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
|
||||
|
@ -1896,6 +1917,9 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
|||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
#include "pngdebug.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -63,7 +63,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
# if PNG_RELEASE_BUILD
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
# endif
|
||||
# endif
|
||||
|
@ -1683,10 +1683,11 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
|
|||
value *= 257;
|
||||
break;
|
||||
|
||||
#ifdef __GNUC__
|
||||
default:
|
||||
png_error(display->image->opaque->png_ptr,
|
||||
"unexpected encoding (internal error)");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -2837,7 +2838,6 @@ png_image_read_colormap(png_voidp argument)
|
|||
default:
|
||||
png_error(png_ptr, "invalid PNG color type");
|
||||
/*NOT REACHED*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now deal with the output processing */
|
||||
|
@ -2847,10 +2847,6 @@ png_image_read_colormap(png_voidp argument)
|
|||
|
||||
switch (data_encoding)
|
||||
{
|
||||
default:
|
||||
png_error(png_ptr, "bad data option (internal error)");
|
||||
break;
|
||||
|
||||
case P_sRGB:
|
||||
/* Change to 8-bit sRGB */
|
||||
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
|
||||
|
@ -2860,6 +2856,11 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (png_ptr->bit_depth > 8)
|
||||
png_set_scale_16(png_ptr);
|
||||
break;
|
||||
|
||||
#ifdef __GNUC__
|
||||
default:
|
||||
png_error(png_ptr, "bad data option (internal error)");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cmap_entries > 256 || cmap_entries > image->colormap_entries)
|
||||
|
@ -3410,10 +3411,6 @@ png_image_read_background(png_voidp argument)
|
|||
*/
|
||||
switch (info_ptr->bit_depth)
|
||||
{
|
||||
default:
|
||||
png_error(png_ptr, "unexpected bit depth");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
/* 8-bit sRGB gray values with an alpha channel; the alpha channel is
|
||||
* to be removed by composing on a background: either the row if
|
||||
|
@ -3631,6 +3628,11 @@ png_image_read_background(png_voidp argument)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef __GNUC__
|
||||
default:
|
||||
png_error(png_ptr, "unexpected bit depth");
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
|||
* reads from a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered reads. This should never be asked
|
||||
* to read more than 64K on a 16 bit machine.
|
||||
* to read more than 64K on a 16-bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -976,7 +976,6 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
|||
|
||||
default:
|
||||
png_error(png_ptr, "invalid error action to rgb_to_gray");
|
||||
break;
|
||||
}
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
|
@ -1997,7 +1996,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
# endif
|
||||
|
||||
# else
|
||||
/* No 16 bit support: force chopping 16-bit input down to 8, in this case
|
||||
/* No 16-bit support: force chopping 16-bit input down to 8, in this case
|
||||
* the app program can chose if both APIs are available by setting the
|
||||
* correct scaling to use.
|
||||
*/
|
||||
|
@ -2098,10 +2097,10 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
if (png_ptr->user_transform_depth != 0)
|
||||
info_ptr->bit_depth = png_ptr->user_transform_depth;
|
||||
|
||||
if (info_ptr->channels < png_ptr->user_transform_channels)
|
||||
if (png_ptr->user_transform_channels != 0)
|
||||
info_ptr->channels = png_ptr->user_transform_channels;
|
||||
}
|
||||
#endif
|
||||
|
@ -2382,8 +2381,8 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
|
|||
|
||||
while (sp < ep)
|
||||
{
|
||||
/* The input is an array of 16 bit components, these must be scaled to
|
||||
* 8 bits each. For a 16 bit value V the required value (from the PNG
|
||||
/* The input is an array of 16-bit components, these must be scaled to
|
||||
* 8 bits each. For a 16-bit value V the required value (from the PNG
|
||||
* specification) is:
|
||||
*
|
||||
* (V * 255) / 65535
|
||||
|
@ -2404,7 +2403,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
|
|||
*
|
||||
* The approximate differs from the exact answer only when (vlo-vhi) is
|
||||
* 128; it then gives a correction of +1 when the exact correction is
|
||||
* 0. This gives 128 errors. The exact answer (correct for all 16 bit
|
||||
* 0. This gives 128 errors. The exact answer (correct for all 16-bit
|
||||
* input values) is:
|
||||
*
|
||||
* error = (vlo-vhi+128)*65535 >> 24;
|
||||
|
@ -3148,9 +3147,9 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
/* From 1.5.5 in the 16 bit case do the accurate conversion even
|
||||
/* From 1.5.5 in the 16-bit case do the accurate conversion even
|
||||
* in the 'fast' case - this is because this is where the code
|
||||
* ends up when handling linear 16 bit data.
|
||||
* ends up when handling linear 16-bit data.
|
||||
*/
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
|
||||
15);
|
||||
|
@ -3315,7 +3314,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
@ -3325,7 +3324,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
unsigned int p = (*sp >> shift) & 0x0f;
|
||||
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
||||
0x0f;
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= g << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
@ -3351,7 +3350,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
@ -4460,7 +4459,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*sp == gray)
|
||||
if ((*sp & 0xffU) == gray)
|
||||
*dp-- = 0;
|
||||
|
||||
else
|
||||
|
@ -4478,7 +4477,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
dp = row + (row_info->rowbytes << 1) - 1;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*(sp - 1) == gray_high && *(sp) == gray_low)
|
||||
if ((*(sp - 1) & 0xffU) == gray_high &&
|
||||
(*(sp) & 0xffU) == gray_low)
|
||||
{
|
||||
*dp-- = 0;
|
||||
*dp-- = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.20 [December 3, 2014]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -89,7 +89,13 @@ png_get_int_32)(png_const_bytep buf)
|
|||
return uval;
|
||||
|
||||
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
||||
if ((uval & 0x80000000) == 0) /* no overflow */
|
||||
return -(png_int_32)uval;
|
||||
/* The following has to be safe; this function only gets called on PNG data
|
||||
* and if we get here that data is invalid. 0 is the most safe value and
|
||||
* if not then an attacker would surely just generate a PNG with 0 instead.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||
|
@ -98,7 +104,7 @@ png_get_uint_16)(png_const_bytep buf)
|
|||
{
|
||||
/* ANSI-C requires an int value to accomodate at least 16 bits so this
|
||||
* works and allows the compiler not to worry about possible narrowing
|
||||
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* on 32-bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* than 16 bits either.)
|
||||
*/
|
||||
unsigned int val =
|
||||
|
@ -341,7 +347,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
* are minimal.
|
||||
*/
|
||||
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
#if PNG_RELEASE_BUILD
|
||||
png_chunk_warning(png_ptr, msg);
|
||||
png_ptr->zowner = 0;
|
||||
#else
|
||||
|
@ -371,10 +377,16 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
|
||||
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
||||
PNG_OPTION_ON)
|
||||
{
|
||||
window_bits = 15;
|
||||
png_ptr->zstream_start = 0; /* fixed window size */
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
window_bits = 0;
|
||||
png_ptr->zstream_start = 1;
|
||||
}
|
||||
# else
|
||||
# define window_bits 0
|
||||
# endif
|
||||
|
@ -423,6 +435,31 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
/* Handle the start of the inflate stream if we called inflateInit2(strm,0);
|
||||
* in this case some zlib versions skip validation of the CINFO field and, in
|
||||
* certain circumstances, libpng may end up displaying an invalid image, in
|
||||
* contrast to implementations that call zlib in the normal way (e.g. libpng
|
||||
* 1.5).
|
||||
*/
|
||||
int /* PRIVATE */
|
||||
png_zlib_inflate(png_structrp png_ptr, int flush)
|
||||
{
|
||||
if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0)
|
||||
{
|
||||
if ((*png_ptr->zstream.next_in >> 4) > 7)
|
||||
{
|
||||
png_ptr->zstream.msg = "invalid window size (libpng)";
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
|
||||
png_ptr->zstream_start = 0;
|
||||
}
|
||||
|
||||
return inflate(&png_ptr->zstream, flush);
|
||||
}
|
||||
#endif /* Zlib >= 1.2.4 */
|
||||
|
||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
|
||||
* allow the caller to do multiple calls if required. If the 'finish' flag is
|
||||
|
@ -516,7 +553,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
|||
* the previous chunk of input data. Tell zlib if we have reached the
|
||||
* end of the output buffer.
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH :
|
||||
ret = PNG_INFLATE(png_ptr, avail_out > 0 ? Z_NO_FLUSH :
|
||||
(finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
} while (ret == Z_OK);
|
||||
|
||||
|
@ -575,7 +612,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||
*/
|
||||
png_alloc_size_t limit = PNG_SIZE_MAX;
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
|
@ -670,7 +707,6 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||
* success)
|
||||
*/
|
||||
png_free(png_ptr, text);
|
||||
text = NULL;
|
||||
|
||||
/* This really is very benign, but it's still an error because
|
||||
* the extra space may otherwise be used as a Trojan Horse.
|
||||
|
@ -766,7 +802,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
|||
* the available output is produced; this allows reading of truncated
|
||||
* streams.
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream,
|
||||
ret = PNG_INFLATE(png_ptr,
|
||||
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
}
|
||||
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
|
||||
|
@ -867,7 +903,7 @@ void /* PRIVATE */
|
|||
png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_color palette[PNG_MAX_PALETTE_LENGTH];
|
||||
int num, i;
|
||||
int max_palette_length, num, i;
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
png_colorp pal_ptr;
|
||||
#endif
|
||||
|
@ -928,6 +964,19 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
/* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
|
||||
num = (int)length / 3;
|
||||
|
||||
/* If the palette has 256 or fewer entries but is too large for the bit
|
||||
* depth, we don't issue an error, to preserve the behavior of previous
|
||||
* libpng versions. We silently truncate the unused extra palette entries
|
||||
* here.
|
||||
*/
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
max_palette_length = (1 << png_ptr->bit_depth);
|
||||
else
|
||||
max_palette_length = PNG_MAX_PALETTE_LENGTH;
|
||||
|
||||
if (num > max_palette_length)
|
||||
num = max_palette_length;
|
||||
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
|
||||
{
|
||||
|
@ -960,7 +1009,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#endif
|
||||
{
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_crc_finish(png_ptr, (int) length - num * 3);
|
||||
}
|
||||
|
||||
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
||||
|
@ -1147,11 +1196,13 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
return;
|
||||
|
||||
for (i=0; i<truelen; ++i)
|
||||
{
|
||||
if (buf[i] == 0 || buf[i] > sample_depth)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
|
@ -1650,7 +1701,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
++entry_start;
|
||||
|
||||
/* A sample depth should follow the separator, and we should be on it */
|
||||
if (entry_start > buffer + length - 2)
|
||||
if (length < 2U || entry_start > buffer + (length - 2U))
|
||||
{
|
||||
png_warning(png_ptr, "malformed sPLT chunk");
|
||||
return;
|
||||
|
@ -1817,7 +1868,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
return;
|
||||
}
|
||||
|
||||
if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH ||
|
||||
if (length > (unsigned int) png_ptr->num_palette ||
|
||||
length > (unsigned int) PNG_MAX_PALETTE_LENGTH ||
|
||||
length == 0)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
@ -1980,7 +2032,8 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
|
||||
num = length / 2 ;
|
||||
|
||||
if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)
|
||||
if (num != (unsigned int) png_ptr->num_palette ||
|
||||
num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
|
@ -2152,7 +2205,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
/* We need to have at least 12 bytes after the purpose string
|
||||
* in order to get the parameter information.
|
||||
*/
|
||||
if (endptr <= buf + 12)
|
||||
if (endptr - buf <= 12)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
return;
|
||||
|
@ -2715,7 +2768,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
|||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
|
@ -4017,7 +4070,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
|||
*
|
||||
* TODO: deal more elegantly with truncated IDAT lists.
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);
|
||||
ret = PNG_INFLATE(png_ptr, Z_NO_FLUSH);
|
||||
|
||||
/* Take the unconsumed output back. */
|
||||
if (output != NULL)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Last changed in libpng 1.6.21 [January 15, 2016]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -123,12 +123,12 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
|||
png_fixed(png_ptr, red_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, green_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
|
||||
png_fixed(png_ptr, green_X, "cHRM Green X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
|
||||
}
|
||||
# endif /* FLOATING_POINT */
|
||||
|
||||
|
@ -513,12 +513,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||
png_const_colorp palette, int num_palette)
|
||||
{
|
||||
|
||||
png_uint_32 max_palette_length;
|
||||
|
||||
png_debug1(1, "in %s storage function", "PLTE");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
||||
max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
|
||||
(1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
|
||||
|
||||
if (num_palette < 0 || num_palette > (int) max_palette_length)
|
||||
{
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_error(png_ptr, "Invalid palette length");
|
||||
|
@ -551,8 +556,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||
|
||||
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
|
||||
* of num_palette entries, in case of an invalid PNG file that has
|
||||
* too-large sample values.
|
||||
* of num_palette entries, in case of an invalid PNG file or incorrect
|
||||
* call to png_set_PLTE() with too-large sample values.
|
||||
*/
|
||||
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||
|
@ -673,7 +678,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
png_free(png_ptr, new_iccp_name);
|
||||
new_iccp_name = NULL;
|
||||
png_benign_error(png_ptr,
|
||||
"Insufficient memory to process iCCP profile");
|
||||
|
||||
|
@ -710,7 +714,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||
|
@ -1522,6 +1526,9 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
|||
}
|
||||
|
||||
#ifndef __COVERITY__
|
||||
/* Some compilers complain that this is always false. However, it
|
||||
* can be true when integer overflow happens.
|
||||
*/
|
||||
if (size > ZLIB_IO_MAX)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
|
@ -1566,7 +1573,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
|||
{
|
||||
/* Images with dimensions larger than these limits will be
|
||||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||
* regardless of dimensions, set both limits to 0x7ffffffL.
|
||||
* regardless of dimensions, set both limits to 0x7fffffff.
|
||||
*/
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
@ -1637,4 +1644,88 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
|||
png_ptr->num_palette_max = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \
|
||||
defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
|
||||
/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,
|
||||
* and if invalid, correct the keyword rather than discarding the entire
|
||||
* chunk. The PNG 1.0 specification requires keywords 1-79 characters in
|
||||
* length, forbids leading or trailing whitespace, multiple internal spaces,
|
||||
* and the non-break space (0x80) from ISO 8859-1. Returns keyword length.
|
||||
*
|
||||
* The 'new_key' buffer must be 80 characters in size (for the keyword plus a
|
||||
* trailing '\0'). If this routine returns 0 then there was no keyword, or a
|
||||
* valid one could not be generated, and the caller must png_error.
|
||||
*/
|
||||
png_uint_32 /* PRIVATE */
|
||||
png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
{
|
||||
png_const_charp orig_key = key;
|
||||
png_uint_32 key_len = 0;
|
||||
int bad_character = 0;
|
||||
int space = 1;
|
||||
|
||||
png_debug(1, "in png_check_keyword");
|
||||
|
||||
if (key == NULL)
|
||||
{
|
||||
*new_key = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (*key && key_len < 79)
|
||||
{
|
||||
png_byte ch = (png_byte)*key++;
|
||||
|
||||
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
|
||||
*new_key++ = ch, ++key_len, space = 0;
|
||||
|
||||
else if (space == 0)
|
||||
{
|
||||
/* A space or an invalid character when one wasn't seen immediately
|
||||
* before; output just a space.
|
||||
*/
|
||||
*new_key++ = 32, ++key_len, space = 1;
|
||||
|
||||
/* If the character was not a space then it is invalid. */
|
||||
if (ch != 32)
|
||||
bad_character = ch;
|
||||
}
|
||||
|
||||
else if (bad_character == 0)
|
||||
bad_character = ch; /* just skip it, record the first error */
|
||||
}
|
||||
|
||||
if (key_len > 0 && space != 0) /* trailing space */
|
||||
{
|
||||
--key_len, --new_key;
|
||||
if (bad_character == 0)
|
||||
bad_character = 32;
|
||||
}
|
||||
|
||||
/* Terminate the keyword */
|
||||
*new_key = 0;
|
||||
|
||||
if (key_len == 0)
|
||||
return 0;
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* Try to only output one warning per keyword: */
|
||||
if (*key != 0) /* keyword too long */
|
||||
png_warning(png_ptr, "keyword truncated");
|
||||
|
||||
else if (bad_character != 0)
|
||||
{
|
||||
PNG_WARNING_PARAMETERS(p)
|
||||
|
||||
png_warning_parameter(p, 1, orig_key);
|
||||
png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character);
|
||||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
#endif /* TEXT || pCAL || iCCP || sPLT */
|
||||
#endif /* READ || WRITE */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -219,16 +219,18 @@ struct png_struct_def
|
|||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
* While reading this is a pointer into
|
||||
* big_prev_row; while writing it is separately
|
||||
* allocated if needed.
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
* While reading, this is a pointer into
|
||||
* big_row_buf; while writing it is separately
|
||||
* allocated.
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_bytep try_row; /* buffer to save trial row when filtering */
|
||||
png_bytep tst_row; /* buffer to save best trial row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
|
@ -261,6 +263,9 @@ struct png_struct_def
|
|||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
png_byte zstream_start; /* at start of an input zlib stream */
|
||||
#endif /* Zlib >= 1.2.4 */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
|
@ -346,16 +351,6 @@ struct png_struct_def
|
|||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif
|
||||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -30,7 +30,7 @@ png_set_bgr(png_structrp png_ptr)
|
|||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Turn on 16 bit byte swapping */
|
||||
/* Turn on 16-bit byte swapping */
|
||||
void PNGAPI
|
||||
png_set_swap(png_structrp png_ptr)
|
||||
{
|
||||
|
@ -313,7 +313,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
|||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swaps byte order on 16 bit depth images */
|
||||
/* Swaps byte order on 16-bit depth images */
|
||||
void /* PRIVATE */
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
|
@ -704,7 +704,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
if ((*rp >> padding) != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
|||
* writes to a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered writes. This should never be asked
|
||||
* to write more than 64K on a 16 bit machine.
|
||||
* to write more than 64K on a 16-bit machine.
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -97,7 +97,8 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
|
||||
png_ptr->mng_features_permitted != 0)
|
||||
{
|
||||
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
|
||||
png_warning(png_ptr,
|
||||
"MNG features are not allowed in a PNG datastream");
|
||||
png_ptr->mng_features_permitted = 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -117,15 +118,15 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
* flag set, and if it does, writes the chunk.
|
||||
*
|
||||
* 1.6.0: COLORSPACE support controls the writing of these chunks too, and
|
||||
* the chunks will be written if the WRITE routine is there and information
|
||||
* is available in the COLORSPACE. (See png_colorspace_sync_info in png.c
|
||||
* for where the valid flags get set.)
|
||||
* the chunks will be written if the WRITE routine is there and
|
||||
* information * is available in the COLORSPACE. (See
|
||||
* png_colorspace_sync_info in png.c for where the valid flags get set.)
|
||||
*
|
||||
* Under certain circumstances the colorspace can be invalidated without
|
||||
* syncing the info_struct 'valid' flags; this happens if libpng detects and
|
||||
* error and calls png_error while the color space is being set, yet the
|
||||
* application continues writing the PNG. So check the 'invalid' flag here
|
||||
* too.
|
||||
* syncing the info_struct 'valid' flags; this happens if libpng detects
|
||||
* an error and calls png_error while the color space is being set, yet
|
||||
* the application continues writing the PNG. So check the 'invalid'
|
||||
* flag here too.
|
||||
*/
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||
|
@ -205,7 +206,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
png_write_PLTE(png_ptr, info_ptr->palette,
|
||||
(png_uint_32)info_ptr->num_palette);
|
||||
|
||||
else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_error(png_ptr, "Valid palette required for paletted images");
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
|
@ -216,8 +217,13 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j<(int)info_ptr->num_trans; j++)
|
||||
int j, jend;
|
||||
|
||||
jend = info_ptr->num_trans;
|
||||
if (jend > PNG_MAX_PALETTE_LENGTH)
|
||||
jend = PNG_MAX_PALETTE_LENGTH;
|
||||
|
||||
for (j = 0; j<jend; ++j)
|
||||
info_ptr->trans_alpha[j] =
|
||||
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
||||
}
|
||||
|
@ -538,7 +544,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
#if PNG_RELEASE_BUILD
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
#endif
|
||||
|
||||
|
@ -917,10 +923,6 @@ png_write_flush(png_structrp png_ptr)
|
|||
}
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
||||
#endif
|
||||
|
||||
/* Free any memory used in png_ptr struct without freeing the struct itself. */
|
||||
static void
|
||||
png_write_destroy(png_structrp png_ptr)
|
||||
|
@ -937,24 +939,11 @@ png_write_destroy(png_structrp png_ptr)
|
|||
png_ptr->row_buf = NULL;
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->sub_row);
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
png_free(png_ptr, png_ptr->avg_row);
|
||||
png_free(png_ptr, png_ptr->paeth_row);
|
||||
png_free(png_ptr, png_ptr->try_row);
|
||||
png_free(png_ptr, png_ptr->tst_row);
|
||||
png_ptr->prev_row = NULL;
|
||||
png_ptr->sub_row = NULL;
|
||||
png_ptr->up_row = NULL;
|
||||
png_ptr->avg_row = NULL;
|
||||
png_ptr->paeth_row = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
/* Use this to save a little code space, it doesn't free the filter_costs */
|
||||
png_reset_filter_heuristics(png_ptr);
|
||||
png_free(png_ptr, png_ptr->filter_costs);
|
||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
||||
png_ptr->filter_costs = NULL;
|
||||
png_ptr->inv_filter_costs = NULL;
|
||||
png_ptr->try_row = NULL;
|
||||
png_ptr->tst_row = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
@ -1044,6 +1033,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
#endif /* WRITE_FILTER */
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* If we have allocated the row_buf, this means we have already started
|
||||
* with the image and we should have allocated all of the filter buffers
|
||||
* that have been selected. If prev_row isn't already allocated, then
|
||||
|
@ -1052,203 +1042,76 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
* wants to start and stop using particular filters during compression,
|
||||
* it should start out with all of the filters, and then remove them
|
||||
* or add them back after the start of compression.
|
||||
*
|
||||
* NOTE: this is a nasty constraint on the code, because it means that the
|
||||
* prev_row buffer must be maintained even if there are currently no
|
||||
* 'prev_row' requiring filters active.
|
||||
*/
|
||||
if (png_ptr->row_buf != NULL)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
|
||||
png_ptr->sub_row == NULL)
|
||||
int num_filters;
|
||||
png_alloc_size_t buf_size;
|
||||
|
||||
/* Repeat the checks in png_write_start_row; 1 pixel high or wide
|
||||
* images cannot benefit from certain filters. If this isn't done here
|
||||
* the check below will fire on 1 pixel high images.
|
||||
*/
|
||||
if (png_ptr->height == 1)
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if (png_ptr->width == 1)
|
||||
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
|
||||
&& png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
/* This is the error case, however it is benign - the previous row
|
||||
* is not available so the filter can't be used. Just warn here.
|
||||
*/
|
||||
png_app_warning(png_ptr,
|
||||
"png_set_filter: UP/AVG/PAETH cannot be added after start");
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
|
||||
png_ptr->up_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Up filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_UP);
|
||||
}
|
||||
num_filters = 0;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
}
|
||||
if (filters & PNG_FILTER_SUB)
|
||||
num_filters++;
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
|
||||
png_ptr->avg_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Average filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_AVG);
|
||||
}
|
||||
if (filters & PNG_FILTER_UP)
|
||||
num_filters++;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
}
|
||||
if (filters & PNG_FILTER_AVG)
|
||||
num_filters++;
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
|
||||
png_ptr->paeth_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
||||
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
|
||||
}
|
||||
if (filters & PNG_FILTER_PAETH)
|
||||
num_filters++;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
/* Allocate needed row buffers if they have not already been
|
||||
* allocated.
|
||||
*/
|
||||
buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
|
||||
png_ptr->width) + 1;
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
#endif /* WRITE_FILTER */
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
if (png_ptr->try_row == NULL)
|
||||
png_ptr->try_row = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, buf_size));
|
||||
|
||||
if (num_filters > 1)
|
||||
{
|
||||
if (png_ptr->tst_row == NULL)
|
||||
png_ptr->tst_row = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, buf_size));
|
||||
}
|
||||
}
|
||||
png_ptr->do_filter = (png_byte)filters;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
png_error(png_ptr, "Unknown custom filter method");
|
||||
}
|
||||
|
||||
/* This allows us to influence the way in which libpng chooses the "best"
|
||||
* filter for the current scanline. While the "minimum-sum-of-absolute-
|
||||
* differences metric is relatively fast and effective, there is some
|
||||
* question as to whether it can be improved upon by trying to keep the
|
||||
* filtered data going to zlib more consistent, hopefully resulting in
|
||||
* better compression.
|
||||
*/
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
|
||||
/* Convenience reset API. */
|
||||
static void
|
||||
png_reset_filter_heuristics(png_structrp png_ptr)
|
||||
{
|
||||
/* Clear out any old values in the 'weights' - this must be done because if
|
||||
* the app calls set_filter_heuristics multiple times with different
|
||||
* 'num_weights' values we would otherwise potentially have wrong sized
|
||||
* arrays.
|
||||
*/
|
||||
png_ptr->num_prev_filters = 0;
|
||||
png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;
|
||||
if (png_ptr->prev_filters != NULL)
|
||||
{
|
||||
png_bytep old = png_ptr->prev_filters;
|
||||
png_ptr->prev_filters = NULL;
|
||||
png_free(png_ptr, old);
|
||||
}
|
||||
if (png_ptr->filter_weights != NULL)
|
||||
{
|
||||
png_uint_16p old = png_ptr->filter_weights;
|
||||
png_ptr->filter_weights = NULL;
|
||||
png_free(png_ptr, old);
|
||||
}
|
||||
|
||||
if (png_ptr->inv_filter_weights != NULL)
|
||||
{
|
||||
png_uint_16p old = png_ptr->inv_filter_weights;
|
||||
png_ptr->inv_filter_weights = NULL;
|
||||
png_free(png_ptr, old);
|
||||
}
|
||||
|
||||
/* Leave the filter_costs - this array is fixed size. */
|
||||
}
|
||||
|
||||
static int
|
||||
png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
int num_weights)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
/* Clear out the arrays */
|
||||
png_reset_filter_heuristics(png_ptr);
|
||||
|
||||
/* Check arguments; the 'reset' function makes the correct settings for the
|
||||
* unweighted case, but we must handle the weight case by initializing the
|
||||
* arrays for the caller.
|
||||
*/
|
||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (num_weights > 0)
|
||||
{
|
||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)((sizeof (png_byte)) * num_weights));
|
||||
|
||||
/* To make sure that the weighting starts out fairly */
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
png_ptr->prev_filters[i] = 255;
|
||||
}
|
||||
|
||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
||||
|
||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
||||
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
png_ptr->inv_filter_weights[i] =
|
||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
||||
}
|
||||
|
||||
/* Safe to set this now */
|
||||
png_ptr->num_prev_filters = (png_byte)num_weights;
|
||||
}
|
||||
|
||||
/* If, in the future, there are other filter methods, this would
|
||||
* need to be based on png_ptr->filter.
|
||||
*/
|
||||
if (png_ptr->filter_costs == NULL)
|
||||
{
|
||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
||||
|
||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
||||
}
|
||||
|
||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
||||
{
|
||||
png_ptr->inv_filter_costs[i] =
|
||||
png_ptr->filter_costs[i] = PNG_COST_FACTOR;
|
||||
}
|
||||
|
||||
/* All the arrays are inited, safe to set this: */
|
||||
png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;
|
||||
|
||||
/* Return the 'ok' code. */
|
||||
return 1;
|
||||
}
|
||||
else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT ||
|
||||
heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Unknown filter heuristic method");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||
/* Provide floating and fixed point APIs */
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
|
@ -1256,52 +1119,11 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
|||
int num_weights, png_const_doublep filter_weights,
|
||||
png_const_doublep filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics");
|
||||
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
if (filter_weights[i] <= 0.0)
|
||||
{
|
||||
png_ptr->inv_filter_weights[i] =
|
||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->inv_filter_weights[i] =
|
||||
(png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);
|
||||
|
||||
png_ptr->filter_weights[i] =
|
||||
(png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);
|
||||
}
|
||||
}
|
||||
|
||||
/* Here is where we set the relative costs of the different filters. We
|
||||
* should take the desired compression level into account when setting
|
||||
* the costs, so that Paeth, for instance, has a high relative cost at low
|
||||
* compression levels, while it has a lower relative cost at higher
|
||||
* compression settings. The filter types are in order of increasing
|
||||
* relative cost, so it would be possible to do this with an algorithm.
|
||||
*/
|
||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)
|
||||
{
|
||||
png_ptr->inv_filter_costs[i] =
|
||||
(png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);
|
||||
|
||||
png_ptr->filter_costs[i] =
|
||||
(png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);
|
||||
}
|
||||
}
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(heuristic_method)
|
||||
PNG_UNUSED(num_weights)
|
||||
PNG_UNUSED(filter_weights)
|
||||
PNG_UNUSED(filter_costs)
|
||||
}
|
||||
#endif /* FLOATING_POINT */
|
||||
|
||||
|
@ -1311,63 +1133,11 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
|||
int num_weights, png_const_fixed_point_p filter_weights,
|
||||
png_const_fixed_point_p filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics_fixed");
|
||||
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
if (filter_weights[i] <= 0)
|
||||
{
|
||||
png_ptr->inv_filter_weights[i] =
|
||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->inv_filter_weights[i] = (png_uint_16)
|
||||
((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);
|
||||
|
||||
png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*
|
||||
PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Here is where we set the relative costs of the different filters. We
|
||||
* should take the desired compression level into account when setting
|
||||
* the costs, so that Paeth, for instance, has a high relative cost at low
|
||||
* compression levels, while it has a lower relative cost at higher
|
||||
* compression settings. The filter types are in order of increasing
|
||||
* relative cost, so it would be possible to do this with an algorithm.
|
||||
*/
|
||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
||||
if (filter_costs[i] >= PNG_FP_1)
|
||||
{
|
||||
png_uint_32 tmp;
|
||||
|
||||
/* Use a 32 bit unsigned temporary here because otherwise the
|
||||
* intermediate value will be a 32 bit *signed* integer (ANSI rules)
|
||||
* and this will get the wrong answer on division.
|
||||
*/
|
||||
tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);
|
||||
tmp /= filter_costs[i];
|
||||
|
||||
png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;
|
||||
|
||||
tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;
|
||||
tmp /= PNG_FP_1;
|
||||
|
||||
png_ptr->filter_costs[i] = (png_uint_16)tmp;
|
||||
}
|
||||
}
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(heuristic_method)
|
||||
PNG_UNUSED(num_weights)
|
||||
PNG_UNUSED(filter_weights)
|
||||
PNG_UNUSED(filter_costs)
|
||||
}
|
||||
#endif /* FIXED_POINT */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
@ -1652,7 +1422,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
|
||||
#endif
|
||||
|
||||
/* Swap bits of 1, 2, 4 bit packed pixel formats */
|
||||
/* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
|
||||
if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
png_set_packswap(png_ptr);
|
||||
|
@ -1765,10 +1535,11 @@ png_write_image_16bit(png_voidp argument)
|
|||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
aindex = channels;
|
||||
# else
|
||||
aindex = channels;
|
||||
# endif
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -2227,7 +1998,7 @@ png_image_write_main(png_voidp argument)
|
|||
/* Now set up the data transformations (*after* the header is written),
|
||||
* remove the handled transformations from the 'format' flags for checking.
|
||||
*
|
||||
* First check for a little endian system if writing 16 bit files.
|
||||
* First check for a little endian system if writing 16-bit files.
|
||||
*/
|
||||
if (write_16bit != 0)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -71,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
|
@ -110,7 +111,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
|
@ -422,7 +424,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=3; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,7 +448,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*/
|
||||
sp+=6; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
|
@ -484,7 +486,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*/
|
||||
sp+=2; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,12 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project(libtiff C)
|
||||
# This convenient copy of libtiff does not support encapsulated zlib or jpeg
|
||||
# stream. see ZIP_SUPPORT and JPEG_SUPPORT values
|
||||
|
||||
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
SET(TARGET_FILES
|
||||
set(TARGET_FILES
|
||||
t4.h
|
||||
tiffiop.h
|
||||
tif_aux.c
|
||||
|
@ -53,11 +53,16 @@ SET(TARGET_FILES
|
|||
uvcode.h
|
||||
)
|
||||
|
||||
IF(UNIX)
|
||||
SET(TARGET_FILES ${TARGET_FILES} tif_unix.c)
|
||||
ELSE()
|
||||
SET(TARGET_FILES ${TARGET_FILES} tif_win32.c)
|
||||
ENDIF()
|
||||
if(UNIX)
|
||||
set(TARGET_FILES ${TARGET_FILES} tif_unix.c)
|
||||
# Large file support
|
||||
# This might not catch every possibility catered for by
|
||||
# AC_SYS_LARGEFILE.
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
set(_FILE_OFFSET_BITS 64)
|
||||
else()
|
||||
set(TARGET_FILES ${TARGET_FILES} tif_win32.c)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
|
||||
|
@ -70,6 +75,7 @@ endif()
|
|||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
CHECK_INCLUDE_FILES("zlib.h" HAVE_ZLIB_H)
|
||||
CHECK_INCLUDE_FILES("jpeglib.h" HAVE_JPEGLIB_H)
|
||||
|
@ -135,6 +141,19 @@ CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL)
|
|||
CHECK_FUNCTION_EXISTS(strtoul HAVE_STRTOUL)
|
||||
CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)
|
||||
|
||||
# May be inlined, so check it compiles:
|
||||
check_c_source_compiles("
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
char buf[10];
|
||||
snprintf(buf, 10, \"Test %d\", 1);
|
||||
return 0;
|
||||
}" HAVE_SNPRINTF)
|
||||
|
||||
if(NOT HAVE_SNPRINTF)
|
||||
set(TARGET_FILES ${TARGET_FILES} snprintf.c)
|
||||
endif()
|
||||
|
||||
include(CheckTypeSize)
|
||||
|
||||
CHECK_TYPE_SIZE("signed int" SIZEOF_SIGNED_INT)
|
||||
|
@ -162,20 +181,23 @@ if(HAVE_STDINT_H)
|
|||
if(NOT HAVE_SSIZE_T)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
|
||||
set(TIFF_SSIZE_T int64_t)
|
||||
set(TIFF_SSIZE_FORMAT "%lld")
|
||||
set(TIFF_SIZE_FORMAT "%llu")
|
||||
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
|
||||
set(TIFF_SSIZE_T int32_t)
|
||||
set(TIFF_SSIZE_FORMAT "%d")
|
||||
set(TIFF_SIZE_FORMAT "%u")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown ssize_t")
|
||||
endif()
|
||||
else()
|
||||
set(TIFF_SSIZE_T ssize_t)
|
||||
endif()
|
||||
set(TIFF_INT32_FORMAT "\"%d\"")
|
||||
set(TIFF_UINT32_FORMAT "\"%u\"")
|
||||
set(TIFF_INT64_FORMAT "\"%ld\"")
|
||||
set(TIFF_UINT64_FORMAT "\"%lu\"")
|
||||
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
|
||||
set(TIFF_SSIZE_FORMAT "\"%ld\"")
|
||||
set(TIFF_INT32_FORMAT "%d")
|
||||
set(TIFF_UINT32_FORMAT "%u")
|
||||
set(TIFF_INT64_FORMAT "%lld")
|
||||
set(TIFF_UINT64_FORMAT "%llu")
|
||||
set(TIFF_PTRDIFF_FORMAT "%ld")
|
||||
else()
|
||||
set(TIFF_INT8_T "signed __int8")
|
||||
set(TIFF_INT16_T "signed __int16")
|
||||
|
@ -189,24 +211,27 @@ else()
|
|||
if(NOT HAVE_SSIZE_T)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
|
||||
set(TIFF_SSIZE_T "signed __int64")
|
||||
set(TIFF_SSIZE_FORMAT "%lld")
|
||||
set(TIFF_SIZE_FORMAT "%llu")
|
||||
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
|
||||
set(TIFF_SSIZE_T "signed __int32")
|
||||
set(TIFF_SSIZE_FORMAT "%d")
|
||||
set(TIFF_SIZE_FORMAT "%u")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown ssize_t")
|
||||
endif()
|
||||
else()
|
||||
set(TIFF_SSIZE_T ssize_t)
|
||||
endif()
|
||||
set(TIFF_INT32_FORMAT "\"%d\"")
|
||||
set(TIFF_UINT32_FORMAT "\"%u\"")
|
||||
set(TIFF_INT64_FORMAT "\"%ld\"")
|
||||
set(TIFF_UINT64_FORMAT "\"%lu\"")
|
||||
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
|
||||
set(TIFF_SSIZE_FORMAT "\"%ld\"")
|
||||
set(TIFF_INT32_FORMAT "%d")
|
||||
set(TIFF_UINT32_FORMAT "%u")
|
||||
set(TIFF_INT64_FORMAT "%lld")
|
||||
set(TIFF_UINT64_FORMAT "%llu")
|
||||
set(TIFF_PTRDIFF_FORMAT "%ld")
|
||||
endif()
|
||||
|
||||
#
|
||||
set(VERSION "\"4.0.1\"")
|
||||
set(VERSION "\"4.0.6\"")
|
||||
set(PACKAGE_VERSION ${VERSION})
|
||||
set(PACKAGE "\"tiff\"")
|
||||
|
||||
|
@ -225,28 +250,28 @@ CHECK_SYMBOL_EXISTS(lfind "search.h" HAVE_LFIND)
|
|||
CHECK_SYMBOL_EXISTS(setmod "io.h" HAVE_SETMODE)
|
||||
|
||||
# http://www.cmake.org/pipermail/cmake/2007-September/016285.html
|
||||
FOREACH(KEYWORD "inline" "__inline__" "__inline")
|
||||
IF(NOT DEFINED C_INLINE)
|
||||
TRY_COMPILE(C_HAS_${KEYWORD} "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
foreach(KEYWORD "inline" "__inline__" "__inline")
|
||||
if(NOT DEFINED C_INLINE)
|
||||
try_compile(C_HAS_${KEYWORD} "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/test_inline.c"
|
||||
COMPILE_DEFINITIONS "-Dinline=${KEYWORD}")
|
||||
IF(C_HAS_${KEYWORD})
|
||||
SET(C_INLINE TRUE)
|
||||
SET(INLINE "${KEYWORD}")
|
||||
ENDIF(C_HAS_${KEYWORD})
|
||||
ENDIF(NOT DEFINED C_INLINE)
|
||||
ENDFOREACH(KEYWORD)
|
||||
if(C_HAS_${KEYWORD})
|
||||
set(C_INLINE TRUE)
|
||||
set(INLINE_KEYWORD "${KEYWORD}")
|
||||
endif(C_HAS_${KEYWORD})
|
||||
endif(NOT DEFINED C_INLINE)
|
||||
endforeach(KEYWORD)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tif_config.h @ONLY)
|
||||
|
||||
SET(LIBTARGET "tiff")
|
||||
set(LIBTARGET "tiff")
|
||||
#
|
||||
ADD_LIBRARY(${LIBTARGET} STATIC ${TARGET_FILES})
|
||||
add_library(${LIBTARGET} STATIC ${TARGET_FILES})
|
||||
#
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET}
|
||||
set_target_properties(${LIBTARGET}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${LIBTARGET}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/lib
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/* $Id: libport.h,v 1.5 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Frank Warmerdam
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _LIBPORT_
|
||||
#define _LIBPORT_
|
||||
|
||||
int getopt(int argc, char * const argv[], const char *optstring);
|
||||
extern char *optarg;
|
||||
extern int opterr;
|
||||
extern int optind;
|
||||
extern int optopt;
|
||||
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
# define HAVE_GETOPT 1
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void *
|
||||
lfind(const void *key, const void *base, size_t *nmemb, size_t size,
|
||||
int(*compar)(const void *, const void *));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
#undef vsnprintf
|
||||
#define vsnprintf _TIFF_vsnprintf_f
|
||||
|
||||
#undef snprintf
|
||||
#define snprintf _TIFF_snprintf_f
|
||||
int snprintf(char* str, size_t size, const char* format, ...);
|
||||
#endif
|
||||
|
||||
#endif /* ndef _LIBPORT_ */
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Workaround for lack of snprintf(3) in Visual Studio. See
|
||||
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
|
||||
* It's a trivial wrapper around the builtin _vsnprintf_s and
|
||||
* _vscprintf functions.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "libport.h"
|
||||
|
||||
int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
if (size != 0)
|
||||
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
||||
if (count == -1)
|
||||
count = _vscprintf(format, ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
|
||||
{
|
||||
int count;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
count = vsnprintf(str, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // _MSC_VER
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: tif_codec.c,v 1.16 2013-05-02 14:44:29 tgl Exp $ */
|
||||
/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
|
@ -108,8 +108,7 @@ _notConfigured(TIFF* tif)
|
|||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
char compression_code[20];
|
||||
|
||||
snprintf(compression_code, sizeof(compression_code), "%d",
|
||||
tif->tif_dir.td_compression );
|
||||
sprintf(compression_code, "%d",tif->tif_dir.td_compression );
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s compression support is not configured",
|
||||
c ? c->name : compression_code );
|
||||
|
|
|
@ -1,357 +1,237 @@
|
|||
/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
#cmakedefine AC_APPLE_UNIVERSAL_BUILD
|
||||
/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */
|
||||
/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */
|
||||
|
||||
/* Support CCITT Group 3 & 4 algorithms */
|
||||
#cmakedefine CCITT_SUPPORT @CCITT_SUPPORT@
|
||||
#cmakedefine CCITT_SUPPORT 1
|
||||
|
||||
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||
lacking the tag (default enabled). */
|
||||
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING @CHECK_JPEG_YCBCR_SUBSAMPLING@
|
||||
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||
|
||||
/* enable partial strip reading for large strips (experimental) */
|
||||
#cmakedefine CHUNKY_STRIP_READ_SUPPORT
|
||||
#cmakedefine CHUNKY_STRIP_READ_SUPPORT 1
|
||||
|
||||
/* Support C++ stream API (requires C++ compiler) */
|
||||
#cmakedefine CXX_SUPPORT @CXX_SUPPORT@
|
||||
|
||||
/* Treat extra sample as alpha (default enabled). The RGBA interface will
|
||||
treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many
|
||||
packages produce RGBA files but don't mark the alpha properly. */
|
||||
#cmakedefine DEFAULT_EXTRASAMPLE_AS_ALPHA @DEFAULT_EXTRASAMPLE_AS_ALPHA@
|
||||
#cmakedefine CXX_SUPPORT 1
|
||||
|
||||
/* enable deferred strip/tile offset/size loading (experimental) */
|
||||
#cmakedefine DEFER_STRILE_LOAD @DEFER_STRILE_LOAD@
|
||||
#cmakedefine DEFER_STRILE_LOAD 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#cmakedefine HAVE_ASSERT_H @HAVE_ASSERT_H@
|
||||
#cmakedefine HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#cmakedefine HAVE_FCNTL_H @HAVE_FCNTL_H@
|
||||
#cmakedefine HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#cmakedefine HAVE_FLOOR @HAVE_FLOOR@
|
||||
#cmakedefine HAVE_FLOOR 1
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#cmakedefine HAVE_GETOPT @HAVE_GETOPT@
|
||||
#cmakedefine HAVE_GETOPT 1
|
||||
|
||||
/* Define to 1 if you have the <GLUT/glut.h> header file. */
|
||||
#cmakedefine HAVE_GLUT_GLUT_H @HAVE_GLUT_GLUT_H@
|
||||
#cmakedefine HAVE_GLUT_GLUT_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/glut.h> header file. */
|
||||
#cmakedefine HAVE_GL_GLUT_H @HAVE_GL_GLUT_H@
|
||||
#cmakedefine HAVE_GL_GLUT_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/glu.h> header file. */
|
||||
#cmakedefine HAVE_GL_GLU_H @HAVE_GL_GLU_H@
|
||||
#cmakedefine HAVE_GL_GLU_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||
#cmakedefine HAVE_GL_GL_H @HAVE_GL_GL_H@
|
||||
|
||||
/* Define as 0 or 1 according to the floating point format suported by the
|
||||
machine */
|
||||
#define HAVE_IEEEFP 1
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
#cmakedefine HAVE_INT16
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
#cmakedefine HAVE_INT32
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
#cmakedefine HAVE_INT8
|
||||
#cmakedefine HAVE_GL_GL_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <io.h> header file. */
|
||||
#cmakedefine HAVE_IO_H @HAVE_IO_H@
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#cmakedefine HAVE_ISASCII @HAVE_ISASCII@
|
||||
#cmakedefine HAVE_ISASCII 1
|
||||
|
||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||
#cmakedefine HAVE_JBG_NEWLEN @HAVE_JBG_NEWLEN@
|
||||
#cmakedefine HAVE_JBG_NEWLEN 1
|
||||
|
||||
/* Define to 1 if you have the `lfind' function. */
|
||||
#cmakedefine HAVE_LFIND @HAVE_LFIND@
|
||||
|
||||
/* Define to 1 if you have the `c' library (-lc). */
|
||||
#cmakedefine HAVE_LIBC @HAVE_LIBC@
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#cmakedefine HAVE_LIBM @HAVE_LIBM@
|
||||
#cmakedefine HAVE_LFIND 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H @HAVE_LIMITS_H@
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#cmakedefine HAVE_MALLOC_H @HAVE_MALLOC_H@
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#cmakedefine HAVE_MEMMOVE @HAVE_MEMMOVE@
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#cmakedefine HAVE_MEMSET @HAVE_MEMSET@
|
||||
#cmakedefine HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#cmakedefine HAVE_MMAP @HAVE_MMAP@
|
||||
#cmakedefine HAVE_MMAP 1
|
||||
|
||||
/* Define to 1 if you have the <OpenGL/glu.h> header file. */
|
||||
#cmakedefine HAVE_OPENGL_GLU_H @HAVE_OPENGL_GLU_H@
|
||||
#cmakedefine HAVE_OPENGL_GLU_H 1
|
||||
|
||||
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
|
||||
#cmakedefine HAVE_OPENGL_GL_H @HAVE_OPENGL_GL_H@
|
||||
#cmakedefine HAVE_OPENGL_GL_H 1
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#cmakedefine HAVE_POW @HAVE_POW@
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#cmakedefine HAVE_PTHREAD
|
||||
#cmakedefine HAVE_POW 1
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#cmakedefine HAVE_SEARCH_H @HAVE_SEARCH_H@
|
||||
#cmakedefine HAVE_SEARCH_H 1
|
||||
|
||||
/* Define to 1 if you have the `setmode' function. */
|
||||
#cmakedefine HAVE_SETMODE @HAVE_SETMODE@
|
||||
#cmakedefine HAVE_SETMODE 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `sqrt' function. */
|
||||
#cmakedefine HAVE_SQRT @HAVE_SQRT@
|
||||
#cmakedefine HAVE_SQRT 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#cmakedefine HAVE_STRCASECMP @HAVE_STRCASECMP@
|
||||
#cmakedefine HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#cmakedefine HAVE_STRCHR @HAVE_STRCHR@
|
||||
#cmakedefine HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#cmakedefine HAVE_STRRCHR @HAVE_STRRCHR@
|
||||
#cmakedefine HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#cmakedefine HAVE_STRSTR @HAVE_STRSTR@
|
||||
#cmakedefine HAVE_STRSTR 1
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#cmakedefine HAVE_STRTOL @HAVE_STRTOL@
|
||||
#cmakedefine HAVE_STRTOL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#cmakedefine HAVE_STRTOUL @HAVE_STRTOUL@
|
||||
#cmakedefine HAVE_STRTOUL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#cmakedefine HAVE_STRTOULL @HAVE_STRTOULL@
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
|
||||
#cmakedefine HAVE_STRTOULL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
|
||||
#cmakedefine HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
|
||||
|
||||
/* Use nonstandard varargs form for the GLU tesselator callback */
|
||||
#cmakedefine HAVE_VARARGS_GLU_TESSCB
|
||||
|
||||
/* Define to 1 if you have the <windows.h> header file. */
|
||||
#cmakedefine HAVE_WINDOWS_H @HAVE_WINDOWS_H@
|
||||
|
||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||
(Intel) */
|
||||
#define HOST_BIGENDIAN @HOST_BIGENDIAN@
|
||||
|
||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||
#cmakedefine HOST_FILLORDER @HOST_FILLORDER@
|
||||
|
||||
/* Support ISO JBIG compression (requires JBIG-KIT library) */
|
||||
#cmakedefine JBIG_SUPPORT
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
||||
/* 8/12 bit libjpeg dual mode enabled */
|
||||
#cmakedefine JPEG_DUAL_MODE_8_12
|
||||
|
||||
/* Support JPEG compression (requires IJG JPEG library) */
|
||||
#cmakedefine JPEG_SUPPORT @JPEG_SUPPORT@
|
||||
#cmakedefine JPEG_DUAL_MODE_8_12 1
|
||||
|
||||
/* 12bit libjpeg primary include file with path */
|
||||
#cmakedefine LIBJPEG_12_PATH
|
||||
|
||||
/* Support LogLuv high dynamic range encoding */
|
||||
#define LOGLUV_SUPPORT 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@
|
||||
|
||||
/* Support LZMA2 compression */
|
||||
#cmakedefine LZMA_SUPPORT @LZMA_SUPPORT@
|
||||
|
||||
/* Support LZW algorithm */
|
||||
#define LZW_SUPPORT 1
|
||||
|
||||
/* Support Microsoft Document Imaging format */
|
||||
#cmakedefine MDI_SUPPORT @MDI_SUPPORT@
|
||||
|
||||
/* Support NeXT 2-bit RLE algorithm */
|
||||
#define NEXT_SUPPORT 1
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#cmakedefine NO_MINUS_C_MINUS_O @NO_MINUS_C_MINUS_O@
|
||||
|
||||
/* Support Old JPEG compresson (read-only) */
|
||||
#cmakedefine OJPEG_SUPPORT
|
||||
#cmakedefine LZMA_SUPPORT 1
|
||||
|
||||
/* Name of package */
|
||||
#cmakedefine PACKAGE @PACKAGE@
|
||||
#define PACKAGE "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#cmakedefine PACKAGE_BUGREPORT
|
||||
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#cmakedefine PACKAGE_NAME
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#cmakedefine PACKAGE_STRING
|
||||
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#cmakedefine PACKAGE_TARNAME
|
||||
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#cmakedefine PACKAGE_VERSION @PACKAGE_VERSION@
|
||||
|
||||
/* Support Macintosh PackBits algorithm */
|
||||
#define PACKBITS_SUPPORT 1
|
||||
|
||||
/* Support Pixar log-format algorithm (requires Zlib) */
|
||||
#cmakedefine PIXARLOG_SUPPORT @PIXARLOG_SUPPORT@
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#cmakedefine PTHREAD_CREATE_JOINABLE
|
||||
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* The size of `signed int', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
|
||||
#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
|
||||
|
||||
/* The size of `signed long', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
|
||||
#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
|
||||
|
||||
/* The size of `signed long long', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
|
||||
#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
|
||||
|
||||
/* The size of `signed short', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
|
||||
#define SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
|
||||
|
||||
/* The size of `unsigned char *', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
|
||||
#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
|
||||
|
||||
/* The size of `unsigned int', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
|
||||
#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
|
||||
|
||||
/* The size of `unsigned long', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
|
||||
#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
|
||||
|
||||
/* The size of `unsigned long long', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
|
||||
#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
|
||||
|
||||
/* The size of `unsigned short', as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#cmakedefine STDC_HEADERS @STDC_HEADERS@
|
||||
|
||||
/* Support strip chopping (whether or not to convert single-strip uncompressed
|
||||
images to mutiple strips of specified size to reduce memory usage) */
|
||||
#cmakedefine STRIPCHOP_DEFAULT @STRIPCHOP_DEFAULT@
|
||||
#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
|
||||
|
||||
/* Default size of the strip in bytes (when strip chopping enabled) */
|
||||
#cmakedefine STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
|
||||
|
||||
/* Enable SubIFD tag (330) support */
|
||||
#cmakedefine SUBIFD_SUPPORT @SUBIFD_SUPPORT@
|
||||
|
||||
/* Support ThunderScan 4-bit RLE algorithm */
|
||||
#cmakedefine THUNDER_SUPPORT @THUNDER_SUPPORT@
|
||||
|
||||
/* Signed 16-bit type */
|
||||
#cmakedefine TIFF_INT16_T @TIFF_INT16_T@
|
||||
#define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
|
||||
|
||||
/* Signed 32-bit type formatter */
|
||||
#cmakedefine TIFF_INT32_FORMAT @TIFF_INT32_FORMAT@
|
||||
|
||||
/* Signed 32-bit type */
|
||||
#cmakedefine TIFF_INT32_T @TIFF_INT32_T@
|
||||
#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@"
|
||||
|
||||
/* Signed 64-bit type formatter */
|
||||
#cmakedefine TIFF_INT64_FORMAT @TIFF_INT64_FORMAT@
|
||||
|
||||
/* Signed 64-bit type */
|
||||
#cmakedefine TIFF_INT64_T @TIFF_INT64_T@
|
||||
|
||||
/* Signed 8-bit type */
|
||||
#cmakedefine TIFF_INT8_T @TIFF_INT8_T@
|
||||
#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@"
|
||||
|
||||
/* Pointer difference type formatter */
|
||||
#cmakedefine TIFF_PTRDIFF_FORMAT @TIFF_PTRDIFF_FORMAT@
|
||||
#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@"
|
||||
|
||||
/* Pointer difference type */
|
||||
#cmakedefine TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@
|
||||
/* Unsigned size type formatter */
|
||||
#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@"
|
||||
|
||||
/* Signed size type formatter */
|
||||
#cmakedefine TIFF_SSIZE_FORMAT @TIFF_SSIZE_FORMAT@
|
||||
|
||||
/* Signed size type */
|
||||
#cmakedefine TIFF_SSIZE_T @TIFF_SSIZE_T@
|
||||
|
||||
/* Unsigned 16-bit type */
|
||||
#cmakedefine TIFF_UINT16_T @TIFF_UINT16_T@
|
||||
#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@"
|
||||
|
||||
/* Unsigned 32-bit type formatter */
|
||||
#cmakedefine TIFF_UINT32_FORMAT @TIFF_UINT32_FORMAT@
|
||||
|
||||
/* Unsigned 32-bit type */
|
||||
#cmakedefine TIFF_UINT32_T @TIFF_UINT32_T@
|
||||
#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@"
|
||||
|
||||
/* Unsigned 64-bit type formatter */
|
||||
#cmakedefine TIFF_UINT64_FORMAT @TIFF_UINT64_FORMAT@
|
||||
|
||||
/* Unsigned 64-bit type */
|
||||
#cmakedefine TIFF_UINT64_T @TIFF_UINT64_T@
|
||||
#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@"
|
||||
|
||||
/* Unsigned 8-bit type */
|
||||
#cmakedefine TIFF_UINT8_T @TIFF_UINT8_T@
|
||||
#define TIFF_UINT8_T @TIFF_UINT8_T@
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#cmakedefine TIME_WITH_SYS_TIME @TIME_WITH_SYS_TIME@
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#cmakedefine TM_IN_SYS_TIME
|
||||
#cmakedefine TM_IN_SYS_TIME 1
|
||||
|
||||
/* define to use win32 IO system */
|
||||
#cmakedefine USE_WIN32_FILEIO
|
||||
#cmakedefine USE_WIN32_FILEIO 1
|
||||
|
||||
/* Version number of package */
|
||||
#cmakedefine VERSION @VERSION@
|
||||
#define VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
|
@ -361,38 +241,21 @@
|
|||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if the X Window System is missing or not being used. */
|
||||
#cmakedefine X_DISPLAY_MISSING
|
||||
|
||||
/* Support Deflate compression */
|
||||
#cmakedefine ZIP_SUPPORT @ZIP_SUPPORT@
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#cmakedefine _LARGE_FILES
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#cmakedefine const
|
||||
|
||||
/* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#define inline @INLINE@
|
||||
#define inline @INLINE_KEYWORD@
|
||||
#endif
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
#cmakedefine off_t
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#cmakedefine size_t
|
||||
#undef size_t
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
/* Define to 1 if you have the `floor' function. */
|
||||
#undef HAVE_FLOOR
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#undef HAVE_GETOPT
|
||||
|
||||
|
@ -119,6 +122,9 @@
|
|||
/* Define to 1 if you have the `setmode' function. */
|
||||
#undef HAVE_SETMODE
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `sqrt' function. */
|
||||
#undef HAVE_SQRT
|
||||
|
||||
|
@ -382,6 +388,9 @@
|
|||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
#undef _LARGEFILE_SOURCE
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: tif_dirread.c,v 1.187 2015-05-31 21:09:33 bfriesen Exp $ */
|
||||
/* $Id: tif_dirread.c,v 1.191 2015-09-05 20:31:41 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
|
@ -3174,11 +3174,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value)
|
|||
/*
|
||||
* Largest 32-bit unsigned integer value.
|
||||
*/
|
||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
||||
# define TIFF_UINT32_MAX 0xFFFFFFFFI64
|
||||
#else
|
||||
# define TIFF_UINT32_MAX 0xFFFFFFFFLL
|
||||
#endif
|
||||
#define TIFF_UINT32_MAX 0xFFFFFFFFU
|
||||
|
||||
static enum TIFFReadDirEntryErr
|
||||
TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
|
||||
|
@ -3192,7 +3188,7 @@ TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
|
|||
static enum TIFFReadDirEntryErr
|
||||
TIFFReadDirEntryCheckRangeLongSlong8(int64 value)
|
||||
{
|
||||
if ((value<0) || (value > TIFF_UINT32_MAX))
|
||||
if ((value < 0) || (value > (int64) TIFF_UINT32_MAX))
|
||||
return(TIFFReadDirEntryErrRange);
|
||||
else
|
||||
return(TIFFReadDirEntryErrOk);
|
||||
|
@ -3209,19 +3205,21 @@ TIFFReadDirEntryCheckRangeSlongLong(uint32 value)
|
|||
return(TIFFReadDirEntryErrOk);
|
||||
}
|
||||
|
||||
/* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */
|
||||
static enum TIFFReadDirEntryErr
|
||||
TIFFReadDirEntryCheckRangeSlongLong8(uint64 value)
|
||||
{
|
||||
if (value > 0x7FFFFFFFUL)
|
||||
if (value > 0x7FFFFFFF)
|
||||
return(TIFFReadDirEntryErrRange);
|
||||
else
|
||||
return(TIFFReadDirEntryErrOk);
|
||||
}
|
||||
|
||||
/* Check that the 8-byte signed value can fit in a 4-byte signed range */
|
||||
static enum TIFFReadDirEntryErr
|
||||
TIFFReadDirEntryCheckRangeSlongSlong8(int64 value)
|
||||
{
|
||||
if ((value < 0L-0x80000000L) || (value > 0x7FFFFFFFL))
|
||||
if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF))
|
||||
return(TIFFReadDirEntryErrRange);
|
||||
else
|
||||
return(TIFFReadDirEntryErrOk);
|
||||
|
@ -3266,11 +3264,7 @@ TIFFReadDirEntryCheckRangeLong8Slong8(int64 value)
|
|||
/*
|
||||
* Largest 64-bit signed integer value.
|
||||
*/
|
||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
||||
# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFI64
|
||||
#else
|
||||
# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFLL
|
||||
#endif
|
||||
#define TIFF_INT64_MAX ((int64)(((uint64) ~0) >> 1))
|
||||
|
||||
static enum TIFFReadDirEntryErr
|
||||
TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue