temporarily disable some memory optimizations, to avoid breaking spirit of current ABI

This commit is contained in:
Aaron Boxer 2016-01-09 10:26:35 -05:00
parent 588e09726e
commit 666e077ab8
13 changed files with 364 additions and 420 deletions

View File

@ -1,6 +1,6 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
@ -8,7 +8,7 @@
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
@ -103,13 +103,13 @@ static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
cb -= offset; cr -= offset;
r = y + (int)(1.402 * (float)cr);
if (r < 0) r = 0; else if (r > upb) r = upb; *out_r = r;
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
if (g < 0) g = 0; else if (g > upb) g = upb; *out_g = g;
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
b = y + (int)(1.772 * (float)cb);
if (b < 0) b = 0; else if (b > upb) b = upb; *out_b = b;
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
}
static void sycc444_to_rgb(opj_image_t *img)
@ -121,10 +121,9 @@ static void sycc444_to_rgb(opj_image_t *img)
opj_image_t* new_image = image_create(3, img->comps[0].w, img->comps[0].h, img->comps[0].prec);
upb = (int)img->comps[0].prec;
offset = 1 << (upb - 1); upb = (1 << upb) - 1;
offset = 1<<(upb - 1); upb = (1<<upb)-1;
maxw = (unsigned int)img->comps[0].w;
maxh = (unsigned int)img->comps[0].h;
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
max = maxw * maxh;
y = img->comps[0].data;
@ -142,7 +141,7 @@ static void sycc444_to_rgb(opj_image_t *img)
opj_image_destroy(new_image);
new_image = NULL;
for (i = 0U; i < max; ++i)
for(i = 0U; i < max; ++i)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++cb; ++cr; ++r; ++g; ++b;
@ -155,7 +154,7 @@ static void sycc444_to_rgb(opj_image_t *img)
}/* 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;
@ -164,7 +163,7 @@ static void sycc422_to_rgb(opj_image_t *img)
opj_image_t* new_image = image_create(3, img->comps[0].w, img->comps[0].h, img->comps[0].prec);
upb = (int)img->comps[0].prec;
offset = 1 << (upb - 1); upb = (1 << upb) - 1;
offset = 1<<(upb - 1); upb = (1<<upb)-1;
maxw = (unsigned int)img->comps[0].w;
maxh = (unsigned int)img->comps[0].h;
@ -186,7 +185,7 @@ static void sycc422_to_rgb(opj_image_t *img)
for (i = 0U; i < maxh; ++i)
{
for (j = 0U; j < (maxw & ~(unsigned int)1U); j += 2U)
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b;
@ -227,7 +226,7 @@ static void sycc420_to_rgb(opj_image_t *img)
opj_image_t* new_image = image_create(3, img->comps[0].w, img->comps[0].h, img->comps[0].prec);
upb = (int)img->comps[0].prec;
offset = 1 << (upb - 1); upb = (1 << upb) - 1;
offset = 1<<(upb - 1); upb = (1<<upb)-1;
maxw = (unsigned int)img->comps[0].w;
maxh = (unsigned int)img->comps[0].h;
@ -252,7 +251,7 @@ static void sycc420_to_rgb(opj_image_t *img)
ny = y + maxw;
nr = r + maxw; ng = g + maxw; nb = b + maxw;
for (j = 0; j < (maxw & ~(unsigned int)1U); j += 2U)
for(j=0; j < (maxw & ~(unsigned int)1U); j += 2U)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b;
@ -264,7 +263,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 < maxw)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b;
@ -274,9 +273,9 @@ static void sycc420_to_rgb(opj_image_t *img)
}
y += maxw; r += maxw; g += maxw; b += maxw;
}
if (i < maxh)
if(i < maxh)
{
for (j = 0U; j < (maxw & ~(unsigned int)1U); j += 2U)
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
@ -286,7 +285,7 @@ static void sycc420_to_rgb(opj_image_t *img)
++y; ++r; ++g; ++b; ++cb; ++cr;
}
if (j < maxw)
if(j < maxw)
{
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
}
@ -312,46 +311,46 @@ static void sycc420_to_rgb(opj_image_t *img)
void color_sycc_to_rgb(opj_image_t *img)
{
if (img->numcomps < 3)
if(img->numcomps < 3)
{
img->color_space = OPJ_CLRSPC_GRAY;
return;
}
if ((img->comps[0].dx == 1)
&& (img->comps[1].dx == 2)
&& (img->comps[2].dx == 2)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 2)
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
{
if((img->comps[0].dx == 1)
&& (img->comps[1].dx == 2)
&& (img->comps[2].dx == 2)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 2)
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
{
sycc420_to_rgb(img);
}
}
else
if ((img->comps[0].dx == 1)
&& (img->comps[1].dx == 2)
&& (img->comps[2].dx == 2)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 1)
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
{
sycc422_to_rgb(img);
}
else
if ((img->comps[0].dx == 1)
&& (img->comps[1].dx == 1)
&& (img->comps[2].dx == 1)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 1)
&& (img->comps[2].dy == 1))/* no sub-sample */
{
sycc444_to_rgb(img);
}
else
{
fprintf(stderr, "%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__, __LINE__);
return;
}
if((img->comps[0].dx == 1)
&& (img->comps[1].dx == 2)
&& (img->comps[2].dx == 2)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 1)
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
{
sycc422_to_rgb(img);
}
else
if((img->comps[0].dx == 1)
&& (img->comps[1].dx == 1)
&& (img->comps[2].dx == 1)
&& (img->comps[0].dy == 1)
&& (img->comps[1].dy == 1)
&& (img->comps[2].dy == 1))/* no sub-sample */
{
sycc444_to_rgb(img);
}
else
{
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() */
@ -386,201 +385,201 @@ void color_apply_icc_profile(opj_image_t *image)
OPJ_COLOR_SPACE oldspace;
opj_image_t* new_image = NULL;
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);
fclose(icm);
FILE *icm = fopen("debug.icm","wb");
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
fclose(icm);
#endif
if (in_prof == NULL) return;
if(in_prof == NULL) return;
in_space = cmsGetPCS(in_prof);
out_space = cmsGetColorSpace(in_prof);
intent = cmsGetHeaderRenderingIntent(in_prof);
max_w = (int)image->comps[0].w;
max_h = (int)image->comps[0].h;
max_h = (int)image->comps[0].h;
prec = (int)image->comps[0].prec;
oldspace = image->color_space;
if (out_space == cmsSigRgbData) /* enumCS 16 */
{
if (prec <= 8)
{
in_type = TYPE_RGB_8;
out_type = TYPE_RGB_8;
}
else
{
in_type = TYPE_RGB_16;
out_type = TYPE_RGB_16;
}
out_prof = cmsCreate_sRGBProfile();
image->color_space = OPJ_CLRSPC_SRGB;
}
if(out_space == cmsSigRgbData) /* enumCS 16 */
{
if( prec <= 8 )
{
in_type = TYPE_RGB_8;
out_type = TYPE_RGB_8;
}
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;
}
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;
}
else
{
{
in_type = TYPE_RGB_16;
out_type = TYPE_RGB_16;
}
out_prof = cmsCreate_sRGBProfile();
image->color_space = OPJ_CLRSPC_SRGB;
}
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;
}
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;
}
else
{
#ifdef DEBUG_PROFILE
fprintf(stderr, "%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
__FILE__, __LINE__, out_space,
(out_space >> 24) & 0xff, (out_space >> 16) & 0xff,
(out_space >> 8) & 0xff, out_space & 0xff);
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
__FILE__,__LINE__,out_space,
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
(out_space>>8) & 0xff, out_space & 0xff);
#endif
return;
}
return;
}
#ifdef DEBUG_PROFILE
fprintf(stderr, "%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
"\n\tprofile: in(%p) out(%p)\n", __FILE__, __LINE__, image->numcomps, prec,
max_w, max_h, (void*)in_prof, (void*)out_prof);
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
max_w,max_h, (void*)in_prof,(void*)out_prof);
fprintf(stderr, "\trender_intent (%u)\n\t"
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
" type: in(%u) out:(%u)\n",
intent,
in_space,
(in_space >> 24) & 0xff, (in_space >> 16) & 0xff,
(in_space >> 8) & 0xff, in_space & 0xff,
fprintf(stderr,"\trender_intent (%u)\n\t"
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
" type: in(%u) out:(%u)\n",
intent,
in_space,
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
(in_space>>8) & 0xff, in_space & 0xff,
out_space,
(out_space >> 24) & 0xff, (out_space >> 16) & 0xff,
(out_space >> 8) & 0xff, out_space & 0xff,
out_space,
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
(out_space>>8) & 0xff, out_space & 0xff,
in_type, out_type
);
in_type,out_type
);
#else
(void)prec;
(void)in_space;
(void)prec;
(void)in_space;
#endif /* DEBUG_PROFILE */
transform = cmsCreateTransform(in_prof, in_type,
out_prof, out_type, intent, 0);
out_prof, out_type, intent, 0);
#ifdef OPJ_HAVE_LIBLCMS2
/* Possible for: LCMS_VERSION >= 2000 :*/
/* Possible for: LCMS_VERSION >= 2000 :*/
cmsCloseProfile(in_prof);
cmsCloseProfile(out_prof);
#endif
if (transform == NULL)
{
if(transform == NULL)
{
#ifdef DEBUG_PROFILE
fprintf(stderr, "%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
"ICC Profile ignored.\n", __FILE__, __LINE__);
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
"ICC Profile ignored.\n",__FILE__,__LINE__);
#endif
image->color_space = oldspace;
image->color_space = oldspace;
#ifdef OPJ_HAVE_LIBLCMS1
cmsCloseProfile(in_prof);
cmsCloseProfile(out_prof);
cmsCloseProfile(in_prof);
cmsCloseProfile(out_prof);
#endif
return;
}
return;
}
if (image->numcomps > 2)/* RGB, RGBA */
{
if (prec <= 8)
{
unsigned char *inbuf, *outbuf, *in, *out;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
in = inbuf = (unsigned char*)malloc(nr_samples);
out = outbuf = (unsigned char*)malloc(nr_samples);
if(image->numcomps > 2)/* RGB, RGBA */
{
if( prec <= 8 )
{
unsigned char *inbuf, *outbuf, *in, *out;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
in = inbuf = (unsigned char*)malloc(nr_samples);
out = outbuf = (unsigned char*)malloc(nr_samples);
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
for (i = 0; i < max; ++i)
{
*in++ = (unsigned char)*r++;
*in++ = (unsigned char)*g++;
*in++ = (unsigned char)*b++;
}
for(i = 0; i < max; ++i)
{
*in++ = (unsigned char)*r++;
*in++ = (unsigned char)*g++;
*in++ = (unsigned char)*b++;
}
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
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);
}
else
{
unsigned short *inbuf, *outbuf, *in, *out;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
in = inbuf = (unsigned short*)malloc(nr_samples);
out = outbuf = (unsigned short*)malloc(nr_samples);
for(i = 0; i < max; ++i)
{
*r++ = (int)*out++;
*g++ = (int)*out++;
*b++ = (int)*out++;
}
free(inbuf); free(outbuf);
}
else
{
unsigned short *inbuf, *outbuf, *in, *out;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
in = inbuf = (unsigned short*)malloc(nr_samples);
out = outbuf = (unsigned short*)malloc(nr_samples);
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
for (i = 0; i < max; ++i)
{
*in++ = (unsigned short)*r++;
*in++ = (unsigned short)*g++;
*in++ = (unsigned short)*b++;
}
for(i = 0; i < max; ++i)
{
*in++ = (unsigned short)*r++;
*in++ = (unsigned short)*g++;
*in++ = (unsigned short)*b++;
}
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
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);
}
}
for(i = 0; i < max; ++i)
{
*r++ = (int)*out++;
*g++ = (int)*out++;
*b++ = (int)*out++;
}
free(inbuf); free(outbuf);
}
}
else /* GRAY, GRAYA */
{
unsigned char *in, *inbuf, *out, *outbuf;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
in = inbuf = (unsigned char*)malloc(nr_samples);
out = outbuf = (unsigned char*)malloc(nr_samples);
{
unsigned char *in, *inbuf, *out, *outbuf;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
in = inbuf = (unsigned char*)malloc(nr_samples);
out = outbuf = (unsigned char*)malloc(nr_samples);
new_image = image_create(2, image->comps[0].w, image->comps[0].h, image->comps[0].prec);
image->comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps + 2)*sizeof(opj_image_comp_t));
if (image->numcomps == 2)
image->comps[3] = image->comps[1];
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] = image->comps[0];
image->comps[2] = image->comps[0];
image->comps[1].data = new_image->comps[0].data;
image->comps[2].data = new_image->comps[1].data;
@ -591,27 +590,27 @@ void color_apply_icc_profile(opj_image_t *image)
opj_image_destroy(new_image);
new_image = NULL;
image->numcomps += 2;
image->numcomps += 2;
r = image->comps[0].data;
r = image->comps[0].data;
for (i = 0; i < max; ++i)
{
*in++ = (unsigned char)*r++;
}
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
for(i = 0; i < max; ++i)
{
*in++ = (unsigned char)*r++;
}
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
r = image->comps[0].data;
g = image->comps[1].data;
b = image->comps[2].data;
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);
for(i = 0; i < max; ++i)
{
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
}
free(inbuf); free(outbuf);
}/* if(image->numcomps */
}/* if(image->numcomps */
cmsDeleteTransform(transform);
@ -625,22 +624,22 @@ void color_cielab_to_rgb(opj_image_t *image)
{
int *row;
int enumcs, numcomps;
image->color_space = OPJ_CLRSPC_SRGB;
numcomps = (int)image->numcomps;
if (numcomps != 3)
if(numcomps != 3)
{
fprintf(stderr, "%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
__FILE__, __LINE__, numcomps);
fprintf(stderr,"%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
__FILE__,__LINE__,numcomps);
return;
}
row = (int*)image->icc_profile_buf;
enumcs = row[0];
if (enumcs == 14) /* CIELab */
if(enumcs == 14) /* CIELab */
{
int *L, *a, *b, *red, *green, *blue;
int *src0, *src1, *src2, *dst0, *dst1, *dst2;
@ -656,14 +655,14 @@ void color_cielab_to_rgb(opj_image_t *image)
in = cmsCreateLab4Profile(NULL);
out = cmsCreate_sRGBProfile();
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
#ifdef OPJ_HAVE_LIBLCMS2
cmsCloseProfile(in);
cmsCloseProfile(out);
#endif
if (transform == NULL)
if(transform == NULL)
{
#ifdef OPJ_HAVE_LIBLCMS1
cmsCloseProfile(in);
@ -674,26 +673,26 @@ void color_cielab_to_rgb(opj_image_t *image)
prec0 = (double)image->comps[0].prec;
prec1 = (double)image->comps[1].prec;
prec2 = (double)image->comps[2].prec;
default_type = (unsigned int)row[1];
if (default_type == 0x44454600)/* DEF : default */
if(default_type == 0x44454600)/* DEF : default */
{
rl = 100; ra = 170; rb = 200;
ol = 0;
oa = pow(2, prec1 - 1);
ob = pow(2, prec2 - 2) + pow(2, prec2 - 3);
ob = pow(2, prec2 - 2) + pow(2, prec2 - 3);
}
else
{
rl = row[2]; ra = row[4]; rb = row[6];
ol = row[3]; oa = row[5]; ob = row[7];
}
L = src0 = image->comps[0].data;
a = src1 = image->comps[1].data;
b = src2 = image->comps[2].data;
max = image->comps[0].w * image->comps[0].h;
red = dst0 = new_image->comps[0].data;
@ -709,21 +708,21 @@ void color_cielab_to_rgb(opj_image_t *image)
minL = -(rl * ol) / (pow(2, prec0) - 1);
maxL = minL + rl;
mina = -(ra * oa) / (pow(2, prec1) - 1);
mina = -(ra * oa)/(pow(2, prec1)-1);
maxa = mina + ra;
minb = -(rb * ob) / (pow(2, prec2) - 1);
minb = -(rb * ob)/(pow(2, prec2)-1);
maxb = minb + rb;
for (i = 0; i < max; ++i)
for(i = 0; i < max; ++i)
{
Lab.L = minL + (double)(*L) * (maxL - minL) / (pow(2, prec0) - 1); ++L;
Lab.a = mina + (double)(*a) * (maxa - mina) / (pow(2, prec1) - 1); ++a;
Lab.b = minb + (double)(*b) * (maxb - minb) / (pow(2, prec2) - 1); ++b;
Lab.L = minL + (double)(*L) * (maxL - minL)/(pow(2, prec0)-1); ++L;
Lab.a = mina + (double)(*a) * (maxa - mina)/(pow(2, prec1)-1); ++a;
Lab.b = minb + (double)(*b) * (maxb - minb)/(pow(2, prec2)-1); ++b;
cmsDoTransform(transform, &Lab, RGB, 1);
*red++ = RGB[0];
*green++ = RGB[1];
*blue++ = RGB[2];
@ -742,11 +741,11 @@ void color_cielab_to_rgb(opj_image_t *image)
image->comps[0].prec = 16;
image->comps[1].prec = 16;
image->comps[2].prec = 16;
return;
}
fprintf(stderr, "%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__, __LINE__, enumcs);
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs);
}/* color_apply_conversion() */
#endif /* OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 */
@ -760,23 +759,23 @@ 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) return;
max = w * h;
sC = 1.0F / (float)((1 << image->comps[0].prec) - 1);
sM = 1.0F / (float)((1 << image->comps[1].prec) - 1);
sY = 1.0F / (float)((1 << image->comps[2].prec) - 1);
sK = 1.0F / (float)((1 << image->comps[3].prec) - 1);
for (i = 0; i < max; ++i)
for(i = 0; i < max; ++i)
{
/* CMYK values from 0 to 1 */
C = (float)(image->comps[0].data[i]) * sC;
M = (float)(image->comps[1].data[i]) * sM;
Y = (float)(image->comps[2].data[i]) * sY;
K = (float)(image->comps[3].data[i]) * sK;
/* Invert all CMYK values */
C = 1.0F - C;
M = 1.0F - M;
@ -795,9 +794,9 @@ void color_cmyk_to_rgb(opj_image_t *image)
image->comps[2].prec = 8;
image->numcomps -= 1;
image->color_space = OPJ_CLRSPC_SRGB;
for (i = 3; i < image->numcomps; ++i) {
memcpy(&(image->comps[i]), &(image->comps[i + 1]), sizeof(image->comps[i]));
memcpy(&(image->comps[i]), &(image->comps[i+1]), sizeof(image->comps[i]));
}
}/* color_cmyk_to_rgb() */
@ -809,46 +808,46 @@ void color_esycc_to_rgb(opj_image_t *image)
{
int y, cb, cr, sign1, sign2, val;
unsigned int w, h, max, i;
int flip_value = (1 << (image->comps[0].prec - 1));
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) return;
w = image->comps[0].w;
h = image->comps[0].h;
sign1 = (int)image->comps[1].sgnd;
sign2 = (int)image->comps[2].sgnd;
max = w * h;
for (i = 0; i < max; ++i)
for(i = 0; i < max; ++i)
{
y = image->comps[0].data[i]; cb = image->comps[1].data[i]; cr = image->comps[2].data[i];
if (!sign1) cb -= flip_value;
if (!sign2) cr -= flip_value;
if( !sign1) cb -= flip_value;
if( !sign2) cr -= flip_value;
val = (int)
((float)y - (float)0.0000368 * (float)cb
+ (float)1.40199 * (float)cr + (float)0.5);
if (val > max_value) val = max_value; else if (val < 0) val = 0;
((float)y - (float)0.0000368 * (float)cb
+ (float)1.40199 * (float)cr + (float)0.5);
if(val > max_value) val = max_value; else if(val < 0) val = 0;
image->comps[0].data[i] = val;
val = (int)
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
- (float)0.7141128 * (float)cr + (float)0.5);
if (val > max_value) val = max_value; else if (val < 0) val = 0;
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
- (float)0.7141128 * (float)cr + (float)0.5);
if(val > max_value) val = max_value; else if(val < 0) val = 0;
image->comps[1].data[i] = val;
val = (int)
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
- (float)0.000008 *(float)cr + (float)0.5);
if (val > max_value) val = max_value; else if (val < 0) val = 0;
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
- (float)0.000008 *(float)cr + (float)0.5);
if(val > max_value) val = max_value; else if(val < 0) val = 0;
image->comps[2].data[i] = val;
}
image->color_space = OPJ_CLRSPC_SRGB;

