summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4frame.c15
-rw-r--r--lib/lz4hc.c7
-rw-r--r--lib/lz4hc.h8
3 files changed, 15 insertions, 15 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 2e42dcc..1dc2bca 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -150,7 +150,6 @@ static void LZ4F_writeLE64 (BYTE* dstPtr, U64 value64)
static const size_t minFHSize = 7;
static const size_t maxFHSize = 15;
static const size_t BHSize = 4;
-static const int minHClevel = 3;
/*-************************************
@@ -306,7 +305,7 @@ size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuf
if (prefs.frameInfo.contentSize != 0)
prefs.frameInfo.contentSize = (U64)srcSize; /* auto-correct content size if selected (!=0) */
- if (prefs.compressionLevel < (int)minHClevel) {
+ if (prefs.compressionLevel < LZ4HC_MIN_CLEVEL) {
cctxI.lz4CtxPtr = &lz4ctx;
cctxI.lz4CtxLevel = 1;
}
@@ -333,7 +332,7 @@ size_t LZ4F_compressFrame(void* dstBuffer, size_t dstMaxSize, const void* srcBuf
if (LZ4F_isError(errorCode)) return errorCode;
dstPtr += errorCode;
- if (prefs.compressionLevel >= (int)minHClevel) /* no allocation necessary with lz4 fast */
+ if (prefs.compressionLevel >= LZ4HC_MIN_CLEVEL) /* no allocation necessary with lz4 fast */
FREEMEM(cctxI.lz4CtxPtr);
return (dstPtr - dstStart);
@@ -404,10 +403,10 @@ size_t LZ4F_compressBegin(LZ4F_compressionContext_t compressionContext, void* ds
cctxPtr->prefs = *preferencesPtr;
/* ctx Management */
- { U32 const tableID = (cctxPtr->prefs.compressionLevel < minHClevel) ? 1 : 2; /* 0:nothing ; 1:LZ4 table ; 2:HC tables */
+ { U32 const tableID = (cctxPtr->prefs.compressionLevel < LZ4HC_MIN_CLEVEL) ? 1 : 2; /* 0:nothing ; 1:LZ4 table ; 2:HC tables */
if (cctxPtr->lz4CtxLevel < tableID) {
FREEMEM(cctxPtr->lz4CtxPtr);
- if (cctxPtr->prefs.compressionLevel < minHClevel)
+ if (cctxPtr->prefs.compressionLevel < LZ4HC_MIN_CLEVEL)
cctxPtr->lz4CtxPtr = (void*)LZ4_createStream();
else
cctxPtr->lz4CtxPtr = (void*)LZ4_createStreamHC();
@@ -432,7 +431,7 @@ size_t LZ4F_compressBegin(LZ4F_compressionContext_t compressionContext, void* ds
cctxPtr->tmpIn = cctxPtr->tmpBuff;
cctxPtr->tmpInSize = 0;
XXH32_reset(&(cctxPtr->xxh), 0);
- if (cctxPtr->prefs.compressionLevel < minHClevel)
+ if (cctxPtr->prefs.compressionLevel < LZ4HC_MIN_CLEVEL)
LZ4_resetStream((LZ4_stream_t*)(cctxPtr->lz4CtxPtr));
else
LZ4_resetStreamHC((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), cctxPtr->prefs.compressionLevel);
@@ -525,7 +524,7 @@ static int LZ4F_localLZ4_compressHC_limitedOutput_continue(void* ctx, const char
static compressFunc_t LZ4F_selectCompression(LZ4F_blockMode_t blockMode, int level)
{
- if (level < minHClevel) {
+ if (level < LZ4HC_MIN_CLEVEL) {
if (blockMode == LZ4F_blockIndependent) return LZ4F_localLZ4_compress_limitedOutput_withState;
return LZ4F_localLZ4_compress_limitedOutput_continue;
}
@@ -535,7 +534,7 @@ static compressFunc_t LZ4F_selectCompression(LZ4F_blockMode_t blockMode, int lev
static int LZ4F_localSaveDict(LZ4F_cctx_t* cctxPtr)
{
- if (cctxPtr->prefs.compressionLevel < minHClevel)
+ if (cctxPtr->prefs.compressionLevel < LZ4HC_MIN_CLEVEL)
return LZ4_saveDict ((LZ4_stream_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
return LZ4_saveDictHC ((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
}
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 80bfa39..8bcebc8 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -37,7 +37,6 @@
/* *************************************
* Tuning Parameter
***************************************/
-static const int LZ4HC_compressionLevel_default = 9;
/*!
* HEAPMODE :
@@ -86,8 +85,6 @@ static const int LZ4HC_compressionLevel_default = 9;
#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
-static const int g_maxCompressionLevel = 16;
-
/**************************************
* Local Types
@@ -371,8 +368,8 @@ static int LZ4HC_compress_generic (
/* init */
- if (compressionLevel > g_maxCompressionLevel) compressionLevel = g_maxCompressionLevel;
- if (compressionLevel < 1) compressionLevel = LZ4HC_compressionLevel_default;
+ if (compressionLevel > LZ4HC_MAX_CLEVEL) compressionLevel = LZ4HC_MAX_CLEVEL;
+ if (compressionLevel < 1) compressionLevel = LZ4HC_DEFAULT_CLEVEL;
maxNbAttempts = 1 << (compressionLevel-1);
ctx->end += inputSize;
diff --git a/lib/lz4hc.h b/lib/lz4hc.h
index fce2213..75eed19 100644
--- a/lib/lz4hc.h
+++ b/lib/lz4hc.h
@@ -45,6 +45,10 @@ extern "C" {
#include <stddef.h> /* size_t */
+#define LZ4HC_MIN_CLEVEL 3
+#define LZ4HC_DEFAULT_CLEVEL 9
+#define LZ4HC_MAX_CLEVEL 16
+
/*-************************************
* Block Compression
**************************************/
@@ -54,9 +58,9 @@ LZ4_compress_HC() :
Compression success is guaranteed if `dst` buffer is sized to handle worst circumstances (data not compressible)
Worst size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
`srcSize` : Max supported value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
- `compressionLevel` : Recommended values are between 4 and 9, although any value between 0 and 16 will work.
+ `compressionLevel` : Recommended values are between 4 and 9, although any value between 0 and LZ4HC_MAX_CLEVEL will work.
0 means "use default value" (see lz4hc.c).
- Values >16 behave the same as 16.
+ Values >LZ4HC_MAX_CLEVEL behave the same as 16.
@return : the number of bytes written into buffer 'dst'
or 0 if compression fails.
*/