itpp::HuffmanCoder Class Reference

Huffman Coder implementation class. This class provides a Huffman entropy coder. More...

#include <HuffmanCoder.h>

List of all members.

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: $[0\ldots N-1]$).
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


Detailed Description

Huffman Coder implementation class. This class provides a Huffman entropy coder.

Author:
Ruediger Knoerig
Examples:

main.cpp.


Constructor & Destructor Documentation

itpp::HuffmanCoder::HuffmanCoder ( unsigned int  H0  )  [inline]

Default constructor resulting in an initialized but untrained Huffman coder.

Parameters:
H0 The entropy coder will have an input range of $[0\ldots 2^{H0}-1$.

itpp::HuffmanCoder::HuffmanCoder ( unsigned int  H0,
const itpp::Vec< unsigned int > &  trainingdata 
) [inline]

Default constructor resulting in an initialized and untrained Huffman coder.

Parameters:
H0 The entropy coder will have an input range of $[0\ldots 2^{H0}-1$.


Member Function Documentation

itpp::bvec itpp::HuffmanCoder::code ( itpp::Vec< unsigned int >  symbols  )  [inline]

Method for coding an input vector.

Parameters:
symbols Raw PCM input vector.
Returns:
Bit vector containing the Huffman-coded input vector.

itpp::bvec itpp::HuffmanCoder::code ( unsigned int  symbol  )  [inline]

Method for coding an individual input sample.

Parameters:
symbol Symbol code in raw PCM.
Returns:
Bit vector containing the Huffman code according to the input sample.
Examples:
main.cpp.

itpp::Vec< unsigned int > itpp::HuffmanCoder::decode ( itpp::bvec  coded  ) 

Method for decoding an coded vector.

Parameters:
coded Huffman-Coded bit sequence.
Returns:
decoded Vector filled with the decoded sequence.
Examples:
main.cpp.

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.

Returns:
The N Huffman code vectors (array index = according symbol).
Examples:
main.cpp.

unsigned int itpp::HuffmanCoder::getH0 (  )  const [inline]

Getter for the raw PCM input rate the Huffman coder is build for.

Returns:
H0 / raw PCM rate.

unsigned int itpp::HuffmanCoder::getN (  )  const [inline]

Getter for the upper input range delimiter (input range: $[0\ldots N-1]$).

Returns:
N
Examples:
main.cpp.

bool itpp::HuffmanCoder::isInitialized (  )  const [inline]

Getter for the initialized state.

Returns:
True if the Huffman coder has been initialized.
Examples:
main.cpp.

bool itpp::HuffmanCoder::isTrained (  )  const [inline]

Getter for the trained state.

Returns:
True if the Huffman coder has been trained.
Examples:
main.cpp.

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!

Parameters:
H0 The entropy coder will have an input range of $[0\ldots 2^{H0}-1$.

double itpp::HuffmanCoder::train ( const Vec< unsigned int > &  trainingdata  ) 

Method for training the Huffman coder.

Parameters:
trainingdata Vector of input data to train the Huffman coder.
Returns:
mean code length.
Examples:
main.cpp.


Member Data Documentation

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

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


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

Generated on Mon Feb 9 17:46:23 2009 for Huffman-Coder by  doxygen 1.5.8