Index: core/src/fxcodec/codec/codec_int.h |
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h |
index be71bf8dd9d3075f0039d028ab80d2d6f61ead9f..752eb3f1a57a0da8a36c9821d710cac3ff8bc69d 100644 |
--- a/core/src/fxcodec/codec/codec_int.h |
+++ b/core/src/fxcodec/codec/codec_int.h |
@@ -4,9 +4,16 @@ |
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
+#ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
+#define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
+ |
#include <limits.h> |
#include <list> |
+ |
+#include "../../../include/fxcodec/fx_codec.h" |
#include "../jbig2/JBig2_Context.h" |
+#include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. |
+ |
class CCodec_BasicModule : public ICodec_BasicModule |
{ |
public: |
@@ -144,67 +151,67 @@ public: |
virtual void* Start(); |
virtual void Finish(void* pContext); |
virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size); |
- virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps, CFX_DIBAttribute* pAttribute = NULL); |
+ virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps, CFX_DIBAttribute* pAttribute = NULL); |
virtual FX_BOOL StartScanline(void* pContext, int down_scale); |
virtual FX_BOOL ReadScanline(void* pContext, FX_LPBYTE dest_buf); |
virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr); |
protected: |
IFX_JpegProvider* m_pExtProvider; |
}; |
-#define PNG_ERROR_SIZE 256 |
-class CCodec_PngModule : public ICodec_PngModule |
-{ |
-public: |
- CCodec_PngModule() |
- { |
- FXSYS_memset8(m_szLastError, '\0', PNG_ERROR_SIZE); |
- } |
- |
- virtual void* Start(void* pModule); |
- virtual void Finish(void* pContext); |
- virtual FX_BOOL Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_DIBAttribute* pAttribute); |
-protected: |
- FX_CHAR m_szLastError[PNG_ERROR_SIZE]; |
-}; |
-class CCodec_GifModule : public ICodec_GifModule |
-{ |
-public: |
- CCodec_GifModule() |
- { |
- FXSYS_memset8(m_szLastError, '\0', 256); |
- } |
- virtual void* Start(void* pModule); |
- virtual void Finish(void* pContext); |
- virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr); |
- virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size); |
- |
- virtual FX_INT32 ReadHeader(void* pContext, int* width, int* height, |
- int* pal_num, void** pal_pp, int* bg_index, CFX_DIBAttribute* pAttribute); |
- |
- virtual FX_INT32 LoadFrameInfo(void* pContext, int* frame_num); |
- |
- virtual FX_INT32 LoadFrame(void* pContext, int frame_num, CFX_DIBAttribute* pAttribute); |
- |
-protected: |
- FX_CHAR m_szLastError[256]; |
-}; |
-class CCodec_BmpModule : public ICodec_BmpModule |
-{ |
-public: |
- CCodec_BmpModule() |
- { |
- FXSYS_memset8(m_szLastError, '\0', 256); |
- } |
- virtual void* Start(void* pModule); |
- virtual void Finish(void* pContext); |
- virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr); |
- virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size); |
- virtual FX_INT32 ReadHeader(void* pContext, FX_INT32* width, FX_INT32* height, FX_BOOL* tb_flag, FX_INT32* components, FX_INT32* pal_num, FX_DWORD** pal_pp, CFX_DIBAttribute* pAttribute); |
- virtual FX_INT32 LoadImage(void* pContext); |
- |
-protected: |
- FX_CHAR m_szLastError[256]; |
-}; |
+#define PNG_ERROR_SIZE 256 |
+class CCodec_PngModule : public ICodec_PngModule |
+{ |
+public: |
+ CCodec_PngModule() |
+ { |
+ FXSYS_memset8(m_szLastError, '\0', PNG_ERROR_SIZE); |
+ } |
+ |
+ virtual void* Start(void* pModule); |
+ virtual void Finish(void* pContext); |
+ virtual FX_BOOL Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_DIBAttribute* pAttribute); |
+protected: |
+ FX_CHAR m_szLastError[PNG_ERROR_SIZE]; |
+}; |
+class CCodec_GifModule : public ICodec_GifModule |
+{ |
+public: |
+ CCodec_GifModule() |
+ { |
+ FXSYS_memset8(m_szLastError, '\0', 256); |
+ } |
+ virtual void* Start(void* pModule); |
+ virtual void Finish(void* pContext); |
+ virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr); |
+ virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size); |
+ |
+ virtual FX_INT32 ReadHeader(void* pContext, int* width, int* height, |
+ int* pal_num, void** pal_pp, int* bg_index, CFX_DIBAttribute* pAttribute); |
+ |
+ virtual FX_INT32 LoadFrameInfo(void* pContext, int* frame_num); |
+ |
+ virtual FX_INT32 LoadFrame(void* pContext, int frame_num, CFX_DIBAttribute* pAttribute); |
+ |
+protected: |
+ FX_CHAR m_szLastError[256]; |
+}; |
+class CCodec_BmpModule : public ICodec_BmpModule |
+{ |
+public: |
+ CCodec_BmpModule() |
+ { |
+ FXSYS_memset8(m_szLastError, '\0', 256); |
+ } |
+ virtual void* Start(void* pModule); |
+ virtual void Finish(void* pContext); |
+ virtual FX_DWORD GetAvailInput(void* pContext, FX_LPBYTE* avail_buf_ptr); |
+ virtual void Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_size); |
+ virtual FX_INT32 ReadHeader(void* pContext, FX_INT32* width, FX_INT32* height, FX_BOOL* tb_flag, FX_INT32* components, FX_INT32* pal_num, FX_DWORD** pal_pp, CFX_DIBAttribute* pAttribute); |
+ virtual FX_INT32 LoadImage(void* pContext); |
+ |
+protected: |
+ FX_CHAR m_szLastError[256]; |
+}; |
class CCodec_IccModule : public ICodec_IccModule |
{ |
public: |
@@ -252,14 +259,14 @@ public: |
FX_BOOL Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_BOOL bTranslateColor, FX_LPBYTE offsets); |
void DestroyDecoder(void* ctx); |
}; |
-class CCodec_TiffModule : public ICodec_TiffModule |
-{ |
-public: |
- virtual FX_LPVOID CreateDecoder(IFX_FileRead* file_ptr); |
- virtual void GetFrames(FX_LPVOID ctx, FX_INT32& frames); |
- virtual FX_BOOL LoadFrameInfo(FX_LPVOID ctx, FX_INT32 frame, FX_DWORD& width, FX_DWORD& height, FX_DWORD& comps, FX_DWORD& bpc, CFX_DIBAttribute* pAttribute = NULL); |
- virtual FX_BOOL Decode(FX_LPVOID ctx, class CFX_DIBitmap* pDIBitmap); |
- virtual void DestroyDecoder(FX_LPVOID ctx); |
+class CCodec_TiffModule : public ICodec_TiffModule |
+{ |
+public: |
+ virtual FX_LPVOID CreateDecoder(IFX_FileRead* file_ptr); |
+ virtual void GetFrames(FX_LPVOID ctx, FX_INT32& frames); |
+ virtual FX_BOOL LoadFrameInfo(FX_LPVOID ctx, FX_INT32 frame, FX_DWORD& width, FX_DWORD& height, FX_DWORD& comps, FX_DWORD& bpc, CFX_DIBAttribute* pAttribute = NULL); |
+ virtual FX_BOOL Decode(FX_LPVOID ctx, class CFX_DIBitmap* pDIBitmap); |
+ virtual void DestroyDecoder(FX_LPVOID ctx); |
}; |
class CPDF_Jbig2Interface : public CFX_Object, public CJBig2_Module |
{ |
@@ -335,27 +342,45 @@ public: |
std::list<CJBig2_CachePair> m_SymbolDictCache; |
private: |
}; |
-class CFX_DIBAttributeExif : public IFX_DIBAttributeExif |
-{ |
-public: |
- CFX_DIBAttributeExif(); |
- ~CFX_DIBAttributeExif(); |
- virtual FX_BOOL GetInfo(FX_WORD tag, FX_LPVOID val); |
- |
- FX_BOOL ParseExif(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pHead, FX_LPBYTE data, FX_DWORD len, CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pVal); |
- |
- typedef FX_WORD (*_Read2Bytes)(FX_LPBYTE data); |
- typedef FX_DWORD (*_Read4Bytes)(FX_LPBYTE data); |
- FX_LPBYTE ParseExifIFH(FX_LPBYTE data, FX_DWORD len, _Read2Bytes* pReadWord, _Read4Bytes* pReadDword); |
- FX_BOOL ParseExifIFD(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pMap, FX_LPBYTE data, FX_DWORD len); |
- |
- FX_LPBYTE m_pExifData; |
- |
- FX_DWORD m_dwExifDataLen; |
- |
- void clear(); |
- _Read2Bytes m_readWord; |
- _Read4Bytes m_readDword; |
- CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE> m_TagHead; |
- CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE> m_TagVal; |
-}; |
+class CFX_DIBAttributeExif : public IFX_DIBAttributeExif |
+{ |
+public: |
+ CFX_DIBAttributeExif(); |
+ ~CFX_DIBAttributeExif(); |
+ virtual FX_BOOL GetInfo(FX_WORD tag, FX_LPVOID val); |
+ |
+ FX_BOOL ParseExif(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pHead, FX_LPBYTE data, FX_DWORD len, CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pVal); |
+ |
+ typedef FX_WORD (*_Read2Bytes)(FX_LPBYTE data); |
+ typedef FX_DWORD (*_Read4Bytes)(FX_LPBYTE data); |
+ FX_LPBYTE ParseExifIFH(FX_LPBYTE data, FX_DWORD len, _Read2Bytes* pReadWord, _Read4Bytes* pReadDword); |
+ FX_BOOL ParseExifIFD(CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE>* pMap, FX_LPBYTE data, FX_DWORD len); |
+ |
+ FX_LPBYTE m_pExifData; |
+ |
+ FX_DWORD m_dwExifDataLen; |
+ |
+ void clear(); |
+ _Read2Bytes m_readWord; |
+ _Read4Bytes m_readDword; |
+ CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE> m_TagHead; |
+ CFX_MapPtrTemplate<FX_DWORD, FX_LPBYTE> m_TagVal; |
+}; |
+ |
+struct DecodeData { |
+public: |
+ DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) : |
+ src_data(src_data), src_size(src_size), offset(0) { |
+ } |
+ unsigned char* src_data; |
+ OPJ_SIZE_T src_size; |
+ OPJ_SIZE_T offset; |
+}; |
+ |
+/* Wrappers for C-style callbacks. */ |
+OPJ_SIZE_T opj_read_from_memory (void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_user_data); |
+OPJ_SIZE_T opj_write_from_memory (void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_user_data); |
+OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T nb_bytes, void* p_user_data); |
+OPJ_BOOL opj_seek_from_memory (OPJ_OFF_T nb_bytes, void* p_user_data); |
+ |
+#endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |