| 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 _JBIG2_CONTEXT_H_ | 7 #ifndef _JBIG2_CONTEXT_H_ |
| 8 #define _JBIG2_CONTEXT_H_ | 8 #define _JBIG2_CONTEXT_H_ |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "../../../../third_party/base/nonstd_unique_ptr.h" | 13 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
| 14 #include "../../../include/fxcodec/fx_codec_def.h" | 14 #include "../../../include/fxcodec/fx_codec_def.h" |
| 15 #include "JBig2_GeneralDecoder.h" | 15 #include "JBig2_GeneralDecoder.h" |
| 16 #include "JBig2_List.h" | 16 #include "JBig2_List.h" |
| 17 #include "JBig2_Module.h" | |
| 18 #include "JBig2_Page.h" | 17 #include "JBig2_Page.h" |
| 19 #include "JBig2_Segment.h" | 18 #include "JBig2_Segment.h" |
| 20 | 19 |
| 21 using CJBig2_CachePair = std::pair<uint8_t*, CJBig2_SymbolDict*>; | 20 using CJBig2_CachePair = std::pair<const uint8_t*, CJBig2_SymbolDict*>; |
| 22 | 21 |
| 23 #define JBIG2_SUCCESS 0 | 22 #define JBIG2_SUCCESS 0 |
| 24 #define JBIG2_FAILED -1 | 23 #define JBIG2_FAILED -1 |
| 25 #define JBIG2_ERROR_TOO_SHORT -2 | 24 #define JBIG2_ERROR_TOO_SHORT -2 |
| 26 #define JBIG2_ERROR_FATAL -3 | 25 #define JBIG2_ERROR_FATAL -3 |
| 27 #define JBIG2_END_OF_PAGE 2 | 26 #define JBIG2_END_OF_PAGE 2 |
| 28 #define JBIG2_END_OF_FILE 3 | 27 #define JBIG2_END_OF_FILE 3 |
| 29 #define JBIG2_ERROR_FILE_FORMAT -4 | 28 #define JBIG2_ERROR_FILE_FORMAT -4 |
| 30 #define JBIG2_ERROR_STREAM_TYPE -5 | 29 #define JBIG2_ERROR_STREAM_TYPE -5 |
| 31 #define JBIG2_ERROR_LIMIT -6 | 30 #define JBIG2_ERROR_LIMIT -6 |
| 32 #define JBIG2_FILE_STREAM 0 | 31 #define JBIG2_FILE_STREAM 0 |
| 33 #define JBIG2_SQUENTIAL_STREAM 1 | 32 #define JBIG2_SQUENTIAL_STREAM 1 |
| 34 #define JBIG2_RANDOM_STREAM 2 | 33 #define JBIG2_RANDOM_STREAM 2 |
| 35 #define JBIG2_EMBED_STREAM 3 | 34 #define JBIG2_EMBED_STREAM 3 |
| 36 #define JBIG2_MIN_SEGMENT_SIZE 11 | 35 #define JBIG2_MIN_SEGMENT_SIZE 11 |
| 37 | 36 |
| 38 class CJBig2_Context : public CJBig2_Object { | 37 class CJBig2_Context { |
| 39 public: | 38 public: |
| 40 static CJBig2_Context* CreateContext( | 39 static CJBig2_Context* CreateContext( |
| 41 CJBig2_Module* pModule, | 40 const uint8_t* pGlobalData, |
| 42 uint8_t* pGlobalData, | |
| 43 FX_DWORD dwGlobalLength, | 41 FX_DWORD dwGlobalLength, |
| 44 uint8_t* pData, | 42 const uint8_t* pData, |
| 45 FX_DWORD dwLength, | 43 FX_DWORD dwLength, |
| 46 int32_t nStreamType, | 44 int32_t nStreamType, |
| 47 std::list<CJBig2_CachePair>* pSymbolDictCache, | 45 std::list<CJBig2_CachePair>* pSymbolDictCache, |
| 48 IFX_Pause* pPause = NULL); | 46 IFX_Pause* pPause = NULL); |
| 49 | 47 |
| 50 static void DestroyContext(CJBig2_Context* pContext); | 48 static void DestroyContext(CJBig2_Context* pContext); |
| 51 | 49 |
| 52 int32_t getFirstPage(uint8_t* pBuf, | 50 int32_t getFirstPage(uint8_t* pBuf, |
| 53 int32_t width, | 51 int32_t width, |
| 54 int32_t height, | 52 int32_t height, |
| 55 int32_t stride, | 53 int32_t stride, |
| 56 IFX_Pause* pPause); | 54 IFX_Pause* pPause); |
| 57 | 55 |
| 58 int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause); | 56 int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause); |
| 59 | 57 |
| 60 int32_t Continue(IFX_Pause* pPause); | 58 int32_t Continue(IFX_Pause* pPause); |
| 61 FXCODEC_STATUS GetProcessiveStatus() { return m_ProcessiveStatus; } | 59 FXCODEC_STATUS GetProcessiveStatus() { return m_ProcessiveStatus; } |
| 62 | 60 |
| 63 private: | 61 private: |
| 64 enum JBig2State { | 62 enum JBig2State { |
| 65 JBIG2_OUT_OF_PAGE = 0, | 63 JBIG2_OUT_OF_PAGE = 0, |
| 66 JBIG2_IN_PAGE, | 64 JBIG2_IN_PAGE, |
| 67 }; | 65 }; |
| 68 | 66 |
| 69 CJBig2_Context(uint8_t* pGlobalData, | 67 CJBig2_Context(const uint8_t* pGlobalData, |
| 70 FX_DWORD dwGlobalLength, | 68 FX_DWORD dwGlobalLength, |
| 71 uint8_t* pData, | 69 const uint8_t* pData, |
| 72 FX_DWORD dwLength, | 70 FX_DWORD dwLength, |
| 73 int32_t nStreamType, | 71 int32_t nStreamType, |
| 74 std::list<CJBig2_CachePair>* pSymbolDictCache, | 72 std::list<CJBig2_CachePair>* pSymbolDictCache, |
| 75 IFX_Pause* pPause); | 73 IFX_Pause* pPause); |
| 76 | 74 |
| 77 ~CJBig2_Context(); | 75 ~CJBig2_Context(); |
| 78 | 76 |
| 79 int32_t decodeFile(IFX_Pause* pPause); | 77 int32_t decodeFile(IFX_Pause* pPause); |
| 80 | 78 |
| 81 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); | 79 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 FX_BOOL m_bFirstPage; | 135 FX_BOOL m_bFirstPage; |
| 138 CJBig2_ArithDecoder* m_pArithDecoder; | 136 CJBig2_ArithDecoder* m_pArithDecoder; |
| 139 CJBig2_GRDProc* m_pGRD; | 137 CJBig2_GRDProc* m_pGRD; |
| 140 JBig2ArithCtx* m_gbContext; | 138 JBig2ArithCtx* m_gbContext; |
| 141 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; | 139 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; |
| 142 FX_DWORD m_dwOffset; | 140 FX_DWORD m_dwOffset; |
| 143 JBig2RegionInfo m_ri; | 141 JBig2RegionInfo m_ri; |
| 144 std::list<CJBig2_CachePair>* m_pSymbolDictCache; | 142 std::list<CJBig2_CachePair>* m_pSymbolDictCache; |
| 145 }; | 143 }; |
| 146 #endif | 144 #endif |
| OLD | NEW |