RLE input-file | BWT | MTF | RLE | ARI > output-file
A brief description of each of the programs follows:
RLE.CPP This program implements a simple run-length encoder. If the input file has many long runs of identical characters, the sorting procedure in the BWT can be degraded dramatically. The RLE front end prevents that from happening.
BWT.CPP The standard Burrows-Wheeler transform is done here. This program outputs repeated blocks consisting of a block size integer, a copy of L, the primary index, and a special last character index. This is repeated until BWT.EXE runs out of input data.
MTF.CPP The Move to Front encoder operates as described in the previous section.
RLE.CPP The fact that the output file is top-heavy with runs containing zeros means that applying another RLE pass to the output can improve overall compression. I believe that further processing of the MTF output will provide fertile ground for additional improvements.
ARI.CPP This is an order-0 adaptive arithmetic encoder, directly derived from the code published by Witten and Cleary in their 1987 CACM article.
advzip -z -3 test.zip
-z, --recompress ARCHIVES...
Recompress the specified archives. If the -1, -2, -3, -4 options are specified, it's used the smallest file choice from: the previous compressed data, the new compression and the uncompressed format. If the -0 option is specified the archive is always rewritten without any compression.
...
-1, --shrink-fast
Set the compression level to "fast" using the zlib compressor.
-2, --shrink-normal
Set the compression level to "normal" using the 7z compressor. This is the default level of compression.
-3, --shrink-extra
Set the compression level to "extra" using the 7z compressor. You can define the compressor iterations with the -i, --iter option.
-4, --shrink-insane
Set the compression level to "insane" using the zopfli compressor. You can define the compressor iterations with the -i, --iter option.