View File

@ -162,7 +162,7 @@ typedef struct opj_decompress_params
int get_num_images(char *imgdirpath);
int load_images(dircnt_t *dirptr, char *imgdirpath);
int get_file_format(const char *filename);
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters, char* infilename, char* outfilename);
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, int* decod_format, char* infilename, char* outfilename);
static int infile_format(const char *fname);
int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol);
@ -427,19 +427,16 @@ const char* path_separator = "/";
#endif
/* -------------------------------------------------------------------------- */
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters, char* infilename, char* outfilename){
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, int* decod_format, char* infilename, char* outfilename){
char image_filename[OPJ_PATH_LEN], temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
strcpy(image_filename,dirptr->filename[imageno]);
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
sprintf(infilename, "%s%s%s", img_fol->imgdirpath, path_separator, image_filename);
parameters->decod_format = infile_format(infilename);
if (parameters->decod_format == -1)
*decod_format = infile_format(infilename);
if (*decod_format == -1)
return 1;
if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infilename) != 0) {
return 1;
}
/*Set output file*/
strcpy(temp_ofname,strtok(image_filename,"."));
@ -449,9 +446,6 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompre
}
if(img_fol->set_out_format==1){
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfilename) != 0) {
return 1;
}
}
return 0;
}
@ -1263,15 +1257,13 @@ int main(int argc, char **argv)
opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
opj_codestream_index_t* cstr_index = NULL;
char infile[OPJ_PATH_LEN], outfile[OPJ_PATH_LEN];
int decod_format = -1;
fprintf(stderr, "\n");
if (img_fol.set_imgdir == 1) {
if (get_next_file(imageno, dirptr, &img_fol, &parameters, infile, outfile)) {
if (get_next_file(imageno, dirptr, &img_fol, &decod_format, infile, outfile)) {
fprintf(stderr, "skipping file...\n");
destroy_parameters(&parameters);
continue;
goto cleanup;
}
}
else {
@ -1281,46 +1273,22 @@ int main(int argc, char **argv)
/* read the input file and put it in memory */
/* ---------------------------------------- */
/*
OPJ_BOOL debug_buffers = OPJ_FALSE;
if (debug_buffers) {
FILE* p_file = NULL;
OPJ_SIZE_T sz = 0;
OPJ_BYTE* buffer = NULL;
p_file = fopen(parameters.infile, "rb");
if (p_file) {
fseek(p_file, 0L, SEEK_END);
sz = ftell(p_file);
fseek(p_file, 0L, SEEK_SET);
buffer = (OPJ_BYTE*)malloc(sz);
if (buffer) {
OPJ_SIZE_T res = fread(buffer, 1, sz, p_file);
if (res) {
fclose(p_file);
l_stream = opj_stream_create_buffer_stream(buffer, sz, 1);
}
}
if (!l_stream) {
l_stream = opj_stream_create_mapped_file_read_stream(infile);
}
}
*/
if (!l_stream) {
l_stream = opj_stream_create_mapped_file_read_stream(parameters.infile);
}
if (!l_stream) {
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", infile);
destroy_parameters(&parameters);
failed = 1;
continue;
goto cleanup;
}
/* decode the JPEG2000 stream */
/* ---------------------- */
switch (parameters.decod_format) {
switch (decod_format) {
case J2K_CFMT: /* JPEG-2000 codestream */
{
/* Get a decoder handle */
@ -1341,10 +1309,7 @@ int main(int argc, char **argv)
}
default:
fprintf(stderr, "skipping file..\n");
destroy_parameters(&parameters);
opj_stream_destroy(l_stream);
l_stream = NULL;
continue;
goto cleanup;
}
/* catch events using our callbacks and give a local context */
@ -1355,23 +1320,16 @@ 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(&parameters);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
failed = 1;
continue;
goto cleanup;
}
/* 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(&parameters);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
if (!parameters.nb_tile_to_decode) {
@ -1379,23 +1337,15 @@ 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(&parameters);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
/* 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(&parameters);
opj_destroy_codec(l_codec);
opj_stream_destroy(l_stream);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
}
else {
@ -1411,12 +1361,8 @@ int main(int argc, char **argv)
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(&parameters);
opj_destroy_codec(l_codec);
opj_stream_destroy(l_stream);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
}
@ -1428,7 +1374,9 @@ int main(int argc, char **argv)
/* Close the byte stream */
opj_stream_destroy(l_stream);
l_stream = NULL;
opj_destroy_codec(l_codec);
l_codec = NULL;
@ -1500,10 +1448,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(&parameters);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
}
@ -1512,25 +1458,21 @@ int main(int argc, char **argv)
if (parameters.force_rgb)
{
switch (image->color_space) {
case OPJ_CLRSPC_SRGB:
break;
case OPJ_CLRSPC_GRAY:
image = convert_gray_to_rgb(image);
break;
default:
fprintf(stderr, "ERROR -> opj_decompress: don't know how to convert image to RGB colorspace!\n");
opj_image_destroy(image);
image = NULL;
failed = 1;
continue;
break;
case OPJ_CLRSPC_SRGB:
break;
case OPJ_CLRSPC_GRAY:
image = convert_gray_to_rgb(image);
break;
default:
fprintf(stderr, "ERROR -> opj_decompress: don't know how to convert image to RGB colorspace!\n");
opj_image_destroy(image);
image = NULL;
failed = 1;
goto cleanup;
}
if (image == NULL) {
fprintf(stderr, "ERROR -> opj_decompress: failed to convert to RGB image!\n");
destroy_parameters(&parameters);
opj_image_destroy(image);
failed = 1;
continue;
goto cleanup;
}
}
@ -1541,9 +1483,7 @@ int main(int argc, char **argv)
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, outfile, parameters.split_pnm)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", outfile);
opj_image_destroy(image);
failed = 1;
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1553,9 +1493,7 @@ int main(int argc, char **argv)
case PGX_DFMT: /* PGX */
if (imagetopgx(image, outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", outfile);
opj_image_destroy(image);
failed = 1;
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1566,8 +1504,6 @@ int main(int argc, char **argv)
if (imagetobmp(image, outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1578,8 +1514,6 @@ int main(int argc, char **argv)
if (imagetotif(image, outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1590,8 +1524,6 @@ int main(int argc, char **argv)
if (imagetoraw(image, outfile)) {
fprintf(stderr, "[ERROR] Error generating raw file. Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1602,8 +1534,6 @@ int main(int argc, char **argv)
if (imagetorawl(image, outfile)) {
fprintf(stderr, "[ERROR] Error generating rawl file. Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1614,8 +1544,6 @@ int main(int argc, char **argv)
if (imagetotga(image, outfile)) {
fprintf(stderr, "[ERROR] Error generating tga file. Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1626,8 +1554,6 @@ int main(int argc, char **argv)
if (imagetopng(image, outfile)) {
fprintf(stderr, "[ERROR] Error generating png file. Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
}
else {
fprintf(stdout, "[INFO] Generated Outfile %s\n", outfile);
@ -1640,21 +1566,25 @@ int main(int argc, char **argv)
default:
fprintf(stderr, "[ERROR] Outfile %s not generated\n", outfile);
failed = 1;
opj_image_destroy(image);
continue;
break;
}
}
/* free remaining structures */
/* free image data structure */
opj_image_destroy(image);
cleanup:
if (l_stream)
opj_stream_destroy(l_stream);
if (l_codec)
opj_destroy_codec(l_codec);
if (image)
opj_image_destroy(image);
/* destroy the codestream index */
opj_destroy_cstr_index(&cstr_index);
if (failed)
(void)remove(parameters.outfile); /* ignore return value */
(void)remove(outfile); /* ignore return value */
}
#ifdef _OPENMP
@ -1663,10 +1593,11 @@ int main(int argc, char **argv)
t_cumulative = opj_clock() - t_cumulative;
destroy_parameters(&parameters);
if (num_decompressed_images) {
fprintf(stdout, "decode time: %d ms \n", (int)( (t_cumulative * 1000) / num_decompressed_images));
}
//getchar();
getchar();
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}
/*end main*/

View File

@ -51,7 +51,7 @@ set(OPENJPEG_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/segmented_stream.h
${CMAKE_CURRENT_SOURCE_DIR}/t1.c
${CMAKE_CURRENT_SOURCE_DIR}/t1.h
${CMAKE_CURRENT_SOURCE_DIR}/t1_opt.c
${CMAKE_CURRENT_SOURCE_DIR}/t1_opt.c
${CMAKE_CURRENT_SOURCE_DIR}/t1_opt.h
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
${CMAKE_CURRENT_SOURCE_DIR}/t2.h

View File

@ -64,8 +64,7 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptpa
comp->prec = cmptparms[compno].prec;
comp->bpp = cmptparms[compno].bpp;
comp->sgnd = cmptparms[compno].sgnd;
comp->data = (OPJ_INT32*) opj_aligned_malloc(comp->w * comp->h * sizeof(OPJ_INT32));
if(!comp->data) {
if(!opj_image_single_component_data_alloc(comp)) {
/* TODO replace with event manager, breaks API */
/* fprintf(stderr,"Unable to allocate memory for image.\n"); */
opj_image_destroy(image);

View File

@ -61,10 +61,7 @@ static void opj_j2k_transfer_image_data(opj_image_t* src, opj_image_t* dest) {
opj_image_comp_t* src_comp = src->comps + compno;
opj_image_comp_t* dest_comp = dest->comps + compno;
dest_comp->resno_decoded = src_comp->resno_decoded;
if (dest_comp->data) {
opj_aligned_free(dest_comp->data);
}
opj_image_single_component_data_free(dest_comp);
dest_comp->data = src_comp->data;
src_comp->data = NULL;
}
@ -8134,7 +8131,6 @@ OPJ_BOOL opj_j2k_decode_tile ( opj_j2k_t * p_j2k,
return OPJ_FALSE;
}
/* if p_data is not null, then copy decoded resolutions from tile data into p_data.
Otherwise, simply copy tile data pointer to output image
*/
@ -8253,9 +8249,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
/* Allocate output component buffer if necessary */
if (!l_img_comp_dest->data) {
l_img_comp_dest->data = (OPJ_INT32*) opj_aligned_malloc((OPJ_SIZE_T)l_img_comp_dest->w * (OPJ_SIZE_T)l_img_comp_dest->h * sizeof(OPJ_INT32));
if (! l_img_comp_dest->data) {
if (!opj_image_single_component_data_alloc(l_img_comp_dest)) {
return OPJ_FALSE;
}
}
@ -8265,7 +8259,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
/*-----*/
/* Compute the precision of the output buffer */
l_size_comp = (l_img_comp_src->prec + 7) >> 3;
l_size_comp = (l_img_comp_src->prec + 7) >> 3;
l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded;
if (l_size_comp == 3) {
@ -9735,12 +9729,14 @@ static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k)
}
static OPJ_BOOL opj_j2k_needs_copy_tile_data(opj_j2k_t *p_j2k) {
return OPJ_TRUE;
#if 0
/* single tile, RGB images only*/
OPJ_BOOL copy_tile_data = (p_j2k->m_cp.th * p_j2k->m_cp.tw > 1) ||
p_j2k->m_output_image->numcomps != 3 ||
p_j2k->m_output_image->numcomps != 3 ||
p_j2k->m_tcd->tcd_image->tiles->numcomps != 3;
OPJ_UINT32 i = 0;
@ -9785,6 +9781,7 @@ static OPJ_BOOL opj_j2k_needs_copy_tile_data(opj_j2k_t *p_j2k) {
}
}
return copy_tile_data;
#endif
}
static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k,

View File

@ -979,21 +979,22 @@ static void opj_jp2_apply_pclr(opj_image_t *image, opj_jp2_color_t *color)
return;
}
for(i = 0; i < nr_channels; ++i) {
pcol = cmap[i].pcol; cmp = cmap[i].cmp;
pcol = cmap[i].pcol;
cmp = cmap[i].cmp;
/* Direct use */
if(cmap[i].mtyp == 0){
assert( pcol == 0 );
new_comps[i] = old_comps[cmp];
} else {
assert( i == pcol );
new_comps[pcol] = old_comps[cmp];
}
if(cmap[i].mtyp == 0){
assert( pcol == 0 );
new_comps[i] = old_comps[cmp];
new_comps[i].data = NULL;
} else {
assert( i == pcol );
new_comps[pcol] = old_comps[cmp];
new_comps[pcol].data = NULL;
}
/* Palette mapping: */
new_comps[i].data = (OPJ_INT32*)
opj_aligned_malloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(OPJ_INT32));
if (!new_comps[i].data) {
if (!opj_image_single_component_data_alloc(new_comps + i)) {
opj_free(new_comps);
new_comps = NULL;
/* FIXME no error code for opj_jp2_apply_pclr */

View File

@ -1368,12 +1368,25 @@ void OPJ_CALLCONV opj_image_all_components_data_free(opj_image_t* image) {
}
OPJ_BOOL OPJ_CALLCONV opj_image_single_component_data_alloc(opj_image_comp_t* comp) {
OPJ_INT32* data = NULL;
if (!comp)
return OPJ_FALSE;
data = (OPJ_INT32*)opj_malloc(comp->w * comp->h * sizeof(OPJ_UINT32));
if (!data)
return OPJ_FALSE;
opj_image_single_component_data_free(comp);
comp->data = data;
return OPJ_TRUE;
}
void OPJ_CALLCONV opj_image_single_component_data_free(opj_image_comp_t* comp) {
if (!comp)
return;
if (comp->data) {
opj_aligned_free(comp->data);
/*opj_aligned_free(comp->data);*/
opj_free(comp->data);
comp->data = NULL;
}
}

View File

@ -568,7 +568,6 @@ typedef struct opj_dparameters {
} opj_dparameters_t;
/**
* JPEG2000 codec V2.
* */
@ -1582,6 +1581,8 @@ OPJ_API void OPJ_CALLCONV opj_image_all_components_data_free(opj_image_t* image)
OPJ_API void OPJ_CALLCONV opj_image_single_component_data_free(opj_image_comp_t* image);
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_image_single_component_data_alloc(opj_image_comp_t* image);
#ifdef __cplusplus
}
#endif

View File

@ -201,7 +201,6 @@ static INLINE long opj_lrintf(float f) {
#include "mct.h"
#include "opj_intmath.h"
#ifdef USE_JPIP
#include "cidx_manager.h"
#include "indexbox_manager.h"

View File

@ -4,7 +4,8 @@
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2015, Aaron Boxer
* Copyright (c) 2002-2016, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2016, OpenJPEG contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -4,7 +4,8 @@
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2015, Aaron Boxer
* Copyright (c) 2002-2016, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2016, OpenJPEG contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -4,7 +4,8 @@
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2015, Aaron Boxer
* Copyright (c) 2002-2016, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2016, OpenJPEG contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -4,7 +4,8 @@
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2015, Aaron Boxer
* Copyright (c) 2002-2016, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2016, OpenJPEG contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without