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 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 7 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
9 | 9 |
10 #include <limits.h> | 10 #include <limits.h> |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 | 13 |
14 #include "core/include/fxcodec/fx_codec.h" | 14 #include "core/include/fxcodec/fx_codec.h" |
15 #include "core/src/fxcodec/jbig2/JBig2_Context.h" | 15 #include "core/src/fxcodec/jbig2/JBig2_Context.h" |
16 #include "third_party/base/nonstd_unique_ptr.h" | 16 #include "third_party/base/nonstd_unique_ptr.h" |
17 #include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. | 17 #include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. |
18 | 18 |
19 class CFX_IccProfileCache; | 19 class CFX_IccProfileCache; |
20 class CFX_IccTransformCache; | 20 class CFX_IccTransformCache; |
21 | 21 |
22 class CCodec_BasicModule : public ICodec_BasicModule { | 22 class CCodec_BasicModule : public ICodec_BasicModule { |
23 public: | 23 public: |
24 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, | 24 // ICodec_BasicModule: |
25 FX_DWORD src_size, | 25 FX_BOOL RunLengthEncode(const uint8_t* src_buf, |
26 uint8_t*& dest_buf, | 26 FX_DWORD src_size, |
27 FX_DWORD& dest_size); | 27 uint8_t*& dest_buf, |
28 virtual FX_BOOL A85Encode(const uint8_t* src_buf, | 28 FX_DWORD& dest_size) override; |
29 FX_DWORD src_size, | 29 FX_BOOL A85Encode(const uint8_t* src_buf, |
30 uint8_t*& dest_buf, | 30 FX_DWORD src_size, |
31 FX_DWORD& dest_size); | 31 uint8_t*& dest_buf, |
32 virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, | 32 FX_DWORD& dest_size) override; |
33 FX_DWORD src_size, | 33 ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, |
34 int width, | 34 FX_DWORD src_size, |
35 int height, | 35 int width, |
36 int nComps, | 36 int height, |
37 int bpc); | 37 int nComps, |
| 38 int bpc) override; |
38 }; | 39 }; |
39 | 40 |
40 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { | 41 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { |
41 public: | 42 public: |
42 CCodec_ScanlineDecoder(); | 43 CCodec_ScanlineDecoder(); |
43 ~CCodec_ScanlineDecoder() override; | 44 ~CCodec_ScanlineDecoder() override; |
44 | 45 |
45 // ICodec_ScanlineDecoder | 46 // ICodec_ScanlineDecoder |
46 FX_DWORD GetSrcOffset() override { return -1; } | 47 FX_DWORD GetSrcOffset() override { return -1; } |
47 void DownScale(int dest_width, int dest_height) override; | 48 void DownScale(int dest_width, int dest_height) override; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 int m_bpc; | 95 int m_bpc; |
95 int m_Pitch; | 96 int m_Pitch; |
96 FX_BOOL m_bColorTransformed; | 97 FX_BOOL m_bColorTransformed; |
97 int m_NextLine; | 98 int m_NextLine; |
98 uint8_t* m_pLastScanline; | 99 uint8_t* m_pLastScanline; |
99 nonstd::unique_ptr<ImageDataCache> m_pDataCache; | 100 nonstd::unique_ptr<ImageDataCache> m_pDataCache; |
100 }; | 101 }; |
101 | 102 |
102 class CCodec_FaxModule : public ICodec_FaxModule { | 103 class CCodec_FaxModule : public ICodec_FaxModule { |
103 public: | 104 public: |
104 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, | 105 // ICodec_FaxModule: |
105 FX_DWORD src_size, | 106 ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, |
106 int width, | 107 FX_DWORD src_size, |
107 int height, | 108 int width, |
108 int K, | 109 int height, |
109 FX_BOOL EndOfLine, | 110 int K, |
110 FX_BOOL EncodedByteAlign, | 111 FX_BOOL EndOfLine, |
111 FX_BOOL BlackIs1, | 112 FX_BOOL EncodedByteAlign, |
112 int Columns, | 113 FX_BOOL BlackIs1, |
113 int Rows); | 114 int Columns, |
| 115 int Rows) override; |
114 FX_BOOL Encode(const uint8_t* src_buf, | 116 FX_BOOL Encode(const uint8_t* src_buf, |
115 int width, | 117 int width, |
116 int height, | 118 int height, |
117 int pitch, | 119 int pitch, |
118 uint8_t*& dest_buf, | 120 uint8_t*& dest_buf, |
119 FX_DWORD& dest_size); | 121 FX_DWORD& dest_size) override; |
120 }; | 122 }; |
121 | 123 |
122 class CCodec_FlateModule : public ICodec_FlateModule { | 124 class CCodec_FlateModule : public ICodec_FlateModule { |
123 public: | 125 public: |
124 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, | 126 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, |
125 FX_DWORD src_size, | 127 FX_DWORD src_size, |
126 int width, | 128 int width, |
127 int height, | 129 int height, |
128 int nComps, | 130 int nComps, |
129 int bpc, | 131 int bpc, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void Input(void* pContext, | 187 void Input(void* pContext, |
186 const uint8_t* src_buf, | 188 const uint8_t* src_buf, |
187 FX_DWORD src_size) override; | 189 FX_DWORD src_size) override; |
188 int ReadHeader(void* pContext, int* width, int* height, int* nComps) override; | 190 int ReadHeader(void* pContext, int* width, int* height, int* nComps) override; |
189 int StartScanline(void* pContext, int down_scale) override; | 191 int StartScanline(void* pContext, int down_scale) override; |
190 FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override; | 192 FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override; |
191 FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; | 193 FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; |
192 }; | 194 }; |
193 class CCodec_IccModule : public ICodec_IccModule { | 195 class CCodec_IccModule : public ICodec_IccModule { |
194 public: | 196 public: |
195 virtual IccCS GetProfileCS(const uint8_t* pProfileData, | 197 ~CCodec_IccModule() override; |
196 unsigned int dwProfileSize); | 198 |
197 virtual IccCS GetProfileCS(IFX_FileRead* pFile); | 199 // ICodec_IccModule: |
198 virtual void* CreateTransform( | 200 IccCS GetProfileCS(const uint8_t* pProfileData, |
199 ICodec_IccModule::IccParam* pInputParam, | 201 unsigned int dwProfileSize) override; |
200 ICodec_IccModule::IccParam* pOutputParam, | 202 IccCS GetProfileCS(IFX_FileRead* pFile) override; |
201 ICodec_IccModule::IccParam* pProofParam = NULL, | 203 void* CreateTransform(ICodec_IccModule::IccParam* pInputParam, |
202 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, | 204 ICodec_IccModule::IccParam* pOutputParam, |
203 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, | 205 ICodec_IccModule::IccParam* pProofParam = NULL, |
204 FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, | 206 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, |
205 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING); | 207 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, |
206 virtual void* CreateTransform_sRGB(const uint8_t* pProfileData, | 208 FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, |
207 FX_DWORD dwProfileSize, | 209 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override; |
208 int32_t& nComponents, | 210 void* CreateTransform_sRGB( |
209 int32_t intent = 0, | 211 const uint8_t* pProfileData, |
210 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT); | 212 FX_DWORD dwProfileSize, |
211 virtual void* CreateTransform_CMYK(const uint8_t* pSrcProfileData, | 213 int32_t& nComponents, |
212 FX_DWORD dwSrcProfileSize, | 214 int32_t intent = 0, |
213 int32_t& nSrcComponents, | 215 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT) override; |
214 const uint8_t* pDstProfileData, | 216 void* CreateTransform_CMYK( |
215 FX_DWORD dwDstProfileSize, | 217 const uint8_t* pSrcProfileData, |
216 int32_t intent = 0, | 218 FX_DWORD dwSrcProfileSize, |
217 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, | 219 int32_t& nSrcComponents, |
218 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT); | 220 const uint8_t* pDstProfileData, |
219 virtual void DestroyTransform(void* pTransform); | 221 FX_DWORD dwDstProfileSize, |
220 virtual void Translate(void* pTransform, | 222 int32_t intent = 0, |
221 FX_FLOAT* pSrcValues, | 223 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, |
222 FX_FLOAT* pDestValues); | 224 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) override; |
223 virtual void TranslateScanline(void* pTransform, | 225 void DestroyTransform(void* pTransform) override; |
224 uint8_t* pDest, | 226 void Translate(void* pTransform, |
225 const uint8_t* pSrc, | 227 FX_FLOAT* pSrcValues, |
226 int pixels); | 228 FX_FLOAT* pDestValues) override; |
227 virtual void SetComponents(FX_DWORD nComponents) { | 229 void TranslateScanline(void* pTransform, |
| 230 uint8_t* pDest, |
| 231 const uint8_t* pSrc, |
| 232 int pixels) override; |
| 233 void SetComponents(FX_DWORD nComponents) override { |
228 m_nComponents = nComponents; | 234 m_nComponents = nComponents; |
229 } | 235 } |
230 virtual ~CCodec_IccModule(); | |
231 | 236 |
232 protected: | 237 protected: |
233 enum Icc_CLASS { | 238 enum Icc_CLASS { |
234 Icc_CLASS_INPUT = 0, | 239 Icc_CLASS_INPUT = 0, |
235 Icc_CLASS_OUTPUT, | 240 Icc_CLASS_OUTPUT, |
236 Icc_CLASS_PROOF, | 241 Icc_CLASS_PROOF, |
237 Icc_CLASS_MAX | 242 Icc_CLASS_MAX |
238 }; | 243 }; |
239 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, | 244 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
240 Icc_CLASS ic, | 245 Icc_CLASS ic, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, | 321 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, |
317 OPJ_SIZE_T nb_bytes, | 322 OPJ_SIZE_T nb_bytes, |
318 void* p_user_data); | 323 void* p_user_data); |
319 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, | 324 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, |
320 OPJ_SIZE_T nb_bytes, | 325 OPJ_SIZE_T nb_bytes, |
321 void* p_user_data); | 326 void* p_user_data); |
322 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 327 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
323 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 328 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
324 | 329 |
325 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 330 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
OLD | NEW |