diff options
Diffstat (limited to 'core/src/fxcodec/codec')
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index 3b0490f3c6..3546f574f9 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -351,25 +351,24 @@ void color_sycc_to_rgb(opj_image_t *img) } void color_apply_icc_profile(opj_image_t *image) { - cmsHPROFILE in_prof, out_prof; - cmsHTRANSFORM transform; - cmsColorSpaceSignature in_space, out_space; - cmsUInt32Number intent, in_type, out_type, nr_samples; - int *r, *g, *b; - int prec, i, max, max_w, max_h; - OPJ_COLOR_SPACE oldspace; - in_prof = + cmsHPROFILE out_prof; + cmsUInt32Number in_type; + cmsUInt32Number out_type; + int *r; + int *g; + int *b; + int max; + cmsHPROFILE in_prof = cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len); if(in_prof == NULL) { return; } - in_space = cmsGetPCS(in_prof); - out_space = cmsGetColorSpace(in_prof); - intent = cmsGetHeaderRenderingIntent(in_prof); - max_w = (int)image->comps[0].w; - max_h = (int)image->comps[0].h; - prec = (int)image->comps[0].prec; - oldspace = image->color_space; + cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof); + cmsUInt32Number intent = cmsGetHeaderRenderingIntent(in_prof); + int max_w = (int)image->comps[0].w; + int max_h = (int)image->comps[0].h; + int prec = (int)image->comps[0].prec; + OPJ_COLOR_SPACE oldspace = image->color_space; if(out_space == cmsSigRgbData) { if( prec <= 8 ) { in_type = TYPE_RGB_8; @@ -398,8 +397,8 @@ void color_apply_icc_profile(opj_image_t *image) } else { return; } - transform = cmsCreateTransform(in_prof, in_type, - out_prof, out_type, intent, 0); + cmsHTRANSFORM transform = + cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0); cmsCloseProfile(in_prof); cmsCloseProfile(out_prof); if(transform == NULL) { @@ -410,13 +409,13 @@ void color_apply_icc_profile(opj_image_t *image) if( prec <= 8 ) { unsigned char *inbuf, *outbuf, *in, *out; max = max_w * max_h; - nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char); + cmsUInt32Number nr_samples = max * 3 * sizeof(unsigned char); in = inbuf = FX_Alloc(unsigned char, nr_samples); out = outbuf = FX_Alloc(unsigned char, nr_samples); r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *in++ = (unsigned char) * r++; *in++ = (unsigned char) * g++; *in++ = (unsigned char) * b++; @@ -425,7 +424,7 @@ void color_apply_icc_profile(opj_image_t *image) r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *r++ = (int) * out++; *g++ = (int) * out++; *b++ = (int) * out++; @@ -435,13 +434,13 @@ void color_apply_icc_profile(opj_image_t *image) } else { unsigned short *inbuf, *outbuf, *in, *out; max = max_w * max_h; - nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short); + cmsUInt32Number nr_samples = max * 3 * sizeof(unsigned short); in = inbuf = FX_Alloc(unsigned short, nr_samples); out = outbuf = FX_Alloc(unsigned short, nr_samples); r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *in++ = (unsigned short) * r++; *in++ = (unsigned short) * g++; *in++ = (unsigned short) * b++; @@ -450,7 +449,7 @@ void color_apply_icc_profile(opj_image_t *image) r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *r++ = (int) * out++; *g++ = (int) * out++; *b++ = (int) * out++; @@ -461,7 +460,8 @@ void color_apply_icc_profile(opj_image_t *image) } else { unsigned char *in, *inbuf, *out, *outbuf; max = max_w * max_h; - nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char); + cmsUInt32Number nr_samples = + (cmsUInt32Number)max * 3 * sizeof(unsigned char); in = inbuf = FX_Alloc(unsigned char, nr_samples); out = outbuf = FX_Alloc(unsigned char, nr_samples); image->comps = (opj_image_comp_t*) @@ -477,14 +477,14 @@ void color_apply_icc_profile(opj_image_t *image) FXSYS_memset8(image->comps[2].data, 0, sizeof(int) * (size_t)max); image->numcomps += 2; r = image->comps[0].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *in++ = (unsigned char) * r++; } cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max); r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - for(i = 0; i < max; ++i) { + for(int i = 0; i < max; ++i) { *r++ = (int) * out++; *g++ = (int) * out++; *b++ = (int) * out++; @@ -508,14 +508,12 @@ void color_apply_conversion(opj_image_t *image) int *L, *a, *b, *red, *green, *blue, *src0, *src1, *src2; double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2; double minL, maxL, mina, maxa, minb, maxb; - unsigned int default_type, il; - unsigned int i, max, illu; + unsigned int default_type; + unsigned int i, max; cmsHPROFILE in, out; cmsHTRANSFORM transform; cmsUInt16Number RGB[3]; cmsCIELab Lab; - illu = 0; - il = 0; in = cmsCreateLab4Profile(NULL); out = cmsCreate_sRGBProfile(); transform = @@ -706,10 +704,7 @@ void CJPX_Decoder::GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestre } FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateColor, FX_LPBYTE offsets) { - FX_BYTE** channel_bufs; - int* adjust_comps; int i, wid, hei, row, col, channel, src; - FX_BOOL flag; FX_LPBYTE pChannel, pScanline, pPixel; if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { @@ -719,16 +714,15 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo return FALSE; } FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); - channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); + FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); if (channel_bufs == NULL) { return FALSE; } - adjust_comps = FX_Alloc(int, image->numcomps); + FX_BOOL result = FALSE; + int* adjust_comps = FX_Alloc(int, image->numcomps); if (adjust_comps == NULL) { - FX_Free(channel_bufs); - return FALSE; + goto done; } - flag = TRUE; for (i = 0; i < (int)image->numcomps; i ++) { channel_bufs[i] = dest_buf + offsets[i]; adjust_comps[i] = image->comps[i].prec - 8; @@ -736,8 +730,7 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo if(image->comps[i].dx != image->comps[i - 1].dx || image->comps[i].dy != image->comps[i - 1].dy || image->comps[i].prec != image->comps[i - 1].prec) { - flag = FALSE; - goto failed; + goto done; } } } @@ -784,14 +777,12 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo } } } + result = TRUE; +done: FX_Free(channel_bufs); FX_Free(adjust_comps); - return TRUE; -failed: - FX_Free(channel_bufs); - FX_Free(adjust_comps); - return FALSE; + return result; } void initialize_transition_table(); void initialize_significance_luts(); |