Home | History | Annotate | Download | only in jbig2
      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 "core/fxcodec/fx_codec_def.h"
     11 #include "core/fxcrt/fx_coordinates.h"
     12 #include "core/fxcrt/fx_system.h"
     13 
     14 class CJBig2_ArithDecoder;
     15 class CJBig2_BitStream;
     16 class CJBig2_Image;
     17 class IFX_Pause;
     18 struct JBig2ArithCtx;
     19 
     20 class CJBig2_GRDProc {
     21  public:
     22   CJBig2_GRDProc();
     23 
     24   CJBig2_Image* decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
     25                              JBig2ArithCtx* gbContext);
     26 
     27   FXCODEC_STATUS Start_decode_Arith(CJBig2_Image** pImage,
     28                                     CJBig2_ArithDecoder* pArithDecoder,
     29                                     JBig2ArithCtx* gbContext,
     30                                     IFX_Pause* pPause);
     31   FXCODEC_STATUS Start_decode_MMR(CJBig2_Image** pImage,
     32                                   CJBig2_BitStream* pStream,
     33                                   IFX_Pause* pPause);
     34   FXCODEC_STATUS Continue_decode(IFX_Pause* pPause);
     35   FX_RECT GetReplaceRect() const { return m_ReplaceRect; }
     36 
     37   bool MMR;
     38   uint32_t GBW;
     39   uint32_t GBH;
     40   uint8_t GBTEMPLATE;
     41   bool TPGDON;
     42   bool USESKIP;
     43   CJBig2_Image* SKIP;
     44   int8_t GBAT[8];
     45 
     46  private:
     47   bool UseTemplate0Opt3() const;
     48   bool UseTemplate1Opt3() const;
     49   bool UseTemplate23Opt3() const;
     50 
     51   FXCODEC_STATUS decode_Arith(IFX_Pause* pPause);
     52   FXCODEC_STATUS decode_Arith_Template0_opt3(CJBig2_Image* pImage,
     53                                              CJBig2_ArithDecoder* pArithDecoder,
     54                                              JBig2ArithCtx* gbContext,
     55                                              IFX_Pause* pPause);
     56   FXCODEC_STATUS decode_Arith_Template0_unopt(
     57       CJBig2_Image* pImage,
     58       CJBig2_ArithDecoder* pArithDecoder,
     59       JBig2ArithCtx* gbContext,
     60       IFX_Pause* pPause);
     61   FXCODEC_STATUS decode_Arith_Template1_opt3(CJBig2_Image* pImage,
     62                                              CJBig2_ArithDecoder* pArithDecoder,
     63                                              JBig2ArithCtx* gbContext,
     64                                              IFX_Pause* pPause);
     65   FXCODEC_STATUS decode_Arith_Template1_unopt(
     66       CJBig2_Image* pImage,
     67       CJBig2_ArithDecoder* pArithDecoder,
     68       JBig2ArithCtx* gbContext,
     69       IFX_Pause* pPause);
     70   FXCODEC_STATUS decode_Arith_Template2_opt3(CJBig2_Image* pImage,
     71                                              CJBig2_ArithDecoder* pArithDecoder,
     72                                              JBig2ArithCtx* gbContext,
     73                                              IFX_Pause* pPause);
     74   FXCODEC_STATUS decode_Arith_Template2_unopt(
     75       CJBig2_Image* pImage,
     76       CJBig2_ArithDecoder* pArithDecoder,
     77       JBig2ArithCtx* gbContext,
     78       IFX_Pause* pPause);
     79   FXCODEC_STATUS decode_Arith_Template3_opt3(CJBig2_Image* pImage,
     80                                              CJBig2_ArithDecoder* pArithDecoder,
     81                                              JBig2ArithCtx* gbContext,
     82                                              IFX_Pause* pPause);
     83   FXCODEC_STATUS decode_Arith_Template3_unopt(
     84       CJBig2_Image* pImage,
     85       CJBig2_ArithDecoder* pArithDecoder,
     86       JBig2ArithCtx* gbContext,
     87       IFX_Pause* pPause);
     88   CJBig2_Image* decode_Arith_Template0_opt3(CJBig2_ArithDecoder* pArithDecoder,
     89                                             JBig2ArithCtx* gbContext);
     90 
     91   CJBig2_Image* decode_Arith_Template0_unopt(CJBig2_ArithDecoder* pArithDecoder,
     92                                              JBig2ArithCtx* gbContext);
     93 
     94   CJBig2_Image* decode_Arith_Template1_opt3(CJBig2_ArithDecoder* pArithDecoder,
     95                                             JBig2ArithCtx* gbContext);
     96 
     97   CJBig2_Image* decode_Arith_Template1_unopt(CJBig2_ArithDecoder* pArithDecoder,
     98                                              JBig2ArithCtx* gbContext);
     99 
    100   CJBig2_Image* decode_Arith_Template2_opt3(CJBig2_ArithDecoder* pArithDecoder,
    101                                             JBig2ArithCtx* gbContext);
    102 
    103   CJBig2_Image* decode_Arith_Template2_unopt(CJBig2_ArithDecoder* pArithDecoder,
    104                                              JBig2ArithCtx* gbContext);
    105 
    106   CJBig2_Image* decode_Arith_Template3_opt3(CJBig2_ArithDecoder* pArithDecoder,
    107                                             JBig2ArithCtx* gbContext);
    108 
    109   CJBig2_Image* decode_Arith_Template3_unopt(CJBig2_ArithDecoder* pArithDecoder,
    110                                              JBig2ArithCtx* gbContext);
    111 
    112   uint32_t m_loopIndex;
    113   uint8_t* m_pLine;
    114   IFX_Pause* m_pPause;
    115   FXCODEC_STATUS m_ProssiveStatus;
    116   CJBig2_Image** m_pImage;
    117   CJBig2_ArithDecoder* m_pArithDecoder;
    118   JBig2ArithCtx* m_gbContext;
    119   uint16_t m_DecodeType;
    120   int m_LTP;
    121   FX_RECT m_ReplaceRect;
    122 };
    123 
    124 #endif  // CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
    125