From 33281a2257f2c65b1b94dff3b6e567a8a8ba2889 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 29 Jan 2014 00:12:04 +0530 Subject: [PATCH] Fix issue #17. Use LZ4 and Libbsc extra padding space for the compression buffer in adaptive modes. --- adaptive_compress.c | 9 +++++++++ pcompress.c | 5 ----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/adaptive_compress.c b/adaptive_compress.c index b2f4b71..990a0d0 100644 --- a/adaptive_compress.c +++ b/adaptive_compress.c @@ -86,6 +86,9 @@ extern int ppmd_alloc(void *data); extern void ppmd_free(void *data); extern int ppmd_state_init(void **data, int *level, int alloc); +extern int lz4_buf_extra(uint64_t buflen); +extern int libbsc_buf_extra(uint64_t buflen); + struct adapt_data { void *lzma_data; void *ppmd_data; @@ -119,8 +122,14 @@ adapt_stats(int show) void adapt_props(algo_props_t *data, int level, uint64_t chunksize) { + int ext1, ext2; + data->delta2_span = 200; data->deltac_min_distance = EIGHTM; + ext1 = lz4_buf_extra(chunksize); + ext2 = libbsc_buf_extra(chunksize); + if (ext2 > ext1) ext1 = ext2; + data->buf_extra = ext1; } int diff --git a/pcompress.c b/pcompress.c index fa9966d..94c557e 100644 --- a/pcompress.c +++ b/pcompress.c @@ -2127,11 +2127,6 @@ start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int lev * We also keep extra 8-byte space for the last chunk's size. */ compressed_chunksize = chunksize + CHUNK_HDR_SZ + zlib_buf_extra(chunksize); - if (chunksize + props.buf_extra > compressed_chunksize) { - compressed_chunksize += (chunksize + props.buf_extra - - compressed_chunksize); - } - if (pctx->_props_func) { pctx->_props_func(&props, level, chunksize); if (chunksize + props.buf_extra > compressed_chunksize) {