Chromium Code Reviews| 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> |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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 |
| 37 #define JBIG2_ERROR_STREAM_TYPE -5 | 37 #define JBIG2_ERROR_STREAM_TYPE -5 |
| 38 #define JBIG2_ERROR_LIMIT -6 | 38 #define JBIG2_ERROR_LIMIT -6 |
| 39 #define JBIG2_MIN_SEGMENT_SIZE 11 | 39 #define JBIG2_MIN_SEGMENT_SIZE 11 |
| 40 | 40 |
| 41 class CJBig2_Context { | 41 class CJBig2_Context { |
| 42 public: | 42 public: |
| 43 static CJBig2_Context* CreateContext( | 43 CJBig2_Context(CPDF_StreamAcc* pGlobalStream, |
| 44 CPDF_StreamAcc* pGlobalStream, | 44 CPDF_StreamAcc* pSrcStream, |
| 45 CPDF_StreamAcc* pSrcStream, | 45 std::list<CJBig2_CachePair>* pSymbolDictCache, |
| 46 std::list<CJBig2_CachePair>* pSymbolDictCache, | 46 IFX_Pause* pPause, |
| 47 IFX_Pause* pPause = nullptr); | 47 bool bIsGlobal); |
| 48 | 48 ~CJBig2_Context(); |
| 49 static void DestroyContext(CJBig2_Context* pContext); | |
| 50 | 49 |
| 51 int32_t getFirstPage(uint8_t* pBuf, | 50 int32_t getFirstPage(uint8_t* pBuf, |
| 52 int32_t width, | 51 int32_t width, |
| 53 int32_t height, | 52 int32_t height, |
| 54 int32_t stride, | 53 int32_t stride, |
| 55 IFX_Pause* pPause); | 54 IFX_Pause* pPause); |
| 56 | 55 |
| 57 int32_t Continue(IFX_Pause* pPause); | 56 int32_t Continue(IFX_Pause* pPause); |
| 58 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } | 57 FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } |
| 59 | 58 |
| 60 private: | 59 private: |
| 61 CJBig2_Context(CPDF_StreamAcc* pGlobalStream, | |
| 62 CPDF_StreamAcc* pSrcStream, | |
| 63 std::list<CJBig2_CachePair>* pSymbolDictCache, | |
| 64 IFX_Pause* pPause, | |
| 65 bool bIsGlobal); | |
| 66 | |
| 67 ~CJBig2_Context(); | |
| 68 | |
| 69 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); | 60 int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); |
| 70 | |
| 71 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); | 61 int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); |
| 72 | |
| 73 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); | 62 int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); |
| 74 | |
| 75 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); | 63 int32_t decode_RandomOrgnazation(IFX_Pause* pPause); |
| 76 | 64 |
| 77 CJBig2_Segment* findSegmentByNumber(uint32_t dwNumber); | 65 CJBig2_Segment* findSegmentByNumber(uint32_t dwNumber); |
| 78 | |
| 79 CJBig2_Segment* findReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment, | 66 CJBig2_Segment* findReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment, |
| 80 uint8_t cType, | 67 uint8_t cType, |
| 81 int32_t nIndex); | 68 int32_t nIndex); |
| 82 | 69 |
| 83 int32_t parseSegmentHeader(CJBig2_Segment* pSegment); | 70 int32_t parseSegmentHeader(CJBig2_Segment* pSegment); |
| 84 | |
| 85 int32_t parseSegmentData(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 71 int32_t parseSegmentData(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
| 86 int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment, | 72 int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment, |
| 87 IFX_Pause* pPause); | 73 IFX_Pause* pPause); |
| 88 | |
| 89 int32_t parseSymbolDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 74 int32_t parseSymbolDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
| 90 | |
| 91 int32_t parseTextRegion(CJBig2_Segment* pSegment); | 75 int32_t parseTextRegion(CJBig2_Segment* pSegment); |
| 92 | |
| 93 int32_t parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 76 int32_t parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
| 94 | |
| 95 int32_t parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 77 int32_t parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
| 96 | |
| 97 int32_t parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); | 78 int32_t parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); |
| 98 | |
| 99 int32_t parseGenericRefinementRegion(CJBig2_Segment* pSegment); | 79 int32_t parseGenericRefinementRegion(CJBig2_Segment* pSegment); |
| 100 | |
| 101 int32_t parseTable(CJBig2_Segment* pSegment); | 80 int32_t parseTable(CJBig2_Segment* pSegment); |
| 102 | |
| 103 int32_t parseRegionInfo(JBig2RegionInfo* pRI); | 81 int32_t parseRegionInfo(JBig2RegionInfo* pRI); |
| 104 | 82 |
| 105 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, | 83 JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, |
| 106 uint32_t SBNUMSYMS); | 84 uint32_t SBNUMSYMS); |
| 107 | 85 |
| 108 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); | 86 void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); |
| 109 | |
| 110 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); | 87 void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); |
| 111 | 88 |
| 112 private: | 89 std::unique_ptr<CJBig2_Context> m_pGlobalContext; |
| 113 CJBig2_Context* m_pGlobalContext; | |
| 114 std::unique_ptr<CJBig2_BitStream> m_pStream; | 90 std::unique_ptr<CJBig2_BitStream> m_pStream; |
| 115 CJBig2_List<CJBig2_Segment> m_SegmentList; | 91 CJBig2_List<CJBig2_Segment> m_SegmentList; |
| 116 CJBig2_List<JBig2PageInfo> m_PageInfoList; | 92 CJBig2_List<JBig2PageInfo> m_PageInfoList; |
| 117 std::unique_ptr<CJBig2_Image> m_pPage; | 93 std::unique_ptr<CJBig2_Image> m_pPage; |
| 118 size_t m_nSegmentDecoded; | 94 size_t m_nSegmentDecoded; |
| 119 bool m_bInPage; | 95 bool m_bInPage; |
| 120 bool m_bBufSpecified; | 96 bool m_bBufSpecified; |
| 121 int32_t m_PauseStep; | 97 int32_t m_PauseStep; |
| 122 IFX_Pause* m_pPause; | 98 IFX_Pause* const m_pPause; |
| 123 FXCODEC_STATUS m_ProcessingStatus; | 99 FXCODEC_STATUS m_ProcessingStatus; |
| 100 std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> m_gbContext; | |
|
Lei Zhang
2016/07/16 01:30:38
vector?
Wei Li
2016/07/18 21:29:35
Done.
| |
| 124 std::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; | 101 std::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; |
| 125 std::unique_ptr<CJBig2_GRDProc> m_pGRD; | 102 std::unique_ptr<CJBig2_GRDProc> m_pGRD; |
| 126 JBig2ArithCtx* m_gbContext; | |
| 127 std::unique_ptr<CJBig2_Segment> m_pSegment; | 103 std::unique_ptr<CJBig2_Segment> m_pSegment; |
| 128 uint32_t m_dwOffset; | 104 uint32_t m_dwOffset; |
| 129 JBig2RegionInfo m_ri; | 105 JBig2RegionInfo m_ri; |
| 130 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; | 106 std::list<CJBig2_CachePair>* const m_pSymbolDictCache; |
| 131 bool m_bIsGlobal; | 107 bool m_bIsGlobal; |
| 132 }; | 108 }; |
| 133 | 109 |
| 134 #endif // CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ | 110 #endif // CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |
| OLD | NEW |