From: Przemyslaw Skibinski Date: Wed, 7 Dec 2016 11:16:33 +0000 (+0100) Subject: LZ4HC_MAX_CLEVEL = 12 X-Git-Tag: upstream/1.9.3~11^2~137^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3fee94742f9027aa2d27fae6458ce285889552e;p=platform%2Fupstream%2Flz4.git LZ4HC_MAX_CLEVEL = 12 --- diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 4381238..608dea9 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -313,7 +313,7 @@ static int LZ4HC_compress_hashChain ( char* const dest, int const inputSize, int const maxOutputSize, - int compressionLevel, + unsigned maxNbAttempts, limitedOutput_directive limit ) { @@ -326,7 +326,6 @@ static int LZ4HC_compress_hashChain ( BYTE* op = (BYTE*) dest; BYTE* const oend = op + maxOutputSize; - unsigned maxNbAttempts; int ml, ml2, ml3, ml0; const BYTE* ref = NULL; const BYTE* start2 = NULL; @@ -337,7 +336,6 @@ static int LZ4HC_compress_hashChain ( const BYTE* ref0; /* init */ - maxNbAttempts = 1 << (compressionLevel-1); ctx->end += inputSize; ip++; @@ -504,17 +502,15 @@ static int LZ4HC_compress_generic ( */ if (compressionLevel < 1) compressionLevel = LZ4HC_DEFAULT_CLEVEL; - if (compressionLevel > 16) { + if (compressionLevel > 9) { switch (compressionLevel) { - case 17: ctx->searchNum = 16; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, 16); - case 18: ctx->searchNum = 64; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, 64); - case 19: ctx->searchNum = 256; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, 256); + case 10: return LZ4HC_compress_hashChain(ctx, source, dest, inputSize, maxOutputSize, 1 << (16-1), limit); + case 11: ctx->searchNum = 256; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, 256); default: - case 20: ctx->searchNum = 1<<14; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, LZ4_OPT_NUM); + case 12: ctx->searchNum = 1<<14; return LZ4HC_compress_optimal(ctx, source, dest, inputSize, maxOutputSize, limit, LZ4_OPT_NUM); } } - - return LZ4HC_compress_hashChain(ctx, source, dest, inputSize, maxOutputSize, compressionLevel, limit); + return LZ4HC_compress_hashChain(ctx, source, dest, inputSize, maxOutputSize, 1 << (compressionLevel-1), limit); } diff --git a/lib/lz4hc.h b/lib/lz4hc.h index 4882d66..fc8067b 100644 --- a/lib/lz4hc.h +++ b/lib/lz4hc.h @@ -46,7 +46,7 @@ extern "C" { /* --- Useful constants --- */ #define LZ4HC_MIN_CLEVEL 3 #define LZ4HC_DEFAULT_CLEVEL 9 -#define LZ4HC_MAX_CLEVEL 20 +#define LZ4HC_MAX_CLEVEL 12 /*-************************************ @@ -134,7 +134,7 @@ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, in #define LZ4HC_MAXD (1<<(LZ4HC_DICTIONARY_LOGSIZE+1)) #define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1) -#define LZ4HC_HASH_LOG (LZ4HC_DICTIONARY_LOGSIZE-1) +#define LZ4HC_HASH_LOG (LZ4HC_DICTIONARY_LOGSIZE+2) #define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG) #define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)