ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::bitbuffer::ac_v1::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 115 of file huffman.inl.

Collaboration diagram for alib::bitbuffer::ac_v1::HuffmanDecoder:
[legend]

Inner Type Index:

struct  Node
 Internal struct representing nodes of the huffman code tree. More...
 

Public Method Index:

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

Protected Static Field Index:

static constexpr int MAX_NODES = 511
 The maximum number of nodes in the tree.
 

Protected Field Index:

BitReaderbr
 The bit reader given in the constructor.
 
Node nodePool [MAX_NODES]
 Pre-allocated node objects.
 
int npNext = 0
 The next node in nodePool to use.
 
Node tree
 The root node of the symbol tree.
 

Field Details:

◆ br

BitReader& alib::bitbuffer::ac_v1::HuffmanDecoder::br
protected

The bit reader given in the constructor.

Definition at line 135 of file huffman.inl.

◆ MAX_NODES

int alib::bitbuffer::ac_v1::HuffmanDecoder::MAX_NODES = 511
staticconstexprprotected

The maximum number of nodes in the tree.

Definition at line 133 of file huffman.inl.

◆ nodePool

Node alib::bitbuffer::ac_v1::HuffmanDecoder::nodePool[MAX_NODES]
protected

Pre-allocated node objects.

Definition at line 137 of file huffman.inl.

◆ npNext

int alib::bitbuffer::ac_v1::HuffmanDecoder::npNext = 0
protected

The next node in nodePool to use.

Definition at line 138 of file huffman.inl.

◆ tree

Node alib::bitbuffer::ac_v1::HuffmanDecoder::tree
protected

The root node of the symbol tree.

Definition at line 136 of file huffman.inl.

Constructor(s) / Destructor Details:

◆ HuffmanDecoder()

alib::bitbuffer::ac_v1::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 144 of file huffman.inl.

Method Details:

◆ Read()

uint8_t alib::bitbuffer::ac_v1::HuffmanDecoder::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 157 of file huffman.inl.

◆ ReadTree()

void alib::bitbuffer::ac_v1::HuffmanDecoder::ReadTree ( )

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

Definition at line 224 of file huffman.cpp.


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