summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJennifer Liu <jenniferliu620@fb.com>2018-06-27 20:36:38 (GMT)
committerJennifer Liu <jenniferliu620@fb.com>2018-06-27 20:36:38 (GMT)
commite778db373b67ce15311b783c49b1d054293ce2af (patch)
tree0a5093a3eb5a14c55b40bde4f8eb6c379522f257 /lib
parent8745638d7c04bdfc33bcf656ed262c2588534db5 (diff)
downloadlz4-e778db373b67ce15311b783c49b1d054293ce2af.zip
lz4-e778db373b67ce15311b783c49b1d054293ce2af.tar.gz
lz4-e778db373b67ce15311b783c49b1d054293ce2af.tar.bz2
Fixed bugs about incorrect acceleration calculation and benchmarking negative compresion level
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4frame.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index e1d0b1d..08bf0fa 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -738,7 +738,7 @@ static size_t LZ4F_makeBlock(void* dst, const void* src, size_t srcSize,
static int LZ4F_compressBlock(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
- int const acceleration = (level < -1) ? -level : 1;
+ int const acceleration = (level < 0) ? -level + 1 : 1;
LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
if (cdict) {
return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
@@ -749,7 +749,7 @@ static int LZ4F_compressBlock(void* ctx, const char* src, char* dst, int srcSize
static int LZ4F_compressBlock_continue(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
- int const acceleration = (level < -1) ? -level : 1;
+ int const acceleration = (level < 0) ? -level + 1 : 1;
(void)cdict; /* init once at beginning of frame */
return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
}