diff options
author | Lei Zhang <thestig@chromium.org> | 2015-05-08 11:03:55 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-05-08 11:03:55 -0700 |
commit | f0a169e6fd5718995fa6ef8749c8d16cdad84985 (patch) | |
tree | 3194ef3427aee1c683efe6b54abdd65b2d6dff9d /core/src/fxcodec | |
parent | 21031ad28a73f0633e720997d310440c5bc31ec5 (diff) | |
download | pdfium-f0a169e6fd5718995fa6ef8749c8d16cdad84985.tar.xz |
Fix a bunch of -Wunused-but-set-variable warnings.
Also fix a few nits and other errors along the way.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1098583002
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 81 | ||||
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp | 10 |
2 files changed, 38 insertions, 53 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(); diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp index 53faab4a46..a5928f9ea3 100644 --- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp +++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp @@ -888,7 +888,7 @@ CJBig2_Image *CJBig2_GRDProc::decode_Arith_Template3_opt2(CJBig2_ArithDecoder *p CJBig2_Image *GBREG; FX_DWORD line1; FX_BYTE *pLine, cVal; - FX_INTPTR nStride, nStride2; + FX_INTPTR nStride; FX_INT32 nBits, k; LTP = 0; JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); @@ -899,7 +899,6 @@ CJBig2_Image *CJBig2_GRDProc::decode_Arith_Template3_opt2(CJBig2_ArithDecoder *p } pLine = GBREG->m_pData; nStride = GBREG->m_nStride; - nStride2 = nStride << 1; for(FX_DWORD h = 0; h < GBH; h++) { if(TPGDON) { SLTP = pArithDecoder->DECODE(&gbContext[0x0195]); @@ -2335,7 +2334,7 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecod CJBig2_Image **SDNEWSYMS; FX_DWORD HCHEIGHT, NSYMSDECODED; FX_INT32 HCDH; - FX_DWORD SYMWIDTH, TOTWIDTH, HCFIRSTSYM; + FX_DWORD SYMWIDTH, TOTWIDTH; FX_INT32 DW; CJBig2_Image *BS; FX_DWORD I, J, REFAGGNINST; @@ -2345,7 +2344,6 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecod FX_DWORD EXRUNLENGTH; FX_INT32 nVal; FX_DWORD nTmp; - FX_BOOL SBHUFF; FX_DWORD SBNUMSYMS; FX_BYTE SBSYMCODELEN; FX_DWORD IDI; @@ -2394,7 +2392,6 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecod } SYMWIDTH = 0; TOTWIDTH = 0; - HCFIRSTSYM = NSYMSDECODED; for(;;) { nVal = IADW->decode(pArithDecoder, &DW); if(nVal == JBIG2_OOB) { @@ -2537,7 +2534,6 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecod delete SBHUFFRSIZE; delete pDecoder; } else if(REFAGGNINST == 1) { - SBHUFF = SDHUFF; SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; if(IAID->decode(pArithDecoder, (int*)&IDI) == -1) { m_pModule->JBig2_Error("symbol dictionary decoding procedure (arith): too short."); @@ -2686,7 +2682,6 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Huffman(CJBig2_BitStream *pStream, FX_DWORD EXRUNLENGTH; FX_INT32 nVal, nBits; FX_DWORD nTmp; - FX_BOOL SBHUFF; FX_DWORD SBNUMSYMS; FX_BYTE SBSYMCODELEN; JBig2HuffmanCode *SBSYMCODES; @@ -2843,7 +2838,6 @@ CJBig2_SymbolDict *CJBig2_SDDProc::decode_Huffman(CJBig2_BitStream *pStream, delete SBHUFFRSIZE; delete pDecoder; } else if(REFAGGNINST == 1) { - SBHUFF = SDHUFF; SBNUMSYMS = SDNUMINSYMS + SDNUMNEWSYMS; nTmp = 1; while((FX_DWORD)(1 << nTmp) < SBNUMSYMS) { |