From 203008def90c457b03f668a765166b966a075b4e Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Mon, 30 Jul 2012 23:30:13 +0530 Subject: [PATCH] Further improve LZMA compression parameters to utilize all the 14 levels. Tweak some Rabin parmeters for better reduction with zlib and Bzip2. --- lzma_compress.c | 18 +++++++++++++++--- rabin/rabin_polynomial.c | 9 +++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lzma_compress.c b/lzma_compress.c index 02f80b2..8d0b2e6 100644 --- a/lzma_compress.c +++ b/lzma_compress.c @@ -64,26 +64,38 @@ lzma_init(void **data, int *level, ssize_t chunksize) * compression. */ p->dictSize = LZMA_DEFAULT_DICT; + } else { /* * Let LZMA determine best dict size. */ p->dictSize = 0; } - /* Determine the fast bytes value. */ + + /* Determine the fast bytes value and also adjust dict size further. */ if (*level < 7) { p->fb = 32; } else if (*level < 10) { p->fb = 64; - } else if (*level < 13) { + } else if (*level == 11) { p->fb = 64; p->mc = 128; - } else { + } else if (*level == 12) { p->fb = 128; p->mc = 256; + + } else if (*level == 13) { + p->fb = 64; + p->mc = 128; + p->dictSize = (1 << 27); + + } else if (*level == 14) { + p->fb = 128; + p->mc = 256; + p->dictSize = (1 << 28); } if (*level > 9) *level = 9; p->level = *level; diff --git a/rabin/rabin_polynomial.c b/rabin/rabin_polynomial.c index 202df14..4dbe473 100755 --- a/rabin/rabin_polynomial.c +++ b/rabin/rabin_polynomial.c @@ -120,7 +120,8 @@ create_rabin_context(uint64_t chunksize, uint64_t real_chunksize, const char *al if (((memcmp(algo, "lzma", 4) == 0 || memcmp(algo, "adapt", 5) == 0) && chunksize <= LZMA_WINDOW_MAX) || delta_flag) { - if (memcmp(algo, "lzfx", 4) == 0 || memcmp(algo, "lz4", 3) == 0) { + if (memcmp(algo, "lzfx", 4) == 0 || memcmp(algo, "lz4", 3) == 0 || + memcmp(algo, "zlib", 4) == 0) { ctx->rabin_poly_min_block_size = RAB_POLYNOMIAL_MIN_BLOCK_SIZE2; ctx->rabin_avg_block_mask = RAB_POLYNOMIAL_AVG_BLOCK_MASK2; ctx->rabin_poly_avg_block_size = RAB_POLYNOMIAL_AVG_BLOCK_SIZE2; @@ -129,7 +130,11 @@ create_rabin_context(uint64_t chunksize, uint64_t real_chunksize, const char *al ctx->rabin_poly_min_block_size = RAB_POLYNOMIAL_MIN_BLOCK_SIZE; ctx->rabin_avg_block_mask = RAB_POLYNOMIAL_AVG_BLOCK_MASK; ctx->rabin_poly_avg_block_size = RAB_POLYNOMIAL_AVG_BLOCK_SIZE; - ctx->rabin_break_patt = RAB_POLYNOMIAL_CONST; + if (memcmp(algo, "bzip2", 5) == 0) { + ctx->rabin_break_patt = 0; + } else { + ctx->rabin_break_patt = RAB_POLYNOMIAL_CONST; + } } } else { ctx->rabin_poly_min_block_size = RAB_POLYNOMIAL_MIN_BLOCK_SIZE2;