Class TLZHCompressor (unit TLZHCOMP) |
Inherits from
TComponent
constructor Create(AOwner: TComponent);
- Public declarations
decoder table
destructor Destroy;
Initialize properties - order IS important
function IsError : Integer;
procedure Compress;
Protected declarations } { I/O Buffering routines.
procedure Decompress;
Signal to flush the buffers.
procedure GetBytesBuff(var DTA; NBytes:WORD; var Bytes_Got : WORD);
Flush condition
procedure OnGetBytes(var DTA;NBytes: WORD;var Bytes_Put: WORD);
procedure OnPutBytes(var DTA;NBytes: WORD;var Bytes_Put: WORD);
procedure PutBytesBuff(var DTA; NBytes:WORD; var Bytes_Put : WORD);
Buffer routines (because this algorithm crunches a byte at a
time, I/O buffering is implemented here to improve performance.
Function DecodeChar: Integer;
Add a bit to signal the end of the data.
Function DecodePosition: WORD;
Special end of decompress case - get out.
Procedure DeleteNode(p: Integer);
Inserting node to the tree remove p
Procedure EncodeChar(c: WORD);
update freq tree repeat it until reaching the root
Procedure EncodeEnd;
output lower 6 bits directly
Procedure EncodePosition(c : WORD);
if node's address is odd, output 1
else output 0
Function GetBit: Integer;
Deleting node from the tree } { Huffman coding parameters Huffman coding parameters
Function GetByte: Integer;
get one bit get one bit
Procedure Init;
Procedure InitTree;
Procedure InsertNode(r : Integer);
Initializing tree node
Procedure Putcode(l : Integer; c: WORD);
get a byte get a byte
Procedure Reconst;
initialize freq tree reconstruct freq tree
procedure SetReadBuffer(BufSize : Word);
May be unnecesary.
procedure SetWriteBuffer(BufSize : Word);
Don't mess with these values while compressing or decompressing!!!
Procedure StartHuff;
output l bits initialize freq tree
Procedure update(c : Integer);
reconstruct freq tree update freq tree
property ReadBufSize : Word
Published declarations
property WriteBufSize : Word
property Finished : Boolean
code : WORD;
codesize : longint;
dad : WordRayPtr;
EOI : Boolean;
FfFinished : Boolean;
End of Input flag - for decoding.
FReadBufSize : Word;
freq : FreqPtr;
FwError : Integer;
When we're doing an operation this is False
FWriteBufSize : Word;
getbuf : WORD;
Private declarations
getlen : BYTE;
GetPosn : word;
InBuf : BufPtr;
IOGetBuf : word;
len : WORD;
lson : WordRayPtr;
match_length : Integer;
match_position : Integer;
OutBuf : BufPtr;
printcount : longint;
prnt : PntrPtr;
cumulative freq table }
* pointing parent nodes.
putbuf : WORD;
putlen : BYTE;
PutPosn : word;
I/O Buffer variables
rson : BWordRayPtr;
son : SonPtr;
pointing children nodes (son[], son[] + 1
textsize : longint;
text_buf : TBufPtr;
constructor Create(AOwner: TComponent);
Public declarations
decoder table
destructor Destroy;
Initialize properties - order IS important
function IsError : Integer;
procedure Compress;
Protected declarations } { I/O Buffering routines.
input lower 6 bits directly
procedure Decompress;
Signal to flush the buffers.
procedure GetBytesBuff(var DTA; NBytes:WORD; var Bytes_Got : WORD);
Flush condition
procedure OnGetBytes(var DTA;NBytes: WORD;var Bytes_Put: WORD);
procedure OnPutBytes(var DTA;NBytes: WORD;var Bytes_Put: WORD);
procedure PutBytesBuff(var DTA; NBytes:WORD; var Bytes_Put : WORD);
Buffer routines (because this algorithm crunches a byte at a
time, I/O buffering is implemented here to improve performance.
Function DecodeChar: Integer;
Add a bit to signal the end of the data.
Function DecodePosition: WORD;
Special end of decompress case - get out.
Procedure DeleteNode(p: Integer);
Inserting node to the tree
remove p
Procedure EncodeChar(c: WORD);
update freq tree
repeat it until reaching the root
Procedure EncodeEnd;
output lower 6 bits directly
Procedure EncodePosition(c : WORD);
if node's address is odd, output 1
else output 0
Function GetBit: Integer;
Deleting node from the tree } { Huffman coding parameters
Huffman coding parameters
Function GetByte: Integer;
get one bit
get one bit
Procedure Init;
Procedure InitTree;
Procedure InsertNode(r : Integer);
Initializing tree
node
Procedure Putcode(l : Integer; c: WORD);
get a byte
get a byte
Procedure Reconst;
initialize freq tree
reconstruct freq tree
procedure SetReadBuffer(BufSize : Word);
May be unnecesary.
procedure SetWriteBuffer(BufSize : Word);
Don't mess with these values while compressing or decompressing!!!
Procedure StartHuff;
output l bits
initialize freq tree
Procedure update(c : Integer);
reconstruct freq tree
update freq tree
property ReadBufSize : Word
Published declarations
property WriteBufSize : Word
property Finished : Boolean
code : WORD;
codesize : longint;
dad : WordRayPtr;
EOI : Boolean;
FfFinished : Boolean;
End of Input flag - for decoding. } { Properties
FReadBufSize : Word;
freq : FreqPtr;
FwError : Integer;
When we're doing an operation this is False
FWriteBufSize : Word;
getbuf : WORD;
Private declarations
getlen : BYTE;
GetPosn : word;
InBuf : BufPtr;
IOGetBuf : word;
len : WORD;
lson : WordRayPtr;
match_length : Integer;
match_position : Integer;
OutBuf : BufPtr;
printcount : longint;
prnt : PntrPtr;
cumulative freq table }
* pointing parent nodes.
* area [T..(T + N_CHAR - 1)] are pointers for leaves
putbuf : WORD;
putlen : BYTE;
PutPosn : word;
I/O Buffer variables
rson : BWordRayPtr;
son : SonPtr;
pointing children nodes (son[], son[] + 1
textsize : longint;
text_buf : TBufPtr;