Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jpx_opj.cpp

Issue 1098583002: Fix a bunch of -Wunused-but-set-variable warnings. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "../../../include/fxcodec/fx_codec.h" 10 #include "../../../include/fxcodec/fx_codec.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 sycc444_to_rgb(img); 346 sycc444_to_rgb(img);
347 } else { 347 } else {
348 return; 348 return;
349 } 349 }
350 img->color_space = OPJ_CLRSPC_SRGB; 350 img->color_space = OPJ_CLRSPC_SRGB;
351 } 351 }
352 void color_apply_icc_profile(opj_image_t *image) 352 void color_apply_icc_profile(opj_image_t *image)
353 { 353 {
354 cmsHPROFILE in_prof, out_prof; 354 cmsHPROFILE in_prof, out_prof;
355 cmsHTRANSFORM transform; 355 cmsHTRANSFORM transform;
356 cmsColorSpaceSignature in_space, out_space; 356 cmsColorSpaceSignature out_space;
357 cmsUInt32Number intent, in_type, out_type, nr_samples; 357 cmsUInt32Number intent, in_type, out_type, nr_samples;
358 int *r, *g, *b; 358 int *r, *g, *b;
359 int prec, i, max, max_w, max_h; 359 int prec, i, max, max_w, max_h;
360 OPJ_COLOR_SPACE oldspace; 360 OPJ_COLOR_SPACE oldspace;
361 in_prof = 361 in_prof =
362 cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len); 362 cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
363 if(in_prof == NULL) { 363 if(in_prof == NULL) {
364 return; 364 return;
365 } 365 }
366 in_space = cmsGetPCS(in_prof);
367 out_space = cmsGetColorSpace(in_prof); 366 out_space = cmsGetColorSpace(in_prof);
Tom Sepez 2015/04/17 16:20:16 nit: declaration of out_space can move here from l
Lei Zhang 2015/05/08 05:40:38 Done.
368 intent = cmsGetHeaderRenderingIntent(in_prof); 367 intent = cmsGetHeaderRenderingIntent(in_prof);
369 max_w = (int)image->comps[0].w; 368 max_w = (int)image->comps[0].w;
370 max_h = (int)image->comps[0].h; 369 max_h = (int)image->comps[0].h;
371 prec = (int)image->comps[0].prec; 370 prec = (int)image->comps[0].prec;
372 oldspace = image->color_space; 371 oldspace = image->color_space;
373 if(out_space == cmsSigRgbData) { 372 if(out_space == cmsSigRgbData) {
374 if( prec <= 8 ) { 373 if( prec <= 8 ) {
375 in_type = TYPE_RGB_8; 374 in_type = TYPE_RGB_8;
376 out_type = TYPE_RGB_8; 375 out_type = TYPE_RGB_8;
377 } else { 376 } else {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 numcomps = image->numcomps; 500 numcomps = image->numcomps;
502 if(numcomps < 3) { 501 if(numcomps < 3) {
503 return; 502 return;
504 } 503 }
505 row = (int*)image->icc_profile_buf; 504 row = (int*)image->icc_profile_buf;
506 enumcs = row[0]; 505 enumcs = row[0];
507 if(enumcs == 14) { 506 if(enumcs == 14) {
508 int *L, *a, *b, *red, *green, *blue, *src0, *src1, *src2; 507 int *L, *a, *b, *red, *green, *blue, *src0, *src1, *src2;
509 double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2; 508 double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2;
510 double minL, maxL, mina, maxa, minb, maxb; 509 double minL, maxL, mina, maxa, minb, maxb;
511 unsigned int default_type, il; 510 unsigned int default_type;
512 unsigned int i, max, illu; 511 unsigned int i, max;
513 cmsHPROFILE in, out; 512 cmsHPROFILE in, out;
514 cmsHTRANSFORM transform; 513 cmsHTRANSFORM transform;
515 cmsUInt16Number RGB[3]; 514 cmsUInt16Number RGB[3];
516 cmsCIELab Lab; 515 cmsCIELab Lab;
517 illu = 0;
518 il = 0;
519 in = cmsCreateLab4Profile(NULL); 516 in = cmsCreateLab4Profile(NULL);
520 out = cmsCreate_sRGBProfile(); 517 out = cmsCreate_sRGBProfile();
521 transform = 518 transform =
522 cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, 519 cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
523 INTENT_PERCEPTUAL, 0); 520 INTENT_PERCEPTUAL, 0);
524 cmsCloseProfile(in); 521 cmsCloseProfile(in);
525 cmsCloseProfile(out); 522 cmsCloseProfile(out);
526 if(transform == NULL) { 523 if(transform == NULL) {
527 return; 524 return;
528 } 525 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 { 699 {
703 width = (FX_DWORD)image->x1; 700 width = (FX_DWORD)image->x1;
704 height = (FX_DWORD)image->y1; 701 height = (FX_DWORD)image->y1;
705 output_nComps = codestream_nComps = (FX_DWORD)image->numcomps; 702 output_nComps = codestream_nComps = (FX_DWORD)image->numcomps;
706 } 703 }
707 FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo lor, FX_LPBYTE offsets) 704 FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo lor, FX_LPBYTE offsets)
708 { 705 {
709 FX_BYTE** channel_bufs; 706 FX_BYTE** channel_bufs;
710 int* adjust_comps; 707 int* adjust_comps;
711 int i, wid, hei, row, col, channel, src; 708 int i, wid, hei, row, col, channel, src;
712 FX_BOOL flag;
713 FX_LPBYTE pChannel, pScanline, pPixel; 709 FX_LPBYTE pChannel, pScanline, pPixel;
714 710
715 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { 711 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) {
716 return FALSE; 712 return FALSE;
717 } 713 }
718 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { 714 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) {
719 return FALSE; 715 return FALSE;
720 } 716 }
721 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); 717 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch);
722 channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); 718 channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps);
723 if (channel_bufs == NULL) { 719 if (channel_bufs == NULL) {
724 return FALSE; 720 return FALSE;
725 } 721 }
726 adjust_comps = FX_Alloc(int, image->numcomps); 722 adjust_comps = FX_Alloc(int, image->numcomps);
727 if (adjust_comps == NULL) { 723 if (adjust_comps == NULL) {
728 FX_Free(channel_bufs); 724 FX_Free(channel_bufs);
729 return FALSE; 725 return FALSE;
730 } 726 }
731 flag = TRUE;
732 for (i = 0; i < (int)image->numcomps; i ++) { 727 for (i = 0; i < (int)image->numcomps; i ++) {
733 channel_bufs[i] = dest_buf + offsets[i]; 728 channel_bufs[i] = dest_buf + offsets[i];
734 adjust_comps[i] = image->comps[i].prec - 8; 729 adjust_comps[i] = image->comps[i].prec - 8;
735 if(i > 0) { 730 if(i > 0) {
736 if(image->comps[i].dx != image->comps[i - 1].dx 731 if(image->comps[i].dx != image->comps[i - 1].dx
737 || image->comps[i].dy != image->comps[i - 1].dy 732 || image->comps[i].dy != image->comps[i - 1].dy
738 || image->comps[i].prec != image->comps[i - 1].prec) { 733 || image->comps[i].prec != image->comps[i - 1].prec) {
739 flag = FALSE;
740 goto failed; 734 goto failed;
741 } 735 }
742 } 736 }
743 } 737 }
744 wid = image->comps[0].w; 738 wid = image->comps[0].w;
745 hei = image->comps[0].h; 739 hei = image->comps[0].h;
746 for (channel = 0; channel < (int)image->numcomps; channel++) { 740 for (channel = 0; channel < (int)image->numcomps; channel++) {
747 pChannel = channel_bufs[channel]; 741 pChannel = channel_bufs[channel];
748 if(adjust_comps[channel] < 0) { 742 if(adjust_comps[channel] < 0) {
749 for(row = 0; row < hei; row++) { 743 for(row = 0; row < hei; row++) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 *pPixel = (FX_BYTE)tmpPixel; 775 *pPixel = (FX_BYTE)tmpPixel;
782 } 776 }
783 } 777 }
784 } 778 }
785 } 779 }
786 } 780 }
787 781
788 FX_Free(channel_bufs); 782 FX_Free(channel_bufs);
789 FX_Free(adjust_comps); 783 FX_Free(adjust_comps);
790 return TRUE; 784 return TRUE;
791 failed: 785 failed:
Tom Sepez 2015/04/17 16:20:16 using |flag| might have avoided this code duplicat
Lei Zhang 2015/05/08 05:40:38 Done. I'll work on the beard.
792 FX_Free(channel_bufs); 786 FX_Free(channel_bufs);
793 FX_Free(adjust_comps); 787 FX_Free(adjust_comps);
794 return FALSE; 788 return FALSE;
795 } 789 }
796 void initialize_transition_table(); 790 void initialize_transition_table();
797 void initialize_significance_luts(); 791 void initialize_significance_luts();
798 void initialize_sign_lut(); 792 void initialize_sign_lut();
799 CCodec_JpxModule::CCodec_JpxModule() 793 CCodec_JpxModule::CCodec_JpxModule()
800 { 794 {
801 } 795 }
(...skipping 16 matching lines...) Expand all
818 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets) 812 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets)
819 { 813 {
820 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 814 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
821 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); 815 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets);
822 } 816 }
823 void CCodec_JpxModule::DestroyDecoder(void* ctx) 817 void CCodec_JpxModule::DestroyDecoder(void* ctx)
824 { 818 {
825 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 819 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
826 delete pDecoder; 820 delete pDecoder;
827 } 821 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698