From 9c23ea9e2be361586896af31568227aa2716447a Mon Sep 17 00:00:00 2001
From: sen zstd 1.4.9 Manual
+zstd 1.5.0 Manual
Contents
@@ -12,15 +12,15 @@
Explicit context
@@ -158,7 +158,7 @@ int ZSTD_defaultCLevel(void); /*!< default compression lev
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
ZSTD_CCtx* ZSTD_createCCtx(void);
-size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
+size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
/* accept NULL pointer */
size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
void* dst, size_t dstCapacity,
@@ -180,7 +180,7 @@ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
Use one context per thread for parallel execution.
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
ZSTD_DCtx* ZSTD_createDCtx(void);
-size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
+size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
/* accept NULL pointer */
size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
void* dst, size_t dstCapacity,
@@ -191,7 +191,7 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
typedef enum { ZSTD_fast=1, ZSTD_dfast=2, @@ -206,6 +206,15 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); Only the order (from fast to strong) is guaranteed */ } ZSTD_strategy;
typedef enum { + ZSTD_lcm_auto = 0, /**< Automatically determine the compression mode based on the compression level. + * Negative compression levels will be uncompressed, and positive compression + * levels will be compressed. */ + ZSTD_lcm_huffman = 1, /**< Always attempt Huffman compression. Uncompressed literals will still be + * emitted if Huffman compression is not profitable. */ + ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */ +} ZSTD_literalCompressionMode_e; /* Requires v1.5.0+ */ +
typedef enum { /* compression parameters @@ -271,10 +280,11 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); * The higher the value of selected strategy, the more complex it is, * resulting in stronger and slower compression. * Special: value 0 means "use default strategy". */ - ZSTD_c_literalCompressionMode=108, /* Controls how the literals are compressed (default is auto). - * The value must be of type ZSTD_literalCompressionMode_e. - * See ZSTD_literalCompressionMode_t enum definition for details. - */ + ZSTD_c_literalCompressionMode=108, /* Note : requires v1.5.0+ + * Controls how the literals are compressed (default is auto). + * The value must be of type ZSTD_literalCompressionMode_e. + * See ZSTD_literalCompressionMode_e enum definition for details. + */ /* LDM mode parameters */ ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching. @@ -332,7 +342,7 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1. * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads. * 0 means default, which is dynamically determined based on compression parameters. - * Job size must be a minimum of overlap size, or 1 MB, whichever is largest. + * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest. * The minimum size is automatically and transparently enforced. */ ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size. * The overlap size is an amount of data reloaded from previous job at the beginning of a new job. @@ -361,6 +371,8 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); * ZSTD_c_stableOutBuffer * ZSTD_c_blockDelimiters * ZSTD_c_validateSequences + * ZSTD_c_splitBlocks + * ZSTD_c_useRowMatchFinder * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. * note : never ever use experimentalParam? names directly; * also, the enums values themselves are unstable and can still change. @@ -375,7 +387,10 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); ZSTD_c_experimentalParam9=1006, ZSTD_c_experimentalParam10=1007, ZSTD_c_experimentalParam11=1008, - ZSTD_c_experimentalParam12=1009 + ZSTD_c_experimentalParam12=1009, + ZSTD_c_experimentalParam13=1010, + ZSTD_c_experimentalParam14=1011, + ZSTD_c_experimentalParam15=1012 } ZSTD_cParameter;
typedef struct { @@ -459,7 +474,7 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
typedef enum { @@ -590,7 +605,7 @@ size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */
ZSTD_CStream management functions
ZSTD_CStream* ZSTD_createCStream(void); -size_t ZSTD_freeCStream(ZSTD_CStream* zcs); +size_t ZSTD_freeCStream(ZSTD_CStream* zcs);/* accept NULL pointer */
typedef enum { ZSTD_e_continue=0,/* collect more data, encoder decides when to output compressed result, for optimal compression ratio */ @@ -684,7 +699,7 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
ZSTD_DStream* ZSTD_createDStream(void); -size_t ZSTD_freeDStream(ZSTD_DStream* zds); +size_t ZSTD_freeDStream(ZSTD_DStream* zds);/* accept NULL pointer */
size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ @@ -700,7 +715,7 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds); int compressionLevel);Compression at an explicit compression level using a Dictionary. A dictionary can be any arbitrary data segment (also called a prefix), - or a buffer with specified information (see dictBuilder/zdict.h). + or a buffer with specified information (see zdict.h). Note : This function loads the dictionary, resulting in significant startup delay. It's intended for a dictionary used only once. Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. @@ -735,7 +750,8 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds);
size_t ZSTD_freeCDict(ZSTD_CDict* CDict); -Function frees memory allocated by ZSTD_createCDict(). +
Function frees memory allocated by ZSTD_createCDict(). + If a NULL pointer is passed, no operation is performed.
size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, @@ -754,7 +770,8 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds);
size_t ZSTD_freeDDict(ZSTD_DDict* ddict); -Function frees memory allocated with ZSTD_createDDict() +
Function frees memory allocated with ZSTD_createDDict() + If a NULL pointer is passed, no operation is performed.
size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, @@ -776,7 +793,7 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds);unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);Provides the dictID of the dictionary loaded into `cdict`. If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - Non-conformant dictionaries can still be loaded, but as content-only dictionaries. + Non-conformant dictionaries can still be loaded, but as content-only dictionaries.
unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); @@ -797,7 +814,7 @@ size_t ZSTD_freeDStream(ZSTD_DStream* zds); When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code.
-Advanced dictionary and prefix API
+Advanced dictionary and prefix API (Requires v1.4.0+)
This API allows dictionaries to be used with ZSTD_compress2(), ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and only reset with the context is reset with ZSTD_reset_parameters or @@ -1059,13 +1076,10 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); } ZSTD_dictAttachPref_e;
typedef enum { - ZSTD_lcm_auto = 0, /**< Automatically determine the compression mode based on the compression level. - * Negative compression levels will be uncompressed, and positive compression - * levels will be compressed. */ - ZSTD_lcm_huffman = 1, /**< Always attempt Huffman compression. Uncompressed literals will still be - * emitted if Huffman compression is not profitable. */ - ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */ -} ZSTD_literalCompressionMode_e; + ZSTD_urm_auto = 0, /* Automatically determine whether or not we use row matchfinder */ + ZSTD_urm_disableRowMatchFinder = 1, /* Never use row matchfinder */ + ZSTD_urm_enableRowMatchFinder = 2 /* Always use row matchfinder when applicable */ +} ZSTD_useRowMatchFinderMode_e;
size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx, +ZSTD_DEPRECATED("use ZSTD_compress2") +size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, const void* dict,size_t dictSize, ZSTD_parameters params);Note : this function is now DEPRECATED. It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters. - This prototype will be marked as deprecated and generate compilation warning on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, +ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary") +size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams); -Note : this function is now REDUNDANT. +
Note : this function is now DEPRECATED. It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters. - This prototype will be marked as deprecated and generate compilation warning in some future version + This prototype will generate compilation warnings.
size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); @@ -1370,7 +1386,7 @@ ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this con
ZSTD_CCtx_params* ZSTD_createCCtxParams(void); -size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); +size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */Quick howto : - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure - ZSTD_CCtxParams_setParameter() : Push parameters one by one into @@ -1382,7 +1398,7 @@ size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); These parameters will be applied to all subsequent frames. - ZSTD_compressStream2() : Do compression using the CCtx. - - ZSTD_freeCCtxParams() : Free the memory. + - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer. This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() for static allocation of CCtx for single-threaded compression. @@ -1496,8 +1512,10 @@ size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
-size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format); -Instruct the decoder context about what kind of data to decode next. +
ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead") +size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format); +This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter(). + Instruct the decoder context about what kind of data to decode next. This instruction is mandatory to decode data without a fully-formed header, such ZSTD_f_zstd1_magicless for example. @return : 0, or an error code (which can be tested using ZSTD_isError()). @@ -1520,11 +1538,11 @@ size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
Advanced Streaming compression functions
-size_t -ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); -This function is deprecated, and equivalent to: +
This function is DEPRECATED, and equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); @@ -1533,15 +1551,15 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, pledgedSrcSize must be correct. If it is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, "0" also disables frame content size field. It may be enabled in the future. - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t -ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); -This function is deprecated, and is equivalent to: +
This function is DEPRECATED, and is equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); @@ -1550,16 +1568,16 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, dict == NULL or dictSize < 8, in which case no dict is used. Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy. - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t -ZSTD_initCStream_advanced(ZSTD_CStream* zcs, +ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); -This function is deprecated, and is approximately equivalent to: +
This function is DEPRECATED, and is approximately equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); // Pseudocode: Set each zstd parameter and leave the rest as-is. for ((param, value) : params) { @@ -1571,22 +1589,23 @@ ZSTD_initCStream_advanced(ZSTD_CStream* zcs, dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); -This function is deprecated, and equivalent to: +
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions") +size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); +This function is DEPRECATED, and equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); ZSTD_CCtx_refCDict(zcs, cdict); - + note : cdict will just be referenced, and must outlive compression session - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t -ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, +ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions") +size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); @@ -1602,18 +1621,18 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, same as ZSTD_initCStream_usingCDict(), with control over frame parameters. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
-size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); -This function is deprecated, and is equivalent to: +
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions") +size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); +This function is DEPRECATED, and is equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - - Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but - ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be - explicitly specified. + Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but + ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be + explicitly specified. start a new frame, using same parameters from previous frame. This is typically useful to skip dictionary loading stage, since it will re-use it in-place. @@ -1623,7 +1642,7 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. @return : 0, or an error code (which can be tested using ZSTD_isError()) - Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x + This prototype will generate compilation warnings.
@@ -1694,8 +1713,7 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, ZSTD_CCtx object can be re-used multiple times within successive compression operations. Start by initializing a context. - Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression, - or ZSTD_compressBegin_advanced(), for finer parameter control. + Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression. It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx() Then, consume your input using ZSTD_compressContinue(). @@ -1719,11 +1737,11 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,Buffer-less streaming compression functions
size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); -size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);/**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */ -size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */ size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
+size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ +
Buffer-less streaming decompression (synchronous mode)
A ZSTD_DCtx object is required to track streaming operations. Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it. diff --git a/lib/zstd.h b/lib/zstd.h index fbc4a98d4..f479a5200 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -71,8 +71,8 @@ extern "C" { /*------ Version ------*/ #define ZSTD_VERSION_MAJOR 1 -#define ZSTD_VERSION_MINOR 4 -#define ZSTD_VERSION_RELEASE 10 +#define ZSTD_VERSION_MINOR 5 +#define ZSTD_VERSION_RELEASE 0 #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) /*! ZSTD_versionNumber() : -- 2.47.2