]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
changed ZSTD_c_compressionStrategy into ZSTD_c_strategy
authorYann Collet <cyan@fb.com>
Thu, 6 Dec 2018 23:00:52 +0000 (15:00 -0800)
committerYann Collet <cyan@fb.com>
Thu, 6 Dec 2018 23:00:52 +0000 (15:00 -0800)
also : fixed paramgrill, and limit conditions

12 files changed:
doc/zstd_manual.html
lib/compress/zstd_compress.c
lib/compress/zstd_ldm.c
lib/compress/zstd_opt.c
lib/compress/zstd_opt.h
lib/zstd.h
programs/benchzstd.c
programs/fileio.c
tests/fullbench.c
tests/fuzz/zstd_helpers.c
tests/paramgrill.c
tests/zstreamtest.c

index 92566e1dd1090ca3b65a4f8d69b2fc32f211247b..d74b41802ab6e186da9fbf851d46b7024a793028 100644 (file)
@@ -399,10 +399,10 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
                ZSTD_lazy2=5,
                ZSTD_btlazy2=6,
                ZSTD_btopt=7,
-               ZSTD_btultra=8
-               </b>/* note : new strategies might be added in the future.<b>
-                         Only the order (from fast to strong) is guaranteed, not the exact position.
-                         new strategy names might be introduced, pushing the maximum number upward */
+               ZSTD_btultra=8,
+               ZSTD_btultra2=9
+               </b>/* note : new strategies _might_ be added in the future.<b>
+                         Only the order (from fast to strong) is guaranteed */
 } ZSTD_strategy;
 </b></pre><BR>
 <pre><b>typedef enum {
@@ -452,7 +452,7 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
                               *     Distance between match sampling.
                               *     Larger values make compression faster, and weaker.
                               * Special: value 0 means "use default targetLength". */
-    ZSTD_c_compressionStrategy=107, </b>/* See ZSTD_strategy enum definition.<b>
+    ZSTD_c_strategy=107,     </b>/* See ZSTD_strategy enum definition.<b>
                               * The higher the value of selected strategy, the more complex it is,
                               * resulting in stronger and slower compression.
                               * Special: value 0 means "use default strategy". */
index cf1c17b29378e9b8a4364890363c8c672532e793..4e47f891819d94a8d671a035c85ce86c491bd423 100644 (file)
@@ -267,7 +267,7 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
         bounds.upperBound = ZSTD_TARGETLENGTH_MAX;
         return bounds;
 
-    case ZSTD_c_compressionStrategy:
+    case ZSTD_c_strategy:
         bounds.lowerBound = (int)ZSTD_fast;
         bounds.upperBound = (int)ZSTD_btultra2;  /* note : how to ensure at compile time that this is the highest value strategy ? */
         return bounds;
@@ -349,12 +349,13 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
     case ZSTD_c_format:
         ZSTD_STATIC_ASSERT((int)ZSTD_f_zstd1 < (int)ZSTD_f_zstd1_magicless);
         bounds.lowerBound = (int)ZSTD_f_zstd1;
-        bounds.upperBound = (int)ZSTD_f_zstd1_magicless;
+        bounds.upperBound = (int)ZSTD_f_zstd1_magicless;   /* note : how to ensure at compile time that this is the highest value enum ? */
         return bounds;
 
     case ZSTD_c_forceAttachDict:
-        bounds.lowerBound = 0;
-        bounds.upperBound = 1;
+        ZSTD_STATIC_ASSERT((int)ZSTD_dictDefaultAttach < (int)ZSTD_dictForceCopy);
+        bounds.lowerBound = ZSTD_dictDefaultAttach;
+        bounds.upperBound = ZSTD_dictForceCopy;           /* note : how to ensure at compile time that this is the highest value enum ? */
         return bounds;
 
     default:
@@ -392,7 +393,7 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
     case ZSTD_c_searchLog:
     case ZSTD_c_minMatch:
     case ZSTD_c_targetLength:
-    case ZSTD_c_compressionStrategy:
+    case ZSTD_c_strategy:
         return 1;
 
     case ZSTD_c_format:
@@ -441,7 +442,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
     case ZSTD_c_searchLog:
     case ZSTD_c_minMatch:
     case ZSTD_c_targetLength:
-    case ZSTD_c_compressionStrategy:
+    case ZSTD_c_strategy:
         if (cctx->cdict) return ERROR(stage_wrong);
         return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
 
@@ -534,13 +535,13 @@ size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* CCtxParams,
         return CCtxParams->cParams.minMatch;
 
     case ZSTD_c_targetLength :
-        /* all values are valid. 0 => use default */
+        CLAMPCHECK(ZSTD_c_targetLength, value);
         CCtxParams->cParams.targetLength = value;
         return CCtxParams->cParams.targetLength;
 
-    case ZSTD_c_compressionStrategy :
+    case ZSTD_c_strategy :
         if (value!=0)   /* 0 => use default */
-            CLAMPCHECK(ZSTD_c_compressionStrategy, value);
+            CLAMPCHECK(ZSTD_c_strategy, value);
         CCtxParams->cParams.strategy = (ZSTD_strategy)value;
         return (size_t)CCtxParams->cParams.strategy;
 
@@ -666,7 +667,7 @@ size_t ZSTD_CCtxParam_getParameter(
     case ZSTD_c_targetLength :
         *value = CCtxParams->cParams.targetLength;
         break;
-    case ZSTD_c_compressionStrategy :
+    case ZSTD_c_strategy :
         *value = (unsigned)CCtxParams->cParams.strategy;
         break;
     case ZSTD_c_contentSizeFlag :
@@ -849,10 +850,8 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
     CLAMPCHECK(ZSTD_c_hashLog,   cParams.hashLog);
     CLAMPCHECK(ZSTD_c_searchLog, cParams.searchLog);
     CLAMPCHECK(ZSTD_c_minMatch,  cParams.minMatch);
-    ZSTD_STATIC_ASSERT(ZSTD_TARGETLENGTH_MIN == 0);
-    if (cParams.targetLength > ZSTD_TARGETLENGTH_MAX)
-        return ERROR(parameter_outOfBound);
-    CLAMPCHECK(ZSTD_c_compressionStrategy, cParams.strategy);
+    CLAMPCHECK(ZSTD_c_targetLength,cParams.targetLength);
+    CLAMPCHECK(ZSTD_c_strategy,  cParams.strategy);
     return 0;
 }
 
@@ -862,20 +861,18 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
 static ZSTD_compressionParameters
 ZSTD_clampCParams(ZSTD_compressionParameters cParams)
 {
-#   define CLAMP(cParam, val) {                                   \
-        ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam); \
-        if (val<bounds.lowerBound) val=bounds.lowerBound;         \
-        else if (val>bounds.upperBound) val=bounds.upperBound;    \
+#   define CLAMP(cParam, val) {                                      \
+        ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam);    \
+        if ((int)val<bounds.lowerBound) val=bounds.lowerBound;       \
+        else if ((int)val>bounds.upperBound) val=bounds.upperBound;  \
     }
     CLAMP(ZSTD_c_windowLog, cParams.windowLog);
     CLAMP(ZSTD_c_chainLog,  cParams.chainLog);
     CLAMP(ZSTD_c_hashLog,   cParams.hashLog);
     CLAMP(ZSTD_c_searchLog, cParams.searchLog);
     CLAMP(ZSTD_c_minMatch,  cParams.minMatch);
