mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
minor function rename
ZSTD_estimateCStreamSize_advanced_usingCParams -> ZSTD_estimateCStreamSize_usingCParams _usingX is clear. _advanced feels redundant
This commit is contained in:
@ -403,29 +403,29 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|||||||
</p></pre><BR>
|
</p></pre><BR>
|
||||||
|
|
||||||
<pre><b>size_t ZSTD_estimateCCtxSize(int compressionLevel);
|
<pre><b>size_t ZSTD_estimateCCtxSize(int compressionLevel);
|
||||||
size_t ZSTD_estimateCCtxSize_advanced_usingCParams(ZSTD_compressionParameters cParams);
|
size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
|
||||||
size_t ZSTD_estimateCCtxSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params);
|
size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
||||||
size_t ZSTD_estimateDCtxSize(void);
|
size_t ZSTD_estimateDCtxSize(void);
|
||||||
</b><p> These functions make it possible to estimate memory usage
|
</b><p> These functions make it possible to estimate memory usage
|
||||||
of a future {D,C}Ctx, before its creation.
|
of a future {D,C}Ctx, before its creation.
|
||||||
ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
|
ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
|
||||||
It will also consider src size to be arbitrarily "large", which is worst case.
|
It will also consider src size to be arbitrarily "large", which is worst case.
|
||||||
If srcSize is known to always be small, ZSTD_estimateCCtxSize_advanced_usingCParams() can provide a tighter estimation.
|
If srcSize is known to always be small, ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation.
|
||||||
ZSTD_estimateCCtxSize_advanced_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
ZSTD_estimateCCtxSize_advanced_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is > 1.
|
ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is > 1.
|
||||||
Note : CCtx estimation is only correct for single-threaded compression
|
Note : CCtx estimation is only correct for single-threaded compression
|
||||||
</p></pre><BR>
|
</p></pre><BR>
|
||||||
|
|
||||||
<pre><b>size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
<pre><b>size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
||||||
size_t ZSTD_estimateCStreamSize_advanced_usingCParams(ZSTD_compressionParameters cParams);
|
size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
|
||||||
size_t ZSTD_estimateCStreamSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params);
|
size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
||||||
size_t ZSTD_estimateDStreamSize(size_t windowSize);
|
size_t ZSTD_estimateDStreamSize(size_t windowSize);
|
||||||
size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
||||||
</b><p> ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
|
</b><p> ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
|
||||||
It will also consider src size to be arbitrarily "large", which is worst case.
|
It will also consider src size to be arbitrarily "large", which is worst case.
|
||||||
If srcSize is known to always be small, ZSTD_estimateCStreamSize_advanced_usingCParams() can provide a tighter estimation.
|
If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation.
|
||||||
ZSTD_estimateCStreamSize_advanced_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
ZSTD_estimateCStreamSize_advanced_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is set to a value > 1.
|
ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is set to a value > 1.
|
||||||
Note : CStream estimation is only correct for single-threaded compression.
|
Note : CStream estimation is only correct for single-threaded compression.
|
||||||
ZSTD_DStream memory budget depends on window Size.
|
ZSTD_DStream memory budget depends on window Size.
|
||||||
This information can be passed manually, using ZSTD_estimateDStreamSize,
|
This information can be passed manually, using ZSTD_estimateDStreamSize,
|
||||||
@ -436,8 +436,8 @@ size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
|||||||
</p></pre><BR>
|
</p></pre><BR>
|
||||||
|
|
||||||
<pre><b>typedef enum {
|
<pre><b>typedef enum {
|
||||||
ZSTD_dlm_byCopy = 0, </b>/* Copy dictionary content internally. */<b>
|
ZSTD_dlm_byCopy = 0, </b>/**< Copy dictionary content internally */<b>
|
||||||
ZSTD_dlm_byRef, </b>/* Reference dictionary content -- the dictionary buffer must outlives its users. */<b>
|
ZSTD_dlm_byRef, </b>/**< Reference dictionary content -- the dictionary buffer must outlive its users. */<b>
|
||||||
} ZSTD_dictLoadMethod_e;
|
} ZSTD_dictLoadMethod_e;
|
||||||
</b></pre><BR>
|
</b></pre><BR>
|
||||||
<pre><b>size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
|
<pre><b>size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
|
||||||
@ -656,8 +656,8 @@ size_t ZSTD_resetDStream(ZSTD_DStream* zds); </b>/**< re-use decompression para
|
|||||||
</pre></b><BR>
|
</pre></b><BR>
|
||||||
<a name="Chapter17"></a><h2>Buffer-less and synchronous inner streaming functions</h2><pre>
|
<a name="Chapter17"></a><h2>Buffer-less and synchronous inner streaming functions</h2><pre>
|
||||||
This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
|
This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
|
||||||
But it's also a complex one, with many restrictions (documented below).
|
But it's also a complex one, with several restrictions, documented below.
|
||||||
Prefer using normal streaming API for an easier experience
|
Prefer normal streaming API for an easier experience.
|
||||||
|
|
||||||
<BR></pre>
|
<BR></pre>
|
||||||
|
|
||||||
@ -673,8 +673,8 @@ size_t ZSTD_resetDStream(ZSTD_DStream* zds); </b>/**< re-use decompression para
|
|||||||
|
|
||||||
Then, consume your input using ZSTD_compressContinue().
|
Then, consume your input using ZSTD_compressContinue().
|
||||||
There are some important considerations to keep in mind when using this advanced function :
|
There are some important considerations to keep in mind when using this advanced function :
|
||||||
- ZSTD_compressContinue() has no internal buffer. It uses externally provided buffer only.
|
- ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
|
||||||
- Interface is synchronous : input is consumed entirely and produce 1+ (or more) compressed blocks.
|
- Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
|
||||||
- Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
- Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
||||||
Worst case evaluation is provided by ZSTD_compressBound().
|
Worst case evaluation is provided by ZSTD_compressBound().
|
||||||
ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
||||||
@ -685,9 +685,9 @@ size_t ZSTD_resetDStream(ZSTD_DStream* zds); </b>/**< re-use decompression para
|
|||||||
|
|
||||||
Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
||||||
It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
||||||
Without last block mark, frames will be considered unfinished (corrupted) by decoders.
|
Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
|
||||||
|
|
||||||
`ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress some new frame.
|
`ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
|
||||||
<BR></pre>
|
<BR></pre>
|
||||||
|
|
||||||
<h3>Buffer-less streaming compression functions</h3><pre></pre><b><pre>size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
<h3>Buffer-less streaming compression functions</h3><pre></pre><b><pre>size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
||||||
|
@ -133,7 +133,7 @@ int main(int argc, char const *argv[]) {
|
|||||||
|
|
||||||
size_t const cstreamSize = ZSTD_sizeof_CStream(cstream);
|
size_t const cstreamSize = ZSTD_sizeof_CStream(cstream);
|
||||||
size_t const cstreamEstimatedSize = wLog ?
|
size_t const cstreamEstimatedSize = wLog ?
|
||||||
ZSTD_estimateCStreamSize_advanced_usingCParams(params.cParams) :
|
ZSTD_estimateCStreamSize_usingCParams(params.cParams) :
|
||||||
ZSTD_estimateCStreamSize(compressionLevel);
|
ZSTD_estimateCStreamSize(compressionLevel);
|
||||||
size_t const dstreamSize = ZSTD_sizeof_DStream(dstream);
|
size_t const dstreamSize = ZSTD_sizeof_DStream(dstream);
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, u
|
|||||||
return ZSTD_adjustCParams_internal(cPar, srcSize, dictSize);
|
return ZSTD_adjustCParams_internal(cPar, srcSize, dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCCtxSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params)
|
size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params)
|
||||||
{
|
{
|
||||||
/* Estimate CCtx size is supported for single-threaded compression only. */
|
/* Estimate CCtx size is supported for single-threaded compression only. */
|
||||||
if (params->nbThreads > 1) { return ERROR(GENERIC); }
|
if (params->nbThreads > 1) { return ERROR(GENERIC); }
|
||||||
@ -710,22 +710,22 @@ size_t ZSTD_estimateCCtxSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCCtxSize_advanced_usingCParams(ZSTD_compressionParameters cParams)
|
size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
||||||
return ZSTD_estimateCCtxSize_advanced_usingCCtxParams(¶ms);
|
return ZSTD_estimateCCtxSize_usingCCtxParams(¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCCtxSize(int compressionLevel)
|
size_t ZSTD_estimateCCtxSize(int compressionLevel)
|
||||||
{
|
{
|
||||||
ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
|
ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
|
||||||
return ZSTD_estimateCCtxSize_advanced_usingCParams(cParams);
|
return ZSTD_estimateCCtxSize_usingCParams(cParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCStreamSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params)
|
size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params)
|
||||||
{
|
{
|
||||||
if (params->nbThreads > 1) { return ERROR(GENERIC); }
|
if (params->nbThreads > 1) { return ERROR(GENERIC); }
|
||||||
{ size_t const CCtxSize = ZSTD_estimateCCtxSize_advanced_usingCCtxParams(params);
|
{ size_t const CCtxSize = ZSTD_estimateCCtxSize_usingCCtxParams(params);
|
||||||
size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params->cParams.windowLog);
|
size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params->cParams.windowLog);
|
||||||
size_t const inBuffSize = ((size_t)1 << params->cParams.windowLog) + blockSize;
|
size_t const inBuffSize = ((size_t)1 << params->cParams.windowLog) + blockSize;
|
||||||
size_t const outBuffSize = ZSTD_compressBound(blockSize) + 1;
|
size_t const outBuffSize = ZSTD_compressBound(blockSize) + 1;
|
||||||
@ -735,15 +735,15 @@ size_t ZSTD_estimateCStreamSize_advanced_usingCCtxParams(const ZSTD_CCtx_params*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCStreamSize_advanced_usingCParams(ZSTD_compressionParameters cParams)
|
size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
|
||||||
return ZSTD_estimateCStreamSize_advanced_usingCCtxParams(¶ms);
|
return ZSTD_estimateCStreamSize_usingCCtxParams(¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCStreamSize(int compressionLevel) {
|
size_t ZSTD_estimateCStreamSize(int compressionLevel) {
|
||||||
ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
|
ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
|
||||||
return ZSTD_estimateCStreamSize_advanced_usingCParams(cParams);
|
return ZSTD_estimateCStreamSize_usingCParams(cParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
static U32 ZSTD_equivalentCParams(ZSTD_compressionParameters cParams1,
|
static U32 ZSTD_equivalentCParams(ZSTD_compressionParameters cParams1,
|
||||||
@ -2182,8 +2182,8 @@ size_t ZSTD_estimateCDictSize_advanced(
|
|||||||
{
|
{
|
||||||
DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (U32)sizeof(ZSTD_CDict));
|
DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (U32)sizeof(ZSTD_CDict));
|
||||||
DEBUGLOG(5, "CCtx estimate : %u",
|
DEBUGLOG(5, "CCtx estimate : %u",
|
||||||
(U32)ZSTD_estimateCCtxSize_advanced_usingCParams(cParams));
|
(U32)ZSTD_estimateCCtxSize_usingCParams(cParams));
|
||||||
return sizeof(ZSTD_CDict) + ZSTD_estimateCCtxSize_advanced_usingCParams(cParams)
|
return sizeof(ZSTD_CDict) + ZSTD_estimateCCtxSize_usingCParams(cParams)
|
||||||
+ (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
|
+ (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2308,7 +2308,7 @@ ZSTD_CDict* ZSTD_initStaticCDict(void* workspace, size_t workspaceSize,
|
|||||||
ZSTD_dictMode_e dictMode,
|
ZSTD_dictMode_e dictMode,
|
||||||
ZSTD_compressionParameters cParams)
|
ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
size_t const cctxSize = ZSTD_estimateCCtxSize_advanced_usingCParams(cParams);
|
size_t const cctxSize = ZSTD_estimateCCtxSize_usingCParams(cParams);
|
||||||
size_t const neededSize = sizeof(ZSTD_CDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize)
|
size_t const neededSize = sizeof(ZSTD_CDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize)
|
||||||
+ cctxSize;
|
+ cctxSize;
|
||||||
ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
|
ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
|
||||||
|
36
lib/zstd.h
36
lib/zstd.h
@ -499,21 +499,21 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|||||||
* of a future {D,C}Ctx, before its creation.
|
* of a future {D,C}Ctx, before its creation.
|
||||||
* ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
|
* ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
|
||||||
* It will also consider src size to be arbitrarily "large", which is worst case.
|
* It will also consider src size to be arbitrarily "large", which is worst case.
|
||||||
* If srcSize is known to always be small, ZSTD_estimateCCtxSize_advanced_usingCParams() can provide a tighter estimation.
|
* If srcSize is known to always be small, ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation.
|
||||||
* ZSTD_estimateCCtxSize_advanced_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
* ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
* ZSTD_estimateCCtxSize_advanced_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is > 1.
|
* ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is > 1.
|
||||||
* Note : CCtx estimation is only correct for single-threaded compression */
|
* Note : CCtx estimation is only correct for single-threaded compression */
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
|
ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCCtxSize_advanced_usingCParams(ZSTD_compressionParameters cParams);
|
ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCCtxSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params);
|
ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
||||||
|
|
||||||
/*! ZSTD_estimateCStreamSize() :
|
/*! ZSTD_estimateCStreamSize() :
|
||||||
* ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
|
* ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
|
||||||
* It will also consider src size to be arbitrarily "large", which is worst case.
|
* It will also consider src size to be arbitrarily "large", which is worst case.
|
||||||
* If srcSize is known to always be small, ZSTD_estimateCStreamSize_advanced_usingCParams() can provide a tighter estimation.
|
* If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation.
|
||||||
* ZSTD_estimateCStreamSize_advanced_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
* ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
* ZSTD_estimateCStreamSize_advanced_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is set to a value > 1.
|
* ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbThreads is set to a value > 1.
|
||||||
* Note : CStream estimation is only correct for single-threaded compression.
|
* Note : CStream estimation is only correct for single-threaded compression.
|
||||||
* ZSTD_DStream memory budget depends on window Size.
|
* ZSTD_DStream memory budget depends on window Size.
|
||||||
* This information can be passed manually, using ZSTD_estimateDStreamSize,
|
* This information can be passed manually, using ZSTD_estimateDStreamSize,
|
||||||
@ -522,14 +522,14 @@ ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
|||||||
* an internal ?Dict will be created, which additional size is not estimated here.
|
* an internal ?Dict will be created, which additional size is not estimated here.
|
||||||
* In this case, get total size by adding ZSTD_estimate?DictSize */
|
* In this case, get total size by adding ZSTD_estimate?DictSize */
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCStreamSize_advanced_usingCParams(ZSTD_compressionParameters cParams);
|
ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateCStreamSize_advanced_usingCCtxParams(const ZSTD_CCtx_params* params);
|
ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
|
ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZSTD_dlm_byCopy = 0, /* Copy dictionary content internally. */
|
ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */
|
||||||
ZSTD_dlm_byRef, /* Reference dictionary content -- the dictionary buffer must outlives its users. */
|
ZSTD_dlm_byRef, /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
|
||||||
} ZSTD_dictLoadMethod_e;
|
} ZSTD_dictLoadMethod_e;
|
||||||
|
|
||||||
/*! ZSTD_estimate?DictSize() :
|
/*! ZSTD_estimate?DictSize() :
|
||||||
@ -760,8 +760,8 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompress
|
|||||||
* Buffer-less and synchronous inner streaming functions
|
* Buffer-less and synchronous inner streaming functions
|
||||||
*
|
*
|
||||||
* This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
|
* This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
|
||||||
* But it's also a complex one, with many restrictions (documented below).
|
* But it's also a complex one, with several restrictions, documented below.
|
||||||
* Prefer using normal streaming API for an easier experience
|
* Prefer normal streaming API for an easier experience.
|
||||||
********************************************************************* */
|
********************************************************************* */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -778,8 +778,8 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompress
|
|||||||
|
|
||||||
Then, consume your input using ZSTD_compressContinue().
|
Then, consume your input using ZSTD_compressContinue().
|
||||||
There are some important considerations to keep in mind when using this advanced function :
|
There are some important considerations to keep in mind when using this advanced function :
|
||||||
- ZSTD_compressContinue() has no internal buffer. It uses externally provided buffer only.
|
- ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
|
||||||
- Interface is synchronous : input is consumed entirely and produce 1+ (or more) compressed blocks.
|
- Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
|
||||||
- Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
- Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
||||||
Worst case evaluation is provided by ZSTD_compressBound().
|
Worst case evaluation is provided by ZSTD_compressBound().
|
||||||
ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
||||||
@ -790,9 +790,9 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompress
|
|||||||
|
|
||||||
Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
||||||
It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
||||||
Without last block mark, frames will be considered unfinished (corrupted) by decoders.
|
Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
|
||||||
|
|
||||||
`ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress some new frame.
|
`ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*===== Buffer-less streaming compression functions =====*/
|
/*===== Buffer-less streaming compression functions =====*/
|
||||||
|
@ -391,8 +391,8 @@ static int BMK_seed(winnerInfo_t* winners, const ZSTD_compressionParameters para
|
|||||||
double W_DMemUsed_note = W_ratioNote * ( 40 + 9*cLevel) - log((double)W_DMemUsed);
|
double W_DMemUsed_note = W_ratioNote * ( 40 + 9*cLevel) - log((double)W_DMemUsed);
|
||||||
double O_DMemUsed_note = O_ratioNote * ( 40 + 9*cLevel) - log((double)O_DMemUsed);
|
double O_DMemUsed_note = O_ratioNote * ( 40 + 9*cLevel) - log((double)O_DMemUsed);
|
||||||
|
|
||||||
size_t W_CMemUsed = (1 << params.windowLog) + ZSTD_estimateCCtxSize_advanced_usingCParams(params);
|
size_t W_CMemUsed = (1 << params.windowLog) + ZSTD_estimateCCtxSize_usingCParams(params);
|
||||||
size_t O_CMemUsed = (1 << winners[cLevel].params.windowLog) + ZSTD_estimateCCtxSize_advanced_usingCParams(winners[cLevel].params);
|
size_t O_CMemUsed = (1 << winners[cLevel].params.windowLog) + ZSTD_estimateCCtxSize_usingCParams(winners[cLevel].params);
|
||||||
double W_CMemUsed_note = W_ratioNote * ( 50 + 13*cLevel) - log((double)W_CMemUsed);
|
double W_CMemUsed_note = W_ratioNote * ( 50 + 13*cLevel) - log((double)W_CMemUsed);
|
||||||
double O_CMemUsed_note = O_ratioNote * ( 50 + 13*cLevel) - log((double)O_CMemUsed);
|
double O_CMemUsed_note = O_ratioNote * ( 50 + 13*cLevel) - log((double)O_CMemUsed);
|
||||||
|
|
||||||
|
@ -200,11 +200,11 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
|
|||||||
/* context size functions */
|
/* context size functions */
|
||||||
DISPLAYLEVEL(3, "test%3i : estimate CStream size : ", testNb++);
|
DISPLAYLEVEL(3, "test%3i : estimate CStream size : ", testNb++);
|
||||||
{ ZSTD_compressionParameters const cParams = ZSTD_getCParams(1, CNBufferSize, dictSize);
|
{ ZSTD_compressionParameters const cParams = ZSTD_getCParams(1, CNBufferSize, dictSize);
|
||||||
size_t const s = ZSTD_estimateCStreamSize_advanced_usingCParams(cParams)
|
size_t const cstreamSize = ZSTD_estimateCStreamSize_usingCParams(cParams);
|
||||||
/* uses ZSTD_initCStream_usingDict() */
|
size_t const cdictSize = ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy); /* uses ZSTD_initCStream_usingDict() */
|
||||||
+ ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy);
|
if (ZSTD_isError(cstreamSize)) goto _output_error;
|
||||||
if (ZSTD_isError(s)) goto _output_error;
|
if (ZSTD_isError(cdictSize)) goto _output_error;
|
||||||
DISPLAYLEVEL(3, "OK (%u bytes) \n", (U32)s);
|
DISPLAYLEVEL(3, "OK (%u bytes) \n", (U32)(cstreamSize + cdictSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAYLEVEL(3, "test%3i : check actual CStream size : ", testNb++);
|
DISPLAYLEVEL(3, "test%3i : check actual CStream size : ", testNb++);
|
||||||
|
Reference in New Issue
Block a user