Fixed bugs about incorrect acceleration calculation and benchmarking negative compresion level
This commit is contained in:
parent
8745638d7c
commit
e778db373b
@ -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);
|
||||
}
|
||||
|
@ -49,7 +49,10 @@
|
||||
|
||||
#include "lz4.h"
|
||||
#define COMPRESSOR0 LZ4_compress_local
|
||||
static int LZ4_compress_local(const char* src, char* dst, int srcSize, int dstSize, int clevel) { (void)clevel; return LZ4_compress_default(src, dst, srcSize, dstSize); }
|
||||
static int LZ4_compress_local(const char* src, char* dst, int srcSize, int dstSize, int clevel) {
|
||||
int const acceleration = (clevel < 0) ? -clevel + 1 : 1;
|
||||
return LZ4_compress_fast(src, dst, srcSize, dstSize, acceleration);
|
||||
}
|
||||
#include "lz4hc.h"
|
||||
#define COMPRESSOR1 LZ4_compress_HC
|
||||
#define DEFAULTCOMPRESSOR COMPRESSOR0
|
||||
|
@ -265,9 +265,8 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat
|
||||
# ./datagen -g20KB generates the same file every single time
|
||||
# cannot save output of ./datagen -g20KB as input file to lz4 because the following shell commands are run before ./datagen -g20KB
|
||||
test "$(shell ./datagen -g20KB | $(LZ4) -c --fast | wc -c)" -lt "$(shell ./datagen -g20KB | $(LZ4) -c --fast=9 | wc -c)" # -1 vs -9
|
||||
test "$(shell ./datagen -g20KB | $(LZ4) -c -1 | wc -c)" -lt "$(shell ./datagen -g20KB| $(LZ4) -c --fast=1 | wc -c)" # 1 vs -1
|
||||
test "$(shell ./datagen -g20KB | $(LZ4) -c --fast=1 | wc -c)" -eq "$(shell ./datagen -g20KB| $(LZ4) -c --fast| wc -c)" # checks default fast compression is -1
|
||||
test "$(shell ./datagen -g20KB | $(LZ4) -c -3 | wc -c)" -lt "$(shell ./datagen -g20KB| $(LZ4) -c --fast=1 | wc -c)" # 3 vs -1
|
||||
test "$(shell ./datagen -g20KB | $(LZ4) -c -1 | wc -c)" -lt "$(shell ./datagen -g20KB| $(LZ4) -c --fast=2 | wc -c)" # 1 vs -2
|
||||
! $(LZ4) -c --fast=0 tmp-tlb-dg20K # lz4 should fail when fast=0
|
||||
! $(LZ4) -c --fast=-1 tmp-tlb-dg20K # lz4 should fail when fast=-1
|
||||
@$(RM) tmp-tlb*
|
||||
|
Loading…
Reference in New Issue
Block a user