| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 int32_t* pal_num, | 253 int32_t* pal_num, |
| 252 FX_DWORD** pal_pp, | 254 FX_DWORD** pal_pp, |
| 253 CFX_DIBAttribute* pAttribute) override; | 255 CFX_DIBAttribute* pAttribute) override; |
| 254 int32_t LoadImage(void* pContext) override; | 256 int32_t LoadImage(void* pContext) override; |
| 255 | 257 |
| 256 protected: | 258 protected: |
| 257 FX_CHAR m_szLastError[256]; | 259 FX_CHAR m_szLastError[256]; |
| 258 }; | 260 }; |
| 259 class CCodec_IccModule : public ICodec_IccModule { | 261 class CCodec_IccModule : public ICodec_IccModule { |
| 260 public: | 262 public: |
| 261 virtual IccCS GetProfileCS(const uint8_t* pProfileData, | 263 ~CCodec_IccModule() override; |
| 262 unsigned int dwProfileSize); | 264 |
| 263 virtual IccCS GetProfileCS(IFX_FileRead* pFile); | 265 // ICodec_IccModule: |
| 264 virtual void* CreateTransform( | 266 IccCS GetProfileCS(const uint8_t* pProfileData, |
| 265 ICodec_IccModule::IccParam* pInputParam, | 267 unsigned int dwProfileSize) override; |
| 266 ICodec_IccModule::IccParam* pOutputParam, | 268 IccCS GetProfileCS(IFX_FileRead* pFile) override; |
| 267 ICodec_IccModule::IccParam* pProofParam = NULL, | 269 void* CreateTransform(ICodec_IccModule::IccParam* pInputParam, |
| 268 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, | 270 ICodec_IccModule::IccParam* pOutputParam, |
| 269 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, | 271 ICodec_IccModule::IccParam* pProofParam = NULL, |
| 270 FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, | 272 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, |
| 271 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING); | 273 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT, |
| 272 virtual void* CreateTransform_sRGB(const uint8_t* pProfileData, | 274 FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC, |
| 273 FX_DWORD dwProfileSize, | 275 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override; |
| 274 int32_t& nComponents, | 276 void* CreateTransform_sRGB( |
| 275 int32_t intent = 0, | 277 const uint8_t* pProfileData, |
| 276 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT); | 278 FX_DWORD dwProfileSize, |
| 277 virtual void* CreateTransform_CMYK(const uint8_t* pSrcProfileData, | 279 int32_t& nComponents, |
| 278 FX_DWORD dwSrcProfileSize, | 280 int32_t intent = 0, |
| 279 int32_t& nSrcComponents, | 281 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT) override; |
| 280 const uint8_t* pDstProfileData, | 282 void* CreateTransform_CMYK( |
| 281 FX_DWORD dwDstProfileSize, | 283 const uint8_t* pSrcProfileData, |
| 282 int32_t intent = 0, | 284 FX_DWORD dwSrcProfileSize, |
| 283 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, | 285 int32_t& nSrcComponents, |
| 284 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT); | 286 const uint8_t* pDstProfileData, |
| 285 virtual void DestroyTransform(void* pTransform); | 287 FX_DWORD dwDstProfileSize, |
| 286 virtual void Translate(void* pTransform, | 288 int32_t intent = 0, |
| 287 FX_FLOAT* pSrcValues, | 289 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, |
| 288 FX_FLOAT* pDestValues); | 290 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) override; |
| 289 virtual void TranslateScanline(void* pTransform, | 291 void DestroyTransform(void* pTransform) override; |
| 290 uint8_t* pDest, | 292 void Translate(void* pTransform, |
| 291 const uint8_t* pSrc, | 293 FX_FLOAT* pSrcValues, |
| 292 int pixels); | 294 FX_FLOAT* pDestValues) override; |
| 293 virtual void SetComponents(FX_DWORD nComponents) { | 295 void TranslateScanline(void* pTransform, |
| 296 uint8_t* pDest, |
| 297 const uint8_t* pSrc, |
| 298 int pixels) override; |
| 299 void SetComponents(FX_DWORD nComponents) override { |
| 294 m_nComponents = nComponents; | 300 m_nComponents = nComponents; |
| 295 } | 301 } |
| 296 virtual ~CCodec_IccModule(); | |
| 297 | 302 |
| 298 protected: | 303 protected: |
| 299 enum Icc_CLASS { | 304 enum Icc_CLASS { |
| 300 Icc_CLASS_INPUT = 0, | 305 Icc_CLASS_INPUT = 0, |
| 301 Icc_CLASS_OUTPUT, | 306 Icc_CLASS_OUTPUT, |
| 302 Icc_CLASS_PROOF, | 307 Icc_CLASS_PROOF, |
| 303 Icc_CLASS_MAX | 308 Icc_CLASS_MAX |
| 304 }; | 309 }; |
| 305 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, | 310 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
| 306 Icc_CLASS ic, | 311 Icc_CLASS ic, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, | 405 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, |
| 401 OPJ_SIZE_T nb_bytes, | 406 OPJ_SIZE_T nb_bytes, |
| 402 void* p_user_data); | 407 void* p_user_data); |
| 403 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, | 408 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, |
| 404 OPJ_SIZE_T nb_bytes, | 409 OPJ_SIZE_T nb_bytes, |
| 405 void* p_user_data); | 410 void* p_user_data); |
| 406 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 411 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
| 407 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 412 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
| 408 | 413 |
| 409 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 414 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
| OLD | NEW |