Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #ifndef CORE_FXCODEC_CODEC_CJPX_DECODER_H_ |
| 8 | #define CORE_FXCODEC_CODEC_CJPX_DECODER_H_ |
| 9 | |
Ryan Harrison | 808b52a | 2017-09-08 10:10:26 -0400 | [diff] [blame^] | 10 | #include <memory> |
Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
Ryan Harrison | 808b52a | 2017-09-08 10:10:26 -0400 | [diff] [blame^] | 13 | #include "core/fxcodec/codec/codec_int.h" |
Tom Sepez | 797ca5c | 2017-05-25 12:03:18 -0700 | [diff] [blame] | 14 | #include "core/fxcrt/cfx_unowned_ptr.h" |
Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 15 | #include "third_party/libopenjpeg20/openjpeg.h" |
| 16 | |
| 17 | class CPDF_ColorSpace; |
| 18 | |
| 19 | class CJPX_Decoder { |
| 20 | public: |
| 21 | explicit CJPX_Decoder(CPDF_ColorSpace* cs); |
| 22 | ~CJPX_Decoder(); |
| 23 | |
| 24 | bool Init(const unsigned char* src_data, uint32_t src_size); |
| 25 | void GetInfo(uint32_t* width, uint32_t* height, uint32_t* components); |
| 26 | bool Decode(uint8_t* dest_buf, |
| 27 | int pitch, |
| 28 | const std::vector<uint8_t>& offsets); |
| 29 | |
| 30 | private: |
| 31 | const uint8_t* m_SrcData; |
| 32 | uint32_t m_SrcSize; |
Ryan Harrison | 808b52a | 2017-09-08 10:10:26 -0400 | [diff] [blame^] | 33 | // TODO(rharrison): Convert these to unowned ptrs, if possible. |
| 34 | opj_image_t* m_Image; |
| 35 | opj_codec_t* m_Codec; |
| 36 | std::unique_ptr<DecodeData> m_DecodeData; |
| 37 | opj_stream_t* m_Stream; |
| 38 | opj_dparameters_t m_Parameters; |
Tom Sepez | 797ca5c | 2017-05-25 12:03:18 -0700 | [diff] [blame] | 39 | CFX_UnownedPtr<const CPDF_ColorSpace> const m_ColorSpace; |
Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | #endif // CORE_FXCODEC_CODEC_CJPX_DECODER_H_ |