8#ifndef HPP_ALIB_BITBUFFER_AC_V1_HUFFMAN
9#define HPP_ALIB_BITBUFFER_AC_V1_HUFFMAN 1
14namespace alib {
namespace bitbuffer {
namespace ac_v1 {
92 NString256(
"Try to write symbol unknown to Huffman table: ")
93 << symbol <<
", " << bitsLeft )
96 "Try to write symbol unknown to Huffman table: ", symbol )
100 auto* word= rec.words;
174 if( node->
left ==
nullptr)
178 node= v ? node->
right
Reads bits from a BitBufferBase.
Writes bits into a BitBufferBase.
void Write(TIntegral value)
int npNext
The next node in nodePool to use.
BitReader & br
The bit reader given in the constructor.
static constexpr int MAX_NODES
The maximum number of nodes in the tree.
Node tree
The root node of the symbol tree.
Node nodePool[MAX_NODES]
Pre-allocated node objects.
HuffmanDecoder(BitReader &bitReader)
static constexpr int WORD_SIZE
ALIB_API void Generate()
Generates the huffman encoding table and writes this information to the bit writer.
Symbol symbols[256]
The symbol table.
void Write(uint8_t symbol)
static constexpr int MAX_CODE_LENGTH
static constexpr int MAX_WORDS
ALIB_FORCE_INLINE void CountSymbol(uint8_t symbol)
BitWriter & bw
The bit writer to use for encoding the data.
#define ALIB_WARNINGS_RESTORE
#define ALIB_FORCE_INLINE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
NLocalString< 256 > NString256
Type alias name for TLocalString<nchar,256>.
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.
uint32_t words[MAX_WORDS]
The bitcode of the symbol.
alib::ShiftOpRHS wordLength
0: symbol not used, otherwise between 1 and 255.
std::size_t frequency
The number of occurrences of the symbol.