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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "../../../../third_party/base/nonstd_unique_ptr.h" | 13 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
| 14 #include "../../../include/fpdfapi/fpdf_objects.h" |
14 #include "../../../include/fxcodec/fx_codec_def.h" | 15 #include "../../../include/fxcodec/fx_codec_def.h" |
15 #include "JBig2_List.h" | 16 #include "JBig2_List.h" |
16 #include "JBig2_Page.h" | 17 #include "JBig2_Page.h" |
17 #include "JBig2_Segment.h" | 18 #include "JBig2_Segment.h" |
18 | 19 |
19 class CJBig2_GRDProc; | 20 class CJBig2_GRDProc; |
20 class IFX_Pause; | 21 class IFX_Pause; |
21 | 22 |
22 using CJBig2_CachePair = std::pair<const uint8_t*, CJBig2_SymbolDict*>; | 23 // Cache is keyed by the ObjNum of a stream and an index within the stream. |
| 24 using CJBig2_CacheKey = std::pair<FX_DWORD, FX_DWORD>; |
| 25 // NB: CJBig2_SymbolDict* is owned. |
| 26 using CJBig2_CachePair = std::pair<CJBig2_CacheKey, CJBig2_SymbolDict*>; |
23 | 27 |
24 #define JBIG2_SUCCESS 0 | 28 #define JBIG2_SUCCESS 0 |
25 #define JBIG2_FAILED -1 | 29 #define JBIG2_FAILED -1 |
26 #define JBIG2_ERROR_TOO_SHORT -2 | 30 #define JBIG2_ERROR_TOO_SHORT -2 |
27 #define JBIG2_ERROR_FATAL -3 | 31 #define JBIG2_ERROR_FATAL -3 |
28 #define JBIG2_END_OF_PAGE 2 | 32 #define JBIG2_END_OF_PAGE 2 |
29 #define JBIG2_END_OF_FILE 3 | 33 #define JBIG2_END_OF_FILE 3 |
30 #define JBIG2_ERROR_FILE_FORMAT -4 | 34 #define JBIG2_ERROR_FILE_FORMAT -4 |
31 #define JBIG2_ERROR_STREAM_TYPE -5 | 35 #define JBIG2_ERROR_STREAM_TYPE -5 |
32 #define JBIG2_ERROR_LIMIT -6 | 36 #define JBIG2_ERROR_LIMIT -6 |
33 #define JBIG2_MIN_SEGMENT_SIZE 11 | 37 #define JBIG2_MIN_SEGMENT_SIZE 11 |
34 | 38 |
35 class CJBig2_Context { | 39 class CJBig2_Context { |
36 public: | 40 public: |
37 static CJBig2_Context* CreateContext( | 41 static CJBig2_Context* CreateContext( |
38 const uint8_t* pGlobalData, | 42 CPDF_StreamAcc* pGlobalStream, |
39 FX_DWORD dwGlobalLength, | 43 CPDF_StreamAcc* pSrcStream, |
40 const uint8_t* pData, | |
41 FX_DWORD dwLength, | |
42 std::list<CJBig2_CachePair>* pSymbolDictCache, | 44 std::list<CJBig2_CachePair>* pSymbolDictCache, |
43 IFX_Pause* pPause = NULL); | 45 IFX_Pause* pPause = NULL); |
44 | 46 |
45 static void DestroyContext(CJBig2_Context* pContext); | 47 static void DestroyContext(CJBig2_Context* pContext); |
46 | 48 |
47 int32_t getFirstPage(uint8_t* pBuf, | 49 int32_t getFirstPage(uint8_t* pBuf, |
48 int32_t width, | 50 int32_t width, |
49 int32_t height, | 51 int32_t height, |
50 int32_t stride, | 52 int32_t stride, |
51 IFX_Pause* pPause); | 53 IFX_Pause* pPause); |
52 | 54 |
53 int32_t Continue(IFX_Pause* pPause); | 55 int32_t Continue(IFX_Pause* pPause); |
54 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } | 56 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } |
55 | 57 |
56 private: | 58 private: |
57 CJBig2_Context(const uint8_t* pGlobalData, | 59 CJBig2_Context(CPDF_StreamAcc* pGlobalStream, |
58 FX_DWORD dwGlobalLength, | 60 CPDF_StreamAcc* pSrcStream, |
59 const uint8_t* pData, | |
60 FX_DWORD dwLength, | |
61 std::list<CJBig2_CachePair>* pSymbolDictCache, | 61 std::list<CJBig2_CachePair>* pSymbolDictCache, |
62 IFX_Pause* pPause); | 62 IFX_Pause* pPause, |
| 63 bool bIsGlobal); |
63 | 64 |
64 ~CJBig2_Context(); | 65 ~CJBig2_Context(); |
65 | 66 |
66 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); | 67 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); |
67 | 68 |
68 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); | 69 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); |
69 | 70 |
70 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); | 71 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); |
71 | 72 |
72 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); | 73 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 int32_t m_PauseStep; | 119 int32_t m_PauseStep; |
119 IFX_Pause* m_pPause; | 120 IFX_Pause* m_pPause; |
120 FXCODEC_STATUS m_ProcessingStatus; | 121 FXCODEC_STATUS m_ProcessingStatus; |
121 nonstd::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; | 122 nonstd::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; |
122 nonstd::unique_ptr<CJBig2_GRDProc> m_pGRD; | 123 nonstd::unique_ptr<CJBig2_GRDProc> m_pGRD; |
123 JBig2ArithCtx* m_gbContext; | 124 JBig2ArithCtx* m_gbContext; |
124 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; | 125 nonstd::unique_ptr<CJBig2_Segment> m_pSegment; |
125 FX_DWORD m_dwOffset; | 126 FX_DWORD m_dwOffset; |
126 JBig2RegionInfo m_ri; | 127 JBig2RegionInfo m_ri; |
127 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; | 128 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; |
| 129 bool m_bIsGlobal; |
128 }; | 130 }; |
129 | 131 |
130 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 132 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
OLD | NEW |