-    ZSTD_STATIC_ASSERT(ZSTD_TARGETLENGTH_MIN == 0);
-    if (cParams.targetLength > ZSTD_TARGETLENGTH_MAX)
-        cParams.targetLength = ZSTD_TARGETLENGTH_MAX;
-    CLAMP(ZSTD_c_compressionStrategy, cParams.strategy);
+    CLAMP(ZSTD_c_targetLength,cParams.targetLength);
+    CLAMP(ZSTD_c_strategy,  cParams.strategy);
     return cParams;
 }
 
@@ -1841,11 +1838,9 @@ static size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, cons
  * note : use same formula for both situations */
 static size_t ZSTD_minGain(size_t srcSize, ZSTD_strategy strat)
 {
-    U32 const minlog = (U32)strat - 1;
-    ZSTD_STATIC_ASSERT(ZSTD_btopt == 7);
-    assert(strat >= ZSTD_btopt);
-    return (srcSize >> minlog) + 2;
-}
+    U32 const minlog = (strat>=ZSTD_btultra) ? (U32)(strat) - 1 : 6;
+    ZSTD_STATIC_ASSERT(ZSTD_btultra == 8);
+    return (srcSize >> minlog) + 2;}
 
 static size_t ZSTD_compressLiterals (ZSTD_hufCTables_t const* prevHuf,
                                      ZSTD_hufCTables_t* nextHuf,
@@ -2585,7 +2580,7 @@ ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMo
     ZSTD_blockCompressor selectedCompressor;
     ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
 
-    assert(ZSTD_cParam_withinBounds(ZSTD_c_compressionStrategy, strat));
+    assert(ZSTD_cParam_withinBounds(ZSTD_c_strategy, strat));
     selectedCompressor = blockCompressor[(int)dictMode][(int)strat];
     assert(selectedCompressor != NULL);
     return selectedCompressor;
index e98006809dee0d246996f0faaf7fcbd83911887d..58eb2ffe4db3e46babd58718cb6b296887843700 100644 (file)
@@ -188,6 +188,7 @@ static size_t ZSTD_ldm_fillFastTables(ZSTD_matchState_t* ms,
     case ZSTD_btlazy2:
     case ZSTD_btopt:
     case ZSTD_btultra:
+    case ZSTD_btultra2:
         break;
     default:
         assert(0);  /* not possible : not a valid strategy id */
index 101c66c7fedcc92933639b6c6acaec6d907a9cff..97902cd959a1213a68f1a570e2c6f1af05aae656 100644 (file)
@@ -1162,5 +1162,5 @@ size_t ZSTD_compressBlock_btultra_extDict(
 }
 
 /* note : no btultra2 variant for extDict nor dictMatchState,
- * tbecause btultra2 is not meant to work with dictionaries
+ * because btultra2 is not meant to work with dictionaries
  * and is only specific for the first block (no prefix) */
index eeadb604c6a80fd2ba29b3c8796aedb25f05fa3e..094f7476650e7971c27f7c3fcf77b08ff18aa947 100644 (file)
@@ -26,6 +26,10 @@ size_t ZSTD_compressBlock_btopt(
 size_t ZSTD_compressBlock_btultra(
         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
         void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btultra2(
+        ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+        void const* src, size_t srcSize);
+
 
 size_t ZSTD_compressBlock_btopt_dictMatchState(
         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
@@ -41,6 +45,10 @@ size_t ZSTD_compressBlock_btultra_extDict(
         ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
         void const* src, size_t srcSize);
 
+        /* note : no btultra2 variant for extDict nor dictMatchState,
+         * because btultra2 is not meant to work with dictionaries
+         * and is only specific for the first block (no prefix) */
+
 #if defined (__cplusplus)
 }
 #endif
index 03e4b4d2838cffe2f9527dd9e85aa98650b2f555..af13d8d9e1f97afb05d96f068c0111d08ee2f152 100644 (file)
@@ -496,9 +496,8 @@ typedef enum { ZSTD_fast=1,
                ZSTD_btopt=7,
                ZSTD_btultra=8,
                ZSTD_btultra2=9
-               /* note : new strategies might be added in the future.
-                         Only the order (from fast to strong) is guaranteed, not the exact position.
-                         new strategy names might be introduced, pushing the maximum number upward */
+               /* note : new strategies _might_ be added in the future.
+                         Only the order (from fast to strong) is guaranteed */
 } ZSTD_strategy;
 
 
@@ -549,7 +548,7 @@ typedef enum {
                               *     Distance between match sampling.
                               *     Larger values make compression faster, and weaker.
                               * Special: value 0 means "use default targetLength". */
-    ZSTD_c_compressionStrategy=107, /* See ZSTD_strategy enum definition.
+    ZSTD_c_strategy=107,     /* See ZSTD_strategy enum definition.
                               * The higher the value of selected strategy, the more complex it is,
                               * resulting in stronger and slower compression.
                               * Special: value 0 means "use default strategy". */
index af2fb6ad76999a4010477acea1b6f3da61c1cd5c..6d671fe8c2f1655c3f296d8f08f7124ba6b4d464 100644 (file)
@@ -178,7 +178,7 @@ static void BMK_initCCtx(ZSTD_CCtx* ctx,
     ZSTD_CCtx_setParameter(ctx, ZSTD_c_searchLog, comprParams->searchLog);
     ZSTD_CCtx_setParameter(ctx, ZSTD_c_minMatch, comprParams->minMatch);
     ZSTD_CCtx_setParameter(ctx, ZSTD_c_targetLength, comprParams->targetLength);
-    ZSTD_CCtx_setParameter(ctx, ZSTD_c_compressionStrategy, comprParams->strategy);
+    ZSTD_CCtx_setParameter(ctx, ZSTD_c_strategy, comprParams->strategy);
     ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize);
 }
 
index 07f08539ffc865362c2509ce3954aa6b234a7bca..cda5295b4b8fea9ec168ccfdda12e79a9a569873 100644 (file)
@@ -551,7 +551,7 @@ static cRess_t FIO_createCResources(const char* dictFileName, int cLevel,
         CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_searchLog, comprParams.searchLog) );
         CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_minMatch, comprParams.minMatch) );
         CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_targetLength, comprParams.targetLength) );
