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

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

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/src/fxcrt/fx_basic_array.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector> 9 #include <vector>
10 10
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 void color_apply_icc_profile(opj_image_t* image) { 431 void color_apply_icc_profile(opj_image_t* image) {
432 cmsHPROFILE out_prof; 432 cmsHPROFILE out_prof;
433 cmsUInt32Number in_type; 433 cmsUInt32Number in_type;
434 cmsUInt32Number out_type; 434 cmsUInt32Number out_type;
435 int* r; 435 int* r;
436 int* g; 436 int* g;
437 int* b; 437 int* b;
438 int max; 438 int max;
439 cmsHPROFILE in_prof = 439 cmsHPROFILE in_prof =
440 cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len); 440 cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
441 if (in_prof == NULL) { 441 if (!in_prof) {
442 return; 442 return;
443 } 443 }
444 cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof); 444 cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof);
445 cmsUInt32Number intent = cmsGetHeaderRenderingIntent(in_prof); 445 cmsUInt32Number intent = cmsGetHeaderRenderingIntent(in_prof);
446 int max_w = (int)image->comps[0].w; 446 int max_w = (int)image->comps[0].w;
447 int max_h = (int)image->comps[0].h; 447 int max_h = (int)image->comps[0].h;
448 int prec = (int)image->comps[0].prec; 448 int prec = (int)image->comps[0].prec;
449 OPJ_COLOR_SPACE oldspace = image->color_space; 449 OPJ_COLOR_SPACE oldspace = image->color_space;
450 if (out_space == cmsSigRgbData) { 450 if (out_space == cmsSigRgbData) {
451 if (prec <= 8) { 451 if (prec <= 8) {
(...skipping 20 matching lines...) Expand all
472 out_type = TYPE_RGB_16; 472 out_type = TYPE_RGB_16;
473 out_prof = cmsCreate_sRGBProfile(); 473 out_prof = cmsCreate_sRGBProfile();
474 image->color_space = OPJ_CLRSPC_SRGB; 474 image->color_space = OPJ_CLRSPC_SRGB;
475 } else { 475 } else {
476 return; 476 return;
477 } 477 }
478 cmsHTRANSFORM transform = 478 cmsHTRANSFORM transform =
479 cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0); 479 cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
480 cmsCloseProfile(in_prof); 480 cmsCloseProfile(in_prof);
481 cmsCloseProfile(out_prof); 481 cmsCloseProfile(out_prof);
482 if (transform == NULL) { 482 if (!transform) {
483 image->color_space = oldspace; 483 image->color_space = oldspace;
484 return; 484 return;
485 } 485 }
486 if (image->numcomps > 2) { 486 if (image->numcomps > 2) {
487 if (prec <= 8) { 487 if (prec <= 8) {
488 unsigned char *inbuf, *outbuf, *in, *out; 488 unsigned char *inbuf, *outbuf, *in, *out;
489 max = max_w * max_h; 489 max = max_w * max_h;
490 cmsUInt32Number nr_samples = max * 3 * sizeof(unsigned char); 490 cmsUInt32Number nr_samples = max * 3 * sizeof(unsigned char);
491 in = inbuf = FX_Alloc(unsigned char, nr_samples); 491 in = inbuf = FX_Alloc(unsigned char, nr_samples);
492 out = outbuf = FX_Alloc(unsigned char, nr_samples); 492 out = outbuf = FX_Alloc(unsigned char, nr_samples);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 cmsHPROFILE in, out; 590 cmsHPROFILE in, out;
591 cmsHTRANSFORM transform; 591 cmsHTRANSFORM transform;
592 cmsUInt16Number RGB[3]; 592 cmsUInt16Number RGB[3];
593 cmsCIELab Lab; 593 cmsCIELab Lab;
594 in = cmsCreateLab4Profile(NULL); 594 in = cmsCreateLab4Profile(NULL);
595 out = cmsCreate_sRGBProfile(); 595 out = cmsCreate_sRGBProfile();
596 transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, 596 transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
597 INTENT_PERCEPTUAL, 0); 597 INTENT_PERCEPTUAL, 0);
598 cmsCloseProfile(in); 598 cmsCloseProfile(in);
599 cmsCloseProfile(out); 599 cmsCloseProfile(out);
600 if (transform == NULL) { 600 if (!transform) {
601 return; 601 return;
602 } 602 }
603 prec0 = (double)image->comps[0].prec; 603 prec0 = (double)image->comps[0].prec;
604 prec1 = (double)image->comps[1].prec; 604 prec1 = (double)image->comps[1].prec;
605 prec2 = (double)image->comps[2].prec; 605 prec2 = (double)image->comps[2].prec;
606 default_type = row[1]; 606 default_type = row[1];
607 if (default_type == 0x44454600) { 607 if (default_type == 0x44454600) {
608 rl = 100; 608 rl = 100;
609 ra = 170; 609 ra = 170;
610 rb = 200; 610 rb = 200;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a}; 701 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a};
702 if (!src_data || src_size < sizeof(szJP2Header)) 702 if (!src_data || src_size < sizeof(szJP2Header))
703 return FALSE; 703 return FALSE;
704 704
705 image = NULL; 705 image = NULL;
706 m_SrcData = src_data; 706 m_SrcData = src_data;
707 m_SrcSize = src_size; 707 m_SrcSize = src_size;
708 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size); 708 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
709 l_stream = fx_opj_stream_create_memory_stream(&srcData, 709 l_stream = fx_opj_stream_create_memory_stream(&srcData,
710 OPJ_J2K_STREAM_CHUNK_SIZE, 1); 710 OPJ_J2K_STREAM_CHUNK_SIZE, 1);
711 if (l_stream == NULL) { 711 if (!l_stream) {
712 return FALSE; 712 return FALSE;
713 } 713 }
714 opj_dparameters_t parameters; 714 opj_dparameters_t parameters;
715 opj_set_default_decoder_parameters(&parameters); 715 opj_set_default_decoder_parameters(&parameters);
716 parameters.decod_format = 0; 716 parameters.decod_format = 0;
717 parameters.cod_format = 3; 717 parameters.cod_format = 3;
718 if (FXSYS_memcmp(m_SrcData, szJP2Header, sizeof(szJP2Header)) == 0) { 718 if (FXSYS_memcmp(m_SrcData, szJP2Header, sizeof(szJP2Header)) == 0) {
719 l_codec = opj_create_decompress(OPJ_CODEC_JP2); 719 l_codec = opj_create_decompress(OPJ_CODEC_JP2);
720 parameters.decod_format = 1; 720 parameters.decod_format = 1;
721 } else { 721 } else {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, 880 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder,
881 uint8_t* dest_data, 881 uint8_t* dest_data,
882 int pitch, 882 int pitch,
883 const std::vector<uint8_t>& offsets) { 883 const std::vector<uint8_t>& offsets) {
884 return pDecoder->Decode(dest_data, pitch, offsets); 884 return pDecoder->Decode(dest_data, pitch, offsets);
885 } 885 }
886 886
887 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { 887 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) {
888 delete pDecoder; 888 delete pDecoder;
889 } 889 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/src/fxcrt/fx_basic_array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698