[libzstd] Allow compression parameters to be set with a cdict

The order you set parameters in the advanced API is not supposed to matter.
However, once you call `ZSTD_CCtx_refCDict()` the compression parameters
cannot be changed. Remove that restriction, and document what parameters
are used when using a CDict.

If the CCtx is in dictionary mode, then the CDict's parameters are used.
If the CCtx is not in dictionary mode, then its requested parameters are
used.
This commit is contained in:
Nick Terrell
2019-03-13 16:10:05 -07:00
parent ea3b81f02c
commit 787b76904a
3 changed files with 22 additions and 18 deletions
+4 -16
View File
@@ -450,11 +450,12 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
switch(param)
{
case ZSTD_c_compressionLevel:
RETURN_ERROR_IF(cctx->cdict, stage_wrong,
"compression level is configured in cdict");
case ZSTD_c_nbWorkers:
RETURN_ERROR_IF((value!=0) && cctx->staticSize, parameter_unsupported,
"MT not compatible with static alloc");
break;
case ZSTD_c_compressionLevel:
case ZSTD_c_windowLog:
case ZSTD_c_hashLog:
case ZSTD_c_chainLog:
@@ -462,20 +463,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
case ZSTD_c_minMatch:
case ZSTD_c_targetLength:
case ZSTD_c_strategy:
RETURN_ERROR_IF(cctx->cdict, stage_wrong,
"cparams are configured in cdict");
break;
case ZSTD_c_nbWorkers:
RETURN_ERROR_IF((value!=0) && cctx->staticSize, parameter_unsupported,
"MT not compatible with static alloc");
break;
case ZSTD_c_ldmHashRateLog:
RETURN_ERROR_IF(cctx->cdict, stage_wrong,
"LDM hash rate log is configured in cdict");
break;
case ZSTD_c_format:
case ZSTD_c_contentSizeFlag:
case ZSTD_c_checksumFlag: