Chromium Code Reviews| Index: core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
| diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
| index 3b0490f3c6f0fe7e052f368e1b39e6344c424399..69d1763995a9379c80700a0dac757701f5121d2b 100644 |
| --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
| +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
| @@ -351,25 +351,21 @@ 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; |
| + cmsHPROFILE out_prof; |
| + cmsUInt32Number in_type, out_type; |
|
Tom Sepez
2015/05/08 16:03:00
nit: one per line.
Lei Zhang
2015/05/08 18:02:05
Done. I took care of the ints below as well.
|
| int *r, *g, *b; |
| int prec, i, max, max_w, max_h; |
| - OPJ_COLOR_SPACE oldspace; |
| - in_prof = |
| + 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); |
| + cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof); |
| + cmsUInt32Number 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; |
| + OPJ_COLOR_SPACE oldspace = image->color_space; |
| if(out_space == cmsSigRgbData) { |
| if( prec <= 8 ) { |
| in_type = TYPE_RGB_8; |
| @@ -398,8 +394,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,7 +406,7 @@ 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; |
| @@ -435,7 +431,7 @@ 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; |
| @@ -461,7 +457,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*) |
| @@ -508,14 +505,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 +701,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 +711,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 +727,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 +774,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(); |