Unit LZRW1KH

--------------------------------------------------------------- This posting includes the sources for the Turbo Pascal version of the LZRW1/KH compression algoritm. --------------------------------------------------------------- File #1 : The LZRW1KH unit -------------------------- { ################################################################### } { ## ## } { ## ## ##### ##### ## ## ## ## ## ## ## ## ## } { ## ## ### ## ## ## # ## ### ## ## ## ## ## ## } { ## ## ### ##### ####### ## ## #### ###### ## } { ## ## ### ## ## ### ### ## ## ## ## ## ## ## } { ## ##### ##### ## ## ## ## #### ## ## ## ## ## ## } { ## ## } { ## EXTREMELY FAST AND EASY TO UNDERSTAND COMPRESSION ALGORITM ## } { ## ## } { ################################################################### } { ## ## } { ## This unit implements the updated LZRW1/KH algoritm which ## } { ## also implements some RLE coding which is usefull when ## } { ## compress files containing a lot of consecutive bytes ## } { ## having the same value. The algoritm is not as good as ## } { ## LZH, but can compete with Lempel-Ziff. It's the fasted ## } { ## one I've encountered upto now. ## } { ## ## } { ## ## } { ## ## } { ## Kurt HAENEN ## } { ## ## } { ## UNIT MODIFED BY Alexander Halser (May 1998) ## } { ## for proper implementation in Delphi 3 ## } { ## ## } { ###################################################################

Classes

Functions

Compression - compress a buffer of max.
Decompression - decompress a buffer of max 32 KB

Types

BufferArray
BufferIndex
BufferPtr
BufferSize
Int16

Constants

BufferMax
BufferMaxSize
FLAG_Compress
FLAG_Copied

Variables


Functions


FUNCTION Compression ( Source,Dest : BufferPtr; SourceSize : BufferSize ) : BufferSize;

compress a buffer of max. 32 KB

FUNCTION Decompression ( Source,Dest : BufferPtr; SourceSize : BufferSize ) : BufferSize;

decompress a buffer of max 32 KB

Types


BufferArray    = ARRAY [BufferIndex] OF BYTE;
extra bytes needed here if compression fails *dh
BufferIndex    = 0..BufferMax + 15

BufferPtr      = ^BufferArray

BufferSize     = 0..BufferMaxSize

Int16 = SmallInt

Constants

BufferMax = BufferMaxSize-1

BufferMaxSize = 32768

FLAG_Compress = $40

FLAG_Copied = $80


Variables