Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_Context.h

Issue 1319713003: Make a bunch of JBig2 classes independent of CJBig2_Object. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: more Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_BitStream.h ('k') | core/src/fxcodec/jbig2/JBig2_Context.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
22 JBIG2_OUT_OF_PAGE = 0,
23 JBIG2_IN_PAGE,
24 } JBig2State;
25 #define JBIG2_SUCCESS 0 23 #define JBIG2_SUCCESS 0
26 #define JBIG2_FAILED -1 24 #define JBIG2_FAILED -1
27 #define JBIG2_ERROR_TOO_SHORT -2 25 #define JBIG2_ERROR_TOO_SHORT -2
28 #define JBIG2_ERROR_FATAL -3 26 #define JBIG2_ERROR_FATAL -3
29 #define JBIG2_END_OF_PAGE 2 27 #define JBIG2_END_OF_PAGE 2
30 #define JBIG2_END_OF_FILE 3 28 #define JBIG2_END_OF_FILE 3
31 #define JBIG2_ERROR_FILE_FORMAT -4 29 #define JBIG2_ERROR_FILE_FORMAT -4
32 #define JBIG2_ERROR_STREAM_TYPE -5 30 #define JBIG2_ERROR_STREAM_TYPE -5
33 #define JBIG2_ERROR_LIMIT -6 31 #define JBIG2_ERROR_LIMIT -6
34 #define JBIG2_FILE_STREAM 0 32 #define JBIG2_FILE_STREAM 0
35 #define JBIG2_SQUENTIAL_STREAM 1 33 #define JBIG2_SQUENTIAL_STREAM 1
36 #define JBIG2_RANDOM_STREAM 2 34 #define JBIG2_RANDOM_STREAM 2
37 #define JBIG2_EMBED_STREAM 3 35 #define JBIG2_EMBED_STREAM 3
38 #define JBIG2_MIN_SEGMENT_SIZE 11 36 #define JBIG2_MIN_SEGMENT_SIZE 11
37
39 class CJBig2_Context : public CJBig2_Object { 38 class CJBig2_Context : public CJBig2_Object {
40 public: 39 public:
41 static CJBig2_Context* CreateContext( 40 static CJBig2_Context* CreateContext(
42 CJBig2_Module* pModule, 41 CJBig2_Module* pModule,
43 uint8_t* pGlobalData, 42 uint8_t* pGlobalData,
44 FX_DWORD dwGlobalLength, 43 FX_DWORD dwGlobalLength,
45 uint8_t* pData, 44 uint8_t* pData,
46 FX_DWORD dwLength, 45 FX_DWORD dwLength,
47 int32_t nStreamType, 46 int32_t nStreamType,
48 std::list<CJBig2_CachePair>* pSymbolDictCache, 47 std::list<CJBig2_CachePair>* pSymbolDictCache,
49 IFX_Pause* pPause = NULL); 48 IFX_Pause* pPause = NULL);
50 49
51 static void DestroyContext(CJBig2_Context* pContext); 50 static void DestroyContext(CJBig2_Context* pContext);
52 51
53 int32_t getFirstPage(uint8_t* pBuf, 52 int32_t getFirstPage(uint8_t* pBuf,
54 int32_t width, 53 int32_t width,
55 int32_t height, 54 int32_t height,
56 int32_t stride, 55 int32_t stride,
57 IFX_Pause* pPause); 56 IFX_Pause* pPause);
58 57
59 int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause); 58 int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause);
60 59
61 int32_t Continue(IFX_Pause* pPause); 60 int32_t Continue(IFX_Pause* pPause);
62 FXCODEC_STATUS GetProcessiveStatus() { return m_ProcessiveStatus; } 61 FXCODEC_STATUS GetProcessiveStatus() { return m_ProcessiveStatus; }
63 62
64 private: 63 private:
64 enum JBig2State {
65 JBIG2_OUT_OF_PAGE = 0,
66 JBIG2_IN_PAGE,
67 };
68
65 CJBig2_Context(uint8_t* pGlobalData, 69 CJBig2_Context(uint8_t* pGlobalData,
66 FX_DWORD dwGlobalLength, 70 FX_DWORD dwGlobalLength,
67 uint8_t* pData, 71 uint8_t* pData,
68 FX_DWORD dwLength, 72 FX_DWORD dwLength,
69 int32_t nStreamType, 73 int32_t nStreamType,
70 std::list<CJBig2_CachePair>* pSymbolDictCache, 74 std::list<CJBig2_CachePair>* pSymbolDictCache,
71 IFX_Pause* pPause); 75 IFX_Pause* pPause);
72 76
73 ~CJBig2_Context(); 77 ~CJBig2_Context();
74 78
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
123 int32_t m_nStreamType; 126 int32_t m_nStreamType;
124
125 CJBig2_BitStream* m_pStream; 127 CJBig2_BitStream* m_pStream;
126
127 int32_t m_nState; 128 int32_t m_nState;
128 129 CJBig2_List<CJBig2_Segment> m_SegmentList;
129 CJBig2_List<CJBig2_Segment>* m_pSegmentList; 130 CJBig2_List<JBig2PageInfo> m_PageInfoList;
130
131 CJBig2_List<JBig2PageInfo>* m_pPageInfoList;
132
133 CJBig2_Image* m_pPage; 131 CJBig2_Image* m_pPage;
134
135 FX_BOOL m_bBufSpecified; 132 FX_BOOL m_bBufSpecified;
136 133 size_t m_nSegmentDecoded;
137 int32_t m_nSegmentDecoded;
138 IFX_Pause* m_pPause; 134 IFX_Pause* m_pPause;
139 int32_t m_PauseStep; 135 int32_t m_PauseStep;
140 FXCODEC_STATUS m_ProcessiveStatus; 136 FXCODEC_STATUS m_ProcessiveStatus;
141 FX_BOOL m_bFirstPage; 137 FX_BOOL m_bFirstPage;
142 CJBig2_ArithDecoder* m_pArithDecoder; 138 CJBig2_ArithDecoder* m_pArithDecoder;
143 CJBig2_GRDProc* m_pGRD; 139 CJBig2_GRDProc* m_pGRD;
144 JBig2ArithCtx* m_gbContext; 140 JBig2ArithCtx* m_gbContext;
145 CJBig2_Segment* m_pSegment; 141 nonstd::unique_ptr<CJBig2_Segment> m_pSegment;
146 FX_DWORD m_dwOffset; 142 FX_DWORD m_dwOffset;
147 JBig2RegionInfo m_ri; 143 JBig2RegionInfo m_ri;
148 std::list<CJBig2_CachePair>* m_pSymbolDictCache; 144 std::list<CJBig2_CachePair>* m_pSymbolDictCache;
149 }; 145 };
150 #endif 146 #endif
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_BitStream.h ('k') | core/src/fxcodec/jbig2/JBig2_Context.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698