00001
#ifndef ADAPTIVEHUFFMAN_HPP
00002
#define ADAPTIVEHUFFMAN_HPP
00003
00004
struct HuffNode;
00005
struct HuffBlocks;
00006
00007 class CAdaptiveHuffman
00008 {
00009
private:
00010
00011
int MaxValue;
00012
int LogValue;
00013
char Compressor;
00014
char UseMarks;
00015
00016
00017
HuffNode **Values;
00018
HuffNode *Root, *Zero;
00019
int Count;
00020
HuffNode **Array;
00021
00022
00023
char *Buffer;
00024
int BufferSize;
00025
int BitPos, MarkedBitPos;
00026
00027
00028
HuffNode *Walk;
00029
const char *BufP;
00030
char BufC;
00031
int State, BitShift;
00032
00033
void Allocate();
00034
void CleanUp();
00035
00036
bool Stuff(
int code,
int length);
00037
00038
public:
00039
enum {
00040
ValueOutOfBounds = -1,
00041
BufferFull = -2,
00042
EndOfFile = -3,
00043 };
00044
00045
CAdaptiveHuffman(
int max_value);
00046
~CAdaptiveHuffman();
00047
00048
void InitCompressor(
int buffer_size,
char use_marks);
00049
int AddValue(
int v);
00050
void Mark();
00051
int GetBits()
const;
00052
const char *
GetBuffer()
const;
00053
00054
void InitDecompressor(
int bits,
const char *buffer);
00055
int GetValue();
00056
00057
void PrintTree();
00058
void PrintAncestors();
00059 };
00060
00061
#endif