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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 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
« no previous file with comments | « core/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/fxcodec/codec/fx_codec_png.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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 image->comps[0].prec = 16; 668 image->comps[0].prec = 16;
669 image->comps[1].prec = 16; 669 image->comps[1].prec = 16;
670 image->comps[2].prec = 16; 670 image->comps[2].prec = 16;
671 return; 671 return;
672 } 672 }
673 } 673 }
674 class CJPX_Decoder { 674 class CJPX_Decoder {
675 public: 675 public:
676 explicit CJPX_Decoder(CPDF_ColorSpace* cs); 676 explicit CJPX_Decoder(CPDF_ColorSpace* cs);
677 ~CJPX_Decoder(); 677 ~CJPX_Decoder();
678 FX_BOOL Init(const unsigned char* src_data, FX_DWORD src_size); 678 FX_BOOL Init(const unsigned char* src_data, uint32_t src_size);
679 void GetInfo(FX_DWORD* width, FX_DWORD* height, FX_DWORD* components); 679 void GetInfo(uint32_t* width, uint32_t* height, uint32_t* components);
680 bool Decode(uint8_t* dest_buf, 680 bool Decode(uint8_t* dest_buf,
681 int pitch, 681 int pitch,
682 const std::vector<uint8_t>& offsets); 682 const std::vector<uint8_t>& offsets);
683 683
684 private: 684 private:
685 const uint8_t* m_SrcData; 685 const uint8_t* m_SrcData;
686 FX_DWORD m_SrcSize; 686 uint32_t m_SrcSize;
687 opj_image_t* image; 687 opj_image_t* image;
688 opj_codec_t* l_codec; 688 opj_codec_t* l_codec;
689 opj_stream_t* l_stream; 689 opj_stream_t* l_stream;
690 const CPDF_ColorSpace* const m_ColorSpace; 690 const CPDF_ColorSpace* const m_ColorSpace;
691 }; 691 };
692 692
693 CJPX_Decoder::CJPX_Decoder(CPDF_ColorSpace* cs) 693 CJPX_Decoder::CJPX_Decoder(CPDF_ColorSpace* cs)
694 : image(nullptr), l_codec(nullptr), l_stream(nullptr), m_ColorSpace(cs) {} 694 : image(nullptr), l_codec(nullptr), l_stream(nullptr), m_ColorSpace(cs) {}
695 695
696 CJPX_Decoder::~CJPX_Decoder() { 696 CJPX_Decoder::~CJPX_Decoder() {
697 if (l_codec) { 697 if (l_codec) {
698 opj_destroy_codec(l_codec); 698 opj_destroy_codec(l_codec);
699 } 699 }
700 if (l_stream) { 700 if (l_stream) {
701 opj_stream_destroy(l_stream); 701 opj_stream_destroy(l_stream);
702 } 702 }
703 if (image) { 703 if (image) {
704 opj_image_destroy(image); 704 opj_image_destroy(image);
705 } 705 }
706 } 706 }
707 707
708 FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD src_size) { 708 FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
709 static const unsigned char szJP2Header[] = { 709 static const unsigned char szJP2Header[] = {
710 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a}; 710 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a};
711 if (!src_data || src_size < sizeof(szJP2Header)) 711 if (!src_data || src_size < sizeof(szJP2Header))
712 return FALSE; 712 return FALSE;
713 713
714 image = NULL; 714 image = NULL;
715 m_SrcData = src_data; 715 m_SrcData = src_data;
716 m_SrcSize = src_size; 716 m_SrcSize = src_size;
717 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size); 717 DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
718 l_stream = fx_opj_stream_create_memory_stream(&srcData, 718 l_stream = fx_opj_stream_create_memory_stream(&srcData,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 FX_Free(image->icc_profile_buf); 781 FX_Free(image->icc_profile_buf);
782 image->icc_profile_buf = NULL; 782 image->icc_profile_buf = NULL;
783 image->icc_profile_len = 0; 783 image->icc_profile_len = 0;
784 } 784 }
785 if (!image) { 785 if (!image) {
786 return FALSE; 786 return FALSE;
787 } 787 }
788 return TRUE; 788 return TRUE;
789 } 789 }
790 790
791 void CJPX_Decoder::GetInfo(FX_DWORD* width, 791 void CJPX_Decoder::GetInfo(uint32_t* width,
792 FX_DWORD* height, 792 uint32_t* height,
793 FX_DWORD* components) { 793 uint32_t* components) {
794 *width = (FX_DWORD)image->x1; 794 *width = (uint32_t)image->x1;
795 *height = (FX_DWORD)image->y1; 795 *height = (uint32_t)image->y1;
796 *components = (FX_DWORD)image->numcomps; 796 *components = (uint32_t)image->numcomps;
797 } 797 }
798 798
799 bool CJPX_Decoder::Decode(uint8_t* dest_buf, 799 bool CJPX_Decoder::Decode(uint8_t* dest_buf,
800 int pitch, 800 int pitch,
801 const std::vector<uint8_t>& offsets) { 801 const std::vector<uint8_t>& offsets) {
802 if (image->comps[0].w != image->x1 || image->comps[0].h != image->y1) 802 if (image->comps[0].w != image->x1 || image->comps[0].h != image->y1)
803 return false; 803 return false;
804 804
805 if (pitch<(int)(image->comps[0].w * 8 * image->numcomps + 31)>> 5 << 2) 805 if (pitch<(int)(image->comps[0].w * 8 * image->numcomps + 31)>> 5 << 2)
806 return false; 806 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 867 }
868 } 868 }
869 } 869 }
870 return true; 870 return true;
871 } 871 }
872 872
873 CCodec_JpxModule::CCodec_JpxModule() {} 873 CCodec_JpxModule::CCodec_JpxModule() {}
874 CCodec_JpxModule::~CCodec_JpxModule() {} 874 CCodec_JpxModule::~CCodec_JpxModule() {}
875 875
876 CJPX_Decoder* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, 876 CJPX_Decoder* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf,
877 FX_DWORD src_size, 877 uint32_t src_size,
878 CPDF_ColorSpace* cs) { 878 CPDF_ColorSpace* cs) {
879 std::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder(cs)); 879 std::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder(cs));
880 return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr; 880 return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr;
881 } 881 }
882 882
883 void CCodec_JpxModule::GetImageInfo(CJPX_Decoder* pDecoder, 883 void CCodec_JpxModule::GetImageInfo(CJPX_Decoder* pDecoder,
884 FX_DWORD* width, 884 uint32_t* width,
885 FX_DWORD* height, 885 uint32_t* height,
886 FX_DWORD* components) { 886 uint32_t* components) {
887 pDecoder->GetInfo(width, height, components); 887 pDecoder->GetInfo(width, height, components);
888 } 888 }
889 889
890 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, 890 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder,
891 uint8_t* dest_data, 891 uint8_t* dest_data,
892 int pitch, 892 int pitch,
893 const std::vector<uint8_t>& offsets) { 893 const std::vector<uint8_t>& offsets) {
894 return pDecoder->Decode(dest_data, pitch, offsets); 894 return pDecoder->Decode(dest_data, pitch, offsets);
895 } 895 }
896 896
897 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { 897 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) {
898 delete pDecoder; 898 delete pDecoder;
899 } 899 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_jpeg.cpp ('k') | core/fxcodec/codec/fx_codec_png.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698