| OLD | NEW |
| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "codec_int.h" | 8 #include "codec_int.h" |
| 9 #include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h" | 9 #include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h" |
| 10 #include "../lcms2/include/fx_lcms2.h" | 10 #include "../lcms2/include/fx_lcms2.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 opj_stream_t* fx_opj_stream_create_memory_stream (DecodeData* data, OPJ_SIZE
_T p_size, OPJ_BOOL p_is_read_stream) | 75 opj_stream_t* fx_opj_stream_create_memory_stream (DecodeData* data, OPJ_SIZE
_T p_size, OPJ_BOOL p_is_read_stream) |
| 76 { | 76 { |
| 77 opj_stream_t* l_stream = 00; | 77 opj_stream_t* l_stream = 00; |
| 78 if (!data || ! data->src_data || data->src_size <= 0 ) { | 78 if (!data || ! data->src_data || data->src_size <= 0 ) { |
| 79 return NULL; | 79 return NULL; |
| 80 } | 80 } |
| 81 l_stream = opj_stream_create(p_size, p_is_read_stream); | 81 l_stream = opj_stream_create(p_size, p_is_read_stream); |
| 82 if (! l_stream) { | 82 if (! l_stream) { |
| 83 return NULL; | 83 return NULL; |
| 84 } | 84 } |
| 85 opj_stream_set_user_data_v3(l_stream, data, NULL); | 85 opj_stream_set_user_data(l_stream, data, NULL); |
| 86 opj_stream_set_user_data_length(l_stream, data->src_size); | 86 opj_stream_set_user_data_length(l_stream, data->src_size); |
| 87 opj_stream_set_read_function(l_stream, opj_read_from_memory); | 87 opj_stream_set_read_function(l_stream, opj_read_from_memory); |
| 88 opj_stream_set_write_function(l_stream, opj_write_from_memory); | 88 opj_stream_set_write_function(l_stream, opj_write_from_memory); |
| 89 opj_stream_set_skip_function(l_stream, opj_skip_from_memory); | 89 opj_stream_set_skip_function(l_stream, opj_skip_from_memory); |
| 90 opj_stream_set_seek_function(l_stream, opj_seek_from_memory); | 90 opj_stream_set_seek_function(l_stream, opj_seek_from_memory); |
| 91 return l_stream; | 91 return l_stream; |
| 92 } | 92 } |
| 93 static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr, | 93 static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr, |
| 94 int *out_r, int *out_g, int *out_b) | 94 int *out_r, int *out_g, int *out_b) |
| 95 { | 95 { |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 opj_set_info_handler(l_codec, fx_info_callback, 00); | 602 opj_set_info_handler(l_codec, fx_info_callback, 00); |
| 603 opj_set_warning_handler(l_codec, fx_warning_callback, 00); | 603 opj_set_warning_handler(l_codec, fx_warning_callback, 00); |
| 604 opj_set_error_handler(l_codec, fx_error_callback, 00); | 604 opj_set_error_handler(l_codec, fx_error_callback, 00); |
| 605 if ( !opj_setup_decoder(l_codec, ¶meters) ) { | 605 if ( !opj_setup_decoder(l_codec, ¶meters) ) { |
| 606 return FALSE; | 606 return FALSE; |
| 607 } | 607 } |
| 608 if(! opj_read_header(l_stream, l_codec, &image)) { | 608 if(! opj_read_header(l_stream, l_codec, &image)) { |
| 609 image = NULL; | 609 image = NULL; |
| 610 return FALSE; | 610 return FALSE; |
| 611 } | 611 } |
| 612 /* |
| 612 if(this->m_useColorSpace) { | 613 if(this->m_useColorSpace) { |
| 613 image->useColorSpace = 1; | 614 image->useColorSpace = 1; |
| 614 } else { | 615 } else { |
| 615 image->useColorSpace = 0; | 616 image->useColorSpace = 0; |
| 616 } | 617 } |
| 618 */ |
| 617 if (!parameters.nb_tile_to_decode) { | 619 if (!parameters.nb_tile_to_decode) { |
| 618 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, | 620 if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, |
| 619 parameters.DA_y0, parameters.DA_x1, paramete
rs.DA_y1)) { | 621 parameters.DA_y0, parameters.DA_x1, paramete
rs.DA_y1)) { |
| 620 opj_image_destroy(image); | 622 opj_image_destroy(image); |
| 621 image = NULL; | 623 image = NULL; |
| 622 return FALSE; | 624 return FALSE; |
| 623 } | 625 } |
| 624 if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec
, l_stream))) { | 626 if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec
, l_stream))) { |
| 625 opj_image_destroy(image); | 627 opj_image_destroy(image); |
| 626 image = NULL; | 628 image = NULL; |
| 627 return FALSE; | 629 return FALSE; |
| 628 } | 630 } |
| 629 } else { | 631 } else { |
| 630 if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_inde
x)) { | 632 if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_inde
x)) { |
| 631 return FALSE; | 633 return FALSE; |
| 632 } | 634 } |
| 633 } | 635 } |
| 634 opj_stream_destroy(l_stream); | 636 opj_stream_destroy(l_stream); |
| 635 l_stream = NULL; | 637 l_stream = NULL; |
| 636 if( image->color_space != OPJ_CLRSPC_SYCC | 638 if( image->color_space != OPJ_CLRSPC_SYCC |
| 637 && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy | 639 && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy |
| 638 && image->comps[1].dx != 1 ) { | 640 && image->comps[1].dx != 1 ) { |
| 639 image->color_space = OPJ_CLRSPC_SYCC; | 641 image->color_space = OPJ_CLRSPC_SYCC; |
| 640 } else if (image->numcomps <= 2) { | 642 } else if (image->numcomps <= 2) { |
| 641 image->color_space = OPJ_CLRSPC_GRAY; | 643 image->color_space = OPJ_CLRSPC_GRAY; |
| 642 } | 644 } |
| 643 if(image->color_space == OPJ_CLRSPC_SYCC) { | 645 if(image->color_space == OPJ_CLRSPC_SYCC) { |
| 644 color_sycc_to_rgb(image); | 646 color_sycc_to_rgb(image); |
| 645 } | 647 } |
| 646 if(image->icc_profile_buf && !image->useColorSpace) { | 648 //if(image->icc_profile_buf && !image->useColorSpace) { |
| 649 if(image->icc_profile_buf) { |
| 647 FX_Free(image->icc_profile_buf); | 650 FX_Free(image->icc_profile_buf); |
| 648 image->icc_profile_buf = NULL; | 651 image->icc_profile_buf = NULL; |
| 649 image->icc_profile_len = 0; | 652 image->icc_profile_len = 0; |
| 650 } | 653 } |
| 651 if(!image) { | 654 if(!image) { |
| 652 return FALSE; | 655 return FALSE; |
| 653 } | 656 } |
| 654 return TRUE; | 657 return TRUE; |
| 655 } | 658 } |
| 656 void CJPX_Decoder::GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestre
am_nComps, FX_DWORD& output_nComps) | 659 void CJPX_Decoder::GetInfo(FX_DWORD& width, FX_DWORD& height, FX_DWORD& codestre
am_nComps, FX_DWORD& output_nComps) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B
OOL bTranslateColor, FX_LPBYTE offsets) | 779 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B
OOL bTranslateColor, FX_LPBYTE offsets) |
| 777 { | 780 { |
| 778 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; | 781 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
| 779 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); | 782 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); |
| 780 } | 783 } |
| 781 void CCodec_JpxModule::DestroyDecoder(void* ctx) | 784 void CCodec_JpxModule::DestroyDecoder(void* ctx) |
| 782 { | 785 { |
| 783 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; | 786 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
| 784 delete pDecoder; | 787 delete pDecoder; |
| 785 } | 788 } |
| OLD | NEW |