ZSTD_estimateCStreamSize_advanced()
This commit is contained in:
parent
31af8290d1
commit
0c9a915a28
@ -414,14 +414,18 @@ size_t ZSTD_estimateDCtxSize(void);
|
|||||||
of a future {D,C}Ctx, before its creation.
|
of a future {D,C}Ctx, before its creation.
|
||||||
The objective is to guide decision before allocation.
|
The objective is to guide decision before allocation.
|
||||||
ZSTD_estimateCCtxSize() will consider src size to be arbitrarily "large".
|
ZSTD_estimateCCtxSize() will consider src size to be arbitrarily "large".
|
||||||
If srcSize is known to be small, ZSTD_estimateCCtxSize_advanced() will provide a better (smaller) estimation.
|
If srcSize is known to be small, ZSTD_estimateCCtxSize_advanced() can provide a tighter estimation.
|
||||||
ZSTD_estimateCCtxSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
ZSTD_estimateCCtxSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
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(ZSTD_compressionParameters cParams);
|
<pre><b>size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
||||||
|
size_t ZSTD_estimateCStreamSize_advanced(ZSTD_compressionParameters cParams);
|
||||||
size_t ZSTD_estimateDStreamSize(ZSTD_frameHeader fHeader);
|
size_t ZSTD_estimateDStreamSize(ZSTD_frameHeader fHeader);
|
||||||
</b><p> Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
|
</b><p> ZSTD_estimateCStreamSize() will consider src size to be arbitrarily "large".
|
||||||
|
If srcSize is known to be small, ZSTD_estimateCStreamSize_advanced() can provide a tighter estimation.
|
||||||
|
ZSTD_estimateCStreamSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
|
Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
|
||||||
an internal ?Dict will be created, which size is not estimated here.
|
an internal ?Dict will be created, which 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
|
||||||
</p></pre><BR>
|
</p></pre><BR>
|
||||||
|
@ -564,7 +564,7 @@ size_t ZSTD_estimateCCtxSize(int compressionLevel)
|
|||||||
return ZSTD_estimateCCtxSize_advanced(cParams);
|
return ZSTD_estimateCCtxSize_advanced(cParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_estimateCStreamSize(ZSTD_compressionParameters cParams)
|
size_t ZSTD_estimateCStreamSize_advanced(ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
size_t const CCtxSize = ZSTD_estimateCCtxSize_advanced(cParams);
|
size_t const CCtxSize = ZSTD_estimateCCtxSize_advanced(cParams);
|
||||||
size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << cParams.windowLog);
|
size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << cParams.windowLog);
|
||||||
@ -575,6 +575,11 @@ size_t ZSTD_estimateCStreamSize(ZSTD_compressionParameters cParams)
|
|||||||
return CCtxSize + streamingSize;
|
return CCtxSize + streamingSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ZSTD_estimateCStreamSize(int compressionLevel) {
|
||||||
|
ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
|
||||||
|
return ZSTD_estimateCStreamSize_advanced(cParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static U32 ZSTD_equivalentParams(ZSTD_compressionParameters cParams1,
|
static U32 ZSTD_equivalentParams(ZSTD_compressionParameters cParams1,
|
||||||
ZSTD_compressionParameters cParams2)
|
ZSTD_compressionParameters cParams2)
|
||||||
|
@ -498,7 +498,7 @@ 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.
|
||||||
* The objective is to guide decision before allocation.
|
* The objective is to guide decision before allocation.
|
||||||
* ZSTD_estimateCCtxSize() will consider src size to be arbitrarily "large".
|
* ZSTD_estimateCCtxSize() will consider src size to be arbitrarily "large".
|
||||||
* If srcSize is known to be small, ZSTD_estimateCCtxSize_advanced() will provide a better (smaller) estimation.
|
* If srcSize is known to be small, ZSTD_estimateCCtxSize_advanced() can provide a tighter estimation.
|
||||||
* ZSTD_estimateCCtxSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
* ZSTD_estimateCCtxSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
* 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);
|
||||||
@ -506,10 +506,14 @@ ZSTDLIB_API size_t ZSTD_estimateCCtxSize_advanced(ZSTD_compressionParameters cPa
|
|||||||
ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
||||||
|
|
||||||
/*! ZSTD_estimate?StreamSize() :
|
/*! ZSTD_estimate?StreamSize() :
|
||||||
|
* ZSTD_estimateCStreamSize() will consider src size to be arbitrarily "large".
|
||||||
|
* If srcSize is known to be small, ZSTD_estimateCStreamSize_advanced() can provide a tighter estimation.
|
||||||
|
* ZSTD_estimateCStreamSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
|
||||||
* Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
|
* Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
|
||||||
* an internal ?Dict will be created, which size is not estimated here.
|
* an internal ?Dict will be created, which 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(ZSTD_compressionParameters cParams);
|
ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
||||||
|
ZSTDLIB_API size_t ZSTD_estimateCStreamSize_advanced(ZSTD_compressionParameters cParams);
|
||||||
ZSTDLIB_API size_t ZSTD_estimateDStreamSize(ZSTD_frameHeader fHeader);
|
ZSTDLIB_API size_t ZSTD_estimateDStreamSize(ZSTD_frameHeader fHeader);
|
||||||
|
|
||||||
/*! ZSTD_estimate?DictSize() :
|
/*! ZSTD_estimate?DictSize() :
|
||||||
|
@ -193,8 +193,7 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
/* Static CCtx tests */
|
/* Static CCtx tests */
|
||||||
#define STATIC_CCTX_LEVEL 3
|
#define STATIC_CCTX_LEVEL 3
|
||||||
DISPLAYLEVEL(4, "test%3i : create static CCtx for level %u :", testNb++, STATIC_CCTX_LEVEL);
|
DISPLAYLEVEL(4, "test%3i : create static CCtx for level %u :", testNb++, STATIC_CCTX_LEVEL);
|
||||||
{ ZSTD_compressionParameters const cParams = ZSTD_getCParams(STATIC_CCTX_LEVEL, 0, 0);
|
{ size_t const staticCCtxSize = ZSTD_estimateCStreamSize(STATIC_CCTX_LEVEL);
|
||||||
size_t const staticCCtxSize = ZSTD_estimateCStreamSize(cParams);
|
|
||||||
void* const staticCCtxBuffer = malloc(staticCCtxSize);
|
void* const staticCCtxBuffer = malloc(staticCCtxSize);
|
||||||
size_t const staticDCtxSize = ZSTD_estimateDCtxSize();
|
size_t const staticDCtxSize = ZSTD_estimateDCtxSize();
|
||||||
void* const staticDCtxBuffer = malloc(staticDCtxSize);
|
void* const staticDCtxBuffer = malloc(staticDCtxSize);
|
||||||
|
@ -210,7 +210,7 @@ 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(cParams)
|
size_t const s = ZSTD_estimateCStreamSize_advanced(cParams)
|
||||||
/* uses ZSTD_initCStream_usingDict() */
|
/* uses ZSTD_initCStream_usingDict() */
|
||||||
+ ZSTD_estimateCDictSize(cParams, dictSize, 0);
|
+ ZSTD_estimateCDictSize(cParams, dictSize, 0);
|
||||||
if (ZSTD_isError(s)) goto _output_error;
|
if (ZSTD_isError(s)) goto _output_error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user