72 int bitsLeft= rec.wordLength;
75 "Try to write symbol unknown to Huffman table: {}, ", symbol, bitsLeft )
78 "Try to write symbol unknown to Huffman table: ", symbol )
82 auto* word= rec.words;
84 bw.WriteBits<32>( *word );
89 bw.WriteBits(bitsLeft, *word );
148 if( node->
left ==
nullptr)
151 auto v=
br.ReadBits<1>();
152 node= v ? node->
right
#define ALIB_ASSERT_ERROR(cond, domain,...)
Reads bits from a #"BitBufferBase".
Writes bits into a #"BitBufferBase".
int npNext
The next node in #".nodePool" to use.
static constexpr int MAX_NODES
The maximum number of nodes in the tree.
HuffmanDecoder(BitReader &bitReader)
Node tree
The root node of the symbol tree.
Node nodePool[MAX_NODES]
Pre-allocated node objects.
BitReader & br
The bit reader given in the constructor.
BitWriter & bw
The bit writer to use for encoding the data.
static constexpr int WORD_SIZE
HuffmanEncoder(BitWriter &bitWriter)
void Write(uint8_t symbol)
static constexpr int MAX_CODE_LENGTH
void CountSymbol(uint8_t symbol)
Symbol symbols[256]
The symbol table.
void Generate()
Generates the huffman encoding table and writes this information to the bit writer.
static constexpr int MAX_WORDS
int ShiftOpRHS
Type alias in namespace #"%alib".
Internal struct representing nodes of the huffman code tree.
Node * right
The right child node.
Node * left
The left child node.
std::size_t frequency
The number of occurrences of the symbol.
uint32_t words[MAX_WORDS]
The bitcode of the symbol.
alib::ShiftOpRHS wordLength
0: symbol not used, otherwise between 1 and 255.