Logo Search packages:      
Sourcecode: camstream version File versions  Download package

CAdaptiveHuffman Class Reference

List of all members.

Detailed Description

An adaptive Huffman encoder in C++.

This probably isn't the fastest implementation around, but at least this code is (hopefully) a lot easier to understand than, for example, the JPEG Huffman encoder (which is static anyway).

This class has an extra for the compressor: it allows you to set marks in the compressed bitstream. This is useful if you want to add a group of values that belong together, but you don't know a priori if they will fit in the remaining bufferspace. By setting a mark after each succesfull group you can be assured you don't end up with half groups (and you don't waste space in the buffer either).

Definition at line 7 of file AdaptiveHuffman.h.

Public Types

enum  { ValueOutOfBounds = -1, BufferFull = -2, EndOfFile = -3 }

Public Member Functions

int AddValue (int v)
 CAdaptiveHuffman (int max_value)
int GetBits () const
 Return number of bits in (marked) buffer.
const char * GetBuffer () const
int GetValue ()
void InitCompressor (int buffer_size, char use_marks)
void InitDecompressor (int bits, const char *buffer)
void Mark ()
 Set bit position marker.
void PrintAncestors ()
void PrintTree ()

Private Member Functions

void Allocate ()
void CleanUp ()
bool Stuff (int code, int length)

Private Attributes

HuffNode ** Array
int BitPos
int BitShift
char BufC
char * Buffer
int BufferSize
const char * BufP
char Compressor
int Count
int LogValue
int MarkedBitPos
int MaxValue
HuffNode * Root
int State
char UseMarks
HuffNode ** Values
HuffNode * Walk
HuffNode * Zero

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

Generated by  Doxygen 1.6.0   Back to index