tree update dependent from compression level

This commit is contained in:
Przemyslaw Skibinski 2016-12-09 18:17:46 +01:00
parent 838ed341f9
commit 4f050b68d8
3 changed files with 7 additions and 4 deletions

View File

@ -574,8 +574,10 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int
static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock)
{
if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */
LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS);
if (ctxPtr->compressionLevel >= LZ4HC_MIN_CLEVEL_OPT)
LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS);
else
if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */
/* Only one memory segment for extDict, so any previous extDict is lost at this stage */
ctxPtr->lowLimit = ctxPtr->dictLimit;

View File

@ -46,6 +46,7 @@ extern "C" {
/* --- Useful constants --- */
#define LZ4HC_MIN_CLEVEL 3
#define LZ4HC_DEFAULT_CLEVEL 9
#define LZ4HC_MIN_CLEVEL_OPT 11
#define LZ4HC_MAX_CLEVEL 12

View File

@ -36,7 +36,7 @@
#define LZ4_LOG_PARSER(fmt, ...) //printf(fmt, __VA_ARGS__)
#define LZ4_LOG_PRICE(fmt, ...) //printf(fmt, __VA_ARGS__)
#define LZ4_LOG_ENCODE(fmt, ...) //printf(fmt, __VA_ARGS__)
#include <stdio.h>
#define LZ4_OPT_NUM (1<<12)
@ -189,7 +189,7 @@ FORCE_INLINE int LZ4HC_BinTree_GetAllMatches (
if (ip < ctx->base + ctx->nextToUpdateBT) return 0; /* skipped area */
if (fullUpdate) LZ4HC_updateBinTree(ctx, ip, iHighLimit);
best_mlen = LZ4HC_BinTree_InsertAndGetAllMatches(ctx, ip, iHighLimit, best_mlen, matches, &mnum);
ctx->nextToUpdateBT = (U32)(ip - ctx->base) + best_mlen;
ctx->nextToUpdateBT = (U32)(ip - ctx->base + best_mlen);
return mnum;
}