1 // Copyright 2014 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_SRC_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_ 8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_ 9 10 #include <vector> 11 12 #include "core/include/fxcrt/fx_system.h" 13 14 class CJBig2_BitStream; 15 struct JBig2TableLine; 16 17 class CJBig2_HuffmanTable { 18 public: 19 CJBig2_HuffmanTable(const JBig2TableLine* pTable, 20 FX_DWORD nLines, 21 bool bHTOOB); 22 23 explicit CJBig2_HuffmanTable(CJBig2_BitStream* pStream); 24 25 ~CJBig2_HuffmanTable(); 26 27 bool IsHTOOB() const { return HTOOB; } 28 FX_DWORD Size() const { return NTEMP; } 29 const std::vector<int>& GetCODES() const { return CODES; } 30 const std::vector<int>& GetPREFLEN() const { return PREFLEN; } 31 const std::vector<int>& GetRANGELEN() const { return RANGELEN; } 32 const std::vector<int>& GetRANGELOW() const { return RANGELOW; } 33 bool IsOK() const { return m_bOK; } 34 35 private: 36 void ParseFromStandardTable(const JBig2TableLine* pTable); 37 bool ParseFromCodedBuffer(CJBig2_BitStream* pStream); 38 void InitCodes(); 39 void ExtendBuffers(bool increment); 40 41 bool m_bOK; 42 bool HTOOB; 43 FX_DWORD NTEMP; 44 std::vector<int> CODES; 45 std::vector<int> PREFLEN; 46 std::vector<int> RANGELEN; 47 std::vector<int> RANGELOW; 48 }; 49 50 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_ 51