diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2022-11-21 10:23:53 +1300 |
---|---|---|
committer | Joseph Sutton <jsutton@samba.org> | 2022-12-01 22:56:39 +0000 |
commit | 955214ef6ec0015d8c1e1f8a43cacdf239b4d253 (patch) | |
tree | 340765889f25f9b881381d0e3387425afeb8cce8 /lib/compression | |
parent | d4e3f0c88ef6f9fdc03ef63c8b45a88ab581f854 (diff) | |
download | samba-955214ef6ec0015d8c1e1f8a43cacdf239b4d253.tar.gz |
lib/compression/lzhuff: add debug flag to skip LZ77
Encoding without LZ77 matches is valid, and it is useful for isolating
bugs.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'lib/compression')
-rw-r--r-- | lib/compression/lzxpress_huffman.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compression/lzxpress_huffman.c b/lib/compression/lzxpress_huffman.c index 7a48ca73425..ef64ea7021f 100644 --- a/lib/compression/lzxpress_huffman.c +++ b/lib/compression/lzxpress_huffman.c @@ -31,6 +31,15 @@ #include "lib/util/byteorder.h" #include "lib/util/bytearray.h" +/* + * DEBUG_NO_LZ77_MATCHES toggles the encoding of matches as matches. If it is + * false the potential match is written as a series of literals, which is a + * valid but usually inefficient encoding. This is useful for isolating a + * problem to either the LZ77 or the Huffman stage. + */ +#ifndef DEBUG_NO_LZ77_MATCHES +#define DEBUG_NO_LZ77_MATCHES false +#endif #define LZXPRESS_ERROR -1LL @@ -574,7 +583,7 @@ static ssize_t lz77_encode_block(struct lzxhuff_compressor_context *cmp_ctx, j = 0; - if (remaining_size < 41) { + if (remaining_size < 41 || DEBUG_NO_LZ77_MATCHES) { /* * There is no point doing a hash table and looking for * matches in this tiny block (remembering we are committed to |