-        CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_compressionStrategy, comprParams.strategy) );
+        CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_c_strategy, comprParams.strategy) );
         /* multi-threading */
 #ifdef ZSTD_MULTITHREAD
         DISPLAYLEVEL(5,"set nb workers = %u \n", g_nbWorkers);
index 33a91d7083c90f5784c3ffff70a97ddf4813e002..8740a5c5b0318dd707d0af45c0ca8f9f91149339 100644 (file)
@@ -401,7 +401,7 @@ static size_t benchMem(U32 benchNb,
     ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_searchLog, cparams.searchLog);
     ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_minMatch, cparams.minMatch);
     ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_targetLength, cparams.targetLength);
-    ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_compressionStrategy, cparams.strategy);
+    ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_strategy, cparams.strategy);
 
 
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_compressionLevel, cLevel);
@@ -411,7 +411,7 @@ static size_t benchMem(U32 benchNb,
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_searchLog, cparams.searchLog);
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_minMatch, cparams.minMatch);
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_targetLength, cparams.targetLength);
-    ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_compressionStrategy, cparams.strategy);
+    ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_strategy, cparams.strategy);
 
     /* Preparation */
     switch(benchNb)
index 9c17b3dc57dc01c2863d80c22c4974b88f138cde..11f62debbc93b8c8051fec37ea85270e55ef27f3 100644 (file)
@@ -13,7 +13,7 @@
 #include "fuzz_helpers.h"
 #include "zstd.h"
 
