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