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