ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
HuffmanDecoder Class Reference

Description:

This class, together with sibling HuffmanEncoder implements the well known Huffman compression . The class uses type BitReader to read the bit stream from an underlying BitBuffer .

The use of this class is quite straight forward:

Note, that the length of the stream (the number of bytes to be decompressed) have to be known by the using software. This class is not responsible for storing this piece of information.

Definition at line 144 of file huffman.hpp.

#include <huffman.hpp>

Collaboration diagram for HuffmanDecoder:
[legend]

Inner Type Index:

struct  Node
 

Public Method Index:

 HuffmanDecoder (BitReader &bitReader)
 
uint8_t Read ()
 
ALIB_API void ReadTree ()
 

Field Details:

◆ br

BitReader& br
protected

The bit reader given in the constructor.

Definition at line 164 of file huffman.hpp.

◆ MAX_NODES

constexpr int MAX_NODES = 511
staticconstexprprotected

The maximum number of nodes in the tree.

Definition at line 162 of file huffman.hpp.

◆ nodePool

Node nodePool[MAX_NODES]
protected

Pre-allocated node objects.

Definition at line 166 of file huffman.hpp.

◆ npNext

int npNext = 0
protected

The next node in nodePool to use.

Definition at line 167 of file huffman.hpp.

◆ tree

Node tree
protected

The root node of the symbol tree.

Definition at line 165 of file huffman.hpp.

Constructor(s) / Destructor Details::

◆ HuffmanDecoder()

HuffmanDecoder ( BitReader & bitReader)
inline

Constructor.

Parameters
bitReaderThe bit reader to read the huffman encoding table and then the encoded symbols from. (Stored in field br.)

Definition at line 175 of file huffman.hpp.

Method Details:

◆ Read()

uint8_t Read ( )
inline

Reads a symbol from the bit stream. This method has to be invoked for every symbol stored, after once reading the encoding information with method ReadTree.

Returns
The symbol read.

Definition at line 189 of file huffman.hpp.

Here is the call graph for this function:

◆ ReadTree()

void ReadTree ( )

Reads the information to decode the data from the beginning of the bit stream. This method has to be invoked once prior to reading the symbols with method Read.

Definition at line 221 of file huffman.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: