summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_GrdProc.h
blob: 08081dde3d886234691be10bbec774459fa2cb46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2015 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
#define CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_

#include <memory>

#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/unowned_ptr.h"

class CJBig2_ArithDecoder;
class CJBig2_BitStream;
class CJBig2_Image;
class PauseIndicatorIface;
struct JBig2ArithCtx;

class CJBig2_GRDProc {
 public:
  CJBig2_GRDProc();
  ~CJBig2_GRDProc();

  std::unique_ptr<CJBig2_Image> DecodeArith(CJBig2_ArithDecoder* pArithDecoder,
                                            JBig2ArithCtx* gbContext);

  FXCODEC_STATUS StartDecodeArith(std::unique_ptr<CJBig2_Image>* pImage,
                                  CJBig2_ArithDecoder* pArithDecoder,
                                  JBig2ArithCtx* gbContext,
                                  PauseIndicatorIface* pPause);
  FXCODEC_STATUS StartDecodeMMR(std::unique_ptr<CJBig2_Image>* pImage,
                                CJBig2_BitStream* pStream);
  FXCODEC_STATUS ContinueDecode(PauseIndicatorIface* pPause,
                                CJBig2_ArithDecoder* pArithDecoder);
  const FX_RECT& GetReplaceRect() const { return m_ReplaceRect; }

  bool MMR;
  uint32_t GBW;
  uint32_t GBH;
  uint8_t GBTEMPLATE;
  bool TPGDON;
  bool USESKIP;
  CJBig2_Image* SKIP;
  int8_t GBAT[8];

 private:
  bool UseTemplate0Opt3() const;
  bool UseTemplate1Opt3() const;
  bool UseTemplate23Opt3() const;

  FXCODEC_STATUS ProgressiveDecodeArith(PauseIndicatorIface* pPause,
                                        CJBig2_ArithDecoder* pArithDecoder);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate0Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate0Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate1Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate1Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate2Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate2Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate3Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);
  FXCODEC_STATUS ProgressiveDecodeArithTemplate3Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      PauseIndicatorIface* pPause);

  std::unique_ptr<CJBig2_Image> DecodeArithTemplate0Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate0Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate1Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate1Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate2Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate2Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate3Opt3(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);
  std::unique_ptr<CJBig2_Image> DecodeArithTemplate3Unopt(
      CJBig2_ArithDecoder* pArithDecoder,
      JBig2ArithCtx* gbContext);

  uint32_t m_loopIndex;
  uint8_t* m_pLine;
  FXCODEC_STATUS m_ProssiveStatus;
  CJBig2_Image* m_pImage;
  JBig2ArithCtx* m_gbContext;
  uint16_t m_DecodeType;
  int m_LTP;
  FX_RECT m_ReplaceRect;
};

#endif  // CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_