diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2022-05-11 16:20:46 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2022-05-12 02:22:35 +0000 |
commit | 05c760165bffa246b724d1471e307c488171b749 (patch) | |
tree | 1cc366b9f0766b09fb5cfe140d3782df204f7475 /lib/compression | |
parent | 383a7cfed9856b9057f2e56a1a26b8d4247ebbb6 (diff) | |
download | samba-05c760165bffa246b724d1471e307c488171b749.tar.gz |
compression: add a few comments, including MS-XCA pointers.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/compression')
-rw-r--r-- | lib/compression/lzxpress.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c index f0100372474..71b39c1efb3 100644 --- a/lib/compression/lzxpress.c +++ b/lib/compression/lzxpress.c @@ -58,6 +58,16 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed, uint8_t *compressed, uint32_t max_compressed_size) { + /* + * This is the algorithm in [MS-XCA] 2.3 "Plain LZ77 Compression". + * + * It avoids Huffman encoding by including literal bytes inline when a + * match is not found. Every so often it includes a uint32 bit map + * flagging which positions contain matches and which contain + * literals. The encoding of matches is of variable size, depending on + * the match length; they are always at least 16 bits long, and can + * implicitly use unused half-bytes from earlier in the stream. + */ uint32_t uncompressed_pos, compressed_pos; uint32_t indic; uint32_t indic_pos; @@ -112,6 +122,11 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed, } if (!found) { + /* + * This is going to literal byte, which we flag by + * setting a bit in an indicator field somewhere + * earlier in the stream. + */ CHECK_INPUT_BYTES(sizeof(uint8_t)); CHECK_OUTPUT_BYTES(sizeof(uint8_t)); compressed[compressed_pos++] = uncompressed[uncompressed_pos++]; @@ -211,6 +226,10 @@ ssize_t lzxpress_decompress(const uint8_t *input, uint8_t *output, uint32_t max_output_size) { + /* + * This is the algorithm in [MS-XCA] 2.4 "Plain LZ77 Decompression + * Algorithm Details". + */ uint32_t output_index, input_index; uint32_t indicator, indicator_bit; uint32_t nibble_index; |