Comment out CCtx_param versions of CDict functions
This commit is contained in:
@@ -360,11 +360,6 @@ size_t ZSTD_initCStream_internal_opaque(
|
||||
ZSTD_CCtx_params params,
|
||||
unsigned long long pledgedSrcSize);
|
||||
|
||||
/* INTERNAL */
|
||||
ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
ZSTD_CCtx_params params, ZSTD_customMem customMem);
|
||||
|
||||
/*! ZSTD_compressStream_generic() :
|
||||
* Private use only. To be called from zstdmt_compress.c in single-thread mode. */
|
||||
size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
||||
|
||||
@@ -3611,7 +3611,7 @@ size_t ZSTD_compress(void* dst, size_t dstCapacity, const void* src, size_t srcS
|
||||
|
||||
|
||||
/* ===== Dictionary API ===== */
|
||||
|
||||
#if 0
|
||||
size_t ZSTD_estimateCDictSize_advanced_opaque(
|
||||
size_t dictSize, const ZSTD_CCtx_params* params)
|
||||
{
|
||||
@@ -3623,14 +3623,17 @@ size_t ZSTD_estimateCDictSize_advanced_opaque(
|
||||
+ (params->dictContentByRef ? 0 : dictSize);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! ZSTD_estimateCDictSize_advanced() :
|
||||
* Estimate amount of memory that will be needed to create a dictionary with following arguments */
|
||||
size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, unsigned byReference)
|
||||
{
|
||||
ZSTD_CCtx_params params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
||||
params.dictContentByRef = byReference;
|
||||
return ZSTD_estimateCDictSize_advanced_opaque(dictSize, ¶ms);
|
||||
DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (U32)sizeof(ZSTD_CDict));
|
||||
DEBUGLOG(5, "CCtx estimate : %u",
|
||||
(U32)ZSTD_estimateCCtxSize_advanced(cParams));
|
||||
return sizeof(ZSTD_CDict) + ZSTD_estimateCCtxSize_advanced(cParams)
|
||||
+ (byReference ? 0 : dictSize);
|
||||
}
|
||||
|
||||
size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel)
|
||||
@@ -3657,6 +3660,7 @@ static ZSTD_parameters ZSTD_makeParams(ZSTD_compressionParameters cParams, ZSTD_
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static size_t ZSTD_initCDict_internal_opaque(ZSTD_CDict* cdict,
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
ZSTD_CCtx_params params)
|
||||
@@ -3683,27 +3687,44 @@ static size_t ZSTD_initCDict_internal_opaque(ZSTD_CDict* cdict,
|
||||
ZSTDb_not_buffered) );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static size_t ZSTD_initCDict_internal(
|
||||
ZSTD_CDict* cdict,
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
unsigned byReference, ZSTD_dictMode_e dictMode,
|
||||
ZSTD_compressionParameters cParams)
|
||||
{
|
||||
ZSTD_CCtx_params cctxParams = cdict->refContext->requestedParams;
|
||||
ZSTD_frameParameters const fParams = { 0 /* contentSizeFlag */,
|
||||
DEBUGLOG(5, "ZSTD_initCDict_internal, mode %u", (U32)dictMode);
|
||||
if ((byReference) || (!dictBuffer) || (!dictSize)) {
|
||||
cdict->dictBuffer = NULL;
|
||||
cdict->dictContent = dictBuffer;
|
||||
} else {
|
||||
void* const internalBuffer = ZSTD_malloc(dictSize, cdict->refContext->customMem);
|
||||
cdict->dictBuffer = internalBuffer;
|
||||
cdict->dictContent = internalBuffer;
|
||||
if (!internalBuffer) return ERROR(memory_allocation);
|
||||
memcpy(internalBuffer, dictBuffer, dictSize);
|
||||
}
|
||||
cdict->dictContentSize = dictSize;
|
||||
|
||||
{ ZSTD_frameParameters const fParams = { 0 /*contentSizeFlag */,
|
||||
0 /* checksumFlag */, 0 /* noDictIDFlag */ }; /* dummy */
|
||||
cctxParams.cParams = cParams;
|
||||
cctxParams.fParams = fParams;
|
||||
cctxParams.dictMode = dictMode;
|
||||
cctxParams.dictContentByRef = byReference;
|
||||
CHECK_F (ZSTD_initCDict_internal_opaque(
|
||||
cdict, dictBuffer, dictSize, cctxParams) );
|
||||
ZSTD_CCtx_params cctxParams = cdict->refContext->requestedParams;
|
||||
cctxParams.fParams = fParams;
|
||||
cctxParams.cParams = cParams;
|
||||
cctxParams.dictContentByRef = byReference;
|
||||
cctxParams.dictMode = dictMode;
|
||||
CHECK_F( ZSTD_compressBegin_internal(cdict->refContext,
|
||||
cdict->dictContent, dictSize,
|
||||
NULL,
|
||||
cctxParams, ZSTD_CONTENTSIZE_UNKNOWN,
|
||||
ZSTDb_not_buffered) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Internal only */
|
||||
ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
@@ -3730,15 +3751,33 @@ ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
||||
return cdict;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize,
|
||||
unsigned byReference, ZSTD_dictMode_e dictMode,
|
||||
ZSTD_compressionParameters cParams, ZSTD_customMem customMem)
|
||||
{
|
||||
ZSTD_CCtx_params cctxParams = ZSTD_makeCCtxParamsFromCParams(cParams);
|
||||
cctxParams.dictMode = dictMode;
|
||||
cctxParams.dictContentByRef = byReference;
|
||||
return ZSTD_createCDict_advanced_opaque(dictBuffer, dictSize, cctxParams, customMem);
|
||||
DEBUGLOG(5, "ZSTD_createCDict_advanced, mode %u", dictMode);
|
||||
if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
|
||||
|
||||
{ ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
|
||||
ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(customMem);
|
||||
if (!cdict || !cctx) {
|
||||
ZSTD_free(cdict, customMem);
|
||||
ZSTD_freeCCtx(cctx);
|
||||
return NULL;
|
||||
}
|
||||
cdict->refContext = cctx;
|
||||
if (ZSTD_isError( ZSTD_initCDict_internal(
|
||||
cdict,
|
||||
dictBuffer, dictSize,
|
||||
byReference, dictMode,
|
||||
cParams) )) {
|
||||
ZSTD_freeCDict(cdict);
|
||||
return NULL;
|
||||
}
|
||||
return cdict;
|
||||
}
|
||||
}
|
||||
|
||||
ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionLevel)
|
||||
@@ -3768,6 +3807,7 @@ size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
ZSTD_CDict* ZSTD_initStaticCDict_advanced_opaque(
|
||||
void *workspace, size_t workspaceSize, const void* dict,
|
||||
size_t dictSize,
|
||||
@@ -3804,6 +3844,7 @@ ZSTD_CDict* ZSTD_initStaticCDict_advanced_opaque(
|
||||
return cdict;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! ZSTD_initStaticCDict_advanced() :
|
||||
* Generate a digested dictionary in provided memory area.
|
||||
@@ -3823,13 +3864,35 @@ ZSTD_CDict* ZSTD_initStaticCDict(void* workspace, size_t workspaceSize,
|
||||
unsigned byReference, ZSTD_dictMode_e dictMode,
|
||||
ZSTD_compressionParameters cParams)
|
||||
{
|
||||
ZSTD_CCtx_params params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
||||
params.dictMode = dictMode;
|
||||
params.dictContentByRef = byReference;
|
||||
return ZSTD_initStaticCDict_advanced_opaque(
|
||||
workspace, workspaceSize, dict, dictSize,
|
||||
¶ms);
|
||||
size_t const cctxSize = ZSTD_estimateCCtxSize_advanced(cParams);
|
||||
size_t const neededSize = sizeof(ZSTD_CDict)
|
||||
+ (byReference ? 0 : dictSize)
|
||||
+ cctxSize;
|
||||
ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
|
||||
void* ptr;
|
||||
DEBUGLOG(5, "(size_t)workspace & 7 : %u", (U32)(size_t)workspace & 7);
|
||||
if ((size_t)workspace & 7) return NULL; /* 8-aligned */
|
||||
DEBUGLOG(5, "(workspaceSize < neededSize) : (%u < %u) => %u",
|
||||
(U32)workspaceSize, (U32)neededSize, (U32)(workspaceSize < neededSize));
|
||||
if (workspaceSize < neededSize) return NULL;
|
||||
|
||||
if (!byReference) {
|
||||
memcpy(cdict+1, dict, dictSize);
|
||||
dict = cdict+1;
|
||||
ptr = (char*)workspace + sizeof(ZSTD_CDict) + dictSize;
|
||||
} else {
|
||||
ptr = cdict+1;
|
||||
}
|
||||
cdict->refContext = ZSTD_initStaticCCtx(ptr, cctxSize);
|
||||
|
||||
if (ZSTD_isError( ZSTD_initCDict_internal(cdict, dict, dictSize,
|
||||
1 /* byReference */,
|
||||
dictMode, cParams) ))
|
||||
return NULL;
|
||||
|
||||
return cdict;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static ZSTD_parameters ZSTD_getParamsFromCDict(const ZSTD_CDict* cdict) {
|
||||
return ZSTD_getParamsFromCCtx(cdict->refContext);
|
||||
@@ -3997,10 +4060,12 @@ size_t ZSTD_initCStream_internal_opaque(
|
||||
return ERROR(memory_allocation);
|
||||
}
|
||||
ZSTD_freeCDict(zcs->cdictLocal);
|
||||
/* TODO opaque version: what needs to be zero? */
|
||||
zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
|
||||
|
||||
/* Is a CCtx_params version needed? */
|
||||
zcs->cdictLocal = ZSTD_createCDict_advanced(
|
||||
dict, dictSize,
|
||||
params, zcs->customMem);
|
||||
params.dictContentByRef, params.dictMode,
|
||||
params.cParams, zcs->customMem);
|
||||
zcs->cdict = zcs->cdictLocal;
|
||||
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
||||
} else {
|
||||
|
||||
@@ -746,11 +746,10 @@ size_t ZSTDMT_initCStream_internal_opaque(
|
||||
if (dict) {
|
||||
DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
|
||||
ZSTD_freeCDict(zcs->cdictLocal);
|
||||
/* TODO: cctxParam version? Is this correct?
|
||||
* by reference should be zero, mode should be ZSTD_dm_auto */
|
||||
zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
|
||||
dict, dictSize,
|
||||
cctxParams, zcs->cMem);
|
||||
/* TODO: cctxParam version? Is this correct? */
|
||||
zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
|
||||
0 /* byRef */, ZSTD_dm_auto, /* note : a loadPrefix becomes an internal CDict */
|
||||
cctxParams.cParams, zcs->cMem);
|
||||
zcs->cdict = zcs->cdictLocal;
|
||||
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
||||
} else {
|
||||
|
||||
@@ -527,11 +527,9 @@ ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t sr
|
||||
/*! ZSTD_estimate?DictSize() :
|
||||
* ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
|
||||
* ZSTD_estimateCStreamSize_advanced() makes it possible to control precisely compression parameters, like ZSTD_createCDict_advanced().
|
||||
* ZSTD_estimateCDictSize_advanced_opaque() allows further compression parameters. ByReference can be set with ZSTD_CCtxParam_setParameter.
|
||||
* Note : dictionary created "byReference" are smaller */
|
||||
ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
|
||||
ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, unsigned byReference);
|
||||
ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced_opaque(size_t dictSize, const ZSTD_CCtx_params* params);
|
||||
ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, unsigned byReference);
|
||||
|
||||
|
||||
@@ -608,13 +606,6 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_initStaticCDict(
|
||||
unsigned byReference, ZSTD_dictMode_e dictMode,
|
||||
ZSTD_compressionParameters cParams);
|
||||
|
||||
ZSTDLIB_API ZSTD_CDict* ZSTD_initStaticCDict_advanced_opaque(
|
||||
void* workspace, size_t workspaceSize,
|
||||
const void* dict, size_t dictSize,
|
||||
const ZSTD_CCtx_params* params);
|
||||
|
||||
|
||||
|
||||
/*! ZSTD_getCParams() :
|
||||
* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
|
||||
* `estimatedSrcSize` value is optional, select 0 if not known */
|
||||
|
||||
Reference in New Issue
Block a user