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_SDDPROC_H_ 8 #define CORE_FXCODEC_JBIG2_JBIG2_SDDPROC_H_ 9 10 #include <stdint.h> 11 12 #include <memory> 13 #include <vector> 14 15 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" 16 #include "core/fxcrt/unowned_ptr.h" 17 #include "third_party/base/span.h" 18 19 class CJBig2_BitStream; 20 class CJBig2_HuffmanTable; 21 class CJBig2_Image; 22 class CJBig2_SymbolDict; 23 24 class CJBig2_SDDProc { 25 public: 26 CJBig2_SDDProc(); 27 ~CJBig2_SDDProc(); 28 29 std::unique_ptr<CJBig2_SymbolDict> DecodeArith( 30 CJBig2_ArithDecoder* pArithDecoder, 31 std::vector<JBig2ArithCtx>* gbContext, 32 std::vector<JBig2ArithCtx>* grContext); 33 34 std::unique_ptr<CJBig2_SymbolDict> DecodeHuffman( 35 CJBig2_BitStream* pStream, 36 std::vector<JBig2ArithCtx>* gbContext, 37 std::vector<JBig2ArithCtx>* grContext); 38 39 bool SDHUFF; 40 bool SDREFAGG; 41 bool SDRTEMPLATE; 42 uint8_t SDTEMPLATE; 43 uint32_t SDNUMINSYMS; 44 uint32_t SDNUMNEWSYMS; 45 uint32_t SDNUMEXSYMS; 46 CJBig2_Image** SDINSYMS; 47 UnownedPtr<const CJBig2_HuffmanTable> SDHUFFDH; 48 UnownedPtr<const CJBig2_HuffmanTable> SDHUFFDW; 49 UnownedPtr<const CJBig2_HuffmanTable> SDHUFFBMSIZE; 50 UnownedPtr<const CJBig2_HuffmanTable> SDHUFFAGGINST; 51 int8_t SDAT[8]; 52 int8_t SDRAT[4]; 53 54 private: 55 // Reads from `SDINSYMS` if `i` is in-bounds. Otherwise, reduce `i` by 56 // `SDNUMINSYMS` and read from `new_syms` at the new index. 57 CJBig2_Image* GetImage( 58 uint32_t i, 59 pdfium::span<const std::unique_ptr<CJBig2_Image>> new_syms) const; 60 }; 61 62 #endif // CORE_FXCODEC_JBIG2_JBIG2_SDDPROC_H_ 63