diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html index 6023189b..5a9d1b5d 100644 --- a/doc/zstd_manual.html +++ b/doc/zstd_manual.html @@ -439,7 +439,7 @@ typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; v void* dst, size_t dstCapacity, const void* src, size_t srcSize, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams); -
Same as ZSTD_compress_usingDict_advanced(), with fine-tune control over frame parameters +
Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters
size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);start a new compression job, using same parameters from previous job. diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index d8d29bde..d6c5fffb 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -3211,17 +3211,25 @@ static size_t ZSTD_initCStream_stage2(ZSTD_CStream* zcs, return ZSTD_resetCStream_internal(zcs, pledgedSrcSize); } -/* note : cdict must outlive compression session */ -size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict) +/* ZSTD_initCStream_usingCDict_advanced() : + * same as ZSTD_initCStream_usingCDict(), with control over frame parameters */ +size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize, ZSTD_frameParameters fParams) { if (!cdict) return ERROR(GENERIC); /* cannot handle NULL cdict (does not know what to do) */ { ZSTD_parameters params = ZSTD_getParamsFromCDict(cdict); - params.fParams.contentSizeFlag = 0; + params.fParams = fParams; zcs->cdict = cdict; - return ZSTD_initCStream_stage2(zcs, params, 0); + return ZSTD_initCStream_stage2(zcs, params, pledgedSrcSize); } } +/* note : cdict must outlive compression session */ +size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict) +{ + ZSTD_frameParameters const fParams = { 0 /* content */, 0 /* checksum */, 0 /* noDictID */ }; + return ZSTD_initCStream_usingCDict_advanced(zcs, cdict, 0, fParams); +} + static size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize) diff --git a/lib/zstd.h b/lib/zstd.h index 6a21cd65..3852b720 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -602,6 +602,7 @@ ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dic ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */ +ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, unsigned long long pledgedSrcSize, ZSTD_frameParameters fParams); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters */ /*! ZSTD_resetCStream() : * start a new compression job, using same parameters from previous job.