-static void set(ZSTD_CCtx *cctx, ZSTD_cParameter param, unsigned value)
+static void set(ZSTD_CCtx *cctx, ZSTD_cParameter param, int value)
 {
     FUZZ_ZASSERT(ZSTD_CCtx_setParameter(cctx, param, value));
 }
@@ -35,7 +35,7 @@ ZSTD_compressionParameters FUZZ_randomCParams(size_t srcSize, uint32_t *state)
     cParams.minMatch = FUZZ_rand32(state, ZSTD_MINMATCH_MIN,
                                           ZSTD_MINMATCH_MAX);
     cParams.targetLength = FUZZ_rand32(state, 0, 512);
-    cParams.strategy = FUZZ_rand32(state, ZSTD_fast, ZSTD_btultra);
+    cParams.strategy = FUZZ_rand32(state, ZSTD_fast, ZSTD_btultra2);
     return ZSTD_adjustCParams(cParams, srcSize, 0);
 }
 
@@ -66,7 +66,7 @@ void FUZZ_setRandomParameters(ZSTD_CCtx *cctx, size_t srcSize, uint32_t *state)
     set(cctx, ZSTD_c_searchLog, cParams.searchLog);
     set(cctx, ZSTD_c_minMatch, cParams.minMatch);
     set(cctx, ZSTD_c_targetLength, cParams.targetLength);
