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" | |
14 #include "../../../include/fxcodec/fx_codec_def.h" | |
15 #include "JBig2_GeneralDecoder.h" | |
16 #include "JBig2_List.h" | |
13 #include "JBig2_Module.h" | 17 #include "JBig2_Module.h" |
14 #include "JBig2_List.h" | 18 #include "JBig2_Page.h" |
15 #include "JBig2_Segment.h" | 19 #include "JBig2_Segment.h" |
16 #include "JBig2_Page.h" | |
17 #include "JBig2_GeneralDecoder.h" | |
18 #include "../../../include/fxcodec/fx_codec_def.h" | |
19 | 20 |
20 typedef std::pair<uint8_t*, CJBig2_SymbolDict*> CJBig2_CachePair; | 21 using CJBig2_CachePair = std::pair<uint8_t*, CJBig2_SymbolDict*>; |
21 typedef enum { | 22 |
23 enum JBig2State { | |
Tom Sepez
2015/09/03 20:24:58
nit: private, scoped by CJBig2_Context class.
Lei Zhang
2015/09/03 22:52:12
Done.
| |
22 JBIG2_OUT_OF_PAGE = 0, | 24 JBIG2_OUT_OF_PAGE = 0, |
23 JBIG2_IN_PAGE, | 25 JBIG2_IN_PAGE, |
24 } JBig2State; | 26 }; |
27 | |
25 #define JBIG2_SUCCESS 0 | 28 #define JBIG2_SUCCESS 0 |
26 #define JBIG2_FAILED -1 | 29 #define JBIG2_FAILED -1 |
27 #define JBIG2_ERROR_TOO_SHORT -2 | 30 #define JBIG2_ERROR_TOO_SHORT -2 |
28 #define JBIG2_ERROR_FATAL -3 | 31 #define JBIG2_ERROR_FATAL -3 |
29 #define JBIG2_END_OF_PAGE 2 | 32 #define JBIG2_END_OF_PAGE 2 |
30 #define JBIG2_END_OF_FILE 3 | 33 #define JBIG2_END_OF_FILE 3 |
31 #define JBIG2_ERROR_FILE_FORMAT -4 | 34 #define JBIG2_ERROR_FILE_FORMAT -4 |
32 #define JBIG2_ERROR_STREAM_TYPE -5 | 35 #define JBIG2_ERROR_STREAM_TYPE -5 |
33 #define JBIG2_ERROR_LIMIT -6 | 36 #define JBIG2_ERROR_LIMIT -6 |
34 #define JBIG2_FILE_STREAM 0 | 37 #define JBIG2_FILE_STREAM 0 |
35 #define JBIG2_SQUENTIAL_STREAM 1 | 38 #define JBIG2_SQUENTIAL_STREAM 1 |
36 #define JBIG2_RANDOM_STREAM 2 | 39 #define JBIG2_RANDOM_STREAM 2 |
37 #define JBIG2_EMBED_STREAM 3 | 40 #define JBIG2_EMBED_STREAM 3 |
38 #define JBIG2_MIN_SEGMENT_SIZE 11 | 41 #define JBIG2_MIN_SEGMENT_SIZE 11 |
42 | |
39 class CJBig2_Context : public CJBig2_Object { | 43 class CJBig2_Context : public CJBig2_Object { |
Tom Sepez
2015/09/03 20:24:58
missed one?
Lei Zhang
2015/09/03 22:52:12
No, next CL...
| |
40 public: | 44 public: |
41 static CJBig2_Context* CreateContext( | 45 static CJBig2_Context* CreateContext( |
42 CJBig2_Module* pModule, | 46 CJBig2_Module* pModule, |
43 uint8_t* pGlobalData, | 47 uint8_t* pGlobalData, |
44 FX_DWORD dwGlobalLength, | 48 FX_DWORD dwGlobalLength, |
45 uint8_t* pData, | 49 uint8_t* pData, |
46 FX_DWORD dwLength, | 50 FX_DWORD dwLength, |
47 int32_t nStreamType, | 51 int32_t nStreamType, |
48 std::list<CJBig2_CachePair>* pSymbolDictCache, | 52 std::list<CJBig2_CachePair>* pSymbolDictCache, |
49 IFX_Pause* pPause = NULL); | 53 IFX_Pause* pPause = NULL); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 116 |
113 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, | 117 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, |
114 FX_DWORD SBNUMSYMS); | 118 FX_DWORD SBNUMSYMS); |
115 | 119 |
116 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); | 120 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); |
117 | 121 |
118 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); | 122 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); |
119 | 123 |
120 private: | 124 private: |
121 CJBig2_Context* m_pGlobalContext; | 125 CJBig2_Context* m_pGlobalContext; |
122 | 126 |
Tom Sepez
2015/09/03 20:24:58
nit: maybe kill blank lines to be consistent with
Lei Zhang
2015/09/03 22:52:12
Done.
| |
123 int32_t m_nStreamType; | 127 int32_t m_nStreamType; |
124 | 128 |
125 CJBig2_BitStream* m_pStream; | 129 CJBig2_BitStream* m_pStream; |
126 | 130 |
127 int32_t m_nState; | 131 int32_t m_nState; |
128 | 132 |
129 CJBig2_List<CJBig2_Segment>* m_pSegmentList; | 133 CJBig2_List<CJBig2_Segment> m_SegmentList; |
130 | 134 |
131 CJBig2_List<JBig2PageInfo>* m_pPageInfoList; | 135 CJBig2_List<JBig2PageInfo> m_PageInfoList; |
132 | 136 |
133 CJBig2_Image* m_pPage; | 137 CJBig2_Image* m_pPage; |
134 | 138 |
135 FX_BOOL m_bBufSpecified; | 139 FX_BOOL m_bBufSpecified; |
136 | 140 |
137 int32_t m_nSegmentDecoded; | 141 size_t m_nSegmentDecoded; |
138 IFX_Pause* m_pPause; | 142 IFX_Pause* m_pPause; |
139 int32_t m_PauseStep; | 143 int32_t m_PauseStep; |
140 FXCODEC_STATUS m_ProcessiveStatus; | 144 FXCODEC_STATUS m_ProcessiveStatus; |
141 FX_BOOL m_bFirstPage; | 145 FX_BOOL m_bFirstPage; |
142 CJBig2_ArithDecoder* m_pArithDecoder; | 146 CJBig2_ArithDecoder* m_pArithDecoder; |
143 CJBig2_GRDProc* m_pGRD; | 147 CJBig2_GRDProc* m_pGRD; |
144 JBig2ArithCtx* m_gbContext; | 148 JBig2ArithCtx* m_gbContext; |
145 CJBig2_Segment* m_pSegment; | 149 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; |
146 FX_DWORD m_dwOffset; | 150 FX_DWORD m_dwOffset; |
147 JBig2RegionInfo m_ri; | 151 JBig2RegionInfo m_ri; |
148 std::list<CJBig2_CachePair>* m_pSymbolDictCache; | 152 std::list<CJBig2_CachePair>* m_pSymbolDictCache; |
149 }; | 153 }; |
150 #endif | 154 #endif |
OLD | NEW |