Added multiplier, renamed new enum to something more useful
This commit is contained in:
parent
1f3a51fb52
commit
676f89902a
@ -387,7 +387,7 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
|
|||||||
case ZSTD_c_forceAttachDict:
|
case ZSTD_c_forceAttachDict:
|
||||||
ZSTD_STATIC_ASSERT(ZSTD_dictDefaultAttach < ZSTD_dictForceCopy);
|
ZSTD_STATIC_ASSERT(ZSTD_dictDefaultAttach < ZSTD_dictForceCopy);
|
||||||
bounds.lowerBound = ZSTD_dictDefaultAttach;
|
bounds.lowerBound = ZSTD_dictDefaultAttach;
|
||||||
bounds.upperBound = ZSTD_dictForceSource; /* note : how to ensure at compile time that this is the highest value enum ? */
|
bounds.upperBound = ZSTD_dictForceLoad; /* note : how to ensure at compile time that this is the highest value enum ? */
|
||||||
return bounds;
|
return bounds;
|
||||||
|
|
||||||
case ZSTD_c_literalCompressionMode:
|
case ZSTD_c_literalCompressionMode:
|
||||||
@ -2890,7 +2890,8 @@ ZSTD_compress_insertDictionary(ZSTD_compressedBlockState_t* bs,
|
|||||||
bs, ms, ws, params, dict, dictSize, dtlm, workspace);
|
bs, ms, ws, params, dict, dictSize, dtlm, workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ZSTD_USE_CDICT_PARAMS_CUTOFF (1 MB)
|
#define ZSTD_USE_CDICT_PARAMS_SRCSIZE_CUTOFF (128 KB)
|
||||||
|
#define ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER (6)
|
||||||
|
|
||||||
/*! ZSTD_compressBegin_internal() :
|
/*! ZSTD_compressBegin_internal() :
|
||||||
* @return : 0, or an error code */
|
* @return : 0, or an error code */
|
||||||
@ -2908,8 +2909,10 @@ static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx,
|
|||||||
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
||||||
if ( (cdict)
|
if ( (cdict)
|
||||||
&& (cdict->dictContentSize > 0)
|
&& (cdict->dictContentSize > 0)
|
||||||
&& (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_CUTOFF || cdict->compressionLevel == 0)
|
&& ( (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_SRCSIZE_CUTOFF
|
||||||
&& (params->attachDictPref != ZSTD_dictForceSource) ) {
|
|| pledgedSrcSize < cdict->dictContentSize * ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER)
|
||||||
|
|| cdict->compressionLevel == 0)
|
||||||
|
&& (params->attachDictPref != ZSTD_dictForceLoad) ) {
|
||||||
return ZSTD_resetCCtx_usingCDict(cctx, cdict, params, pledgedSrcSize, zbuff);
|
return ZSTD_resetCCtx_usingCDict(cctx, cdict, params, pledgedSrcSize, zbuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3357,8 +3360,10 @@ size_t ZSTD_compressBegin_usingCDict_advanced(
|
|||||||
DEBUGLOG(4, "ZSTD_compressBegin_usingCDict_advanced");
|
DEBUGLOG(4, "ZSTD_compressBegin_usingCDict_advanced");
|
||||||
RETURN_ERROR_IF(cdict==NULL, dictionary_wrong);
|
RETURN_ERROR_IF(cdict==NULL, dictionary_wrong);
|
||||||
{ ZSTD_CCtx_params params = cctx->requestedParams;
|
{ ZSTD_CCtx_params params = cctx->requestedParams;
|
||||||
params.cParams = ( (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_CUTOFF) || (cdict->compressionLevel == 0) )
|
params.cParams = ( (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_SRCSIZE_CUTOFF
|
||||||
&& (params.attachDictPref != ZSTD_dictForceSource) ?
|
|| pledgedSrcSize < cdict->dictContentSize * ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER)
|
||||||
|
|| (cdict->compressionLevel == 0) )
|
||||||
|
&& (params.attachDictPref != ZSTD_dictForceLoad) ?
|
||||||
ZSTD_getCParamsFromCDict(cdict)
|
ZSTD_getCParamsFromCDict(cdict)
|
||||||
: ZSTD_getCParams(cdict->compressionLevel,
|
: ZSTD_getCParams(cdict->compressionLevel,
|
||||||
pledgedSrcSize,
|
pledgedSrcSize,
|
||||||
|
@ -1166,8 +1166,10 @@ typedef enum {
|
|||||||
* faster than copying the CDict's tables.
|
* faster than copying the CDict's tables.
|
||||||
*
|
*
|
||||||
* - The CDict's tables are not used at all, and instead we use the working
|
* - The CDict's tables are not used at all, and instead we use the working
|
||||||
* context alone to determine how our tables are initialized. This method
|
* context alone to reload the dictionary and use params based on the source
|
||||||
* should be used when using a small dictionary to compress a large input.
|
* size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict().
|
||||||
|
* This method is effective when the dictionary sizes are very small relative
|
||||||
|
* to the input size, and the input size is fairly large to begin with.
|
||||||
*
|
*
|
||||||
* Zstd has a simple internal heuristic that selects which strategy to use
|
* Zstd has a simple internal heuristic that selects which strategy to use
|
||||||
* at the beginning of a compression. However, if experimentation shows that
|
* at the beginning of a compression. However, if experimentation shows that
|
||||||
@ -1177,7 +1179,7 @@ typedef enum {
|
|||||||
ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
|
ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
|
||||||
ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */
|
ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */
|
||||||
ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */
|
ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */
|
||||||
ZSTD_dictForceSource = 3, /* Always use src input to determine tables */
|
ZSTD_dictForceLoad = 3, /* Always reload the dictionary */
|
||||||
} ZSTD_dictAttachPref_e;
|
} ZSTD_dictAttachPref_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user