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

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

Issue 1310603006: Cleanup dead code in CPDF_DIBSource::LoadJpxBitmap() and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: remove redundent components params / variables Created 5 years, 3 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
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | no next file » | 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 9
10 #include "../../../../third_party/lcms2-2.6/include/lcms2.h" 10 #include "../../../../third_party/lcms2-2.6/include/lcms2.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 image->comps[1].prec = 16; 609 image->comps[1].prec = 16;
610 image->comps[2].prec = 16; 610 image->comps[2].prec = 16;
611 return; 611 return;
612 } 612 }
613 } 613 }
614 class CJPX_Decoder { 614 class CJPX_Decoder {
615 public: 615 public:
616 CJPX_Decoder(); 616 CJPX_Decoder();
617 ~CJPX_Decoder(); 617 ~CJPX_Decoder();
618 FX_BOOL Init(const unsigned char* src_data, int src_size); 618 FX_BOOL Init(const unsigned char* src_data, int src_size);
619 void GetInfo(FX_DWORD& width, 619 void GetInfo(FX_DWORD* width, FX_DWORD* height, FX_DWORD* components);
620 FX_DWORD& height,
621 FX_DWORD& codestream_nComps,
622 FX_DWORD& output_nComps);
623 FX_BOOL Decode(uint8_t* dest_buf, 620 FX_BOOL Decode(uint8_t* dest_buf,
624 int pitch, 621 int pitch,
625 FX_BOOL bTranslateColor,
626 uint8_t* offsets); 622 uint8_t* offsets);
627 const uint8_t* m_SrcData; 623 const uint8_t* m_SrcData;
628 int m_SrcSize; 624 int m_SrcSize;
629 opj_image_t* image; 625 opj_image_t* image;
630 opj_codec_t* l_codec; 626 opj_codec_t* l_codec;
631 opj_stream_t* l_stream; 627 opj_stream_t* l_stream;
632 FX_BOOL m_useColorSpace; 628 FX_BOOL m_useColorSpace;
633 }; 629 };
634 CJPX_Decoder::CJPX_Decoder() 630 CJPX_Decoder::CJPX_Decoder()
635 : image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(FALSE) {} 631 : image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(FALSE) {}
632
636 CJPX_Decoder::~CJPX_Decoder() { 633 CJPX_Decoder::~CJPX_Decoder() {
637 if (l_codec) { 634 if (l_codec) {
638 opj_destroy_codec(l_codec); 635 opj_destroy_codec(l_codec);
639 } 636 }
640 if (l_stream) { 637 if (l_stream) {
641 opj_stream_destroy(l_stream); 638 opj_stream_destroy(l_stream);
642 } 639 }
643 if (image) { 640 if (image) {
644 opj_image_destroy(image); 641 opj_image_destroy(image);
645 } 642 }
646 } 643 }
644
647 FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) { 645 FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) {
648 static const unsigned char szJP2Header[] = { 646 static const unsigned char szJP2Header[] = {
649 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a}; 647 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a};
650 if (!src_data || src_size < sizeof(szJP2Header)) { 648 if (!src_data || src_size < sizeof(szJP2Header)) {
651 return FALSE; 649 return FALSE;
652 } 650 }
653 image = NULL; 651 image = NULL;
654 m_SrcData = src_data; 652 m_SrcData = src_data;
655 m_SrcSize = src_size; 653 m_SrcSize = src_size;
656 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size); 654 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 if (image->icc_profile_buf) { 713 if (image->icc_profile_buf) {
716 FX_Free(image->icc_profile_buf); 714 FX_Free(image->icc_profile_buf);
717 image->icc_profile_buf = NULL; 715 image->icc_profile_buf = NULL;
718 image->icc_profile_len = 0; 716 image->icc_profile_len = 0;
719 } 717 }
720 if (!image) { 718 if (!image) {
721 return FALSE; 719 return FALSE;
722 } 720 }
723 return TRUE; 721 return TRUE;
724 } 722 }
725 void CJPX_Decoder::GetInfo(FX_DWORD& width, 723
726 FX_DWORD& height, 724 void CJPX_Decoder::GetInfo(FX_DWORD* width,
727 FX_DWORD& codestream_nComps, 725 FX_DWORD* height,
728 FX_DWORD& output_nComps) { 726 FX_DWORD* components) {
729 width = (FX_DWORD)image->x1; 727 *width = (FX_DWORD)image->x1;
730 height = (FX_DWORD)image->y1; 728 *height = (FX_DWORD)image->y1;
731 output_nComps = codestream_nComps = (FX_DWORD)image->numcomps; 729 *components = (FX_DWORD)image->numcomps;
Tom Sepez 2015/09/01 21:43:37 nevermind.
732 } 730 }
731
733 FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf, 732 FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf,
734 int pitch, 733 int pitch,
735 FX_BOOL bTranslateColor,
736 uint8_t* offsets) { 734 uint8_t* offsets) {
737 int i, wid, hei, row, col, channel, src; 735 int i, wid, hei, row, col, channel, src;
738 uint8_t* pChannel; 736 uint8_t* pChannel;
739 uint8_t* pScanline; 737 uint8_t* pScanline;
740 uint8_t* pPixel; 738 uint8_t* pPixel;
741 739
742 if (image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { 740 if (image->comps[0].w != image->x1 || image->comps[0].h != image->y1) {
743 return FALSE; 741 return FALSE;
744 } 742 }
745 if (pitch<(int)(image->comps[0].w * 8 * image->numcomps + 31)>> 5 << 2) { 743 if (pitch<(int)(image->comps[0].w * 8 * image->numcomps + 31)>> 5 << 2) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 } 806 }
809 } 807 }
810 } 808 }
811 result = TRUE; 809 result = TRUE;
812 810
813 done: 811 done:
814 FX_Free(channel_bufs); 812 FX_Free(channel_bufs);
815 FX_Free(adjust_comps); 813 FX_Free(adjust_comps);
816 return result; 814 return result;
817 } 815 }
816
818 void initialize_transition_table(); 817 void initialize_transition_table();
819 void initialize_significance_luts(); 818 void initialize_significance_luts();
820 void initialize_sign_lut(); 819 void initialize_sign_lut();
820
821 CCodec_JpxModule::CCodec_JpxModule() {} 821 CCodec_JpxModule::CCodec_JpxModule() {}
822 CCodec_JpxModule::~CCodec_JpxModule() {
823 }
824
822 void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, 825 void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf,
823 FX_DWORD src_size, 826 FX_DWORD src_size,
824 FX_BOOL useColorSpace) { 827 FX_BOOL useColorSpace) {
825 CJPX_Decoder* pDecoder = new CJPX_Decoder; 828 nonstd::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder);
826 pDecoder->m_useColorSpace = useColorSpace; 829 decoder->m_useColorSpace = useColorSpace;
827 if (!pDecoder->Init(src_buf, src_size)) { 830 return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr;
828 delete pDecoder;
829 return NULL;
830 }
831 return pDecoder;
832 } 831 }
832
833 void CCodec_JpxModule::GetImageInfo(void* ctx, 833 void CCodec_JpxModule::GetImageInfo(void* ctx,
834 FX_DWORD& width, 834 FX_DWORD* width,
835 FX_DWORD& height, 835 FX_DWORD* height,
836 FX_DWORD& codestream_nComps, 836 FX_DWORD* components) {
837 FX_DWORD& output_nComps) {
838 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 837 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
Tom Sepez 2015/09/01 21:43:37 nit: can we use an CJPX_Decoder as an incomplete t
Lei Zhang 2015/09/01 22:06:27 Probably. I'll wait for your comment and do this i
839 pDecoder->GetInfo(width, height, codestream_nComps, output_nComps); 838 pDecoder->GetInfo(width, height, components);
840 } 839 }
840
841 FX_BOOL CCodec_JpxModule::Decode(void* ctx, 841 FX_BOOL CCodec_JpxModule::Decode(void* ctx,
842 uint8_t* dest_data, 842 uint8_t* dest_data,
843 int pitch, 843 int pitch,
844 FX_BOOL bTranslateColor,
845 uint8_t* offsets) { 844 uint8_t* offsets) {
846 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 845 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
847 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); 846 return pDecoder->Decode(dest_data, pitch, offsets);
848 } 847 }
848
849 void CCodec_JpxModule::DestroyDecoder(void* ctx) { 849 void CCodec_JpxModule::DestroyDecoder(void* ctx) {
850 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 850 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
851 delete pDecoder; 851 delete pDecoder;
852 } 852 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698