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_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_
8 #define CORE_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_
9 
10 #include <vector>
11 
12 #include "core/fxcodec/jbig2/JBig2_Define.h"
13 #include "core/fxcrt/fx_system.h"
14 
15 class CJBig2_BitStream;
16 
17 class CJBig2_HuffmanTable {
18  public:
19   explicit CJBig2_HuffmanTable(size_t idx);
20   explicit CJBig2_HuffmanTable(CJBig2_BitStream* pStream);
21   ~CJBig2_HuffmanTable();
22 
IsHTOOB()23   bool IsHTOOB() const { return HTOOB; }
Size()24   uint32_t Size() const { return NTEMP; }
GetCODES()25   const std::vector<JBig2HuffmanCode>& GetCODES() const { return CODES; }
GetRANGELEN()26   const std::vector<int>& GetRANGELEN() const { return RANGELEN; }
GetRANGELOW()27   const std::vector<int>& GetRANGELOW() const { return RANGELOW; }
IsOK()28   bool IsOK() const { return m_bOK; }
29 
30   constexpr static size_t kNumHuffmanTables = 16;
31 
32  private:
33   bool ParseFromStandardTable(size_t table_idx);
34   bool ParseFromCodedBuffer(CJBig2_BitStream* pStream);
35   void ExtendBuffers(bool increment);
36 
37   bool m_bOK;
38   bool HTOOB;
39   uint32_t NTEMP;
40   std::vector<JBig2HuffmanCode> CODES;
41   std::vector<int> RANGELEN;
42   std::vector<int> RANGELOW;
43 };
44 
45 #endif  // CORE_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_H_
46