lib/compression: LZ77 + Huffman compression
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 17 Nov 2022 10:14:58 +0000 (23:14 +1300)
committerJoseph Sutton <jsutton@samba.org>
Thu, 1 Dec 2022 22:56:39 +0000 (22:56 +0000)
commitd4e3f0c88ef6f9fdc03ef63c8b45a88ab581f854
tree54941280df4c147acd8222a0f14c05032eda0464
parentf86035c65bf4ae41a2c210dbff132dbce499f03c
lib/compression: LZ77 + Huffman compression

This compresses files as described in MS-XCA 2.2, and as decompressed
by the decompressor in the previous commit.

As with the decompressor, there are two public functions -- one that
uses a talloc context, and one that uses pre-allocated memory. The
compressor requires a tightly bound amount of auxillary memory
(>220kB) in a few different buffers, which is all gathered together in
the public struct lzxhuff_compressor_mem. An instantiated but not
initialised copy of this struct is required by the non-talloc
function; it can be used over and over again.

Our compression speed is about the same as the decompression speed
(between 20 and 500 MB/s on this laptop, depending on the data), and
our compression ratio is very similar to that of Windows.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
lib/compression/lzxpress_huffman.c
lib/compression/lzxpress_huffman.h
lib/compression/tests/test_lzx_huffman.c