From 1e16f7bd02d33f0f8b492a424a8115a3277bc8c7 Mon Sep 17 00:00:00 2001 From: Peter Hyman Date: Mon, 25 Nov 2019 07:31:29 -0600 Subject: [PATCH] Small changes to control->threads and memory overhead for LZMA. --- stream.c | 3 ++- util.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stream.c b/stream.c index 4dd2d82..311fc5d 100644 --- a/stream.c +++ b/stream.c @@ -325,7 +325,8 @@ retry: lzma_level, 0, /* dict size. set default, choose by level */ -1, -1, -1, -1, /* lc, lp, pb, fb */ - control->threads); + control->threads > 1 ? 2: 1); + /* LZMA spec has threads = 1 or 2 only. */ if (lzma_ret != SZ_OK) { switch (lzma_ret) { case SZ_ERROR_MEM: diff --git a/util.c b/util.c index a40de7f..94b5c5d 100644 --- a/util.c +++ b/util.c @@ -117,7 +117,9 @@ void setup_overhead(rzip_control *control) i64 dictsize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); - control->overhead = (dictsize * 23 / 2) + (4 * 1024 * 1024); + control->overhead = (dictsize * 23 / 2) + (6 * 1024 * 1024) + 16384; + /* LZMA spec shows memory requirements as 6MB, not 4MB and state size + * where default is 16KB */ } else if (ZPAQ_COMPRESS) control->overhead = 112 * 1024 * 1024; }