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 "core/fxcrt/unowned_ptr_exclusion.h" 18 #include "third_party/base/containers/span.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 std::vector<JBig2ArithCtx>* gbContext, 33 std::vector<JBig2ArithCtx>* grContext); 34 35 std::unique_ptr<CJBig2_SymbolDict> DecodeHuffman( 36 CJBig2_BitStream* pStream, 37 std::vector<JBig2ArithCtx>* gbContext, 38 std::vector<JBig2ArithCtx>* grContext); 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 UNOWNED_PTR_EXCLUSION 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 int8_t SDAT[8]; 53 int8_t SDRAT[4]; 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