Examples

The package includes a simple example packer, blzpack, which can compress and decompress a single file using BriefLZ.

blzpack processes the data in blocks of 56k to make the 32-bit and 16-bit versions compatible. The 32-bit version can achieve better ratios by using larger block sizes.

Each compressed block starts with a 24 byte header with the following format:

  • 32-bit signature (string "blz",0x1A)
  • 32-bit format version (1 in current version)
  • 32-bit size of compressed data following header
  • 32-bit CRC32 value of compressed data
  • 32-bit size of original uncompressed data
  • 32-bit CRC32 value of original uncompressed data

All values in the header are stored in network order (big endian, most significant byte first), and are read and written using the get_uint32() and put_uint32() functions.

In most cases storing the CRC32 of both the compressed and decompressed data is superfluous, but in the example it serves as a simple verification of the correct functioning of the compression/decompression code.