Open-Source Compression Library
A small, lossless compression library loosely based on LZSS and written entirely in 32-bit x86 assembly. It compresses very well, though slowly, and decompresses as fast as any other LZ77 derivative.
A legacy project, first released in 1999. The download includes the library and its x86 assembly source.
Features
A good compression ratio, typically much better than ZIP’s deflate.
An extremely small and fast decompressor that needs no memory beyond the output buffer.
A unique ability to handle data that is already compressed or otherwise high in entropy.
Choose a smaller window for faster compression, at the cost of compression ratio.
A handful of STDCALL functions that fit into any application.
Open source under the MIT license.
Results
Compression results with a 128 KB window (c7).
| File | Original Size | Compressed Size | Bits Per Byte |
|---|---|---|---|
| bib | 111,261 | 36,594 | 2.63 |
| book1 | 768,771 | 335,310 | 3.49 |
| book2 | 610,856 | 213,402 | 2.79 |
| geo | 102,400 | 71,022 | 5.55 |
| news | 377,109 | 142,978 | 3.03 |
| obj1 | 21,504 | 9,982 | 3.71 |
| obj2 | 246,814 | 77,722 | 2.52 |
| paper1 | 53,161 | 20,014 | 3.01 |
| paper2 | 82,199 | 32,534 | 3.17 |
| pic | 513,216 | 58,338 | 0.91 |
| progc | 39,611 | 14,194 | 2.87 |
| progl | 71,646 | 17,174 | 1.92 |
| progp | 49,379 | 11,674 | 1.89 |
| trans | 93,695 | 19,486 | 1.66 |
| Total | 3,141,622 | 1,060,424 | 2.80 (2.70 weighted) |
Documentation
All functions use the STDCALL calling convention: Parameters are pushed onto the stack, and the called function adjusts the stack pointer before returning.
DWORD JCALG1_Compress(
void *Source,
DWORD Length,
void *Destination,
DWORD WindowSize,
AllocFunc *pAlloc,
DeAllocFunc *pDealloc,
CallbackFunc *pCallback,
BOOLEAN bDisableChecksum);Source: The uncompressed data.Length: The size of the uncompressed data.Destination: The buffer for the compressed data. It should be at least 4 bytes larger than the uncompressed data; JCALG1_GetNeededBufferSize returns the minimum size.WindowSize: A nonzero value up to the size of the file. The larger it is, the better the compression ratio, but the slower the compression.pAlloc, pDealloc: Memory allocation and deallocation functions (prototypes below).pCallback: Called on every iteration of the main compression loop (prototype below).bDisableChecksum: If TRUE, no checksum is computed or stored.Returns: The size of the compressed data, or 0 if the data could not be compressed.
DWORD JCALG1_Decompress_Fast(void *Source, void *Destination); DWORD JCALG1_Decompress_Small(void *Source, void *Destination);
Source: The compressed data.Destination: The buffer for the uncompressed data.Returns: The size of the uncompressed data, or 0 if the block is not a valid JCALG1 stream (it failed the header or checksum tests). The Small version is optimized for size, the Fast version for speed.
DWORD JCALG1_GetUncompressedSizeOfCompressedBlock(void *pBlock);
pBlock: A JCALG1 compressed block.Returns: The size of the uncompressed block, in bytes.
DWORD JCALG1_GetNeededBufferSize(DWORD nSize);
nSize: The size, in bytes, of a block of uncompressed data.Returns: The minimum destination buffer size (currently nSize + 4).
void JCALG1_GetInfo(_JCALG1_Info *JCALG1_Info);
typedef struct __JCALG1_Info {
DWORD MajorRev;
DWORD MinorRev;
DWORD FastDecompressorSize;
DWORD SmallDecompressorSize;
} _JCALG1_Info;JCALG1_Info: A _JCALG1_Info structure to fill in.BOOL CallbackFunc(DWORD pCurrentSrc, DWORD pCurrentDest);
pCurrentSrc: The offset of the current position in the uncompressed data.pCurrentDest: The offset of the current position in the compressed data.Returns: FALSE to stop compression, TRUE to continue.
void *AllocFunc(DWORD Size);
Size: The number of bytes requested.Returns: A pointer to the allocated memory block.
BOOL DeallocFunc(void *pMemory);
pMemory: The memory block to free.Returns: FALSE on failure.
Subscribe to get the latest posts sent to your email.
Bitsum Technologies
Independent Windows software since 2002. We build novel solutions to software performance and automation challenges.