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_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 7 #ifndef CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
8 #define CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 8 #define CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" |
15 #include "core/fxcodec/jbig2/JBig2_List.h" | 15 #include "core/fxcodec/jbig2/JBig2_List.h" |
16 #include "core/fxcodec/jbig2/JBig2_Page.h" | 16 #include "core/fxcodec/jbig2/JBig2_Page.h" |
17 #include "core/fxcodec/jbig2/JBig2_Segment.h" | 17 #include "core/fxcodec/jbig2/JBig2_Segment.h" |
18 #include "core/include/fxcodec/fx_codec_def.h" | 18 #include "core/include/fxcodec/fx_codec_def.h" |
19 | 19 |
20 class CJBig2_ArithDecoder; | 20 class CJBig2_ArithDecoder; |
21 class CJBig2_GRDProc; | 21 class CJBig2_GRDProc; |
22 class CPDF_StreamAcc; | 22 class CPDF_StreamAcc; |
23 class IFX_Pause; | 23 class IFX_Pause; |
24 | 24 |
25 // Cache is keyed by the ObjNum of a stream and an index within the stream. | 25 // Cache is keyed by the ObjNum of a stream and an index within the stream. |
26 using CJBig2_CacheKey = std::pair<FX_DWORD, FX_DWORD>; | 26 using CJBig2_CacheKey = std::pair<uint32_t, uint32_t>; |
27 // NB: CJBig2_SymbolDict* is owned. | 27 // NB: CJBig2_SymbolDict* is owned. |
28 using CJBig2_CachePair = std::pair<CJBig2_CacheKey, CJBig2_SymbolDict*>; | 28 using CJBig2_CachePair = std::pair<CJBig2_CacheKey, CJBig2_SymbolDict*>; |
29 | 29 |
30 #define JBIG2_SUCCESS 0 | 30 #define JBIG2_SUCCESS 0 |
31 #define JBIG2_FAILED -1 | 31 #define JBIG2_FAILED -1 |
32 #define JBIG2_ERROR_TOO_SHORT -2 | 32 #define JBIG2_ERROR_TOO_SHORT -2 |
33 #define JBIG2_ERROR_FATAL -3 | 33 #define JBIG2_ERROR_FATAL -3 |
34 #define JBIG2_END_OF_PAGE 2 | 34 #define JBIG2_END_OF_PAGE 2 |
35 #define JBIG2_END_OF_FILE 3 | 35 #define JBIG2_END_OF_FILE 3 |
36 #define JBIG2_ERROR_FILE_FORMAT -4 | 36 #define JBIG2_ERROR_FILE_FORMAT -4 |
(...skipping 30 matching lines...) Expand all Loading... |
67 ~CJBig2_Context(); | 67 ~CJBig2_Context(); |
68 | 68 |
69 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); | 69 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); |
70 | 70 |
71 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); | 71 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); |
72 | 72 |
73 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); | 73 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); |
74 | 74 |
75 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); | 75 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); |
76 | 76 |
77 CJBig2_Segment* findSegmentByNumber(FX_DWORD dwNumber); | 77 CJBig2_Segment* findSegmentByNumber(uint32_t dwNumber); |
78 | 78 |
79 CJBig2_Segment* findReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment, | 79 CJBig2_Segment* findReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment, |
80 uint8_t cType, | 80 uint8_t cType, |
81 int32_t nIndex); | 81 int32_t nIndex); |
82 | 82 |
83 int32_t parseSegmentHeader(CJBig2_Segment* pSegment); | 83 int32_t parseSegmentHeader(CJBig2_Segment* pSegment); |
84 | 84 |
85 int32_t parseSegmentData(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 85 int32_t parseSegmentData(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
86 int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment, | 86 int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment, |
87 IFX_Pause* pPause); | 87 IFX_Pause* pPause); |
88 | 88 |
89 int32_t parseSymbolDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 89 int32_t parseSymbolDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
90 | 90 |
91 int32_t parseTextRegion(CJBig2_Segment* pSegment); | 91 int32_t parseTextRegion(CJBig2_Segment* pSegment); |
92 | 92 |
93 int32_t parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 93 int32_t parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
94 | 94 |
95 int32_t parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 95 int32_t parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
96 | 96 |
97 int32_t parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 97 int32_t parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
98 | 98 |
99 int32_t parseGenericRefinementRegion(CJBig2_Segment* pSegment); | 99 int32_t parseGenericRefinementRegion(CJBig2_Segment* pSegment); |
100 | 100 |
101 int32_t parseTable(CJBig2_Segment* pSegment); | 101 int32_t parseTable(CJBig2_Segment* pSegment); |
102 | 102 |
103 int32_t parseRegionInfo(JBig2RegionInfo* pRI); | 103 int32_t parseRegionInfo(JBig2RegionInfo* pRI); |
104 | 104 |
105 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, | 105 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, |
106 FX_DWORD SBNUMSYMS); | 106 uint32_t SBNUMSYMS); |
107 | 107 |
108 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); | 108 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); |
109 | 109 |
110 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); | 110 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); |
111 | 111 |
112 private: | 112 private: |
113 CJBig2_Context* m_pGlobalContext; | 113 CJBig2_Context* m_pGlobalContext; |
114 std::unique_ptr<CJBig2_BitStream> m_pStream; | 114 std::unique_ptr<CJBig2_BitStream> m_pStream; |
115 CJBig2_List<CJBig2_Segment> m_SegmentList; | 115 CJBig2_List<CJBig2_Segment> m_SegmentList; |
116 CJBig2_List<JBig2PageInfo> m_PageInfoList; | 116 CJBig2_List<JBig2PageInfo> m_PageInfoList; |
117 std::unique_ptr<CJBig2_Image> m_pPage; | 117 std::unique_ptr<CJBig2_Image> m_pPage; |
118 size_t m_nSegmentDecoded; | 118 size_t m_nSegmentDecoded; |
119 bool m_bInPage; | 119 bool m_bInPage; |
120 bool m_bBufSpecified; | 120 bool m_bBufSpecified; |
121 int32_t m_PauseStep; | 121 int32_t m_PauseStep; |
122 IFX_Pause* m_pPause; | 122 IFX_Pause* m_pPause; |
123 FXCODEC_STATUS m_ProcessingStatus; | 123 FXCODEC_STATUS m_ProcessingStatus; |
124 std::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; | 124 std::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; |
125 std::unique_ptr<CJBig2_GRDProc> m_pGRD; | 125 std::unique_ptr<CJBig2_GRDProc> m_pGRD; |
126 JBig2ArithCtx* m_gbContext; | 126 JBig2ArithCtx* m_gbContext; |
127 std::unique_ptr<CJBig2_Segment> m_pSegment; | 127 std::unique_ptr<CJBig2_Segment> m_pSegment; |
128 FX_DWORD m_dwOffset; | 128 uint32_t m_dwOffset; |
129 JBig2RegionInfo m_ri; | 129 JBig2RegionInfo m_ri; |
130 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; | 130 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; |
131 bool m_bIsGlobal; | 131 bool m_bIsGlobal; |
132 }; | 132 }; |
133 | 133 |
134 #endif // CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 134 #endif // CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
OLD | NEW |