summaryrefslogtreecommitdiffstats
path: root/lib/lz4hc.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-11-03 09:01:20 (GMT)
committerYann Collet <cyan@fb.com>2017-11-03 09:03:19 (GMT)
commite2eca62046e500a95ab34e913e939aa68acb2cd4 (patch)
tree2093a20c1fcd451c7c8f1e80e22087c3b1e3090b /lib/lz4hc.c
parent3b222d2d963fe6144498a3cb306943566ddb6922 (diff)
downloadlz4-e2eca62046e500a95ab34e913e939aa68acb2cd4.zip
lz4-e2eca62046e500a95ab34e913e939aa68acb2cd4.tar.gz
lz4-e2eca62046e500a95ab34e913e939aa68acb2cd4.tar.bz2
LZ4_compress_HC_continue_destSize() now compatible with optimal parser
levels 11+
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r--lib/lz4hc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index c1f8da6..643fbb2 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -642,8 +642,11 @@ _dest_overflow:
static int LZ4HC_getSearchNum(int compressionLevel)
{
+ assert(compressionLevel >= 1);
+ assert(compressionLevel <= LZ4HC_CLEVEL_MAX);
switch (compressionLevel) {
- default: return 0; /* unused */
+ default: return 1 << (compressionLevel-1);
+ case 10: return 1 << 12;
case 11: return 512;
case 12: return 1<<13;
}
@@ -709,8 +712,7 @@ int LZ4_compress_HC(const char* src, char* dst, int srcSize, int dstCapacity, in
}
/* LZ4_compress_HC_destSize() :
- * currently, only compatible with Hash Chain implementation,
- * hence limit compression level to LZ4HC_CLEVEL_OPT_MIN-1*/
+ * only compatible with Hash Chain match finder */
int LZ4_compress_HC_destSize(void* LZ4HC_Data, const char* source, char* dest, int* sourceSizePtr, int targetDestSize, int cLevel)
{
LZ4HC_CCtx_internal* const ctx = &((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse;
@@ -744,6 +746,7 @@ void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel)
void LZ4_setCompressionLevel(LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel)
{
+ /* note : 1-10 / 11-12 separation might no longer be necessary since optimal parser uses hash chain too */
int const currentCLevel = LZ4_streamHCPtr->internal_donotuse.compressionLevel;
int const minCLevel = currentCLevel < LZ4HC_CLEVEL_OPT_MIN ? 1 : LZ4HC_CLEVEL_OPT_MIN;
int const maxCLevel = currentCLevel < LZ4HC_CLEVEL_OPT_MIN ? LZ4HC_CLEVEL_OPT_MIN-1 : LZ4HC_CLEVEL_MAX;
@@ -824,8 +827,6 @@ int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* src,
int LZ4_compress_HC_continue_destSize (LZ4_streamHC_t* LZ4_streamHCPtr, const char* src, char* dst, int* srcSizePtr, int targetDestSize)
{
- LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
- if (ctxPtr->compressionLevel >= LZ4HC_CLEVEL_OPT_MIN) LZ4HC_init(ctxPtr, (const BYTE*)src); /* not compatible with btopt implementation */
return LZ4_compressHC_continue_generic(LZ4_streamHCPtr, src, dst, srcSizePtr, targetDestSize, limitedDestSize);
}