CAdaptiveHuffman Class Reference
An adaptive Huffman encoder in C++.
More...
#include <AdaptiveHuffman.h>
List of all members.
Public Types
Public Member Functions
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).
Member Enumeration Documentation
|
- Enumeration values:
-
ValueOutOfBounds |
|
BufferFull |
|
EndOfFile |
|
|
Constructor & Destructor Documentation
CAdaptiveHuffman::CAdaptiveHuffman |
( |
int |
max_values |
) |
|
|
|
constructor
- Parameters:
-
| max_values | The number of values being used for compression |
This initializes the encoder/decoder. With max_values you specify the maximum number of different symbols you want to encode. This number cannot be changed later! |
Member Function Documentation
int CAdaptiveHuffman::AddValue |
( |
int |
v |
) |
|
|
int CAdaptiveHuffman::GetBits |
( |
|
) |
const |
|
|
Return number of bits in (marked) buffer.
This returns the number of bits that are used in the buffer. In case of marks, returns the number in the buffer at the last call to Mark(). |
const char * CAdaptiveHuffman::GetBuffer |
( |
|
) |
const |
|
int CAdaptiveHuffman::GetValue |
( |
|
) |
|
|
void CAdaptiveHuffman::InitCompressor |
( |
int |
buffer_size, |
|
|
char |
use_marks |
|
) |
|
|
|
- Parameters:
-
| buffer_size | Size in bytes |
| use_marks | flag: use marks in bitstream |
When the use_marks parameter is set to non-zero, the Compressor uses marks in the stream. Each time you call Mark() the internal bitpointer is advanced to the current bit position. When use_marks is 0, no marking is done and the bitpointer is always at the end of the buffer. |
void CAdaptiveHuffman::InitDecompressor |
( |
int |
bits, |
|
|
const char * |
buffer |
|
) |
|
|
void CAdaptiveHuffman::Mark |
( |
|
) |
|
|
void CAdaptiveHuffman::PrintAncestors |
( |
|
) |
|
|
void CAdaptiveHuffman::PrintTree |
( |
|
) |
|
|
The documentation for this class was generated from the following files:
Generated on Wed Dec 13 23:38:47 2006 for CamStream by
1.3.7