• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
8 #define CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
9 
10 #include <memory>
11 
12 #include "core/fxcodec/fx_codec_def.h"
13 #include "core/fxcrt/fx_coordinates.h"
14 #include "core/fxcrt/fx_system.h"
15 #include "core/fxcrt/unowned_ptr.h"
16 
17 class CJBig2_ArithDecoder;
18 class CJBig2_BitStream;
19 class CJBig2_Image;
20 class IFX_PauseIndicator;
21 struct JBig2ArithCtx;
22 
23 class CJBig2_GRDProc {
24  public:
25   CJBig2_GRDProc();
26   ~CJBig2_GRDProc();
27 
28   std::unique_ptr<CJBig2_Image> decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
29                                              JBig2ArithCtx* gbContext);
30 
31   FXCODEC_STATUS Start_decode_Arith(std::unique_ptr<CJBig2_Image>* pImage,
32                                     CJBig2_ArithDecoder* pArithDecoder,
33                                     JBig2ArithCtx* gbContext,
34                                     IFX_PauseIndicator* pPause);
35   FXCODEC_STATUS Start_decode_MMR(std::unique_ptr<CJBig2_Image>* pImage,
36                                   CJBig2_BitStream* pStream);
37   FXCODEC_STATUS Continue_decode(IFX_PauseIndicator* pPause,
38                                  CJBig2_ArithDecoder* pArithDecoder);
GetReplaceRect()39   FX_RECT GetReplaceRect() const { return m_ReplaceRect; }
40 
41   bool MMR;
42   uint32_t GBW;
43   uint32_t GBH;
44   uint8_t GBTEMPLATE;
45   bool TPGDON;
46   bool USESKIP;
47   CJBig2_Image* SKIP;
48   int8_t GBAT[8];
49 
50  private:
51   bool UseTemplate0Opt3() const;
52   bool UseTemplate1Opt3() const;
53   bool UseTemplate23Opt3() const;
54 
55   FXCODEC_STATUS decode_Arith(IFX_PauseIndicator* pPause,
56                               CJBig2_ArithDecoder* pArithDecoder);
57   FXCODEC_STATUS decode_Arith_Template0_opt3(CJBig2_Image* pImage,
58                                              CJBig2_ArithDecoder* pArithDecoder,
59                                              JBig2ArithCtx* gbContext,
60                                              IFX_PauseIndicator* pPause);
61   FXCODEC_STATUS decode_Arith_Template0_unopt(
62       CJBig2_Image* pImage,
63       CJBig2_ArithDecoder* pArithDecoder,
64       JBig2ArithCtx* gbContext,
65       IFX_PauseIndicator* pPause);
66   FXCODEC_STATUS decode_Arith_Template1_opt3(CJBig2_Image* pImage,
67                                              CJBig2_ArithDecoder* pArithDecoder,
68                                              JBig2ArithCtx* gbContext,
69                                              IFX_PauseIndicator* pPause);
70   FXCODEC_STATUS decode_Arith_Template1_unopt(
71       CJBig2_Image* pImage,
72       CJBig2_ArithDecoder* pArithDecoder,
73       JBig2ArithCtx* gbContext,
74       IFX_PauseIndicator* pPause);
75   FXCODEC_STATUS decode_Arith_Template2_opt3(CJBig2_Image* pImage,
76                                              CJBig2_ArithDecoder* pArithDecoder,
77                                              JBig2ArithCtx* gbContext,
78                                              IFX_PauseIndicator* pPause);
79   FXCODEC_STATUS decode_Arith_Template2_unopt(
80       CJBig2_Image* pImage,
81       CJBig2_ArithDecoder* pArithDecoder,
82       JBig2ArithCtx* gbContext,
83       IFX_PauseIndicator* pPause);
84   FXCODEC_STATUS decode_Arith_Template3_opt3(CJBig2_Image* pImage,
85                                              CJBig2_ArithDecoder* pArithDecoder,
86                                              JBig2ArithCtx* gbContext,
87                                              IFX_PauseIndicator* pPause);
88   FXCODEC_STATUS decode_Arith_Template3_unopt(
89       CJBig2_Image* pImage,
90       CJBig2_ArithDecoder* pArithDecoder,
91       JBig2ArithCtx* gbContext,
92       IFX_PauseIndicator* pPause);
93   std::unique_ptr<CJBig2_Image> decode_Arith_Template0_opt3(
94       CJBig2_ArithDecoder* pArithDecoder,
95       JBig2ArithCtx* gbContext);
96 
97   std::unique_ptr<CJBig2_Image> decode_Arith_Template0_unopt(
98       CJBig2_ArithDecoder* pArithDecoder,
99       JBig2ArithCtx* gbContext);
100 
101   std::unique_ptr<CJBig2_Image> decode_Arith_Template1_opt3(
102       CJBig2_ArithDecoder* pArithDecoder,
103       JBig2ArithCtx* gbContext);
104 
105   std::unique_ptr<CJBig2_Image> decode_Arith_Template1_unopt(
106       CJBig2_ArithDecoder* pArithDecoder,
107       JBig2ArithCtx* gbContext);
108 
109   std::unique_ptr<CJBig2_Image> decode_Arith_Template2_opt3(
110       CJBig2_ArithDecoder* pArithDecoder,
111       JBig2ArithCtx* gbContext);
112 
113   std::unique_ptr<CJBig2_Image> decode_Arith_Template2_unopt(
114       CJBig2_ArithDecoder* pArithDecoder,
115       JBig2ArithCtx* gbContext);
116 
117   std::unique_ptr<CJBig2_Image> decode_Arith_Template3_opt3(
118       CJBig2_ArithDecoder* pArithDecoder,
119       JBig2ArithCtx* gbContext);
120 
121   std::unique_ptr<CJBig2_Image> decode_Arith_Template3_unopt(
122       CJBig2_ArithDecoder* pArithDecoder,
123       JBig2ArithCtx* gbContext);
124 
125   uint32_t m_loopIndex;
126   uint8_t* m_pLine;
127   FXCODEC_STATUS m_ProssiveStatus;
128   CJBig2_Image* m_pImage;
129   JBig2ArithCtx* m_gbContext;
130   uint16_t m_DecodeType;
131   int m_LTP;
132   FX_RECT m_ReplaceRect;
133 };
134 
135 #endif  // CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
136