Compare commits

...

5 Commits

Author SHA1 Message Date
Antonin Descampe
0febbff19e processed all c/h files through astyle with opj_astyle.cfg 2016-01-25 23:22:06 +01:00
Antonin Descampe
bede1568b1 Merge branch 'master' into codingstyle 2016-01-25 22:43:03 +01:00
Antonin Descampe
6ec68a27f8 modified astyle config 2016-01-25 15:03:21 +01:00
Antonin Descampe
4b927ecea3 modified style cfg 2016-01-24 19:00:31 +01:00
Antonin Descampe
0efb2f5293 adding astyle and uncrustify config files 2016-01-24 18:54:13 +01:00
261 changed files with 71174 additions and 71149 deletions

View File

@ -76,15 +76,22 @@ static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
{
int r, g, b;
cb -= offset; cr -= offset;
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)
@ -95,9 +102,11 @@ static void sycc444_to_rgb(opj_image_t *img)
int offset, upb;
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;
@ -108,14 +117,21 @@ static void sycc444_to_rgb(opj_image_t *img)
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
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;
++y;
++cb;
++cr;
++r;
++g;
++b;
}
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;
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;
}/* sycc444_to_rgb() */
@ -128,9 +144,11 @@ static void sycc422_to_rgb(opj_image_t *img)
unsigned int i, j;
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;
@ -141,30 +159,48 @@ static void sycc422_to_rgb(opj_image_t *img)
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
for(i=0U; i < maxh; ++i)
{
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
{
for(i=0U; i < maxh; ++i) {
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;
++y;
++r;
++g;
++b;
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b; ++cb; ++cr;
++y;
++r;
++g;
++b;
++cb;
++cr;
}
if (j < maxw) {
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b; ++cb; ++cr;
++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;
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;
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;
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;
@ -182,9 +218,11 @@ static void sycc420_to_rgb(opj_image_t *img)
unsigned int i, j;
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;
@ -195,61 +233,97 @@ static void sycc420_to_rgb(opj_image_t *img)
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
{
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U) {
ny = y + maxw;
nr = r + maxw; ng = g + maxw; nb = b + 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;
++y;
++r;
++g;
++b;
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b;
++y;
++r;
++g;
++b;
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
++ny; ++nr; ++ng; ++nb;
++ny;
++nr;
++ng;
++nb;
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
++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;
++y;
++r;
++g;
++b;
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
++ny;
++nr;
++ng;
++nb;
++cb;
++cr;
}
y += maxw; r += maxw; g += maxw; b += maxw;
y += maxw;
r += maxw;
g += maxw;
b += maxw;
}
if(i < maxh)
{
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
{
if(i < maxh) {
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;
++y;
++r;
++g;
++b;
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y; ++r; ++g; ++b; ++cb; ++cr;
++y;
++r;
++g;
++b;
++cb;
++cr;
}
if(j < maxw)
{
if(j < maxw) {
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
}
}
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;
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;
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;
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;
@ -260,8 +334,7 @@ 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;
}
@ -271,32 +344,23 @@ void color_sycc_to_rgb(opj_image_t *img)
&& (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 */
{
&& (img->comps[2].dy == 2)) { /* horizontal and vertical sub-sample */
sycc420_to_rgb(img);
}
else
if((img->comps[0].dx == 1)
} 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 */
{
&& (img->comps[2].dy == 1)) { /* horizontal sub-sample only */
sycc422_to_rgb(img);
}
else
if((img->comps[0].dx == 1)
} 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 */
{
&& (img->comps[2].dy == 1)) { /* no sub-sample */
sycc444_to_rgb(img);
}
else
{
} else {
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
return;
}
@ -353,39 +417,27 @@ void color_apply_icc_profile(opj_image_t *image)
prec = (int)image->comps[0].prec;
oldspace = image->color_space;
if(out_space == cmsSigRgbData) /* enumCS 16 */
{
if( prec <= 8 )
{
if(out_space == cmsSigRgbData) { /* enumCS 16 */
if( prec <= 8 ) {
in_type = TYPE_RGB_8;
out_type = TYPE_RGB_8;
}
else
{
} 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 */
{
} 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 */
{
} 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
{
} 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",
@ -429,8 +481,7 @@ fprintf(stderr,"\trender_intent (%u)\n\t"
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__);
@ -443,10 +494,8 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
return;
}
if(image->numcomps > 2)/* RGB, RGBA */
{
if( prec <= 8 )
{
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);
@ -457,8 +506,7 @@ 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 = 0; i < max; ++i) {
*in++ = (unsigned char)*r++;
*in++ = (unsigned char)*g++;
*in++ = (unsigned char)*b++;
@ -470,16 +518,14 @@ 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 = 0; i < max; ++i) {
*r++ = (int)*out++;
*g++ = (int)*out++;
*b++ = (int)*out++;
}
free(inbuf); free(outbuf);
}
else
{
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);
@ -490,8 +536,7 @@ 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 = 0; i < max; ++i) {
*in++ = (unsigned short)*r++;
*in++ = (unsigned short)*g++;
*in++ = (unsigned short)*b++;
@ -503,17 +548,15 @@ 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 = 0; i < max; ++i) {
*r++ = (int)*out++;
*g++ = (int)*out++;
*b++ = (int)*out++;
}
free(inbuf); free(outbuf);
free(inbuf);
free(outbuf);
}
}
else /* GRAY, GRAYA */
{
} else { /* GRAY, GRAYA */
unsigned char *in, *inbuf, *out, *outbuf;
max = max_w * max_h;
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
@ -536,8 +579,7 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
r = image->comps[0].data;
for(i = 0; i < max; ++i)
{
for(i = 0; i < max; ++i) {
*in++ = (unsigned char)*r++;
}
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
@ -546,11 +588,13 @@ 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)
{
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
for(i = 0; i < max; ++i) {
*r++ = (int)*out++;
*g++ = (int)*out++;
*b++ = (int)*out++;
}
free(inbuf); free(outbuf);
free(inbuf);
free(outbuf);
}/* if(image->numcomps */
@ -571,8 +615,7 @@ void color_cielab_to_rgb(opj_image_t *image)
numcomps = (int)image->numcomps;
if(numcomps != 3)
{
if(numcomps != 3) {
fprintf(stderr,"%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
__FILE__,__LINE__,numcomps);
return;
@ -581,8 +624,7 @@ void color_cielab_to_rgb(opj_image_t *image)
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;
double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2;
@ -603,8 +645,7 @@ void color_cielab_to_rgb(opj_image_t *image)
cmsCloseProfile(in);
cmsCloseProfile(out);
#endif
if(transform == NULL)
{
if(transform == NULL) {
#ifdef OPJ_HAVE_LIBLCMS1
cmsCloseProfile(in);
cmsCloseProfile(out);
@ -617,17 +658,20 @@ void color_cielab_to_rgb(opj_image_t *image)
default_type = (unsigned int)row[1];
if(default_type == 0x44454600)/* DEF : default */
{
rl = 100; ra = 170; rb = 200;
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);
}
else
{
rl = row[2]; ra = row[4]; rb = row[6];
ol = row[3]; oa = row[5]; ob = row[7];
} 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;
@ -649,11 +693,13 @@ void color_cielab_to_rgb(opj_image_t *image)
minb = -(rb * ob)/(pow(2, prec2)-1);
maxb = minb + rb;
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;
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;
cmsDoTransform(transform, &Lab, RGB, 1);
@ -666,9 +712,12 @@ void color_cielab_to_rgb(opj_image_t *image)
cmsCloseProfile(in);
cmsCloseProfile(out);
#endif
free(src0); image->comps[0].data = dst0;
free(src1); image->comps[1].data = dst1;
free(src2); image->comps[2].data = dst2;
free(src0);
image->comps[0].data = dst0;
free(src1);
image->comps[1].data = dst1;
free(src2);
image->comps[2].data = dst2;
image->color_space = OPJ_CLRSPC_SRGB;
image->comps[0].prec = 16;
@ -701,8 +750,7 @@ void color_cmyk_to_rgb(opj_image_t *image)
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;
@ -721,7 +769,8 @@ void color_cmyk_to_rgb(opj_image_t *image)
image->comps[2].data[i] = (int)(255.0F * Y * K); /* B */
}
free(image->comps[3].data); image->comps[3].data = NULL;
free(image->comps[3].data);
image->comps[3].data = NULL;
image->comps[0].prec = 8;
image->comps[1].prec = 8;
image->comps[2].prec = 8;
@ -754,10 +803,11 @@ void color_esycc_to_rgb(opj_image_t *image)
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];
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;
@ -766,21 +816,24 @@ void color_esycc_to_rgb(opj_image_t *image)
((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;
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;
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;
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

@ -54,7 +54,8 @@ int opj_opterr = 1, /* if error message should be printed */
static char EMSG[]= {""};
/* As this class remembers its values from one Java call to the other, reset the values before each use */
void opj_reset_options_reading(void) {
void opj_reset_options_reading(void)
{
opj_opterr = 1;
opj_optind = 1;
}
@ -63,7 +64,8 @@ void opj_reset_options_reading(void) {
* getopt --
* Parse argc/argv argument vector.
*/
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
int opj_getopt(int nargc, char *const *nargv, const char *ostr)
{
# define __progname nargv[0]
static char *place = EMSG; /* option letter processing */
const char *oli = NULL; /* option letter list index */
@ -123,7 +125,8 @@ int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
const opj_option_t *longopts, int totlen) {
const opj_option_t *longopts, int totlen)
{
static int lastidx,lastofs;
const char *tmp;
int i,len;
@ -136,12 +139,10 @@ again:
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
if(opj_optind >= (argc - 1)) { /* no more input parameters */
param = 0;
}
else{ /* more input parameters */
} else { /* more input parameters */
if(argv[opj_optind + 1][0] == '-') {
param = 0; /* Missing parameter after '-' */
}
else{
} else {
param = 2;
}
}
@ -161,8 +162,7 @@ again:
if (param > 1) {
arg = argv[opj_optind+1];
opj_optind++;
}
else
} else
arg = argv[opj_optind]+1;
if(strlen(arg)>1) {
@ -205,7 +205,8 @@ again:
} else { /*Single character input parameter*/
if (*optstring==':') return ':';
if (lastidx!=opj_optind) {
lastidx=opj_optind; lastofs=0;
lastidx=opj_optind;
lastofs=0;
}
opj_optopt=argv[opj_optind][lastofs+1];
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/

View File

@ -3,8 +3,7 @@
#ifndef _GETOPT_H_
#define _GETOPT_H_
typedef struct opj_option
{
typedef struct opj_option {
const char *name;
int has_arg;
int *flag;

File diff suppressed because it is too large Load Diff

View File

@ -91,8 +91,7 @@ static void opj_applyLUT8u_8u32s_C1R(
for (y = height; y != 0U; --y) {
OPJ_UINT32 x;
for(x = 0; x < width; x++)
{
for(x = 0; x < width; x++) {
pDst[x] = (OPJ_INT32)pLUT[pSrc[x]];
}
pSrc += srcStride;
@ -117,8 +116,7 @@ static void opj_applyLUT8u_8u32s_C1P3R(
for (y = height; y != 0U; --y) {
OPJ_UINT32 x;
for(x = 0; x < width; x++)
{
for(x = 0; x < width; x++) {
OPJ_UINT8 idx = pSrc[x];
pR[x] = (OPJ_INT32)pLUT_R[idx];
pG[x] = (OPJ_INT32)pLUT_G[idx];
@ -143,10 +141,8 @@ static void bmp24toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t*
index = 0;
pSrc = pData + (height - 1U) * stride;
for(y = 0; y < height; y++)
{
for(x = 0; x < width; x++)
{
for(y = 0; y < height; y++) {
for(x = 0; x < width; x++) {
image->comps[0].data[index] = (OPJ_INT32)pSrc[3*x+2]; /* R */
image->comps[1].data[index] = (OPJ_INT32)pSrc[3*x+1]; /* G */
image->comps[2].data[index] = (OPJ_INT32)pSrc[3*x+0]; /* B */
@ -172,7 +168,8 @@ static void bmp_mask_get_shift_and_prec(OPJ_UINT32 mask, OPJ_UINT32* shift, OPJ_
l_prec++;
}
}
*shift = l_shift; *prec = l_prec;
*shift = l_shift;
*prec = l_prec;
}
static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT32 redMask, OPJ_UINT32 greenMask, OPJ_UINT32 blueMask, OPJ_UINT32 alphaMask)
@ -210,10 +207,8 @@ static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
index = 0;
pSrc = pData + (height - 1U) * stride;
for(y = 0; y < height; y++)
{
for(x = 0; x < width; x++)
{
for(y = 0; y < height; y++) {
for(x = 0; x < width; x++) {
OPJ_UINT32 value = 0U;
value |= ((OPJ_UINT32)pSrc[4*x+0]) << 0;
@ -268,10 +263,8 @@ static void bmpmask16toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
index = 0;
pSrc = pData + (height - 1U) * stride;
for(y = 0; y < height; y++)
{
for(x = 0; x < width; x++)
{
for(y = 0; y < height; y++) {
for(x = 0; x < width; x++) {
OPJ_UINT32 value = 0U;
value |= ((OPJ_UINT32)pSrc[2*x+0]) << 0;
@ -300,13 +293,16 @@ static opj_image_t* bmp8toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_i
pSrc = pData + (height - 1U) * stride;
if (image->numcomps == 1U) {
opj_applyLUT8u_8u32s_C1R(pSrc, -(OPJ_INT32)stride, image->comps[0].data, (OPJ_INT32)width, pLUT[0], width, height);
}
else {
} else {
OPJ_INT32* pDst[3];
OPJ_INT32 pDstStride[3];
pDst[0] = image->comps[0].data; pDst[1] = image->comps[1].data; pDst[2] = image->comps[2].data;
pDstStride[0] = (OPJ_INT32)width; pDstStride[1] = (OPJ_INT32)width; pDstStride[2] = (OPJ_INT32)width;
pDst[0] = image->comps[0].data;
pDst[1] = image->comps[1].data;
pDst[2] = image->comps[2].data;
pDstStride[0] = (OPJ_INT32)width;
pDstStride[1] = (OPJ_INT32)width;
pDstStride[2] = (OPJ_INT32)width;
opj_applyLUT8u_8u32s_C1P3R(pSrc, -(OPJ_INT32)stride, pDst, pDstStride, pLUT, width, height);
}
return image;
@ -489,8 +485,7 @@ static OPJ_BOOL bmp_read_raw_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride,
{
OPJ_ARG_NOT_USED(width);
if ( fread(pData, sizeof(OPJ_UINT8), stride * height, IN) != (stride * height) )
{
if ( fread(pData, sizeof(OPJ_UINT8), stride * height, IN) != (stride * height) ) {
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
return OPJ_FALSE;
}
@ -507,8 +502,7 @@ static OPJ_BOOL bmp_read_rle8_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
pix = pData;
x = y = 0U;
while (y < height)
{
while (y < height) {
int c = getc(IN);
if (c) {
@ -518,29 +512,23 @@ static OPJ_BOOL bmp_read_rle8_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
*pix = c1;
}
}
else {
} else {
c = getc(IN);
if (c == 0x00) { /* EOL */
x = 0;
++y;
pix = pData + y * stride + x;
}
else if (c == 0x01) { /* EOP */
} else if (c == 0x01) { /* EOP */
break;
}
else if (c == 0x02) { /* MOVE by dxdy */
} else if (c == 0x02) { /* MOVE by dxdy */
c = getc(IN);
x += (OPJ_UINT32)c;
c = getc(IN);
y += (OPJ_UINT32)c;
pix = pData + y * stride + x;
}
else /* 03 .. 255 */
{
} else { /* 03 .. 255 */
int j;
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++)
{
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
*pix = c1;
}
@ -562,8 +550,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
beyond = pData + stride * height;
pix = pData;
x = y = 0U;
while(y < height)
{
while(y < height) {
int c = getc(IN);
if(c == EOF) break;
@ -574,23 +561,23 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
*pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
}
}
else { /* absolute mode */
} else { /* absolute mode */
c = getc(IN);
if(c == EOF) break;
if(c == 0x00) { /* EOL */
x = 0; y++; pix = pData + y * stride;
}
else if(c == 0x01) { /* EOP */
x = 0;
y++;
pix = pData + y * stride;
} else if(c == 0x01) { /* EOP */
break;
}
else if(c == 0x02) { /* MOVE by dxdy */
c = getc(IN); x += (OPJ_UINT32)c;
c = getc(IN); y += (OPJ_UINT32)c;
} else if(c == 0x02) { /* MOVE by dxdy */
c = getc(IN);
x += (OPJ_UINT32)c;
c = getc(IN);
y += (OPJ_UINT32)c;
pix = pData + y * stride + x;
}
else { /* 03 .. 255 : absolute mode */
} else { /* 03 .. 255 : absolute mode */
int j;
OPJ_UINT8 c1 = 0U;
@ -623,11 +610,12 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
OPJ_UINT8* pData = NULL;
OPJ_UINT32 stride;
pLUT[0] = lut_R; pLUT[1] = lut_G; pLUT[2] = lut_B;
pLUT[0] = lut_R;
pLUT[1] = lut_G;
pLUT[2] = lut_B;
IN = fopen(filename, "rb");
if (!IN)
{
if (!IN) {
fprintf(stderr, "Failed to open %s for reading !!\n", filename);
return NULL;
}
@ -642,8 +630,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
}
/* Load palette */
if (Info_h.biBitCount <= 8U)
{
if (Info_h.biBitCount <= 8U) {
memset(&lut_R[0], 0, sizeof(lut_R));
memset(&lut_G[0], 0, sizeof(lut_G));
memset(&lut_B[0], 0, sizeof(lut_B));
@ -715,8 +702,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
/* create the image */
memset(&cmptparm[0], 0, sizeof(cmptparm));
for(i = 0; i < 4U; i++)
{
for(i = 0; i < 4U; i++) {
cmptparm[i].prec = 8;
cmptparm[i].bpp = 8;
cmptparm[i].sgnd = 0;
@ -745,34 +731,26 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
/* Read the data */
if (Info_h.biBitCount == 24 && Info_h.biCompression == 0) { /*RGB */
bmp24toimage(pData, stride, image);
}
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
bmp8toimage(pData, stride, image, pLUT);
}
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
bmp8toimage(pData, stride, image, pLUT);
}
else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
} else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
bmp8toimage(pData, stride, image, pLUT); /* RLE 4 gets decoded as 8 bits data for now */
}
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
} else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
bmpmask32toimage(pData, stride, image, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, 0x00000000U);
}
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
} else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
bmpmask32toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
}
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
} else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
bmpmask16toimage(pData, stride, image, 0x7C00U, 0x03E0U, 0x001FU, 0x0000U);
}
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
} else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
if ((Info_h.biRedMask == 0U) && (Info_h.biGreenMask == 0U) && (Info_h.biBlueMask == 0U)) {
Info_h.biRedMask = 0xF800U;
Info_h.biGreenMask = 0x07E0U;
Info_h.biBlueMask = 0x001FU;
}
bmpmask16toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
}
else {
} else {
opj_image_destroy(image);
image = NULL;
fprintf(stderr, "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
@ -782,7 +760,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
return image;
}
int imagetobmp(opj_image_t * image, const char *outfile) {
int imagetobmp(opj_image_t * image, const char *outfile)
{
int w, h;
int i, pad;
FILE *fdest = NULL;
@ -850,20 +829,17 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
if (image->comps[0].prec > 8) {
adjustR = (int)image->comps[0].prec - 8;
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
}
else
} else
adjustR = 0;
if (image->comps[1].prec > 8) {
adjustG = (int)image->comps[1].prec - 8;
printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
}
else
} else
adjustG = 0;
if (image->comps[2].prec > 8) {
adjustB = (int)image->comps[2].prec - 8;
printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
}
else
} else
adjustB = 0;
for (i = 0; i < w * h; i++) {
@ -873,19 +849,22 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
if(r > 255) r = 255; else if(r < 0) r = 0;
if(r > 255) r = 255;
else if(r < 0) r = 0;
rc = (OPJ_UINT8)r;
g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
g = ((g >> adjustG)+((g >> (adjustG-1))%2));
if(g > 255) g = 255; else if(g < 0) g = 0;
if(g > 255) g = 255;
else if(g < 0) g = 0;
gc = (OPJ_UINT8)g;
b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
b = ((b >> adjustB)+((b >> (adjustB-1))%2));
if(b > 255) b = 255; else if(b < 0) b = 0;
if(b > 255) b = 255;
else if(b < 0) b = 0;
bc = (OPJ_UINT8)b;
fprintf(fdest, "%c%c%c", bc, gc, rc);
@ -962,7 +941,8 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
if(r > 255) r = 255; else if(r < 0) r = 0;
if(r > 255) r = 255;
else if(r < 0) r = 0;
fprintf(fdest, "%c", (OPJ_UINT8)r);

View File

@ -85,15 +85,13 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
convert_32s_CXPX cvtCxToPx = NULL;
OPJ_INT32* planes[4];
if((reader = fopen(read_idf, "rb")) == NULL)
{
if((reader = fopen(read_idf, "rb")) == NULL) {
fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
return NULL;
}
if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0)
{
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0) {
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
goto fin;
}
@ -192,8 +190,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
/* Create image */
memset(cmptparm, 0, sizeof(cmptparm));
for(i = 0; i < nr_comp; ++i)
{
for(i = 0; i < nr_comp; ++i) {
cmptparm[i].prec = (OPJ_UINT32)bit_depth;
/* bits_per_pixel: 8 or 16 */
cmptparm[i].bpp = (OPJ_UINT32)bit_depth;
@ -217,13 +214,11 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
/* Set alpha channel */
image->comps[nr_comp-1U].alpha = 1U - (nr_comp & 1U);
for(i = 0; i < nr_comp; i++)
{
for(i = 0; i < nr_comp; i++) {
planes[i] = image->comps[i].data;
}
for(i = 0; i < height; ++i)
{
for(i = 0; i < height; ++i) {
cvtXXTo32s(rows[i], row32s, (OPJ_SIZE_T)width * nr_comp);
cvtCxToPx(row32s, planes, width);
planes[0] += width;
@ -232,8 +227,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
planes[3] += width;
}
fin:
if(rows)
{
if(rows) {
for(i = 0; i < height; ++i)
free(rows[i]);
free(rows);
@ -306,15 +300,12 @@ int imagetopng(opj_image_t * image, const char *write_idf)
for (i = 0; i < nr_comp; ++i) {
clip_component(&(image->comps[i]), image->comps[0].prec);
}
if(prec > 8 && prec < 16)
{
if(prec > 8 && prec < 16) {
for (i = 0; i < nr_comp; ++i) {
scale_component(&(image->comps[i]), 16);
}
prec = 16;
}
else if(prec < 8 && nr_comp > 1)/* GRAY_ALPHA, RGB, RGB_ALPHA */
{
} else if(prec < 8 && nr_comp > 1) { /* GRAY_ALPHA, RGB, RGB_ALPHA */
for (i = 0; i < nr_comp; ++i) {
scale_component(&(image->comps[i]), 8);
}
@ -330,8 +321,7 @@ int imagetopng(opj_image_t * image, const char *write_idf)
}
}
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
{
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16) {
fprintf(stderr,"imagetopng: can not create %s\n\twrong bit_depth %d\n", write_idf, prec);
return fails;
}
@ -386,18 +376,14 @@ int imagetopng(opj_image_t * image, const char *write_idf)
*/
png_set_compression_level(png, Z_BEST_COMPRESSION);
if(nr_comp >= 3) /* RGB(A) */
{
if(nr_comp >= 3) { /* RGB(A) */
color_type = PNG_COLOR_TYPE_RGB;
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
}
else /* GRAY(A) */
{
} else { /* GRAY(A) */
color_type = PNG_COLOR_TYPE_GRAY;
sig_bit.gray = (png_byte)prec;
}
if((nr_comp & 1) == 0) /* ALPHA */
{
if((nr_comp & 1) == 0) { /* ALPHA */
color_type |= PNG_COLOR_MASK_ALPHA;
sig_bit.alpha = (png_byte)prec;
}
@ -458,8 +444,7 @@ int imagetopng(opj_image_t * image, const char *write_idf)
break;
}
for(y = 0; y < image->comps[0].h; ++y)
{
for(y = 0; y < image->comps[0].h; ++y) {
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (OPJ_SIZE_T)nr_comp);
png_write_row(png, row_buf_cpy);

View File

@ -193,8 +193,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
if (numcomps > 4U) {
numcomps = 4U; /* Alpha not supported */
}
}
else if (numcomps > 2U) {
} else if (numcomps > 2U) {
tiPhoto = PHOTOMETRIC_RGB;
if (numcomps > 4U) {
numcomps = 4U;
@ -224,15 +223,13 @@ int imagetotif(opj_image_t * image, const char *outfile)
}
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
if(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,"\tAborting\n");
return 1;
}
tif = TIFFOpen(outfile, "wb");
if (!tif)
{
if (!tif) {
fprintf(stderr, "imagetotif:failed to open %s for writing\n", outfile);
return 1;
}
@ -436,8 +433,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
tif = TIFFOpen(filename, "r");
if(!tif)
{
if(!tif) {
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
return 0;
}
@ -500,10 +496,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
&extrasamples, &sampleinfo);
if(extrasamples >= 1)
{
switch(sampleinfo[0])
{
if(extrasamples >= 1) {
switch(sampleinfo[0]) {
case EXTRASAMPLE_UNSPECIFIED:
/* Workaround for some images without correct info about alpha channel
*/
@ -516,8 +510,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
has_alpha = 1;
break;
}
}
else /* extrasamples == 0 */
} else /* extrasamples == 0 */
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
}
@ -534,13 +527,10 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
is_cinema = 0U;
}
if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
{
if(tiPhoto == PHOTOMETRIC_RGB) { /* RGB(A) */
numcomps = 3 + has_alpha;
color_space = OPJ_CLRSPC_SRGB;
}
else if (tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
{
} else if (tiPhoto == PHOTOMETRIC_MINISBLACK) { /* GRAY(A) */
numcomps = 1 + has_alpha;
color_space = OPJ_CLRSPC_GRAY;
}
@ -551,8 +541,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
tiSpp = 1U; /* consider only one sample per plane */
}
for(j = 0; j < numcomps; j++)
{
for(j = 0; j < numcomps; j++) {
cmptparm[j].prec = tiBps;
cmptparm[j].bpp = tiBps;
cmptparm[j].dx = (OPJ_UINT32)subsampling_dx;
@ -562,8 +551,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
}
image = opj_image_create((OPJ_UINT32)numcomps, &cmptparm[0], color_space);
if(!image)
{
if(!image) {
TIFFClose(tif);
return NULL;
}
@ -575,8 +563,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
image->y1 = !image->y0 ? (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1 :
image->y0 + (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1;
for(j = 0; j < numcomps; j++)
{
for(j = 0; j < numcomps; j++) {
planes[j] = image->comps[j].data;
}
image->comps[numcomps - 1].alpha = (OPJ_UINT16)(1 - (numcomps & 1));
@ -600,13 +587,11 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
strip = 0;
currentPlane = 0;
do
{
do {
planes[0] = image->comps[currentPlane].data; /* to manage planar data */
h= (int)tiHeight;
/* Read the Image components */
for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++)
{
for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++) {
const OPJ_UINT8 *dat8;
OPJ_SIZE_T ssize;

View File

@ -46,7 +46,8 @@ Write a structured index to a file
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
{
int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL;
double total_disto = 0;

View File

@ -89,7 +89,8 @@ typedef struct img_folder{
char set_out_format;
} img_fol_t;
static void encode_help_display(void) {
static void encode_help_display(void)
{
fprintf(stdout,"\nThis is the opj_compress utility from the OpenJPEG project.\n"
"It compresses various image formats with the JPEG 2000 algorithm.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
@ -353,7 +354,8 @@ static void encode_help_display(void) {
#endif /*FIXME_INDEX*/
}
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
static OPJ_PROG_ORDER give_progression(const char progression[4])
{
if(strncmp(progression, "LRCP", 4) == 0) {
return OPJ_LRCP;
}
@ -373,7 +375,8 @@ static OPJ_PROG_ORDER give_progression(const char progression[4]) {
return OPJ_PROG_UNKNOWN;
}
static unsigned int get_num_images(char *imgdirpath){
static unsigned int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
unsigned int num_images = 0;
@ -396,7 +399,8 @@ static unsigned int get_num_images(char *imgdirpath){
return num_images;
}
static int load_images(dircnt_t *dirptr, char *imgdirpath){
static int load_images(dircnt_t *dirptr, char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int i = 0;
@ -422,7 +426,8 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
return 0;
}
static int get_file_format(char *filename) {
static int get_file_format(char *filename)
{
unsigned int i;
static const char *extension[] = {
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "rawl", "tga", "png", "j2k", "jp2", "j2c", "jpc"
@ -442,12 +447,14 @@ static int get_file_format(char *filename) {
return -1;
}
static char * get_file_name(char *name){
static char * get_file_name(char *name)
{
char *fname = strtok(name,".");
return fname;
}
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
@ -479,7 +486,8 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c
/* ------------------------------------------------------------------------------------ */
static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename, size_t indexfilename_size) {
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename, size_t indexfilename_size)
{
OPJ_UINT32 i, j;
int totlen, c;
opj_option_t long_option[]= {
@ -512,8 +520,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
@ -541,8 +548,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -560,8 +566,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
break;
/* ----------------------------------------------------- */
case 'O': /* output format */
{
case 'O': { /* output format */
char outformat[50];
char *of = opj_optarg;
sprintf(outformat,".%s",of);
@ -583,8 +588,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'r': /* rates rates/distorsion */
{
case 'r': { /* rates rates/distorsion */
char *s = opj_optarg;
parameters->tcp_numlayers = 0;
while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
@ -603,8 +607,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'F': /* Raw image format parameters */
{
case 'F': { /* Raw image format parameters */
OPJ_BOOL wrong = OPJ_FALSE;
char *substr1;
char *substr2;
@ -691,8 +694,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'q': /* add fixed_quality */
{
case 'q': { /* add fixed_quality */
char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++;
@ -710,8 +712,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* dda */
/* ----------------------------------------------------- */
case 'f': /* mod fixed_quality (before : -q) */
{
case 'f': { /* mod fixed_quality (before : -q) */
int *row = NULL, *col = NULL;
OPJ_UINT32 numlayers = 0, numresolution = 0, matrix_width = 0;
@ -757,8 +758,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 't': /* tiles */
{
case 't': { /* tiles */
sscanf(opj_optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
parameters->tile_size_on = OPJ_TRUE;
}
@ -766,15 +766,13 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'n': /* resolution */
{
case 'n': { /* resolution */
sscanf(opj_optarg, "%d", &parameters->numresolution);
}
break;
/* ----------------------------------------------------- */
case 'c': /* precinct dimension */
{
case 'c': { /* precinct dimension */
char sep;
int res_spec = 0;
@ -784,8 +782,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
sep = 0;
ret = sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
&parameters->prch_init[res_spec], &sep);
if( !(ret == 2 && sep == 0) && !(ret == 3 && sep == ',') )
{
if( !(ret == 2 && sep == 0) && !(ret == 3 && sep == ',') ) {
fprintf(stderr,"\nError: could not parse precinct dimension: '%s' %x\n", s, sep);
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -c [128,128],[128,128]\n");
return 1;
@ -793,16 +790,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
}
while (sep == ',');
} while (sep == ',');
parameters->res_spec = res_spec;
}
break;
/* ----------------------------------------------------- */
case 'b': /* code-block dimension */
{
case 'b': { /* code-block dimension */
int cblockw_init = 0, cblockh_init = 0;
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
@ -819,8 +814,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'x': /* creation of index file */
{
case 'x': { /* creation of index file */
if (opj_strcpy_s(indexfilename, indexfilename_size, opj_optarg) != 0) {
return 1;
}
@ -834,8 +828,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'p': /* progression order */
{
case 'p': { /* progression order */
char progression[4];
strncpy(progression, opj_optarg, 4);
@ -850,8 +843,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 's': /* subsampling factor */
{
case 's': { /* subsampling factor */
if (sscanf(opj_optarg, "%d,%d", &parameters->subsampling_dx,
&parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
@ -862,8 +854,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'd': /* coordonnate of the reference grid */
{
case 'd': { /* coordonnate of the reference grid */
if (sscanf(opj_optarg, "%d,%d", &parameters->image_offset_x0,
&parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
@ -881,8 +872,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'P': /* POC */
{
case 'P': { /* POC */
int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
@ -909,24 +899,21 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'S': /* SOP marker */
{
case 'S': { /* SOP marker */
parameters->csty |= 0x02;
}
break;
/* ------------------------------------------------------ */
case 'E': /* EPH marker */
{
case 'E': { /* EPH marker */
parameters->csty |= 0x04;
}
break;
/* ------------------------------------------------------ */
case 'M': /* Mode switch pas tous au point !! */
{
case 'M': { /* Mode switch pas tous au point !! */
int value = 0;
if (sscanf(opj_optarg, "%d", &value) == 1) {
for (i = 0; i <= 5; i++) {
@ -940,8 +927,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'R': /* ROI */
{
case 'R': { /* ROI */
if (sscanf(opj_optarg, "c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
@ -952,8 +938,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'T': /* Tile offset */
{
case 'T': { /* Tile offset */
if (sscanf(opj_optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1;
@ -963,8 +948,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'C': /* add a comment */
{
case 'C': { /* add a comment */
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
if(parameters->cp_comment) {
strcpy(parameters->cp_comment, opj_optarg);
@ -975,16 +959,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'I': /* reversible or not */
{
case 'I': { /* reversible or not */
parameters->irreversible = 1;
}
break;
/* ------------------------------------------------------ */
case 'u': /* Tile part generation*/
{
case 'u': { /* Tile part generation*/
parameters->tp_flag = opj_optarg[0];
parameters->tp_on = 1;
}
@ -992,8 +974,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'z': /* Image Directory path */
{
case 'z': { /* Image Directory path */
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
@ -1002,8 +983,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'w': /* Digital Cinema 2K profile compliance*/
{
case 'w': { /* Digital Cinema 2K profile compliance*/
int fps=0;
sscanf(opj_optarg,"%d",&fps);
if(fps == 24) {
@ -1026,8 +1006,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'y': /* Digital Cinema 4K profile compliance*/
{
case 'y': { /* Digital Cinema 4K profile compliance*/
parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
fprintf(stdout,"CINEMA 4K profile activated\n"
"Other options specified could be overriden\n");
@ -1036,8 +1015,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'Y': /* Shall we do an MCT ? 0:no_mct;1:rgb->ycc;2:custom mct (-m option required)*/
{
case 'Y': { /* Shall we do an MCT ? 0:no_mct;1:rgb->ycc;2:custom mct (-m option required)*/
int mct_mode=0;
sscanf(opj_optarg,"%d",&mct_mode);
if(mct_mode < 0 || mct_mode > 2) {
@ -1051,8 +1029,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'm': /* mct input file */
{
case 'm': { /* mct input file */
char *lFilename = opj_optarg;
char *lMatrix;
char *lCurrentPtr ;
@ -1136,8 +1113,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
#ifdef USE_JPWL
/* ------------------------------------------------------ */
case 'W': /* JPWL capabilities switched on */
{
case 'W': { /* JPWL capabilities switched on */
char *token = NULL;
int hprot, pprot, sens, addr, size, range;
@ -1455,8 +1431,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* <<UniPG */
/* ------------------------------------------------------ */
case 'J': /* jpip on */
{
case 'J': { /* jpip on */
parameters->jpip_on = OPJ_TRUE;
}
break;
@ -1547,26 +1522,30 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/**
sample error debug callback expecting no client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[ERROR] %s", msg);
}
/**
sample warning debug callback expecting no client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
OPJ_FLOAT64 opj_clock(void) {
OPJ_FLOAT64 opj_clock(void)
{
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
@ -1596,7 +1575,8 @@ OPJ_FLOAT64 opj_clock(void) {
* OPJ_COMPRESS MAIN
*/
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
opj_cparameters_t parameters; /* compression parameters */
@ -1796,14 +1776,12 @@ int main(int argc, char **argv) {
/* ---------------------------- */
switch(parameters.cod_format) {
case J2K_CFMT: /* JPEG-2000 codestream */
{
case J2K_CFMT: { /* JPEG-2000 codestream */
/* Get a decoder handle */
l_codec = opj_create_compress(OPJ_CODEC_J2K);
break;
}
case JP2_CFMT: /* JPEG 2000 compressed image data */
{
case JP2_CFMT: { /* JPEG 2000 compressed image data */
/* Get a decoder handle */
l_codec = opj_create_compress(OPJ_CODEC_JP2);
break;
@ -1859,8 +1837,7 @@ int main(int argc, char **argv) {
}
}
free(l_data);
}
else {
} else {
bSuccess = bSuccess && opj_encode(l_codec, l_stream);
if (!bSuccess) {
fprintf(stderr, "failed to encode image: opj_encode\n");

View File

@ -97,20 +97,17 @@ typedef struct img_folder{
} img_fol_t;
typedef enum opj_prec_mode
{
typedef enum opj_prec_mode {
OPJ_PREC_MODE_CLIP,
OPJ_PREC_MODE_SCALE
} opj_precision_mode;
typedef struct opj_prec
{
typedef struct opj_prec {
OPJ_UINT32 prec;
opj_precision_mode mode;
} opj_precision;
typedef struct opj_decompress_params
{
typedef struct opj_decompress_params {
/** core library parameters */
opj_dparameters_t core;
@ -166,7 +163,8 @@ int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsi
static opj_image_t* convert_gray_to_rgb(opj_image_t* original);
/* -------------------------------------------------------------------------- */
static void decode_help_display(void) {
static void decode_help_display(void)
{
fprintf(stdout,"\nThis is the opj_decompress utility from the OpenJPEG project.\n"
"It decompresses JPEG 2000 codestreams to various image formats.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
@ -253,8 +251,7 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p
}
parameters->nb_precision = 0U;
for(;;)
{
for(;;) {
int prec;
char mode;
char comma;
@ -346,7 +343,8 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p
/* -------------------------------------------------------------------------- */
int get_num_images(char *imgdirpath){
int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int num_images = 0;
@ -369,7 +367,8 @@ int get_num_images(char *imgdirpath){
}
/* -------------------------------------------------------------------------- */
int load_images(dircnt_t *dirptr, char *imgdirpath){
int load_images(dircnt_t *dirptr, char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int i = 0;
@ -396,7 +395,8 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
}
/* -------------------------------------------------------------------------- */
int get_file_format(const char *filename) {
int get_file_format(const char *filename)
{
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "rawl", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, RAWL_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
@ -422,7 +422,8 @@ const char* path_separator = "/";
#endif
/* -------------------------------------------------------------------------- */
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters){
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
@ -486,12 +487,10 @@ static int infile_format(const char *fname)
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
magic_format = JP2_CFMT;
magic_s = ".jp2";
}
else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
magic_format = J2K_CFMT;
magic_s = ".j2k or .jpc or .j2c";
}
else
} else
return -1;
if (magic_format == ext_format)
@ -512,7 +511,8 @@ static int infile_format(const char *fname)
* Parse the command line
*/
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol) {
int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol)
{
/* parse the command line */
int totlen, c;
opj_option_t long_option[]= {
@ -545,8 +545,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
switch (c) {
case 0: /* long opt with flag */
break;
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = infile_format(infile);
switch(parameters->decod_format) {
@ -577,8 +576,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -611,8 +609,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'O': /* output format */
{
case 'O': { /* output format */
char outformat[50];
char *of = opj_optarg;
sprintf(outformat,".%s",of);
@ -654,8 +651,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
case 'r': { /* reduce option */
sscanf(opj_optarg, "%u", &(parameters->core.cp_reduce));
}
break;
@ -663,8 +659,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
case 'l': { /* layering option */
sscanf(opj_optarg, "%u", &(parameters->core.cp_layer));
}
break;
@ -677,8 +672,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'y': /* Image Directory path */
{
case 'y': { /* Image Directory path */
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
@ -687,8 +681,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'd': /* Input decode ROI */
{
case 'd': { /* Input decode ROI */
size_t size_optarg = (size_t)strlen(opj_optarg) + 1U;
char *ROI_values = (char*) malloc(size_optarg);
if (ROI_values == NULL) {
@ -706,8 +699,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 't': /* Input tile index */
{
case 't': { /* Input tile index */
sscanf(opj_optarg, "%u", &parameters->tile_index);
parameters->nb_tile_to_decode = 1;
}
@ -715,8 +707,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* ----------------------------------------------------- */
case 'x': /* Creation of index file */
{
case 'x': { /* Creation of index file */
if (opj_strcpy_s(parameters->indexfilename, sizeof(parameters->indexfilename), opj_optarg) != 0) {
fprintf(stderr, "[ERROR] Path is too long\n");
return 1;
@ -725,10 +716,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
break;
/* ----------------------------------------------------- */
case 'p': /* Force precision */
{
if (!parse_precision(opj_optarg, parameters))
{
case 'p': { /* Force precision */
if (!parse_precision(opj_optarg, parameters)) {
return 1;
}
}
@ -738,8 +727,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* UniPG>> */
#ifdef USE_JPWL
case 'W': /* activate JPWL correction */
{
case 'W': { /* activate JPWL correction */
char *token = NULL;
token = strtok(opj_optarg, ",");
@ -864,15 +852,17 @@ int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsi
if (it != 4) {
return EXIT_FAILURE;
}
else{
*DA_x0 = (OPJ_UINT32)values[0]; *DA_y0 = (OPJ_UINT32)values[1];
*DA_x1 = (OPJ_UINT32)values[2]; *DA_y1 = (OPJ_UINT32)values[3];
} else {
*DA_x0 = (OPJ_UINT32)values[0];
*DA_y0 = (OPJ_UINT32)values[1];
*DA_x1 = (OPJ_UINT32)values[2];
*DA_y1 = (OPJ_UINT32)values[3];
return EXIT_SUCCESS;
}
}
OPJ_FLOAT64 opj_clock(void) {
OPJ_FLOAT64 opj_clock(void)
{
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
@ -901,21 +891,24 @@ OPJ_FLOAT64 opj_clock(void) {
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
@ -1163,8 +1156,7 @@ static opj_image_t* upsample_image_components(opj_image_t* original)
l_dst += l_new_cmp->w;
}
}
}
else {
} else {
memcpy(l_new_cmp->data, l_org_cmp->data, l_org_cmp->w * l_org_cmp->h * sizeof(OPJ_INT32));
}
}
@ -1262,20 +1254,17 @@ int main(int argc, char **argv)
/* ---------------------- */
switch(parameters.decod_format) {
case J2K_CFMT: /* JPEG-2000 codestream */
{
case J2K_CFMT: { /* JPEG-2000 codestream */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
break;
}
case JP2_CFMT: /* JPEG 2000 compressed image data */
{
case JP2_CFMT: { /* JPEG 2000 compressed image data */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
break;
}
case JPT_CFMT: /* JPEG 2000, JPIP */
{
case JPT_CFMT: { /* JPEG 2000, JPIP */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_JPT);
break;
@ -1335,8 +1324,7 @@ int main(int argc, char **argv)
opj_image_destroy(image);
return EXIT_FAILURE;
}
}
else {
} else {
/* It is just here to illustrate how to use the resolution after set parameters */
/*if (!opj_set_decoded_resolution_factor(l_codec, 5)) {
@ -1373,11 +1361,9 @@ int main(int argc, char **argv)
if(image->color_space == OPJ_CLRSPC_SYCC) {
color_sycc_to_rgb(image);
}
else if((image->color_space == OPJ_CLRSPC_CMYK) && (parameters.cod_format != TIF_DFMT)){
} else if((image->color_space == OPJ_CLRSPC_CMYK) && (parameters.cod_format != TIF_DFMT)) {
color_cmyk_to_rgb(image);
}
else if(image->color_space == OPJ_CLRSPC_EYCC){
} else if(image->color_space == OPJ_CLRSPC_EYCC) {
color_esycc_to_rgb(image);
}
@ -1389,16 +1375,15 @@ int main(int argc, char **argv)
color_cielab_to_rgb(image);
#endif
free(image->icc_profile_buf);
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
image->icc_profile_buf = NULL;
image->icc_profile_len = 0;
}
/* Force output precision */
/* ---------------------- */
if (parameters.precision != NULL)
{
if (parameters.precision != NULL) {
OPJ_UINT32 compno;
for (compno = 0; compno < image->numcomps; ++compno)
{
for (compno = 0; compno < image->numcomps; ++compno) {
OPJ_UINT32 precno = compno;
OPJ_UINT32 prec;
@ -1427,8 +1412,7 @@ int main(int argc, char **argv)
/* Upsample components */
/* ------------------- */
if (parameters.upsample)
{
if (parameters.upsample) {
image = upsample_image_components(image);
if (image == NULL) {
fprintf(stderr, "ERROR -> opj_decompress: failed to upsample image components!\n");
@ -1440,8 +1424,7 @@ int main(int argc, char **argv)
/* Force RGB output */
/* ---------------- */
if (parameters.force_rgb)
{
if (parameters.force_rgb) {
switch (image->color_space) {
case OPJ_CLRSPC_SRGB:
break;
@ -1469,8 +1452,7 @@ int main(int argc, char **argv)
if (imagetopnm(image, parameters.outfile, parameters.split_pnm)) {
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1479,8 +1461,7 @@ int main(int argc, char **argv)
if(imagetopgx(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1489,8 +1470,7 @@ int main(int argc, char **argv)
if(imagetobmp(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1499,8 +1479,7 @@ int main(int argc, char **argv)
if(imagetotif(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1509,8 +1488,7 @@ int main(int argc, char **argv)
if(imagetoraw(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Error generating raw file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1519,8 +1497,7 @@ int main(int argc, char **argv)
if(imagetorawl(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1529,8 +1506,7 @@ int main(int argc, char **argv)
if(imagetotga(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Error generating tga file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
@ -1539,8 +1515,7 @@ int main(int argc, char **argv)
if(imagetopng(image, parameters.outfile)) {
fprintf(stderr,"[ERROR] Error generating png file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
} else {
fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;

View File

@ -91,7 +91,8 @@ static int infile_format(const char *fname);
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol);
/* -------------------------------------------------------------------------- */
static void decode_help_display(void) {
static void decode_help_display(void)
{
fprintf(stdout,"\nThis is the opj_dump utility from the OpenJPEG project.\n"
"It dumps JPEG 2000 codestream info to stdout or a given file.\n"
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
@ -117,7 +118,8 @@ static void decode_help_display(void) {
}
/* -------------------------------------------------------------------------- */
static int get_num_images(char *imgdirpath){
static int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int num_images = 0;
@ -140,7 +142,8 @@ static int get_num_images(char *imgdirpath){
}
/* -------------------------------------------------------------------------- */
static int load_images(dircnt_t *dirptr, char *imgdirpath){
static int load_images(dircnt_t *dirptr, char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int i = 0;
@ -167,7 +170,8 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
}
/* -------------------------------------------------------------------------- */
static int get_file_format(const char *filename) {
static int get_file_format(const char *filename)
{
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
@ -187,7 +191,8 @@ static int get_file_format(const char *filename) {
}
/* -------------------------------------------------------------------------- */
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
@ -251,12 +256,10 @@ static int infile_format(const char *fname)
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
magic_format = JP2_CFMT;
magic_s = ".jp2";
}
else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
magic_format = J2K_CFMT;
magic_s = ".j2k or .jpc or .j2c";
}
else
} else
return -1;
if (magic_format == ext_format)
@ -276,7 +279,8 @@ static int infile_format(const char *fname)
* Parse the command line
*/
/* -------------------------------------------------------------------------- */
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol)
{
int totlen, c;
opj_option_t long_option[]= {
{"ImgDir",REQ_ARG, NULL ,'y'}
@ -290,8 +294,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = infile_format(infile);
switch(parameters->decod_format) {
@ -317,8 +320,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* ------------------------------------------------------ */
case 'o': /* output file */
{
case 'o': { /* output file */
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), opj_optarg) != 0) {
fprintf(stderr, "[ERROR] Path is too long\n");
return 1;
@ -338,8 +340,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* ------------------------------------------------------ */
case 'y': /* Image Directory path */
{
case 'y': { /* Image Directory path */
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
@ -348,8 +349,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* ----------------------------------------------------- */
case 'v': /* Verbose mode */
{
case 'v': { /* Verbose mode */
parameters->m_verbose = 1;
}
break;
@ -394,21 +394,24 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/**
sample error debug callback expecting no client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[ERROR] %s", msg);
}
/**
sample warning debug callback expecting no client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
@ -488,8 +491,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
return EXIT_FAILURE;
}
}
else
} else
fout = stdout;
/* Read the header of each image one by one */
@ -517,20 +519,17 @@ int main(int argc, char *argv[])
/* ------------------------ */
switch(parameters.decod_format) {
case J2K_CFMT: /* JPEG-2000 codestream */
{
case J2K_CFMT: { /* JPEG-2000 codestream */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
break;
}
case JP2_CFMT: /* JPEG 2000 compressed image data */
{
case JP2_CFMT: { /* JPEG 2000 compressed image data */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
break;
}
case JPT_CFMT: /* JPEG 2000, JPIP */
{
case JPT_CFMT: { /* JPEG 2000, JPIP */
/* Get a decoder handle */
l_codec = opj_create_decompress(OPJ_CODEC_JPT);
break;

View File

@ -365,8 +365,7 @@ static DIR *opendir(const char *dirname)
strcpy (dirp->dirname, dirname);
p = strchr (dirp->dirname, '\0');
if (dirp->dirname < p &&
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
{
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
strcpy (p++, "\\");
}
# ifdef DIRENT_WIN32_INTERFACE
@ -619,8 +618,7 @@ _initdir (DIR *dirp)
# elif defined(DIRENT_MSDOS_INTERFACE)
if (_dos_findfirst (dirp->dirname,
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
&dirp->current.data) != 0)
{
&dirp->current.data) != 0) {
/* _dos_findfirst and findfirst will set errno to ENOENT when no
* more entries could be retrieved. */
return 0;
@ -656,7 +654,8 @@ _getdirname (const struct dirent *dp)
* Copy name of implementation dependent directory entry to the d_name field.
*/
static void
_setdirname (struct DIR *dirp) {
_setdirname (struct DIR *dirp)
{
/* make sure that d_name is long enough */
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);

View File

@ -45,7 +45,8 @@
void dump_volume(FILE *fd, opj_volume_t * vol) {
void dump_volume(FILE *fd, opj_volume_t * vol)
{
int compno;
fprintf(fd, "volume {\n");
fprintf(fd, " x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", vol->x0, vol->y0, vol->z0,vol->x1, vol->y1, vol->z1);
@ -66,7 +67,8 @@ void dump_volume(FILE *fd, opj_volume_t * vol) {
*
* log2(a)
*/
static int int_floorlog2(int a) {
static int int_floorlog2(int a)
{
int l;
for (l = 0; a > 1; l++) {
a >>= 1;
@ -79,7 +81,8 @@ static int int_floorlog2(int a) {
*
* a divided by 2^b
*/
static int int_ceildivpow2(int a, int b) {
static int int_ceildivpow2(int a, int b)
{
return (a + (1 << b) - 1) >> b;
}
@ -88,7 +91,8 @@ static int int_ceildivpow2(int a, int b) {
*
* a divided by b
*/
static int int_ceildiv(int a, int b) {
static int int_ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
@ -150,7 +154,8 @@ static unsigned int LongSwap (unsigned int i)
}
/*****************************************/
opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters)
{
FILE *f = NULL;
int w, h, prec;
@ -196,7 +201,8 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
/*Fetch only the path */
strcpy(tmpdirpath,relpath);
if ((tmp = strrchr(tmpdirpath,'/')) != NULL) {
tmp++; *tmp='\0';
tmp++;
*tmp='\0';
strcpy(dirpath,tmpdirpath);
} else {
strcpy(dirpath,"./");
@ -222,8 +228,7 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
}
/*Read all .pgx files of directory */
while ( (direntp = readdir( dirp )) != NULL )
{
while ( (direntp = readdir( dirp )) != NULL ) {
/* Found a directory, but ignore . and .. */
if(strcmp(".",direntp->d_name) == 0 || strcmp("..",direntp->d_name) == 0)
continue;
@ -241,7 +246,8 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
tmpno[i++] = *tmp2;
point = tmp2;
tmp2 = strpbrk (tmp2+1,"0123456789");
}tmpno[i]='\0';
}
tmpno[i]='\0';
/*Comprobamos que no estamos leyendo algo raro como pattern.jp3d*/
if ((point = strpbrk (point,".")) == NULL) {
@ -270,8 +276,7 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
return NULL;
}*/
for (s=0;s<sliceno;s++)
{
for (s=0; s<sliceno; s++) {
int pos = maxslice == sliceno ? s: pgxslicepos[s];
f = fopen(pgxfiles[pos], "rb");
if (!f) {
@ -379,7 +384,8 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
}
int volumetopgx(opj_volume_t * volume, char *outfile) {
int volumetopgx(opj_volume_t * volume, char *outfile)
{
int w, wr, wrr, h, hr, hrr, l, lr, lrr;
int i, j, compno, offset, sliceno;
FILE *fdest = NULL;
@ -466,7 +472,8 @@ BIN IMAGE FORMAT
<<-- <<-- <<-- <<-- */
opj_volume_t* bintovolume(char *filename, char *fileimg, opj_cparameters_t *parameters) {
opj_volume_t* bintovolume(char *filename, char *fileimg, opj_cparameters_t *parameters)
{
int subsampling_dx = parameters->subsampling_dx;
int subsampling_dy = parameters->subsampling_dy;
int subsampling_dz = parameters->subsampling_dz;
@ -678,7 +685,8 @@ opj_volume_t* bintovolume(char *filename, char *fileimg, opj_cparameters_t *para
return volume;
}
int volumetobin(opj_volume_t * volume, char *outfile) {
int volumetobin(opj_volume_t * volume, char *outfile)
{
int w, wr, wrr, h, hr, hrr, l, lr, lrr, max;
int i,j, compno, nbytes;
int offset, sliceno;
@ -764,7 +772,8 @@ int volumetobin(opj_volume_t * volume, char *outfile) {
IMG IMAGE FORMAT
<<-- <<-- <<-- <<-- */
opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters) {
opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters)
{
int subsampling_dx = parameters->subsampling_dx;
int subsampling_dy = parameters->subsampling_dy;
int subsampling_dz = parameters->subsampling_dz;
@ -795,7 +804,8 @@ opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters) {
/*Fetch only the path */
strcpy(tmpdirpath,fileimg);
if ((tmp = strrchr(tmpdirpath,'/')) != NULL) {
tmp++; *tmp='\0';
tmp++;
*tmp='\0';
strcpy(dirpath,tmpdirpath);
} else {
strcpy(dirpath,"./");

View File

@ -55,7 +55,8 @@ char *optarg; /* argument associated with option */
* getopt --
* Parse argc/argv argument vector.
*/
int getopt(int nargc, char *const *nargv, const char *ostr) {
int getopt(int nargc, char *const *nargv, const char *ostr)
{
# define __progname nargv[0] /* program name */

View File

@ -46,7 +46,8 @@
/* ----------------------------------------------------------------------- */
void encode_help_display() {
void encode_help_display()
{
fprintf(stdout,"List of parameters for the JPEG2000 Part 10 encoder:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"\n");
@ -166,7 +167,8 @@ void encode_help_display() {
}
OPJ_PROG_ORDER give_progression(char progression[4]) {
OPJ_PROG_ORDER give_progression(char progression[4])
{
if(strncmp(progression, "LRCP", 4) == 0) {
return LRCP;
}
@ -186,7 +188,8 @@ OPJ_PROG_ORDER give_progression(char progression[4]) {
return PROG_UNKNOWN;
}
OPJ_TRANSFORM give_transform(char transform[4]) {
OPJ_TRANSFORM give_transform(char transform[4])
{
if(strncmp(transform, "2DWT", 4) == 0) {
return TRF_2D_DWT;
}
@ -196,7 +199,8 @@ OPJ_TRANSFORM give_transform(char transform[4]) {
return TRF_UNKNOWN;
}
OPJ_ENTROPY_CODING give_coding(char coding[3]) {
OPJ_ENTROPY_CODING give_coding(char coding[3])
{
if(strncmp(coding, "2EB", 3) == 0) {
return ENCOD_2EB;
@ -214,7 +218,8 @@ OPJ_ENTROPY_CODING give_coding(char coding[3]) {
return ENCOD_UNKNOWN;
}
int get_file_format(char *filename) {
int get_file_format(char *filename)
{
int i;
static const char *extension[] = {"pgx", "bin", "img", "j3d", "jp3d", "j2k"};
static const int format[] = { PGX_DFMT, BIN_DFMT, IMG_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT};
@ -233,7 +238,8 @@ int get_file_format(char *filename) {
/* ------------------------------------------------------------------------------------ */
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
{
int i, value;
/* parse the command line */
@ -243,8 +249,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
@ -264,8 +269,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
break;
/* ----------------------------------------------------- */
case 'm': /* input IMG file */
{
case 'm': { /* input IMG file */
char *imgfile = opj_optarg;
int imgformat = get_file_format(imgfile);
switch(imgformat) {
@ -282,8 +286,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
break;
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -303,8 +306,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'r': /* define compression rates for each layer */
{
case 'r': { /* define compression rates for each layer */
char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++;
@ -321,8 +323,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'q': /* define distorsion (PSNR) for each layer */
{
case 'q': { /* define distorsion (PSNR) for each layer */
char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++;
@ -339,8 +340,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'f':
{
case 'f': {
fprintf(stdout, "/---------------------------------------------------\\\n");
fprintf(stdout, "| Fixed layer allocation option not implemented !! |\n");
fprintf(stdout, "\\---------------------------------------------------/\n");
@ -388,8 +388,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 't': /* tiles */
{
case 't': { /* tiles */
if (sscanf(opj_optarg, "%d,%d,%d", &parameters->cp_tdx, &parameters->cp_tdy, &parameters->cp_tdz) !=3) {
fprintf(stdout, "[ERROR] '-t' 'dimensions of tiles' argument error ! [-t tdx,tdy,tdz]\n");
return 1;
@ -400,8 +399,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'n': /* resolution */
{
case 'n': { /* resolution */
int aux;
aux = sscanf(opj_optarg, "%d,%d,%d", &parameters->numresolution[0], &parameters->numresolution[1], &parameters->numresolution[2]);
if (aux == 2)
@ -418,8 +416,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
break;
/* ----------------------------------------------------- */
case 'c': /* precinct dimension */
{
case 'c': { /* precinct dimension */
char sep;
int res_spec = 0;
int aux;
@ -434,16 +431,14 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
}
while (sep == ',');
} while (sep == ',');
parameters->res_spec = res_spec; /* number of precinct size specifications */
}
break;
/* ----------------------------------------------------- */
case 'b': /* code-block dimension */
{
case 'b': { /* code-block dimension */
int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
if (sscanf(opj_optarg, "%d,%d,%d", &cblockw_init, &cblockh_init, &cblockl_init) != 3) {
fprintf(stdout, "[ERROR] '-b' 'dimensions of codeblocks' argument error ! [-b cblkx,cblky,cblkz]\n");
@ -461,8 +456,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'x': /* creation of index file */
{
case 'x': { /* creation of index file */
char *index = opj_optarg;
strncpy(parameters->index, index, MAX_PATH);
parameters->index_on = 1;
@ -471,8 +465,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'p': /* progression order */
{
case 'p': { /* progression order */
char progression[4];
strncpy(progression, opj_optarg, 4);
@ -486,8 +479,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 's': /* subsampling factor */
{
case 's': { /* subsampling factor */
if (sscanf(opj_optarg, "%d,%d,%d", &parameters->subsampling_dx, &parameters->subsampling_dy, &parameters->subsampling_dz) != 3) {
fprintf(stdout, "[ERROR] '-s' sub-sampling argument error ! [-s dx,dy,dz]\n");
return 1;
@ -497,8 +489,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'd': /* coordonnate of the reference grid */
{
case 'd': { /* coordonnate of the reference grid */
if (sscanf(opj_optarg, "%d,%d,%d", &parameters->volume_offset_x0, &parameters->volume_offset_y0, &parameters->volume_offset_z0) != 3) {
fprintf(stdout, "[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
return 1;
@ -508,8 +499,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'h': /* display an help description */
{
case 'h': { /* display an help description */
encode_help_display();
return 1;
}
@ -517,8 +507,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ----------------------------------------------------- */
case 'P': /* POC */
{
case 'P': { /* POC */
int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
@ -550,24 +539,21 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ------------------------------------------------------ */
case 'S': /* SOP marker */
{
case 'S': { /* SOP marker */
parameters->csty |= 0x02;
}
break;
/* ------------------------------------------------------ */
case 'E': /* EPH marker */
{
case 'E': { /* EPH marker */
parameters->csty |= 0x04;
}
break;
/* ------------------------------------------------------ */
case 'M': /* Codification mode switch */
{
case 'M': { /* Codification mode switch */
fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
value = 0;
if (sscanf(opj_optarg, "%d", &value) == 1) {
@ -582,8 +568,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ------------------------------------------------------ */
case 'D': /* DCO */
{
case 'D': { /* DCO */
if (sscanf(opj_optarg, "%d", &parameters->dcoffset) != 1) {
fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n",parameters->dcoffset);
return 1;
@ -593,8 +578,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ------------------------------------------------------ */
case 'R': /* ROI */
{
case 'R': { /* ROI */
if (sscanf(opj_optarg, "OI:c=%d,U=%d", &parameters->roi_compno, &parameters->roi_shift) != 2) {
fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
return 1;
@ -604,8 +588,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ------------------------------------------------------ */
case 'l': /* Tile offset */
{
case 'l': { /* Tile offset */
if (sscanf(opj_optarg, "%d,%d,%d", &parameters->cp_tx0, &parameters->cp_ty0, &parameters->cp_tz0) != 3) {
fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
return 1;
@ -630,8 +613,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
------------------------------------------------------ */
case 'C': /* Coding of transformed data */
{
case 'C': { /* Coding of transformed data */
char coding[3];
strncpy(coding, opj_optarg, 3);
@ -645,8 +627,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/* ------------------------------------------------------ */
case 'I': /* reversible or not */
{
case 'I': { /* reversible or not */
parameters->irreversible = 1;
}
break;
@ -754,28 +735,32 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting a FILE* client object
*/
void info_callback(const char *msg, void *client_data) {
void info_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
bool bSuccess;
bool delete_comment = true;
opj_cparameters_t parameters; /* compression parameters */

View File

@ -149,7 +149,8 @@ static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
return sum;
}
void decode_help_display() {
void decode_help_display()
{
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
@ -195,7 +196,8 @@ void decode_help_display() {
/* -------------------------------------------------------------------------- */
int get_file_format(char *filename) {
int get_file_format(char *filename)
{
int i;
static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
@ -214,7 +216,8 @@ int get_file_format(char *filename) {
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
{
/* parse the command line */
while (1) {
@ -222,8 +225,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
@ -241,8 +243,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
}
break;
case 'm': /* img file */
{
case 'm': { /* img file */
char *imgfile = opj_optarg;
int imgformat = get_file_format(imgfile);
switch(imgformat) {
@ -260,8 +261,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -281,8 +281,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/* ----------------------------------------------------- */
case 'O': /* Original image for PSNR computing */
{
case 'O': { /* Original image for PSNR computing */
char *original = opj_optarg;
parameters->orig_format = get_file_format(original);
switch(parameters->orig_format) {
@ -301,8 +300,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
case 'r': { /* reduce option */
/*sscanf(opj_optarg, "%d, %d, %d", &parameters->cp_reduce[0], &parameters->cp_reduce[1], &parameters->cp_reduce[2]);*/
int aux;
aux = sscanf(opj_optarg, "%d,%d,%d", &parameters->cp_reduce[0], &parameters->cp_reduce[1], &parameters->cp_reduce[2]);
@ -321,32 +319,28 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
case 'l': { /* layering option */
sscanf(opj_optarg, "%d", &parameters->cp_layer);
}
break;
/* ----------------------------------------------------- */
case 'B': /* BIGENDIAN vs. LITTLEENDIAN */
{
case 'B': { /* BIGENDIAN vs. LITTLEENDIAN */
parameters->bigendian = 1;
}
break;
/* ----------------------------------------------------- */
case 'L': /* BIGENDIAN vs. LITTLEENDIAN */
{
case 'L': { /* BIGENDIAN vs. LITTLEENDIAN */
parameters->decod_format = LSE_CFMT;
}
break;
/* ----------------------------------------------------- */
case 'h': /* display an help description */
{
case 'h': { /* display an help description */
decode_help_display();
return 1;
}
@ -375,27 +369,31 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *client_data) {
void info_callback(const char *msg, void *client_data)
{
fprintf(stdout, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
@ -499,8 +497,12 @@ int main(int argc, char **argv) {
case PGX_DFMT: /* PGX */
if (strcmp("NULL",parameters.original) != 0) {
fprintf(stdout,"Loading original file %s \n",parameters.original);
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
cparameters.subsampling_dx = 1;
cparameters.subsampling_dy = 1;
cparameters.subsampling_dz = 1;
cparameters.volume_offset_x0 = 0;
cparameters.volume_offset_y0 = 0;
cparameters.volume_offset_z0 = 0;
original = pgxtovolume(parameters.original,&cparameters);
}
break;
@ -508,8 +510,12 @@ int main(int argc, char **argv) {
case BIN_DFMT: /* BMP */
if (strcmp("NULL",parameters.original) != 0 && strcmp("NULL",parameters.imgfile) != 0) {
fprintf(stdout,"Loading original file %s %s\n",parameters.original,parameters.imgfile);
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
cparameters.subsampling_dx = 1;
cparameters.subsampling_dy = 1;
cparameters.subsampling_dz = 1;
cparameters.volume_offset_x0 = 0;
cparameters.volume_offset_y0 = 0;
cparameters.volume_offset_z0 = 0;
original = bintovolume(parameters.original,parameters.imgfile,&cparameters);
}
break;

View File

@ -364,8 +364,7 @@ static DIR *opendir(const char *dirname)
strcpy (dirp->dirname, dirname);
p = strchr (dirp->dirname, '\0');
if (dirp->dirname < p &&
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
{
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
strcpy (p++, "\\");
}
# ifdef DIRENT_WIN32_INTERFACE
@ -618,8 +617,7 @@ _initdir (DIR *dirp)
# elif defined(DIRENT_MSDOS_INTERFACE)
if (_dos_findfirst (dirp->dirname,
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
&dirp->current.data) != 0)
{
&dirp->current.data) != 0) {
/* _dos_findfirst and findfirst will set errno to ENOENT when no
* more entries could be retrieved. */
return 0;
@ -655,7 +653,8 @@ _getdirname (const struct dirent *dp)
* Copy name of implementation dependent directory entry to the d_name field.
*/
static void
_setdirname (struct DIR *dirp) {
_setdirname (struct DIR *dirp)
{
/* make sure that d_name is long enough */
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);

View File

@ -54,7 +54,8 @@
WSADATA initialisation_win32;
#endif
int main(int argc, char *argv[]){
int main(int argc, char *argv[])
{
dec_server_record_t *server_record;
client_t client;

View File

@ -106,15 +106,12 @@ int main(int argc,char *argv[])
}
ext = strrchr( argv[2], '.' );
if( ext )
{
if( ext ) {
/* strcasecmp ? */
if( strcmp(ext, ".jp2" ) == 0 )
{
if( strcmp(ext, ".jp2" ) == 0 ) {
return jpip_to_jp2(argv);
}
if( strcmp(ext, ".j2k" ) == 0 )
{
if( strcmp(ext, ".j2k" ) == 0 ) {
return jpip_to_j2k(argv);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ Write a structured index to a file
@param index Index filename
@return Returns 0 if successful, returns 1 otherwise
*/
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
{
int tileno, compno, layno, resno, precno, pack_nb, x, y;
FILE *stream = NULL;
double total_disto = 0;

View File

@ -88,7 +88,8 @@ typedef struct img_folder{
float *rates;
} img_fol_t;
static void encode_help_display(void) {
static void encode_help_display(void)
{
fprintf(stdout,"HELP for opj_jpwl_compress\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
@ -327,7 +328,8 @@ static void encode_help_display(void) {
fprintf(stdout,"TotalDisto\n\n");
}
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
static OPJ_PROG_ORDER give_progression(const char progression[4])
{
if(strncmp(progression, "LRCP", 4) == 0) {
return LRCP;
}
@ -347,7 +349,8 @@ static OPJ_PROG_ORDER give_progression(const char progression[4]) {
return PROG_UNKNOWN;
}
static unsigned int get_num_images(char *imgdirpath){
static unsigned int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
unsigned int num_images = 0;
@ -369,7 +372,8 @@ static unsigned int get_num_images(char *imgdirpath){
return num_images;
}
static int load_images(dircnt_t *dirptr, char *imgdirpath){
static int load_images(dircnt_t *dirptr, char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int i = 0;
@ -394,7 +398,8 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
return 0;
}
static int get_file_format(char *filename) {
static int get_file_format(char *filename)
{
unsigned int i;
static const char *extension[] = {
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
@ -414,14 +419,16 @@ static int get_file_format(char *filename) {
return -1;
}
static char * get_file_name(char *name){
static char * get_file_name(char *name)
{
char *fname;
fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
fname= strtok(name,".");
return fname;
}
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
@ -446,7 +453,8 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c
return 0;
}
static int initialise_4K_poc(opj_poc_t *POC, int numres){
static int initialise_4K_poc(opj_poc_t *POC, int numres)
{
POC[0].tile = 1;
POC[0].resno0 = 0;
POC[0].compno0 = 0;
@ -464,7 +472,8 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
return 2;
}
static void cinema_parameters(opj_cparameters_t *parameters){
static void cinema_parameters(opj_cparameters_t *parameters)
{
parameters->tile_size_on = OPJ_FALSE;
parameters->cp_tdx=1;
parameters->cp_tdy=1;
@ -490,14 +499,16 @@ static void cinema_parameters(opj_cparameters_t *parameters){
/* No ROI */
parameters->roi_compno = -1;
parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
parameters->subsampling_dx = 1;
parameters->subsampling_dy = 1;
/* 9-7 transform */
parameters->irreversible = 1;
}
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol)
{
int i;
float temp_rate;
@ -583,7 +594,8 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
/* ------------------------------------------------------------------------------------ */
static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename)
{
int i, j, totlen, c;
opj_option_t long_option[]= {
{"cinema2K",REQ_ARG, NULL ,'w'},
@ -614,8 +626,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
@ -640,8 +651,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -657,8 +667,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
break;
/* ----------------------------------------------------- */
case 'O': /* output format */
{
case 'O': { /* output format */
char outformat[50];
char *of = opj_optarg;
sprintf(outformat,".%s",of);
@ -680,8 +689,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'r': /* rates rates/distorsion */
{
case 'r': { /* rates rates/distorsion */
char *s = opj_optarg;
parameters->tcp_numlayers = 0;
while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
@ -700,28 +708,24 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'F': /* Raw image format parameters */
{
case 'F': { /* Raw image format parameters */
char signo;
char *s = opj_optarg;
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
if (signo == 's') {
raw_cp->rawSigned = OPJ_TRUE;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Signed\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else if (signo == 'u') {
} else if (signo == 'u') {
raw_cp->rawSigned = OPJ_FALSE;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Unsigned\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else {
} else {
fprintf(stderr,"\nError: invalid raw image parameters: Unknown sign of raw file\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stderr,"Aborting\n");
}
}
else {
} else {
fprintf(stderr,"\nError: invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
@ -734,8 +738,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'q': /* add fixed_quality */
{
case 'q': { /* add fixed_quality */
char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++;
@ -753,8 +756,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* dda */
/* ----------------------------------------------------- */
case 'f': /* mod fixed_quality (before : -q) */
{
case 'f': { /* mod fixed_quality (before : -q) */
int *row = NULL, *col = NULL;
int numlayers = 0, numresolution = 0, matrix_width = 0;
@ -800,8 +802,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 't': /* tiles */
{
case 't': { /* tiles */
sscanf(opj_optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
parameters->tile_size_on = OPJ_TRUE;
}
@ -809,15 +810,13 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'n': /* resolution */
{
case 'n': { /* resolution */
sscanf(opj_optarg, "%d", &parameters->numresolution);
}
break;
/* ----------------------------------------------------- */
case 'c': /* precinct dimension */
{
case 'c': { /* precinct dimension */
char sep;
int res_spec = 0;
@ -829,16 +828,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
}
while (sep == ',');
} while (sep == ',');
parameters->res_spec = res_spec;
}
break;
/* ----------------------------------------------------- */
case 'b': /* code-block dimension */
{
case 'b': { /* code-block dimension */
int cblockw_init = 0, cblockh_init = 0;
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
@ -855,8 +852,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'x': /* creation of index file */
{
case 'x': { /* creation of index file */
char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN);
}
@ -864,8 +860,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'p': /* progression order */
{
case 'p': { /* progression order */
char progression[4];
strncpy(progression, opj_optarg, 4);
@ -880,8 +875,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 's': /* subsampling factor */
{
case 's': { /* subsampling factor */
if (sscanf(opj_optarg, "%d,%d", &parameters->subsampling_dx,
&parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
@ -892,8 +886,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'd': /* coordonnate of the reference grid */
{
case 'd': { /* coordonnate of the reference grid */
if (sscanf(opj_optarg, "%d,%d", &parameters->image_offset_x0,
&parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
@ -911,8 +904,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ----------------------------------------------------- */
case 'P': /* POC */
{
case 'P': { /* POC */
int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
@ -939,24 +931,21 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'S': /* SOP marker */
{
case 'S': { /* SOP marker */
parameters->csty |= 0x02;
}
break;
/* ------------------------------------------------------ */
case 'E': /* EPH marker */
{
case 'E': { /* EPH marker */
parameters->csty |= 0x04;
}
break;
/* ------------------------------------------------------ */
case 'M': /* Mode switch pas tous au point !! */
{
case 'M': { /* Mode switch pas tous au point !! */
int value = 0;
if (sscanf(opj_optarg, "%d", &value) == 1) {
for (i = 0; i <= 5; i++) {
@ -970,8 +959,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'R': /* ROI */
{
case 'R': { /* ROI */
if (sscanf(opj_optarg, "c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
@ -982,8 +970,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'T': /* Tile offset */
{
case 'T': { /* Tile offset */
if (sscanf(opj_optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1;
@ -993,8 +980,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'C': /* add a comment */
{
case 'C': { /* add a comment */
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
if(parameters->cp_comment) {
strcpy(parameters->cp_comment, opj_optarg);
@ -1005,16 +991,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'I': /* reversible or not */
{
case 'I': { /* reversible or not */
parameters->irreversible = 1;
}
break;
/* ------------------------------------------------------ */
case 'u': /* Tile part generation*/
{
case 'u': { /* Tile part generation*/
parameters->tp_flag = opj_optarg[0];
parameters->tp_on = 1;
}
@ -1022,8 +1006,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'z': /* Image Directory path */
{
case 'z': { /* Image Directory path */
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
@ -1032,8 +1015,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'w': /* Digital Cinema 2K profile compliance*/
{
case 'w': { /* Digital Cinema 2K profile compliance*/
int fps=0;
sscanf(opj_optarg,"%d",&fps);
if(fps == 24) {
@ -1052,8 +1034,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
case 'y': /* Digital Cinema 4K profile compliance*/
{
case 'y': { /* Digital Cinema 4K profile compliance*/
parameters->cp_cinema = CINEMA4K_24;
fprintf(stdout,"CINEMA 4K compliant codestream\n");
parameters->cp_rsiz = CINEMA4K;
@ -1066,8 +1047,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
#ifdef USE_JPWL
/* ------------------------------------------------------ */
case 'W': /* JPWL capabilities switched on */
{
case 'W': { /* JPWL capabilities switched on */
char *token = NULL;
int hprot, pprot, sens, addr, size, range;
@ -1383,8 +1363,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* <<UniPG */
/* ------------------------------------------------------ */
case 'J': /* jpip on */
{
case 'J': { /* jpip on */
/*parameters->jpip_on = OPJ_TRUE;*/
}
break;
@ -1472,28 +1451,32 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting a FILE* client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
opj_bool bSuccess;
opj_cparameters_t parameters; /* compression parameters */
img_fol_t img_fol;
@ -1670,8 +1653,7 @@ int main(int argc, char **argv) {
/* Can happen if input file is TIFF or PNG
* and OPJ_HAVE_LIBTIF or OPJ_HAVE_LIBPNG is undefined
*/
if( !image)
{
if( !image) {
fprintf(stderr, "Unable to load file: got no image\n");
return 1;
}

View File

@ -91,7 +91,8 @@ typedef struct img_folder{
} img_fol_t;
void decode_help_display(void) {
void decode_help_display(void)
{
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
@ -150,7 +151,8 @@ void decode_help_display(void) {
/* -------------------------------------------------------------------------- */
int get_num_images(char *imgdirpath){
int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int num_images = 0;
@ -171,7 +173,8 @@ int get_num_images(char *imgdirpath){
return num_images;
}
int load_images(dircnt_t *dirptr, char *imgdirpath){
int load_images(dircnt_t *dirptr, char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int i = 0;
@ -196,7 +199,8 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
return 0;
}
int get_file_format(char *filename) {
int get_file_format(char *filename)
{
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
@ -215,7 +219,8 @@ int get_file_format(char *filename) {
return -1;
}
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
@ -241,7 +246,8 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename)
{
/* parse the command line */
int totlen, c;
opj_option_t long_option[]= {
@ -264,8 +270,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
case 'i': { /* input file */
char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
@ -285,8 +290,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
case 'o': /* output file */
{
case 'o': { /* output file */
char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
@ -308,8 +312,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
case 'O': /* output format */
{
case 'O': { /* output format */
char outformat[50];
char *of = opj_optarg;
sprintf(outformat,".%s",of);
@ -348,8 +351,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
case 'r': { /* reduce option */
sscanf(opj_optarg, "%d", &parameters->cp_reduce);
}
break;
@ -357,8 +359,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
case 'l': { /* layering option */
sscanf(opj_optarg, "%d", &parameters->cp_layer);
}
break;
@ -371,16 +372,14 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ------------------------------------------------------ */
case 'y': /* Image Directory path */
{
case 'y': { /* Image Directory path */
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
}
break;
/* ----------------------------------------------------- */
case 'x': /* Creation of index file */
{
case 'x': { /* Creation of index file */
char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN);
}
@ -389,8 +388,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* UniPG>> */
#ifdef USE_JPWL
case 'W': /* activate JPWL correction */
{
case 'W': { /* activate JPWL correction */
char *token = NULL;
token = strtok(opj_optarg, ",");
@ -496,28 +494,32 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *client_data) {
void info_callback(const char *msg, void *client_data)
{
(void)client_data;
fprintf(stdout, "[INFO] %s", msg);
}
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
opj_dparameters_t parameters; /* decompression parameters */
img_fol_t img_fol;
opj_event_mgr_t event_mgr; /* event manager */
@ -601,8 +603,7 @@ int main(int argc, char **argv) {
file_length = ftell(fsrc);
fseek(fsrc, 0, SEEK_SET);
src = (unsigned char *) malloc(file_length);
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
{
if (fread(src, 1, file_length, fsrc) != (size_t)file_length) {
free(src);
fclose(fsrc);
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
@ -614,8 +615,7 @@ int main(int argc, char **argv) {
/* ---------------------- */
switch(parameters.decod_format) {
case J2K_CFMT:
{
case J2K_CFMT: {
/* JPEG-2000 codestream */
/* get a decoder handle */
@ -657,8 +657,7 @@ int main(int argc, char **argv) {
}
break;
case JP2_CFMT:
{
case JP2_CFMT: {
/* JPEG 2000 compressed image data */
/* get a decoder handle */
@ -700,8 +699,7 @@ int main(int argc, char **argv) {
}
break;
case JPT_CFMT:
{
case JPT_CFMT: {
/* JPEG 2000, JPIP */
/* get a decoder handle */
@ -752,19 +750,18 @@ int main(int argc, char **argv) {
free(src);
src = NULL;
if(image->color_space == CLRSPC_SYCC)
{
if(image->color_space == CLRSPC_SYCC) {
color_sycc_to_rgb(image);
}
if(image->icc_profile_buf)
{
if(image->icc_profile_buf) {
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
color_apply_icc_profile(image);
#endif
free(image->icc_profile_buf);
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
image->icc_profile_buf = NULL;
image->icc_profile_len = 0;
}
/* create output image */
@ -773,8 +770,7 @@ int main(int argc, char **argv) {
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@ -782,8 +778,7 @@ int main(int argc, char **argv) {
case PGX_DFMT: /* PGX */
if(imagetopgx(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@ -791,8 +786,7 @@ int main(int argc, char **argv) {
case BMP_DFMT: /* BMP */
if(imagetobmp(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@ -800,8 +794,7 @@ int main(int argc, char **argv) {
case TIF_DFMT: /* TIFF */
if(imagetotif(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@ -809,8 +802,7 @@ int main(int argc, char **argv) {
case RAW_DFMT: /* RAW */
if(imagetoraw(image, parameters.outfile)) {
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;
@ -818,8 +810,7 @@ int main(int argc, char **argv) {
case TGA_DFMT: /* TGA */
if(imagetotga(image, parameters.outfile)) {
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;
@ -827,8 +818,7 @@ int main(int argc, char **argv) {
case PNG_DFMT: /* PNG */
if(imagetopng(image, parameters.outfile)) {
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
}
else {
} else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;

View File

@ -365,8 +365,7 @@ static DIR *opendir(const char *dirname)
strcpy (dirp->dirname, dirname);
p = strchr (dirp->dirname, '\0');
if (dirp->dirname < p &&
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
{
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
strcpy (p++, "\\");
}
# ifdef DIRENT_WIN32_INTERFACE
@ -619,8 +618,7 @@ _initdir (DIR *dirp)
# elif defined(DIRENT_MSDOS_INTERFACE)
if (_dos_findfirst (dirp->dirname,
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
&dirp->current.data) != 0)
{
&dirp->current.data) != 0) {
/* _dos_findfirst and findfirst will set errno to ENOENT when no
* more entries could be retrieved. */
return 0;
@ -656,7 +654,8 @@ _getdirname (const struct dirent *dp)
* Copy name of implementation dependent directory entry to the d_name field.
*/
static void
_setdirname (struct DIR *dirp) {
_setdirname (struct DIR *dirp)
{
/* make sure that d_name is long enough */
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);

View File

@ -89,10 +89,10 @@ void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d)
derived = d;
}
int xml_write_struct(FILE* file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr) {
if(stringDTD != NULL)
int xml_write_struct(FILE* file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr)
{
if(stringDTD != NULL) {
fprintf(xmlout,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
/* stringDTD is known to start with "SYSTEM " or "PUBLIC " */
/* typical: SYSTEM mj2_to_metadata.dtd */
@ -123,8 +123,7 @@ int xml_write_overall_header(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsign
fprintf(xmlout, " <Brand>%s</Brand>\n", buf); /* 4 character; BR */
fprintf(xmlout, " <MinorVersion>%u</MinorVersion>\n", movie->minversion); /* 4 char; MinV */
fprintf(xmlout, " <CompatibilityList Count=\"%d\">\n",movie->num_cl);
for (i = movie->num_cl - 1; i > -1; i--) /* read routine stored in reverse order, so let's undo damage */
{
for (i = movie->num_cl - 1; i > -1; i--) { /* read routine stored in reverse order, so let's undo damage */
uint_to_chars(movie->cl[i], buf);
fprintf(xmlout, " <CompatibleBrand>%s</CompatibleBrand>\n", buf); /*4 characters, each CLi */
}
@ -264,8 +263,7 @@ void uint_to_chars(unsigned int value, char* buf)
{
/* buf is at least char[5] */
int i;
for (i = 3; i >= 0; i--)
{
for (i = 3; i >= 0; i--) {
buf[i] = (value & 0x000000ff);
value = (value >> 8);
}
@ -319,7 +317,8 @@ void xml_time_out(FILE* xmlout, time_t t)
/* ------------- */
void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie) {
void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie)
{
/* Compare with xml_write_udta */
#ifdef NOTYET
/* NO-OP so far. Optional UserData 'udta' (zero or one in moov or each trak)
@ -346,7 +345,8 @@ void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie) {
#endif
}
void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie) {
void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie)
{
#ifdef NOTYET
/* NO-OP so far. There can be zero or more instances of free and/or skip
at the top level of the file. This may be a place where the user squirrel's metadata.
@ -374,7 +374,8 @@ void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie) {
#endif
}
void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie) {
void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie)
{
/* Universal Unique IDs of 16 bytes. */
#ifdef NOTYET
/* NO-OP so far. There can be zero or more instances of private uuid boxes in a file.
@ -411,8 +412,7 @@ void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
/* sampleframe is from user option -f. 1 = first frame */
/* sampleframe of 0 is a user requests: no jp2 header */
/* Treat out-of-bounds values in the same way */
if(sampleframe > 0 && sampleframe <= track->num_samples)
{
if(sampleframe > 0 && sampleframe <= track->num_samples) {
mj2_sample_t *sample;
unsigned int snum;
@ -439,14 +439,12 @@ void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
fprintf(xmlout, " <!-- If both found, value read from MediaHeader is used. -->\n");
}
fprintf(xmlout, " <TrackID>%u</TrackID>\n", track->track_ID);
if(track->track_type==0) /* For visual track */
{
if(track->track_type==0) { /* For visual track */
fprintf(xmlout, " <TrackLayer>%d</TrackLayer>\n", track->layer);
if(notes)
fprintf(xmlout," <!-- front-to-back ordering of video tracks. 0 = normal, -1 is closer, etc. -->\n");
}
if(track->track_type!=0) /* volume irrelevant for visual track */
{
if(track->track_type!=0) { /* volume irrelevant for visual track */
#ifdef CURRENTSTRUCT
track->volume = track->volume << 8;
#endif
@ -466,8 +464,7 @@ void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
track->volume = track->volume >> 8;
#endif
}
if(track->track_type==0)
{
if(track->track_type==0) {
/* Transformation matrix for video */
fprintf(xmlout, " <TransformationMatrix>\n");
if(notes) {
@ -518,7 +515,8 @@ void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
/* ------------- */
void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) {
void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
{
/* NO-OP so far. Optional UserData 'udta' (zero or one in moov or each trak)
can contain multiple Copyright 'cprt' with different language codes */
/* There may be nested non-standard boxes within udta */
@ -590,14 +588,16 @@ void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
fprintf(xmlout, " <Language>%s</Language>\n", buf); /* 3 chars */
fprintf(xmlout, " </MediaHeader>\n");
fprintf(xmlout, " <HandlerReference BoxType=\"hdlr\">\n");
switch(track->track_type)
{
switch(track->track_type) {
case 0:
fprintf(xmlout, " <HandlerType Code=\"vide\">video media track</HandlerType>\n"); break;
fprintf(xmlout, " <HandlerType Code=\"vide\">video media track</HandlerType>\n");
break;
case 1:
fprintf(xmlout, " <HandlerType Code=\"soun\">Sound</HandlerType>\n"); break;
fprintf(xmlout, " <HandlerType Code=\"soun\">Sound</HandlerType>\n");
break;
case 2:
fprintf(xmlout, " <HandlerType Code=\"hint\">Hint</HandlerType>\n"); break;
fprintf(xmlout, " <HandlerType Code=\"hint\">Hint</HandlerType>\n");
break;
}
if(notes) {
fprintf(xmlout, " <!-- String value shown is not actually read from file. -->\n");
@ -605,8 +605,7 @@ void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
}
fprintf(xmlout, " </HandlerReference>\n");
fprintf(xmlout, " <MediaInfoContainer BoxType=\"minf\">\n");
switch(track->track_type)
{
switch(track->track_type) {
case 0:
fprintf(xmlout, " <VideoMediaHeader BoxType=\"vmhd\">\n");
fprintf(xmlout, " <GraphicsMode>0x%02x</GraphicsMode>\n", track->graphicsmode);
@ -724,8 +723,7 @@ void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
fprintf(xmlout, " <SampleTable BoxType=\"stbl\">\n");
if(notes)
fprintf(xmlout, " <!-- What follows are specific instances of generic SampleDescription BoxType=\"stsd\" -->\n");
switch(track->track_type)
{
switch(track->track_type) {
case 0:
// There could be multiple instances of this, but "entry_count" is just a local at read-time.
// And it's used wrong, too, as count of just visual type, when it's really all 3 types.
@ -797,16 +795,15 @@ void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
fprintf(xmlout, " </FieldCoding>\n");
fprintf(xmlout, " <MJP2_Profile BoxType=\"jp2p\" Count=\"%d\">\n",track->num_br);
for (i = 0; i < track->num_br; i++) /* read routine stored in reverse order, so let's undo damage */
{
for (i = 0; i < track->num_br; i++) { /* read routine stored in reverse order, so let's undo damage */
uint_to_chars(track->br[i], buf);
fprintf(xmlout, " <CompatibleBrand>%s</CompatibleBrand>\n", buf); /*4 characters, each CLi */
}
fprintf(xmlout, " </MJP2_Profile>\n");
fprintf(xmlout, " <MJP2_Prefix BoxType=\"jp2x\" Count=\"%d\">\n",track->num_jp2x);
for (i = 0; i < track->num_jp2x; i++)
{ // We'll probably need better formatting than this
for (i = 0; i < track->num_jp2x; i++) {
// We'll probably need better formatting than this
fprintf(xmlout, " <Data>0x%02x</Data>\n", track->jp2xdata[i]); /* Each entry is single byte */
}
fprintf(xmlout, " </MJP2_Prefix>\n");
@ -843,9 +840,11 @@ void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum
fprintf(xmlout, " </MJP2_OriginalFormat>\n");
fprintf(xmlout, " </VisualSampleEntry>\n");
break;
case 1: case 2:
case 1:
case 2:
if(notes)
fprintf(xmlout, " <!-- mj2_to_metadata's data structure doesn't record this currently. -->\n"); break;
fprintf(xmlout, " <!-- mj2_to_metadata's data structure doesn't record this currently. -->\n");
break;
}
fprintf(xmlout, " <TimeToSample BoxType=\"stts\">\n");
fprintf(xmlout, " <SampleStatistics>\n");
@ -1031,13 +1030,11 @@ int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int s
&& (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
|| (img->numcomps == 1)) {
fprintf(xmlout, " <!-- file to a YUV movie in the normal manner. -->\n");
}
else if ((img->numcomps == 3) &&
} else if ((img->numcomps == 3) &&
(img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
(img->comps[2].dx == 1)) {// If YUV 4:4:4 input --> to bmp
fprintf(xmlout, " <!-- YUV 4:4:4 file to a series of .bmp files. -->\n");
}
else {
} else {
fprintf(xmlout, " <!-- file whose image component dimension are unknown, to a series of .j2k files. -->\n");
}
}
@ -1056,8 +1053,7 @@ void int16_to_3packedchars(short int value, char* buf)
/* This is to retrieve the 3-letter ASCII language code */
/* Each char is packed into 5 bits, as difference from 0x60 */
int i;
for (i = 2; i >= 0; i--)
{
for (i = 2; i >= 0; i--) {
buf[i] = (value & 0x001f) + 0x60;
value = (value >>5);
}
@ -1144,7 +1140,8 @@ void xml_out_frame_cod(FILE* xmlout, opj_tcp_t *tcp)
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
tccp = &(tcp->tccps[0]);
@ -1225,7 +1222,8 @@ void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps) /* Optional i
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
firstcomp_tccp = &(tcp->tccps[0]);
@ -1241,8 +1239,7 @@ void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps) /* Optional i
else
fprintf(xmlout, "%s<!-- and any other component, with tile-part-header style values different from [0], as COC. -->\n", s);
}
for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
{
for (compno = 1; compno < numcomps; compno++) { /* spec says components are zero-based */
tccp = &tcp->tccps[compno];
if(same_component_style(firstcomp_tccp, tccp))
continue;
@ -1344,7 +1341,8 @@ void xml_out_frame_qcd(FILE* xmlout, opj_tcp_t *tcp)
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
/* Compare j2k_read_qcx */
@ -1477,7 +1475,8 @@ void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
firstcomp_tccp = &(tcp->tccps[0]);
@ -1493,8 +1492,7 @@ void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
else
fprintf(xmlout, "%s<!-- and any other component, with tile-part-header quantization values different from [0], as QCC. -->\n", s);
}
for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
{
for (compno = 1; compno < numcomps; compno++) { /* spec says components are zero-based */
tccp = &(tcp->tccps[compno]);
if(same_component_quantization(firstcomp_tccp, tccp))
continue;
@ -1661,7 +1659,8 @@ void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
for(compno = 0; compno < numcomps; compno++) {
@ -1686,14 +1685,16 @@ void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
/* ------------- */
void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp) { /* Progression Order Change */
void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp) /* Progression Order Change */
{
/* Compare j2k_read_poc() */
int i;
opj_poc_t *poc;
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
if(tcp->POC != 1)
@ -1739,7 +1740,8 @@ void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp) { /* Progression Order Chan
/* Suppress PPM and PPT since we're not showing data from the third option, namely within the codestream, and
that's evidently what frames_to_mj2 uses. And a hex dump isn't so useful anyway */
void xml_out_frame_ppm(FILE *xmlout, opj_cp_t *cp) { /* For main header, not tile-part (which uses PPT instead). */
void xml_out_frame_ppm(FILE *xmlout, opj_cp_t *cp) /* For main header, not tile-part (which uses PPT instead). */
{
/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
/* Use of PPM and PPT are mutually exclusive. */
/* Compare j2k_read_ppm() */
@ -1770,7 +1772,8 @@ void xml_out_frame_ppm(FILE *xmlout, opj_cp_t *cp) { /* For main header, not til
/* ------------- */
void xml_out_frame_ppt(FILE *xmlout, opj_tcp_t *tcp) { /* For tile-part header, not main (which uses PPM instead). */
void xml_out_frame_ppt(FILE *xmlout, opj_tcp_t *tcp) /* For tile-part header, not main (which uses PPM instead). */
{
/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
/* Use of PPM and PPT are mutually exclusive. */
/* Compare j2k_read_ppt() */
@ -1803,7 +1806,8 @@ void xml_out_frame_ppt(FILE *xmlout, opj_tcp_t *tcp) { /* For tile-part header,
/* ------------- */
void xml_out_frame_tlm(FILE* xmlout) { /* opt, main header only. May be multiple. */
void xml_out_frame_tlm(FILE* xmlout) /* opt, main header only. May be multiple. */
{
/* Compare j2k_read_tlm()... which doesn't retain anything! */
/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
/* Main header indents are 10 spaces */
@ -1811,7 +1815,8 @@ void xml_out_frame_tlm(FILE* xmlout) { /* opt, main header only. May be multipl
/* ------------- */
void xml_out_frame_plm(FILE* xmlout) { /* opt, main header only; can be used in conjunction with tile-part's PLT */
void xml_out_frame_plm(FILE* xmlout) /* opt, main header only; can be used in conjunction with tile-part's PLT */
{
/* NO-OP. PLM NOT SAVED IN DATA STRUCTURE */
/* Compare j2k_read_plm()... which doesn't retain anything! */
/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
@ -1820,7 +1825,8 @@ void xml_out_frame_plm(FILE* xmlout) { /* opt, main header only; can be used in
/* ------------- */
void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp) { /* opt, tile-part headers only; can be used in conjunction with main header's PLM */
void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp) /* opt, tile-part headers only; can be used in conjunction with main header's PLM */
{
/* NO-OP. PLT NOT SAVED IN DATA STRUCTURE */
/* Compare j2k_read_plt()... which doesn't retain anything! */
/* Tile-part header indents are 12 spaces */
@ -1828,11 +1834,14 @@ void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp) { /* opt, tile-part headers
/* ------------- */
void xml_out_frame_crg(FILE* xmlout) { /* NO-OP. CRG NOT SAVED IN DATA STRUCTURE */ /* opt, main header only; */
void xml_out_frame_crg(FILE* xmlout)
{
/* NO-OP. CRG NOT SAVED IN DATA STRUCTURE */ /* opt, main header only; */
/* Compare j2k_read_crg()... which doesn't retain anything! */
/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
#ifdef NOTYET
THIS PSEUDOCODE IMAGINES THESE EXIST: j2k_default_tcp->crg, j2k_default_tcp->crg_i, j2k_default_tcp->crg_xcrg*, j2k_default_tcp->crg_ycrg*
THIS PSEUDOCODE IMAGINES THESE EXIST:
j2k_default_tcp->crg, j2k_default_tcp->crg_i, j2k_default_tcp->crg_xcrg*, j2k_default_tcp->crg_ycrg*
(POSSIBLY DON'T NEED crg_i, CAN GET NUMBER OR COMPONENTS FROM ELSEWHERE)
if(j2k_default_tcp->crg != 1 || j2k_default_tcp->crg_i == 0)
return; /* Not present */
@ -1875,15 +1884,19 @@ void xml_out_frame_crg(FILE* xmlout) { /* NO-OP. CRG NOT SAVED IN DATA STRUCTUR
/* ------------- */
/* Regrettably from a metadata point of view, j2k_read_com() skips over any comments in main header or tile-part-header */
void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp) { /* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ /* opt in main or tile-part headers; */
void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp)
{
/* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ /* opt in main or tile-part headers; */
/* Compare j2k_read_com()... which doesn't retain anything! */
#ifdef NOTYET
char spaces[13] = " "; /* 12 spaces if tilepart*/
char* s = spaces;
if(tcp == &j2k_default_tcp) {
s++;s++; /* shorten s to 10 spaces if main */
s++;
s++; /* shorten s to 10 spaces if main */
}
THIS PSEUDOCODE IMAGINES THESE EXIST: tcp->com, tcp->com_len, tcp->com_data array
THIS PSEUDOCODE IMAGINES THESE EXIST:
tcp->com, tcp->com_len, tcp->com_data array
if(tcp->com != 1)
return; /* Not present */
@ -1893,7 +1906,8 @@ void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp) { /* NO-OP. COM NOT SAVED
#endif
}
void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s) {
void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s)
{
/* s is a string of spaces for indent */
int i;
@ -1909,7 +1923,8 @@ void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s) {
/* Define this as an even number: */
#define BYTES_PER_DUMP_LINE 40
/* Current total width for Hex and ASCII is : 11 spaces lead + (3 * BPDL) + 2 spaces + BPDL */
void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s) {
void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s)
{
/* s is a string of spaces for indent */
int i,j;
@ -1944,7 +1959,8 @@ void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s)
/* ------------- */
void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) { /* JP2 Header */
void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) /* JP2 Header */
{
/* Compare jp2_read_jp2h(opj_jp2_t * jp2_struct) */
int i;
@ -1987,8 +2003,7 @@ void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) { /* JP2 Header */
fprintf(xmlout, " <!-- IPR is 1 if frame contains an Intellectual Property box; 0 otherwise. -->\n"); /* 2 bytes */
fprintf(xmlout, " </ImageHeader>\n");
if (jp2_struct->bpc == 255)
{
if (jp2_struct->bpc == 255) {
fprintf(xmlout, " <BitsPerComponent BoxType=\"bpcc\">\n");
if(notes)
fprintf(xmlout, " <!-- Pixel depth (range 1 to 38) is low 7 bits of hex value + 1 -->\n");
@ -2029,9 +2044,7 @@ void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) { /* JP2 Header */
fprintf(xmlout, " <!-- 18: sRGB YCC (from JPEG 2000 Part II). -->\n");
fprintf(xmlout, " <!-- (Additional JPX values are defined in Part II). -->\n");
}
}
else
if(notes)
} else if(notes)
fprintf(xmlout, " <!-- PROFILE is not handled by current OpenJPEG implementation. -->\n");
/* only 1 byte is read and nothing stored */
fprintf(xmlout, " </ColourSpecification>\n");
@ -2048,15 +2061,15 @@ void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) { /* JP2 Header */
#ifdef NOTYET
IMAGE these use cp structure, extended... but we could use a new data structure instead
void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp) {
void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp)
{
/* IntellectualProperty 'jp2i' (no restrictions on location) */
int i;
IMAGE cp->jp2i, cp->jp2i_count, cp->jp2i_data (array of chars), cp->cp2i_len (array of ints)
if(cp->jp2i != 1)
return; /* Not present */
for(i = 0; i < cp->jp2i_count; i++)
{
for(i = 0; i < cp->jp2i_count; i++) {
fprintf(xmlout, " <IntellectualProperty BoxType=\"jp2i\">\n");
/* I think this can be anything, including binary, so do a dump */
/* Is it better to indent or not indent this content? Indent is better for reading, but
@ -2066,7 +2079,8 @@ void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp) {
}
}
void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp) {
void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp)
{
/* XML 'xml\040' (0x786d6c20). Can appear multiply, before or after jp2c codestreams */
IMAGE cp->xml, cp->xml_count, cp->xml_data (array of chars)
MAYBE WE DON'T NEED cp->xml_len (array of ints) IF WE ASSUME xml_data IS NULL-TERMINATED.
@ -2085,7 +2099,8 @@ void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp) {
}
}
void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp) {
void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp)
{
/* UUID 'uuid' (top level only) */
/* Part I 1.7.2 says: may appear multiply in JP2 file, anywhere except before File Type box */
/* Part III 5.2.1 says: Private extensions shall be achieved through the 'uuid' type. */

View File

@ -23,21 +23,24 @@ can be bound by the Open JPEG open-source license and disclaimer, expressed else
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting a FILE* client object
*/
void info_callback(const char *msg, void *client_data) {
void info_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[INFO] %s", msg);
}
@ -107,7 +110,8 @@ void help_display()
/* ------------- */
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
opj_dinfo_t* dinfo;
opj_event_mgr_t event_mgr; /* event manager */
@ -138,7 +142,9 @@ int main(int argc, char *argv[]) {
case 'i': /* IN file */
infile = optarg;
s = optarg;
while (*s) { s++; } /* Run to filename end */
while (*s) {
s++; /* Run to filename end */
}
s--;
S3 = *s;
s--;
@ -156,7 +162,9 @@ int main(int argc, char *argv[]) {
/* ----------------------------------------------------- */
case 'o': /* OUT file */
outfile = optarg;
while (*outfile) { outfile++; } /* Run to filename end */
while (*outfile) {
outfile++; /* Run to filename end */
}
outfile--;
S3 = *outfile;
outfile--;
@ -244,8 +252,7 @@ int main(int argc, char *argv[]) {
}
*/
len = strlen(infile);
if(infile[0] == ' ')
{
if(infile[0] == ' ') {
infile++; /* There may be a leading blank if user put space after -i */
}
@ -257,8 +264,7 @@ int main(int argc, char *argv[]) {
}
len = strlen(outfile);
if(outfile[0] == ' ')
{
if(outfile[0] == ' ') {
outfile++; /* There may be a leading blank if user put space after -o */
}
@ -289,8 +295,7 @@ int main(int argc, char *argv[]) {
movie = (opj_mj2_t*) dinfo->mj2_handle;
mj2_setup_decoder(dinfo->mj2_handle, &parameters);
if (mj2_read_struct(file, movie)) // Creating the movie structure
{
if (mj2_read_struct(file, movie)) { // Creating the movie structure
fclose(xmlout);
return 1;
}

View File

@ -50,14 +50,16 @@ Size of memory first allocated for MOOV box
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
@ -285,8 +287,7 @@ int main(int argc, char **argv)
if (c == -1)
break;
switch (c) {
case 'i': /* IN fill */
{
case 'i': { /* IN fill */
char *infile = opj_optarg;
s = opj_optarg;
while (*s) {
@ -302,8 +303,7 @@ int main(int argc, char **argv)
if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
|| (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
mj2_parameters.decod_format = YUV_DFMT;
}
else {
} else {
fprintf(stderr,
"!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
S1, S2, S3);
@ -313,8 +313,7 @@ int main(int argc, char **argv)
}
break;
/* ----------------------------------------------------- */
case 'o': /* OUT fill */
{
case 'o': { /* OUT fill */
char *outfile = opj_optarg;
while (*outfile) {
outfile++;
@ -341,8 +340,7 @@ int main(int argc, char **argv)
}
break;
/* ----------------------------------------------------- */
case 'r': /* rates rates/distorsion */
{
case 'r': { /* rates rates/distorsion */
float rate;
s = opj_optarg;
while (sscanf(s, "%f", &rate) == 1) {
@ -374,8 +372,7 @@ int main(int argc, char **argv)
break;
/* dda */
/* ----------------------------------------------------- */
case 'f': /* mod fixed_quality (before : -q) */
{
case 'f': { /* mod fixed_quality (before : -q) */
int *row = NULL, *col = NULL;
int numlayers = 0, numresolution = 0, matrix_width = 0;
@ -428,8 +425,7 @@ int main(int argc, char **argv)
sscanf(opj_optarg, "%d", &j2k_parameters->numresolution);
break;
/* ----------------------------------------------------- */
case 'c': /* precinct dimension */
{
case 'c': { /* precinct dimension */
char sep;
int res_spec = 0;
@ -441,15 +437,13 @@ int main(int argc, char **argv)
j2k_parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
}
while (sep == ',');
} while (sep == ',');
j2k_parameters->res_spec = res_spec;
}
break;
/* ----------------------------------------------------- */
case 'b': /* code-block dimension */
{
case 'b': { /* code-block dimension */
int cblockw_init = 0, cblockh_init = 0;
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
@ -464,8 +458,7 @@ int main(int argc, char **argv)
}
break;
/* ----------------------------------------------------- */
case 'p': /* progression order */
{
case 'p': { /* progression order */
char progression[5];
strncpy(progression, opj_optarg, 5);
@ -478,8 +471,7 @@ int main(int argc, char **argv)
}
break;
/* ----------------------------------------------------- */
case 's': /* subsampling factor */
{
case 's': { /* subsampling factor */
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->subsampling_dx,
&j2k_parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
@ -488,8 +480,7 @@ int main(int argc, char **argv)
}
break;
/* ----------------------------------------------------- */
case 'd': /* coordonnate of the reference grid */
{
case 'd': { /* coordonnate of the reference grid */
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->image_offset_x0,
&j2k_parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
@ -504,8 +495,7 @@ int main(int argc, char **argv)
return 0;
break;
/* ----------------------------------------------------- */
case 'P': /* POC */
{
case 'P': { /* POC */
int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
@ -548,8 +538,7 @@ int main(int argc, char **argv)
}
break;
/* ------------------------------------------------------ */
case 'R': /* ROI */
{
case 'R': { /* ROI */
if (sscanf(opj_optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
&j2k_parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
@ -558,8 +547,7 @@ int main(int argc, char **argv)
}
break;
/* ------------------------------------------------------ */
case 'T': /* Tile offset */
{
case 'T': { /* Tile offset */
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1;
@ -567,8 +555,7 @@ int main(int argc, char **argv)
}
break;
/* ------------------------------------------------------ */
case 'C': /* Add a comment */
{
case 'C': { /* Add a comment */
j2k_parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
if(j2k_parameters->cp_comment) {
strcpy(j2k_parameters->cp_comment, opj_optarg);
@ -576,8 +563,7 @@ int main(int argc, char **argv)
}
break;
/* ------------------------------------------------------ */
case 'I': /* reversible or not */
{
case 'I': { /* reversible or not */
j2k_parameters->irreversible = 1;
}
break;
@ -614,8 +600,7 @@ int main(int argc, char **argv)
"Usage: %s -i yuv-file -o mj2-file (+ options)\n",argv[0]);
return 1;
}
if(prec < 1 || prec > 16)
{
if(prec < 1 || prec > 16) {
fprintf(stderr, "Error: Depth %d must be in the range 8 .. 16\n",prec);
return 1;
}
@ -723,14 +708,10 @@ int main(int argc, char **argv)
opj_cio_close(cio);
free(buf);
for(i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++)
{
if(movie->tk[i].track_type != 0)
{
for(i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++) {
if(movie->tk[i].track_type != 0) {
fprintf(stderr, "Unable to write sound or hint tracks\n");
}
else
{
} else {
mj2_tk_t *tk;
int buflen = 0;
@ -746,14 +727,12 @@ int main(int argc, char **argv)
buflen = 2 * (tk->w * tk->h * 8);
buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));
for(sampleno = 0; sampleno < numframes; sampleno++)
{
for(sampleno = 0; sampleno < numframes; sampleno++) {
double init_time = opj_clock();
double elapsed_time;
if(yuvtoimage(tk, img, sampleno, j2k_parameters,
mj2_parameters.infile))
{
mj2_parameters.infile)) {
fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
return 1;
}

View File

@ -50,14 +50,16 @@
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
@ -65,7 +67,8 @@ static void warning_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
mj2_dparameters_t mj2_parameters; /* decompression parameters */
opj_dinfo_t* dinfo;
opj_event_mgr_t event_mgr; /* event manager */
@ -150,8 +153,7 @@ int main(int argc, char *argv[]) {
numframes = track->num_samples;
for (snum=0; snum < numframes; snum++)
{
for (snum=0; snum < numframes; snum++) {
double init_time = opj_clock();
double elapsed_time;
@ -173,20 +175,19 @@ int main(int argc, char *argv[]) {
img = opj_decode(dinfo, cio); /* Decode J2K to image */
#ifdef WANT_SYCC_TO_RGB
if(img->color_space == CLRSPC_SYCC)
{
if(img->color_space == CLRSPC_SYCC) {
color_sycc_to_rgb(img);
}
#endif
if(img->icc_profile_buf)
{
if(img->icc_profile_buf) {
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
color_apply_icc_profile(img);
#endif
free(img->icc_profile_buf);
img->icc_profile_buf = NULL; img->icc_profile_len = 0;
img->icc_profile_buf = NULL;
img->icc_profile_len = 0;
}
if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
@ -195,18 +196,15 @@ int main(int argc, char *argv[]) {
if (!imagetoyuv(img, argv[2])) /* Convert image to YUV */
return 1;
}
else if ((img->numcomps == 3) &&
} else if ((img->numcomps == 3) &&
(img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
(img->comps[2].dx == 1))/* If YUV 4:4:4 input --> to bmp */
{
(img->comps[2].dx == 1)) { /* If YUV 4:4:4 input --> to bmp */
fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
sprintf(outfilename,"output_%d.bmp",snum);
if (imagetobmp(img, outfilename)) /* Convert image to BMP */
return 1;
}
else {
} else {
fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");

View File

@ -46,21 +46,24 @@
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *client_data) {
void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *client_data) {
void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting a FILE* client object
*/
void info_callback(const char *msg, void *client_data) {
void info_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[INFO] %s", msg);
}
@ -68,7 +71,8 @@ void info_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
opj_dinfo_t* dinfo;
opj_event_mgr_t event_mgr; /* event manager */
int tnum;
@ -126,8 +130,7 @@ int main(int argc, char *argv[]) {
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
for (snum=0; snum < track->num_samples; snum++)
{
for (snum=0; snum < track->num_samples; snum++) {
sample = &track->sample[snum];
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker*/
fseek(file,sample->offset+8,SEEK_SET);

View File

@ -41,7 +41,8 @@
#include "jp2.h"
#include "mj2.h"
static int int_ceildiv(int a, int b) {
static int int_ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
@ -76,9 +77,9 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
fread(src, 1, src_len, reader);
fclose(reader);
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0)
{
free(src); return success;
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0) {
free(src);
return success;
}
memset(&dparameters, 0, sizeof(opj_dparameters_t));
@ -92,7 +93,8 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
image = opj_decode(dinfo, cio);
free(src); cio->buffer = NULL;
free(src);
cio->buffer = NULL;
opj_cio_close(cio);
if(image == NULL) goto fin;
@ -102,75 +104,59 @@ static int test_image(const char *fname, mj2_cparameters_t *cp)
cp->h = image->comps[0].h;
cp->prec = image->comps[0].prec;
if(image->numcomps > 2 )
{
if(image->numcomps > 2 ) {
if((image->comps[0].dx == 1)
&& (image->comps[1].dx == 2)
&& (image->comps[2].dx == 2)
&& (image->comps[0].dy == 1)
&& (image->comps[1].dy == 2)
&& (image->comps[2].dy == 2))/* horizontal and vertical*/
{
&& (image->comps[2].dy == 2)) { /* horizontal and vertical*/
/* Y420*/
cp->enumcs = ENUMCS_SYCC;
cp->CbCr_subsampling_dx = 2;
cp->CbCr_subsampling_dy = 2;
}
else
if((image->comps[0].dx == 1)
} else if((image->comps[0].dx == 1)
&& (image->comps[1].dx == 2)
&& (image->comps[2].dx == 2)
&& (image->comps[0].dy == 1)
&& (image->comps[1].dy == 1)
&& (image->comps[2].dy == 1))/* horizontal only*/
{
&& (image->comps[2].dy == 1)) { /* horizontal only*/
/* Y422*/
cp->enumcs = ENUMCS_SYCC;
cp->CbCr_subsampling_dx = 2;
cp->CbCr_subsampling_dy = 1;
}
else
if((image->comps[0].dx == 1)
} else if((image->comps[0].dx == 1)
&& (image->comps[1].dx == 1)
&& (image->comps[2].dx == 1)
&& (image->comps[0].dy == 1)
&& (image->comps[1].dy == 1)
&& (image->comps[2].dy == 1))
{
&& (image->comps[2].dy == 1)) {
/* Y444 or RGB */
if(image->color_space == CLRSPC_SRGB)
{
if(image->color_space == CLRSPC_SRGB) {
cp->enumcs = ENUMCS_SRGB;
/* cp->CbCr_subsampling_dx = 0; */
/* cp->CbCr_subsampling_dy = 0; */
}
else
{
} else {
cp->enumcs = ENUMCS_SYCC;
cp->CbCr_subsampling_dx = 1;
cp->CbCr_subsampling_dy = 1;
}
}
else
{
} else {
goto fin;
}
}
else
{
} else {
cp->enumcs = ENUMCS_GRAY;
/* cp->CbCr_subsampling_dx = 0; */
/* cp->CbCr_subsampling_dy = 0; */
}
if(image->icc_profile_buf)
{
if(image->icc_profile_buf) {
cp->meth = 2;
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
}
else cp->meth = 1;
free(image->icc_profile_buf);
image->icc_profile_buf = NULL;
} else cp->meth = 1;
success = 1;
fin:
@ -186,21 +172,24 @@ fin:
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting a FILE* client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[INFO] %s", msg);
}
@ -221,8 +210,7 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
fread(&buf,1,1, file);
if (buf==(char)0xff)
fread(&buf,1,1, file);
}
while (!(buf==(char)0x51));
} while (!(buf==(char)0x51));
fread(buf2,2,1,file); /* Lsiz */
len = ((buf2[0])<<8) + buf2[1];
@ -257,7 +245,8 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
free(siz_buffer);
}
static void setparams(opj_mj2_t *movie, opj_image_t *image) {
static void setparams(opj_mj2_t *movie, opj_image_t *image)
{
int i, depth_0, depth, sign;
movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
@ -271,8 +260,7 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
&& (image->comps[1].dx == 1)
&& (image->comps[2].dx == 1))
movie->tk[0].CbCr_subsampling_dx = 1;
else
if ((image->comps[0].dx == 1)
else if ((image->comps[0].dx == 1)
&& (image->comps[1].dx == 2)
&& (image->comps[2].dx == 2))
movie->tk[0].CbCr_subsampling_dx = 2;
@ -283,8 +271,7 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
&& (image->comps[1].dy == 1)
&& (image->comps[2].dy == 1))
movie->tk[0].CbCr_subsampling_dy = 1;
else
if ((image->comps[0].dy == 1)
else if ((image->comps[0].dy == 1)
&& (image->comps[1].dy == 2)
&& (image->comps[2].dy == 2))
movie->tk[0].CbCr_subsampling_dy = 2;
@ -337,8 +324,7 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
if (image->numcomps == 1)
movie->tk[0].jp2_struct.enumcs = 17; /* Grayscale */
else
if ((image->comps[0].dx == 1)
else if ((image->comps[0].dx == 1)
&& (image->comps[1].dx == 1)
&& (image->comps[2].dx == 1)
&& (image->comps[0].dy == 1)
@ -346,8 +332,7 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
&& (image->comps[2].dy == 1))
movie->tk[0].jp2_struct.enumcs = 16; /* RGB */
else
if ((image->comps[0].dx == 1)
else if ((image->comps[0].dx == 1)
&& (image->comps[1].dx == 2)
&& (image->comps[2].dx == 2)
&& (image->comps[0].dy == 1)
@ -359,7 +344,8 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) {
movie->tk[0].jp2_struct.enumcs = 0; /* Unknown profile */
}
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
opj_cinfo_t* cinfo;
opj_event_mgr_t event_mgr; /* event manager */
unsigned int snum;
@ -432,8 +418,7 @@ int main(int argc, char *argv[]) {
/* Insert each j2k codestream in a JP2C box */
snum=0;
offset = 0;
while(1)
{
while(1) {
mj2_sample_t * new_sample;
mj2_chunk_t * new_chunk;
sample = &movie->tk[0].sample[snum];
@ -443,8 +428,7 @@ int main(int argc, char *argv[]) {
if (snum==0) { /* Could not open a single codestream */
fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
return 1;
}
else { /* Tried to open a inexistant codestream */
} else { /* Tried to open a inexistant codestream */
fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
break;
}

View File

@ -184,13 +184,23 @@ class OPJViewerApp: public wxApp
public:
// class constructor
OPJViewerApp() { m_showImages = true; m_showButtons = false; }
OPJViewerApp()
{
m_showImages = true;
m_showButtons = false;
}
// other methods
bool OnInit(void);
int OnExit(void);
void SetShowImages(bool show) { m_showImages = show; }
bool ShowImages() const { return m_showImages; }
void SetShowImages(bool show)
{
m_showImages = show;
}
bool ShowImages() const
{
return m_showImages;
}
void ShowCmdLine(const wxCmdLineParser& parser);
// all the threads currently alive - as soon as the thread terminates, it's
@ -265,7 +275,8 @@ class OPJCanvas: public wxScrolledWindow
virtual void OnDraw(wxDC& dc);
void OnEvent(wxMouseEvent& event);
void WriteText(const wxString& text) {
void WriteText(const wxString& text)
{
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif //__WXGTK__
@ -299,11 +310,21 @@ class OPJMarkerData : public wxTreeItemData
public:
// class constructor
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname)
{
m_start = start;
m_length = length;
}
void ShowInfo(wxTreeCtrl *tree);
const wxChar *GetDesc1() const { return m_desc.c_str(); }
const wxChar *GetDesc2() const { return m_filestring.c_str(); }
const wxChar *GetDesc1() const
{
return m_desc.c_str();
}
const wxChar *GetDesc2() const
{
return m_filestring.c_str();
}
wxFileOffset m_start, m_length;
wxString m_desc;
@ -316,8 +337,7 @@ class OPJMarkerData : public wxTreeItemData
class OPJMarkerTree : public wxTreeCtrl
{
public:
enum
{
enum {
TreeCtrlIcon_File,
TreeCtrlIcon_FileSelected,
TreeCtrlIcon_Folder,
@ -331,7 +351,12 @@ public:
long style);
virtual ~OPJMarkerTree() {};
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
void WriteText(const wxString& text)
{
wxMutexGuiEnter();
wxLogMessage(text);
wxMutexGuiLeave();
}
wxFileName m_fname;
wxTextCtrl *m_peektextCtrl;
@ -372,9 +397,15 @@ public:
/*void DoToggleIcon(const wxTreeItemId& item);*/
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
int ImageSize(void) const { return m_imageSize; }
int ImageSize(void) const
{
return m_imageSize;
}
void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
void SetLastItem(wxTreeItemId id)
{
m_lastItem = id;
}
protected:
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
@ -541,8 +572,7 @@ enum {
// menu and control ids
enum
{
enum {
TreeTest_Quit = wxID_EXIT,
TreeTest_About = wxID_ABOUT,
TreeTest_TogButtons = wxID_HIGHEST,
@ -666,7 +696,10 @@ private:
class OPJDnDFile: public wxFileDropTarget
{
public:
OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
OPJDnDFile(OPJFrame *pOwner)
{
m_pOwner = pOwner;
}
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
private:

View File

@ -78,7 +78,8 @@ static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
==========================================================
*/
static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) {
static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio)
{
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
@ -88,7 +89,8 @@ static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) {
return OPJ_TRUE;
}
static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) {
static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio)
{
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
@ -98,7 +100,8 @@ static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) {
return OPJ_TRUE;
}
static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b)
{
if (bio->ct == 0) {
opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */
}
@ -106,7 +109,8 @@ static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
bio->buf |= b << bio->ct;
}
static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio)
{
if (bio->ct == 0) {
opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */
}
@ -120,22 +124,26 @@ static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
==========================================================
*/
opj_bio_t* opj_bio_create(void) {
opj_bio_t* opj_bio_create(void)
{
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
return bio;
}
void opj_bio_destroy(opj_bio_t *bio) {
void opj_bio_destroy(opj_bio_t *bio)
{
if(bio) {
opj_free(bio);
}
}
ptrdiff_t opj_bio_numbytes(opj_bio_t *bio) {
ptrdiff_t opj_bio_numbytes(opj_bio_t *bio)
{
return (bio->bp - bio->start);
}
void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
{
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
@ -143,7 +151,8 @@ void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
bio->ct = 8;
}
void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
{
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
@ -151,14 +160,16 @@ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
bio->ct = 0;
}
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n)
{
OPJ_UINT32 i;
for (i = n - 1; i < n; i--) {
opj_bio_putbit(bio, (v >> i) & 1);
}
}
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n)
{
OPJ_UINT32 i;
OPJ_UINT32 v;
v = 0;
@ -168,7 +179,8 @@ OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
return v;
}
OPJ_BOOL opj_bio_flush(opj_bio_t *bio) {
OPJ_BOOL opj_bio_flush(opj_bio_t *bio)
{
if (! opj_bio_byteout(bio)) {
return OPJ_FALSE;
}
@ -180,7 +192,8 @@ OPJ_BOOL opj_bio_flush(opj_bio_t *bio) {
return OPJ_TRUE;
}
OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) {
OPJ_BOOL opj_bio_inalign(opj_bio_t *bio)
{
if ((bio->buf & 0xff) == 0xff) {
if (! opj_bio_bytein(bio)) {
return OPJ_FALSE;

View File

@ -219,10 +219,8 @@ OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, op
OPJ_OFF_T org_pos;
unsigned int Scod;
for(i = 0; i < marknum; i++)
{
if( markers[i].type == J2K_MS_COD)
{
for(i = 0; i < marknum; i++) {
if( markers[i].type == J2K_MS_COD) {
org_pos = opj_stream_tell(cio);
opj_stream_seek(cio, coff+markers[i].pos+2,p_manager);

View File

@ -169,8 +169,7 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,OPJ_BOOL l
l_stream->m_status |= OPJ_STREAM_STATUS_INPUT;
l_stream->m_opj_skip = opj_stream_read_skip;
l_stream->m_opj_seek = opj_stream_read_seek;
}
else {
} else {
l_stream->m_status |= OPJ_STREAM_STATUS_OUTPUT;
l_stream->m_opj_skip = opj_stream_write_skip;
l_stream->m_opj_seek = opj_stream_write_seek;
@ -294,8 +293,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else {
} else {
/* case where we are already at the end of the buffer
so reset the m_current_data to point to the start of the
stored buffer to get ready to read from disk*/
@ -316,8 +314,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_stream->m_status |= OPJ_STREAM_STATUS_END;
/* end of stream */
return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
}
else if (p_stream->m_bytes_in_buffer < p_size) {
} else if (p_stream->m_bytes_in_buffer < p_size) {
/* not enough data */
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
@ -326,8 +323,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else {
} else {
l_read_nb_bytes += p_size;
memcpy(p_buffer,p_stream->m_current_data,p_size);
p_stream->m_current_data += p_size;
@ -335,8 +331,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
return l_read_nb_bytes;
}
}
else {
} else {
/* direct read on the dest buffer */
p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_buffer,p_size,p_stream->m_user_data);
@ -348,8 +343,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_stream->m_status |= OPJ_STREAM_STATUS_END;
/* end of stream */
return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
}
else if (p_stream->m_bytes_in_buffer < p_size) {
} else if (p_stream->m_bytes_in_buffer < p_size) {
/* not enough data */
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_current_data = p_stream->m_stored_data;
@ -357,8 +351,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_size -= p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
p_stream->m_bytes_in_buffer = 0;
}
else {
} else {
/* we have read the exact size */
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
@ -570,8 +563,7 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size
if( !(p_stream->m_seek_fn(p_size,p_stream->m_user_data)) ) {
p_stream->m_status |= OPJ_STREAM_STATUS_END;
return OPJ_FALSE;
}
else {
} else {
/* reset stream status */
p_stream->m_status &= (~OPJ_STREAM_STATUS_END);
p_stream->m_byte_offset = p_size;
@ -594,8 +586,7 @@ OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
if (! p_stream->m_seek_fn(p_size,p_stream->m_user_data)) {
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
return OPJ_FALSE;
}
else {
} else {
p_stream->m_byte_offset = p_size;
}

View File

@ -78,8 +78,7 @@ The functions in CIO.C have for goal to realize a byte input / output process.
/**
Byte input-output stream.
*/
typedef struct opj_stream_private
{
typedef struct opj_stream_private {
/**
* User data, be it files, ... The actual data depends on the type of the stream.
*/

View File

@ -193,7 +193,8 @@ static const OPJ_FLOAT64 opj_dwt_norms_real[4][10] = {
/* <summary> */
/* Forward lazy transform (horizontal). */
/* </summary> */
static void opj_dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
static void opj_dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
{
OPJ_INT32 i;
OPJ_INT32 * l_dest = b;
OPJ_INT32 * l_src = a+cas;
@ -215,7 +216,8 @@ static void opj_dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ
/* <summary> */
/* Forward lazy transform (vertical). */
/* </summary> */
static void opj_dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas) {
static void opj_dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas)
{
OPJ_INT32 i = sn;
OPJ_INT32 * l_dest = b;
OPJ_INT32 * l_src = a+cas;
@ -240,7 +242,8 @@ static void opj_dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ
/* <summary> */
/* Inverse lazy transform (horizontal). */
/* </summary> */
static void opj_dwt_interleave_h(opj_dwt_t* h, OPJ_INT32 *a) {
static void opj_dwt_interleave_h(opj_dwt_t* h, OPJ_INT32 *a)
{
OPJ_INT32 *ai = a;
OPJ_INT32 *bi = h->mem + h->cas;
OPJ_INT32 i = h->sn;
@ -260,7 +263,8 @@ static void opj_dwt_interleave_h(opj_dwt_t* h, OPJ_INT32 *a) {
/* <summary> */
/* Inverse lazy transform (vertical). */
/* </summary> */
static void opj_dwt_interleave_v(opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x) {
static void opj_dwt_interleave_v(opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x)
{
OPJ_INT32 *ai = a;
OPJ_INT32 *bi = v->mem + v->cas;
OPJ_INT32 i = v->sn;
@ -283,7 +287,8 @@ static void opj_dwt_interleave_v(opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x) {
/* <summary> */
/* Forward 5-3 wavelet transform in 1-D. */
/* </summary> */
static void opj_dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
static void opj_dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
{
OPJ_INT32 i;
if (!cas) {
@ -304,7 +309,8 @@ static void opj_dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32
/* <summary> */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
{
OPJ_INT32 i;
if (!cas) {
@ -325,14 +331,16 @@ static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT3
/* <summary> */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void opj_dwt_decode_1(opj_dwt_t *v) {
static void opj_dwt_decode_1(opj_dwt_t *v)
{
opj_dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
}
/* <summary> */
/* Forward 9-7 wavelet transform in 1-D. */
/* </summary> */
static void opj_dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
static void opj_dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
{
OPJ_INT32 i;
if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
@ -367,7 +375,8 @@ static void opj_dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_
}
}
static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize) {
static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize)
{
OPJ_INT32 p, n;
p = opj_int_floorlog2(stepsize) - 13;
n = 11 - opj_int_floorlog2(stepsize);
@ -473,7 +482,8 @@ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec)
/* <summary> */
/* Inverse 5-3 wavelet transform in 2-D. */
/* </summary> */
OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres)
{
return opj_dwt_decode_tile(tilec, numres, &opj_dwt_decode_1);
}
@ -481,7 +491,8 @@ OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
/* <summary> */
/* Get gain of 5-3 wavelet transform. */
/* </summary> */
OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient) {
OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient)
{
if (orient == 0)
return 0;
if (orient == 1 || orient == 2)
@ -492,7 +503,8 @@ OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient) {
/* <summary> */
/* Get norm of 5-3 wavelet. */
/* </summary> */
OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient) {
OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient)
{
return opj_dwt_norms[orient][level];
}
@ -507,7 +519,8 @@ OPJ_BOOL opj_dwt_encode_real(opj_tcd_tilecomp_t * tilec)
/* <summary> */
/* Get gain of 9-7 wavelet transform. */
/* </summary> */
OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient) {
OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient)
{
(void)orient;
return 0;
}
@ -515,11 +528,13 @@ OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient) {
/* <summary> */
/* Get norm of 9-7 wavelet. */
/* </summary> */
OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient) {
OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient)
{
return opj_dwt_norms_real[orient][level];
}
void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec)
{
OPJ_UINT32 numbands, bandno;
numbands = 3 * tccp->numresolutions - 2;
for (bandno = 0; bandno < numbands; bandno++) {
@ -543,7 +558,8 @@ void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
/* <summary> */
/* Determine maximum computed resolution level for inverse wavelet transform */
/* </summary> */
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) {
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i)
{
OPJ_UINT32 mr = 0;
OPJ_UINT32 w;
while( --i ) {
@ -559,7 +575,8 @@ static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_U
/* <summary> */
/* Inverse wavelet transform in 2-D. */
/* </summary> */
static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D)
{
opj_dwt_t h;
opj_dwt_t v;
@ -617,7 +634,8 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
return OPJ_TRUE;
}
static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size){
static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size)
{
OPJ_FLOAT32* restrict bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
OPJ_INT32 count = w->sn;
OPJ_INT32 i, k;
@ -635,8 +653,7 @@ static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restric
j += x;
bi[i*8 + 3] = a[j];
}
}
else {
} else {
/* Slow code path */
for(i = 0; i < count; ++i) {
OPJ_INT32 j = i;
@ -660,7 +677,8 @@ static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restric
}
}
static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read){
static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read)
{
opj_v4_t* restrict bi = v->wavelet + v->cas;
OPJ_INT32 i;
@ -678,7 +696,8 @@ static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restri
#ifdef __SSE__
static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c){
static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c)
{
__m128* restrict vw = (__m128*) w;
OPJ_INT32 i;
/* 4x unrolled loop */
@ -699,7 +718,8 @@ static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m12
}
}
void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c){
void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c)
{
__m128* restrict vl = (__m128*) l;
__m128* restrict vw = (__m128*) w;
OPJ_INT32 i;
@ -892,9 +912,12 @@ OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numr
opj_v4dwt_decode(&h);
for(k = (OPJ_INT32)rw; --k >= 0;) {
switch(j) {
case 3: aj[k+(OPJ_INT32)w*2] = h.wavelet[k].f[2];
case 2: aj[k+(OPJ_INT32)w ] = h.wavelet[k].f[1];
case 1: aj[k ] = h.wavelet[k].f[0];
case 3:
aj[k+(OPJ_INT32)w*2] = h.wavelet[k].f[2];
case 2:
aj[k+(OPJ_INT32)w ] = h.wavelet[k].f[1];
case 1:
aj[k ] = h.wavelet[k].f[0];
}
}
}

View File

@ -40,7 +40,8 @@
#ifdef OPJ_CODE_NOT_USED
#ifndef _WIN32
static char*
i2a(unsigned i, char *a, unsigned r) {
i2a(unsigned i, char *a, unsigned r)
{
if (i/r > 0) a = i2a(i/r,a,r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
return a+1;
@ -55,13 +56,13 @@ i2a(unsigned i, char *a, unsigned r) {
@return Returns a
*/
static char *
_itoa(int i, char *a, int r) {
_itoa(int i, char *a, int r)
{
r = ((r < 2) || (r > 36)) ? 10 : r;
if(i < 0) {
*a = '-';
*i2a(-i, a+1, r) = 0;
}
else *i2a(i, a, r) = 0;
} else *i2a(i, a, r) = 0;
return a;
}
@ -83,7 +84,8 @@ static void opj_default_callback (const char *msg, void *client_data)
/* ----------------------------------------------------------------------- */
OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type, const char *fmt, ...) {
OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type, const char *fmt, ...)
{
#define OPJ_MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = 00;
void * l_data = 00;

View File

@ -47,8 +47,7 @@ used for
<li>Debugging messages
</ul>
*/
typedef struct opj_event_mgr
{
typedef struct opj_event_mgr {
/** Data to call the event manager upon */
void * m_error_data;
/** Data to call the event manager upon */

View File

@ -40,15 +40,13 @@ opj_procedure_list_t * opj_procedure_list_create()
{
/* memory allocation */
opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_calloc(1,sizeof(opj_procedure_list_t));
if (! l_validation)
{
if (! l_validation) {
return 00;
}
/* initialization */
l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
l_validation->m_procedures = (opj_procedure*)opj_calloc(OPJ_VALIDATION_SIZE, sizeof(opj_procedure));
if (! l_validation->m_procedures)
{
if (! l_validation->m_procedures) {
opj_free(l_validation);
return 00;
}
@ -57,13 +55,11 @@ opj_procedure_list_t * opj_procedure_list_create()
void opj_procedure_list_destroy(opj_procedure_list_t * p_list)
{
if (! p_list)
{
if (! p_list) {
return;
}
/* initialization */
if (p_list->m_procedures)
{
if (p_list->m_procedures) {
opj_free(p_list->m_procedures);
}
opj_free(p_list);
@ -74,24 +70,20 @@ OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_l
assert(p_manager != NULL);
if (p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures)
{
if (p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures) {
opj_procedure * new_procedures;
p_validation_list->m_nb_max_procedures += OPJ_VALIDATION_SIZE;
new_procedures = (opj_procedure*)opj_realloc(
p_validation_list->m_procedures,
p_validation_list->m_nb_max_procedures * sizeof(opj_procedure));
if (! new_procedures)
{
if (! new_procedures) {
opj_free(p_validation_list->m_procedures);
p_validation_list->m_nb_max_procedures = 0;
p_validation_list->m_nb_procedures = 0;
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add a new validation procedure\n");
return OPJ_FALSE;
}
else
{
} else {
p_validation_list->m_procedures = new_procedures;
}
}

View File

@ -54,8 +54,7 @@ typedef void (*opj_procedure)(void);
/**
* A list of procedures.
*/
typedef struct opj_procedure_list
{
typedef struct opj_procedure_list {
/**
* The number of validation procedures.
*/

View File

@ -31,12 +31,14 @@
#include "opj_includes.h"
opj_image_t* opj_image_create0(void) {
opj_image_t* opj_image_create0(void)
{
opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
return image;
}
opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc)
{
OPJ_UINT32 compno;
opj_image_t *image = NULL;
@ -77,7 +79,8 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptpa
return image;
}
void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
void OPJ_CALLCONV opj_image_destroy(opj_image_t *image)
{
if(image) {
if(image->comps) {
OPJ_UINT32 compno;
@ -198,20 +201,19 @@ void opj_copy_image_header(const opj_image_t* p_image_src, opj_image_t* p_image_
memcpy( p_image_dest->icc_profile_buf,
p_image_src->icc_profile_buf,
p_image_src->icc_profile_len);
}
else
} else
p_image_dest->icc_profile_buf = NULL;
return;
}
opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc)
{
OPJ_UINT32 compno;
opj_image_t *image = 00;
image = (opj_image_t*) opj_calloc(1,sizeof(opj_image_t));
if (image)
{
if (image) {
image->color_space = clrspc;
image->numcomps = numcmpts;

View File

@ -121,8 +121,7 @@ static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations,
OPJ_UINT32 lStride = nb_compo-1;
/*initialize permutations */
for (i = 0; i < nb_compo; ++i)
{
for (i = 0; i < nb_compo; ++i) {
*tmpPermutations++ = i;
}
/* now make a pivot with column switch */
@ -232,8 +231,7 @@ static void opj_lupSolve (OPJ_FLOAT32 * pResult,
sum = 0.0;
lCurrentPtr = p_intermediate_data;
lTmpMatrix = lLineMatrix;
for (j = 1; j <= i; ++j)
{
for (j = 1; j <= i; ++j) {
/* sum += matrix[i][j-1] * y[j-1]; */
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
}

View File

@ -1281,8 +1281,7 @@ static j2k_prog_order_t j2k_prog_order_list[] = {
/**
* FIXME DOC
*/
static const OPJ_UINT32 MCT_ELEMENT_SIZE [] =
{
static const OPJ_UINT32 MCT_ELEMENT_SIZE [] = {
2,
4,
4,
@ -1291,32 +1290,28 @@ static const OPJ_UINT32 MCT_ELEMENT_SIZE [] =
typedef void (* opj_j2k_mct_function) (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
static const opj_j2k_mct_function j2k_mct_read_functions_to_float [] =
{
static const opj_j2k_mct_function j2k_mct_read_functions_to_float [] = {
opj_j2k_read_int16_to_float,
opj_j2k_read_int32_to_float,
opj_j2k_read_float32_to_float,
opj_j2k_read_float64_to_float
};
static const opj_j2k_mct_function j2k_mct_read_functions_to_int32 [] =
{
static const opj_j2k_mct_function j2k_mct_read_functions_to_int32 [] = {
opj_j2k_read_int16_to_int32,
opj_j2k_read_int32_to_int32,
opj_j2k_read_float32_to_int32,
opj_j2k_read_float64_to_int32
};
static const opj_j2k_mct_function j2k_mct_write_functions_from_float [] =
{
static const opj_j2k_mct_function j2k_mct_write_functions_from_float [] = {
opj_j2k_write_float_to_int16,
opj_j2k_write_float_to_int32,
opj_j2k_write_float_to_float,
opj_j2k_write_float_to_float64
};
typedef struct opj_dec_memory_marker_handler
{
typedef struct opj_dec_memory_marker_handler {
/** marker value */
OPJ_UINT32 id;
/** value of the state when the marker can appear */
@ -1329,8 +1324,7 @@ typedef struct opj_dec_memory_marker_handler
}
opj_dec_memory_marker_handler_t;
static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
{
static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] = {
{J2K_MS_SOT, J2K_STATE_MH | J2K_STATE_TPHSOT, opj_j2k_read_sot},
{J2K_MS_COD, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_cod},
{J2K_MS_COC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_coc},
@ -1558,7 +1552,8 @@ static void opj_j2k_write_float_to_float64 (const void * p_src_data, void * p_d
}
}
char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order)
{
j2k_prog_order_t *po;
for(po = j2k_prog_order_list; po->enum_prog != -1; po++ ) {
if(po->enum_prog == prg_order) {
@ -1597,8 +1592,7 @@ static OPJ_BOOL opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
index = step_r * p_pocs->resno0;
/* take each resolution for each poc */
for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno)
{
for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) {
OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
/* take each comp of each resolution for each poc */
@ -1697,8 +1691,7 @@ static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino, OPJ_UINT32 t
if (cp->m_specific_param.m_enc.m_tp_on == 1) {
for (i=0; i<4; ++i) {
switch (prog[i])
{
switch (prog[i]) {
/* component wise */
case 'C':
tpnum *= l_current_poc->compE;
@ -1722,8 +1715,7 @@ static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino, OPJ_UINT32 t
break;
}
}
}
else {
} else {
tpnum=1;
}
@ -2210,8 +2202,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
}
else {
} else {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
@ -2545,8 +2536,7 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k,
/* If user didn't set a number layer to decode take the max specify in the codestream. */
if (l_cp->m_specific_param.m_dec.m_layer) {
l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_layer;
}
else {
} else {
l_tcp->num_layers_to_decode = l_tcp->numlayers;
}
@ -2945,8 +2935,7 @@ static void opj_j2k_write_qcc_in_memory( opj_j2k_t *p_j2k,
/* in the case only one byte is sufficient the last byte allocated is useless -> still do -6 for available */
l_remaining_size -= 6;
}
else {
} else {
opj_write_bytes(l_current_data,l_qcc_size-2,2); /* L_QCC */
l_current_data += 2;
@ -2996,8 +2985,7 @@ static OPJ_BOOL opj_j2k_read_qcc( opj_j2k_t *p_j2k,
opj_read_bytes(p_header_data,&l_comp_no,1);
++p_header_data;
--p_header_size;
}
else {
} else {
if (p_header_size < 2) {
opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
return OPJ_FALSE;
@ -3076,8 +3064,7 @@ static OPJ_BOOL opj_j2k_write_poc( opj_j2k_t *p_j2k,
if (l_nb_comp <= 256) {
l_poc_room = 1;
}
else {
} else {
l_poc_room = 2;
}
l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
@ -3133,8 +3120,7 @@ static void opj_j2k_write_poc_in_memory( opj_j2k_t *p_j2k,
if (l_nb_comp <= 256) {
l_poc_room = 1;
}
else {
} else {
l_poc_room = 2;
}
@ -3274,8 +3260,7 @@ static OPJ_BOOL opj_j2k_read_poc ( opj_j2k_t *p_j2k,
l_nb_comp = l_image->numcomps;
if (l_nb_comp <= 256) {
l_comp_room = 1;
}
else {
} else {
l_comp_room = 2;
}
l_chunk_size = 5 + 2 * l_comp_room;
@ -3294,8 +3279,7 @@ static OPJ_BOOL opj_j2k_read_poc ( opj_j2k_t *p_j2k,
l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
l_current_poc_nb += l_old_poc_nb;
if(l_current_poc_nb >= 32)
{
if(l_current_poc_nb >= 32) {
opj_event_msg(p_manager, EVT_ERROR, "Too many POCs %d\n", l_current_poc_nb);
return OPJ_FALSE;
}
@ -3533,8 +3517,7 @@ static OPJ_BOOL opj_j2k_read_plt ( opj_j2k_t *p_j2k,
l_packet_len |= (l_tmp & 0x7f);
if (l_tmp & 0x80) {
l_packet_len <<= 7;
}
else {
} else {
/* store packet length and proceed to next packet */
l_packet_len = 0;
}
@ -3664,8 +3647,7 @@ static OPJ_BOOL opj_j2k_merge_ppm ( opj_cp_t *p_cp, opj_event_mgr_t * p_manager
}
if (l_data_size > 0U) {
do
{
do {
/* read Nppm */
if (l_data_size < 4U) {
/* clean up to be done on l_cp destruction */
@ -3723,8 +3705,7 @@ static OPJ_BOOL opj_j2k_merge_ppm ( opj_cp_t *p_cp, opj_event_mgr_t * p_manager
}
if (l_data_size > 0U) {
do
{
do {
/* read Nppm */
if (l_data_size < 4U) {
/* clean up to be done on l_cp destruction */
@ -4090,14 +4071,10 @@ static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
/* since the time taken by this function can only grow at the time */
/* PSot should be equal to zero or >=14 or <= 2^32-1 */
if ((l_tot_len !=0 ) && (l_tot_len < 14) )
{
if (l_tot_len == 12 ) /* MSD: Special case for the PHR data which are read by kakadu*/
{
if ((l_tot_len !=0 ) && (l_tot_len < 14) ) {
if (l_tot_len == 12 ) { /* MSD: Special case for the PHR data which are read by kakadu*/
opj_event_msg(p_manager, EVT_WARNING, "Empty SOT marker detected: Psot=%d.\n", l_tot_len);
}
else
{
} else {
opj_event_msg(p_manager, EVT_ERROR, "Psot value is not correct regards to the JPEG2000 norm: %d.\n", l_tot_len);
return OPJ_FALSE;
}
@ -4163,8 +4140,7 @@ static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part) {
/* Keep the size of data to skip after this marker */
p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */
}
else {
} else {
/* FIXME: need to be computed from the number of bytes remaining in the codestream */
p_j2k->m_specific_param.m_decoder.m_sot_length = 0;
}
@ -4178,16 +4154,14 @@ static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
|| (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x)
|| (l_tile_y < p_j2k->m_specific_param.m_decoder.m_start_tile_y)
|| (l_tile_y >= p_j2k->m_specific_param.m_decoder.m_end_tile_y);
}
else {
} else {
assert( p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec >= 0 );
p_j2k->m_specific_param.m_decoder.m_skip_data =
(p_j2k->m_current_tile_number != (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec);
}
/* Index */
if (p_j2k->cstr_index)
{
if (p_j2k->cstr_index) {
assert(p_j2k->cstr_index->tile_index != 00);
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number;
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno = l_current_part;
@ -4203,8 +4177,7 @@ static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\n");
return OPJ_FALSE;
}
}
else {
} else {
opj_tp_index_t *new_tp_index = (opj_tp_index_t *) opj_realloc(
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t));
if (! new_tp_index) {
@ -4215,8 +4188,7 @@ static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
}
p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = new_tp_index;
}
}
else{
} else {
/*if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index)*/ {
if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
@ -4381,8 +4353,7 @@ static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k,
// so its result will fit on OPJ_UINT32 unless we find
// a file with a single tile part of more than 4 GB...*/
p_j2k->m_specific_param.m_decoder.m_sot_length = (OPJ_UINT32)(opj_stream_get_number_byte_left(p_stream) - 2);
}
else {
} else {
/* Check to avoid pass the limit of OPJ_UINT32 */
if (p_j2k->m_specific_param.m_decoder.m_sot_length >= 2 )
p_j2k->m_specific_param.m_decoder.m_sot_length -= 2;
@ -4407,8 +4378,7 @@ static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k,
* TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...).
*/
*l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param.m_decoder.m_sot_length);
}
else {
} else {
OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length);
if (! l_new_current_data) {
opj_free(*l_current_data);
@ -4424,8 +4394,7 @@ static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k,
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tile\n");
return OPJ_FALSE;
}
}
else {
} else {
l_sot_length_pb_detected = OPJ_TRUE;
}
@ -4459,16 +4428,13 @@ static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k,
*l_current_data + *l_tile_len,
p_j2k->m_specific_param.m_decoder.m_sot_length,
p_manager);
}
else
{
} else {
l_current_read_size = 0;
}
if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
}
else {
} else {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
}
@ -4503,8 +4469,7 @@ static OPJ_BOOL opj_j2k_write_rgn(opj_j2k_t *p_j2k,
if (nb_comps <= 256) {
l_comp_room = 1;
}
else {
} else {
l_comp_room = 2;
}
@ -4595,9 +4560,10 @@ static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
l_nb_comp = l_image->numcomps;
if (l_nb_comp <= 256) {
l_comp_room = 1; }
else {
l_comp_room = 2; }
l_comp_room = 1;
} else {
l_comp_room = 2;
}
if (p_header_size != 2 + l_comp_room) {
opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
@ -4688,8 +4654,7 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
if (l_cp->m_specific_param.m_enc.m_tp_on) {
l_tp_stride_func = opj_j2k_get_tp_stride;
}
else {
} else {
l_tp_stride_func = opj_j2k_get_default_stride;
}
@ -4942,8 +4907,7 @@ static OPJ_BOOL opj_j2k_write_all_coc(
assert(p_manager != 00);
assert(p_stream != 00);
for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno)
{
for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno) {
/* cod is first component of first tile */
if (! opj_j2k_compare_coc(p_j2k, 0, compno)) {
if (! opj_j2k_write_coc(p_j2k,compno,p_stream, p_manager)) {
@ -4967,8 +4931,7 @@ static OPJ_BOOL opj_j2k_write_all_qcc(
assert(p_manager != 00);
assert(p_stream != 00);
for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno)
{
for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno) {
/* qcd is first component of first tile */
if (! opj_j2k_compare_qcc(p_j2k, 0, compno)) {
if (! opj_j2k_write_qcc(p_j2k,compno,p_stream, p_manager)) {
@ -5080,12 +5043,10 @@ static OPJ_BOOL opj_j2k_read_unk ( opj_j2k_t *p_j2k,
if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) {
opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
return OPJ_FALSE;
}
else {
} else {
if (l_marker_handler->id != J2K_MS_UNK) {
/* Add the marker to the codestream index*/
if (l_marker_handler->id != J2K_MS_SOT)
{
if (l_marker_handler->id != J2K_MS_SOT) {
OPJ_BOOL res = opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_UNK,
(OPJ_UINT32) opj_stream_tell(p_stream) - l_size_unk,
l_size_unk);
@ -5095,8 +5056,7 @@ static OPJ_BOOL opj_j2k_read_unk ( opj_j2k_t *p_j2k,
}
}
break; /* next marker is known and well located */
}
else
} else
l_size_unk += 2;
}
}
@ -5299,15 +5259,13 @@ static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k,
if (p_mcc_record->m_nb_comps > 255 ) {
l_nb_bytes_for_comp = 2;
l_mask = 0x8000;
}
else {
} else {
l_nb_bytes_for_comp = 1;
l_mask = 0;
}
l_mcc_size = p_mcc_record->m_nb_comps * 2 * l_nb_bytes_for_comp + 19;
if (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
{
if (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mcc_size);
if (! new_header_tile_data) {
opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
@ -5356,8 +5314,7 @@ static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k,
opj_write_bytes(l_current_data,p_mcc_record->m_nb_comps|l_mask,2); /* Mmcci number of output components involved and size for each component offset = 8 bits */
l_current_data+=2;
for (i=0;i<p_mcc_record->m_nb_comps;++i)
{
for (i=0; i<p_mcc_record->m_nb_comps; ++i) {
opj_write_bytes(l_current_data,i,l_nb_bytes_for_comp); /* Wmccij Component offset*/
l_current_data+=l_nb_bytes_for_comp;
}
@ -5975,7 +5932,8 @@ opj_j2k_t* opj_j2k_create_compress(void)
return l_j2k;
}
static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres){
static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres)
{
POC[0].tile = 1;
POC[0].resno0 = 0;
POC[0].compno0 = 0;
@ -6594,8 +6552,7 @@ OPJ_BOOL opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct encoding\n");
return OPJ_FALSE;
}
}
else {
} else {
if(tcp->mct==1 && image->numcomps >= 3) { /* RGB->YCC MCT is enabled */
if ((image->comps[0].dx != image->comps[1].dx) ||
(image->comps[0].dx != image->comps[2].dx) ||
@ -7517,8 +7474,7 @@ void opj_j2k_destroy (opj_j2k_t *p_j2k)
p_j2k->m_specific_param.m_decoder.m_header_data = 00;
p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
}
}
else {
} else {
if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {
opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
@ -7685,18 +7641,15 @@ static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
OPJ_UINT32 l_nb_tiles;
opj_tcp_t * l_current_tile = 00;
if (p_cp == 00)
{
if (p_cp == 00) {
return;
}
if (p_cp->tcps != 00)
{
if (p_cp->tcps != 00) {
OPJ_UINT32 i;
l_current_tile = p_cp->tcps;
l_nb_tiles = p_cp->th * p_cp->tw;
for (i = 0U; i < l_nb_tiles; ++i)
{
for (i = 0U; i < l_nb_tiles; ++i) {
opj_j2k_tcp_destroy(l_current_tile);
++l_current_tile;
}
@ -7719,8 +7672,7 @@ static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
p_cp->ppm_data = NULL; /* ppm_data belongs to the allocated buffer pointed by ppm_buffer */
opj_free(p_cp->comment);
p_cp->comment = 00;
if (! p_cp->m_is_decoder)
{
if (! p_cp->m_is_decoder) {
opj_free(p_cp->m_specific_param.m_enc.m_matrice);
p_cp->m_specific_param.m_enc.m_matrice = 00;
}
@ -7864,8 +7816,7 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
/* Try to read until the Start Of Data is detected */
while (l_current_marker != J2K_MS_SOD) {
if(opj_stream_get_number_byte_left(p_stream) == 0)
{
if(opj_stream_get_number_byte_left(p_stream) == 0) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
break;
}
@ -7958,8 +7909,7 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
/* Keep the position of the last SOT marker read */
if ( l_marker_handler->id == J2K_MS_SOT ) {
OPJ_UINT32 sot_pos = (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4 ;
if (sot_pos > p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos)
{
if (sot_pos > p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos) {
p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = sot_pos;
}
}
@ -7971,8 +7921,7 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
return OPJ_FALSE;
}
l_current_marker = J2K_MS_SOD; /* Normally we reached a SOD */
}
else {
} else {
/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
@ -8026,8 +7975,7 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
/* Read 2 bytes from buffer as the new marker ID */
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
}
}
else {
} else {
/* Indicate we will try to read a new tile-part header*/
p_j2k->m_specific_param.m_decoder.m_skip_data = 0;
p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
@ -8162,9 +8110,7 @@ OPJ_BOOL opj_j2k_decode_tile ( opj_j2k_t * p_j2k,
if (l_current_marker == J2K_MS_EOC) {
p_j2k->m_current_tile_number = 0;
p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FIXME J2K_DEC_STATE_EOC;*/
}
else if (l_current_marker != J2K_MS_SOT)
{
} else if (l_current_marker != J2K_MS_SOT) {
if(opj_stream_get_number_byte_left(p_stream) == 0) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
opj_event_msg(p_manager, EVT_WARNING, "Stream does not end with EOC\n");
@ -8269,21 +8215,18 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
l_width_dest = l_width_src;
l_offset_x1_src = 0;
}
else {
} else {
l_width_dest = l_x1_dest - (OPJ_UINT32)l_res->x0 ;
l_offset_x1_src = (OPJ_INT32)(l_width_src - l_width_dest);
}
}
else {
} else {
l_start_x_dest = 0U;
l_offset_x0_src = (OPJ_INT32)l_x0_dest - l_res->x0;
if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
l_width_dest = l_width_src - (OPJ_UINT32)l_offset_x0_src;
l_offset_x1_src = 0;
}
else {
} else {
l_width_dest = l_img_comp_dest->w ;
l_offset_x1_src = l_res->x1 - (OPJ_INT32)l_x1_dest;
}
@ -8296,21 +8239,18 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
if ( l_y1_dest >= (OPJ_UINT32)l_res->y1 ) {
l_height_dest = l_height_src;
l_offset_y1_src = 0;
}
else {
} else {
l_height_dest = l_y1_dest - (OPJ_UINT32)l_res->y0 ;
l_offset_y1_src = (OPJ_INT32)(l_height_src - l_height_dest);
}
}
else {
} else {
l_start_y_dest = 0U;
l_offset_y0_src = (OPJ_INT32)l_y0_dest - l_res->y0;
if ( l_y1_dest >= (OPJ_UINT32)l_res->y1 ) {
l_height_dest = l_height_src - (OPJ_UINT32)l_offset_y0_src;
l_offset_y1_src = 0;
}
else {
} else {
l_height_dest = l_img_comp_dest->h ;
l_offset_y1_src = l_res->y1 - (OPJ_INT32)l_y1_dest;
}
@ -8352,8 +8292,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
}*/
switch (l_size_comp) {
case 1:
{
case 1: {
OPJ_CHAR * l_src_ptr = (OPJ_CHAR*) p_data;
l_src_ptr += l_start_offset_src; /* Move to the first place where we will read*/
@ -8366,8 +8305,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
l_dest_ptr+= l_line_offset_dest; /* Move to the next place where we will write */
l_src_ptr += l_line_offset_src ; /* Move to the next place where we will read */
}
}
else {
} else {
for ( j = 0 ; j < l_height_dest ; ++j ) {
for ( k = 0 ; k < l_width_dest ; ++k) {
*(l_dest_ptr++) = (OPJ_INT32) ((*(l_src_ptr++))&0xff);
@ -8382,8 +8320,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
p_data = (OPJ_BYTE*) l_src_ptr; /* Keep the current position for the next component-part */
}
break;
case 2:
{
case 2: {
OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_data;
l_src_ptr += l_start_offset_src;
@ -8396,8 +8333,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
l_dest_ptr+= l_line_offset_dest;
l_src_ptr += l_line_offset_src ;
}
}
else {
} else {
for (j=0; j<l_height_dest; ++j) {
for (k=0; k<l_width_dest; ++k) {
*(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
@ -8412,8 +8348,7 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
p_data = (OPJ_BYTE*) l_src_ptr;
}
break;
case 4:
{
case 4: {
OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_data;
l_src_ptr += l_start_offset_src;
@ -8482,15 +8417,13 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
"Left position of the decoded area (region_x0=%d) is outside the image area (Xsiz=%d).\n",
p_start_x, l_image->x1);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_start_x < l_image->x0){
} else if ((OPJ_UINT32)p_start_x < l_image->x0) {
opj_event_msg(p_manager, EVT_WARNING,
"Left position of the decoded area (region_x0=%d) is outside the image area (XOsiz=%d).\n",
p_start_x, l_image->x0);
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
p_image->x0 = l_image->x0;
}
else {
} else {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = ((OPJ_UINT32)p_start_x - l_cp->tx0) / l_cp->tdx;
p_image->x0 = (OPJ_UINT32)p_start_x;
}
@ -8501,15 +8434,13 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
"Up position of the decoded area (region_y0=%d) is outside the image area (Ysiz=%d).\n",
p_start_y, l_image->y1);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_start_y < l_image->y0){
} else if ((OPJ_UINT32)p_start_y < l_image->y0) {
opj_event_msg(p_manager, EVT_WARNING,
"Up position of the decoded area (region_y0=%d) is outside the image area (YOsiz=%d).\n",
p_start_y, l_image->y0);
p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
p_image->y0 = l_image->y0;
}
else {
} else {
p_j2k->m_specific_param.m_decoder.m_start_tile_y = ((OPJ_UINT32)p_start_y - l_cp->ty0) / l_cp->tdy;
p_image->y0 = (OPJ_UINT32)p_start_y;
}
@ -8522,15 +8453,13 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
"Right position of the decoded area (region_x1=%d) is outside the image area (XOsiz=%d).\n",
p_end_x, l_image->x0);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_end_x > l_image->x1) {
} else if ((OPJ_UINT32)p_end_x > l_image->x1) {
opj_event_msg(p_manager, EVT_WARNING,
"Right position of the decoded area (region_x1=%d) is outside the image area (Xsiz=%d).\n",
p_end_x, l_image->x1);
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
p_image->x1 = l_image->x1;
}
else {
} else {
p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv(p_end_x - (OPJ_INT32)l_cp->tx0, (OPJ_INT32)l_cp->tdx);
p_image->x1 = (OPJ_UINT32)p_end_x;
}
@ -8548,8 +8477,7 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
p_end_y, l_image->y1);
p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
p_image->y1 = l_image->y1;
}
else{
} else {
p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv(p_end_y - (OPJ_INT32)l_cp->ty0, (OPJ_INT32)l_cp->tdy);
p_image->y1 = (OPJ_UINT32)p_end_y;
}
@ -8558,8 +8486,7 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
p_j2k->m_specific_param.m_decoder.m_discard_tiles = 1;
l_img_comp = p_image->comps;
for (it_comp=0; it_comp < p_image->numcomps; ++it_comp)
{
for (it_comp=0; it_comp < p_image->numcomps; ++it_comp) {
OPJ_INT32 l_h,l_w;
l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0, (OPJ_INT32)l_img_comp->dx);
@ -8694,8 +8621,7 @@ static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size ( opj_j2k_t *p_j2k,
if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
return 5 + l_tccp->numresolutions;
}
else {
} else {
return 5;
}
}
@ -8906,8 +8832,7 @@ static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k,
}
*p_header_size = *p_header_size - l_tccp->numresolutions;
}
else {
} else {
/* set default size for the precinct width and height */
for (i = 0; i < l_tccp->numresolutions; ++i) {
l_tccp->prcw[i] = 15;
@ -8993,8 +8918,7 @@ static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size ( opj_j2k_t *p_j2k,
if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
return 1 + l_num_bands;
}
else {
} else {
return 1 + 2*l_num_bands;
}
}
@ -9035,8 +8959,7 @@ static OPJ_BOOL opj_j2k_compare_SQcd_SQcc(opj_j2k_t *p_j2k, OPJ_UINT32 p_tile_no
return OPJ_FALSE;
}
}
if (l_tccp0->qntsty != J2K_CCP_QNTSTY_NOQNT)
{
if (l_tccp0->qntsty != J2K_CCP_QNTSTY_NOQNT) {
for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
if (l_tccp0->stepsizes[l_band_no].mant != l_tccp1->stepsizes[l_band_no].mant ) {
return OPJ_FALSE;
@ -9094,8 +9017,7 @@ static OPJ_BOOL opj_j2k_write_SQcd_SQcc( opj_j2k_t *p_j2k,
opj_write_bytes(p_data, l_expn << 3, 1); /* SPqcx_i */
++p_data;
}
}
else {
} else {
l_header_size = 1 + 2*l_num_bands;
if (*p_header_size < l_header_size) {
@ -9165,8 +9087,7 @@ static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
l_tccp->numgbits = l_tmp >> 5;
if (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
l_num_band = 1;
}
else {
} else {
l_num_band = (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) ?
(*p_header_size) :
(*p_header_size) / 2;
@ -9211,8 +9132,7 @@ static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
}
}
*p_header_size = *p_header_size - l_num_band;
}
else {
} else {
for (l_band_no = 0; l_band_no < l_num_band; l_band_no++) {
opj_read_bytes(l_current_ptr, &l_tmp ,2); /* SPqcx_i */
l_current_ptr+=2;
@ -9268,8 +9188,7 @@ static void opj_j2k_copy_tile_quantization_parameters( opj_j2k_t *p_j2k )
static void opj_j2k_dump_tile_info( opj_tcp_t * l_default_tile,OPJ_INT32 numcomps,FILE* out_stream)
{
if (l_default_tile)
{
if (l_default_tile) {
OPJ_INT32 compno;
fprintf(out_stream, "\t default tile {\n");
@ -9396,8 +9315,7 @@ static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream)
l_acc_nb_of_tile_part += cstr_index->tile_index[it_tile].nb_tps;
}
if (l_acc_nb_of_tile_part)
{
if (l_acc_nb_of_tile_part) {
fprintf(out_stream, "\t Tile index: {\n");
for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++) {
@ -9452,10 +9370,10 @@ void j2k_dump_image_header(opj_image_t* img_header, OPJ_BOOL dev_dump_flag, FILE
if (dev_dump_flag) {
fprintf(stdout, "[DEV] Dump an image_header struct {\n");
tab[0] = '\0';
}
else {
} else {
fprintf(out_stream, "Image info {\n");
tab[0] = '\t';tab[1] = '\0';
tab[0] = '\t';
tab[1] = '\0';
}
fprintf(out_stream, "%s x0=%d, y0=%d\n", tab, img_header->x0, img_header->y0);
@ -9482,7 +9400,9 @@ void j2k_dump_image_comp_header(opj_image_comp_t* comp_header, OPJ_BOOL dev_dump
fprintf(stdout, "[DEV] Dump an image_comp_header struct {\n");
tab[0] = '\0';
} else {
tab[0] = '\t';tab[1] = '\t';tab[2] = '\0';
tab[0] = '\t';
tab[1] = '\t';
tab[2] = '\0';
}
fprintf(out_stream, "%s dx=%d, dy=%d\n", tab, comp_header->dx, comp_header->dy);
@ -9521,8 +9441,7 @@ opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k)
cstr_info->m_default_tile_info.mct = l_default_tile->mct;
cstr_info->m_default_tile_info.tccp_info = (opj_tccp_info_t*) opj_calloc(cstr_info->nbcomps, sizeof(opj_tccp_info_t));
if (!cstr_info->m_default_tile_info.tccp_info)
{
if (!cstr_info->m_default_tile_info.tccp_info) {
opj_destroy_cstr_info(&cstr_info);
return NULL;
}
@ -9539,8 +9458,7 @@ opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k)
l_tccp_info->cblkh = l_tccp->cblkh;
l_tccp_info->cblksty = l_tccp->cblksty;
l_tccp_info->qmfbid = l_tccp->qmfbid;
if (l_tccp->numresolutions < OPJ_J2K_MAXRLVLS)
{
if (l_tccp->numresolutions < OPJ_J2K_MAXRLVLS) {
memcpy(l_tccp_info->prch, l_tccp->prch, l_tccp->numresolutions);
memcpy(l_tccp_info->prcw, l_tccp->prcw, l_tccp->numresolutions);
}
@ -9600,8 +9518,7 @@ opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k)
if (!p_j2k->cstr_index->tile_index) {
opj_free(l_cstr_index->tile_index);
l_cstr_index->tile_index = NULL;
}
else {
} else {
OPJ_UINT32 it_tile = 0;
for (it_tile = 0; it_tile < l_cstr_index->nb_of_tiles; it_tile++ ) {
@ -9657,8 +9574,7 @@ opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k)
memcpy( l_cstr_index->tile_index[it_tile].tp_index,
p_j2k->cstr_index->tile_index[it_tile].tp_index,
l_cstr_index->tile_index[it_tile].nb_tps * sizeof(opj_tp_index_t) );
}
else{
} else {
opj_free(l_cstr_index->tile_index[it_tile].tp_index);
l_cstr_index->tile_index[it_tile].tp_index = NULL;
}
@ -9807,8 +9723,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
l_max_data_size = 1000;
/*Allocate and initialize some elements of codestrem index if not already done*/
if( !p_j2k->cstr_index->tile_index)
{
if( !p_j2k->cstr_index->tile_index) {
if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)) {
opj_free(l_current_data);
return OPJ_FALSE;
@ -9817,8 +9732,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
/* Move into the codestream to the first SOT used to decode the desired tile */
l_tile_no_to_dec = (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec;
if (p_j2k->cstr_index->tile_index)
if(p_j2k->cstr_index->tile_index->tp_index)
{
if(p_j2k->cstr_index->tile_index->tp_index) {
if ( ! p_j2k->cstr_index->tile_index[l_tile_no_to_dec].nb_tps) {
/* the index for this tile has not been built,
* so move to the last SOT read */
@ -9827,8 +9741,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
opj_free(l_current_data);
return OPJ_FALSE;
}
}
else{
} else {
if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos+2, p_manager)) ) {
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
opj_free(l_current_data);
@ -9882,8 +9795,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
}
opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no+1);
if(l_current_tile_no == l_tile_no_to_dec)
{
if(l_current_tile_no == l_tile_no_to_dec) {
/* move into the codestream to the first SOT (FIXME or not move?)*/
if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) {
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
@ -9891,8 +9803,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
break;
}
else {
} else {
opj_event_msg(p_manager, EVT_WARNING, "Tile read, decoded and updated is not the desired one (%d vs %d).\n", l_current_tile_no+1, l_tile_no_to_dec+1);
}
@ -10002,8 +9913,7 @@ OPJ_BOOL opj_j2k_get_tile( opj_j2k_t *p_j2k,
p_image->y1 = p_j2k->m_private_image->y1;
l_img_comp = p_image->comps;
for (compno=0; compno < p_image->numcomps; ++compno)
{
for (compno=0; compno < p_image->numcomps; ++compno) {
OPJ_INT32 l_comp_x1, l_comp_y1;
l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor;
@ -10193,8 +10103,7 @@ OPJ_BOOL opj_j2k_end_compress( opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
if (! opj_j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager))
{
if (! opj_j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) {
return OPJ_FALSE;
}
@ -10288,7 +10197,8 @@ static void opj_get_tile_dimensions(opj_image_t * l_image,
OPJ_UINT32* l_offset_y,
OPJ_UINT32* l_image_width,
OPJ_UINT32* l_stride,
OPJ_UINT32* l_tile_offset) {
OPJ_UINT32* l_tile_offset)
{
OPJ_UINT32 l_remaining;
*l_size_comp = l_img_comp->prec >> 3; /* (/8) */
l_remaining = l_img_comp->prec & 7; /* (%8) */
@ -10335,8 +10245,7 @@ static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
l_src_ptr = l_img_comp->data + l_tile_offset;
switch (l_size_comp) {
case 1:
{
case 1: {
OPJ_CHAR * l_dest_ptr = (OPJ_CHAR*) p_data;
if (l_img_comp->sgnd) {
for (j=0; j<l_height; ++j) {
@ -10347,8 +10256,7 @@ static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
}
l_src_ptr += l_stride;
}
}
else {
} else {
for (j=0; j<l_height; ++j) {
for (k=0; k<l_width; ++k) {
*(l_dest_ptr) = (OPJ_CHAR)((*l_src_ptr)&0xff);
@ -10362,8 +10270,7 @@ static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
p_data = (OPJ_BYTE*) l_dest_ptr;
}
break;
case 2:
{
case 2: {
OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
if (l_img_comp->sgnd) {
for (j=0; j<l_height; ++j) {
@ -10372,8 +10279,7 @@ static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
}
l_src_ptr += l_stride;
}
}
else {
} else {
for (j=0; j<l_height; ++j) {
for (k=0; k<l_width; ++k) {
*(l_dest_ptr++) = (OPJ_INT16)((*(l_src_ptr++)) & 0xffff);
@ -10385,8 +10291,7 @@ static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
p_data = (OPJ_BYTE*) l_dest_ptr;
}
break;
case 4:
{
case 4: {
OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
for (j=0; j<l_height; ++j) {
for (k=0; k<l_width; ++k) {
@ -10595,8 +10500,7 @@ static OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k,
l_current_nb_bytes_written = 0;
l_begin_data = p_data;
if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager))
{
if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) {
return OPJ_FALSE;
}
@ -10937,8 +10841,7 @@ OPJ_BOOL opj_j2k_write_tile (opj_j2k_t * p_j2k,
if (! opj_j2k_pre_write_tile(p_j2k,p_tile_index,p_stream,p_manager)) {
opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k_pre_write_tile with tile index = %d\n", p_tile_index);
return OPJ_FALSE;
}
else {
} else {
OPJ_UINT32 j;
/* Allocate data */
for (j=0; j<p_j2k->m_tcd->image->numcomps; ++j) {

View File

@ -132,8 +132,7 @@ typedef enum J2K_STATUS {
/**
* Type of elements storing in the MCT data
*/
typedef enum MCT_ELEMENT_TYPE
{
typedef enum MCT_ELEMENT_TYPE {
MCT_TYPE_INT16 = 0, /** MCT data is stored as signed shorts*/
MCT_TYPE_INT32 = 1, /** MCT data is stored as signed integers*/
MCT_TYPE_FLOAT = 2, /** MCT data is stored as floats*/
@ -143,8 +142,7 @@ typedef enum MCT_ELEMENT_TYPE
/**
* Type of MCT array
*/
typedef enum MCT_ARRAY_TYPE
{
typedef enum MCT_ARRAY_TYPE {
MCT_TYPE_DEPENDENCY = 0,
MCT_TYPE_DECORRELATION = 1,
MCT_TYPE_OFFSET = 2
@ -173,8 +171,7 @@ typedef struct opj_stepsize {
/**
Tile-component coding parameters
*/
typedef struct opj_tccp
{
typedef struct opj_tccp {
/** coding style */
OPJ_UINT32 csty;
/** number of resolutions */
@ -209,8 +206,7 @@ opj_tccp_t;
/**
* FIXME DOC
*/
typedef struct opj_mct_data
{
typedef struct opj_mct_data {
J2K_MCT_ELEMENT_TYPE m_element_type;
J2K_MCT_ARRAY_TYPE m_array_type;
OPJ_UINT32 m_index;
@ -222,8 +218,7 @@ opj_mct_data_t;
/**
* FIXME DOC
*/
typedef struct opj_simple_mcc_decorrelation_data
{
typedef struct opj_simple_mcc_decorrelation_data {
OPJ_UINT32 m_index;
OPJ_UINT32 m_nb_comps;
opj_mct_data_t * m_decorrelation_array;
@ -232,8 +227,7 @@ typedef struct opj_simple_mcc_decorrelation_data
}
opj_simple_mcc_decorrelation_data_t;
typedef struct opj_ppx_struct
{
typedef struct opj_ppx_struct {
OPJ_BYTE* m_data; /* m_data == NULL => Zppx not read yet */
OPJ_UINT32 m_data_size;
} opj_ppx;
@ -243,8 +237,7 @@ Tile coding parameters :
this structure is used to store coding/decoding parameters common to all
tiles (information like COD, COC in main header)
*/
typedef struct opj_tcp
{
typedef struct opj_tcp {
/** coding style */
OPJ_UINT32 csty;
/** progression order */
@ -316,8 +309,7 @@ typedef struct opj_tcp
typedef struct opj_encoding_param
{
typedef struct opj_encoding_param {
/** Maximum rate for each component. If == 0, component size limitation is not considered */
OPJ_UINT32 m_max_comp_size;
/** Position of tile part flag in progression order*/
@ -337,8 +329,7 @@ typedef struct opj_encoding_param
}
opj_encoding_param_t;
typedef struct opj_decoding_param
{
typedef struct opj_decoding_param {
/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
OPJ_UINT32 m_reduce;
/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
@ -350,8 +341,7 @@ opj_decoding_param_t;
/**
* Coding parameters
*/
typedef struct opj_cp
{
typedef struct opj_cp {
/** Size of the image in bits*/
/*int img_size;*/
/** Rsiz*/
@ -399,8 +389,7 @@ typedef struct opj_cp
/** tile coding parameters */
opj_tcp_t *tcps;
union
{
union {
opj_decoding_param_t m_dec;
opj_encoding_param_t m_enc;
}
@ -460,8 +449,7 @@ typedef struct opj_cp
} opj_cp_t;
typedef struct opj_j2k_dec
{
typedef struct opj_j2k_dec {
/** locate in which part of the codestream the decoder is (main header, tile header, end) */
OPJ_UINT32 m_state;
/**
@ -506,8 +494,7 @@ typedef struct opj_j2k_dec
} opj_j2k_dec_t;
typedef struct opj_j2k_enc
{
typedef struct opj_j2k_enc {
/** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */
@ -553,14 +540,12 @@ struct opj_tcd;
/**
JPEG-2000 codestream reader/writer
*/
typedef struct opj_j2k
{
typedef struct opj_j2k {
/* J2K codestream is decoded*/
OPJ_BOOL m_is_decoder;
/* FIXME DOC*/
union
{
union {
opj_j2k_dec_t m_decoder;
opj_j2k_enc_t m_encoder;
}

View File

@ -410,15 +410,13 @@ static const opj_jp2_header_handler_t * opj_jp2_img_find_handler (OPJ_UINT32 p_i
*/
static const opj_jp2_header_handler_t * opj_jp2_find_handler (OPJ_UINT32 p_id );
static const opj_jp2_header_handler_t jp2_header [] =
{
static const opj_jp2_header_handler_t jp2_header [] = {
{JP2_JP,opj_jp2_read_jp},
{JP2_FTYP,opj_jp2_read_ftyp},
{JP2_JP2H,opj_jp2_read_jp2h}
};
static const opj_jp2_header_handler_t jp2_img_header [] =
{
static const opj_jp2_header_handler_t jp2_img_header [] = {
{JP2_IHDR,opj_jp2_read_ihdr},
{JP2_COLR,opj_jp2_read_colr},
{JP2_BPCC,opj_jp2_read_bpcc},
@ -481,8 +479,7 @@ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
opj_read_bytes(l_data_header,&(box->length), 4);
opj_read_bytes(l_data_header+4,&(box->type), 4);
if(box->length == 0)/* last box */
{
if(box->length == 0) { /* last box */
const OPJ_OFF_T bleft = opj_stream_get_number_byte_left(cio);
if (bleft > (OPJ_OFF_T)(0xFFFFFFFFU - 8U)) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
@ -519,7 +516,8 @@ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
}
#if 0
static void jp2_write_url(opj_cio_t *cio, char *Idx_file) {
static void jp2_write_url(opj_cio_t *cio, char *Idx_file)
{
OPJ_UINT32 i;
opj_jp2_box_t box;
@ -806,7 +804,8 @@ static OPJ_BYTE * opj_jp2_write_colr( opj_jp2_t *jp2,
++l_current_colr_ptr;
if (jp2->meth == 1) { /* Meth value is restricted to 1 or 2 (Table I.9 of part 1) */
opj_write_bytes(l_current_colr_ptr, jp2->enumcs,4); } /* EnumCS */
opj_write_bytes(l_current_colr_ptr, jp2->enumcs,4);
} /* EnumCS */
else {
if (jp2->meth == 2) { /* ICC profile */
OPJ_UINT32 i;
@ -830,7 +829,8 @@ static void opj_jp2_free_pclr(opj_jp2_color_t *color)
if(color->jp2_pclr->cmap) opj_free(color->jp2_pclr->cmap);
opj_free(color->jp2_pclr); color->jp2_pclr = NULL;
opj_free(color->jp2_pclr);
color->jp2_pclr = NULL;
}
static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *p_manager)
@ -863,8 +863,7 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
/* issue 397 */
/* ISO 15444-1 states that if cdef is present, it shall contain a complete list of channel definitions. */
while (nr_channels > 0)
{
while (nr_channels > 0) {
for(i = 0; i < n; ++i) {
if ((OPJ_UINT32)info[i].cn == (nr_channels - 1U)) {
break;
@ -905,18 +904,15 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
if (pcol >= nr_channels) {
opj_event_msg(p_manager, EVT_ERROR, "Invalid component/palette index for direct mapping %d.\n", pcol);
is_sane = OPJ_FALSE;
}
else if (pcol_usage[pcol] && cmap[i].mtyp == 1) {
} else if (pcol_usage[pcol] && cmap[i].mtyp == 1) {
opj_event_msg(p_manager, EVT_ERROR, "Component %d is mapped twice.\n", pcol);
is_sane = OPJ_FALSE;
}
else if (cmap[i].mtyp == 0 && cmap[i].pcol != 0) {
} else if (cmap[i].mtyp == 0 && cmap[i].pcol != 0) {
/* I.5.3.5 PCOL: If the value of the MTYP field for this channel is 0, then
* the value of this field shall be 0. */
opj_event_msg(p_manager, EVT_ERROR, "Direct use at #%d however pcol=%d.\n", i, pcol);
is_sane = OPJ_FALSE;
}
else
} else
pcol_usage[pcol] = OPJ_TRUE;
}
/* verify that all components are targeted at least once */
@ -979,7 +975,8 @@ 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) {
@ -1008,7 +1005,8 @@ static void opj_jp2_apply_pclr(opj_image_t *image, opj_jp2_color_t *color)
for(i = 0; i < nr_channels; ++i) {
/* Palette mapping: */
cmp = cmap[i].cmp; pcol = cmap[i].pcol;
cmp = cmap[i].cmp;
pcol = cmap[i].pcol;
src = old_comps[cmp].data;
assert( src );
max = new_comps[pcol].w * new_comps[pcol].h;
@ -1021,14 +1019,14 @@ static void opj_jp2_apply_pclr(opj_image_t *image, opj_jp2_color_t *color)
for(j = 0; j < max; ++j) {
dst[j] = src[j];
}
}
else {
} else {
assert( i == pcol );
dst = new_comps[pcol].data;
assert( dst );
for(j = 0; j < max; ++j) {
/* The index */
if((k = src[j]) < 0) k = 0; else if(k > top_k) k = top_k;
if((k = src[j]) < 0) k = 0;
else if(k > top_k) k = top_k;
/* The colour */
dst[j] = (OPJ_INT32)entries[k * nr_channels + pcol];
@ -1098,22 +1096,19 @@ static OPJ_BOOL opj_jp2_read_pclr( opj_jp2_t *jp2,
if (!entries)
return OPJ_FALSE;
channel_size = (OPJ_BYTE*) opj_malloc(nr_channels);
if (!channel_size)
{
if (!channel_size) {
opj_free(entries);
return OPJ_FALSE;
}
channel_sign = (OPJ_BYTE*) opj_malloc(nr_channels);
if (!channel_sign)
{
if (!channel_sign) {
opj_free(entries);
opj_free(channel_size);
return OPJ_FALSE;
}
jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t));
if (!jp2_pclr)
{
if (!jp2_pclr) {
opj_free(entries);
opj_free(channel_size);
opj_free(channel_sign);
@ -1224,33 +1219,28 @@ static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_e
info = color->jp2_cdef->info;
n = color->jp2_cdef->n;
for(i = 0; i < n; ++i)
{
for(i = 0; i < n; ++i) {
/* WATCH: acn = asoc - 1 ! */
asoc = info[i].asoc;
cn = info[i].cn;
if( cn >= image->numcomps)
{
if( cn >= image->numcomps) {
opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: cn=%d, numcomps=%d\n", cn, image->numcomps);
continue;
}
if(asoc == 0 || asoc == 65535)
{
if(asoc == 0 || asoc == 65535) {
image->comps[cn].alpha = info[i].typ;
continue;
}
acn = (OPJ_UINT16)(asoc - 1);
if( acn >= image->numcomps )
{
if( acn >= image->numcomps ) {
opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: acn=%d, numcomps=%d\n", acn, image->numcomps);
continue;
}
/* Swap only if color channel */
if((cn != acn) && (info[i].typ == 0))
{
if((cn != acn) && (info[i].typ == 0)) {
opj_image_comp_t saved;
OPJ_UINT16 j;
@ -1259,12 +1249,10 @@ static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_e
memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t));
/* Swap channels in following channel definitions, don't bother with j <= i that are already processed */
for (j = (OPJ_UINT16)(i + 1U); j < n ; ++j)
{
for (j = (OPJ_UINT16)(i + 1U); j < n ; ++j) {
if (info[j].cn == cn) {
info[j].cn = acn;
}
else if (info[j].cn == acn) {
} else if (info[j].cn == acn) {
info[j].cn = cn;
}
/* asoc is related to color index. Do not update. */
@ -1276,7 +1264,8 @@ static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_e
if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info);
opj_free(color->jp2_cdef); color->jp2_cdef = NULL;
opj_free(color->jp2_cdef);
color->jp2_cdef = NULL;
}/* jp2_apply_cdef() */
@ -1323,8 +1312,7 @@ static OPJ_BOOL opj_jp2_read_cdef( opj_jp2_t * jp2,
return OPJ_FALSE;
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
if(!jp2->color.jp2_cdef)
{
if(!jp2->color.jp2_cdef) {
opj_free(cdef_info);
return OPJ_FALSE;
}
@ -1398,8 +1386,7 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
p_colr_header_data += 4;
if(jp2->enumcs == 14)/* CIELab */
{
if(jp2->enumcs == 14) { /* CIELab */
OPJ_UINT32 *cielab;
OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
@ -1411,8 +1398,7 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
il = 0x00443530; /* D50 */
cielab[1] = 0x44454600;/* DEF */
if(p_colr_header_size == 35)
{
if(p_colr_header_size == 35) {
opj_read_bytes(p_colr_header_data, &rl, 4);
p_colr_header_data += 4;
opj_read_bytes(p_colr_header_data, &ol, 4);
@ -1429,44 +1415,41 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
p_colr_header_data += 4;
cielab[1] = 0;
}
else if(p_colr_header_size != 7)
{
} else if(p_colr_header_size != 7) {
opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (CIELab, bad size: %d)\n", p_colr_header_size);
}
cielab[2] = rl; cielab[4] = ra; cielab[6] = rb;
cielab[3] = ol; cielab[5] = oa; cielab[7] = ob;
cielab[2] = rl;
cielab[4] = ra;
cielab[6] = rb;
cielab[3] = ol;
cielab[5] = oa;
cielab[7] = ob;
cielab[8] = il;
jp2->color.icc_profile_buf = (OPJ_BYTE*)cielab;
jp2->color.icc_profile_len = 0;
}
jp2->color.jp2_has_colr = 1;
}
else if (jp2->meth == 2) {
} else if (jp2->meth == 2) {
/* ICC profile */
OPJ_INT32 it_icc_value = 0;
OPJ_INT32 icc_len = (OPJ_INT32)p_colr_header_size - 3;
jp2->color.icc_profile_len = (OPJ_UINT32)icc_len;
jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_calloc(1,(size_t)icc_len);
if (!jp2->color.icc_profile_buf)
{
if (!jp2->color.icc_profile_buf) {
jp2->color.icc_profile_len = 0;
return OPJ_FALSE;
}
for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value)
{
for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value) {
opj_read_bytes(p_colr_header_data,&l_value,1); /* icc values */
++p_colr_header_data;
jp2->color.icc_profile_buf[it_icc_value] = (OPJ_BYTE) l_value;
}
jp2->color.jp2_has_colr = 1;
}
else if (jp2->meth > 2)
{
} else if (jp2->meth > 2) {
/* ISO/IEC 15444-1:2004 (E), Table I.9 Legal METH values:
conforming JP2 reader shall ignore the entire Colour Specification box.*/
opj_event_msg(p_manager, EVT_INFO, "COLR BOX meth value is not a regular value (%d), "
@ -1559,8 +1542,7 @@ static OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2,
l_writers[0].handler = opj_jp2_write_ihdr;
l_writers[1].handler = opj_jp2_write_bpcc;
l_writers[2].handler = opj_jp2_write_colr;
}
else {
} else {
l_nb_pass = 2;
l_writers[0].handler = opj_jp2_write_ihdr;
l_writers[1].handler = opj_jp2_write_colr;
@ -1674,8 +1656,7 @@ static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
}
l_result = (opj_stream_write_data(cio,l_ftyp_data,l_ftyp_size,p_manager) == l_ftyp_size);
if (! l_result)
{
if (! l_result) {
opj_event_msg(p_manager, EVT_ERROR, "Error while writing ftyp data to stream\n");
}
@ -1846,8 +1827,7 @@ OPJ_BOOL opj_jp2_setup_encoder( opj_jp2_t *jp2,
if(image->icc_profile_len) {
jp2->meth = 2;
jp2->enumcs = 0;
}
else {
} else {
jp2->meth = 1;
if (image->color_space == 1)
jp2->enumcs = 16; /* sRGB as defined by IEC 61966-2-1 */
@ -2005,8 +1985,7 @@ static OPJ_BOOL opj_jp2_setup_end_header_writing (opj_jp2_t *jp2, opj_event_mgr_
}
/* DEVELOPER CORNER, add your custom procedures */
#ifdef USE_JPIP
if( jp2->jpip_on )
{
if( jp2->jpip_on ) {
if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_cidx, p_manager)) {
return OPJ_FALSE;
}
@ -2118,14 +2097,12 @@ static OPJ_BOOL opj_jp2_read_header_procedure( opj_jp2_t *jp2,
jp2->jp2_state |= JP2_STATE_CODESTREAM;
opj_free(l_current_data);
return OPJ_TRUE;
}
else {
} else {
opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n");
opj_free(l_current_data);
return OPJ_FALSE;
}
}
else if (box.length == 0) {
} else if (box.length == 0) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
opj_free(l_current_data);
return OPJ_FALSE;
@ -2186,8 +2163,7 @@ static OPJ_BOOL opj_jp2_read_header_procedure( opj_jp2_t *jp2,
opj_free(l_current_data);
return OPJ_FALSE;
}
}
else {
} else {
if (!(jp2->jp2_state & JP2_STATE_SIGNATURE)) {
opj_event_msg(p_manager, EVT_ERROR, "Malformed JP2 file format: first box must be JPEG 2000 signature box\n");
opj_free(l_current_data);
@ -2308,8 +2284,7 @@ static const opj_jp2_header_handler_t * opj_jp2_find_handler (OPJ_UINT32 p_id)
static const opj_jp2_header_handler_t * opj_jp2_img_find_handler (OPJ_UINT32 p_id)
{
OPJ_UINT32 i, l_handler_size = sizeof(jp2_img_header) / sizeof(opj_jp2_header_handler_t);
for (i=0;i<l_handler_size;++i)
{
for (i=0; i<l_handler_size; ++i) {
if (jp2_img_header[i].id == p_id) {
return &jp2_img_header[i];
}
@ -2423,8 +2398,7 @@ static OPJ_BOOL opj_jp2_read_ftyp( opj_jp2_t *jp2,
}
}
for (i = 0; i < jp2->numcl; ++i)
{
for (i = 0; i < jp2->numcl; ++i) {
opj_read_bytes(p_header_data,&jp2->cl[i],4); /* CLi */
p_header_data += 4;
}
@ -2525,8 +2499,7 @@ static OPJ_BOOL opj_jp2_read_jp2h( opj_jp2_t *jp2,
if (! l_current_handler->handler(jp2,p_header_data,l_current_data_size,p_manager)) {
return OPJ_FALSE;
}
}
else {
} else {
jp2->jp2_img_state |= JP2_IMG_STATE_UNKNOWN;
}
@ -2606,8 +2579,7 @@ static OPJ_BOOL opj_jp2_read_boxhdr_char( opj_jp2_box_t *box,
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
return OPJ_FALSE;
}
}
else if (box->length == 0) {
} else if (box->length == 0) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
return OPJ_FALSE;
}
@ -2918,8 +2890,7 @@ opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder)
/* create the J2K codec */
if (! p_is_decoder) {
jp2->j2k = opj_j2k_create_compress();
}
else {
} else {
jp2->j2k = opj_j2k_create_decompress();
}

View File

@ -70,8 +70,7 @@
/* ----------------------------------------------------------------------- */
typedef enum
{
typedef enum {
JP2_STATE_NONE = 0x0,
JP2_STATE_SIGNATURE = 0x1,
JP2_STATE_FILE_TYPE = 0x2,
@ -82,8 +81,7 @@ typedef enum
}
JP2_STATE;
typedef enum
{
typedef enum {
JP2_IMG_STATE_NONE = 0x0,
JP2_IMG_STATE_UNKNOWN = 0x7fffffff
}
@ -92,16 +90,14 @@ JP2_IMG_STATE;
/**
Channel description: channel index, type, association
*/
typedef struct opj_jp2_cdef_info
{
typedef struct opj_jp2_cdef_info {
OPJ_UINT16 cn, typ, asoc;
} opj_jp2_cdef_info_t;
/**
Channel descriptions and number of descriptions
*/
typedef struct opj_jp2_cdef
{
typedef struct opj_jp2_cdef {
opj_jp2_cdef_info_t *info;
OPJ_UINT16 n;
} opj_jp2_cdef_t;
@ -109,8 +105,7 @@ typedef struct opj_jp2_cdef
/**
Component mappings: channel index, mapping type, palette index
*/
typedef struct opj_jp2_cmap_comp
{
typedef struct opj_jp2_cmap_comp {
OPJ_UINT16 cmp;
OPJ_BYTE mtyp, pcol;
} opj_jp2_cmap_comp_t;
@ -118,8 +113,7 @@ typedef struct opj_jp2_cmap_comp
/**
Palette data: table entries, palette columns
*/
typedef struct opj_jp2_pclr
{
typedef struct opj_jp2_pclr {
OPJ_UINT32 *entries;
OPJ_BYTE *channel_sign;
OPJ_BYTE *channel_size;
@ -131,8 +125,7 @@ typedef struct opj_jp2_pclr
/**
Collector for ICC profile, palette, component mapping, channel description
*/
typedef struct opj_jp2_color
{
typedef struct opj_jp2_color {
OPJ_BYTE *icc_profile_buf;
OPJ_UINT32 icc_profile_len;
@ -153,8 +146,7 @@ typedef struct opj_jp2_comps {
/**
JPEG-2000 file format reader/writer
*/
typedef struct opj_jp2
{
typedef struct opj_jp2 {
/** handle to the J2K codec */
opj_j2k_t *j2k;
/** list of validation procedures */
@ -207,8 +199,7 @@ typedef struct opj_jp2_box {
OPJ_INT32 init_pos;
} opj_jp2_box_t;
typedef struct opj_jp2_header_handler
{
typedef struct opj_jp2_header_handler {
/* marker value */
OPJ_UINT32 id;
/* action linked to the marker */
@ -220,8 +211,7 @@ typedef struct opj_jp2_header_handler
opj_jp2_header_handler_t;
typedef struct opj_jp2_img_header_writer_handler
{
typedef struct opj_jp2_img_header_writer_handler {
/* action to perform */
OPJ_BYTE* (*handler) (opj_jp2_t *jp2, OPJ_UINT32 * p_data_size);
/* result of the action : data */

View File

@ -201,7 +201,8 @@ void opj_mct_decode(
/* <summary> */
/* Get norm of basis function of reversible MCT. */
/* </summary> */
OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) {
OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno)
{
return opj_mct_norms[compno];
}
@ -435,7 +436,8 @@ void opj_mct_decode_real(
/* <summary> */
/* Get norm of basis function of irreversible MCT. */
/* </summary> */
OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno) {
OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno)
{
return opj_mct_norms_real[compno];
}

View File

@ -202,7 +202,8 @@ static opj_mqc_state_t mqc_states[47 * 2] = {
==========================================================
*/
static void opj_mqc_byteout(opj_mqc_t *mqc) {
static void opj_mqc_byteout(opj_mqc_t *mqc)
{
if (*mqc->bp == 0xff) {
mqc->bp++;
*mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
@ -232,7 +233,8 @@ static void opj_mqc_byteout(opj_mqc_t *mqc) {
}
}
static void opj_mqc_renorme(opj_mqc_t *mqc) {
static void opj_mqc_renorme(opj_mqc_t *mqc)
{
do {
mqc->a <<= 1;
mqc->c <<= 1;
@ -243,7 +245,8 @@ static void opj_mqc_renorme(opj_mqc_t *mqc) {
} while ((mqc->a & 0x8000) == 0);
}
static void opj_mqc_codemps(opj_mqc_t *mqc) {
static void opj_mqc_codemps(opj_mqc_t *mqc)
{
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->a & 0x8000) == 0) {
if (mqc->a < (*mqc->curctx)->qeval) {
@ -258,7 +261,8 @@ static void opj_mqc_codemps(opj_mqc_t *mqc) {
}
}
static void opj_mqc_codelps(opj_mqc_t *mqc) {
static void opj_mqc_codelps(opj_mqc_t *mqc)
{
mqc->a -= (*mqc->curctx)->qeval;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->c += (*mqc->curctx)->qeval;
@ -269,7 +273,8 @@ static void opj_mqc_codelps(opj_mqc_t *mqc) {
opj_mqc_renorme(mqc);
}
static void opj_mqc_setbits(opj_mqc_t *mqc) {
static void opj_mqc_setbits(opj_mqc_t *mqc)
{
OPJ_UINT32 tempc = mqc->c + mqc->a;
mqc->c |= 0xffff;
if (mqc->c >= tempc) {
@ -277,7 +282,8 @@ static void opj_mqc_setbits(opj_mqc_t *mqc) {
}
}
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) {
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc)
{
OPJ_INT32 d;
if (mqc->a < (*mqc->curctx)->qeval) {
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
@ -290,7 +296,8 @@ static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) {
return d;
}
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) {
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc)
{
OPJ_INT32 d;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->a = (*mqc->curctx)->qeval;
@ -306,14 +313,16 @@ static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) {
}
#ifdef MQC_PERF_OPT
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) {
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
{
unsigned int i = *((unsigned int *) mqc->bp);
mqc->c += i & 0xffff00;
mqc->ct = i & 0x0f;
mqc->bp += (i >> 2) & 0x04;
}
#else
static void opj_mqc_bytein(opj_mqc_t *const mqc) {
static void opj_mqc_bytein(opj_mqc_t *const mqc)
{
if (mqc->bp != mqc->end) {
OPJ_UINT32 c;
if (mqc->bp + 1 != mqc->end) {
@ -342,7 +351,8 @@ static void opj_mqc_bytein(opj_mqc_t *const mqc) {
}
#endif
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) {
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc)
{
do {
if (mqc->ct == 0) {
opj_mqc_bytein(mqc);
@ -359,7 +369,8 @@ static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) {
==========================================================
*/
opj_mqc_t* opj_mqc_create(void) {
opj_mqc_t* opj_mqc_create(void)
{
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
#ifdef MQC_PERF_OPT
if (mqc) {
@ -369,7 +380,8 @@ opj_mqc_t* opj_mqc_create(void) {
return mqc;
}
void opj_mqc_destroy(opj_mqc_t *mqc) {
void opj_mqc_destroy(opj_mqc_t *mqc)
{
if(mqc) {
#ifdef MQC_PERF_OPT
if (mqc->buffer) {
@ -380,7 +392,8 @@ void opj_mqc_destroy(opj_mqc_t *mqc) {
}
}
OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc) {
OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc)
{
const ptrdiff_t diff = mqc->bp - mqc->start;
#if 0
assert( diff <= 0xffffffff && diff >= 0 ); /* UINT32_MAX */
@ -388,7 +401,8 @@ OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc) {
return (OPJ_UINT32)diff;
}
void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp)
{
/* TODO MSD: need to take a look to the v2 version */
opj_mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
@ -401,7 +415,8 @@ void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
mqc->start = bp;
}
void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) {
void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d)
{
if ((*mqc->curctx)->mps == d) {
opj_mqc_codemps(mqc);
} else {
@ -409,7 +424,8 @@ void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) {
}
}
void opj_mqc_flush(opj_mqc_t *mqc) {
void opj_mqc_flush(opj_mqc_t *mqc)
{
opj_mqc_setbits(mqc);
mqc->c <<= mqc->ct;
opj_mqc_byteout(mqc);
@ -421,7 +437,8 @@ void opj_mqc_flush(opj_mqc_t *mqc) {
}
}
void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) {
void opj_mqc_bypass_init_enc(opj_mqc_t *mqc)
{
mqc->c = 0;
mqc->ct = 8;
/*if (*mqc->bp == 0xff) {
@ -429,7 +446,8 @@ void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) {
} */
}
void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) {
void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d)
{
mqc->ct--;
mqc->c = mqc->c + (d << mqc->ct);
if (mqc->ct == 0) {
@ -443,7 +461,8 @@ void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) {
}
}
OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc) {
OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc)
{
OPJ_BYTE bit_padding;
bit_padding = 0;
@ -463,14 +482,16 @@ OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc) {
return 1;
}
void opj_mqc_reset_enc(opj_mqc_t *mqc) {
void opj_mqc_reset_enc(opj_mqc_t *mqc)
{
opj_mqc_resetstates(mqc);
opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
}
OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc) {
OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc)
{
OPJ_UINT32 correction = 1;
/* <flush part> */
@ -486,7 +507,8 @@ OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc) {
return correction;
}
void opj_mqc_restart_init_enc(opj_mqc_t *mqc) {
void opj_mqc_restart_init_enc(opj_mqc_t *mqc)
{
/* <Re-init part> */
opj_mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
@ -498,7 +520,8 @@ void opj_mqc_restart_init_enc(opj_mqc_t *mqc) {
}
}
void opj_mqc_erterm_enc(opj_mqc_t *mqc) {
void opj_mqc_erterm_enc(opj_mqc_t *mqc)
{
OPJ_INT32 k = (OPJ_INT32)(11 - mqc->ct + 1);
while (k > 0) {
@ -513,7 +536,8 @@ void opj_mqc_erterm_enc(opj_mqc_t *mqc) {
}
}
void opj_mqc_segmark_enc(opj_mqc_t *mqc) {
void opj_mqc_segmark_enc(opj_mqc_t *mqc)
{
OPJ_UINT32 i;
opj_mqc_setcurctx(mqc, 18);
@ -522,7 +546,8 @@ void opj_mqc_segmark_enc(opj_mqc_t *mqc) {
}
}
OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len)
{
opj_mqc_setcurctx(mqc, 0);
mqc->start = bp;
mqc->end = bp + len;
@ -581,7 +606,8 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
return OPJ_TRUE;
}
OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) {
OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc)
{
OPJ_INT32 d;
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
@ -600,14 +626,16 @@ OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) {
return d;
}
void opj_mqc_resetstates(opj_mqc_t *mqc) {
void opj_mqc_resetstates(opj_mqc_t *mqc)
{
OPJ_UINT32 i;
for (i = 0; i < MQC_NUMCTXS; i++) {
mqc->ctxs[i] = mqc_states;
}
}
void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob) {
void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob)
{
mqc->ctxs[ctxno] = &mqc_states[msb + (OPJ_UINT32)(prob << 1)];
}

View File

@ -132,7 +132,8 @@ static OPJ_BOOL opj_seek_from_file (OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
#ifdef _WIN32
#ifndef OPJ_STATIC
BOOL APIENTRY
DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
OPJ_ARG_NOT_USED(lpReserved);
OPJ_ARG_NOT_USED(hModule);
@ -154,7 +155,8 @@ DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version(void) {
const char* OPJ_CALLCONV opj_version(void)
{
return OPJ_PACKAGE_VERSION;
}
@ -334,7 +336,8 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
return (opj_codec_t*) l_codec;
}
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters)
{
if(parameters) {
memset(parameters, 0, sizeof(opj_dparameters_t));
/* default decoding parameters */
@ -631,7 +634,8 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
return (opj_codec_t*) l_codec;
}
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters)
{
if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */
@ -843,8 +847,7 @@ void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)
if (l_codec->is_decompressor) {
l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec);
}
else {
} else {
l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec);
}
@ -882,7 +885,8 @@ opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec)
return NULL;
}
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info) {
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info)
{
if (cstr_info) {
if ((*cstr_info)->m_default_tile_info.tccp_info) {
@ -935,7 +939,8 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (
return NULL;
}
if(p_is_read_stream) mode = "rb"; else mode = "wb";
if(p_is_read_stream) mode = "rb";
else mode = "wb";
p_file = fopen(fname, mode);

View File

@ -855,8 +855,7 @@ typedef struct opj_codestream_info {
/**
* Tile-component coding parameters information
*/
typedef struct opj_tccp_info
{
typedef struct opj_tccp_info {
/** component index */
OPJ_UINT32 compno;
/** coding style */

View File

@ -39,7 +39,8 @@
#include <sys/times.h>
#endif /* _WIN32 */
OPJ_FLOAT64 opj_clock(void) {
OPJ_FLOAT64 opj_clock(void)
{
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;

View File

@ -39,16 +39,13 @@
/**
* Main codec handler used for compression or decompression.
*/
typedef struct opj_codec_private
{
typedef struct opj_codec_private {
/** FIXME DOC */
union
{
union {
/**
* Decompression handler.
*/
struct opj_decompression
{
struct opj_decompression {
/** Main header reading function handler */
OPJ_BOOL (*opj_read_header) ( struct opj_stream_private * cio,
void * p_codec,
@ -118,8 +115,7 @@ typedef struct opj_codec_private
/**
* Compression handler. FIXME DOC
*/
struct opj_compression
{
struct opj_compression {
OPJ_BOOL (* opj_start_compress) ( void *p_codec,
struct opj_stream_private * cio,
struct opj_image * p_image,

View File

@ -123,7 +123,8 @@
/* MSVC before 2013 and Borland C do not have lrintf */
#if defined(_MSC_VER)
#include <intrin.h>
static INLINE long opj_lrintf(float f){
static INLINE long opj_lrintf(float f)
{
#ifdef _M_X64
return _mm_cvt_ss2si(_mm_load_ss(&f));
@ -142,7 +143,8 @@ static INLINE long opj_lrintf(float f){
#endif
}
#elif defined(__BORLANDC__)
static INLINE long opj_lrintf(float f) {
static INLINE long opj_lrintf(float f)
{
#ifdef _M_X64
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
#else
@ -157,7 +159,8 @@ static INLINE long opj_lrintf(float f) {
#endif
}
#else
static INLINE long opj_lrintf(float f) {
static INLINE long opj_lrintf(float f)
{
return lrintf(f);
}
#endif

View File

@ -53,7 +53,8 @@ The functions in OPJ_INTMATH.H have for goal to realize operations on integers.
Get the minimum of two integers
@return Returns a if a < b else b
*/
static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b)
{
return a < b ? a : b;
}
@ -61,7 +62,8 @@ static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) {
Get the minimum of two integers
@return Returns a if a < b else b
*/
static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b)
{
return a < b ? a : b;
}
@ -69,7 +71,8 @@ static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
Get the maximum of two integers
@return Returns a if a > b else b
*/
static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b)
{
return (a > b) ? a : b;
}
@ -77,7 +80,8 @@ static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) {
Get the maximum of two integers
@return Returns a if a > b else b
*/
static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b)
{
return (a > b) ? a : b;
}
@ -85,7 +89,8 @@ static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
Get the saturated sum of two unsigned integers
@return Returns saturated sum of a+b
*/
static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b)
{
OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum;
}
@ -99,7 +104,8 @@ Clamp an integer inside an interval
<li>Returns min if (a < min)
</ul>
*/
static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max)
{
if (a < min)
return min;
if (a > max)
@ -109,14 +115,16 @@ static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max)
/**
@return Get absolute value of integer
*/
static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) {
static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a)
{
return a < 0 ? -a : a;
}
/**
Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b)
{
assert(b);
return (a + b - 1) / b;
}
@ -125,7 +133,8 @@ static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
Divide an integer and round upwards
@return Returns a divided by b
*/
static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b)
{
assert(b);
return (a + b - 1) / b;
}
@ -134,7 +143,8 @@ static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b)
{
return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
}
@ -142,7 +152,8 @@ static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
Divide a 64bits integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b)
{
return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
}
@ -150,7 +161,8 @@ static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) {
Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) {
static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b)
{
return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b);
}
@ -158,14 +170,16 @@ static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) {
Divide an integer by a power of 2 and round downwards
@return Returns a divided by 2^b
*/
static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b)
{
return a >> b;
}
/**
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) {
static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a)
{
OPJ_INT32 l;
for (l = 0; a > 1; l++) {
a >>= 1;
@ -176,10 +190,10 @@ static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) {
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a) {
OPJ_UINT32 l;
for (l = 0; a > 1; ++l)
static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a)
{
OPJ_UINT32 l;
for (l = 0; a > 1; ++l) {
a >>= 1;
}
return l;
@ -191,7 +205,8 @@ Multiply two fixed-precision rational numbers.
@param b
@return Returns a * b
*/
static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b)
{
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
OPJ_INT64 temp = __emul(a, b);
#else
@ -203,7 +218,8 @@ static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
return (OPJ_INT32) (temp >> 13);
}
static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b)
{
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
OPJ_INT64 temp = __emul(a, b);
#else

View File

@ -58,8 +58,7 @@ static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
* This function was introduced in POSIX 1003.1d. Although this function is
* superseded by aligned_alloc, it is more portable to older POSIX systems
* that do not support ISO C11. */
if (posix_memalign (&ptr, alignment, size))
{
if (posix_memalign (&ptr, alignment, size)) {
ptr = NULL;
}
/* older linux */
@ -164,8 +163,7 @@ static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t ne
if (newmem == oldmem) {
r_ptr = ptr;
}
else {
} else {
size_t old_offset;
size_t new_offset;

View File

@ -107,8 +107,7 @@ int opj_write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, O
if( j2klen > pow( 2, 32)) {
size_of_coding = 8;
version = 1;
}
else{
} else {
size_of_coding = 4;
version = 0;
}

View File

@ -230,7 +230,8 @@ static OPJ_BOOL opj_pi_check_next_level( OPJ_INT32 pos,
==========================================================
*/
static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi) {
static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
@ -261,7 +262,8 @@ static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -270,7 +272,8 @@ LABEL_SKIP:;
return OPJ_FALSE;
}
static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi) {
static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
@ -300,7 +303,8 @@ static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -309,7 +313,8 @@ LABEL_SKIP:;
return OPJ_FALSE;
}
static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi) {
static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
@ -382,7 +387,8 @@ if (!pi->tp_on){
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -392,7 +398,8 @@ LABEL_SKIP:;
return OPJ_FALSE;
}
static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi) {
static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
@ -463,7 +470,8 @@ static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -473,7 +481,8 @@ LABEL_SKIP:;
return OPJ_FALSE;
}
static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi) {
static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
@ -542,7 +551,8 @@ static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -1194,15 +1204,13 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_tmp_data = (OPJ_UINT32*)opj_malloc(
l_data_stride * p_image->numcomps * sizeof(OPJ_UINT32));
if
(! l_tmp_data)
{
(! l_tmp_data) {
return 00;
}
l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
p_image->numcomps * sizeof(OPJ_UINT32 *));
if
(! l_tmp_ptr)
{
(! l_tmp_ptr) {
opj_free(l_tmp_data);
return 00;
}
@ -1218,8 +1226,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_encoding_value_ptr = l_tmp_data;
/* update pointer array */
for
(compno = 0; compno < p_image->numcomps; ++compno)
{
(compno = 0; compno < p_image->numcomps; ++compno) {
l_tmp_ptr[compno] = l_encoding_value_ptr;
l_encoding_value_ptr += l_data_stride;
}
@ -1238,8 +1245,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
/* memory allocation for include */
l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
if
(!l_current_pi->include)
{
(!l_current_pi->include) {
opj_free(l_tmp_data);
opj_free(l_tmp_ptr);
opj_pi_destroy(l_pi, l_bound);
@ -1266,8 +1272,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
/* allocation for components and number of components has already been calculated by opj_pi_create */
for
(compno = 0; compno < l_current_pi->numcomps; ++compno)
{
(compno = 0; compno < l_current_pi->numcomps; ++compno) {
opj_pi_resolution_t *l_res = l_current_comp->resolutions;
l_encoding_value_ptr = l_tmp_ptr[compno];
@ -1275,8 +1280,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_current_comp->dy = l_img_comp->dy;
/* resolutions have already been initialized */
for
(resno = 0; resno < l_current_comp->numresolutions; resno++)
{
(resno = 0; resno < l_current_comp->numresolutions; resno++) {
l_res->pdx = *(l_encoding_value_ptr++);
l_res->pdy = *(l_encoding_value_ptr++);
l_res->pw = *(l_encoding_value_ptr++);
@ -1289,8 +1293,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
}
++l_current_pi;
for (pino = 1 ; pino<l_bound ; ++pino )
{
for (pino = 1 ; pino<l_bound ; ++pino ) {
l_current_comp = l_current_pi->comps;
l_img_comp = p_image->comps;
l_tccp = l_tcp->tccps;
@ -1308,8 +1311,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
/* allocation for components and number of components has already been calculated by opj_pi_create */
for
(compno = 0; compno < l_current_pi->numcomps; ++compno)
{
(compno = 0; compno < l_current_pi->numcomps; ++compno) {
opj_pi_resolution_t *l_res = l_current_comp->resolutions;
l_encoding_value_ptr = l_tmp_ptr[compno];
@ -1317,8 +1319,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_current_comp->dy = l_img_comp->dy;
/* resolutions have already been initialized */
for
(resno = 0; resno < l_current_comp->numresolutions; resno++)
{
(resno = 0; resno < l_current_comp->numresolutions; resno++) {
l_res->pdx = *(l_encoding_value_ptr++);
l_res->pdy = *(l_encoding_value_ptr++);
l_res->pw = *(l_encoding_value_ptr++);
@ -1338,12 +1339,9 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
opj_free(l_tmp_ptr);
l_tmp_ptr = 00;
if
(l_tcp->POC)
{
(l_tcp->POC) {
opj_pi_update_decode_poc (l_pi,l_tcp,l_max_prec,l_max_res);
}
else
{
} else {
opj_pi_update_decode_not_poc(l_pi,l_tcp,l_max_prec,l_max_res);
}
return l_pi;
@ -1528,8 +1526,7 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
if (l_tcp->POC && (OPJ_IS_CINEMA(p_cp->rsiz) || p_t2_mode == FINAL_PASS)) {
opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
}
else {
} else {
opj_pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
}
@ -1762,15 +1759,18 @@ void opj_pi_create_encode( opj_pi_iterator_t *pi,
pi[pino].poc.ty0 = (OPJ_INT32)tcp->ty0_t;
pi[pino].poc.ty1 = (OPJ_INT32)(tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy));
tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
incr_top=1;resetX=1;
incr_top=1;
resetX=1;
} else {
incr_top=0;resetX=0;
incr_top=0;
resetX=0;
}
} else {
pi[pino].poc.ty0 = (OPJ_INT32)tcp->ty0_t;
pi[pino].poc.ty1 = (OPJ_INT32)(tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy));
tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
incr_top=0;resetX=1;
incr_top=0;
resetX=1;
}
if(resetX==1) {
tcp->tx0_t = tcp->txS;
@ -1851,13 +1851,13 @@ void opj_pi_update_encoding_parameters( const opj_image_t *p_image,
if (l_tcp->POC) {
opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
}
else {
} else {
opj_pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
}
}
OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi) {
OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi)
{
switch (pi->poc.prg) {
case OPJ_LRCP:
return opj_pi_next_lrcp(pi);

View File

@ -112,8 +112,7 @@ int opj_write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, O
if( j2klen > pow( 2, 32)) {
size_of_coding = 8;
version = 1;
}
else{
} else {
size_of_coding = 4;
version = 0;
}

View File

@ -48,24 +48,28 @@
==========================================================
*/
opj_raw_t* opj_raw_create(void) {
opj_raw_t* opj_raw_create(void)
{
opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
return raw;
}
void opj_raw_destroy(opj_raw_t *raw) {
void opj_raw_destroy(opj_raw_t *raw)
{
if(raw) {
opj_free(raw);
}
}
OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw) {
OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw)
{
const ptrdiff_t diff = raw->bp - raw->start;
assert( diff <= (ptrdiff_t)0xffffffff && diff >= 0 ); /* UINT32_MAX */
return (OPJ_UINT32)diff;
}
void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len) {
void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len)
{
raw->start = bp;
raw->lenmax = len;
raw->len = 0;
@ -73,7 +77,8 @@ void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len) {
raw->ct = 0;
}
OPJ_UINT32 opj_raw_decode(opj_raw_t *raw) {
OPJ_UINT32 opj_raw_decode(opj_raw_t *raw)
{
OPJ_UINT32 d;
if (raw->ct == 0) {
raw->ct = 8;

View File

@ -305,25 +305,30 @@ static OPJ_BOOL opj_t1_allocate_buffers( opj_t1_t *t1,
/* ----------------------------------------------------------------------- */
static OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) {
static OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient)
{
return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
}
static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f) {
static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f)
{
return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
}
static OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f) {
static OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f)
{
OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
return (tmp2);
}
static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f) {
static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f)
{
return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
}
static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos)
{
if (bitpos > 0) {
return lut_nmsedec_sig[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -331,7 +336,8 @@ static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos)
{
if (bitpos > 0) {
return lut_nmsedec_ref[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -339,7 +345,8 @@ static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride) {
static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride)
{
opj_flag_t *np = flagsp - stride;
opj_flag_t *sp = flagsp + stride;
@ -1375,8 +1382,7 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
if(!opj_t1_allocate_buffers(
t1,
(OPJ_UINT32)(cblk->x1 - cblk->x0),
(OPJ_UINT32)(cblk->y1 - cblk->y0)))
{
(OPJ_UINT32)(cblk->y1 - cblk->y0))) {
return OPJ_FALSE;
}
@ -1499,8 +1505,7 @@ OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1,
if(!opj_t1_allocate_buffers(
t1,
(OPJ_UINT32)(cblk->x1 - cblk->x0),
(OPJ_UINT32)(cblk->y1 - cblk->y0)))
{
(OPJ_UINT32)(cblk->y1 - cblk->y0))) {
return OPJ_FALSE;
}

View File

@ -38,7 +38,8 @@
#include "opj_includes.h"
static int t1_init_ctxno_zc(int f, int orient) {
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);
@ -110,7 +111,8 @@ static int t1_init_ctxno_zc(int f, int orient) {
return (T1_CTXNO_ZC + n);
}
static int t1_init_ctxno_sc(int f) {
static int t1_init_ctxno_sc(int f)
{
int hc, vc, n;
n = 0;
@ -151,7 +153,8 @@ static int t1_init_ctxno_sc(int f) {
return (T1_CTXNO_SC + n);
}
static int t1_init_spb(int f) {
static int t1_init_spb(int f)
{
int hc, vc, n;
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
@ -176,7 +179,8 @@ static int t1_init_spb(int f) {
return n;
}
static void dump_array16(int array[],int size){
static void dump_array16(int array[],int size)
{
int i;
--size;
for (i = 0; i < size; ++i) {
@ -197,7 +201,8 @@ int main(int argc, char **argv)
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
(void)argc; (void)argv;
(void)argc;
(void)argv;
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");

View File

@ -156,7 +156,8 @@ static OPJ_BOOL opj_t2_init_seg( opj_tcd_cblk_dec_t* cblk,
/* ----------------------------------------------------------------------- */
/* #define RESTART 0x04 */
static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n) {
static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n)
{
while (--n >= 0) {
opj_bio_write(bio, 1, 1);
}
@ -172,7 +173,8 @@ static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio)
return n;
}
static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n) {
static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n)
{
if (n == 1) {
opj_bio_write(bio, 0, 1);
} else if (n == 2) {
@ -186,7 +188,8 @@ static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n) {
}
}
static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio) {
static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio)
{
OPJ_UINT32 n;
if (!opj_bio_read(bio, 1))
return 1;
@ -279,8 +282,7 @@ OPJ_BOOL opj_t2_encode_packets( opj_t2_t* p_t2,
++l_current_pi;
}
}
}
else { /* t2_mode == FINAL_PASS */
} else { /* t2_mode == FINAL_PASS */
opj_pi_create_encode(l_pi, l_cp,p_tile_no,p_pino,p_tp_num,p_tp_pos,p_t2_mode);
l_current_pi = &l_pi[p_pino];
@ -402,8 +404,7 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
}
first_pass_failed = (OPJ_BOOL*)opj_malloc(l_image->numcomps * sizeof(OPJ_BOOL));
if (!first_pass_failed)
{
if (!first_pass_failed) {
opj_pi_destroy(l_pi,l_nb_pocs);
return OPJ_FALSE;
}
@ -427,8 +428,7 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
l_img_comp = &(l_image->comps[l_current_pi->compno]);
l_img_comp->resno_decoded = opj_uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
}
else {
} else {
l_nb_bytes_read = 0;
if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info, p_manager)) {
opj_pi_destroy(l_pi,l_nb_pocs);
@ -511,7 +511,8 @@ opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp)
return l_t2;
}
void opj_t2_destroy(opj_t2_t *t2) {
void opj_t2_destroy(opj_t2_t *t2)
{
if(t2) {
opj_free(t2);
}
@ -918,13 +919,11 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
l_header_data = *l_header_data_start;
l_modified_length_ptr = &(l_cp->ppm_len);
}
else if (p_tcp->ppt == 1) { /* PPT */
} else if (p_tcp->ppt == 1) { /* PPT */
l_header_data_start = &(p_tcp->ppt_data);
l_header_data = *l_header_data_start;
l_modified_length_ptr = &(p_tcp->ppt_len);
}
else { /* Normal Case */
} else { /* Normal Case */
l_header_data_start = &(l_current_data);
l_header_data = *l_header_data_start;
l_remaining_length = (OPJ_UINT32)(p_src_data+p_max_length-l_header_data);
@ -988,8 +987,7 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
if (!l_cblk->numsegs) {
l_included = opj_tgt_decode(l_bio, l_prc->incltree, cblkno, (OPJ_INT32)(p_pi->layno + 1));
/* else one bit */
}
else {
} else {
l_included = opj_bio_read(l_bio, 1);
}
@ -1026,8 +1024,7 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
}
else {
} else {
l_segno = l_cblk->numsegs - 1;
if (l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses) {
++l_segno;
@ -1144,8 +1141,7 @@ static OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
l_seg = l_cblk->segs;
++l_cblk->numsegs;
l_cblk->data_current_size = 0;
}
else {
} else {
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
if (l_seg->numpasses == l_seg->maxpasses) {
@ -1279,8 +1275,7 @@ static OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
l_seg = l_cblk->segs;
++l_cblk->numsegs;
l_cblk->data_current_size = 0;
}
else {
} else {
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
if (l_seg->numpasses == l_seg->maxpasses) {
@ -1321,8 +1316,7 @@ static OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
l_seg->numpasses += l_seg->numnewpasses;
l_cblk->numnewpasses -= l_seg->numnewpasses;
if (l_cblk->numnewpasses > 0)
{
if (l_cblk->numnewpasses > 0) {
++l_seg;
++l_cblk->numsegs;
}
@ -1366,8 +1360,7 @@ static OPJ_BOOL opj_t2_init_seg( opj_tcd_cblk_dec_t* cblk,
if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
seg->maxpasses = 1;
}
else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
} else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
if (first) {
seg->maxpasses = 10;
} else {

View File

@ -44,7 +44,8 @@
/* TODO MSD: */
#ifdef TODO_MSD
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img)
{
int tileno, compno, resno, bandno, precno;/*, cblkno;*/
fprintf(fd, "image {\n");
@ -206,7 +207,8 @@ opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder)
/* ----------------------------------------------------------------------- */
void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd) {
void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd)
{
OPJ_UINT32 layno;
for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
@ -300,7 +302,8 @@ void opj_tcd_makelayer( opj_tcd_t *tcd,
}
}
void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final) {
void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final)
{
OPJ_UINT32 compno, resno, bandno, precno, cblkno;
OPJ_INT32 value; /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */
OPJ_INT32 matrice[10][10][3];
@ -521,8 +524,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
lo = thresh;
continue;
}
else {
} else {
distoachieved = layno == 0 ?
tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
@ -546,8 +548,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
lo = thresh;
}
} else {
if (! opj_t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC))
{
if (! opj_t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC)) {
/* TODO: what to do with l ??? seek / tell ??? */
/* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
lo = thresh;
@ -611,7 +612,8 @@ OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
/**
Destroy a previously created TCD handle
*/
void opj_tcd_destroy(opj_tcd_t *tcd) {
void opj_tcd_destroy(opj_tcd_t *tcd)
{
if (tcd) {
opj_tcd_free_tile(tcd);
@ -633,8 +635,7 @@ OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec)
/*fprintf(stderr, "tAllocate data of tilec (int): %d x OPJ_UINT32n",l_data_size);*/
l_tilec->data_size = l_tilec->data_size_needed;
l_tilec->ownsData = OPJ_TRUE;
}
else if (l_tilec->data_size_needed > l_tilec->data_size) {
} else if (l_tilec->data_size_needed > l_tilec->data_size) {
/* We don't need to keep old data */
opj_aligned_free(l_tilec->data);
l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_tilec->data_size_needed);
@ -741,8 +742,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
l_tilec->numresolutions = l_tccp->numresolutions;
if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_reduce) {
l_tilec->minimum_num_resolutions = 1;
}
else {
} else {
l_tilec->minimum_num_resolutions = l_tccp->numresolutions - l_cp->m_specific_param.m_dec.m_reduce;
}
@ -762,8 +762,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
/*fprintf(stderr, "\tAllocate resolutions of tilec (opj_tcd_resolution_t): %d\n",l_data_size);*/
l_tilec->resolutions_size = l_data_size;
memset(l_tilec->resolutions,0,l_data_size);
}
else if (l_data_size > l_tilec->resolutions_size) {
} else if (l_data_size > l_tilec->resolutions_size) {
opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolution_t *) opj_realloc(l_tilec->resolutions, l_data_size);
if (! new_resolutions) {
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile resolutions\n");
@ -783,8 +782,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
l_step_size = l_tccp->stepsizes;
if (l_tccp->qmfbid == 0) {
l_gain_ptr = &opj_dwt_getgain_real;
}
else {
} else {
l_gain_ptr = &opj_dwt_getgain;
}
/*fprintf(stderr, "\tlevel_no=%d\n",l_level_no);*/
@ -826,8 +824,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
cbgwidthexpn = l_pdx;
cbgheightexpn = l_pdy;
l_res->numbands = 1;
}
else {
} else {
tlcbgxstart = opj_int_ceildivpow2(l_tl_prc_x_start, 1);
tlcbgystart = opj_int_ceildivpow2(l_tl_prc_y_start, 1);
/*brcbgxend = opj_int_ceildivpow2(l_br_prc_x_end, 1);*/
@ -851,8 +848,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
l_band->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
l_band->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
l_band->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
}
else {
} else {
l_band->bandno = bandno + 1;
/* x0b = 1 if bandno = 1 or 3 */
l_x0b = l_band->bandno&1;
@ -879,8 +875,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
/*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */
memset(l_band->precincts,0,l_nb_precinct_size);
l_band->precincts_data_size = l_nb_precinct_size;
}
else if (l_band->precincts_data_size < l_nb_precinct_size) {
} else if (l_band->precincts_data_size < l_nb_precinct_size) {
opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size);
if (! new_precincts) {
@ -940,8 +935,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
memset(l_current_precinct->cblks.blocks,0,l_nb_code_blocks_size);
l_current_precinct->block_size = l_nb_code_blocks_size;
}
else if (l_nb_code_blocks_size > l_current_precinct->block_size) {
} else if (l_nb_code_blocks_size > l_current_precinct->block_size) {
void *new_blocks = opj_realloc(l_current_precinct->cblks.blocks, l_nb_code_blocks_size);
if (! new_blocks) {
opj_free(l_current_precinct->cblks.blocks);
@ -962,8 +956,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
if (! l_current_precinct->incltree) {
l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
}
else{
} else {
l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree, l_current_precinct->cw, l_current_precinct->ch, manager);
}
@ -974,8 +967,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
if (! l_current_precinct->imsbtree) {
l_current_precinct->imsbtree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
}
else {
} else {
l_current_precinct->imsbtree = opj_tgt_init(l_current_precinct->imsbtree, l_current_precinct->cw, l_current_precinct->ch, manager);
}
@ -1288,8 +1280,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
/*--------------TIER2------------------*/
/* FIXME _ProfStart(PGROUP_T2); */
l_data_read = 0;
if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, p_manager))
{
if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, p_manager)) {
return OPJ_FALSE;
}
/* FIXME _ProfStop(PGROUP_T2); */
@ -1298,8 +1289,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
/* FIXME _ProfStart(PGROUP_T1); */
if
(! opj_tcd_t1_decode(p_tcd))
{
(! opj_tcd_t1_decode(p_tcd)) {
return OPJ_FALSE;
}
/* FIXME _ProfStop(PGROUP_T1); */
@ -1308,8 +1298,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
/* FIXME _ProfStart(PGROUP_DWT); */
if
(! opj_tcd_dwt_decode(p_tcd))
{
(! opj_tcd_dwt_decode(p_tcd)) {
return OPJ_FALSE;
}
/* FIXME _ProfStop(PGROUP_DWT); */
@ -1317,16 +1306,14 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
/*----------------MCT-------------------*/
/* FIXME _ProfStart(PGROUP_MCT); */
if
(! opj_tcd_mct_decode(p_tcd, p_manager))
{
(! opj_tcd_mct_decode(p_tcd, p_manager)) {
return OPJ_FALSE;
}
/* FIXME _ProfStop(PGROUP_MCT); */
/* FIXME _ProfStart(PGROUP_DC_SHIFT); */
if
(! opj_tcd_dc_level_shift_decode(p_tcd))
{
(! opj_tcd_dc_level_shift_decode(p_tcd)) {
return OPJ_FALSE;
}
/* FIXME _ProfStop(PGROUP_DC_SHIFT); */
@ -1372,10 +1359,8 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
l_size_comp = 4;
}
switch (l_size_comp)
{
case 1:
{
switch (l_size_comp) {
case 1: {
OPJ_CHAR * l_dest_ptr = (OPJ_CHAR *) p_dest;
const OPJ_INT32 * l_src_ptr = l_tilec->data;
@ -1386,8 +1371,7 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
}
l_src_ptr += l_stride;
}
}
else {
} else {
for (j=0; j<l_height; ++j) {
for (k=0; k<l_width; ++k) {
*(l_dest_ptr++) = (OPJ_CHAR) ((*(l_src_ptr++))&0xff);
@ -1399,8 +1383,7 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
p_dest = (OPJ_BYTE *)l_dest_ptr;
}
break;
case 2:
{
case 2: {
const OPJ_INT32 * l_src_ptr = l_tilec->data;
OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_dest;
@ -1411,8 +1394,7 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
}
l_src_ptr += l_stride;
}
}
else {
} else {
for (j=0; j<l_height; ++j) {
for (k=0; k<l_width; ++k) {
*(l_dest_ptr++) = (OPJ_INT16) ((*(l_src_ptr++))&0xffff);
@ -1424,8 +1406,7 @@ OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
p_dest = (OPJ_BYTE*) l_dest_ptr;
}
break;
case 4:
{
case 4: {
OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_dest;
OPJ_INT32 * l_src_ptr = l_tilec->data;
@ -1472,8 +1453,7 @@ static void opj_tcd_free_tile(opj_tcd_t *p_tcd)
if (p_tcd->m_is_decoder) {
l_tcd_code_block_deallocate = opj_tcd_code_block_dec_deallocate;
}
else {
} else {
l_tcd_code_block_deallocate = opj_tcd_code_block_enc_deallocate;
}
@ -1624,8 +1604,7 @@ static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd )
if (! opj_dwt_decode(l_tile_comp, l_img_comp->resno_decoded+1)) {
return OPJ_FALSE;
}
}
else {
} else {
if (! opj_dwt_decode_real(l_tile_comp, l_img_comp->resno_decoded+1)) {
return OPJ_FALSE;
}
@ -1658,8 +1637,7 @@ static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd, opj_event_mgr_t *p_manage
(l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps[2].y1 - l_tile->comps[2].y0) < (OPJ_INT32)l_samples) {
opj_event_msg(p_manager, EVT_ERROR, "Tiles don't all have the same dimension. Skip the MCT step.\n");
return OPJ_FALSE;
}
else if (l_tcp->mct == 2) {
} else if (l_tcp->mct == 2) {
OPJ_BYTE ** l_data;
if (! l_tcp->m_mct_decoding_matrix) {
@ -1691,23 +1669,20 @@ static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd, opj_event_mgr_t *p_manage
}
opj_free(l_data);
}
else {
} else {
if (l_tcp->tccps->qmfbid == 1) {
opj_mct_decode( l_tile->comps[0].data,
l_tile->comps[1].data,
l_tile->comps[2].data,
l_samples);
}
else {
} else {
opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].data,
(OPJ_FLOAT32*)l_tile->comps[1].data,
(OPJ_FLOAT32*)l_tile->comps[2].data,
l_samples);
}
}
}
else {
} else {
opj_event_msg(p_manager, EVT_ERROR, "Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",l_tile->numcomps);
}
@ -1744,8 +1719,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd )
if (l_img_comp->sgnd) {
l_min = -(1 << (l_img_comp->prec - 1));
l_max = (1 << (l_img_comp->prec - 1)) - 1;
}
else {
} else {
l_min = 0;
l_max = (1 << l_img_comp->prec) - 1;
}
@ -1760,8 +1734,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd )
}
l_current_ptr += l_stride;
}
}
else {
} else {
for (j=0; j<l_height; ++j) {
for (i = 0; i < l_width; ++i) {
OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
@ -1908,8 +1881,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd )
*l_current_ptr -= l_tccp->m_dc_level_shift ;
++l_current_ptr;
}
}
else {
} 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;
@ -1961,18 +1933,15 @@ static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd )
/* nb of components (i.e. size of pData) */
l_tile->numcomps,
/* tells if the data is signed */
p_tcd->image->comps->sgnd) )
{
p_tcd->image->comps->sgnd) ) {
opj_free(l_data);
return OPJ_FALSE;
}
opj_free(l_data);
}
else if (l_tcp->tccps->qmfbid == 0) {
} else if (l_tcp->tccps->qmfbid == 0) {
opj_mct_encode_real(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
}
else {
} else {
opj_mct_encode(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
}
@ -1991,8 +1960,7 @@ static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd )
if (! opj_dwt_encode(l_tile_comp)) {
return OPJ_FALSE;
}
}
else if (l_tccp->qmfbid == 0) {
} else if (l_tccp->qmfbid == 0) {
if (! opj_dwt_encode_real(l_tile_comp)) {
return OPJ_FALSE;
}
@ -2022,12 +1990,10 @@ static OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd )
/* irreversible encoding */
if (l_tcp->tccps->qmfbid == 0) {
l_mct_norms = opj_mct_get_mct_norms_real();
}
else {
} else {
l_mct_norms = opj_mct_get_mct_norms();
}
}
else {
} else {
l_mct_numcomps = p_tcd->image->numcomps;
l_mct_norms = (const OPJ_FLOAT64 *) (l_tcp->mct_norms);
}
@ -2067,8 +2033,7 @@ static OPJ_BOOL opj_tcd_t2_encode (opj_tcd_t *p_tcd,
p_tcd->tp_num,
p_tcd->tp_pos,
p_tcd->cur_pino,
FINAL_PASS))
{
FINAL_PASS)) {
opj_t2_destroy(l_t2);
return OPJ_FALSE;
}
@ -2098,8 +2063,7 @@ static OPJ_BOOL opj_tcd_rate_allocate_encode( opj_tcd_t *p_tcd,
if (! opj_tcd_rateallocate(p_tcd, p_dest_data,&l_nb_written, p_max_dest_size, p_cstr_info)) {
return OPJ_FALSE;
}
}
else {
} else {
/* Fixed layer allocation */
opj_tcd_rateallocate_fixed(p_tcd);
}
@ -2139,8 +2103,7 @@ OPJ_BOOL opj_tcd_copy_tile_data ( opj_tcd_t *p_tcd,
}
switch (l_size_comp) {
case 1:
{
case 1: {
OPJ_CHAR * l_src_ptr = (OPJ_CHAR *) p_src;
OPJ_INT32 * l_dest_ptr = l_tilec->data;
@ -2148,8 +2111,7 @@ OPJ_BOOL opj_tcd_copy_tile_data ( opj_tcd_t *p_tcd,
for (j=0; j<l_nb_elem; ++j) {
*(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
}
}
else {
} else {
for (j=0; j<l_nb_elem; ++j) {
*(l_dest_ptr++) = (*(l_src_ptr++))&0xff;
}
@ -2158,8 +2120,7 @@ OPJ_BOOL opj_tcd_copy_tile_data ( opj_tcd_t *p_tcd,
p_src = (OPJ_BYTE*) l_src_ptr;
}
break;
case 2:
{
case 2: {
OPJ_INT32 * l_dest_ptr = l_tilec->data;
OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_src;
@ -2167,8 +2128,7 @@ OPJ_BOOL opj_tcd_copy_tile_data ( opj_tcd_t *p_tcd,
for (j=0; j<l_nb_elem; ++j) {
*(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
}
}
else {
} else {
for (j=0; j<l_nb_elem; ++j) {
*(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
}
@ -2177,8 +2137,7 @@ OPJ_BOOL opj_tcd_copy_tile_data ( opj_tcd_t *p_tcd,
p_src = (OPJ_BYTE*) l_src_ptr;
}
break;
case 4:
{
case 4: {
OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_src;
OPJ_INT32 * l_dest_ptr = l_tilec->data;

View File

@ -155,8 +155,7 @@ typedef struct opj_tcd_resolution {
/**
FIXME DOC
*/
typedef struct opj_tcd_tilecomp
{
typedef struct opj_tcd_tilecomp {
OPJ_INT32 x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
OPJ_UINT32 numresolutions; /* number of resolutions level */
OPJ_UINT32 minimum_num_resolutions; /* number of resolutions level to decode (at max)*/
@ -186,8 +185,7 @@ typedef struct opj_tcd_tile {
/**
FIXME DOC
*/
typedef struct opj_tcd_image
{
typedef struct opj_tcd_image {
opj_tcd_tile_t *tiles; /* Tiles information */
}
opj_tcd_image_t;
@ -196,8 +194,7 @@ opj_tcd_image_t;
/**
Tile coder/decoder
*/
typedef struct opj_tcd
{
typedef struct opj_tcd {
/** Position of the tilepart flag in Progression order*/
OPJ_INT32 tp_pos;
/** Tile part number*/

View File

@ -45,7 +45,8 @@
==========================================================
*/
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager) {
opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager)
{
OPJ_INT32 nplh[32];
OPJ_INT32 nplv[32];
opj_tgt_node_t *node = 00;
@ -155,15 +156,13 @@ opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, O
l_nplh[0] = (OPJ_INT32)p_num_leafs_h;
l_nplv[0] = (OPJ_INT32)p_num_leafs_v;
p_tree->numnodes = 0;
do
{
do {
n = (OPJ_UINT32)(l_nplh[l_num_levels] * l_nplv[l_num_levels]);
l_nplh[l_num_levels + 1] = (l_nplh[l_num_levels] + 1) / 2;
l_nplv[l_num_levels + 1] = (l_nplv[l_num_levels] + 1) / 2;
p_tree->numnodes += n;
++l_num_levels;
}
while (n > 1);
} while (n > 1);
/* ADD */
if (p_tree->numnodes == 0) {
@ -199,12 +198,9 @@ opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, O
}
++l_parent_node;
}
if ((j & 1) || j == l_nplv[i] - 1)
{
if ((j & 1) || j == l_nplv[i] - 1) {
l_parent_node0 = l_parent_node;
}
else
{
} else {
l_parent_node = l_parent_node0;
l_parent_node0 += l_nplh[i];
}
@ -230,7 +226,8 @@ void opj_tgt_destroy(opj_tgt_tree_t *p_tree)
opj_free(p_tree);
}
void opj_tgt_reset(opj_tgt_tree_t *p_tree) {
void opj_tgt_reset(opj_tgt_tree_t *p_tree)
{
OPJ_UINT32 i;
opj_tgt_node_t * l_current_node = 00;;
@ -239,8 +236,7 @@ void opj_tgt_reset(opj_tgt_tree_t *p_tree) {
}
l_current_node = p_tree->nodes;
for (i = 0; i < p_tree->numnodes; ++i)
{
for (i = 0; i < p_tree->numnodes; ++i) {
l_current_node->value = 999;
l_current_node->low = 0;
l_current_node->known = 0;
@ -248,7 +244,8 @@ void opj_tgt_reset(opj_tgt_tree_t *p_tree) {
}
}
void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value) {
void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value)
{
opj_tgt_node_t *node;
node = &tree->nodes[leafno];
while (node && node->value > value) {
@ -257,7 +254,8 @@ void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value)
}
}
void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold)
{
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;
@ -297,7 +295,8 @@ void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ
}
}
OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold)
{
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;

View File

@ -64,8 +64,7 @@ typedef struct opj_tgt_node {
/**
Tag tree
*/
typedef struct opj_tgt_tree
{
typedef struct opj_tgt_tree {
OPJ_UINT32 numleafsh;
OPJ_UINT32 numleafsv;
OPJ_UINT32 numnodes;

View File

@ -105,8 +105,7 @@ int opj_write_tpixfaix( int coff,
if( j2klen > pow( 2, 32)) {
size_of_coding = 8;
version = num_max_tile_parts == 1 ? 1:3;
}
else{
} else {
size_of_coding = 4;
version = num_max_tile_parts == 1 ? 0:2;
}
@ -123,10 +122,8 @@ int opj_write_tpixfaix( int coff,
opj_write_bytes(l_data_header,(OPJ_UINT32)(cstr_info.tw*cstr_info.th),size_of_coding); /* M */
opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
for (i = 0; i < (OPJ_UINT32)(cstr_info.tw*cstr_info.th); i++)
{
for (j = 0; j < (OPJ_UINT32)cstr_info.tile[i].num_tps; j++)
{
for (i = 0; i < (OPJ_UINT32)(cstr_info.tw*cstr_info.th); i++) {
for (j = 0; j < (OPJ_UINT32)cstr_info.tile[i].num_tps; j++) {
tp = cstr_info.tile[i].tp[j];
opj_write_bytes(l_data_header,(OPJ_UINT32)(tp.tp_start_pos-coff),size_of_coding); /* start position */
@ -134,8 +131,7 @@ int opj_write_tpixfaix( int coff,
opj_write_bytes(l_data_header,(OPJ_UINT32)(tp.tp_end_pos-tp.tp_start_pos+1),size_of_coding); /* length */
opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
if (version & 0x02)
{
if (version & 0x02) {
if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
Aux = (OPJ_UINT32)(cstr_info.numdecompos[compno] + 1);
else
@ -150,8 +146,7 @@ int opj_write_tpixfaix( int coff,
/*cio_write(0,4);*/
}
/* PADDING */
while (j < num_max_tile_parts)
{
while (j < num_max_tile_parts) {
opj_write_bytes(l_data_header,0,size_of_coding);/* start position */
opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);

View File

@ -77,7 +77,8 @@ static int bio_bytein(opj_bio_t *bio);
==========================================================
*/
static int bio_byteout(opj_bio_t *bio) {
static int bio_byteout(opj_bio_t *bio)
{
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) {
@ -87,7 +88,8 @@ static int bio_byteout(opj_bio_t *bio) {
return 0;
}
static int bio_bytein(opj_bio_t *bio) {
static int bio_bytein(opj_bio_t *bio)
{
bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) {
@ -97,7 +99,8 @@ static int bio_bytein(opj_bio_t *bio) {
return 0;
}
static void bio_putbit(opj_bio_t *bio, int b) {
static void bio_putbit(opj_bio_t *bio, int b)
{
if (bio->ct == 0) {
bio_byteout(bio);
}
@ -106,7 +109,8 @@ static void bio_putbit(opj_bio_t *bio, int b) {
}
/* MOD antonin */
static int bio_getbit(opj_bio_t *bio) {
static int bio_getbit(opj_bio_t *bio)
{
/* DOM */
if (bio->ct == 0) {
bio_bytein(bio);
@ -121,22 +125,26 @@ static int bio_getbit(opj_bio_t *bio) {
==========================================================
*/
opj_bio_t* bio_create() {
opj_bio_t* bio_create()
{
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
return bio;
}
void bio_destroy(opj_bio_t *bio) {
void bio_destroy(opj_bio_t *bio)
{
if(bio) {
opj_free(bio);
}
}
int bio_numbytes(opj_bio_t *bio) {
int bio_numbytes(opj_bio_t *bio)
{
return (bio->bp - bio->start);
}
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len)
{
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
@ -144,7 +152,8 @@ void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
bio->ct = 8;
}
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len)
{
bio->start = bp;
bio->end = bp + len;
bio->bp = bp;
@ -152,14 +161,16 @@ void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
bio->ct = 0;
}
void bio_write(opj_bio_t *bio, int v, int n) {
void bio_write(opj_bio_t *bio, int v, int n)
{
int i;
for (i = n - 1; i >= 0; i--) {
bio_putbit(bio, (v >> i) & 1);
}
}
int bio_read(opj_bio_t *bio, int n) {
int bio_read(opj_bio_t *bio, int n)
{
int i, v;
v = 0;
for (i = n - 1; i >= 0; i--) {
@ -168,7 +179,8 @@ int bio_read(opj_bio_t *bio, int n) {
return v;
}
int bio_flush(opj_bio_t *bio) {
int bio_flush(opj_bio_t *bio)
{
bio->ct = 0;
if (bio_byteout(bio)) {
return 1;
@ -182,7 +194,8 @@ int bio_flush(opj_bio_t *bio) {
return 0;
}
int bio_inalign(opj_bio_t *bio) {
int bio_inalign(opj_bio_t *bio)
{
bio->ct = 0;
if ((bio->buf & 0xff) == 0xff) {
if (bio_bytein(bio)) {

View File

@ -37,7 +37,8 @@
/* ----------------------------------------------------------------------- */
opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length)
{
opj_cp_t *cp = NULL;
opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
if(!cio) return NULL;
@ -47,8 +48,7 @@ opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer
cio->openmode = OPJ_STREAM_READ;
cio->buffer = buffer;
cio->length = length;
}
else if(!buffer && !length && cinfo) {
} else if(!buffer && !length && cinfo) {
/* allocate a buffer for the encoded image */
cio->openmode = OPJ_STREAM_WRITE;
switch(cinfo->codec_format) {
@ -67,8 +67,7 @@ opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer
opj_free(cio);
return NULL;
}
}
else {
} else {
opj_free(cio);
return NULL;
}
@ -81,7 +80,8 @@ opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer
return cio;
}
void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio)
{
if(cio) {
if(cio->openmode == OPJ_STREAM_WRITE) {
/* destroy the allocated buffer */
@ -98,7 +98,8 @@ void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
/*
* Get position in byte stream.
*/
int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
int OPJ_CALLCONV cio_tell(opj_cio_t *cio)
{
return cio->bp - cio->start;
}
@ -107,28 +108,32 @@ int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
*
* pos : position, in number of bytes, from the beginning of the stream
*/
void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos)
{
cio->bp = cio->start + pos;
}
/*
* Number of bytes left before the end of the stream.
*/
int cio_numbytesleft(opj_cio_t *cio) {
int cio_numbytesleft(opj_cio_t *cio)
{
return cio->end - cio->bp;
}
/*
* Get pointer to the current position in the stream.
*/
unsigned char *cio_getbp(opj_cio_t *cio) {
unsigned char *cio_getbp(opj_cio_t *cio)
{
return cio->bp;
}
/*
* Write a byte.
*/
static bool cio_byteout(opj_cio_t *cio, unsigned char v) {
static bool cio_byteout(opj_cio_t *cio, unsigned char v)
{
if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
return false;
@ -140,7 +145,8 @@ static bool cio_byteout(opj_cio_t *cio, unsigned char v) {
/*
* Read a byte.
*/
static unsigned char cio_bytein(opj_cio_t *cio) {
static unsigned char cio_bytein(opj_cio_t *cio)
{
if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n");
return 0;
@ -154,7 +160,8 @@ static unsigned char cio_bytein(opj_cio_t *cio) {
* v : value to write
* n : number of bytes to write
*/
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n)
{
int i;
for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
@ -170,7 +177,8 @@ unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
*
* return : value of the n bytes read
*/
unsigned int cio_read(opj_cio_t *cio, int n) {
unsigned int cio_read(opj_cio_t *cio, int n)
{
int i;
unsigned int v;
v = 0;
@ -185,7 +193,8 @@ unsigned int cio_read(opj_cio_t *cio, int n) {
*
* n : number of bytes to skip
*/
void cio_skip(opj_cio_t *cio, int n) {
void cio_skip(opj_cio_t *cio, int n)
{
cio->bp += n;
}
@ -195,7 +204,8 @@ void cio_skip(opj_cio_t *cio, int n) {
* v : value to write
* n : number of bytes to write
*/
int cio_write_int(opj_cio_t *cio, int v, int n) {
int cio_write_int(opj_cio_t *cio, int v, int n)
{
int i;
for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (char) ((v >> (i << 3)) & 0xff)) )
@ -211,7 +221,8 @@ int cio_write_int(opj_cio_t *cio, int v, int n) {
*
* return : value of the n bytes read
*/
int cio_read_int(opj_cio_t *cio, int n) {
int cio_read_int(opj_cio_t *cio, int n)
{
int i;
int v;
v = 0;

View File

@ -224,8 +224,11 @@ static opj_atk_t atk_info_wt[] = {
{3, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-1}, {0,1,2}, {0,1,2}, {1,1,3}, {{-1},{1},{1,0,-1}}}, /* WT 2-6 REV*/
{4, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-2}, {0,1,6}, {0,1,32}, {1,1,5}, {{-1},{1},{-3,22,0,-22,3}}}, /* WT 2-10 REV*/
{5, 1, J3D_ATK_ARB, J3D_ATK_IRR, 1, J3D_ATK_WS, 1, 7, {0}, {0}, {0}, {1,1,2,1,2,1,3},{{-1},{1.58613434206},{-0.460348209828, 0.460348209828},{0.25},{0.374213867768,-0.374213867768},{-1.33613434206},{0.29306717103,0,-0.29306717103}}}, /* WT 6-10 IRR*/
{6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}}}, /* WT 10-18 IRR*/
{
6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}
}
}, /* WT 10-18 IRR*/
{7, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 2, {0}, {0}, {0}, {1,1}, {-0.5, 0.25}}, /* WT 5-3 IRR*/
{8, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {4,4}, {8,8}, {2,2}, {{-9,1},{5,-1}}} /* WT 13-7 REV*/
};
@ -238,7 +241,8 @@ static opj_atk_t atk_info_wt[] = {
/* <summary> */
/* Forward lazy transform (horizontal). */
/* </summary> */
static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas)
{
int i;
for (i=0; i<sn; i++) b[i]=a[2*i+cas];
for (i=0; i<dn; i++) b[sn+i]=a[(2*i+1-cas)];
@ -247,7 +251,8 @@ static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
/* <summary> */
/* Forward lazy transform (vertical). */
/* </summary> */
static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas)
{
int i;
for (i=0; i<sn; i++) b[i*x]=a[2*i+cas];
for (i=0; i<dn; i++) b[(sn+i)*x]=a[(2*i+1-cas)];
@ -256,7 +261,8 @@ static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
/* <summary> */
/* Forward lazy transform (axial). */
/* </summary> */
static void dwt_deinterleave_z(int *a, int *b, int dn, int sn, int xy, int cas) {
static void dwt_deinterleave_z(int *a, int *b, int dn, int sn, int xy, int cas)
{
int i;
for (i=0; i<sn; i++) b[i*xy]=a[2*i+cas];
for (i=0; i<dn; i++) b[(sn+i)*xy]=a[(2*i+1-cas)];
@ -265,7 +271,8 @@ static void dwt_deinterleave_z(int *a, int *b, int dn, int sn, int xy, int cas)
/* <summary> */
/* Inverse lazy transform (horizontal). */
/* </summary> */
static void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
static void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas)
{
int i;
int *ai = NULL;
int *bi = NULL;
@ -288,7 +295,8 @@ static void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
/* <summary> */
/* Inverse lazy transform (vertical). */
/* </summary> */
static void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
static void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas)
{
int i;
int *ai = NULL;
int *bi = NULL;
@ -311,7 +319,8 @@ static void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
/* <summary> */
/* Inverse lazy transform (axial). */
/* </summary> */
static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas) {
static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas)
{
int i;
int *ai = NULL;
int *bi = NULL;
@ -335,7 +344,8 @@ static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas) {
/* <summary> */
/* Forward 5-3 or 9-7 wavelet transform in 1-D. */
/* </summary> */
static void dwt_encode_53(int *a, int dn, int sn, int cas) {
static void dwt_encode_53(int *a, int dn, int sn, int cas)
{
int i;
if (!cas) {
@ -373,7 +383,8 @@ static void dwt_encode_53(int *a, int dn, int sn, int cas) {
}
}
}
static void dwt_encode_97(int *a, int dn, int sn, int cas) {
static void dwt_encode_97(int *a, int dn, int sn, int cas)
{
int i;
if (!cas) {
@ -411,7 +422,8 @@ static void dwt_encode_97(int *a, int dn, int sn, int cas) {
/* <summary> */
/* Inverse 5-3 or 9-7 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_53(int *a, int dn, int sn, int cas) {
static void dwt_decode_53(int *a, int dn, int sn, int cas)
{
int i;
if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
@ -427,7 +439,8 @@ static void dwt_decode_53(int *a, int dn, int sn, int cas) {
}
}
}
static void dwt_decode_97(int *a, int dn, int sn, int cas) {
static void dwt_decode_97(int *a, int dn, int sn, int cas)
{
int i;
if (!cas) {
@ -467,7 +480,8 @@ static void dwt_decode_97(int *a, int dn, int sn, int cas) {
/* <summary> */
/* Get norm of arbitrary wavelet transform. */
/* </summary> */
static int upandconv(double *nXPS, double *LPS, int lenXPS, int lenLPS) {
static int upandconv(double *nXPS, double *LPS, int lenXPS, int lenLPS)
{
/* Perform the convolution of the vectors. */
int i,j;
double *tmp = (double *)opj_malloc(2*lenXPS * sizeof(double));
@ -488,7 +502,8 @@ static int upandconv(double *nXPS, double *LPS, int lenXPS, int lenLPS) {
return 2*lenXPS+lenLPS-1;
}
static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfilt_t *wtfiltX, opj_wtfilt_t *wtfiltY, opj_wtfilt_t *wtfiltZ) {
static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfilt_t *wtfiltX, opj_wtfilt_t *wtfiltY, opj_wtfilt_t *wtfiltZ)
{
int i, lenLPS, lenHPS;
double Lx = 0, Ly= 0, Hx= 0, Hy= 0, Lz= 0, Hz= 0;
double *nLPSx, *nHPSx,*nLPSy, *nHPSy,*nLPSz, *nHPSz;
@ -590,7 +605,8 @@ static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfil
free(nLPSz);
free(nHPSz);
} else {
Lz = 1.0; Hz = 1.0;
Lz = 1.0;
Hz = 1.0;
}
switch (orient) {
case 0:
@ -614,27 +630,40 @@ static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfil
}
}
static void dwt_getwtfilters(opj_wtfilt_t *wtfilt, int dwtid) {
static void dwt_getwtfilters(opj_wtfilt_t *wtfilt, int dwtid)
{
if (dwtid == 0) { /*DWT 9-7 */
wtfilt->lenLPS = 7; wtfilt->lenHPS = 9;
wtfilt->lenLPS = 7;
wtfilt->lenHPS = 9;
wtfilt->LPS = (double *)opj_malloc(wtfilt->lenLPS * sizeof(double));
wtfilt->HPS = (double *)opj_malloc(wtfilt->lenHPS * sizeof(double));
wtfilt->LPS[0] = -0.091271763114; wtfilt->HPS[0] = 0.026748757411;
wtfilt->LPS[1] = -0.057543526228; wtfilt->HPS[1] = 0.016864118443;
wtfilt->LPS[2] = 0.591271763114; wtfilt->HPS[2] = -0.078223266529;
wtfilt->LPS[3] = 1.115087052457; wtfilt->HPS[3] = -0.266864118443;
wtfilt->LPS[4] = 0.591271763114; wtfilt->HPS[4] = 0.602949018236;
wtfilt->LPS[5] = -0.057543526228; wtfilt->HPS[5] = -0.266864118443;
wtfilt->LPS[6] = -0.091271763114; wtfilt->HPS[6] = -0.078223266529;
wtfilt->LPS[0] = -0.091271763114;
wtfilt->HPS[0] = 0.026748757411;
wtfilt->LPS[1] = -0.057543526228;
wtfilt->HPS[1] = 0.016864118443;
wtfilt->LPS[2] = 0.591271763114;
wtfilt->HPS[2] = -0.078223266529;
wtfilt->LPS[3] = 1.115087052457;
wtfilt->HPS[3] = -0.266864118443;
wtfilt->LPS[4] = 0.591271763114;
wtfilt->HPS[4] = 0.602949018236;
wtfilt->LPS[5] = -0.057543526228;
wtfilt->HPS[5] = -0.266864118443;
wtfilt->LPS[6] = -0.091271763114;
wtfilt->HPS[6] = -0.078223266529;
wtfilt->HPS[7] = 0.016864118443;
wtfilt->HPS[8] = 0.026748757411;
} else if (dwtid == 1) { /*DWT 5-3 */
wtfilt->lenLPS = 3; wtfilt->lenHPS = 5;
wtfilt->lenLPS = 3;
wtfilt->lenHPS = 5;
wtfilt->LPS = (double *)opj_malloc(wtfilt->lenLPS * sizeof(double));
wtfilt->HPS = (double *)opj_malloc(wtfilt->lenHPS * sizeof(double));
wtfilt->LPS[0] = 0.5; wtfilt->HPS[0] = -0.125;
wtfilt->LPS[1] = 1; wtfilt->HPS[1] = -0.25;
wtfilt->LPS[2] = 0.5; wtfilt->HPS[2] = 0.75;
wtfilt->LPS[0] = 0.5;
wtfilt->HPS[0] = -0.125;
wtfilt->LPS[1] = 1;
wtfilt->HPS[1] = -0.25;
wtfilt->LPS[2] = 0.5;
wtfilt->HPS[2] = 0.75;
wtfilt->HPS[3] = -0.25;
wtfilt->HPS[4] = -0.125;
} else {
@ -645,7 +674,8 @@ static void dwt_getwtfilters(opj_wtfilt_t *wtfilt, int dwtid) {
/* <summary> */
/* Encoding of quantization stepsize for each subband. */
/* </summary> */
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize) {
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize)
{
int p, n;
p = int_floorlog2(stepsize) - 13;
n = 11 - int_floorlog2(stepsize);
@ -663,7 +693,8 @@ static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno
/* <summary> */
/* Forward 5-3 wavelet transform in 3-D. */
/* </summary> */
void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]) {
void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3])
{
int i, j, k;
int x, y, z;
int w, h, wh, d;
@ -794,7 +825,8 @@ void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]) {
/* <summary> */
/* Inverse 5-3 wavelet transform in 3-D. */
/* </summary> */
void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]) {
void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3])
{
int i, j, k;
int x, y, z;
int w, h, wh, d;
@ -925,7 +957,8 @@ void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]) {
/* <summary> */
/* Get gain of wavelet transform. */
/* </summary> */
int dwt_getgain(int orient, int reversible) {
int dwt_getgain(int orient, int reversible)
{
if (reversible == 1) {
if (orient == 0)
return 0;
@ -943,7 +976,8 @@ int dwt_getgain(int orient, int reversible) {
/* <summary> */
/* Get norm of wavelet transform. */
/* </summary> */
double dwt_getnorm(int orient, int level[3], int dwtid[3]) {
double dwt_getnorm(int orient, int level[3], int dwtid[3])
{
int levelx = level[0];
int levely = level[1];
int levelz = (level[2] < 0) ? 0 : level[2];
@ -966,9 +1000,15 @@ double dwt_getnorm(int orient, int level[3], int dwtid[3]) {
dwt_norm[levelx][levely][levelz][orient] = norm;
flagnorm[levelx][levely][levelz][orient] = 1;
/*Free reserved space*/
opj_free(wtfiltx->LPS); opj_free(wtfilty->LPS); opj_free(wtfiltz->LPS);
opj_free(wtfiltx->HPS); opj_free(wtfilty->HPS); opj_free(wtfiltz->HPS);
opj_free(wtfiltx); opj_free(wtfilty); opj_free(wtfiltz);
opj_free(wtfiltx->LPS);
opj_free(wtfilty->LPS);
opj_free(wtfiltz->LPS);
opj_free(wtfiltx->HPS);
opj_free(wtfilty->HPS);
opj_free(wtfiltz->HPS);
opj_free(wtfiltx);
opj_free(wtfilty);
opj_free(wtfiltz);
/*fprintf(stdout,"[INFO] Dwtid: %d %d %d Level: %d %d %d Orient %d Norm: %f \n",dwtid[0],dwtid[1],dwtid[2],level[0],level[1],level[2],orient,norm);*/
}
return norm;
@ -976,7 +1016,8 @@ double dwt_getnorm(int orient, int level[3], int dwtid[3]) {
/* <summary> */
/* Calculate explicit stepsizes for DWT. */
/* </summary> */
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) {
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec)
{
int totnumbands, bandno, diff;
assert(tccp->numresolution[0] >= tccp->numresolution[2]);

View File

@ -37,7 +37,8 @@
#ifndef _WIN32
static char*
i2a(unsigned i, char *a, unsigned r) {
i2a(unsigned i, char *a, unsigned r)
{
if (i/r > 0) a = i2a(i/r,a,r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
return a+1;
@ -52,13 +53,13 @@ i2a(unsigned i, char *a, unsigned r) {
@return Returns a
*/
static char *
_itoa(int i, char *a, int r) {
_itoa(int i, char *a, int r)
{
r = ((r < 2) || (r > 36)) ? 10 : r;
if(i < 0) {
*a = '-';
*i2a(-i, a+1, r) = 0;
}
else *i2a(i, a, r) = 0;
} else *i2a(i, a, r) = 0;
return a;
}
@ -66,7 +67,8 @@ _itoa(int i, char *a, int r) {
/* ----------------------------------------------------------------------- */
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context)
{
if(cinfo) {
opj_event_mgr_t *previous = cinfo->event_mgr;
cinfo->event_mgr = event_mgr;
@ -77,7 +79,8 @@ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_
return NULL;
}
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...)
{
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = NULL;
@ -120,8 +123,7 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
case '%' :
message[j++] = '%';
break;
case 'o' : /* octal numbers */
{
case 'o' : { /* octal numbers */
char tmp[16];
_itoa(va_arg(arg, int), tmp, 8);
strcat(message, tmp);
@ -130,8 +132,7 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
break;
}
case 'i' : /* decimal numbers */
case 'd' :
{
case 'd' : {
char tmp[16];
_itoa(va_arg(arg, int), tmp, 10);
strcat(message, tmp);
@ -139,8 +140,7 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
++i;
break;
}
case 'x' : /* hexadecimal numbers */
{
case 'x' : { /* hexadecimal numbers */
char tmp[16];
_itoa(va_arg(arg, int), tmp, 16);
strcat(message, tmp);
@ -148,16 +148,14 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
++i;
break;
}
case 's' : /* strings */
{
case 's' : { /* strings */
char *tmp = va_arg(arg, char*);
strcat(message, tmp);
j += strlen(tmp);
++i;
break;
}
case 'f' : /* floats */
{
case 'f' : { /* floats */
char tmp[16];
double value = va_arg(arg, double);
sprintf(tmp, "%f", value);

View File

@ -57,7 +57,8 @@ Multiply two fixed-precision rational numbers.
@param b
@return Returns a * b
*/
static int fix_mul(int a, int b) {
static int fix_mul(int a, int b)
{
int64 temp = (int64) a * (int64) b >> 12;
return (int) ((temp >> 1) + (temp & 1)) ;
}

View File

@ -51,14 +51,16 @@ The functions in INT.H have for goal to realize operations on integers.
Get the minimum of two integers
@return Returns a if a < b else b
*/
static int int_min(int a, int b) {
static int int_min(int a, int b)
{
return a < b ? a : b;
}
/**
Get the maximum of two integers
@return Returns a if a > b else b
*/
static int int_max(int a, int b) {
static int int_max(int a, int b)
{
return (a > b) ? a : b;
}
/**
@ -70,7 +72,8 @@ Clamp an integer inside an interval
<li>Returns min if (a < min)
</ul>
*/
static int int_clamp(int a, int min, int max) {
static int int_clamp(int a, int min, int max)
{
if (a < min)
return min;
if (a > max)
@ -80,39 +83,45 @@ static int int_clamp(int a, int min, int max) {
/**
@return Get absolute value of integer
*/
static int int_abs(int a) {
static int int_abs(int a)
{
return a < 0 ? -a : a;
}
static double dbl_abs(double a) {
static double dbl_abs(double a)
{
return a < 0 ? -a : a;
}
/**
Divide an integer and round upwards
@return Returns a divided by b
*/
static int int_ceildiv(int a, int b) {
static int int_ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
/**
Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
static int int_ceildivpow2(int a, int b) {
static int int_ceildivpow2(int a, int b)
{
return (a + (1 << b) - 1) >> b;
}
/**
Divide an integer by a power of 2 and round downwards
@return Returns a divided by 2^b
*/
static int int_floordivpow2(int a, int b) {
static int int_floordivpow2(int a, int b)
{
return a >> b;
}
/**
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
static int int_floorlog2(int a) {
static int int_floorlog2(int a)
{
int l;
for (l = 0; a > 1; l++) {
a >>= 1;

View File

@ -321,7 +321,8 @@ static void j3d_read_nlt(opj_j3d_t *j3d);
/* ----------------------------------------------------------------------- */
static void j3d_dump_volume(FILE *fd, opj_volume_t * vol) {
static void j3d_dump_volume(FILE *fd, opj_volume_t * vol)
{
int compno;
fprintf(fd, "volume {\n");
fprintf(fd, " x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", vol->x0, vol->y0, vol->z0,vol->x1, vol->y1, vol->z1);
@ -337,7 +338,8 @@ static void j3d_dump_volume(FILE *fd, opj_volume_t * vol) {
fprintf(fd, "}\n");
}
static void j3d_dump_cp(FILE *fd, opj_volume_t * vol, opj_cp_t * cp) {
static void j3d_dump_cp(FILE *fd, opj_volume_t * vol, opj_cp_t * cp)
{
int tileno, compno, layno, bandno, resno, numbands;
fprintf(fd, "coding parameters {\n");
fprintf(fd, " tx0=%d, ty0=%d, tz0=%d\n", cp->tx0, cp->ty0, cp->tz0);
@ -415,7 +417,8 @@ static void j3d_dump_cp(FILE *fd, opj_volume_t * vol, opj_cp_t * cp) {
Extended capabilities
------------------------------------------------------------------------*/
static void j3d_write_cap(opj_j3d_t *j3d){
static void j3d_write_cap(opj_j3d_t *j3d)
{
int len,lenp;
opj_cio_t *cio = j3d->cio;
@ -423,8 +426,7 @@ static void j3d_write_cap(opj_j3d_t *j3d){
lenp = cio_tell(cio);
cio_skip(cio, 2);
cio_write(cio,J3D_CAP_10, 4);
if( J3D_CAP_10 )
{
if( J3D_CAP_10 ) {
cio_write(cio, 0x0, 2);
}
len = cio_tell(cio) - lenp;
@ -433,7 +435,8 @@ static void j3d_write_cap(opj_j3d_t *j3d){
cio_seek(cio, lenp + len);
}
static void j3d_read_cap(opj_j3d_t *j3d){
static void j3d_read_cap(opj_j3d_t *j3d)
{
int len, Cap;
opj_cio_t *cio = j3d->cio;
/*cio_read(cio, 2); CAP */
@ -444,7 +447,8 @@ static void j3d_read_cap(opj_j3d_t *j3d){
}
assert( len == 2 + 4 + 2 );
}
static void j3d_write_nsi(opj_j3d_t *j3d) {
static void j3d_write_nsi(opj_j3d_t *j3d)
{
int i;
int lenp, len;
int ndim = 3;
@ -470,7 +474,8 @@ static void j3d_write_nsi(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_nsi(opj_j3d_t *j3d) {
static void j3d_read_nsi(opj_j3d_t *j3d)
{
int ndim;
int len, i;
@ -519,7 +524,8 @@ static void j3d_read_nsi(opj_j3d_t *j3d) {
j3d->state = J3D_STATE_MH;
}
static void j3d_write_dco(opj_j3d_t *j3d){
static void j3d_write_dco(opj_j3d_t *j3d)
{
int lenp, len, i;
int dcotype;
@ -547,7 +553,8 @@ static void j3d_write_dco(opj_j3d_t *j3d){
cio_seek(cio, lenp + len);
}
static void j3d_read_dco(opj_j3d_t *j3d){
static void j3d_read_dco(opj_j3d_t *j3d)
{
int len, i;
int dcotype;
@ -572,7 +579,8 @@ static void j3d_read_dco(opj_j3d_t *j3d){
}
}
static void j3d_write_atk(opj_j3d_t *j3d){
static void j3d_write_atk(opj_j3d_t *j3d)
{
int lenp, len, s, k;
opj_cio_t *cio = j3d->cio;
@ -603,7 +611,8 @@ static void j3d_write_atk(opj_j3d_t *j3d){
cio_write(cio, len, 2); /* Latk */
cio_seek(cio, lenp + len);
}
static void j3d_read_atk(opj_j3d_t *j3d){
static void j3d_read_atk(opj_j3d_t *j3d)
{
int len, i, Satk, k;
opj_cio_t *cio = j3d->cio;
@ -634,39 +643,52 @@ static void j3d_read_atk(opj_j3d_t *j3d){
atk->Aatk[i][k] = ((double) cio_read(cio, 1 << atk->coeff_typ) / 8192.0);
}
}
static void j3d_write_cbd(opj_j3d_t *j3d){
static void j3d_write_cbd(opj_j3d_t *j3d)
{
}
static void j3d_read_cbd(opj_j3d_t *j3d){
static void j3d_read_cbd(opj_j3d_t *j3d)
{
}
static void j3d_write_mct(opj_j3d_t *j3d){
static void j3d_write_mct(opj_j3d_t *j3d)
{
}
static void j3d_read_mct(opj_j3d_t *j3d){
static void j3d_read_mct(opj_j3d_t *j3d)
{
}
static void j3d_write_mcc(opj_j3d_t *j3d){
static void j3d_write_mcc(opj_j3d_t *j3d)
{
}
static void j3d_read_mcc(opj_j3d_t *j3d){
static void j3d_read_mcc(opj_j3d_t *j3d)
{
}
static void j3d_write_mco(opj_j3d_t *j3d){
static void j3d_write_mco(opj_j3d_t *j3d)
{
}
static void j3d_read_mco(opj_j3d_t *j3d){
static void j3d_read_mco(opj_j3d_t *j3d)
{
}
static void j3d_write_nlt(opj_j3d_t *j3d){
static void j3d_write_nlt(opj_j3d_t *j3d)
{
}
static void j3d_read_nlt(opj_j3d_t *j3d){
static void j3d_read_nlt(opj_j3d_t *j3d)
{
}
/* -----------------------------------------------------------------------
15444-1 codestream syntax
------------------------------------------------------------------------*/
static void j3d_write_soc(opj_j3d_t *j3d) {
static void j3d_write_soc(opj_j3d_t *j3d)
{
opj_cio_t *cio = j3d->cio;
cio_write(cio, J3D_MS_SOC, 2);
}
static void j3d_read_soc(opj_j3d_t *j3d) {
static void j3d_read_soc(opj_j3d_t *j3d)
{
j3d->state = J3D_STATE_MHSIZ;
}
static void j3d_write_siz(opj_j3d_t *j3d) {
static void j3d_write_siz(opj_j3d_t *j3d)
{
int i;
int lenp, len;
int Rsiz;
@ -701,7 +723,8 @@ static void j3d_write_siz(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_siz(opj_j3d_t *j3d) {
static void j3d_read_siz(opj_j3d_t *j3d)
{
int len, i;
opj_cio_t *cio = j3d->cio;
@ -776,7 +799,8 @@ static void j3d_read_siz(opj_j3d_t *j3d) {
static void j3d_write_com(opj_j3d_t *j3d) {
static void j3d_write_com(opj_j3d_t *j3d)
{
unsigned int i;
int lenp, len;
@ -799,7 +823,8 @@ static void j3d_write_com(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_com(opj_j3d_t *j3d) {
static void j3d_read_com(opj_j3d_t *j3d)
{
int len;
opj_cio_t *cio = j3d->cio;
@ -811,7 +836,8 @@ static void j3d_read_com(opj_j3d_t *j3d) {
cio_skip(cio, len - 4); /*posible comments*/
}
static void j3d_write_cox(opj_j3d_t *j3d, int compno) {
static void j3d_write_cox(opj_j3d_t *j3d, int compno)
{
int i;
int shift = 2;
@ -846,15 +872,16 @@ static void j3d_write_cox(opj_j3d_t *j3d, int compno) {
for (i = 0; i < tccp->numresolution[0]; i++) {
if (i < tccp->numresolution[2])
cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4) + (tccp->prctsiz[2][i] << 8), 2); /* SPcox (N_i) Table A9*/
else
if (j3d->cinfo->codec_format == CODEC_J3D)
else if (j3d->cinfo->codec_format == CODEC_J3D)
cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4), 2); /* SPcox (N_i) Table A9*/
else
cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4), 1); /* SPcox (N_i) Table A9*/ }
cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4), 1); /* SPcox (N_i) Table A9*/
}
}
}
static void j3d_read_cox(opj_j3d_t *j3d, int compno) {
static void j3d_read_cox(opj_j3d_t *j3d, int compno)
{
int i;
int shift = 2;
@ -907,7 +934,8 @@ static void j3d_read_cox(opj_j3d_t *j3d, int compno) {
}
}
static void j3d_write_cod(opj_j3d_t *j3d) {
static void j3d_write_cod(opj_j3d_t *j3d)
{
opj_cp_t *cp = NULL;
opj_tcp_t *tcp = NULL;
int lenp, len;
@ -936,7 +964,8 @@ static void j3d_write_cod(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_cod(opj_j3d_t *j3d) {
static void j3d_read_cod(opj_j3d_t *j3d)
{
int len, i, pos;
opj_cio_t *cio = j3d->cio;
@ -961,7 +990,8 @@ static void j3d_read_cod(opj_j3d_t *j3d) {
}
}
static void j3d_write_coc(opj_j3d_t *j3d, int compno) {
static void j3d_write_coc(opj_j3d_t *j3d, int compno)
{
int lenp, len;
opj_cp_t *cp = j3d->cp;
@ -983,7 +1013,8 @@ static void j3d_write_coc(opj_j3d_t *j3d, int compno) {
cio_seek(cio, lenp + len);
}
static void j3d_read_coc(opj_j3d_t *j3d) {
static void j3d_read_coc(opj_j3d_t *j3d)
{
int len, compno;
opj_cp_t *cp = j3d->cp;
@ -997,7 +1028,8 @@ static void j3d_read_coc(opj_j3d_t *j3d) {
j3d_read_cox(j3d, compno);
}
static void j3d_write_qcx(opj_j3d_t *j3d, int compno) {
static void j3d_write_qcx(opj_j3d_t *j3d, int compno)
{
int bandno, numbands;
int expn, mant;
@ -1028,7 +1060,8 @@ static void j3d_write_qcx(opj_j3d_t *j3d, int compno) {
}
}
static void j3d_read_qcx(opj_j3d_t *j3d, int compno, int len) {
static void j3d_read_qcx(opj_j3d_t *j3d, int compno, int len)
{
int tmp;
int bandno, numbands;
@ -1071,7 +1104,8 @@ static void j3d_read_qcx(opj_j3d_t *j3d, int compno, int len) {
/* ddA */
}
static void j3d_write_qcd(opj_j3d_t *j3d) {
static void j3d_write_qcd(opj_j3d_t *j3d)
{
int lenp, len;
opj_cio_t *cio = j3d->cio;
@ -1086,7 +1120,8 @@ static void j3d_write_qcd(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_qcd(opj_j3d_t *j3d) {
static void j3d_read_qcd(opj_j3d_t *j3d)
{
int len, i, pos;
opj_cio_t *cio = j3d->cio;
@ -1100,7 +1135,8 @@ static void j3d_read_qcd(opj_j3d_t *j3d) {
}
}
static void j3d_write_qcc(opj_j3d_t *j3d, int compno) {
static void j3d_write_qcc(opj_j3d_t *j3d, int compno)
{
int lenp, len;
opj_cio_t *cio = j3d->cio;
@ -1116,7 +1152,8 @@ static void j3d_write_qcc(opj_j3d_t *j3d, int compno) {
cio_seek(cio, lenp + len);
}
static void j3d_read_qcc(opj_j3d_t *j3d) {
static void j3d_read_qcc(opj_j3d_t *j3d)
{
int len, compno;
int numcomp = j3d->volume->numcomps;
opj_cio_t *cio = j3d->cio;
@ -1126,7 +1163,8 @@ static void j3d_read_qcc(opj_j3d_t *j3d) {
j3d_read_qcx(j3d, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
}
static void j3d_write_poc(opj_j3d_t *j3d) {
static void j3d_write_poc(opj_j3d_t *j3d)
{
int len, numpchgs, i;
int numcomps = j3d->volume->numcomps;
@ -1154,7 +1192,8 @@ static void j3d_write_poc(opj_j3d_t *j3d) {
}
}
static void j3d_read_poc(opj_j3d_t *j3d) {
static void j3d_read_poc(opj_j3d_t *j3d)
{
int len, numpchgs, i, old_poc;
int numcomps = j3d->volume->numcomps;
@ -1184,7 +1223,8 @@ static void j3d_read_poc(opj_j3d_t *j3d) {
tcp->numpocs = numpchgs + old_poc - 1;
}
static void j3d_read_crg(opj_j3d_t *j3d) {
static void j3d_read_crg(opj_j3d_t *j3d)
{
int len, i, Xcrg_i, Ycrg_i, Zcrg_i;
opj_cio_t *cio = j3d->cio;
@ -1198,7 +1238,8 @@ static void j3d_read_crg(opj_j3d_t *j3d) {
}
}
static void j3d_read_tlm(opj_j3d_t *j3d) {
static void j3d_read_tlm(opj_j3d_t *j3d)
{
int len, Ztlm, Stlm, ST, SP, tile_tlm, i;
long int Ttlm_i, Ptlm_i;
@ -1216,7 +1257,8 @@ static void j3d_read_tlm(opj_j3d_t *j3d) {
}
}
static void j3d_read_plm(opj_j3d_t *j3d) {
static void j3d_read_plm(opj_j3d_t *j3d)
{
int len, i, Zplm, Nplm, add, packet_len = 0;
opj_cio_t *cio = j3d->cio;
@ -1241,7 +1283,8 @@ static void j3d_read_plm(opj_j3d_t *j3d) {
}
}
static void j3d_read_plt(opj_j3d_t *j3d) {
static void j3d_read_plt(opj_j3d_t *j3d)
{
int len, i, Zplt, packet_len = 0, add;
opj_cio_t *cio = j3d->cio;
@ -1258,7 +1301,8 @@ static void j3d_read_plt(opj_j3d_t *j3d) {
}
}
static void j3d_read_ppm(opj_j3d_t *j3d) {
static void j3d_read_ppm(opj_j3d_t *j3d)
{
int len, Z_ppm, i, j;
int N_ppm;
@ -1299,7 +1343,8 @@ static void j3d_read_ppm(opj_j3d_t *j3d) {
}
}
static void j3d_read_ppt(opj_j3d_t *j3d) {
static void j3d_read_ppt(opj_j3d_t *j3d)
{
int len, Z_ppt, i, j = 0;
opj_cp_t *cp = j3d->cp;
@ -1327,7 +1372,8 @@ static void j3d_read_ppt(opj_j3d_t *j3d) {
tcp->ppt_store = j;
}
static void j3d_write_sot(opj_j3d_t *j3d) {
static void j3d_write_sot(opj_j3d_t *j3d)
{
int lenp, len;
opj_cio_t *cio = j3d->cio;
@ -1346,7 +1392,8 @@ static void j3d_write_sot(opj_j3d_t *j3d) {
cio_seek(cio, lenp + len);
}
static void j3d_read_sot(opj_j3d_t *j3d) {
static void j3d_read_sot(opj_j3d_t *j3d)
{
int len, tileno, totlen, partno, numparts, i;
opj_tcp_t *tcp = NULL;
char status = 0;
@ -1401,7 +1448,8 @@ static void j3d_read_sot(opj_j3d_t *j3d) {
}
}
static void j3d_write_sod(opj_j3d_t *j3d, void *tile_coder) {
static void j3d_write_sod(opj_j3d_t *j3d, void *tile_coder)
{
int l, layno;
int totlen;
opj_tcp_t *tcp = NULL;
@ -1441,7 +1489,8 @@ static void j3d_write_sod(opj_j3d_t *j3d, void *tile_coder) {
cio_seek(cio, j3d->sot_start + totlen);
}
static void j3d_read_sod(opj_j3d_t *j3d) {
static void j3d_read_sod(opj_j3d_t *j3d)
{
int len, truncate = 0, i;
unsigned char *data = NULL, *data_ptr = NULL;
@ -1476,7 +1525,8 @@ static void j3d_read_sod(opj_j3d_t *j3d) {
}
}
static void j3d_write_rgn(opj_j3d_t *j3d, int compno, int tileno) {
static void j3d_write_rgn(opj_j3d_t *j3d, int compno, int tileno)
{
opj_cp_t *cp = j3d->cp;
opj_tcp_t *tcp = &cp->tcps[tileno];
@ -1490,7 +1540,8 @@ static void j3d_write_rgn(opj_j3d_t *j3d, int compno, int tileno) {
cio_write(cio, tcp->tccps[compno].roishift, 1); /* SPrgn */
}
static void j3d_read_rgn(opj_j3d_t *j3d) {
static void j3d_read_rgn(opj_j3d_t *j3d)
{
int len, compno, roisty;
opj_cp_t *cp = j3d->cp;
@ -1504,13 +1555,15 @@ static void j3d_read_rgn(opj_j3d_t *j3d) {
tcp->tccps[compno].roishift = cio_read(cio, 1); /* SPrgn */
}
static void j3d_write_eoc(opj_j3d_t *j3d) {
static void j3d_write_eoc(opj_j3d_t *j3d)
{
opj_cio_t *cio = j3d->cio;
/* opj_event_msg(j3d->cinfo, "%.8x: EOC\n", cio_tell(cio) + j3d->pos_correction); */
cio_write(cio, J3D_MS_EOC, 2);
}
static void j3d_read_eoc(opj_j3d_t *j3d) {
static void j3d_read_eoc(opj_j3d_t *j3d)
{
int i, tileno;
#ifndef NO_PACKETS_DECODING
@ -1538,7 +1591,8 @@ static void j3d_read_eoc(opj_j3d_t *j3d) {
j3d->state = J3D_STATE_MT;
}
static void j3d_read_unk(opj_j3d_t *j3d) {
static void j3d_read_unk(opj_j3d_t *j3d)
{
opj_event_msg(j3d->cinfo, EVT_WARNING, "Unknown marker\n");
}
@ -1549,8 +1603,11 @@ static opj_atk_t atk_info_wt[] = {
{3, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-1}, {0,1,2}, {0,1,2}, {1,1,3}, {{-1.0},{1.0},{1.0,0.0,-1.0}}}, /* WT 2-6 REV*/
{4, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-2}, {0,1,6}, {0,1,32}, {1,1,5}, {{-1},{1},{-3.0,22.0,0.0,-22.0,3.0}}}, /* WT 2-10 REV*/
{5, 1, J3D_ATK_ARB, J3D_ATK_IRR, 1, J3D_ATK_WS, 1, 7, {0}, {0}, {0}, {1,1,2,1,2,1,3},{{-1},{1.58613434206},{-0.460348209828, 0.460348209828},{0.25},{0.374213867768,-0.374213867768},{-1.33613434206},{0.29306717103,0,-0.29306717103}}}, /* WT 6-10 IRR*/
{6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}}}, /* WT 10-18 IRR*/
{
6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}
}
}, /* WT 10-18 IRR*/
{7, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 2, {0}, {0}, {0}, {1,1}, {-0.5, 0.25}}, /* WT 5-3 IRR*/
{8, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {4,4}, {8,8}, {2,2}, {{-9,1},{5,-1}}} /* WT 13-7 REV*/
};
@ -1606,7 +1663,8 @@ opj_dec_mstabent_t j3d_dec_mstab[] = {
Read the lookup table containing all the marker, status and action
@param id Marker value
*/
static opj_dec_mstabent_t *j3d_dec_mstab_lookup(int id) {
static opj_dec_mstabent_t *j3d_dec_mstab_lookup(int id)
{
opj_dec_mstabent_t *e;
for (e = j3d_dec_mstab; e->id != 0; e++) {
if (e->id == id) {
@ -1620,7 +1678,8 @@ static opj_dec_mstabent_t *j3d_dec_mstab_lookup(int id) {
/* J3D / JPT decoder interface */
/* ----------------------------------------------------------------------- */
opj_j3d_t* j3d_create_decompress(opj_common_ptr cinfo) {
opj_j3d_t* j3d_create_decompress(opj_common_ptr cinfo)
{
opj_j3d_t *j3d = (opj_j3d_t*)opj_malloc(sizeof(opj_j3d_t));
if(j3d) {
j3d->cinfo = cinfo;
@ -1633,7 +1692,8 @@ opj_j3d_t* j3d_create_decompress(opj_common_ptr cinfo) {
return j3d;
}
void j3d_destroy_decompress(opj_j3d_t *j3d) {
void j3d_destroy_decompress(opj_j3d_t *j3d)
{
int i = 0;
if(j3d->tile_len != NULL) {
@ -1681,7 +1741,8 @@ void j3d_destroy_decompress(opj_j3d_t *j3d) {
opj_free(j3d);
}
void j3d_setup_decoder(opj_j3d_t *j3d, opj_dparameters_t *parameters) {
void j3d_setup_decoder(opj_j3d_t *j3d, opj_dparameters_t *parameters)
{
if(j3d && parameters) {
/* create and initialize the coding parameters structure */
opj_cp_t *cp = (opj_cp_t*)opj_malloc(sizeof(opj_cp_t));
@ -1701,7 +1762,8 @@ void j3d_setup_decoder(opj_j3d_t *j3d, opj_dparameters_t *parameters) {
}
}
opj_volume_t* j3d_decode(opj_j3d_t *j3d, opj_cio_t *cio) {
opj_volume_t* j3d_decode(opj_j3d_t *j3d, opj_cio_t *cio)
{
opj_volume_t *volume = NULL;
opj_common_ptr cinfo = j3d->cinfo;
@ -1755,7 +1817,8 @@ opj_volume_t* j3d_decode(opj_j3d_t *j3d, opj_cio_t *cio) {
/* J3D encoder interface */
/* ----------------------------------------------------------------------- */
opj_j3d_t* j3d_create_compress(opj_common_ptr cinfo) {
opj_j3d_t* j3d_create_compress(opj_common_ptr cinfo)
{
opj_j3d_t *j3d = (opj_j3d_t*)opj_malloc(sizeof(opj_j3d_t));
if(j3d) {
j3d->cinfo = cinfo;
@ -1763,7 +1826,8 @@ opj_j3d_t* j3d_create_compress(opj_common_ptr cinfo) {
return j3d;
}
void j3d_destroy_compress(opj_j3d_t *j3d) {
void j3d_destroy_compress(opj_j3d_t *j3d)
{
int tileno;
if(!j3d) return;
@ -1800,7 +1864,8 @@ void j3d_destroy_compress(opj_j3d_t *j3d) {
opj_free(j3d);
}
void j3d_setup_encoder(opj_j3d_t *j3d, opj_cparameters_t *parameters, opj_volume_t *volume) {
void j3d_setup_encoder(opj_j3d_t *j3d, opj_cparameters_t *parameters, opj_volume_t *volume)
{
int i, j, tileno, numpocs_tile;
opj_cp_t *cp = NULL;
@ -1987,7 +2052,8 @@ Create an index file
@param index Index filename
@return Returns 1 if successful, returns 0 otherwise
*/
static int j3d_create_index(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_info_t *volume_info, char *index) {
static int j3d_create_index(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_info_t *volume_info, char *index)
{
int tileno, compno, layno, resno, precno, pack_nb, x, y, z;
FILE *stream = NULL;
@ -2224,7 +2290,8 @@ static int j3d_create_index(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_info_t *v
return 1;
}
bool j3d_encode(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_t *volume, char *index) {
bool j3d_encode(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_t *volume, char *index)
{
int tileno, compno;
opj_volume_info_t *volume_info = NULL;
opj_cp_t *cp = NULL;

View File

@ -38,7 +38,8 @@
#endif /* _WIN32 */
#include "opj_includes.h"
double opj_clock() {
double opj_clock()
{
#ifdef _WIN32
/* WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
@ -62,7 +63,8 @@ double opj_clock() {
#endif /* _WIN32 */
}
void* opj_malloc( size_t size ) {
void* opj_malloc( size_t size )
{
void *memblock = malloc(size);
if(memblock) {
memset(memblock, 0, size);
@ -70,11 +72,13 @@ void* opj_malloc( size_t size ) {
return memblock;
}
void* opj_realloc( void *memblock, size_t size ) {
void* opj_realloc( void *memblock, size_t size )
{
return realloc(memblock, size);
}
void opj_free( void *memblock ) {
void opj_free( void *memblock )
{
free(memblock);
}

View File

@ -48,7 +48,8 @@ static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
/* <summary> */
/* Forward reversible MCT. */
/* </summary> */
void mct_encode(int *c0, int *c1, int *c2, int n) {
void mct_encode(int *c0, int *c1, int *c2, int n)
{
int i;
for (i = 0; i < n; i++) {
int r, g, b, y, u, v;
@ -67,7 +68,8 @@ void mct_encode(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Inverse reversible MCT. */
/* </summary> */
void mct_decode(int *c0, int *c1, int *c2, int n) {
void mct_decode(int *c0, int *c1, int *c2, int n)
{
int i;
for (i = 0; i < n; i++) {
int y, u, v, r, g, b;
@ -86,14 +88,16 @@ void mct_decode(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Get norm of basis function of reversible MCT. */
/* </summary> */
double mct_getnorm(int compno) {
double mct_getnorm(int compno)
{
return mct_norms[compno];
}
/* <summary> */
/* Forward irreversible MCT. */
/* </summary> */
void mct_encode_real(int *c0, int *c1, int *c2, int n) {
void mct_encode_real(int *c0, int *c1, int *c2, int n)
{
int i;
for (i = 0; i < n; i++) {
int r, g, b, y, u, v;
@ -112,7 +116,8 @@ void mct_encode_real(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Inverse irreversible MCT. */
/* </summary> */
void mct_decode_real(int *c0, int *c1, int *c2, int n) {
void mct_decode_real(int *c0, int *c1, int *c2, int n)
{
int i;
for (i = 0; i < n; i++) {
int y, u, v, r, g, b;
@ -131,6 +136,7 @@ void mct_decode_real(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Get norm of basis function of irreversible MCT. */
/* </summary> */
double mct_getnorm_real(int compno) {
double mct_getnorm_real(int compno)
{
return mct_norms_real[compno];
}

View File

@ -200,7 +200,8 @@ static opj_mqc_state_t mqc_states[47 * 2] = {
==========================================================
*/
static void mqc_byteout(opj_mqc_t *mqc) {
static void mqc_byteout(opj_mqc_t *mqc)
{
if (*mqc->bp == 0xff) {
mqc->bp++;
*mqc->bp = mqc->c >> 20;
@ -230,7 +231,8 @@ static void mqc_byteout(opj_mqc_t *mqc) {
}
}
static void mqc_renorme(opj_mqc_t *mqc) {
static void mqc_renorme(opj_mqc_t *mqc)
{
do {
mqc->a <<= 1;
mqc->c <<= 1;
@ -241,7 +243,8 @@ static void mqc_renorme(opj_mqc_t *mqc) {
} while ((mqc->a & 0x8000) == 0);
}
static void mqc_codemps(opj_mqc_t *mqc) {
static void mqc_codemps(opj_mqc_t *mqc)
{
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->a & 0x8000) == 0) {
if (mqc->a < (*mqc->curctx)->qeval) {
@ -256,7 +259,8 @@ static void mqc_codemps(opj_mqc_t *mqc) {
}
}
static void mqc_codelps(opj_mqc_t *mqc) {
static void mqc_codelps(opj_mqc_t *mqc)
{
mqc->a -= (*mqc->curctx)->qeval;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->c += (*mqc->curctx)->qeval;
@ -267,7 +271,8 @@ static void mqc_codelps(opj_mqc_t *mqc) {
mqc_renorme(mqc);
}
static void mqc_setbits(opj_mqc_t *mqc) {
static void mqc_setbits(opj_mqc_t *mqc)
{
unsigned int tempc = mqc->c + mqc->a;
mqc->c |= 0xffff;
if (mqc->c >= tempc) {
@ -275,7 +280,8 @@ static void mqc_setbits(opj_mqc_t *mqc) {
}
}
static int mqc_mpsexchange(opj_mqc_t *mqc) {
static int mqc_mpsexchange(opj_mqc_t *mqc)
{
int d;
if (mqc->a < (*mqc->curctx)->qeval) {
d = 1 - (*mqc->curctx)->mps;
@ -288,7 +294,8 @@ static int mqc_mpsexchange(opj_mqc_t *mqc) {
return d;
}
static int mqc_lpsexchange(opj_mqc_t *mqc) {
static int mqc_lpsexchange(opj_mqc_t *mqc)
{
int d;
if (mqc->a < (*mqc->curctx)->qeval) {
mqc->a = (*mqc->curctx)->qeval;
@ -303,7 +310,8 @@ static int mqc_lpsexchange(opj_mqc_t *mqc) {
return d;
}
static void mqc_bytein(opj_mqc_t *mqc) {
static void mqc_bytein(opj_mqc_t *mqc)
{
if (mqc->bp != mqc->end) {
unsigned int c;
if (mqc->bp + 1 != mqc->end) {
@ -331,7 +339,8 @@ static void mqc_bytein(opj_mqc_t *mqc) {
}
}
static void mqc_renormd(opj_mqc_t *mqc) {
static void mqc_renormd(opj_mqc_t *mqc)
{
do {
if (mqc->ct == 0) {
mqc_bytein(mqc);
@ -348,22 +357,26 @@ static void mqc_renormd(opj_mqc_t *mqc) {
==========================================================
*/
opj_mqc_t* mqc_create() {
opj_mqc_t* mqc_create()
{
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
return mqc;
}
void mqc_destroy(opj_mqc_t *mqc) {
void mqc_destroy(opj_mqc_t *mqc)
{
if(mqc) {
opj_free(mqc);
}
}
int mqc_numbytes(opj_mqc_t *mqc) {
int mqc_numbytes(opj_mqc_t *mqc)
{
return mqc->bp - mqc->start;
}
void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp) {
void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp)
{
mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
mqc->c = 0;
@ -375,11 +388,13 @@ void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp) {
mqc->start = bp;
}
void mqc_setcurctx(opj_mqc_t *mqc, int ctxno) {
void mqc_setcurctx(opj_mqc_t *mqc, int ctxno)
{
mqc->curctx = &mqc->ctxs[ctxno];
}
void mqc_encode(opj_mqc_t *mqc, int d) {
void mqc_encode(opj_mqc_t *mqc, int d)
{
if ((*mqc->curctx)->mps == d) {
mqc_codemps(mqc);
} else {
@ -387,7 +402,8 @@ void mqc_encode(opj_mqc_t *mqc, int d) {
}
}
void mqc_flush(opj_mqc_t *mqc) {
void mqc_flush(opj_mqc_t *mqc)
{
mqc_setbits(mqc);
mqc->c <<= mqc->ct;
mqc_byteout(mqc);
@ -399,7 +415,8 @@ void mqc_flush(opj_mqc_t *mqc) {
}
}
void mqc_bypass_init_enc(opj_mqc_t *mqc) {
void mqc_bypass_init_enc(opj_mqc_t *mqc)
{
mqc->c = 0;
mqc->ct = 8;
/*if (*mqc->bp == 0xff) {
@ -407,7 +424,8 @@ void mqc_bypass_init_enc(opj_mqc_t *mqc) {
} */
}
void mqc_bypass_enc(opj_mqc_t *mqc, int d) {
void mqc_bypass_enc(opj_mqc_t *mqc, int d)
{
mqc->ct--;
mqc->c = mqc->c + (d << mqc->ct);
if (mqc->ct == 0) {
@ -421,7 +439,8 @@ void mqc_bypass_enc(opj_mqc_t *mqc, int d) {
}
}
int mqc_bypass_flush_enc(opj_mqc_t *mqc) {
int mqc_bypass_flush_enc(opj_mqc_t *mqc)
{
unsigned char bit_padding;
bit_padding = 0;
@ -441,21 +460,24 @@ int mqc_bypass_flush_enc(opj_mqc_t *mqc) {
return 1;
}
void mqc_reset_enc(opj_mqc_t *mqc) {
void mqc_reset_enc(opj_mqc_t *mqc)
{
mqc_resetstates(mqc);
mqc_setstate(mqc, 18, 0, 46);
mqc_setstate(mqc, 0, 0, 3);
mqc_setstate(mqc, 1, 0, 4);
}
void mqc_reset_enc_3(opj_mqc_t *mqc) {
void mqc_reset_enc_3(opj_mqc_t *mqc)
{
mqc_resetstates(mqc);
mqc_setstate(mqc, T1_3D_CTXNO_UNI, 0, 46);
mqc_setstate(mqc, T1_3D_CTXNO_AGG, 0, 3);
mqc_setstate(mqc, T1_3D_CTXNO_ZC, 0, 4);
}
int mqc_restart_enc(opj_mqc_t *mqc) {
int mqc_restart_enc(opj_mqc_t *mqc)
{
int correction = 1;
/* <flush part> */
@ -471,7 +493,8 @@ int mqc_restart_enc(opj_mqc_t *mqc) {
return correction;
}
void mqc_restart_init_enc(opj_mqc_t *mqc) {
void mqc_restart_init_enc(opj_mqc_t *mqc)
{
/* <Re-init part> */
mqc_setcurctx(mqc, 0);
mqc->a = 0x8000;
@ -483,7 +506,8 @@ void mqc_restart_init_enc(opj_mqc_t *mqc) {
}
}
void mqc_erterm_enc(opj_mqc_t *mqc) {
void mqc_erterm_enc(opj_mqc_t *mqc)
{
int k = 11 - mqc->ct + 1;
while (k > 0) {
@ -498,7 +522,8 @@ void mqc_erterm_enc(opj_mqc_t *mqc) {
}
}
void mqc_segmark_enc(opj_mqc_t *mqc) {
void mqc_segmark_enc(opj_mqc_t *mqc)
{
int i;
mqc_setcurctx(mqc, 18);
@ -507,7 +532,8 @@ void mqc_segmark_enc(opj_mqc_t *mqc) {
}
}
void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len)
{
mqc_setcurctx(mqc, 0);
mqc->start = bp;
mqc->end = bp + len;
@ -520,7 +546,8 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
mqc->a = 0x8000;
}
int mqc_decode(opj_mqc_t *mqc) {
int mqc_decode(opj_mqc_t *mqc)
{
int d;
mqc->a -= (*mqc->curctx)->qeval;
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
@ -539,14 +566,16 @@ int mqc_decode(opj_mqc_t *mqc) {
return d;
}
void mqc_resetstates(opj_mqc_t *mqc) {
void mqc_resetstates(opj_mqc_t *mqc)
{
int i;
for (i = 0; i < MQC_NUMCTXS; i++) {
mqc->ctxs[i] = mqc_states;
}
}
void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob) {
void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob)
{
mqc->ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
}

View File

@ -41,7 +41,8 @@
#ifdef _WIN32
#ifndef OPJ_STATIC
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH :
break;
@ -59,10 +60,12 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version() {
const char* OPJ_CALLCONV opj_version()
{
return JP3D_VERSION;
}
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format)
{
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
dinfo->is_decompressor = true;
@ -86,7 +89,8 @@ opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
return dinfo;
}
void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo)
{
if(dinfo) {
/* destroy the codec */
if(dinfo->codec_format != CODEC_UNKNOWN) {
@ -97,7 +101,8 @@ void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
}
}
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters)
{
if(parameters) {
memset(parameters, 0, sizeof(opj_dparameters_t));
/* default decoding parameters */
@ -112,7 +117,8 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
}
}
void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters)
{
if(dinfo && parameters) {
if (dinfo->codec_format != CODEC_UNKNOWN) {
j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
@ -120,7 +126,8 @@ void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *param
}
}
opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio)
{
if(dinfo && cio) {
if (dinfo->codec_format != CODEC_UNKNOWN) {
return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
@ -130,7 +137,8 @@ opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
return NULL;
}
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format)
{
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
if(!cinfo) return NULL;
cinfo->is_decompressor = false;
@ -154,7 +162,8 @@ opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
return cinfo;
}
void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo)
{
if(cinfo) {
/* destroy the codec */
if (cinfo->codec_format != CODEC_UNKNOWN) {
@ -165,7 +174,8 @@ void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
}
}
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters)
{
if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */
@ -192,7 +202,8 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
}
}
void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume)
{
if(cinfo && parameters && volume) {
if (cinfo->codec_format != CODEC_UNKNOWN) {
j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
@ -200,7 +211,8 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param
}
}
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index)
{
if(cinfo && cio && volume) {
if (cinfo->codec_format != CODEC_UNKNOWN) {
return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);

View File

@ -83,7 +83,8 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi);
==========================================================
*/
static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
static bool pi_next_lrcp(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@ -114,7 +115,8 @@ static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return true;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
@ -124,7 +126,8 @@ LABEL_SKIP:;
return false;
}
static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
static bool pi_next_rlcp(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@ -152,7 +155,8 @@ static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return true;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -161,7 +165,8 @@ LABEL_SKIP:;
return false;
}
static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
static bool pi_next_rpcl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@ -241,7 +246,8 @@ static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return true;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -252,7 +258,8 @@ static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
return false;
}
static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
static bool pi_next_pcrl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@ -335,7 +342,8 @@ for (pi->z = pi->tz0; pi->z < pi->tz1; pi->z += pi->dz - (pi->z % pi->dz)) {
pi->include[index] = 1;
return true;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -346,7 +354,8 @@ LABEL_SKIP:;
return false;
}
static bool pi_next_cprl(opj_pi_iterator_t * pi) {
static bool pi_next_cprl(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@ -426,7 +435,8 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) {
pi->include[index] = 1;
return true;
}
LABEL_SKIP:;
LABEL_SKIP:
;
}
}
}
@ -443,7 +453,8 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) {
==========================================================
*/
opj_pi_iterator_t *pi_create(opj_volume_t *volume, opj_cp_t *cp, int tileno) {
opj_pi_iterator_t *pi_create(opj_volume_t *volume, opj_cp_t *cp, int tileno)
{
int p, q, r;
int compno, resno, pino;
opj_pi_iterator_t *pi = NULL;
@ -570,8 +581,7 @@ opj_pi_iterator_t *pi_create(opj_volume_t *volume, opj_cp_t *cp, int tileno) {
pi_destroy(pi, cp, tileno);
return NULL;
}
}
else {
} else {
pi[pino].include = pi[pino - 1].include;
}
@ -597,7 +607,8 @@ opj_pi_iterator_t *pi_create(opj_volume_t *volume, opj_cp_t *cp, int tileno) {
return pi;
}
void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno)
{
int compno, pino;
opj_tcp_t *tcp = &cp->tcps[tileno];
if(pi) {
@ -619,7 +630,8 @@ void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
}
}
bool pi_next(opj_pi_iterator_t * pi) {
bool pi_next(opj_pi_iterator_t * pi)
{
switch (pi->poc.prg) {
case LRCP:
return pi_next_lrcp(pi);

View File

@ -46,22 +46,26 @@
==========================================================
*/
opj_raw_t* raw_create() {
opj_raw_t* raw_create()
{
opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
return raw;
}
void raw_destroy(opj_raw_t *raw) {
void raw_destroy(opj_raw_t *raw)
{
if(raw) {
opj_free(raw);
}
}
int raw_numbytes(opj_raw_t *raw) {
int raw_numbytes(opj_raw_t *raw)
{
return raw->bp - raw->start;
}
void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len)
{
raw->start = bp;
raw->lenmax = len;
raw->len = 0;
@ -69,7 +73,8 @@ void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
raw->ct = 0;
}
int raw_decode(opj_raw_t *raw) {
int raw_decode(opj_raw_t *raw)
{
int d;
if (raw->ct == 0) {
raw->ct = 8;

View File

@ -136,23 +136,28 @@ static void t1_init_luts(opj_t1_t *t1);
/* ----------------------------------------------------------------------- */
static int t1_getctxno_zc(opj_t1_t *t1, int f, int orient) {
static int t1_getctxno_zc(opj_t1_t *t1, int f, int orient)
{
return t1->lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
}
static int t1_getctxno_sc(opj_t1_t *t1, int f) {
static int t1_getctxno_sc(opj_t1_t *t1, int f)
{
return t1->lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
}
static int t1_getctxno_mag(opj_t1_t *t1, int f) {
static int t1_getctxno_mag(opj_t1_t *t1, int f)
{
return t1->lut_ctxno_mag[(f & T1_SIG_OTH) | (((f & T1_REFINE) != 0) << 11)];
}
static int t1_getspb(opj_t1_t *t1, int f) {
static int t1_getspb(opj_t1_t *t1, int f)
{
return t1->lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
}
static int t1_getnmsedec_sig(opj_t1_t *t1, int x, int bitpos) {
static int t1_getnmsedec_sig(opj_t1_t *t1, int x, int bitpos)
{
if (bitpos > T1_NMSEDEC_FRACBITS) {
return t1->lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -160,7 +165,8 @@ static int t1_getnmsedec_sig(opj_t1_t *t1, int x, int bitpos) {
return t1->lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static int t1_getnmsedec_ref(opj_t1_t *t1, int x, int bitpos) {
static int t1_getnmsedec_ref(opj_t1_t *t1, int x, int bitpos)
{
if (bitpos > T1_NMSEDEC_FRACBITS) {
return t1->lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -168,7 +174,8 @@ static int t1_getnmsedec_ref(opj_t1_t *t1, int x, int bitpos) {
return t1->lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static void t1_updateflags(int *fp, int s) {
static void t1_updateflags(int *fp, int s)
{
int *np = fp - (T1_MAXCBLKW + 2);
int *sp = fp + (T1_MAXCBLKW + 2);
np[-1] |= T1_SIG_SE;
@ -187,7 +194,8 @@ static void t1_updateflags(int *fp, int s) {
}
}
static void t1_enc_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc) {
static void t1_enc_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc)
{
int v, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -219,7 +227,8 @@ static void t1_enc_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int
}
}
static void t1_dec_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, char type, int vsc) {
static void t1_dec_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, char type, int vsc)
{
int v, flag;
opj_raw_t *raw = t1->raw; /* RAW component */
@ -248,7 +257,8 @@ static void t1_dec_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int
}
} /* VSC and BYPASS by Antonin */
static void t1_enc_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty) {
static void t1_enc_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty)
{
int i, j, k, m, one, vsc;
*nmsedec = 0;
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
@ -264,7 +274,8 @@ static void t1_enc_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orie
}
}
static void t1_dec_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty) {
static void t1_dec_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty)
{
int i, j, k, m, one, half, oneplushalf, vsc;
one = 1 << bpno;
half = one >> 1;
@ -281,7 +292,8 @@ static void t1_dec_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orie
}
} /* VSC and BYPASS by Antonin */
static void t1_enc_refpass_step(opj_t1_t *t1, int *fp, int *dp, int bpno, int one, int *nmsedec, char type, int vsc) {
static void t1_enc_refpass_step(opj_t1_t *t1, int *fp, int *dp, int bpno, int one, int *nmsedec, char type, int vsc)
{
int v, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -301,7 +313,8 @@ static void t1_enc_refpass_step(opj_t1_t *t1, int *fp, int *dp, int bpno, int on
}
}
static void t1_dec_refpass_step(opj_t1_t *t1, int *fp, int *dp, int poshalf, int neghalf, char type, int vsc) {
static void t1_dec_refpass_step(opj_t1_t *t1, int *fp, int *dp, int poshalf, int neghalf, char type, int vsc)
{
int v, t, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -322,7 +335,8 @@ static void t1_dec_refpass_step(opj_t1_t *t1, int *fp, int *dp, int poshalf, int
}
} /* VSC and BYPASS by Antonin */
static void t1_enc_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty) {
static void t1_enc_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty)
{
int i, j, k, m, one, vsc;
*nmsedec = 0;
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
@ -338,7 +352,8 @@ static void t1_enc_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, int *nms
}
}
static void t1_dec_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, char type, int cblksty) {
static void t1_dec_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, char type, int cblksty)
{
int i, j, k, m, one, poshalf, neghalf;
int vsc;
one = 1 << bpno;
@ -356,7 +371,8 @@ static void t1_dec_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, char typ
}
} /* VSC and BYPASS by Antonin */
static void t1_enc_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc) {
static void t1_enc_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc)
{
int v, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -382,7 +398,8 @@ LABEL_PARTIAL:
*fp &= ~T1_VISIT;
}
static void t1_dec_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, int partial, int vsc) {
static void t1_dec_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, int partial, int vsc)
{
int v, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -405,7 +422,8 @@ LABEL_PARTIAL:
*fp &= ~T1_VISIT;
} /* VSC and BYPASS by Antonin */
static void t1_enc_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty) {
static void t1_enc_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty)
{
int i, j, k, m, one, agg, runlen, vsc;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -456,7 +474,8 @@ static void t1_enc_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orie
}
}
static void t1_dec_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int cblksty) {
static void t1_dec_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int cblksty)
{
int i, j, k, m, one, half, oneplushalf, agg, runlen, vsc;
int segsym = cblksty & J3D_CCP_CBLKSTY_SEGSYM;
@ -518,7 +537,8 @@ static void t1_dec_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orie
} /* VSC and BYPASS by Antonin */
static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile) {
static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile)
{
int i, j, k;
int w, h, l;
int passno;
@ -645,7 +665,8 @@ static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int
cblk->totalpasses = passno;
}
static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty) {
static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty)
{
int i, j, k, w, h, l;
int bpno, passtype;
int segno, passno;
@ -714,7 +735,8 @@ static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int
}
}
static int t1_init_ctxno_zc(int f, int orient) {
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);
@ -786,7 +808,8 @@ static int t1_init_ctxno_zc(int f, int orient) {
return (T1_CTXNO_ZC + n);
}
static int t1_init_ctxno_sc(int f) {
static int t1_init_ctxno_sc(int f)
{
int hc, vc, n;
n = 0;
@ -827,7 +850,8 @@ static int t1_init_ctxno_sc(int f) {
return (T1_CTXNO_SC + n);
}
static int t1_init_ctxno_mag(int f) {
static int t1_init_ctxno_mag(int f)
{
int n;
if (!(f & T1_REFINE))
n = (f & (T1_SIG_OTH)) ? 1 : 0;
@ -837,7 +861,8 @@ static int t1_init_ctxno_mag(int f) {
return (T1_CTXNO_MAG + n);
}
static int t1_init_spb(int f) {
static int t1_init_spb(int f)
{
int hc, vc, n;
hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
@ -862,7 +887,8 @@ static int t1_init_spb(int f) {
return n;
}
static void t1_init_luts(opj_t1_t *t1) {
static void t1_init_luts(opj_t1_t *t1)
{
int i, j;
double u, v, t;
for (j = 0; j < 4; j++) {
@ -910,7 +936,8 @@ static void t1_init_luts(opj_t1_t *t1) {
/* ----------------------------------------------------------------------- */
opj_t1_t* t1_create(opj_common_ptr cinfo) {
opj_t1_t* t1_create(opj_common_ptr cinfo)
{
opj_t1_t *t1 = (opj_t1_t*)opj_malloc(sizeof(opj_t1_t));
if(t1) {
t1->cinfo = cinfo;
@ -923,7 +950,8 @@ opj_t1_t* t1_create(opj_common_ptr cinfo) {
return t1;
}
void t1_destroy(opj_t1_t *t1) {
void t1_destroy(opj_t1_t *t1)
{
if(t1) {
/* destroy MQC and RAW handles */
mqc_destroy(t1->mqc);
@ -934,7 +962,8 @@ void t1_destroy(opj_t1_t *t1) {
}
}
void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp)
{
int compno, resno, bandno, precno, cblkno;
int x, y, z, i, j, k, orient;
int n=0;
@ -1048,7 +1077,8 @@ void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
} /* compno */
}
void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp)
{
int compno, resno, bandno, precno, cblkno;
for (compno = 0; compno < tile->numcomps; compno++) {
@ -1167,7 +1197,8 @@ void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
/** mod fixed_quality */
double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3]) {
double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3])
{
double w1, w2, wmsedec;
if (dwtid[0] == 1 || dwtid[1] == 1 || dwtid[2] == 1) {

View File

@ -126,25 +126,30 @@ static void t1_3d_init_luts(opj_t1_3d_t *t1);
/* ----------------------------------------------------------------------- */
static int t1_3d_getctxno_zc(unsigned int f, int orient) {
static int t1_3d_getctxno_zc(unsigned int f, int orient)
{
return t1_3d_init_ctxno_zc((f & T1_3D_SIG_OTH), orient);
}
static int t1_3d_getctxno_sc(unsigned int f) {
static int t1_3d_getctxno_sc(unsigned int f)
{
return t1_3d_init_ctxno_sc((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN));
/*return t1->lut_ctxno_sc[((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN)) >> 4];*/
}
static int t1_3d_getctxno_mag(unsigned int f, int fsvr) {
static int t1_3d_getctxno_mag(unsigned int f, int fsvr)
{
return t1_3d_init_ctxno_mag((f & T1_3D_SIG_OTH), fsvr);
}
static int t1_3d_getspb(unsigned int f) {
static int t1_3d_getspb(unsigned int f)
{
return t1_3d_init_spb((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN));
/*return t1->lut_spb[((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN)) >> 4];*/
}
static int t1_3d_getnmsedec_sig(opj_t1_3d_t *t1, int x, int bitpos) {
static int t1_3d_getnmsedec_sig(opj_t1_3d_t *t1, int x, int bitpos)
{
if (bitpos > T1_NMSEDEC_FRACBITS) {
return t1->lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -152,7 +157,8 @@ static int t1_3d_getnmsedec_sig(opj_t1_3d_t *t1, int x, int bitpos) {
return t1->lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static int t1_3d_getnmsedec_ref(opj_t1_3d_t *t1, int x, int bitpos) {
static int t1_3d_getnmsedec_ref(opj_t1_3d_t *t1, int x, int bitpos)
{
if (bitpos > T1_NMSEDEC_FRACBITS) {
return t1->lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
}
@ -160,7 +166,8 @@ static int t1_3d_getnmsedec_ref(opj_t1_3d_t *t1, int x, int bitpos) {
return t1->lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
}
static void t1_3d_updateflags(unsigned int *fp, int s) {
static void t1_3d_updateflags(unsigned int *fp, int s)
{
unsigned int *np = fp - (T1_MAXCBLKW + 2);
unsigned int *sp = fp + (T1_MAXCBLKW + 2);
@ -212,7 +219,8 @@ static void t1_3d_updateflags(unsigned int *fp, int s) {
}
}
static void t1_3d_enc_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc) {
static void t1_3d_enc_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc)
{
int v, flagsvr;
unsigned int flag;
@ -246,7 +254,8 @@ static void t1_3d_enc_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr,
}
}
static void t1_3d_dec_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, char type, int vsc) {
static void t1_3d_dec_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, char type, int vsc)
{
int v, flagsvr;
unsigned int flag;
@ -277,7 +286,8 @@ static void t1_3d_dec_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr,
}
} /* VSC and BYPASS by Antonin */
static void t1_3d_enc_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty) {
static void t1_3d_enc_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty)
{
int i, j, k, m, one, vsc;
*nmsedec = 0;
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
@ -293,7 +303,8 @@ static void t1_3d_enc_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, in
}
}
static void t1_3d_dec_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty) {
static void t1_3d_dec_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty)
{
int i, j, k, m, one, half, oneplushalf, vsc;
one = 1 << bpno;
half = one >> 1;
@ -310,7 +321,8 @@ static void t1_3d_dec_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, in
}
} /* VSC and BYPASS by Antonin */
static void t1_3d_enc_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int bpno, int one, int *nmsedec, char type, int vsc) {
static void t1_3d_enc_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int bpno, int one, int *nmsedec, char type, int vsc)
{
int v, flagsvr;
unsigned int flag;
@ -332,7 +344,8 @@ static void t1_3d_enc_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr,
}
}
static void t1_3d_dec_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int poshalf, int neghalf, char type, int vsc) {
static void t1_3d_dec_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int poshalf, int neghalf, char type, int vsc)
{
int v, t, flagsvr;
unsigned int flag;
@ -355,7 +368,8 @@ static void t1_3d_dec_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr,
}
} /* VSC and BYPASS by Antonin */
static void t1_3d_enc_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty) {
static void t1_3d_enc_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty)
{
int i, j, k, m, one, vsc;
*nmsedec = 0;
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
@ -371,7 +385,8 @@ static void t1_3d_enc_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, in
}
}
static void t1_3d_dec_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, char type, int cblksty) {
static void t1_3d_dec_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, char type, int cblksty)
{
int i, j, k, m, one, poshalf, neghalf;
int vsc;
one = 1 << bpno;
@ -389,7 +404,8 @@ static void t1_3d_dec_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, ch
}
} /* VSC and BYPASS by Antonin */
static void t1_3d_enc_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc) {
static void t1_3d_enc_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc)
{
int v, flagsvr;
unsigned int flag;
@ -417,7 +433,8 @@ LABEL_PARTIAL:
*fsvr &= ~T1_3D_VISIT;
}
static void t1_3d_dec_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, int partial, int vsc) {
static void t1_3d_dec_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, int partial, int vsc)
{
int v, flagsvr;
unsigned int flag;
@ -442,7 +459,8 @@ LABEL_PARTIAL:
*fsvr &= ~T1_3D_VISIT;
} /* VSC and BYPASS by Antonin */
static void t1_3d_enc_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty) {
static void t1_3d_enc_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty)
{
int i, j, k, m, one, agg, runlen, vsc;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
@ -495,7 +513,8 @@ static void t1_3d_enc_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, in
}
}
static void t1_3d_dec_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int cblksty) {
static void t1_3d_dec_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int cblksty)
{
int i, j, k, m, one, half, oneplushalf, agg, runlen, vsc;
int segsym = cblksty & J3D_CCP_CBLKSTY_SEGSYM;
@ -560,7 +579,8 @@ static void t1_3d_dec_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, in
} /* VSC and BYPASS by Antonin */
static void t1_3d_encode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile) {
static void t1_3d_encode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile)
{
int i, j, k;
int w, h, l;
int passno;
@ -685,7 +705,8 @@ static void t1_3d_encode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient
cblk->totalpasses = passno;
}
static void t1_3d_decode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty) {
static void t1_3d_decode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty)
{
int i, j, k;
int w, h, l;
int bpno, passtype;
@ -757,7 +778,8 @@ static void t1_3d_decode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient
}
}
static int t1_3d_init_ctxno_zc(unsigned int f, int orient) {
static int t1_3d_init_ctxno_zc(unsigned int f, int orient)
{
unsigned int h, v, c;
unsigned int d2xy, d2xz, d2yz, d3;
int n;
@ -868,7 +890,8 @@ static int t1_3d_init_ctxno_zc(unsigned int f, int orient) {
return (T1_3D_CTXNO_ZC + n);
}
static int t1_3d_init_ctxno_sc(unsigned int f) {
static int t1_3d_init_ctxno_sc(unsigned int f)
{
int hc, vc, cc;
int n = 0;
@ -918,7 +941,8 @@ static int t1_3d_init_ctxno_sc(unsigned int f) {
return (T1_3D_CTXNO_SC + n);
}
static int t1_3d_init_ctxno_mag(unsigned int f, int f2) {
static int t1_3d_init_ctxno_mag(unsigned int f, int f2)
{
int n;
if (!(f2 & T1_3D_REFINE)) /*First refinement for this coefficient (no previous refinement)*/
n = (f & (T1_3D_SIG_PRIM)) ? 1 : 0;
@ -928,7 +952,8 @@ static int t1_3d_init_ctxno_mag(unsigned int f, int f2) {
return (T1_3D_CTXNO_MAG + n);
}
static int t1_3d_init_spb(unsigned int f) {
static int t1_3d_init_spb(unsigned int f)
{
int hc, vc, cc;
int n = 0;
@ -952,7 +977,8 @@ static int t1_3d_init_spb(unsigned int f) {
return n;
}
static void t1_3d_init_luts(opj_t1_3d_t *t1) {
static void t1_3d_init_luts(opj_t1_3d_t *t1)
{
int i;
double u, v, t;
/*for (j = 0; j < 4; j++) {
@ -999,7 +1025,8 @@ static void t1_3d_init_luts(opj_t1_3d_t *t1) {
/* ----------------------------------------------------------------------- */
opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo) {
opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo)
{
opj_t1_3d_t *t1 = (opj_t1_3d_t*)opj_malloc(sizeof(opj_t1_3d_t));
if(t1) {
t1->cinfo = cinfo;
@ -1012,7 +1039,8 @@ opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo) {
return t1;
}
void t1_3d_destroy(opj_t1_3d_t *t1) {
void t1_3d_destroy(opj_t1_3d_t *t1)
{
if(t1) {
/* destroy MQC and RAW handles */
mqc_destroy(t1->mqc);
@ -1021,7 +1049,8 @@ void t1_3d_destroy(opj_t1_3d_t *t1) {
}
}
void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp)
{
int compno, resno, bandno, precno, cblkno;
int x, y, z, i, j, k, orient;
int level[3];
@ -1116,7 +1145,8 @@ void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
} /* compno */
}
void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp)
{
int compno, resno, bandno, precno, cblkno;
for (compno = 0; compno < tile->numcomps; compno++) {

View File

@ -89,14 +89,16 @@ int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *
/* ----------------------------------------------------------------------- */
/* #define RESTART 0x04 */
static void t2_putcommacode(opj_bio_t *bio, int n) {
static void t2_putcommacode(opj_bio_t *bio, int n)
{
while (--n >= 0) {
bio_write(bio, 1, 1);
}
bio_write(bio, 0, 1);
}
static int t2_getcommacode(opj_bio_t *bio) {
static int t2_getcommacode(opj_bio_t *bio)
{
int n;
for (n = 0; bio_read(bio, 1); n++) {
;
@ -104,7 +106,8 @@ static int t2_getcommacode(opj_bio_t *bio) {
return n;
}
static void t2_putnumpasses(opj_bio_t *bio, int n) {
static void t2_putnumpasses(opj_bio_t *bio, int n)
{
if (n == 1) {
bio_write(bio, 0, 1);
} else if (n == 2) {
@ -118,7 +121,8 @@ static void t2_putnumpasses(opj_bio_t *bio, int n) {
}
}
static int t2_getnumpasses(opj_bio_t *bio) {
static int t2_getnumpasses(opj_bio_t *bio)
{
int n;
if (!bio_read(bio, 1))
return 1;
@ -131,7 +135,8 @@ static int t2_getnumpasses(opj_bio_t *bio) {
return (37 + bio_read(bio, 7));
}
static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_volume_info_t * volume_info, int tileno, opj_cp_t *cp) {
static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_volume_info_t * volume_info, int tileno, opj_cp_t *cp)
{
int bandno, cblkno;
unsigned char *sop = 0, *eph = 0;
unsigned char *c = dest;
@ -300,13 +305,13 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
return (c - dest);
}
static void t2_init_seg(opj_tcd_seg_t * seg, int cblksty, int first) {
static void t2_init_seg(opj_tcd_seg_t * seg, int cblksty, int first)
{
seg->numpasses = 0;
seg->len = 0;
if (cblksty & J3D_CCP_CBLKSTY_TERMALL) {
seg->maxpasses = 1;
}
else if (cblksty & J3D_CCP_CBLKSTY_LAZY) {
} else if (cblksty & J3D_CCP_CBLKSTY_LAZY) {
if (first) {
seg->maxpasses = 10;
} else {
@ -317,7 +322,8 @@ static void t2_init_seg(opj_tcd_seg_t * seg, int cblksty, int first) {
}
}
int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi) {
int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi)
{
int bandno, cblkno;
unsigned char *c = src;
@ -550,7 +556,8 @@ int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *
/* ----------------------------------------------------------------------- */
int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info) {
int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info)
{
unsigned char *c = dest;
int e = 0;
opj_pi_iterator_t *pi = NULL;
@ -611,7 +618,8 @@ int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlay
return (c - dest);
}
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile) {
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile)
{
unsigned char *c = src;
opj_pi_iterator_t *pi;
int pino, e = 0;
@ -662,7 +670,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
/* ----------------------------------------------------------------------- */
opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp) {
opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp)
{
/* create the tcd structure */
opj_t2_t *t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
if(!t2) return NULL;
@ -673,7 +682,8 @@ opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp) {
return t2;
}
void t2_destroy(opj_t2_t *t2) {
void t2_destroy(opj_t2_t *t2)
{
if(t2) {
opj_free(t2);
}

View File

@ -36,7 +36,8 @@
#include "opj_includes.h"
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_volume_t * vol) {
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_volume_t * vol)
{
int tileno, compno, resno, bandno, precno, cblkno;
fprintf(fd, "volume {\n");
@ -87,7 +88,8 @@ void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_volume_t * vol) {
fprintf(fd, "}\n");
}
static void tilec_dump(FILE *fd, opj_tcd_tilecomp_t *tilec) {
static void tilec_dump(FILE *fd, opj_tcd_tilecomp_t *tilec)
{
int i=0,k;
int datalen;
@ -135,7 +137,8 @@ static void tilec_dump(FILE *fd, opj_tcd_tilecomp_t *tilec) {
/**
Create a new TCD handle
*/
opj_tcd_t* tcd_create(opj_common_ptr cinfo) {
opj_tcd_t* tcd_create(opj_common_ptr cinfo)
{
/* create the tcd structure */
opj_tcd_t *tcd = (opj_tcd_t*)opj_malloc(sizeof(opj_tcd_t));
if(!tcd) return NULL;
@ -152,7 +155,8 @@ opj_tcd_t* tcd_create(opj_common_ptr cinfo) {
/**
Destroy a previously created TCD handle
*/
void tcd_destroy(opj_tcd_t *tcd) {
void tcd_destroy(opj_tcd_t *tcd)
{
if(tcd) {
opj_free(tcd->tcd_volume);
opj_free(tcd);
@ -160,7 +164,8 @@ void tcd_destroy(opj_tcd_t *tcd) {
}
/* ----------------------------------------------------------------------- */
void tcd_malloc_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno) {
void tcd_malloc_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno)
{
int compno, resno, bandno, precno, cblkno, i, j;/*, k;*/
opj_tcd_tile_t *tile = NULL; /* pointer to tcd->tile */
@ -447,7 +452,8 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int
/*tcd_dump(stdout, tcd, tcd->tcd_volume);*/
}
void tcd_init_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno) {
void tcd_init_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno)
{
int compno, resno, bandno, precno, cblkno;
int j, p, q, r;
@ -717,7 +723,8 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int c
}
void tcd_free_encode(opj_tcd_t *tcd) {
void tcd_free_encode(opj_tcd_t *tcd)
{
int tileno, compno, resno, bandno, precno;
opj_tcd_tile_t *tile = NULL; /* pointer to tcd->tile */
@ -773,7 +780,8 @@ void tcd_free_encode(opj_tcd_t *tcd) {
}
/* ----------------------------------------------------------------------- */
void tcd_malloc_decode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp) {
void tcd_malloc_decode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp)
{
int tileno, compno, resno, bandno, precno, cblkno, res_max,
i, j, p, q, r;
unsigned int x0 = 0, y0 = 0, z0 = 0,
@ -1042,7 +1050,8 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp) {
}
}
void tcd_free_decode(opj_tcd_t *tcd) {
void tcd_free_decode(opj_tcd_t *tcd)
{
int tileno,compno,resno,bandno,precno;
opj_tcd_volume_t *tcd_volume = tcd->tcd_volume;
@ -1079,7 +1088,8 @@ void tcd_free_decode(opj_tcd_t *tcd) {
/* ----------------------------------------------------------------------- */
void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final) {
void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final)
{
int compno, resno, bandno, precno, cblkno;
int value; /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolution[0]][3]; */
int matrice[10][10][3];
@ -1168,14 +1178,16 @@ void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final) {
}
}
void tcd_rateallocate_fixed(opj_tcd_t *tcd) {
void tcd_rateallocate_fixed(opj_tcd_t *tcd)
{
int layno;
for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
tcd_makelayer_fixed(tcd, layno, 1);
}
}
void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final)
{
int compno, resno, bandno, precno, cblkno, passno;
opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
@ -1248,7 +1260,8 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
}
}
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_info_t * volume_info) {
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_info_t * volume_info)
{
int compno, resno, bandno, precno, cblkno, passno, layno;
double min, max;
double cumdisto[100]; /* fixed_quality */
@ -1387,7 +1400,8 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_i
}
/* ----------------------------------------------------------------------- */
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_volume_info_t * volume_info) {
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_volume_info_t * volume_info)
{
int compno;
int l, i, npck = 0;
double encoding_time;
@ -1511,8 +1525,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op
/*-------------------ENTROPY CODING-----------------------------*/
fprintf(stdout,"[INFO] Tcd_encode_tile: Entropy coding\n");
if ((cp->encoding_format == ENCOD_2EB)||(cp->encoding_format == ENCOD_3EB))
{
if ((cp->encoding_format == ENCOD_2EB)||(cp->encoding_format == ENCOD_3EB)) {
if (cp->encoding_format == ENCOD_2EB) {
opj_t1_t *t1 = NULL;
t1 = t1_create(tcd->cinfo);
@ -1576,7 +1589,8 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op
}
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno) {
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno)
{
int l, i;
int compno, eof = 0;
double tile_time, t1_time, dwt_time;

View File

@ -40,7 +40,8 @@
Tag-tree coder interface
==========================================================
*/
void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree){
void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree)
{
int nodesno;
fprintf(fd, "TGT_TREE {\n");
@ -65,7 +66,8 @@ void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree){
}
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz) {
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz)
{
int nplh[32];
int nplv[32];
@ -151,12 +153,14 @@ opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz) {
return tree;
}
void tgt_destroy(opj_tgt_tree_t *tree) {
void tgt_destroy(opj_tgt_tree_t *tree)
{
opj_free(tree->nodes);
opj_free(tree);
}
void tgt_reset(opj_tgt_tree_t *tree) {
void tgt_reset(opj_tgt_tree_t *tree)
{
int i;
if (NULL == tree)
@ -169,7 +173,8 @@ void tgt_reset(opj_tgt_tree_t *tree) {
}
}
void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) {
void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value)
{
opj_tgt_node_t *node;
node = &tree->nodes[leafno];
while (node && node->value > value) {
@ -178,7 +183,8 @@ void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) {
}
}
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold)
{
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;
@ -218,7 +224,8 @@ void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold)
}
}
int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold)
{
opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr;
opj_tgt_node_t *node;

View File

@ -33,7 +33,8 @@
#include "volume.h"
#include "openjp3d.h"
opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc)
{
int compno;
opj_volume_t *volume = NULL;
@ -77,7 +78,8 @@ opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t
return volume;
}
void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume) {
void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume)
{
int i;
if(volume) {
if(volume->comps) {

View File

@ -128,8 +128,7 @@ void send_responsedata_on_aux( OPJ_BOOL istcp, auxtrans_param_t auxtrans, const
if( status != 0)
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
#endif
}
else
} else
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n");
}

View File

@ -114,8 +114,7 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset)
if((data2 = fetch_bytes( fd, offset+8, 8))) {
boxlen = big8(data2);
free(data2);
}
else{
} else {
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %" PRId64 ")\n", fd, offset);
free( data);
return NULL;
@ -203,8 +202,7 @@ box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const
if((data2 = fetch_bytes( fd, pos+8, 8))) {
boxlen = big8(data2);
free(data2);
}
else{
} else {
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
return NULL;
}
@ -221,8 +219,7 @@ box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const
return foundbox;
}
free( data);
}
else{
} else {
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
return NULL;
}
@ -287,8 +284,7 @@ box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, cons
{
OPJ_SIZE_T DBOXlen = get_DBoxlen(superbox);
assert( offset >= 0 );
if( DBOXlen < (OPJ_SIZE_T)offset )
{
if( DBOXlen < (OPJ_SIZE_T)offset ) {
fprintf( FCGI_stderr, "Error: Impossible happen %lu < %ld\n", DBOXlen, offset);
return NULL;
}

View File

@ -224,8 +224,7 @@ OPJ_BOOL is_allsent( cachemodel_param_t cachemodel)
}
}
return OPJ_TRUE;
}
else{
} else {
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
for( j=0; j<target->codeidx->SIZ.XTnum; j++)
for( k=0; k<TPnum; k++)

View File

@ -69,13 +69,11 @@ void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist
update_cachetid( tid, cache);
if( cid != NULL)
add_cachecid( cid, cache);
}
else{
} else {
cache = gene_cache( target, (int)msgqueue->last->csn, tid, cid);
insert_cache_into_list( cache, cachelist);
}
}
else
} else
cache = search_cacheBycsn( (int)msgqueue->last->csn, cachelist);
if( cache->metadatalist)

View File

@ -81,8 +81,7 @@ faixbox_param_t * gene_faixbox( box_param_t *box)
if( faix->version == 3)
subfaixbox->aux[i] = fetch_DBox4bytebigendian( box, (pos+=4)-4);
}
}
else{
} else {
subfaixbox4_param_t *subfaixbox;
size_t i;
@ -137,8 +136,7 @@ void delete_faixbox( faixbox_param_t **faix)
if( (*faix)->version == 3)
free((*faix)->subfaixbox.byte8_params->aux);
free((*faix)->subfaixbox.byte8_params);
}
else{
} else {
free((*faix)->subfaixbox.byte4_params->elem);
if( (*faix)->version == 2)
free((*faix)->subfaixbox.byte4_params->aux);

View File

@ -67,8 +67,7 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
if( rx == -1 || ry == -1) {
imgreg.ox = 0;
imgreg.oy = 0;
}
else{
} else {
imgreg.ox = rx*imgreg.fx/fx;
imgreg.oy = ry*imgreg.fy/fy;
}
@ -76,8 +75,7 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
if( rw == -1 || rh == -1) {
imgreg.sx = imgreg.fx;
imgreg.sy = imgreg.fy;
}
else{
} else {
px = (int)ceil((double)((rx+rw)*imgreg.fx)/(double)fx);
py = (int)ceil((double)((ry+rh)*imgreg.fy)/(double)fy);
@ -111,8 +109,7 @@ void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, i
if ((*fx < 1 && xwidth != 0) || (*fy < 1 && ywidth != 0)) {
fprintf( FCGI_stderr, "Frame size must be strictly positive");
exit(-1);
}
else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
} else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
/* Simulate the ceil function. */
*xmin = (int)ceil((double)*xmin/(double)2.0);
*ymin = (int)ceil((double)*ymin/(double)2.0);

View File

@ -42,7 +42,8 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
char buf[BUF_LEN];
static const char *magicid[] = { "JPIP-stream", "PNM request", "XML request",
"TID request", "CID request", "CID destroy", "SIZ request", "JP2 save",
"QUIT"};
"QUIT"
};
int i;
receive_size = receive_line( connected_socket, buf);
@ -102,8 +103,7 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid,
}
idatalen = atoi( buf);
if( idatalen < 0 )
{
if( idatalen < 0 ) {
fprintf( stderr, "Receive Data: %d Bytes\n", idatalen);
return NULL;
}

View File

@ -641,8 +641,7 @@ OPJ_BOOL set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestr
COD->XPsiz[i] = (Byte2_t)pow( 2, fetch_marker1byte( codmkr, 12+i) & 0x0F);
COD->YPsiz[i] = (Byte2_t)pow( 2,(fetch_marker1byte( codmkr, 12+i) & 0xF0) >> 4);
}
}
else{
} else {
COD->XPsiz = (Byte4_t *)opj_malloc( sizeof(Byte4_t));
COD->YPsiz = (Byte4_t *)opj_malloc( sizeof(Byte4_t));

View File

@ -135,8 +135,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
COD.XPsiz[i] = (Byte4_t)pow( 2, *( CODstream+12+i) & 0x0F);
COD.YPsiz[i] = (Byte4_t)pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
}
}
else{
} else {
COD.XPsiz = (Byte4_t *)opj_malloc( sizeof(Byte4_t));
COD.YPsiz = (Byte4_t *)opj_malloc( sizeof(Byte4_t));
COD.XPsiz[0] = COD.YPsiz[0] = 1<<15; /*pow(2,15)*/
@ -219,8 +218,7 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
*CODstream++ = (Byte_t)((Byte2_t)(newLcod & 0xff00) >> 8);
*CODstream++ = (Byte_t)(newLcod & 0x00ff);
}
else{
} else {
newLcod = COD.Lcod;
CODstream += 2;
}

View File

@ -132,21 +132,24 @@ Byte_t * j2k_to_pnm( const char *fn, ihdrbox_param_t **ihdrbox)
/**
sample error callback expecting a FILE* client object
*/
static void error_callback(const char *msg, void *client_data) {
static void error_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[ERROR] %s", msg);
}
/**
sample warning callback expecting a FILE* client object
*/
static void warning_callback(const char *msg, void *client_data) {
static void warning_callback(const char *msg, void *client_data)
{
FILE *stream = (FILE*)client_data;
fprintf(stream, "[WARNING] %s", msg);
}
/**
sample debug callback expecting no client object
*/
static void info_callback(const char *msg, void *client_data) {
static void info_callback(const char *msg, void *client_data)
{
(void)client_data;
(void)msg;
/* fprintf(stdout, "[INFO] %s", msg); */
@ -172,8 +175,7 @@ static Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
if( (*ihdrbox)->bpc != image->comps[0].prec)
fprintf( stderr, "Exception: bits per component not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].prec, (*ihdrbox)->bpc);
}
else{
} else {
*ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t));
(*ihdrbox)->width = image->comps[0].w;
(*ihdrbox)->height = image->comps[0].h;
@ -188,23 +190,20 @@ static Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
if (image->comps[0].prec > 8) {
adjustR = image->comps[0].prec - 8;
printf("PNM CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
}
else
} else
adjustR = 0;
if( image->numcomps == 3) {
if (image->comps[1].prec > 8) {
adjustG = image->comps[1].prec - 8;
printf("PNM CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
}
else
} else
adjustG = 0;
if (image->comps[2].prec > 8) {
adjustB = image->comps[2].prec - 8;
printf("PNM CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
}
else
} else
adjustB = 0;
}

View File

@ -109,8 +109,7 @@ Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn
jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen;
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
jp2cDBoxlen = *jp2len - jp2cDBoxOffset;
}
else
} else
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
}
jp2stream = add_msgstream( ptr, jpipstream, jp2stream, jp2len);
@ -151,8 +150,7 @@ OPJ_BOOL isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue)
if( msg->csn == csn) {
if( msg->class_id <= 2)
return OPJ_TRUE;
else
if( msg->class_id == 4 || msg->class_id == 5)
else if( msg->class_id == 4 || msg->class_id == 5)
return OPJ_FALSE;
}
msg = msg->next;
@ -274,8 +272,7 @@ Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *j
if( foundTH) {
j2kstream = recons_bitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, &max_reslev, j2klen);
modify_tileheader( j2kstream, SOToffset, (max_reslev<COD.numOfdecomp ? max_reslev : -1), SIZ.Csiz, j2klen);
}
else
} else
j2kstream = add_emptytilestream( tileID, j2kstream, j2klen);
}
@ -459,8 +456,7 @@ Byte_t * recons_PCRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, B
if( numOfprcts < min_numOfprcts || min_numOfprcts == 0)
min_numOfprcts = numOfprcts;
}
}
else
} else
min_numOfprcts = 1;
for( p=0; p<min_numOfprcts; p++)
@ -491,8 +487,7 @@ Byte_t * recons_CPRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, B
if( numOfprcts < min_numOfprcts || min_numOfprcts == 0)
min_numOfprcts = numOfprcts;
}
}
else
} else
min_numOfprcts = 1;
for( c=0; c<SIZ.Csiz; c++)
@ -618,8 +613,7 @@ Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, OPJ_BOOL isjpp
if( isjppstream) {
if((msg->class_id == TILE_HEADER_MSG) && msg->csn == csn && last_tileID < msg->in_class_id)
last_tileID = msg->in_class_id;
}
else{
} else {
if((msg->class_id == TILE_MSG || msg->class_id == EXT_TILE_MSG) && msg->csn == csn && last_tileID < msg->in_class_id)
last_tileID = msg->in_class_id;
}
@ -635,8 +629,7 @@ message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t
if( in_class_id == (Byte8_t)-1) {
if( msg->class_id == class_id && msg->csn == csn)
return msg;
}
else{
} else {
if( msg->class_id == class_id && msg->in_class_id == in_class_id && msg->csn == csn)
return msg;
}

View File

@ -68,8 +68,7 @@ OPJ_BOOL identify_target( query_param_t query_param, targetlist_param_t *targetl
if( *target) {
fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", (*target)->tid);
return OPJ_TRUE;
}
else{
} else {
fprintf( FCGI_stdout, "Reason: target not found\r\n");
fprintf( FCGI_stdout, "Status: 400\r\n");
return OPJ_FALSE;
@ -85,8 +84,7 @@ OPJ_BOOL associate_channel( query_param_t query_param,
if( !query_param.cnew)
set_channel_variable_param( query_param, *curchannel);
}
else{
} else {
fprintf( FCGI_stderr, "Error: process canceled\n");
return OPJ_FALSE;
}
@ -108,9 +106,7 @@ OPJ_BOOL open_channel( query_param_t query_param,
if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist)))
if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target, query_param.return_type==JPPstream)))
return OPJ_FALSE;
}
else
if( *curchannel)
} else if( *curchannel)
cachemodel = (*curchannel)->cachemodel;
*curchannel = gene_channel( query_param, auxtrans, cachemodel, (*cursession)->channellist);
@ -135,8 +131,7 @@ OPJ_BOOL close_channel( query_param_t query_param,
/* all channels associatd with the session will be closed */
if( !delete_session( cursession, sessionlist))
return OPJ_FALSE;
}
else{
} else {
/* check if all entry belonging to the same session */
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)) {
@ -145,8 +140,7 @@ OPJ_BOOL close_channel( query_param_t query_param,
if( *cursession == NULL) {
if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel))
return OPJ_FALSE;
}
else /* second or more entry of close cid */
} else /* second or more entry of close cid */
if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))) {
fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose);
return OPJ_FALSE;
@ -201,8 +195,7 @@ OPJ_BOOL gene_JPIPstream( query_param_t query_param,
if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
return OPJ_FALSE;
*msgqueue = gene_msgqueue( OPJ_TRUE, cachemodel);
}
else{ /* session */
} else { /* session */
cachemodel = curchannel->cachemodel;
target = cachemodel->target;
*msgqueue = gene_msgqueue( OPJ_FALSE, cachemodel);
@ -309,8 +302,7 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
/*printf("Tile completely excluded from view-window %d\n", tile_id);*/
/* Tile completely excluded from view-window */
}
else if( tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) &&
} else if( tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) &&
tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) &&
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) &&
tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
@ -320,11 +312,9 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
if( msgqueue->cachemodel->jppstream) {
enqueue_tileheader( (int)tile_id, msgqueue);
enqueue_allprecincts( (int)tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
}
else
} else
enqueue_tile( tile_id, imgreg.level, msgqueue);
}
else{
} else {
/* Tile partially overlaps view-window */
/* low priority */
/*printf("Tile partially overlaps view-window %d\n", tile_id);*/
@ -337,8 +327,7 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
ymin = tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) ? 0 : imgreg.yosiz + imgreg.oy - (int)tile_Yrange.minvalue;
ymax = tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy) ? (int)(tile_Yrange.maxvalue - tile_Yrange.minvalue - 1) : (int)(imgreg.yosiz + imgreg.oy + imgreg.sy - (int)tile_Yrange.minvalue - 1);
enqueue_precincts( xmin, xmax, ymin, ymax, (int)tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
}
else
} else
enqueue_tile( tile_id, imgreg.level, msgqueue);
}
}
@ -389,13 +378,11 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
if( xmaxP < (Byte4_t)xmin || xminP > (Byte4_t)xmax || ymaxP < (Byte4_t)ymin || yminP > (Byte4_t)ymax) {
/* Precinct completely excluded from view-window */
}
else if( xminP >= (Byte4_t)xmin && xmaxP <= (Byte4_t)xmax && yminP >= (Byte4_t)ymin && ymaxP <= (Byte4_t)ymax){
} else if( xminP >= (Byte4_t)xmin && xmaxP <= (Byte4_t)xmax && yminP >= (Byte4_t)ymin && ymaxP <= (Byte4_t)ymax) {
/* Precinct completely contained within view-window
high priority */
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
}
else{
} else {
/* Precinct partially overlaps view-window
low priority */
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
@ -443,8 +430,7 @@ OPJ_BOOL enqueue_metabins( query_param_t query_param, metadatalist_param_t *meta
fprintf( FCGI_stdout, "Status: 501\r\n");
fprintf( FCGI_stdout, "Reason: metareq with all box-property * not implemented\r\n");
return OPJ_FALSE;
}
else{
} else {
Byte8_t idx = search_metadataidx( query_param.box_type[i], metadatalist);
if( idx != (Byte8_t)-1)

View File

@ -81,13 +81,11 @@ Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte
const char j2kfname[] = "tmp.j2k";
fp = fopen( j2kfname, "w+b");
if( !fp )
{
if( !fp ) {
return NULL;
}
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
if( !j2kstream )
{
if( !j2kstream ) {
fclose(fp);
remove( j2kfname);
return NULL;
@ -96,8 +94,7 @@ Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte
retlen = fwrite( j2kstream, 1, j2klen, fp);
opj_free( j2kstream);
fclose(fp);
if( retlen != j2klen )
{
if( retlen != j2klen ) {
remove( j2kfname);
return NULL;
}

View File

@ -95,7 +95,8 @@ void print_msgqueue( msgqueue_param_t *msgqueue)
{
message_param_t *ptr;
static const char *message_class[] = { "Precinct", "Ext-Prec", "TileHead", "non",
"Tile", "Ext-Tile", "Main", "non", "Meta"};
"Tile", "Ext-Tile", "Main", "non", "Meta"
};
if( !msgqueue)
return;
@ -427,8 +428,7 @@ void recons_stream_from_msgqueue( msgqueue_param_t *msgqueue, int tmpfd)
bb = 2;
class_id = msg->class_id;
}
}
else{
} else {
bb = 3;
class_id = msg->class_id;
csn = msg->csn;
@ -671,8 +671,7 @@ void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *d
phld = parse_phld( datastream, msg->length);
msg->phld = phld;
insert_placeholder_into_list( phld, metadata->placeholderlist);
}
else if( isalpha(boxtype[0]) && isalpha(boxtype[1]) &&
} else if( isalpha(boxtype[0]) && isalpha(boxtype[1]) &&
(isalnum(boxtype[2])||isspace(boxtype[2])) &&
(isalpha(boxtype[3])||isspace(boxtype[3]))) {
if( !metadata->boxlist)
@ -680,8 +679,7 @@ void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *d
box = gene_boxbyOffinStream( datastream, msg->res_offset);
insert_box_into_list( box, metadata->boxlist);
}
else
} else
metadata->boxcontents = gene_boxcontents( msg->res_offset, msg->length);
}

Some files were not shown because too many files have changed in this diff Show More