#include <HuffmanCoder.h>
Classes | |
class | sort_elem |
Internal class to create the huffman table. | |
Public Member Functions | |
HuffmanCoder () | |
Default constructor resulting in an uninitialized and untrained Huffman coder. | |
HuffmanCoder (unsigned int H0) | |
Default constructor resulting in an initialized but untrained Huffman coder. | |
HuffmanCoder (unsigned int H0, const itpp::Vec< unsigned int > &trainingdata) | |
Default constructor resulting in an initialized and untrained Huffman coder. | |
virtual | ~HuffmanCoder () |
Destructor. | |
void | setRawRate (unsigned int H0) |
Setter for the H0 rate / raw PCM rate. After calling this method the Huffman coder will be in untrained state again! | |
itpp::bvec | code (unsigned int symbol) |
Method for coding an individual input sample. | |
itpp::bvec | code (itpp::Vec< unsigned int > symbols) |
Method for coding an input vector. | |
itpp::Vec< unsigned int > | decode (itpp::bvec coded) |
Method for decoding an coded vector. | |
double | train (const Vec< unsigned int > &trainingdata) |
Method for training the Huffman coder. | |
bool | isTrained () const |
Getter for the trained state. | |
bool | isInitialized () const |
Getter for the initialized state. | |
unsigned int | getN () const |
Getter for the upper input range delimiter (input range: ![]() | |
unsigned int | getH0 () const |
Getter for the raw PCM input rate the Huffman coder is build for. | |
const itpp::Array< itpp::bvec > & | getCodeTable () const |
Getter for the coding table. The coding table consists of the Huffman code vector for each input symbol. | |
const itpp::Vec< unsigned int > & | getDecodeTable () const |
Getter for the decoding table. Address the vector with the numbers of '0' in the huffman code and you get the according symbol. | |
Protected Attributes | |
bool | initialized |
bool | trained |
unsigned int | N |
unsigned int | H0 |
itpp::Array< itpp::bvec > | codetable |
itpp::Vec< unsigned int > | decodetable |
itpp::HuffmanCoder::HuffmanCoder | ( | unsigned int | H0 | ) | [inline] |
Default constructor resulting in an initialized but untrained Huffman coder.
H0 | The entropy coder will have an input range of ![]() |
itpp::HuffmanCoder::HuffmanCoder | ( | unsigned int | H0, | |
const itpp::Vec< unsigned int > & | trainingdata | |||
) | [inline] |
Default constructor resulting in an initialized and untrained Huffman coder.
H0 | The entropy coder will have an input range of ![]() |
itpp::bvec itpp::HuffmanCoder::code | ( | itpp::Vec< unsigned int > | symbols | ) | [inline] |
Method for coding an input vector.
symbols | Raw PCM input vector. |
itpp::bvec itpp::HuffmanCoder::code | ( | unsigned int | symbol | ) | [inline] |
Method for coding an individual input sample.
symbol | Symbol code in raw PCM. |
itpp::Vec< unsigned int > itpp::HuffmanCoder::decode | ( | itpp::bvec | coded | ) |
Method for decoding an coded vector.
coded | Huffman-Coded bit sequence. |
const itpp::Array<itpp::bvec>& itpp::HuffmanCoder::getCodeTable | ( | ) | const [inline] |
Getter for the coding table. The coding table consists of the Huffman code vector for each input symbol.
unsigned int itpp::HuffmanCoder::getH0 | ( | ) | const [inline] |
Getter for the raw PCM input rate the Huffman coder is build for.
unsigned int itpp::HuffmanCoder::getN | ( | ) | const [inline] |
bool itpp::HuffmanCoder::isInitialized | ( | ) | const [inline] |
Getter for the initialized state.
bool itpp::HuffmanCoder::isTrained | ( | ) | const [inline] |
Getter for the trained state.
void itpp::HuffmanCoder::setRawRate | ( | unsigned int | H0 | ) | [inline] |
Setter for the H0 rate / raw PCM rate. After calling this method the Huffman coder will be in untrained state again!
H0 | The entropy coder will have an input range of ![]() |
double itpp::HuffmanCoder::train | ( | const Vec< unsigned int > & | trainingdata | ) |
Method for training the Huffman coder.
trainingdata | Vector of input data to train the Huffman coder. |
itpp::Array<itpp::bvec> itpp::HuffmanCoder::codetable [protected] |
encoding table
itpp::Vec<unsigned int> itpp::HuffmanCoder::decodetable [protected] |
decoding table
unsigned int itpp::HuffmanCoder::H0 [protected] |
Raw PCM rate
bool itpp::HuffmanCoder::initialized [protected] |
Flag indicating if the Huffman coder has been initialized with a raw rate
unsigned int itpp::HuffmanCoder::N [protected] |
input range [0..N-1]
bool itpp::HuffmanCoder::trained [protected] |
Flag indicating if the Huffman coder has been trained