a minimalist lossless data compression library
liblzg is a minimal implementation of an LZ77 class compression library. The main characteristic of the library is that the decoding routine is very simple, fast, and requires no memory.
In general, liblzg does not compress as well as zlib, for instance. On the other hand the decoder is very simple and very fast - ideal for systems with tight memory limits or limited processing capabilities.
The main features of libzlg are:
The latest release of liblzg is v1.0.8 (2014-09-10). The source code and documentation can be downloaded here:
The archive contains:
Since liblzg is fully portable, it should work with just about any operating system and compiler.
The API documentation can be found here.
To give a picture of how liblzg performs, here is a comparison against zlib and bzip2 at compressing and decompressing the Cantebury Calgary Corpus (a 3.2 MB data set of mixed content). The "level" (on the horizontal axis) is an option to the encoder, basically telling it how hard it should try to achieve a good compression ratio. Level 1 means "be as quick as you can", while level 9 means "try as hard as you can".
The tests were performed on an AMD 64-bit 2.5 GHz 4850e CPU under Ubuntu 10.04 (64-bit).
The compression ratio of liblzg is not guite as good as the rivaling compression libraries, but yet fairly close.
The compression speed of liblzg is similar to zlib and bzip2. The main reason that liblzg is slower than zlib is that liblzg uses a larger sliding window (up to 512 KB, compared to maxiumum 32 KB for zlib).
Decompression is where liblzg really shines. It is almost twice as fast as zlib, and more than 10 times as fast as bzip2. Also, remember that liblzg requires no memory during decompression.
Conclusion: The liblzg library is ideal for pre-compressing content that is to be used in environments where speed and memory is of essence.
Unlike many other compression libraries that are designed to be very fast, liblzg is safe by default with regards to data corruption and buffer overflow. However, it is possible to configure the decompression routine of liblzg to ignore data integrity and buffer boundary checks, but it is not recommended (it is usually only worth it in very special cases).
For the Calgary Corpus data set, disabling the safe mode improves the decompression speed by roughly 12%.
The project is hosted on GitHub, where you can check out the latest development source code, etc.