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

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

Issue 1416783002: Merge to M46: upgrade openjpeg to commit# cf352af (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2490
Patch Set: Fix pdfium:168 since we are already half way there Created 5 years, 2 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 "../../../../third_party/lcms2-2.6/include/lcms2.h" 10 #include "../../../../third_party/lcms2-2.6/include/lcms2.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 FX_Free(src2); 648 FX_Free(src2);
649 image->color_space = OPJ_CLRSPC_SRGB; 649 image->color_space = OPJ_CLRSPC_SRGB;
650 image->comps[0].prec = 16; 650 image->comps[0].prec = 16;
651 image->comps[1].prec = 16; 651 image->comps[1].prec = 16;
652 image->comps[2].prec = 16; 652 image->comps[2].prec = 16;
653 return; 653 return;
654 } 654 }
655 } 655 }
656 class CJPX_Decoder { 656 class CJPX_Decoder {
657 public: 657 public:
658 CJPX_Decoder(); 658 explicit CJPX_Decoder(bool use_colorspace);
659 ~CJPX_Decoder(); 659 ~CJPX_Decoder();
660 FX_BOOL Init(const unsigned char* src_data, int src_size); 660 FX_BOOL Init(const unsigned char* src_data, int src_size);
661 void GetInfo(FX_DWORD& width, 661 void GetInfo(FX_DWORD& width,
662 FX_DWORD& height, 662 FX_DWORD& height,
663 FX_DWORD& codestream_nComps, 663 FX_DWORD& codestream_nComps,
664 FX_DWORD& output_nComps); 664 FX_DWORD& output_nComps);
665 FX_BOOL Decode(uint8_t* dest_buf, 665 FX_BOOL Decode(uint8_t* dest_buf,
666 int pitch, 666 int pitch,
667 FX_BOOL bTranslateColor, 667 FX_BOOL bTranslateColor,
668 uint8_t* offsets); 668 uint8_t* offsets);
669 const uint8_t* m_SrcData; 669 const uint8_t* m_SrcData;
670 int m_SrcSize; 670 int m_SrcSize;
671 opj_image_t* image; 671 opj_image_t* image;
672 opj_codec_t* l_codec; 672 opj_codec_t* l_codec;
673 opj_stream_t* l_stream; 673 opj_stream_t* l_stream;
674 FX_BOOL m_useColorSpace; 674 const bool m_UseColorSpace;
675 }; 675 };
676 CJPX_Decoder::CJPX_Decoder() 676 CJPX_Decoder::CJPX_Decoder(bool use_colorspace)
677 : image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(FALSE) {} 677 : image(NULL), l_codec(NULL), l_stream(NULL), m_UseColorSpace(use_colorspace ) {}
678 CJPX_Decoder::~CJPX_Decoder() { 678 CJPX_Decoder::~CJPX_Decoder() {
679 if (l_codec) { 679 if (l_codec) {
680 opj_destroy_codec(l_codec); 680 opj_destroy_codec(l_codec);
681 } 681 }
682 if (l_stream) { 682 if (l_stream) {
683 opj_stream_destroy(l_stream); 683 opj_stream_destroy(l_stream);
684 } 684 }
685 if (image) { 685 if (image) {
686 opj_image_destroy(image); 686 opj_image_destroy(image);
687 } 687 }
(...skipping 29 matching lines...) Expand all
717 opj_set_info_handler(l_codec, fx_info_callback, 00); 717 opj_set_info_handler(l_codec, fx_info_callback, 00);
718 opj_set_warning_handler(l_codec, fx_warning_callback, 00); 718 opj_set_warning_handler(l_codec, fx_warning_callback, 00);
719 opj_set_error_handler(l_codec, fx_error_callback, 00); 719 opj_set_error_handler(l_codec, fx_error_callback, 00);
720 if (!opj_setup_decoder(l_codec, &parameters)) { 720 if (!opj_setup_decoder(l_codec, &parameters)) {
721 return FALSE; 721 return FALSE;
722 } 722 }
723 if (!opj_read_header(l_stream, l_codec, &image)) { 723 if (!opj_read_header(l_stream, l_codec, &image)) {
724 image = NULL; 724 image = NULL;
725 return FALSE; 725 return FALSE;
726 } 726 }
727 image->pdfium_use_colorspace = m_UseColorSpace;
728
727 if (!parameters.nb_tile_to_decode) { 729 if (!parameters.nb_tile_to_decode) {
728 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, 730 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0,
729 parameters.DA_x1, parameters.DA_y1)) { 731 parameters.DA_x1, parameters.DA_y1)) {
730 opj_image_destroy(image); 732 opj_image_destroy(image);
731 image = NULL; 733 image = NULL;
732 return FALSE; 734 return FALSE;
733 } 735 }
734 if (!(opj_decode(l_codec, l_stream, image) && 736 if (!(opj_decode(l_codec, l_stream, image) &&
735 opj_end_decompress(l_codec, l_stream))) { 737 opj_end_decompress(l_codec, l_stream))) {
736 opj_image_destroy(image); 738 opj_image_destroy(image);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 FX_Free(adjust_comps); 859 FX_Free(adjust_comps);
858 return result; 860 return result;
859 } 861 }
860 void initialize_transition_table(); 862 void initialize_transition_table();
861 void initialize_significance_luts(); 863 void initialize_significance_luts();
862 void initialize_sign_lut(); 864 void initialize_sign_lut();
863 CCodec_JpxModule::CCodec_JpxModule() {} 865 CCodec_JpxModule::CCodec_JpxModule() {}
864 void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, 866 void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf,
865 FX_DWORD src_size, 867 FX_DWORD src_size,
866 FX_BOOL useColorSpace) { 868 FX_BOOL useColorSpace) {
867 CJPX_Decoder* pDecoder = new CJPX_Decoder; 869 CJPX_Decoder* pDecoder = new CJPX_Decoder(useColorSpace);
868 pDecoder->m_useColorSpace = useColorSpace;
869 if (!pDecoder->Init(src_buf, src_size)) { 870 if (!pDecoder->Init(src_buf, src_size)) {
870 delete pDecoder; 871 delete pDecoder;
871 return NULL; 872 return NULL;
872 } 873 }
873 return pDecoder; 874 return pDecoder;
874 } 875 }
875 void CCodec_JpxModule::GetImageInfo(void* ctx, 876 void CCodec_JpxModule::GetImageInfo(void* ctx,
876 FX_DWORD& width, 877 FX_DWORD& width,
877 FX_DWORD& height, 878 FX_DWORD& height,
878 FX_DWORD& codestream_nComps, 879 FX_DWORD& codestream_nComps,
879 FX_DWORD& output_nComps) { 880 FX_DWORD& output_nComps) {
880 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 881 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
881 pDecoder->GetInfo(width, height, codestream_nComps, output_nComps); 882 pDecoder->GetInfo(width, height, codestream_nComps, output_nComps);
882 } 883 }
883 FX_BOOL CCodec_JpxModule::Decode(void* ctx, 884 FX_BOOL CCodec_JpxModule::Decode(void* ctx,
884 uint8_t* dest_data, 885 uint8_t* dest_data,
885 int pitch, 886 int pitch,
886 FX_BOOL bTranslateColor, 887 FX_BOOL bTranslateColor,
887 uint8_t* offsets) { 888 uint8_t* offsets) {
888 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 889 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
889 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); 890 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets);
890 } 891 }
891 void CCodec_JpxModule::DestroyDecoder(void* ctx) { 892 void CCodec_JpxModule::DestroyDecoder(void* ctx) {
892 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 893 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
893 delete pDecoder; 894 delete pDecoder;
894 } 895 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp ('k') | third_party/libopenjpeg20/0000-use-colorspace.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698