introduced constants ZSTD_STRATEGY_MIN and ZSTD_STRATEGY_MAX
This commit is contained in:
@@ -268,8 +268,8 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
|
|||||||
return bounds;
|
return bounds;
|
||||||
|
|
||||||
case ZSTD_c_strategy:
|
case ZSTD_c_strategy:
|
||||||
bounds.lowerBound = (int)ZSTD_fast;
|
bounds.lowerBound = (int)ZSTD_STRATEGY_MIN;
|
||||||
bounds.upperBound = (int)ZSTD_btultra2; /* note : how to ensure at compile time that this is the highest value strategy ? */
|
bounds.upperBound = (int)ZSTD_STRATEGY_MAX; /* note : how to ensure at compile time that this is the highest value strategy ? */
|
||||||
return bounds;
|
return bounds;
|
||||||
|
|
||||||
case ZSTD_c_contentSizeFlag:
|
case ZSTD_c_contentSizeFlag:
|
||||||
@@ -1474,7 +1474,7 @@ void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) {
|
|||||||
* dictionary tables into the working context is faster than using them
|
* dictionary tables into the working context is faster than using them
|
||||||
* in-place.
|
* in-place.
|
||||||
*/
|
*/
|
||||||
static const size_t attachDictSizeCutoffs[(unsigned)ZSTD_btultra2+1] = {
|
static const size_t attachDictSizeCutoffs[ZSTD_STRATEGY_MAX+1] = {
|
||||||
8 KB, /* unused */
|
8 KB, /* unused */
|
||||||
8 KB, /* ZSTD_fast */
|
8 KB, /* ZSTD_fast */
|
||||||
16 KB, /* ZSTD_dfast */
|
16 KB, /* ZSTD_dfast */
|
||||||
@@ -2546,7 +2546,7 @@ ZSTD_compressSequences(seqStore_t* seqStorePtr,
|
|||||||
* assumption : strat is a valid strategy */
|
* assumption : strat is a valid strategy */
|
||||||
ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMode_e dictMode)
|
ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMode_e dictMode)
|
||||||
{
|
{
|
||||||
static const ZSTD_blockCompressor blockCompressor[3][(unsigned)ZSTD_btultra2+1] = {
|
static const ZSTD_blockCompressor blockCompressor[3][ZSTD_STRATEGY_MAX+1] = {
|
||||||
{ ZSTD_compressBlock_fast /* default for 0 */,
|
{ ZSTD_compressBlock_fast /* default for 0 */,
|
||||||
ZSTD_compressBlock_fast,
|
ZSTD_compressBlock_fast,
|
||||||
ZSTD_compressBlock_doubleFast,
|
ZSTD_compressBlock_doubleFast,
|
||||||
|
|||||||
@@ -940,6 +940,9 @@ ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset);
|
|||||||
#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */
|
#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */
|
||||||
#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
|
#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
|
||||||
#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
|
#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
|
||||||
|
#define ZSTD_STRATEGY_MIN ZSTD_fast
|
||||||
|
#define ZSTD_STRATEGY_MAX ZSTD_btultra2
|
||||||
|
|
||||||
|
|
||||||
#define ZSTD_OVERLAPLOG_MIN 0
|
#define ZSTD_OVERLAPLOG_MIN 0
|
||||||
#define ZSTD_OVERLAPLOG_MAX 9
|
#define ZSTD_OVERLAPLOG_MAX 9
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ ZSTD_compressionParameters FUZZ_randomCParams(size_t srcSize, uint32_t *state)
|
|||||||
cParams.minMatch = FUZZ_rand32(state, ZSTD_MINMATCH_MIN,
|
cParams.minMatch = FUZZ_rand32(state, ZSTD_MINMATCH_MIN,
|
||||||
ZSTD_MINMATCH_MAX);
|
ZSTD_MINMATCH_MAX);
|
||||||
cParams.targetLength = FUZZ_rand32(state, 0, 512);
|
cParams.targetLength = FUZZ_rand32(state, 0, 512);
|
||||||
cParams.strategy = FUZZ_rand32(state, ZSTD_fast, ZSTD_btultra2);
|
cParams.strategy = FUZZ_rand32(state, ZSTD_STRATEGY_MIN, ZSTD_STRATEGY_MAX);
|
||||||
return ZSTD_adjustCParams(cParams, srcSize, 0);
|
return ZSTD_adjustCParams(cParams, srcSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -77,7 +77,7 @@ static const int g_maxNbVariations = 64;
|
|||||||
#define SLOG_RANGE (ZSTD_SEARCHLOG_MAX - ZSTD_SEARCHLOG_MIN + 1)
|
#define SLOG_RANGE (ZSTD_SEARCHLOG_MAX - ZSTD_SEARCHLOG_MIN + 1)
|
||||||
#define MML_RANGE (ZSTD_MINMATCH_MAX - ZSTD_MINMATCH_MIN + 1)
|
#define MML_RANGE (ZSTD_MINMATCH_MAX - ZSTD_MINMATCH_MIN + 1)
|
||||||
#define TLEN_RANGE 17
|
#define TLEN_RANGE 17
|
||||||
#define STRT_RANGE (ZSTD_btultra2 - ZSTD_fast + 1)
|
#define STRT_RANGE (ZSTD_STRATEGY_MAX - ZSTD_STRATEGY_MIN + 1)
|
||||||
#define FADT_RANGE 3
|
#define FADT_RANGE 3
|
||||||
|
|
||||||
#define CHECKTIME(r) { if(BMK_timeSpan(g_time) > g_timeLimit_s) { DEBUGOUTPUT("Time Limit Reached\n"); return r; } }
|
#define CHECKTIME(r) { if(BMK_timeSpan(g_time) > g_timeLimit_s) { DEBUGOUTPUT("Time Limit Reached\n"); return r; } }
|
||||||
@@ -85,7 +85,7 @@ static const int g_maxNbVariations = 64;
|
|||||||
|
|
||||||
#define PARAM_UNSET ((U32)-2) /* can't be -1 b/c fadt uses -1 */
|
#define PARAM_UNSET ((U32)-2) /* can't be -1 b/c fadt uses -1 */
|
||||||
|
|
||||||
static const char* g_stratName[ZSTD_btultra2+1] = {
|
static const char* g_stratName[ZSTD_STRATEGY_MAX+1] = {
|
||||||
"(none) ", "ZSTD_fast ", "ZSTD_dfast ",
|
"(none) ", "ZSTD_fast ", "ZSTD_dfast ",
|
||||||
"ZSTD_greedy ", "ZSTD_lazy ", "ZSTD_lazy2 ",
|
"ZSTD_greedy ", "ZSTD_lazy ", "ZSTD_lazy2 ",
|
||||||
"ZSTD_btlazy2 ", "ZSTD_btopt ", "ZSTD_btultra ",
|
"ZSTD_btlazy2 ", "ZSTD_btopt ", "ZSTD_btultra ",
|
||||||
@@ -117,11 +117,11 @@ typedef struct {
|
|||||||
|
|
||||||
/* minimum value of parameters */
|
/* minimum value of parameters */
|
||||||
static const U32 mintable[NUM_PARAMS] =
|
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 };
|
{ ZSTD_WINDOWLOG_MIN, ZSTD_CHAINLOG_MIN, ZSTD_HASHLOG_MIN, ZSTD_SEARCHLOG_MIN, ZSTD_MINMATCH_MIN, ZSTD_TARGETLENGTH_MIN, ZSTD_STRATEGY_MIN, FADT_MIN };
|
||||||
|
|
||||||
/* maximum value of parameters */
|
/* maximum value of parameters */
|
||||||
static const U32 maxtable[NUM_PARAMS] =
|
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_btultra2, FADT_MAX };
|
{ ZSTD_WINDOWLOG_MAX, ZSTD_CHAINLOG_MAX, ZSTD_HASHLOG_MAX, ZSTD_SEARCHLOG_MAX, ZSTD_MINMATCH_MAX, ZSTD_TARGETLENGTH_MAX, ZSTD_STRATEGY_MAX, FADT_MAX };
|
||||||
|
|
||||||
/* # of values parameters can take on */
|
/* # of values parameters can take on */
|
||||||
static const U32 rangetable[NUM_PARAMS] =
|
static const U32 rangetable[NUM_PARAMS] =
|
||||||
@@ -1292,11 +1292,11 @@ static void memoTableSet(const memoTable_t* memoTableArray, const paramValues_t
|
|||||||
|
|
||||||
/* frees all allocated memotables */
|
/* frees all allocated memotables */
|
||||||
/* secret contract :
|
/* secret contract :
|
||||||
* mtAll is a table of (ZSTD_btultra2+1) memoTable_t */
|
* mtAll is a table of (ZSTD_STRATEGY_MAX+1) memoTable_t */
|
||||||
static void freeMemoTableArray(memoTable_t* const mtAll) {
|
static void freeMemoTableArray(memoTable_t* const mtAll) {
|
||||||
int i;
|
int i;
|
||||||
if(mtAll == NULL) { return; }
|
if(mtAll == NULL) { return; }
|
||||||
for(i = 1; i <= (int)ZSTD_btultra2; i++) {
|
for(i = 1; i <= (int)ZSTD_STRATEGY_MAX; i++) {
|
||||||
free(mtAll[i].table);
|
free(mtAll[i].table);
|
||||||
}
|
}
|
||||||
free(mtAll);
|
free(mtAll);
|
||||||
@@ -1310,20 +1310,20 @@ createMemoTableArray(const paramValues_t p,
|
|||||||
const size_t varyLen,
|
const size_t varyLen,
|
||||||
const U32 memoTableLog)
|
const U32 memoTableLog)
|
||||||
{
|
{
|
||||||
memoTable_t* const mtAll = (memoTable_t*)calloc(sizeof(memoTable_t),(ZSTD_btultra2 + 1));
|
memoTable_t* const mtAll = (memoTable_t*)calloc(sizeof(memoTable_t),(ZSTD_STRATEGY_MAX + 1));
|
||||||
ZSTD_strategy i, stratMin = ZSTD_fast, stratMax = ZSTD_btultra2;
|
ZSTD_strategy i, stratMin = ZSTD_STRATEGY_MIN, stratMax = ZSTD_STRATEGY_MAX;
|
||||||
|
|
||||||
if(mtAll == NULL) {
|
if(mtAll == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 1; i <= (int)ZSTD_btultra2; i++) {
|
for(i = 1; i <= (int)ZSTD_STRATEGY_MAX; i++) {
|
||||||
mtAll[i].varLen = sanitizeVarArray(mtAll[i].varArray, varyLen, varyParams, i);
|
mtAll[i].varLen = sanitizeVarArray(mtAll[i].varArray, varyLen, varyParams, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no memoization */
|
/* no memoization */
|
||||||
if(memoTableLog == 0) {
|
if(memoTableLog == 0) {
|
||||||
for(i = 1; i <= (int)ZSTD_btultra2; i++) {
|
for(i = 1; i <= (int)ZSTD_STRATEGY_MAX; i++) {
|
||||||
mtAll[i].tableType = noMemo;
|
mtAll[i].tableType = noMemo;
|
||||||
mtAll[i].table = NULL;
|
mtAll[i].table = NULL;
|
||||||
mtAll[i].tableLen = 0;
|
mtAll[i].tableLen = 0;
|
||||||
@@ -1669,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].cSpeed_min = (g_level_constraint[l-1].cSpeed_min * 49) / 64;
|
||||||
g_level_constraint[l].dSpeed_min = 0.;
|
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].windowLog_max = (l<20) ? 23 : l+5; /* only --ultra levels >= 20 can use windowlog > 23 */
|
||||||
g_level_constraint[l].strategy_max = ZSTD_btultra2; /* level 19 is allowed to use btultra */
|
g_level_constraint[l].strategy_max = ZSTD_STRATEGY_MAX;
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2142,7 +2142,7 @@ static int nextStrategy(const int currentStrategy, const int bestStrategy) {
|
|||||||
int candidate = 2 * bestStrategy - currentStrategy - 1;
|
int candidate = 2 * bestStrategy - currentStrategy - 1;
|
||||||
if(candidate < 1) {
|
if(candidate < 1) {
|
||||||
candidate = currentStrategy + 1;
|
candidate = currentStrategy + 1;
|
||||||
if(candidate > (int)ZSTD_btultra2) {
|
if(candidate > (int)ZSTD_STRATEGY_MAX) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return candidate;
|
return candidate;
|
||||||
@@ -2152,7 +2152,7 @@ static int nextStrategy(const int currentStrategy, const int bestStrategy) {
|
|||||||
}
|
}
|
||||||
} else { /* bestStrategy >= currentStrategy */
|
} else { /* bestStrategy >= currentStrategy */
|
||||||
int candidate = 2 * bestStrategy - currentStrategy;
|
int candidate = 2 * bestStrategy - currentStrategy;
|
||||||
if(candidate > (int)ZSTD_btultra2) {
|
if(candidate > (int)ZSTD_STRATEGY_MAX) {
|
||||||
candidate = currentStrategy - 1;
|
candidate = currentStrategy - 1;
|
||||||
if(candidate < 1) {
|
if(candidate < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user