1 // Copyright 2015 The PDFium Authors 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_GRRDPROC_H_ 8 #define CORE_FXCODEC_JBIG2_JBIG2_GRRDPROC_H_ 9 10 #include <stdint.h> 11 12 #include <array> 13 #include <memory> 14 15 #include "core/fxcrt/span.h" 16 #include "core/fxcrt/unowned_ptr.h" 17 18 class CJBig2_ArithDecoder; 19 class CJBig2_Image; 20 class JBig2ArithCtx; 21 22 class CJBig2_GRRDProc { 23 public: 24 CJBig2_GRRDProc(); 25 ~CJBig2_GRRDProc(); 26 27 std::unique_ptr<CJBig2_Image> Decode(CJBig2_ArithDecoder* pArithDecoder, 28 pdfium::span<JBig2ArithCtx> grContexts); 29 30 bool GRTEMPLATE; 31 bool TPGRON; 32 uint32_t GRW; 33 uint32_t GRH; 34 int32_t GRREFERENCEDX; 35 int32_t GRREFERENCEDY; 36 UnownedPtr<CJBig2_Image> GRREFERENCE; 37 std::array<int8_t, 4> GRAT; 38 39 private: 40 uint32_t DecodeTemplate0UnoptCalculateContext(const CJBig2_Image& GRREG, 41 const uint32_t* lines, 42 uint32_t w, 43 uint32_t h) const; 44 void DecodeTemplate0UnoptSetPixel(CJBig2_Image* GRREG, 45 uint32_t* lines, 46 uint32_t w, 47 uint32_t h, 48 int bVal); 49 50 std::unique_ptr<CJBig2_Image> DecodeTemplate0Unopt( 51 CJBig2_ArithDecoder* pArithDecoder, 52 pdfium::span<JBig2ArithCtx> grContexts); 53 54 std::unique_ptr<CJBig2_Image> DecodeTemplate0Opt( 55 CJBig2_ArithDecoder* pArithDecoder, 56 pdfium::span<JBig2ArithCtx> grContexts); 57 58 std::unique_ptr<CJBig2_Image> DecodeTemplate1Unopt( 59 CJBig2_ArithDecoder* pArithDecoder, 60 pdfium::span<JBig2ArithCtx> grContexts); 61 62 std::unique_ptr<CJBig2_Image> DecodeTemplate1Opt( 63 CJBig2_ArithDecoder* pArithDecoder, 64 pdfium::span<JBig2ArithCtx> grContexts); 65 }; 66 67 #endif // CORE_FXCODEC_JBIG2_JBIG2_GRRDPROC_H_ 68