From b10fe5514ff33d3aa073e863cfc64931e33a9643 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Mon, 4 Mar 2019 20:15:18 +0100 Subject: [PATCH] Modified lz4 code to create a fix for #73 - by default, 7-Zip ZS creates lz4 streams with skippable frames, cause this makes parallel decompression possible - but: sometimes this feature is not needed or wanted - this patch will skip the writing of the additional frames for lz4, when compressing single threaded (-mmt=1) --- C/zstdmt/lz4-mt_compress.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/C/zstdmt/lz4-mt_compress.c b/C/zstdmt/lz4-mt_compress.c index 0e479619..24ed4929 100644 --- a/C/zstdmt/lz4-mt_compress.c +++ b/C/zstdmt/lz4-mt_compress.c @@ -291,11 +291,13 @@ static void *pt_compress(void *arg) } /* write skippable frame */ - MEM_writeLE32((unsigned char *)wl->out.buf + 0, - LZ4FMT_MAGIC_SKIPPABLE); - MEM_writeLE32((unsigned char *)wl->out.buf + 4, 4); - MEM_writeLE32((unsigned char *)wl->out.buf + 8, (U32) result); - wl->out.size = result + 12; + if (ctx->threads > 1) { + MEM_writeLE32((unsigned char *)wl->out.buf + 0, + LZ4FMT_MAGIC_SKIPPABLE); + MEM_writeLE32((unsigned char *)wl->out.buf + 4, 4); + MEM_writeLE32((unsigned char *)wl->out.buf + 8, (U32) result); + wl->out.size = result + 12; + } /* write result */ pthread_mutex_lock(&ctx->write_mutex);