diff options
author | Yann Collet <cyan@fb.com> | 2017-11-03 18:28:28 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-11-03 18:28:28 (GMT) |
commit | 1025546347d75ec94f584294a36132527a45d46c (patch) | |
tree | 2609790bfc414d5cb1b2ca8dd8ef1b276cb7fb4b /lib/lz4hc.c | |
parent | a1f4a0d98361c6ff95833dedba07a9d5a15cfa5e (diff) | |
download | lz4-1025546347d75ec94f584294a36132527a45d46c.zip lz4-1025546347d75ec94f584294a36132527a45d46c.tar.gz lz4-1025546347d75ec94f584294a36132527a45d46c.tar.bz2 |
unified HC levels
LZ4_setCompressionLevel() can be users accross the whole range of HC levels
No more transition issue between Optimal and HC modes
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r-- | lib/lz4hc.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index cea83f2..042e034 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -49,6 +49,7 @@ /*=== Dependency ===*/ +#define LZ4_HC_STATIC_LINKING_ONLY #include "lz4hc.h" @@ -726,18 +727,13 @@ void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel) { LZ4_STATIC_ASSERT(sizeof(LZ4HC_CCtx_internal) <= sizeof(size_t) * LZ4_STREAMHCSIZE_SIZET); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */ LZ4_streamHCPtr->internal_donotuse.base = NULL; - if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX; /* cap compression level */ - LZ4_streamHCPtr->internal_donotuse.compressionLevel = compressionLevel; + LZ4_setCompressionLevel(LZ4_streamHCPtr, 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; - compressionLevel = MIN(compressionLevel, minCLevel); - compressionLevel = MAX(compressionLevel, maxCLevel); + if (compressionLevel < 1) compressionLevel = 1; + if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX; LZ4_streamHCPtr->internal_donotuse.compressionLevel = compressionLevel; } |