summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c16
-rw-r--r--lib/lz4hc.h4
2 files changed, 8 insertions, 12 deletions
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)