-    set(cctx, ZSTD_c_compressionStrategy, cParams.strategy);
+    set(cctx, ZSTD_c_strategy, cParams.strategy);
     /* Select frame parameters */
     setRand(cctx, ZSTD_c_contentSizeFlag, 0, 1, state);
     setRand(cctx, ZSTD_c_checksumFlag, 0, 1, state);
index 21c2cfe69dec219c8652c5f613889700a4ff6942..18c244d19a7ee9703062cbb0e002e3faee2a12ad 100644 (file)
@@ -75,20 +75,21 @@ static const int g_maxNbVariations = 64;
 #define CLOG_RANGE (ZSTD_CHAINLOG_MAX - ZSTD_CHAINLOG_MIN + 1)
 #define HLOG_RANGE (ZSTD_HASHLOG_MAX - ZSTD_HASHLOG_MIN + 1)
 #define SLOG_RANGE (ZSTD_SEARCHLOG_MAX - ZSTD_SEARCHLOG_MIN + 1)
-#define MML_RANGE (ZSTD_MINMATCH_MAX - ZSTD_MINMATCH_MIN + 1)
-#define TLEN_RANGE 17
-#define STRT_RANGE (ZSTD_btultra - ZSTD_fast + 1)
-#define FADT_RANGE 3
+#define MML_RANGE  (ZSTD_MINMATCH_MAX - ZSTD_MINMATCH_MIN + 1)
+#define TLEN_RANGE  17
+#define STRT_RANGE (ZSTD_btultra2 - ZSTD_fast + 1)
+#define FADT_RANGE   3
 
 #define CHECKTIME(r) { if(BMK_timeSpan(g_time) > g_timeLimit_s) { DEBUGOUTPUT("Time Limit Reached\n"); return r; } }
 #define CHECKTIMEGT(ret, val, _gototag) {if(BMK_timeSpan(g_time) > g_timeLimit_s) { DEBUGOUTPUT("Time Limit Reached\n"); ret = val; goto _gototag; } }
 
 #define PARAM_UNSET ((U32)-2) /* can't be -1 b/c fadt uses -1 */
 
-static const char* g_stratName[ZSTD_btultra+1] = {
+static const char* g_stratName[ZSTD_btultra2+1] = {
                 "(none)       ", "ZSTD_fast    ", "ZSTD_dfast   ",
                 "ZSTD_greedy  ", "ZSTD_lazy    ", "ZSTD_lazy2   ",
-                "ZSTD_btlazy2 ", "ZSTD_btopt   ", "ZSTD_btultra "};
+                "ZSTD_btlazy2 ", "ZSTD_btopt   ", "ZSTD_btultra ",
+                "ZSTD_btultra2"};
 
 static const U32 tlen_table[TLEN_RANGE] = { 0, 1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 256, 512, 999 };
 
@@ -114,13 +115,13 @@ typedef struct {
     U32 vals[NUM_PARAMS];
 } paramValues_t;
 
-/* maximum value of parameters */
+/* minimum value of parameters */
 static const U32 mintable[NUM_PARAMS] =
         { ZSTD_WINDOWLOG_MIN, ZSTD_CHAINLOG_MIN, ZSTD_HASHLOG_MIN, ZSTD_SEARCHLOG_MIN, ZSTD_MINMATCH_MIN, ZSTD_TARGETLENGTH_MIN, ZSTD_fast, FADT_MIN };
 
