Struct HuffmanTree#

Struct Documentation#

struct HuffmanTree#

Huffman tree struct, containing multiple representations of the tree.

Public Functions

constexpr HuffmanTree() noexcept = default#

Constructor.

consteval HuffmanTree(const HuffmanTree&) = delete#

Copy constructor.

consteval HuffmanTree &operator=(const HuffmanTree&) = delete#

Copy assignment operator.

constexpr HuffmanTree(HuffmanTree&&) noexcept = default#

Move constructor.

constexpr HuffmanTree &operator=(HuffmanTree&&) noexcept = default#

Move assignment operator,.

constexpr ~HuffmanTree() = default#

Destructor.

constexpr u32 DecodeSymbol(BitReader &reader) const#

The bit reader must already have been ensured at least 15 bits.

Parameters:

readerBitReader to decode symbol from.

Returns:

Code.

Public Members

std::vector<u32> Codes#
std::vector<u32> Lengths#
u32 MaxBitLength = {}#
u32 NumCodes = {}#

Public Static Functions

static constexpr bool GetTreeInflateFixed(HuffmanTree &treeLL, HuffmanTree &treeD)#

Get the tree of a deflated block with fixed tree, as specified in the deflate specification.

Parameters:
  • treeLL – Literal length huffman tree.

  • treeD – Distance huffman tree.

Returns:

True on success, false otherwise.

static constexpr bool GetTreeInflateDynamic(HuffmanTree &treeLL, HuffmanTree &treeD, BitReader &reader)#

Get the tree of a deflated block with dynamic tree, the tree itself is also Huffman compressed with a known tree.

Parameters:
  • treeLL – Literal length huffman tree.

  • treeD – Distance huffman tree.

  • readerBitReader.

Returns:

True on success, false otherwise.

Public Static Attributes

static constexpr std::array<u32, 29> LengthBase{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}#
static constexpr std::array<u32, 29> LengthExtra{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}#
static constexpr std::array<u32, 30> DistanceBase{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}#
static constexpr std::array<u32, 30> DistanceExtra{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}#