mirror of
https://github.com/facebook/zstd.git
synced 2025-10-07 00:12:40 -04:00
linked newAPI to ZSTDMT
This commit is contained in:
parent
c59162e053
commit
f35e2de61c
@ -707,7 +707,7 @@ size_t ZSTD_CDict_loadDictionary(ZSTD_CDict* cdict, const void* dict, size_t dic
|
||||
</b><p> Same as ZSTD_compress_generic(),
|
||||
but using only simple integral types as arguments.
|
||||
Argument list is less expressive than ZSTD_{in,out}Buffer,
|
||||
but can be helpful for binders towards dynamic languages
|
||||
but can be helpful for binders to dynamic languages
|
||||
which have troubles handling structures containing memory pointers.
|
||||
|
||||
</p></pre><BR>
|
||||
|
@ -3734,6 +3734,16 @@ size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuf
|
||||
return ZSTD_compressStream_generic(zcs, output, input, ZSTD_e_continue);
|
||||
}
|
||||
|
||||
/*! ZSTDMT_initCStream_internal() :
|
||||
* Private use only. Init streaming operation.
|
||||
* expects params to be valid.
|
||||
* must receive dict, or cdict, or none, but not both.
|
||||
* @return : 0, or an error code */
|
||||
size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
|
||||
const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
|
||||
ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
||||
|
||||
|
||||
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
||||
ZSTD_outBuffer* output,
|
||||
ZSTD_inBuffer* input,
|
||||
@ -3750,12 +3760,19 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
||||
if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
|
||||
params.cParams = ZSTD_getCParams(cctx->compressionLevel,
|
||||
cctx->frameContentSize, 0 /* dictSize */);
|
||||
CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
|
||||
if (cctx->nbThreads > 1) {
|
||||
CHECK_F( ZSTDMT_initCStream_internal(cctx->mtctx, NULL, 0, cctx->cdict, params, cctx->frameContentSize) );
|
||||
} else {
|
||||
CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
|
||||
} }
|
||||
|
||||
if (cctx->nbThreads > 1) {
|
||||
DEBUGLOG(5, "starting ZSTDMT_compressStream_generic");
|
||||
return ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp) ;
|
||||
}
|
||||
|
||||
DEBUGLOG(5, "starting ZSTD_compressStream_generic");
|
||||
CHECK_F( ZSTD_compressStream_generic(cctx, output, input, endOp) );
|
||||
|
||||
DEBUGLOG(5, "completing ZSTD_compress_generic");
|
||||
return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
|
||||
}
|
||||
@ -3773,7 +3790,6 @@ size_t ZSTD_compress_generic_simpleArgs (
|
||||
*dstPos = output.pos;
|
||||
*srcPos = input.pos;
|
||||
return cErr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,9 +559,9 @@ static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* zcs)
|
||||
}
|
||||
|
||||
|
||||
static size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
|
||||
const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
|
||||
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
||||
size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
|
||||
const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
|
||||
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
||||
{
|
||||
/* params are supposed to be fully validated at this point */
|
||||
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
||||
@ -849,3 +849,22 @@ size_t ZSTDMT_endStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output)
|
||||
return ZSTD_endStream(zcs->cctxPool->cctx[0], output);
|
||||
return ZSTDMT_flushStream_internal(zcs, output, 1);
|
||||
}
|
||||
|
||||
size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
|
||||
ZSTD_outBuffer* output,
|
||||
ZSTD_inBuffer* input,
|
||||
ZSTD_EndDirective endOp)
|
||||
{
|
||||
CHECK_F (ZSTDMT_compressStream(mtctx, output, input));
|
||||
switch(endOp)
|
||||
{
|
||||
case ZSTD_e_flush:
|
||||
return ZSTDMT_flushStream(mtctx, output);
|
||||
case ZSTD_e_end:
|
||||
return ZSTDMT_endStream(mtctx, output);
|
||||
case ZSTD_e_continue:
|
||||
return 1;
|
||||
default:
|
||||
return ERROR(GENERIC);
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,19 @@ typedef enum {
|
||||
ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value);
|
||||
|
||||
|
||||
/*! ZSTDMT_compressStream_generic() :
|
||||
* Combines ZSTDMT_compressStream() with ZSTDMT_flushStream() or ZSTDMT_endStream()
|
||||
* depending on flush directive
|
||||
* @return : minimum amount of data still to be flushed
|
||||
* 0 if fully flushed
|
||||
* or an error code */
|
||||
ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
|
||||
ZSTD_outBuffer* output,
|
||||
ZSTD_inBuffer* input,
|
||||
ZSTD_EndDirective endOp);
|
||||
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -828,7 +828,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx); /* Not ready yet ! */
|
||||
* Same as ZSTD_compress_generic(),
|
||||
* but using only simple integral types as arguments.
|
||||
* Argument list is less expressive than ZSTD_{in,out}Buffer,
|
||||
* but can be helpful for binders towards dynamic languages
|
||||
* but can be helpful for binders to dynamic languages
|
||||
* which have troubles handling structures containing memory pointers.
|
||||
*/
|
||||
size_t ZSTD_compress_generic_simpleArgs (
|
||||
|
Loading…
x
Reference in New Issue
Block a user