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