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_JBIG2_JBIG2_CONTEXT_H_ | 7 #ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #define JBIG2_SUCCESS 0 | 24 #define JBIG2_SUCCESS 0 |
25 #define JBIG2_FAILED -1 | 25 #define JBIG2_FAILED -1 |
26 #define JBIG2_ERROR_TOO_SHORT -2 | 26 #define JBIG2_ERROR_TOO_SHORT -2 |
27 #define JBIG2_ERROR_FATAL -3 | 27 #define JBIG2_ERROR_FATAL -3 |
28 #define JBIG2_END_OF_PAGE 2 | 28 #define JBIG2_END_OF_PAGE 2 |
29 #define JBIG2_END_OF_FILE 3 | 29 #define JBIG2_END_OF_FILE 3 |
30 #define JBIG2_ERROR_FILE_FORMAT -4 | 30 #define JBIG2_ERROR_FILE_FORMAT -4 |
31 #define JBIG2_ERROR_STREAM_TYPE -5 | 31 #define JBIG2_ERROR_STREAM_TYPE -5 |
32 #define JBIG2_ERROR_LIMIT -6 | 32 #define JBIG2_ERROR_LIMIT -6 |
33 #define JBIG2_FILE_STREAM 0 | |
34 #define JBIG2_SQUENTIAL_STREAM 1 | |
35 #define JBIG2_RANDOM_STREAM 2 | |
36 #define JBIG2_EMBED_STREAM 3 | |
37 #define JBIG2_MIN_SEGMENT_SIZE 11 | 33 #define JBIG2_MIN_SEGMENT_SIZE 11 |
38 | 34 |
39 class CJBig2_Context { | 35 class CJBig2_Context { |
40 public: | 36 public: |
41 static CJBig2_Context* CreateContext( | 37 static CJBig2_Context* CreateContext( |
42 const uint8_t* pGlobalData, | 38 const uint8_t* pGlobalData, |
43 FX_DWORD dwGlobalLength, | 39 FX_DWORD dwGlobalLength, |
44 const uint8_t* pData, | 40 const uint8_t* pData, |
45 FX_DWORD dwLength, | 41 FX_DWORD dwLength, |
46 int32_t nStreamType, | |
47 std::list<CJBig2_CachePair>* pSymbolDictCache, | 42 std::list<CJBig2_CachePair>* pSymbolDictCache, |
48 IFX_Pause* pPause = NULL); | 43 IFX_Pause* pPause = NULL); |
49 | 44 |
50 static void DestroyContext(CJBig2_Context* pContext); | 45 static void DestroyContext(CJBig2_Context* pContext); |
51 | 46 |
52 int32_t getFirstPage(uint8_t* pBuf, | 47 int32_t getFirstPage(uint8_t* pBuf, |
53 int32_t width, | 48 int32_t width, |
54 int32_t height, | 49 int32_t height, |
55 int32_t stride, | 50 int32_t stride, |
56 IFX_Pause* pPause); | 51 IFX_Pause* pPause); |
57 | 52 |
58 int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause); | |
59 | |
60 int32_t Continue(IFX_Pause* pPause); | 53 int32_t Continue(IFX_Pause* pPause); |
61 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } | 54 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } |
62 | 55 |
63 private: | 56 private: |
64 enum JBig2State { | |
65 JBIG2_OUT_OF_PAGE = 0, | |
66 JBIG2_IN_PAGE, | |
67 }; | |
68 | |
69 CJBig2_Context(const uint8_t* pGlobalData, | 57 CJBig2_Context(const uint8_t* pGlobalData, |
70 FX_DWORD dwGlobalLength, | 58 FX_DWORD dwGlobalLength, |
71 const uint8_t* pData, | 59 const uint8_t* pData, |
72 FX_DWORD dwLength, | 60 FX_DWORD dwLength, |
73 int32_t nStreamType, | |
74 std::list<CJBig2_CachePair>* pSymbolDictCache, | 61 std::list<CJBig2_CachePair>* pSymbolDictCache, |
75 IFX_Pause* pPause); | 62 IFX_Pause* pPause); |
76 | 63 |
77 ~CJBig2_Context(); | 64 ~CJBig2_Context(); |
78 | 65 |
79 int32_t decodeFile(IFX_Pause* pPause); | |
80 | |
81 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); | 66 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); |
82 | 67 |
83 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); | 68 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); |
84 | 69 |
85 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); | 70 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); |
86 | 71 |
87 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); | 72 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); |
88 | 73 |
89 CJBig2_Segment* findSegmentByNumber(FX_DWORD dwNumber); | 74 CJBig2_Segment* findSegmentByNumber(FX_DWORD dwNumber); |
90 | 75 |
(...skipping 25 matching lines...) Expand all Loading... |
116 | 101 |
117 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, | 102 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, |
118 FX_DWORD SBNUMSYMS); | 103 FX_DWORD SBNUMSYMS); |
119 | 104 |
120 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); | 105 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); |
121 | 106 |
122 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); | 107 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); |
123 | 108 |
124 private: | 109 private: |
125 CJBig2_Context* m_pGlobalContext; | 110 CJBig2_Context* m_pGlobalContext; |
126 int32_t m_nStreamType; | 111 nonstd::unique_ptr<CJBig2_BitStream> m_pStream; |
127 CJBig2_BitStream* m_pStream; | |
128 int32_t m_nState; | |
129 CJBig2_List<CJBig2_Segment> m_SegmentList; | 112 CJBig2_List<CJBig2_Segment> m_SegmentList; |
130 CJBig2_List<JBig2PageInfo> m_PageInfoList; | 113 CJBig2_List<JBig2PageInfo> m_PageInfoList; |
131 CJBig2_Image* m_pPage; | 114 nonstd::unique_ptr<CJBig2_Image> m_pPage; |
132 FX_BOOL m_bBufSpecified; | |
133 size_t m_nSegmentDecoded; | 115 size_t m_nSegmentDecoded; |
| 116 bool m_bInPage; |
| 117 bool m_bBufSpecified; |
| 118 int32_t m_PauseStep; |
134 IFX_Pause* m_pPause; | 119 IFX_Pause* m_pPause; |
135 int32_t m_PauseStep; | |
136 FXCODEC_STATUS m_ProcessingStatus; | 120 FXCODEC_STATUS m_ProcessingStatus; |
137 FX_BOOL m_bFirstPage; | |
138 CJBig2_ArithDecoder* m_pArithDecoder; | 121 CJBig2_ArithDecoder* m_pArithDecoder; |
139 CJBig2_GRDProc* m_pGRD; | 122 nonstd::unique_ptr<CJBig2_GRDProc> m_pGRD; |
140 JBig2ArithCtx* m_gbContext; | 123 JBig2ArithCtx* m_gbContext; |
141 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; | 124 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; |
142 FX_DWORD m_dwOffset; | 125 FX_DWORD m_dwOffset; |
143 JBig2RegionInfo m_ri; | 126 JBig2RegionInfo m_ri; |
144 std::list<CJBig2_CachePair>* m_pSymbolDictCache; | 127 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; |
145 }; | 128 }; |
146 | 129 |
147 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 130 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
OLD | NEW |