diff options
Diffstat (limited to 'core/fxcodec/codec/fx_codec_jpx_opj.cpp')
-rw-r--r-- | core/fxcodec/codec/fx_codec_jpx_opj.cpp | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index eccf876218..4fc3d689f1 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -7,12 +7,15 @@ #include <algorithm> #include <limits> #include <memory> +#include <utility> #include <vector> #include "core/fpdfapi/page/cpdf_colorspace.h" +#include "core/fxcodec/codec/cjpx_decoder.h" #include "core/fxcodec/codec/codec_int.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/fx_safe_types.h" +#include "third_party/base/ptr_util.h" #include "third_party/lcms2-2.6/include/lcms2.h" #include "third_party/libopenjpeg20/openjpeg.h" @@ -669,24 +672,6 @@ void color_apply_conversion(opj_image_t* image) { return; } } -class CJPX_Decoder { - public: - explicit CJPX_Decoder(CPDF_ColorSpace* cs); - ~CJPX_Decoder(); - bool Init(const unsigned char* src_data, uint32_t src_size); - void GetInfo(uint32_t* width, uint32_t* height, uint32_t* components); - bool Decode(uint8_t* dest_buf, - int pitch, - const std::vector<uint8_t>& offsets); - - private: - const uint8_t* m_SrcData; - uint32_t m_SrcSize; - opj_image_t* image; - opj_codec_t* l_codec; - opj_stream_t* l_stream; - const CPDF_ColorSpace* const m_ColorSpace; -}; CJPX_Decoder::CJPX_Decoder(CPDF_ColorSpace* cs) : image(nullptr), l_codec(nullptr), l_stream(nullptr), m_ColorSpace(cs) {} @@ -872,13 +857,15 @@ bool CJPX_Decoder::Decode(uint8_t* dest_buf, } CCodec_JpxModule::CCodec_JpxModule() {} + CCodec_JpxModule::~CCodec_JpxModule() {} -CJPX_Decoder* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, - uint32_t src_size, - CPDF_ColorSpace* cs) { - std::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder(cs)); - return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr; +std::unique_ptr<CJPX_Decoder> CCodec_JpxModule::CreateDecoder( + const uint8_t* src_buf, + uint32_t src_size, + CPDF_ColorSpace* cs) { + auto decoder = pdfium::MakeUnique<CJPX_Decoder>(cs); + return decoder->Init(src_buf, src_size) ? std::move(decoder) : nullptr; } void CCodec_JpxModule::GetImageInfo(CJPX_Decoder* pDecoder, @@ -894,7 +881,3 @@ bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, const std::vector<uint8_t>& offsets) { return pDecoder->Decode(dest_data, pitch, offsets); } - -void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { - delete pDecoder; -} |