-/* minimum value of parameters */
+/* maximum value of parameters */
 static const U32 maxtable[NUM_PARAMS] =
-        { ZSTD_WINDOWLOG_MAX, ZSTD_CHAINLOG_MAX, ZSTD_HASHLOG_MAX, ZSTD_SEARCHLOG_MAX, ZSTD_MINMATCH_MAX, ZSTD_TARGETLENGTH_MAX, ZSTD_btultra, FADT_MAX };
+        { ZSTD_WINDOWLOG_MAX, ZSTD_CHAINLOG_MAX, ZSTD_HASHLOG_MAX, ZSTD_SEARCHLOG_MAX, ZSTD_MINMATCH_MAX, ZSTD_TARGETLENGTH_MAX, ZSTD_btultra2, FADT_MAX };
 
 /* # of values parameters can take on */
 static const U32 rangetable[NUM_PARAMS] =
@@ -128,7 +129,7 @@ static const U32 rangetable[NUM_PARAMS] =
 
 /* ZSTD_cctxSetParameter() index to set */
 static const ZSTD_cParameter cctxSetParamTable[NUM_PARAMS] =
-        { ZSTD_c_windowLog, ZSTD_c_chainLog, ZSTD_c_hashLog, ZSTD_c_searchLog, ZSTD_c_minMatch, ZSTD_c_targetLength, ZSTD_c_compressionStrategy, ZSTD_c_forceAttachDict };
+        { ZSTD_c_windowLog, ZSTD_c_chainLog, ZSTD_c_hashLog, ZSTD_c_searchLog, ZSTD_c_minMatch, ZSTD_c_targetLength, ZSTD_c_strategy, ZSTD_c_forceAttachDict };
 
 /* names of parameters */
 static const char* g_paramNames[NUM_PARAMS] =
@@ -298,7 +299,7 @@ static paramValues_t sanitizeParams(paramValues_t params)
         params.vals[clog_ind] = 0, params.vals[slog_ind] = 0;
     if (params.vals[strt_ind] == ZSTD_dfast)
         params.vals[slog_ind] = 0;
-    if (params.vals[strt_ind] != ZSTD_btopt && params.vals[strt_ind] != ZSTD_btultra && params.vals[strt_ind] != ZSTD_fast)
+    if ( (params.vals[strt_ind] < ZSTD_btopt) && (params.vals[strt_ind] != ZSTD_fast) )
         params.vals[tlen_ind] = 0;
 
     return params;
@@ -1218,7 +1219,7 @@ static size_t sanitizeVarArray(varInds_t* varNew, const size_t varLength, const
         if( !((varArray[i] == clog_ind && strat == ZSTD_fast)
             || (varArray[i] == slog_ind && strat == ZSTD_fast)
             || (varArray[i] == slog_ind && strat == ZSTD_dfast)
-            || (varArray[i] == tlen_ind && strat != ZSTD_btopt && strat != ZSTD_btultra && strat != ZSTD_fast))) {
+            || (varArray[i] == tlen_ind && strat < ZSTD_btopt && strat != ZSTD_fast))) {
             varNew[j] = varArray[i];
             j++;
         }
@@ -1290,10 +1291,12 @@ static void memoTableSet(const memoTable_t* memoTableArray, const paramValues_t
 }
 
 /* frees all allocated memotables */
