JCALG1 revision 5.01
(c)1999 by Jeremy Collake
All Rights Reserved.
This software is provided as-is, without warranty of ANY KIND,
either expressed or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
The author shall NOT be held liable for ANY damage to you, your
computer, or to anyone or anything else, that may result from its use,
or misuse. Basically, you use it at YOUR OWN RISK.
Credits
First of all, I would like to credit Joergen Ibsen, author of apLib, for
many suggestions and help with my development of JCALG1. You may notice
similarities between the JCALG1 decompressor and that of apLib. The reason for this is because I could not come up with a better encoding scheme than Joergen Ibsen's. So, I must, rightfully, give him much credit to developing the encoding scheme that JCALG1 uses.
Synopsis
JCALG1 is a fast and tight compression library that can easily
be integrated into any application. Written in 100% assembly,
compression is fairly fast, and decompression is rapid.
Features
- Coded in 100% 32bit x86 assembly language for maximum performance
and minimum size.
- Excellent compression ratio, typically much better than ZIP's deflate.
- Extremely small and fast decompressor. Decompression throughput greater
than 13MB/Sec on my PII/450 with 100mhz SDRAM.
- Adjustable window size to allow for faster compression at the cost of
compression ratio.
- Decompression requires no memory, other than the destination buffer of course.
- x86 assembly decompressor source code included.
- Easy integration with any application.
Specifications
- Author: Jeremy Collake
- Revision: 5.01
- Type: LZSS with Lazy Evaluation, Gamma Encoding, and LOTS of other additions.
- Window Size: Variable. Maximum is size of the source data.
- Orientation: Binary data.
- Compression memory requirement: ((WindowSize+1)*10h)+40000h+WindowSize.
- Phrase Search Algorithm: 64k linked lists holding positions of WORDs in window
- Decompression memory requirement: None.
- Small Decompressor Size: 271 bytes. (could be decreased, I did do some speed optimization).
- Fast Decompressor Size: 415 bytes.
- Decompression Throughput: Approximatly 13MB/Sec+
Documentation
This is where I tell you what you need to know, ever-so-briefly ;). I decided to document
all functions in C, since most people are familar with it. All functions use the STDCALL
calling convention (parameters pushed onto stack, called function adjusts stack before return).
- unsigned int JCALG1_Compress(
- void *Source,
- unsigned int Length,
- void *Destination,
- unsigned int WindowSize,
- AllocFunc *pAlloc,
- DeAllocFunc *pDealloc,
- CallbackFunc *pCallback);
Parameters
- Source is a pointer to the uncompressed data.
- Length is the size of the uncompressed data.
- Destination is a pointer to the destination of the compressed data.
- WindowSize is a nonzero value up to the size of the file. The larger,
the better the compression ratio but the slower the compression.
- pAlloc is a pointer to a memory allocation function. See prototype below.
- pDealloc is a pointer to a memory deallocation function. See prototype below.
- pCallback is a pointer to a callback function which is called in every
iteration of the main compression loop. See protoype below.
Returns: Size of the compressed data, or NULL if the
data could not be compressed.
- unsigned int JCALG1_Decompress(
- void *Source,
- void *Destination);
Parameters
- Source is a pointer to the source data.
- Destination is a pointer to the destination buffer for the uncompressed
data.
Returns: Size of the uncompressed data.
Notes: The decompressor assumes that the direction flag is clear.
- void JCALG1_GetInfo(
- _JCALG1_Info *JCALG1_Info);
Parameters :
- JCALG1_Info is a pointer to a _JCALG1_Info structure.
- typedef struct __JCALG1_Info {
- DWORD MajorRev;
- DWORD MinorRev;
- DWORD FastDecompressorSize;
- DWORD SmallDecompressorSize;
- } _JCALG1_Info;
- BOOL CallbackFunc(
- void *pCurrentSrc,
- void *pCurrentDest);
Parameters :
- pCurrentSrc is a pointer to the current position in the source data.
- pCurrentDest is a pointer to the current position in the destination data.
Return: FALSE to stop compression, TRUE to continue compression.
- void *AllocFunc(
- unsigned int Size);
Parameters
- Size is the number of bytes requested.
Returns: Pointer to allocated memory block.
- BOOL DeallocFunc(
- void *pMemory)
Parameters
- pMemory is a pointer to the memory block to be deallocated.
Returns: FALSE if failure.