+/* secret contract :
+ * mtAll is a table of (ZSTD_btultra2+1) memoTable_t */
 static void freeMemoTableArray(memoTable_t* const mtAll) {
     int i;
     if(mtAll == NULL) { return; }
-    for(i = 1; i <= (int)ZSTD_btultra; i++) {
+    for(i = 1; i <= (int)ZSTD_btultra2; i++) {
         free(mtAll[i].table);
     }
     free(mtAll);
@@ -1301,21 +1304,26 @@ static void freeMemoTableArray(memoTable_t* const mtAll) {
 
 /* inits memotables for all (including mallocs), all strategies */
 /* takes unsanitized varyParams */
-static memoTable_t* createMemoTableArray(const paramValues_t p, const varInds_t* const varyParams, const size_t varyLen, const U32 memoTableLog) {
-    memoTable_t* mtAll = (memoTable_t*)calloc(sizeof(memoTable_t),(ZSTD_btultra + 1));
-    ZSTD_strategy i, stratMin = ZSTD_fast, stratMax = ZSTD_btultra;
+static memoTable_t*
+createMemoTableArray(const paramValues_t p,
+                     const varInds_t* const varyParams,
+                     const size_t varyLen,
+                     const U32 memoTableLog)
+{
+    memoTable_t* const mtAll = (memoTable_t*)calloc(sizeof(memoTable_t),(ZSTD_btultra2 + 1));
+    ZSTD_strategy i, stratMin = ZSTD_fast, stratMax = ZSTD_btultra2;
 
     if(mtAll == NULL) {
         return NULL;
     }
 
-    for(i = 1; i <= (int)ZSTD_btultra; i++) {
+    for(i = 1; i <= (int)ZSTD_btultra2; i++) {
         mtAll[i].varLen = sanitizeVarArray(mtAll[i].varArray, varyLen, varyParams, i);
     }
 
     /* no memoization */
     if(memoTableLog == 0) {
-        for(i = 1; i <= (int)ZSTD_btultra; i++) {
+        for(i = 1; i <= (int)ZSTD_btultra2; i++) {
             mtAll[i].tableType = noMemo;
             mtAll[i].table = NULL;
             mtAll[i].tableLen = 0;
@@ -1661,7 +1669,7 @@ static void BMK_init_level_constraints(int bytePerSec_level1)
             g_level_constraint[l].cSpeed_min = (g_level_constraint[l-1].cSpeed_min * 49) / 64;
             g_level_constraint[l].dSpeed_min = 0.;
             g_level_constraint[l].windowLog_max = (l<20) ? 23 : l+5;   /* only --ultra levels >= 20 can use windowlog > 23 */
-            g_level_constraint[l].strategy_max = (l<19) ? ZSTD_btopt : ZSTD_btultra;   /* level 19 is allowed to use btultra */
+            g_level_constraint[l].strategy_max = ZSTD_btultra2;   /* level 19 is allowed to use btultra */
     }   }
 }
 
@@ -2134,7 +2142,7 @@ static int nextStrategy(const int currentStrategy, const int bestStrategy) {
         int candidate = 2 * bestStrategy - currentStrategy - 1;
         if(candidate < 1) {
             candidate = currentStrategy + 1;
-            if(candidate > (int)ZSTD_btultra) {
+            if(candidate > (int)ZSTD_btultra2) {
                 return 0;
             } else {
                 return candidate;
@@ -2144,7 +2152,7 @@ static int nextStrategy(const int currentStrategy, const int bestStrategy) {
         }
     } else { /* bestStrategy >= currentStrategy */
         int candidate = 2 * bestStrategy - currentStrategy;
-        if(candidate > (int)ZSTD_btultra) {
+        if(candidate > (int)ZSTD_btultra2) {
             candidate = currentStrategy - 1;
             if(candidate < 1) {
                 return 0;
index d148b17cf52f89d24bb1c1e136a4dc54f8d9299b..4ff1d3531cc2a3bf15acfb732a887816c85f6288 100644 (file)
@@ -230,7 +230,7 @@ static size_t getCCtxParams(ZSTD_CCtx* zc, ZSTD_parameters* savedParams)
     CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_searchLog, (int*)&savedParams->cParams.searchLog));
     CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_minMatch, (int*)&savedParams->cParams.minMatch));
     CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_targetLength, (int*)&savedParams->cParams.targetLength));
-    CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_compressionStrategy, &value));
+    CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_strategy, &value));
     savedParams->cParams.strategy = value;
 
     CHECK_RET_Z(ZSTD_CCtx_getParameter(zc, ZSTD_c_checksumFlag, &savedParams->fParams.checksumFlag));