zstdlib 0.7.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -0
- data/README.md +7 -1
- data/Rakefile +38 -8
- data/ext/{zstdlib → zstdlib_c}/extconf.rb +11 -6
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/adler32.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/compress.c +0 -0
- data/ext/zstdlib_c/zlib-1.2.12/crc32.c +1116 -0
- data/ext/zstdlib_c/zlib-1.2.12/crc32.h +9446 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/deflate.c +78 -30
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/deflate.h +12 -15
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzclose.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzguts.h +3 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzlib.c +5 -3
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzread.c +5 -7
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzwrite.c +25 -13
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/infback.c +2 -1
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffast.c +14 -14
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffast.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffixed.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inflate.c +39 -8
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inflate.h +3 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inftrees.c +3 -3
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inftrees.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/trees.c +27 -48
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/trees.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/uncompr.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zconf.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zlib.h +123 -100
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zutil.c +2 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zutil.h +12 -9
- data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +46 -22
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +1 -3
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/debug.c +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +12 -19
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +2 -1
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +41 -12
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +139 -22
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +47 -23
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +87 -98
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +34 -23
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +4 -4
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +6 -5
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +0 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +10 -10
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_internal.h +191 -145
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +89 -46
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +27 -29
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +2 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress.c +2917 -868
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +458 -125
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +12 -11
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +4 -2
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +41 -18
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.c +26 -298
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +234 -83
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +313 -138
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +329 -150
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +1 -1
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +321 -216
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +9 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +412 -166
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +169 -453
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/huf_decompress.c +1044 -403
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +9 -9
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +2 -2
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +450 -105
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.c +913 -273
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +14 -5
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +59 -12
- data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +699 -214
- data/ext/{zstdlib/zstd-1.4.5/lib/common → zstdlib_c/zstd-1.5.2/lib}/zstd_errors.h +2 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +133 -44
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +1 -1
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/zstdlib.rb +2 -2
- metadata +118 -109
- data/ext/zstdlib/zlib-1.2.11/crc32.c +0 -442
- data/ext/zstdlib/zlib-1.2.11/crc32.h +0 -441
- data/ext/zstdlib/zstd-1.4.5/lib/common/compiler.h +0 -175
- data/ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c +0 -216
- data/ext/zstdlib/zstd-1.4.5/lib/common/error_private.h +0 -80
- data/ext/zstdlib/zstd-1.4.5/lib/common/xxhash.c +0 -864
- data/ext/zstdlib/zstd-1.4.5/lib/common/xxhash.h +0 -285
- data/ext/zstdlib/zstd-1.4.5/lib/compress/huf_compress.c +0 -798
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c +0 -1138
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h +0 -67
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h +0 -192
- data/ext/zstdlib/zstd.mk +0 -14
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
@@ -20,19 +20,21 @@ extern "C" {
|
|
20
20
|
|
21
21
|
|
22
22
|
/* ===== ZSTDLIB_API : control library symbols visibility ===== */
|
23
|
-
#ifndef
|
24
|
-
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
25
|
-
# define
|
23
|
+
#ifndef ZSTDLIB_VISIBLE
|
24
|
+
# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
25
|
+
# define ZSTDLIB_VISIBLE __attribute__ ((visibility ("default")))
|
26
|
+
# define ZSTDLIB_HIDDEN __attribute__ ((visibility ("hidden")))
|
26
27
|
# else
|
27
|
-
# define
|
28
|
+
# define ZSTDLIB_VISIBLE
|
29
|
+
# define ZSTDLIB_HIDDEN
|
28
30
|
# endif
|
29
31
|
#endif
|
30
32
|
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
31
|
-
# define ZSTDLIB_API __declspec(dllexport)
|
33
|
+
# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBLE
|
32
34
|
#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
33
|
-
# define ZSTDLIB_API __declspec(dllimport)
|
35
|
+
# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
34
36
|
#else
|
35
|
-
# define ZSTDLIB_API
|
37
|
+
# define ZSTDLIB_API ZSTDLIB_VISIBLE
|
36
38
|
#endif
|
37
39
|
|
38
40
|
|
@@ -71,17 +73,22 @@ extern "C" {
|
|
71
73
|
|
72
74
|
/*------ Version ------*/
|
73
75
|
#define ZSTD_VERSION_MAJOR 1
|
74
|
-
#define ZSTD_VERSION_MINOR
|
75
|
-
#define ZSTD_VERSION_RELEASE
|
76
|
-
|
76
|
+
#define ZSTD_VERSION_MINOR 5
|
77
|
+
#define ZSTD_VERSION_RELEASE 2
|
77
78
|
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
|
78
|
-
|
79
|
+
|
80
|
+
/*! ZSTD_versionNumber() :
|
81
|
+
* Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */
|
82
|
+
ZSTDLIB_API unsigned ZSTD_versionNumber(void);
|
79
83
|
|
80
84
|
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
|
81
85
|
#define ZSTD_QUOTE(str) #str
|
82
86
|
#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
|
83
87
|
#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
|
84
|
-
|
88
|
+
|
89
|
+
/*! ZSTD_versionString() :
|
90
|
+
* Return runtime library version, like "1.4.5". Requires v1.3.0+. */
|
91
|
+
ZSTDLIB_API const char* ZSTD_versionString(void);
|
85
92
|
|
86
93
|
/* *************************************
|
87
94
|
* Default constant
|
@@ -104,7 +111,6 @@ ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
|
|
104
111
|
#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
|
105
112
|
|
106
113
|
|
107
|
-
|
108
114
|
/***************************************
|
109
115
|
* Simple API
|
110
116
|
***************************************/
|
@@ -161,7 +167,7 @@ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t
|
|
161
167
|
* @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
|
162
168
|
ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
|
163
169
|
|
164
|
-
/*! ZSTD_findFrameCompressedSize() :
|
170
|
+
/*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+
|
165
171
|
* `src` should point to the start of a ZSTD frame or skippable frame.
|
166
172
|
* `srcSize` must be >= first frame size
|
167
173
|
* @return : the compressed size of the first frame starting at `src`,
|
@@ -175,8 +181,9 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
|
|
175
181
|
ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
|
176
182
|
ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
177
183
|
ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
|
178
|
-
ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */
|
184
|
+
ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
|
179
185
|
ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
|
186
|
+
ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
|
180
187
|
|
181
188
|
|
182
189
|
/***************************************
|
@@ -194,7 +201,7 @@ ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compres
|
|
194
201
|
*/
|
195
202
|
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
|
196
203
|
ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
|
197
|
-
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
|
204
|
+
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
|
198
205
|
|
199
206
|
/*! ZSTD_compressCCtx() :
|
200
207
|
* Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
|
@@ -217,7 +224,7 @@ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
|
|
217
224
|
* Use one context per thread for parallel execution. */
|
218
225
|
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
219
226
|
ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
|
220
|
-
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
|
227
|
+
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */
|
221
228
|
|
222
229
|
/*! ZSTD_decompressDCtx() :
|
223
230
|
* Same as ZSTD_decompress(),
|
@@ -229,9 +236,9 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
|
|
229
236
|
const void* src, size_t srcSize);
|
230
237
|
|
231
238
|
|
232
|
-
|
233
|
-
* Advanced compression API
|
234
|
-
|
239
|
+
/*********************************************
|
240
|
+
* Advanced compression API (Requires v1.4.0+)
|
241
|
+
**********************************************/
|
235
242
|
|
236
243
|
/* API design :
|
237
244
|
* Parameters are pushed one by one into an existing context,
|
@@ -242,7 +249,7 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
|
|
242
249
|
*
|
243
250
|
* It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
|
244
251
|
*
|
245
|
-
* This API
|
252
|
+
* This API supersedes all other "advanced" API entry points in the experimental section.
|
246
253
|
* In the future, we expect to remove from experimental API entry points which are redundant with this API.
|
247
254
|
*/
|
248
255
|
|
@@ -261,7 +268,6 @@ typedef enum { ZSTD_fast=1,
|
|
261
268
|
Only the order (from fast to strong) is guaranteed */
|
262
269
|
} ZSTD_strategy;
|
263
270
|
|
264
|
-
|
265
271
|
typedef enum {
|
266
272
|
|
267
273
|
/* compression parameters
|
@@ -327,14 +333,15 @@ typedef enum {
|
|
327
333
|
* The higher the value of selected strategy, the more complex it is,
|
328
334
|
* resulting in stronger and slower compression.
|
329
335
|
* Special: value 0 means "use default strategy". */
|
330
|
-
|
331
336
|
/* LDM mode parameters */
|
332
337
|
ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
|
333
338
|
* This parameter is designed to improve compression ratio
|
334
339
|
* for large inputs, by finding large matches at long distance.
|
335
340
|
* It increases memory usage and window size.
|
336
341
|
* Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
|
337
|
-
* except when expressly set to a different value.
|
342
|
+
* except when expressly set to a different value.
|
343
|
+
* Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
|
344
|
+
* compression strategy >= ZSTD_btopt (== compression level 16+) */
|
338
345
|
ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
|
339
346
|
* Larger values increase memory usage and compression ratio,
|
340
347
|
* but decrease compression speed.
|
@@ -365,20 +372,24 @@ typedef enum {
|
|
365
372
|
ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
|
366
373
|
|
367
374
|
/* multi-threading parameters */
|
368
|
-
/* These parameters are only
|
369
|
-
*
|
375
|
+
/* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
|
376
|
+
* Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
|
377
|
+
* In a situation where it's unknown if the linked library supports multi-threading or not,
|
378
|
+
* setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
|
379
|
+
*/
|
370
380
|
ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
|
371
|
-
* When nbWorkers >= 1, triggers asynchronous mode when
|
381
|
+
* When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
|
372
382
|
* ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
|
373
|
-
* while compression
|
383
|
+
* while compression is performed in parallel, within worker thread(s).
|
374
384
|
* (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
|
375
385
|
* in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
|
376
386
|
* More workers improve speed, but also increase memory usage.
|
377
|
-
* Default value is `0`, aka "single-threaded mode" : no worker is spawned,
|
387
|
+
* Default value is `0`, aka "single-threaded mode" : no worker is spawned,
|
388
|
+
* compression is performed inside Caller's thread, and all invocations are blocking */
|
378
389
|
ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
|
379
390
|
* Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
|
380
391
|
* 0 means default, which is dynamically determined based on compression parameters.
|
381
|
-
* Job size must be a minimum of overlap size, or
|
392
|
+
* Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
|
382
393
|
* The minimum size is automatically and transparently enforced. */
|
383
394
|
ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
|
384
395
|
* The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
|
@@ -403,6 +414,13 @@ typedef enum {
|
|
403
414
|
* ZSTD_c_literalCompressionMode
|
404
415
|
* ZSTD_c_targetCBlockSize
|
405
416
|
* ZSTD_c_srcSizeHint
|
417
|
+
* ZSTD_c_enableDedicatedDictSearch
|
418
|
+
* ZSTD_c_stableInBuffer
|
419
|
+
* ZSTD_c_stableOutBuffer
|
420
|
+
* ZSTD_c_blockDelimiters
|
421
|
+
* ZSTD_c_validateSequences
|
422
|
+
* ZSTD_c_useBlockSplitter
|
423
|
+
* ZSTD_c_useRowMatchFinder
|
406
424
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
407
425
|
* note : never ever use experimentalParam? names directly;
|
408
426
|
* also, the enums values themselves are unstable and can still change.
|
@@ -413,7 +431,15 @@ typedef enum {
|
|
413
431
|
ZSTD_c_experimentalParam4=1001,
|
414
432
|
ZSTD_c_experimentalParam5=1002,
|
415
433
|
ZSTD_c_experimentalParam6=1003,
|
416
|
-
ZSTD_c_experimentalParam7=1004
|
434
|
+
ZSTD_c_experimentalParam7=1004,
|
435
|
+
ZSTD_c_experimentalParam8=1005,
|
436
|
+
ZSTD_c_experimentalParam9=1006,
|
437
|
+
ZSTD_c_experimentalParam10=1007,
|
438
|
+
ZSTD_c_experimentalParam11=1008,
|
439
|
+
ZSTD_c_experimentalParam12=1009,
|
440
|
+
ZSTD_c_experimentalParam13=1010,
|
441
|
+
ZSTD_c_experimentalParam14=1011,
|
442
|
+
ZSTD_c_experimentalParam15=1012
|
417
443
|
} ZSTD_cParameter;
|
418
444
|
|
419
445
|
typedef struct {
|
@@ -498,9 +524,9 @@ ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
|
|
498
524
|
const void* src, size_t srcSize);
|
499
525
|
|
500
526
|
|
501
|
-
|
502
|
-
* Advanced decompression API
|
503
|
-
|
527
|
+
/***********************************************
|
528
|
+
* Advanced decompression API (Requires v1.4.0+)
|
529
|
+
************************************************/
|
504
530
|
|
505
531
|
/* The advanced API pushes parameters one by one into an existing DCtx context.
|
506
532
|
* Parameters are sticky, and remain valid for all following frames
|
@@ -524,11 +550,15 @@ typedef enum {
|
|
524
550
|
* At the time of this writing, they include :
|
525
551
|
* ZSTD_d_format
|
526
552
|
* ZSTD_d_stableOutBuffer
|
553
|
+
* ZSTD_d_forceIgnoreChecksum
|
554
|
+
* ZSTD_d_refMultipleDDicts
|
527
555
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
528
556
|
* note : never ever use experimentalParam? names directly
|
529
557
|
*/
|
530
558
|
ZSTD_d_experimentalParam1=1000,
|
531
|
-
ZSTD_d_experimentalParam2=1001
|
559
|
+
ZSTD_d_experimentalParam2=1001,
|
560
|
+
ZSTD_d_experimentalParam3=1002,
|
561
|
+
ZSTD_d_experimentalParam4=1003
|
532
562
|
|
533
563
|
} ZSTD_dParameter;
|
534
564
|
|
@@ -642,7 +672,7 @@ typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same
|
|
642
672
|
/* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
|
643
673
|
/*===== ZSTD_CStream management functions =====*/
|
644
674
|
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
|
645
|
-
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
|
675
|
+
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */
|
646
676
|
|
647
677
|
/*===== Streaming compression functions =====*/
|
648
678
|
typedef enum {
|
@@ -658,14 +688,15 @@ typedef enum {
|
|
658
688
|
: note : multithreaded compression will block to flush as much output as possible. */
|
659
689
|
} ZSTD_EndDirective;
|
660
690
|
|
661
|
-
/*! ZSTD_compressStream2() :
|
691
|
+
/*! ZSTD_compressStream2() : Requires v1.4.0+
|
662
692
|
* Behaves about the same as ZSTD_compressStream, with additional control on end directive.
|
663
693
|
* - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
|
664
694
|
* - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
|
665
695
|
* - output->pos must be <= dstCapacity, input->pos must be <= srcSize
|
666
696
|
* - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
|
697
|
+
* - endOp must be a valid directive
|
667
698
|
* - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
|
668
|
-
* - When nbWorkers>=1, function is non-blocking : it
|
699
|
+
* - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available,
|
669
700
|
* and then immediately returns, just indicating that there is some data remaining to be flushed.
|
670
701
|
* The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
|
671
702
|
* - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.
|
@@ -703,11 +734,11 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
|
|
703
734
|
|
704
735
|
|
705
736
|
/* *****************************************************************************
|
706
|
-
* This following is a legacy streaming API.
|
737
|
+
* This following is a legacy streaming API, available since v1.0+ .
|
707
738
|
* It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
|
708
739
|
* It is redundant, but remains fully supported.
|
709
|
-
*
|
710
|
-
* new API.
|
740
|
+
* Streaming in combination with advanced parameters and dictionary compression
|
741
|
+
* can only be used through the new API.
|
711
742
|
******************************************************************************/
|
712
743
|
|
713
744
|
/*!
|
@@ -762,7 +793,7 @@ typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same
|
|
762
793
|
/* For compatibility with versions <= v1.2.0, prefer differentiating them. */
|
763
794
|
/*===== ZSTD_DStream management functions =====*/
|
764
795
|
ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
|
765
|
-
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
|
796
|
+
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */
|
766
797
|
|
767
798
|
/*===== Streaming decompression functions =====*/
|
768
799
|
|
@@ -785,7 +816,7 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
|
|
785
816
|
/*! ZSTD_compress_usingDict() :
|
786
817
|
* Compression at an explicit compression level using a Dictionary.
|
787
818
|
* A dictionary can be any arbitrary data segment (also called a prefix),
|
788
|
-
* or a buffer with specified information (see
|
819
|
+
* or a buffer with specified information (see zdict.h).
|
789
820
|
* Note : This function loads the dictionary, resulting in significant startup delay.
|
790
821
|
* It's intended for a dictionary used only once.
|
791
822
|
* Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */
|
@@ -828,7 +859,8 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize
|
|
828
859
|
int compressionLevel);
|
829
860
|
|
830
861
|
/*! ZSTD_freeCDict() :
|
831
|
-
* Function frees memory allocated by ZSTD_createCDict().
|
862
|
+
* Function frees memory allocated by ZSTD_createCDict().
|
863
|
+
* If a NULL pointer is passed, no operation is performed. */
|
832
864
|
ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
|
833
865
|
|
834
866
|
/*! ZSTD_compress_usingCDict() :
|
@@ -850,7 +882,8 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
|
|
850
882
|
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
|
851
883
|
|
852
884
|
/*! ZSTD_freeDDict() :
|
853
|
-
* Function frees memory allocated with ZSTD_createDDict()
|
885
|
+
* Function frees memory allocated with ZSTD_createDDict()
|
886
|
+
* If a NULL pointer is passed, no operation is performed. */
|
854
887
|
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
|
855
888
|
|
856
889
|
/*! ZSTD_decompress_usingDDict() :
|
@@ -866,19 +899,25 @@ ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
|
|
866
899
|
* Dictionary helper functions
|
867
900
|
*******************************/
|
868
901
|
|
869
|
-
/*! ZSTD_getDictID_fromDict() :
|
902
|
+
/*! ZSTD_getDictID_fromDict() : Requires v1.4.0+
|
870
903
|
* Provides the dictID stored within dictionary.
|
871
904
|
* if @return == 0, the dictionary is not conformant with Zstandard specification.
|
872
905
|
* It can still be loaded, but as a content-only dictionary. */
|
873
906
|
ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
|
874
907
|
|
875
|
-
/*!
|
908
|
+
/*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+
|
909
|
+
* Provides the dictID of the dictionary loaded into `cdict`.
|
910
|
+
* If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
|
911
|
+
* Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
|
912
|
+
ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
|
913
|
+
|
914
|
+
/*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+
|
876
915
|
* Provides the dictID of the dictionary loaded into `ddict`.
|
877
916
|
* If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
|
878
917
|
* Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
|
879
918
|
ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
|
880
919
|
|
881
|
-
/*! ZSTD_getDictID_fromFrame() :
|
920
|
+
/*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+
|
882
921
|
* Provides the dictID required to decompressed the frame stored within `src`.
|
883
922
|
* If @return == 0, the dictID could not be decoded.
|
884
923
|
* This could for one of the following reasons :
|
@@ -892,16 +931,16 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
892
931
|
|
893
932
|
|
894
933
|
/*******************************************************************************
|
895
|
-
* Advanced dictionary and prefix API
|
934
|
+
* Advanced dictionary and prefix API (Requires v1.4.0+)
|
896
935
|
*
|
897
936
|
* This API allows dictionaries to be used with ZSTD_compress2(),
|
898
|
-
* ZSTD_compressStream2(), and
|
937
|
+
* ZSTD_compressStream2(), and ZSTD_decompressDCtx(). Dictionaries are sticky, and
|
899
938
|
* only reset with the context is reset with ZSTD_reset_parameters or
|
900
939
|
* ZSTD_reset_session_and_parameters. Prefixes are single-use.
|
901
940
|
******************************************************************************/
|
902
941
|
|
903
942
|
|
904
|
-
/*! ZSTD_CCtx_loadDictionary() :
|
943
|
+
/*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+
|
905
944
|
* Create an internal CDict from `dict` buffer.
|
906
945
|
* Decompression will have to use same dictionary.
|
907
946
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
@@ -920,11 +959,11 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
920
959
|
* to precisely select how dictionary content must be interpreted. */
|
921
960
|
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
|
922
961
|
|
923
|
-
/*! ZSTD_CCtx_refCDict() :
|
962
|
+
/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
|
924
963
|
* Reference a prepared dictionary, to be used for all next compressed frames.
|
925
964
|
* Note that compression parameters are enforced from within CDict,
|
926
965
|
* and supersede any compression parameter previously set within CCtx.
|
927
|
-
* The parameters ignored are
|
966
|
+
* The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
|
928
967
|
* The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.
|
929
968
|
* The dictionary will remain valid for future compressed frames using same CCtx.
|
930
969
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
@@ -934,7 +973,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
|
|
934
973
|
* Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */
|
935
974
|
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
|
936
975
|
|
937
|
-
/*! ZSTD_CCtx_refPrefix() :
|
976
|
+
/*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+
|
938
977
|
* Reference a prefix (single-usage dictionary) for next compressed frame.
|
939
978
|
* A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
|
940
979
|
* Decompression will need same prefix to properly regenerate data.
|
@@ -955,7 +994,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
|
|
955
994
|
ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
956
995
|
const void* prefix, size_t prefixSize);
|
957
996
|
|
958
|
-
/*! ZSTD_DCtx_loadDictionary() :
|
997
|
+
/*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
|
959
998
|
* Create an internal DDict from dict buffer,
|
960
999
|
* to be used to decompress next frames.
|
961
1000
|
* The dictionary remains valid for all future frames, until explicitly invalidated.
|
@@ -972,9 +1011,16 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
|
972
1011
|
*/
|
973
1012
|
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
974
1013
|
|
975
|
-
/*! ZSTD_DCtx_refDDict() :
|
1014
|
+
/*! ZSTD_DCtx_refDDict() : Requires v1.4.0+
|
976
1015
|
* Reference a prepared dictionary, to be used to decompress next frames.
|
977
1016
|
* The dictionary remains active for decompression of future frames using same DCtx.
|
1017
|
+
*
|
1018
|
+
* If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
|
1019
|
+
* will store the DDict references in a table, and the DDict used for decompression
|
1020
|
+
* will be determined at decompression time, as per the dict ID in the frame.
|
1021
|
+
* The memory for the table is allocated on the first call to refDDict, and can be
|
1022
|
+
* freed with ZSTD_freeDCtx().
|
1023
|
+
*
|
978
1024
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
979
1025
|
* Note 1 : Currently, only one dictionary can be managed.
|
980
1026
|
* Referencing a new dictionary effectively "discards" any previous one.
|
@@ -983,7 +1029,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
|
|
983
1029
|
*/
|
984
1030
|
ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
985
1031
|
|
986
|
-
/*! ZSTD_DCtx_refPrefix() :
|
1032
|
+
/*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+
|
987
1033
|
* Reference a prefix (single-usage dictionary) to decompress next frame.
|
988
1034
|
* This is the reverse operation of ZSTD_CCtx_refPrefix(),
|
989
1035
|
* and must use the same prefix as the one used during compression.
|
@@ -1004,7 +1050,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
|
|
1004
1050
|
|
1005
1051
|
/* === Memory management === */
|
1006
1052
|
|
1007
|
-
/*! ZSTD_sizeof_*() :
|
1053
|
+
/*! ZSTD_sizeof_*() : Requires v1.4.0+
|
1008
1054
|
* These functions give the _current_ memory usage of selected object.
|
1009
1055
|
* Note that object memory usage can evolve (increase or decrease) over time. */
|
1010
1056
|
ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
|
@@ -1029,6 +1075,39 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|
1029
1075
|
#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
|
1030
1076
|
#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
|
1031
1077
|
|
1078
|
+
/* This can be overridden externally to hide static symbols. */
|
1079
|
+
#ifndef ZSTDLIB_STATIC_API
|
1080
|
+
# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
1081
|
+
# define ZSTDLIB_STATIC_API __declspec(dllexport) ZSTDLIB_VISIBLE
|
1082
|
+
# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
1083
|
+
# define ZSTDLIB_STATIC_API __declspec(dllimport) ZSTDLIB_VISIBLE
|
1084
|
+
# else
|
1085
|
+
# define ZSTDLIB_STATIC_API ZSTDLIB_VISIBLE
|
1086
|
+
# endif
|
1087
|
+
#endif
|
1088
|
+
|
1089
|
+
/* Deprecation warnings :
|
1090
|
+
* Should these warnings be a problem, it is generally possible to disable them,
|
1091
|
+
* typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual.
|
1092
|
+
* Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS.
|
1093
|
+
*/
|
1094
|
+
#ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS
|
1095
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API /* disable deprecation warnings */
|
1096
|
+
#else
|
1097
|
+
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
1098
|
+
# define ZSTD_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_STATIC_API
|
1099
|
+
# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
|
1100
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated(message)))
|
1101
|
+
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
1102
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated))
|
1103
|
+
# elif defined(_MSC_VER)
|
1104
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __declspec(deprecated(message))
|
1105
|
+
# else
|
1106
|
+
# pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler")
|
1107
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API
|
1108
|
+
# endif
|
1109
|
+
#endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */
|
1110
|
+
|
1032
1111
|
/****************************************************************************************
|
1033
1112
|
* experimental API (static linking only)
|
1034
1113
|
****************************************************************************************
|
@@ -1091,30 +1170,46 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|
1091
1170
|
#define ZSTD_SRCSIZEHINT_MIN 0
|
1092
1171
|
#define ZSTD_SRCSIZEHINT_MAX INT_MAX
|
1093
1172
|
|
1094
|
-
/* internal */
|
1095
|
-
#define ZSTD_HASHLOG3_MAX 17
|
1096
|
-
|
1097
1173
|
|
1098
1174
|
/* --- Advanced types --- */
|
1099
1175
|
|
1100
1176
|
typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
|
1101
1177
|
|
1102
1178
|
typedef struct {
|
1103
|
-
unsigned int
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1179
|
+
unsigned int offset; /* The offset of the match. (NOT the same as the offset code)
|
1180
|
+
* If offset == 0 and matchLength == 0, this sequence represents the last
|
1181
|
+
* literals in the block of litLength size.
|
1182
|
+
*/
|
1183
|
+
|
1184
|
+
unsigned int litLength; /* Literal length of the sequence. */
|
1185
|
+
unsigned int matchLength; /* Match length of the sequence. */
|
1186
|
+
|
1187
|
+
/* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
|
1188
|
+
* In this case, we will treat the sequence as a marker for a block boundary.
|
1189
|
+
*/
|
1190
|
+
|
1191
|
+
unsigned int rep; /* Represents which repeat offset is represented by the field 'offset'.
|
1192
|
+
* Ranges from [0, 3].
|
1193
|
+
*
|
1194
|
+
* Repeat offsets are essentially previous offsets from previous sequences sorted in
|
1195
|
+
* recency order. For more detail, see doc/zstd_compression_format.md
|
1196
|
+
*
|
1197
|
+
* If rep == 0, then 'offset' does not contain a repeat offset.
|
1198
|
+
* If rep > 0:
|
1199
|
+
* If litLength != 0:
|
1200
|
+
* rep == 1 --> offset == repeat_offset_1
|
1201
|
+
* rep == 2 --> offset == repeat_offset_2
|
1202
|
+
* rep == 3 --> offset == repeat_offset_3
|
1203
|
+
* If litLength == 0:
|
1204
|
+
* rep == 1 --> offset == repeat_offset_2
|
1205
|
+
* rep == 2 --> offset == repeat_offset_3
|
1206
|
+
* rep == 3 --> offset == repeat_offset_1 - 1
|
1207
|
+
*
|
1208
|
+
* Note: This field is optional. ZSTD_generateSequences() will calculate the value of
|
1209
|
+
* 'rep', but repeat offsets do not necessarily need to be calculated from an external
|
1210
|
+
* sequence provider's perspective. For example, ZSTD_compressSequences() does not
|
1211
|
+
* use this 'rep' field at all (as of now).
|
1212
|
+
*/
|
1118
1213
|
} ZSTD_Sequence;
|
1119
1214
|
|
1120
1215
|
typedef struct {
|
@@ -1156,6 +1251,18 @@ typedef enum {
|
|
1156
1251
|
* Decoder cannot recognise automatically this format, requiring this instruction. */
|
1157
1252
|
} ZSTD_format_e;
|
1158
1253
|
|
1254
|
+
typedef enum {
|
1255
|
+
/* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
|
1256
|
+
ZSTD_d_validateChecksum = 0,
|
1257
|
+
ZSTD_d_ignoreChecksum = 1
|
1258
|
+
} ZSTD_forceIgnoreChecksum_e;
|
1259
|
+
|
1260
|
+
typedef enum {
|
1261
|
+
/* Note: this enum controls ZSTD_d_refMultipleDDicts */
|
1262
|
+
ZSTD_rmd_refSingleDDict = 0,
|
1263
|
+
ZSTD_rmd_refMultipleDDicts = 1
|
1264
|
+
} ZSTD_refMultipleDDicts_e;
|
1265
|
+
|
1159
1266
|
typedef enum {
|
1160
1267
|
/* Note: this enum and the behavior it controls are effectively internal
|
1161
1268
|
* implementation details of the compressor. They are expected to continue
|
@@ -1204,6 +1311,15 @@ typedef enum {
|
|
1204
1311
|
ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */
|
1205
1312
|
} ZSTD_literalCompressionMode_e;
|
1206
1313
|
|
1314
|
+
typedef enum {
|
1315
|
+
/* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final
|
1316
|
+
* decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
|
1317
|
+
* or ZSTD_ps_disable allow for a force enable/disable the feature.
|
1318
|
+
*/
|
1319
|
+
ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */
|
1320
|
+
ZSTD_ps_enable = 1, /* Force-enable the feature */
|
1321
|
+
ZSTD_ps_disable = 2 /* Do not use the feature */
|
1322
|
+
} ZSTD_paramSwitch_e;
|
1207
1323
|
|
1208
1324
|
/***************************************
|
1209
1325
|
* Frame size functions
|
@@ -1230,14 +1346,14 @@ typedef enum {
|
|
1230
1346
|
* note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
|
1231
1347
|
* read each contained frame header. This is fast as most of the data is skipped,
|
1232
1348
|
* however it does mean that all frame data must be present and valid. */
|
1233
|
-
|
1349
|
+
ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
|
1234
1350
|
|
1235
1351
|
/*! ZSTD_decompressBound() :
|
1236
1352
|
* `src` should point to the start of a series of ZSTD encoded and/or skippable frames
|
1237
1353
|
* `srcSize` must be the _exact_ size of this series
|
1238
1354
|
* (i.e. there should be a frame boundary at `src + srcSize`)
|
1239
1355
|
* @return : - upper-bound for the decompressed size of all data in all successive frames
|
1240
|
-
* - if an error
|
1356
|
+
* - if an error occurred: ZSTD_CONTENTSIZE_ERROR
|
1241
1357
|
*
|
1242
1358
|
* note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame.
|
1243
1359
|
* note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`.
|
@@ -1245,22 +1361,119 @@ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t
|
|
1245
1361
|
* note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by:
|
1246
1362
|
* upper-bound = # blocks * min(128 KB, Window_Size)
|
1247
1363
|
*/
|
1248
|
-
|
1364
|
+
ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
|
1249
1365
|
|
1250
1366
|
/*! ZSTD_frameHeaderSize() :
|
1251
1367
|
* srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX.
|
1252
1368
|
* @return : size of the Frame Header,
|
1253
1369
|
* or an error code (if srcSize is too small) */
|
1254
|
-
|
1370
|
+
ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
1255
1371
|
|
1256
|
-
|
1257
|
-
|
1372
|
+
typedef enum {
|
1373
|
+
ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
|
1374
|
+
ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
1375
|
+
} ZSTD_sequenceFormat_e;
|
1376
|
+
|
1377
|
+
/*! ZSTD_generateSequences() :
|
1378
|
+
* Generate sequences using ZSTD_compress2, given a source buffer.
|
1379
|
+
*
|
1380
|
+
* Each block will end with a dummy sequence
|
1381
|
+
* with offset == 0, matchLength == 0, and litLength == length of last literals.
|
1382
|
+
* litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
|
1383
|
+
* simply acts as a block delimiter.
|
1384
|
+
*
|
1258
1385
|
* zc can be used to insert custom compression params.
|
1259
1386
|
* This function invokes ZSTD_compress2
|
1260
|
-
*
|
1387
|
+
*
|
1388
|
+
* The output of this function can be fed into ZSTD_compressSequences() with CCtx
|
1389
|
+
* setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
|
1390
|
+
* @return : number of sequences generated
|
1261
1391
|
*/
|
1262
|
-
|
1263
|
-
|
1392
|
+
|
1393
|
+
ZSTDLIB_STATIC_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
1394
|
+
size_t outSeqsSize, const void* src, size_t srcSize);
|
1395
|
+
|
1396
|
+
/*! ZSTD_mergeBlockDelimiters() :
|
1397
|
+
* Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
|
1398
|
+
* by merging them into into the literals of the next sequence.
|
1399
|
+
*
|
1400
|
+
* As such, the final generated result has no explicit representation of block boundaries,
|
1401
|
+
* and the final last literals segment is not represented in the sequences.
|
1402
|
+
*
|
1403
|
+
* The output of this function can be fed into ZSTD_compressSequences() with CCtx
|
1404
|
+
* setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters
|
1405
|
+
* @return : number of sequences left after merging
|
1406
|
+
*/
|
1407
|
+
ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
1408
|
+
|
1409
|
+
/*! ZSTD_compressSequences() :
|
1410
|
+
* Compress an array of ZSTD_Sequence, generated from the original source buffer, into dst.
|
1411
|
+
* If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
|
1412
|
+
* The entire source is compressed into a single frame.
|
1413
|
+
*
|
1414
|
+
* The compression behavior changes based on cctx params. In particular:
|
1415
|
+
* If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain
|
1416
|
+
* no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on
|
1417
|
+
* the block size derived from the cctx, and sequences may be split. This is the default setting.
|
1418
|
+
*
|
1419
|
+
* If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
|
1420
|
+
* block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
|
1421
|
+
*
|
1422
|
+
* If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
|
1423
|
+
* behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
|
1424
|
+
* specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
|
1425
|
+
*
|
1426
|
+
* In addition to the two adjustable experimental params, there are other important cctx params.
|
1427
|
+
* - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN.
|
1428
|
+
* - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression.
|
1429
|
+
* - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
|
1430
|
+
* is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
|
1431
|
+
*
|
1432
|
+
* Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
|
1433
|
+
* Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
|
1434
|
+
* and cannot emit an RLE block that disagrees with the repcode history
|
1435
|
+
* @return : final compressed size or a ZSTD error.
|
1436
|
+
*/
|
1437
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
|
1438
|
+
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
1439
|
+
const void* src, size_t srcSize);
|
1440
|
+
|
1441
|
+
|
1442
|
+
/*! ZSTD_writeSkippableFrame() :
|
1443
|
+
* Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
1444
|
+
*
|
1445
|
+
* Skippable frames begin with a a 4-byte magic number. There are 16 possible choices of magic number,
|
1446
|
+
* ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
|
1447
|
+
* As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
|
1448
|
+
* the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
|
1449
|
+
*
|
1450
|
+
* Returns an error if destination buffer is not large enough, if the source size is not representable
|
1451
|
+
* with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
|
1452
|
+
*
|
1453
|
+
* @return : number of bytes written or a ZSTD error.
|
1454
|
+
*/
|
1455
|
+
ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
|
1456
|
+
const void* src, size_t srcSize, unsigned magicVariant);
|
1457
|
+
|
1458
|
+
/*! ZSTD_readSkippableFrame() :
|
1459
|
+
* Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
1460
|
+
*
|
1461
|
+
* The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
|
1462
|
+
* i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
|
1463
|
+
* in the magicVariant.
|
1464
|
+
*
|
1465
|
+
* Returns an error if destination buffer is not large enough, or if the frame is not skippable.
|
1466
|
+
*
|
1467
|
+
* @return : number of bytes written or a ZSTD error.
|
1468
|
+
*/
|
1469
|
+
ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
|
1470
|
+
const void* src, size_t srcSize);
|
1471
|
+
|
1472
|
+
/*! ZSTD_isSkippableFrame() :
|
1473
|
+
* Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
|
1474
|
+
*/
|
1475
|
+
ZSTDLIB_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
|
1476
|
+
|
1264
1477
|
|
1265
1478
|
|
1266
1479
|
/***************************************
|
@@ -1290,10 +1503,10 @@ ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
|
1290
1503
|
* Note 2 : only single-threaded compression is supported.
|
1291
1504
|
* ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.
|
1292
1505
|
*/
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1506
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
|
1507
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
|
1508
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
1509
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void);
|
1297
1510
|
|
1298
1511
|
/*! ZSTD_estimateCStreamSize() :
|
1299
1512
|
* ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
|
@@ -1308,20 +1521,20 @@ ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
|
|
1308
1521
|
* Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
|
1309
1522
|
* an internal ?Dict will be created, which additional size is not estimated here.
|
1310
1523
|
* In this case, get total size by adding ZSTD_estimate?DictSize */
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1524
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
|
1525
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
|
1526
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
|
1527
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
|
1528
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
|
1316
1529
|
|
1317
1530
|
/*! ZSTD_estimate?DictSize() :
|
1318
1531
|
* ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
|
1319
1532
|
* ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced().
|
1320
1533
|
* Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller.
|
1321
1534
|
*/
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1535
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
|
1536
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
|
1537
|
+
ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
|
1325
1538
|
|
1326
1539
|
/*! ZSTD_initStatic*() :
|
1327
1540
|
* Initialize an object using a pre-allocated fixed-size buffer.
|
@@ -1344,20 +1557,20 @@ ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e
|
|
1344
1557
|
* Limitation 2 : static cctx currently not compatible with multi-threading.
|
1345
1558
|
* Limitation 3 : static dctx is incompatible with legacy support.
|
1346
1559
|
*/
|
1347
|
-
|
1348
|
-
|
1560
|
+
ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
|
1561
|
+
ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
|
1349
1562
|
|
1350
|
-
|
1351
|
-
|
1563
|
+
ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
|
1564
|
+
ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
|
1352
1565
|
|
1353
|
-
|
1566
|
+
ZSTDLIB_STATIC_API const ZSTD_CDict* ZSTD_initStaticCDict(
|
1354
1567
|
void* workspace, size_t workspaceSize,
|
1355
1568
|
const void* dict, size_t dictSize,
|
1356
1569
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1357
1570
|
ZSTD_dictContentType_e dictContentType,
|
1358
1571
|
ZSTD_compressionParameters cParams);
|
1359
1572
|
|
1360
|
-
|
1573
|
+
ZSTDLIB_STATIC_API const ZSTD_DDict* ZSTD_initStaticDDict(
|
1361
1574
|
void* workspace, size_t workspaceSize,
|
1362
1575
|
const void* dict, size_t dictSize,
|
1363
1576
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
@@ -1372,24 +1585,54 @@ ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
|
|
1372
1585
|
typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
|
1373
1586
|
typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
|
1374
1587
|
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
|
1375
|
-
static
|
1588
|
+
static
|
1589
|
+
#ifdef __GNUC__
|
1590
|
+
__attribute__((__unused__))
|
1591
|
+
#endif
|
1592
|
+
ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
|
1376
1593
|
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1594
|
+
ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
|
1595
|
+
ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
|
1596
|
+
ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
|
1597
|
+
ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
|
1381
1598
|
|
1382
|
-
|
1599
|
+
ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
|
1383
1600
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1384
1601
|
ZSTD_dictContentType_e dictContentType,
|
1385
1602
|
ZSTD_compressionParameters cParams,
|
1386
1603
|
ZSTD_customMem customMem);
|
1387
1604
|
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1605
|
+
/*! Thread pool :
|
1606
|
+
* These prototypes make it possible to share a thread pool among multiple compression contexts.
|
1607
|
+
* This can limit resources for applications with multiple threads where each one uses
|
1608
|
+
* a threaded compression mode (via ZSTD_c_nbWorkers parameter).
|
1609
|
+
* ZSTD_createThreadPool creates a new thread pool with a given number of threads.
|
1610
|
+
* Note that the lifetime of such pool must exist while being used.
|
1611
|
+
* ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
|
1612
|
+
* to use an internal thread pool).
|
1613
|
+
* ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer.
|
1614
|
+
*/
|
1615
|
+
typedef struct POOL_ctx_s ZSTD_threadPool;
|
1616
|
+
ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
|
1617
|
+
ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */
|
1618
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
|
1619
|
+
|
1620
|
+
|
1621
|
+
/*
|
1622
|
+
* This API is temporary and is expected to change or disappear in the future!
|
1623
|
+
*/
|
1624
|
+
ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced2(
|
1625
|
+
const void* dict, size_t dictSize,
|
1626
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1627
|
+
ZSTD_dictContentType_e dictContentType,
|
1628
|
+
const ZSTD_CCtx_params* cctxParams,
|
1629
|
+
ZSTD_customMem customMem);
|
1392
1630
|
|
1631
|
+
ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_advanced(
|
1632
|
+
const void* dict, size_t dictSize,
|
1633
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1634
|
+
ZSTD_dictContentType_e dictContentType,
|
1635
|
+
ZSTD_customMem customMem);
|
1393
1636
|
|
1394
1637
|
|
1395
1638
|
/***************************************
|
@@ -1402,22 +1645,22 @@ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictS
|
|
1402
1645
|
* As a consequence, `dictBuffer` **must** outlive CDict,
|
1403
1646
|
* and its content must remain unmodified throughout the lifetime of CDict.
|
1404
1647
|
* note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */
|
1405
|
-
|
1648
|
+
ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
|
1406
1649
|
|
1407
1650
|
/*! ZSTD_getCParams() :
|
1408
1651
|
* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
|
1409
1652
|
* `estimatedSrcSize` value is optional, select 0 if not known */
|
1410
|
-
|
1653
|
+
ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
|
1411
1654
|
|
1412
1655
|
/*! ZSTD_getParams() :
|
1413
1656
|
* same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
|
1414
1657
|
* All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */
|
1415
|
-
|
1658
|
+
ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
|
1416
1659
|
|
1417
1660
|
/*! ZSTD_checkCParams() :
|
1418
1661
|
* Ensure param values remain within authorized range.
|
1419
1662
|
* @return 0 on success, or an error code (can be checked with ZSTD_isError()) */
|
1420
|
-
|
1663
|
+
ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
|
1421
1664
|
|
1422
1665
|
/*! ZSTD_adjustCParams() :
|
1423
1666
|
* optimize params for a given `srcSize` and `dictSize`.
|
@@ -1425,23 +1668,25 @@ ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
|
|
1425
1668
|
* `dictSize` must be `0` when there is no dictionary.
|
1426
1669
|
* cPar can be invalid : all parameters will be clamped within valid range in the @return struct.
|
1427
1670
|
* This function never fails (wide contract) */
|
1428
|
-
|
1671
|
+
ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
|
1429
1672
|
|
1430
1673
|
/*! ZSTD_compress_advanced() :
|
1431
1674
|
* Note : this function is now DEPRECATED.
|
1432
1675
|
* It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters.
|
1433
|
-
* This prototype will
|
1434
|
-
|
1676
|
+
* This prototype will generate compilation warnings. */
|
1677
|
+
ZSTD_DEPRECATED("use ZSTD_compress2")
|
1678
|
+
size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
|
1435
1679
|
void* dst, size_t dstCapacity,
|
1436
1680
|
const void* src, size_t srcSize,
|
1437
1681
|
const void* dict,size_t dictSize,
|
1438
1682
|
ZSTD_parameters params);
|
1439
1683
|
|
1440
1684
|
/*! ZSTD_compress_usingCDict_advanced() :
|
1441
|
-
* Note : this function is now
|
1685
|
+
* Note : this function is now DEPRECATED.
|
1442
1686
|
* It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters.
|
1443
|
-
* This prototype will
|
1444
|
-
|
1687
|
+
* This prototype will generate compilation warnings. */
|
1688
|
+
ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary")
|
1689
|
+
size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
|
1445
1690
|
void* dst, size_t dstCapacity,
|
1446
1691
|
const void* src, size_t srcSize,
|
1447
1692
|
const ZSTD_CDict* cdict,
|
@@ -1451,18 +1696,18 @@ ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
|
|
1451
1696
|
/*! ZSTD_CCtx_loadDictionary_byReference() :
|
1452
1697
|
* Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx.
|
1453
1698
|
* It saves some memory, but also requires that `dict` outlives its usage within `cctx` */
|
1454
|
-
|
1699
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
|
1455
1700
|
|
1456
1701
|
/*! ZSTD_CCtx_loadDictionary_advanced() :
|
1457
1702
|
* Same as ZSTD_CCtx_loadDictionary(), but gives finer control over
|
1458
1703
|
* how to load the dictionary (by copy ? by reference ?)
|
1459
1704
|
* and how to interpret it (automatic ? force raw mode ? full mode only ?) */
|
1460
|
-
|
1705
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
1461
1706
|
|
1462
1707
|
/*! ZSTD_CCtx_refPrefix_advanced() :
|
1463
1708
|
* Same as ZSTD_CCtx_refPrefix(), but gives finer control over
|
1464
1709
|
* how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
|
1465
|
-
|
1710
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
|
1466
1711
|
|
1467
1712
|
/* === experimental parameters === */
|
1468
1713
|
/* these parameters can be used with ZSTD_setParameter()
|
@@ -1501,9 +1746,15 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|
1501
1746
|
* See the comments on that enum for an explanation of the feature. */
|
1502
1747
|
#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
|
1503
1748
|
|
1504
|
-
/*
|
1505
|
-
*
|
1506
|
-
*
|
1749
|
+
/* Controlled with ZSTD_paramSwitch_e enum.
|
1750
|
+
* Default is ZSTD_ps_auto.
|
1751
|
+
* Set to ZSTD_ps_disable to never compress literals.
|
1752
|
+
* Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals
|
1753
|
+
* may still be emitted if huffman is not beneficial to use.)
|
1754
|
+
*
|
1755
|
+
* By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
|
1756
|
+
* literals compression based on the compression parameters - specifically,
|
1757
|
+
* negative compression levels do not use literal compression.
|
1507
1758
|
*/
|
1508
1759
|
#define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
|
1509
1760
|
|
@@ -1518,12 +1769,192 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|
1518
1769
|
* but compression ratio may regress significantly if guess considerably underestimates */
|
1519
1770
|
#define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
|
1520
1771
|
|
1772
|
+
/* Controls whether the new and experimental "dedicated dictionary search
|
1773
|
+
* structure" can be used. This feature is still rough around the edges, be
|
1774
|
+
* prepared for surprising behavior!
|
1775
|
+
*
|
1776
|
+
* How to use it:
|
1777
|
+
*
|
1778
|
+
* When using a CDict, whether to use this feature or not is controlled at
|
1779
|
+
* CDict creation, and it must be set in a CCtxParams set passed into that
|
1780
|
+
* construction (via ZSTD_createCDict_advanced2()). A compression will then
|
1781
|
+
* use the feature or not based on how the CDict was constructed; the value of
|
1782
|
+
* this param, set in the CCtx, will have no effect.
|
1783
|
+
*
|
1784
|
+
* However, when a dictionary buffer is passed into a CCtx, such as via
|
1785
|
+
* ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control
|
1786
|
+
* whether the CDict that is created internally can use the feature or not.
|
1787
|
+
*
|
1788
|
+
* What it does:
|
1789
|
+
*
|
1790
|
+
* Normally, the internal data structures of the CDict are analogous to what
|
1791
|
+
* would be stored in a CCtx after compressing the contents of a dictionary.
|
1792
|
+
* To an approximation, a compression using a dictionary can then use those
|
1793
|
+
* data structures to simply continue what is effectively a streaming
|
1794
|
+
* compression where the simulated compression of the dictionary left off.
|
1795
|
+
* Which is to say, the search structures in the CDict are normally the same
|
1796
|
+
* format as in the CCtx.
|
1797
|
+
*
|
1798
|
+
* It is possible to do better, since the CDict is not like a CCtx: the search
|
1799
|
+
* structures are written once during CDict creation, and then are only read
|
1800
|
+
* after that, while the search structures in the CCtx are both read and
|
1801
|
+
* written as the compression goes along. This means we can choose a search
|
1802
|
+
* structure for the dictionary that is read-optimized.
|
1803
|
+
*
|
1804
|
+
* This feature enables the use of that different structure.
|
1805
|
+
*
|
1806
|
+
* Note that some of the members of the ZSTD_compressionParameters struct have
|
1807
|
+
* different semantics and constraints in the dedicated search structure. It is
|
1808
|
+
* highly recommended that you simply set a compression level in the CCtxParams
|
1809
|
+
* you pass into the CDict creation call, and avoid messing with the cParams
|
1810
|
+
* directly.
|
1811
|
+
*
|
1812
|
+
* Effects:
|
1813
|
+
*
|
1814
|
+
* This will only have any effect when the selected ZSTD_strategy
|
1815
|
+
* implementation supports this feature. Currently, that's limited to
|
1816
|
+
* ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2.
|
1817
|
+
*
|
1818
|
+
* Note that this means that the CDict tables can no longer be copied into the
|
1819
|
+
* CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be
|
1820
|
+
* usable. The dictionary can only be attached or reloaded.
|
1821
|
+
*
|
1822
|
+
* In general, you should expect compression to be faster--sometimes very much
|
1823
|
+
* so--and CDict creation to be slightly slower. Eventually, we will probably
|
1824
|
+
* make this mode the default.
|
1825
|
+
*/
|
1826
|
+
#define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8
|
1827
|
+
|
1828
|
+
/* ZSTD_c_stableInBuffer
|
1829
|
+
* Experimental parameter.
|
1830
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1831
|
+
*
|
1832
|
+
* Tells the compressor that the ZSTD_inBuffer will ALWAYS be the same
|
1833
|
+
* between calls, except for the modifications that zstd makes to pos (the
|
1834
|
+
* caller must not modify pos). This is checked by the compressor, and
|
1835
|
+
* compression will fail if it ever changes. This means the only flush
|
1836
|
+
* mode that makes sense is ZSTD_e_end, so zstd will error if ZSTD_e_end
|
1837
|
+
* is not used. The data in the ZSTD_inBuffer in the range [src, src + pos)
|
1838
|
+
* MUST not be modified during compression or you will get data corruption.
|
1839
|
+
*
|
1840
|
+
* When this flag is enabled zstd won't allocate an input window buffer,
|
1841
|
+
* because the user guarantees it can reference the ZSTD_inBuffer until
|
1842
|
+
* the frame is complete. But, it will still allocate an output buffer
|
1843
|
+
* large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also
|
1844
|
+
* avoid the memcpy() from the input buffer to the input window buffer.
|
1845
|
+
*
|
1846
|
+
* NOTE: ZSTD_compressStream2() will error if ZSTD_e_end is not used.
|
1847
|
+
* That means this flag cannot be used with ZSTD_compressStream().
|
1848
|
+
*
|
1849
|
+
* NOTE: So long as the ZSTD_inBuffer always points to valid memory, using
|
1850
|
+
* this flag is ALWAYS memory safe, and will never access out-of-bounds
|
1851
|
+
* memory. However, compression WILL fail if you violate the preconditions.
|
1852
|
+
*
|
1853
|
+
* WARNING: The data in the ZSTD_inBuffer in the range [dst, dst + pos) MUST
|
1854
|
+
* not be modified during compression or you will get data corruption. This
|
1855
|
+
* is because zstd needs to reference data in the ZSTD_inBuffer to find
|
1856
|
+
* matches. Normally zstd maintains its own window buffer for this purpose,
|
1857
|
+
* but passing this flag tells zstd to use the user provided buffer.
|
1858
|
+
*/
|
1859
|
+
#define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9
|
1860
|
+
|
1861
|
+
/* ZSTD_c_stableOutBuffer
|
1862
|
+
* Experimental parameter.
|
1863
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1864
|
+
*
|
1865
|
+
* Tells he compressor that the ZSTD_outBuffer will not be resized between
|
1866
|
+
* calls. Specifically: (out.size - out.pos) will never grow. This gives the
|
1867
|
+
* compressor the freedom to say: If the compressed data doesn't fit in the
|
1868
|
+
* output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to
|
1869
|
+
* always decompress directly into the output buffer, instead of decompressing
|
1870
|
+
* into an internal buffer and copying to the output buffer.
|
1871
|
+
*
|
1872
|
+
* When this flag is enabled zstd won't allocate an output buffer, because
|
1873
|
+
* it can write directly to the ZSTD_outBuffer. It will still allocate the
|
1874
|
+
* input window buffer (see ZSTD_c_stableInBuffer).
|
1875
|
+
*
|
1876
|
+
* Zstd will check that (out.size - out.pos) never grows and return an error
|
1877
|
+
* if it does. While not strictly necessary, this should prevent surprises.
|
1878
|
+
*/
|
1879
|
+
#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
|
1880
|
+
|
1881
|
+
/* ZSTD_c_blockDelimiters
|
1882
|
+
* Default is 0 == ZSTD_sf_noBlockDelimiters.
|
1883
|
+
*
|
1884
|
+
* For use with sequence compression API: ZSTD_compressSequences().
|
1885
|
+
*
|
1886
|
+
* Designates whether or not the given array of ZSTD_Sequence contains block delimiters
|
1887
|
+
* and last literals, which are defined as sequences with offset == 0 and matchLength == 0.
|
1888
|
+
* See the definition of ZSTD_Sequence for more specifics.
|
1889
|
+
*/
|
1890
|
+
#define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
|
1891
|
+
|
1892
|
+
/* ZSTD_c_validateSequences
|
1893
|
+
* Default is 0 == disabled. Set to 1 to enable sequence validation.
|
1894
|
+
*
|
1895
|
+
* For use with sequence compression API: ZSTD_compressSequences().
|
1896
|
+
* Designates whether or not we validate sequences provided to ZSTD_compressSequences()
|
1897
|
+
* during function execution.
|
1898
|
+
*
|
1899
|
+
* Without validation, providing a sequence that does not conform to the zstd spec will cause
|
1900
|
+
* undefined behavior, and may produce a corrupted block.
|
1901
|
+
*
|
1902
|
+
* With validation enabled, a if sequence is invalid (see doc/zstd_compression_format.md for
|
1903
|
+
* specifics regarding offset/matchlength requirements) then the function will bail out and
|
1904
|
+
* return an error.
|
1905
|
+
*
|
1906
|
+
*/
|
1907
|
+
#define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
|
1908
|
+
|
1909
|
+
/* ZSTD_c_useBlockSplitter
|
1910
|
+
* Controlled with ZSTD_paramSwitch_e enum.
|
1911
|
+
* Default is ZSTD_ps_auto.
|
1912
|
+
* Set to ZSTD_ps_disable to never use block splitter.
|
1913
|
+
* Set to ZSTD_ps_enable to always use block splitter.
|
1914
|
+
*
|
1915
|
+
* By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
|
1916
|
+
* block splitting based on the compression parameters.
|
1917
|
+
*/
|
1918
|
+
#define ZSTD_c_useBlockSplitter ZSTD_c_experimentalParam13
|
1919
|
+
|
1920
|
+
/* ZSTD_c_useRowMatchFinder
|
1921
|
+
* Controlled with ZSTD_paramSwitch_e enum.
|
1922
|
+
* Default is ZSTD_ps_auto.
|
1923
|
+
* Set to ZSTD_ps_disable to never use row-based matchfinder.
|
1924
|
+
* Set to ZSTD_ps_enable to force usage of row-based matchfinder.
|
1925
|
+
*
|
1926
|
+
* By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
|
1927
|
+
* the row-based matchfinder based on support for SIMD instructions and the window log.
|
1928
|
+
* Note that this only pertains to compression strategies: greedy, lazy, and lazy2
|
1929
|
+
*/
|
1930
|
+
#define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14
|
1931
|
+
|
1932
|
+
/* ZSTD_c_deterministicRefPrefix
|
1933
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1934
|
+
*
|
1935
|
+
* Zstd produces different results for prefix compression when the prefix is
|
1936
|
+
* directly adjacent to the data about to be compressed vs. when it isn't.
|
1937
|
+
* This is because zstd detects that the two buffers are contiguous and it can
|
1938
|
+
* use a more efficient match finding algorithm. However, this produces different
|
1939
|
+
* results than when the two buffers are non-contiguous. This flag forces zstd
|
1940
|
+
* to always load the prefix in non-contiguous mode, even if it happens to be
|
1941
|
+
* adjacent to the data, to guarantee determinism.
|
1942
|
+
*
|
1943
|
+
* If you really care about determinism when using a dictionary or prefix,
|
1944
|
+
* like when doing delta compression, you should select this option. It comes
|
1945
|
+
* at a speed penalty of about ~2.5% if the dictionary and data happened to be
|
1946
|
+
* contiguous, and is free if they weren't contiguous. We don't expect that
|
1947
|
+
* intentionally making the dictionary and data contiguous will be worth the
|
1948
|
+
* cost to memcpy() the data.
|
1949
|
+
*/
|
1950
|
+
#define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
|
1951
|
+
|
1521
1952
|
/*! ZSTD_CCtx_getParameter() :
|
1522
1953
|
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
|
1523
1954
|
* and store it into int* value.
|
1524
1955
|
* @return : 0, or an error code (which can be tested with ZSTD_isError()).
|
1525
1956
|
*/
|
1526
|
-
|
1957
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
|
1527
1958
|
|
1528
1959
|
|
1529
1960
|
/*! ZSTD_CCtx_params :
|
@@ -1538,45 +1969,47 @@ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param
|
|
1538
1969
|
* These parameters will be applied to
|
1539
1970
|
* all subsequent frames.
|
1540
1971
|
* - ZSTD_compressStream2() : Do compression using the CCtx.
|
1541
|
-
* - ZSTD_freeCCtxParams() : Free the memory.
|
1972
|
+
* - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer.
|
1542
1973
|
*
|
1543
1974
|
* This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
|
1544
1975
|
* for static allocation of CCtx for single-threaded compression.
|
1545
1976
|
*/
|
1546
|
-
|
1547
|
-
|
1977
|
+
ZSTDLIB_STATIC_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
|
1978
|
+
ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */
|
1548
1979
|
|
1549
1980
|
/*! ZSTD_CCtxParams_reset() :
|
1550
1981
|
* Reset params to default values.
|
1551
1982
|
*/
|
1552
|
-
|
1983
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
|
1553
1984
|
|
1554
1985
|
/*! ZSTD_CCtxParams_init() :
|
1555
1986
|
* Initializes the compression parameters of cctxParams according to
|
1556
1987
|
* compression level. All other parameters are reset to their default values.
|
1557
1988
|
*/
|
1558
|
-
|
1989
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
|
1559
1990
|
|
1560
1991
|
/*! ZSTD_CCtxParams_init_advanced() :
|
1561
1992
|
* Initializes the compression and frame parameters of cctxParams according to
|
1562
1993
|
* params. All other parameters are reset to their default values.
|
1563
1994
|
*/
|
1564
|
-
|
1995
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
|
1565
1996
|
|
1566
|
-
/*! ZSTD_CCtxParams_setParameter() :
|
1997
|
+
/*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+
|
1567
1998
|
* Similar to ZSTD_CCtx_setParameter.
|
1568
1999
|
* Set one compression parameter, selected by enum ZSTD_cParameter.
|
1569
|
-
* Parameters must be applied to a ZSTD_CCtx using
|
1570
|
-
*
|
2000
|
+
* Parameters must be applied to a ZSTD_CCtx using
|
2001
|
+
* ZSTD_CCtx_setParametersUsingCCtxParams().
|
2002
|
+
* @result : a code representing success or failure (which can be tested with
|
2003
|
+
* ZSTD_isError()).
|
1571
2004
|
*/
|
1572
|
-
|
2005
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
|
1573
2006
|
|
1574
2007
|
/*! ZSTD_CCtxParams_getParameter() :
|
1575
2008
|
* Similar to ZSTD_CCtx_getParameter.
|
1576
2009
|
* Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
|
1577
2010
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
1578
2011
|
*/
|
1579
|
-
|
2012
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
|
1580
2013
|
|
1581
2014
|
/*! ZSTD_CCtx_setParametersUsingCCtxParams() :
|
1582
2015
|
* Apply a set of ZSTD_CCtx_params to the compression context.
|
@@ -1585,7 +2018,7 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_c
|
|
1585
2018
|
* if nbWorkers>=1, new parameters will be picked up at next job,
|
1586
2019
|
* with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated).
|
1587
2020
|
*/
|
1588
|
-
|
2021
|
+
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
1589
2022
|
ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
|
1590
2023
|
|
1591
2024
|
/*! ZSTD_compressStream2_simpleArgs() :
|
@@ -1594,7 +2027,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
|
1594
2027
|
* This variant might be helpful for binders from dynamic languages
|
1595
2028
|
* which have troubles handling structures containing memory pointers.
|
1596
2029
|
*/
|
1597
|
-
|
2030
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs (
|
1598
2031
|
ZSTD_CCtx* cctx,
|
1599
2032
|
void* dst, size_t dstCapacity, size_t* dstPos,
|
1600
2033
|
const void* src, size_t srcSize, size_t* srcPos,
|
@@ -1610,33 +2043,33 @@ ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs (
|
|
1610
2043
|
* Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
|
1611
2044
|
* Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
|
1612
2045
|
* Note 3 : Skippable Frame Identifiers are considered valid. */
|
1613
|
-
|
2046
|
+
ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
|
1614
2047
|
|
1615
2048
|
/*! ZSTD_createDDict_byReference() :
|
1616
2049
|
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
1617
2050
|
* Dictionary content is referenced, and therefore stays in dictBuffer.
|
1618
2051
|
* It is important that dictBuffer outlives DDict,
|
1619
2052
|
* it must remain read accessible throughout the lifetime of DDict */
|
1620
|
-
|
2053
|
+
ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
|
1621
2054
|
|
1622
2055
|
/*! ZSTD_DCtx_loadDictionary_byReference() :
|
1623
2056
|
* Same as ZSTD_DCtx_loadDictionary(),
|
1624
2057
|
* but references `dict` content instead of copying it into `dctx`.
|
1625
2058
|
* This saves memory if `dict` remains around.,
|
1626
2059
|
* However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */
|
1627
|
-
|
2060
|
+
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
1628
2061
|
|
1629
2062
|
/*! ZSTD_DCtx_loadDictionary_advanced() :
|
1630
2063
|
* Same as ZSTD_DCtx_loadDictionary(),
|
1631
2064
|
* but gives direct control over
|
1632
2065
|
* how to load the dictionary (by copy ? by reference ?)
|
1633
2066
|
* and how to interpret it (automatic ? force raw mode ? full mode only ?). */
|
1634
|
-
|
2067
|
+
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
|
1635
2068
|
|
1636
2069
|
/*! ZSTD_DCtx_refPrefix_advanced() :
|
1637
2070
|
* Same as ZSTD_DCtx_refPrefix(), but gives finer control over
|
1638
2071
|
* how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
|
1639
|
-
|
2072
|
+
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
|
1640
2073
|
|
1641
2074
|
/*! ZSTD_DCtx_setMaxWindowSize() :
|
1642
2075
|
* Refuses allocating internal buffers for frames requiring a window size larger than provided limit.
|
@@ -1645,7 +2078,14 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* pre
|
|
1645
2078
|
* By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT)
|
1646
2079
|
* @return : 0, or an error code (which can be tested using ZSTD_isError()).
|
1647
2080
|
*/
|
1648
|
-
|
2081
|
+
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
|
2082
|
+
|
2083
|
+
/*! ZSTD_DCtx_getParameter() :
|
2084
|
+
* Get the requested decompression parameter value, selected by enum ZSTD_dParameter,
|
2085
|
+
* and store it into int* value.
|
2086
|
+
* @return : 0, or an error code (which can be tested with ZSTD_isError()).
|
2087
|
+
*/
|
2088
|
+
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
|
1649
2089
|
|
1650
2090
|
/* ZSTD_d_format
|
1651
2091
|
* experimental parameter,
|
@@ -1684,12 +2124,49 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
|
|
1684
2124
|
*/
|
1685
2125
|
#define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
|
1686
2126
|
|
2127
|
+
/* ZSTD_d_forceIgnoreChecksum
|
2128
|
+
* Experimental parameter.
|
2129
|
+
* Default is 0 == disabled. Set to 1 to enable
|
2130
|
+
*
|
2131
|
+
* Tells the decompressor to skip checksum validation during decompression, regardless
|
2132
|
+
* of whether checksumming was specified during compression. This offers some
|
2133
|
+
* slight performance benefits, and may be useful for debugging.
|
2134
|
+
* Param has values of type ZSTD_forceIgnoreChecksum_e
|
2135
|
+
*/
|
2136
|
+
#define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
|
2137
|
+
|
2138
|
+
/* ZSTD_d_refMultipleDDicts
|
2139
|
+
* Experimental parameter.
|
2140
|
+
* Default is 0 == disabled. Set to 1 to enable
|
2141
|
+
*
|
2142
|
+
* If enabled and dctx is allocated on the heap, then additional memory will be allocated
|
2143
|
+
* to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
|
2144
|
+
* using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
|
2145
|
+
* store all references. At decompression time, the appropriate dictID is selected
|
2146
|
+
* from the set of DDicts based on the dictID in the frame.
|
2147
|
+
*
|
2148
|
+
* Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
|
2149
|
+
*
|
2150
|
+
* Param has values of byte ZSTD_refMultipleDDicts_e
|
2151
|
+
*
|
2152
|
+
* WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory
|
2153
|
+
* allocation for the hash table. ZSTD_freeDCtx() also frees this memory.
|
2154
|
+
* Memory is allocated as per ZSTD_DCtx::customMem.
|
2155
|
+
*
|
2156
|
+
* Although this function allocates memory for the table, the user is still responsible for
|
2157
|
+
* memory management of the underlying ZSTD_DDict* themselves.
|
2158
|
+
*/
|
2159
|
+
#define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4
|
2160
|
+
|
2161
|
+
|
1687
2162
|
/*! ZSTD_DCtx_setFormat() :
|
2163
|
+
* This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter().
|
1688
2164
|
* Instruct the decoder context about what kind of data to decode next.
|
1689
2165
|
* This instruction is mandatory to decode data without a fully-formed header,
|
1690
2166
|
* such ZSTD_f_zstd1_magicless for example.
|
1691
2167
|
* @return : 0, or an error code (which can be tested using ZSTD_isError()). */
|
1692
|
-
|
2168
|
+
ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
|
2169
|
+
size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
|
1693
2170
|
|
1694
2171
|
/*! ZSTD_decompressStream_simpleArgs() :
|
1695
2172
|
* Same as ZSTD_decompressStream(),
|
@@ -1697,7 +2174,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
|
|
1697
2174
|
* This can be helpful for binders from dynamic languages
|
1698
2175
|
* which have troubles handling structures containing memory pointers.
|
1699
2176
|
*/
|
1700
|
-
|
2177
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs (
|
1701
2178
|
ZSTD_DCtx* dctx,
|
1702
2179
|
void* dst, size_t dstCapacity, size_t* dstPos,
|
1703
2180
|
const void* src, size_t srcSize, size_t* srcPos);
|
@@ -1711,8 +2188,9 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
|
|
1711
2188
|
********************************************************************/
|
1712
2189
|
|
1713
2190
|
/*===== Advanced Streaming compression functions =====*/
|
1714
|
-
|
1715
|
-
|
2191
|
+
|
2192
|
+
/*! ZSTD_initCStream_srcSize() :
|
2193
|
+
* This function is DEPRECATED, and equivalent to:
|
1716
2194
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1717
2195
|
* ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
|
1718
2196
|
* ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
|
@@ -1721,15 +2199,15 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
|
|
1721
2199
|
* pledgedSrcSize must be correct. If it is not known at init time, use
|
1722
2200
|
* ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs,
|
1723
2201
|
* "0" also disables frame content size field. It may be enabled in the future.
|
1724
|
-
*
|
2202
|
+
* This prototype will generate compilation warnings.
|
1725
2203
|
*/
|
1726
|
-
|
1727
|
-
ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
2204
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2205
|
+
size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
1728
2206
|
int compressionLevel,
|
1729
2207
|
unsigned long long pledgedSrcSize);
|
1730
2208
|
|
1731
|
-
|
1732
|
-
* This function is
|
2209
|
+
/*! ZSTD_initCStream_usingDict() :
|
2210
|
+
* This function is DEPRECATED, and is equivalent to:
|
1733
2211
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1734
2212
|
* ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
|
1735
2213
|
* ZSTD_CCtx_loadDictionary(zcs, dict, dictSize);
|
@@ -1738,15 +2216,15 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
|
1738
2216
|
* dict == NULL or dictSize < 8, in which case no dict is used.
|
1739
2217
|
* Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if
|
1740
2218
|
* it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.
|
1741
|
-
*
|
2219
|
+
* This prototype will generate compilation warnings.
|
1742
2220
|
*/
|
1743
|
-
|
1744
|
-
ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
2221
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2222
|
+
size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
1745
2223
|
const void* dict, size_t dictSize,
|
1746
2224
|
int compressionLevel);
|
1747
2225
|
|
1748
|
-
|
1749
|
-
* This function is
|
2226
|
+
/*! ZSTD_initCStream_advanced() :
|
2227
|
+
* This function is DEPRECATED, and is approximately equivalent to:
|
1750
2228
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1751
2229
|
* // Pseudocode: Set each zstd parameter and leave the rest as-is.
|
1752
2230
|
* for ((param, value) : params) {
|
@@ -1758,25 +2236,26 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
|
1758
2236
|
* dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy.
|
1759
2237
|
* pledgedSrcSize must be correct.
|
1760
2238
|
* If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN.
|
1761
|
-
*
|
2239
|
+
* This prototype will generate compilation warnings.
|
1762
2240
|
*/
|
1763
|
-
|
1764
|
-
ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
2241
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2242
|
+
size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
1765
2243
|
const void* dict, size_t dictSize,
|
1766
2244
|
ZSTD_parameters params,
|
1767
2245
|
unsigned long long pledgedSrcSize);
|
1768
2246
|
|
1769
|
-
|
1770
|
-
* This function is
|
2247
|
+
/*! ZSTD_initCStream_usingCDict() :
|
2248
|
+
* This function is DEPRECATED, and equivalent to:
|
1771
2249
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1772
2250
|
* ZSTD_CCtx_refCDict(zcs, cdict);
|
1773
2251
|
*
|
1774
2252
|
* note : cdict will just be referenced, and must outlive compression session
|
1775
|
-
*
|
2253
|
+
* This prototype will generate compilation warnings.
|
1776
2254
|
*/
|
1777
|
-
|
2255
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
|
2256
|
+
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
|
1778
2257
|
|
1779
|
-
|
2258
|
+
/*! ZSTD_initCStream_usingCDict_advanced() :
|
1780
2259
|
* This function is DEPRECATED, and is approximately equivalent to:
|
1781
2260
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1782
2261
|
* // Pseudocode: Set each zstd frame parameter and leave the rest as-is.
|
@@ -1789,18 +2268,21 @@ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDi
|
|
1789
2268
|
* same as ZSTD_initCStream_usingCDict(), with control over frame parameters.
|
1790
2269
|
* pledgedSrcSize must be correct. If srcSize is not known at init time, use
|
1791
2270
|
* value ZSTD_CONTENTSIZE_UNKNOWN.
|
1792
|
-
*
|
2271
|
+
* This prototype will generate compilation warnings.
|
1793
2272
|
*/
|
1794
|
-
|
1795
|
-
ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
2273
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
|
2274
|
+
size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
1796
2275
|
const ZSTD_CDict* cdict,
|
1797
2276
|
ZSTD_frameParameters fParams,
|
1798
2277
|
unsigned long long pledgedSrcSize);
|
1799
2278
|
|
1800
2279
|
/*! ZSTD_resetCStream() :
|
1801
|
-
* This function is
|
2280
|
+
* This function is DEPRECATED, and is equivalent to:
|
1802
2281
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1803
2282
|
* ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
|
2283
|
+
* Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but
|
2284
|
+
* ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be
|
2285
|
+
* explicitly specified.
|
1804
2286
|
*
|
1805
2287
|
* start a new frame, using same parameters from previous frame.
|
1806
2288
|
* This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
|
@@ -1810,9 +2292,10 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
|
1810
2292
|
* For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
|
1811
2293
|
* but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
|
1812
2294
|
* @return : 0, or an error code (which can be tested using ZSTD_isError())
|
1813
|
-
*
|
2295
|
+
* This prototype will generate compilation warnings.
|
1814
2296
|
*/
|
1815
|
-
|
2297
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2298
|
+
size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
|
1816
2299
|
|
1817
2300
|
|
1818
2301
|
typedef struct {
|
@@ -1830,7 +2313,7 @@ typedef struct {
|
|
1830
2313
|
* Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
|
1831
2314
|
* Aggregates progression inside active worker threads.
|
1832
2315
|
*/
|
1833
|
-
|
2316
|
+
ZSTDLIB_STATIC_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
|
1834
2317
|
|
1835
2318
|
/*! ZSTD_toFlushNow() :
|
1836
2319
|
* Tell how many bytes are ready to be flushed immediately.
|
@@ -1845,11 +2328,12 @@ ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx
|
|
1845
2328
|
* therefore flush speed is limited by production speed of oldest job
|
1846
2329
|
* irrespective of the speed of concurrent (and newer) jobs.
|
1847
2330
|
*/
|
1848
|
-
|
2331
|
+
ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
|
1849
2332
|
|
1850
2333
|
|
1851
2334
|
/*===== Advanced Streaming decompression functions =====*/
|
1852
|
-
|
2335
|
+
|
2336
|
+
/*!
|
1853
2337
|
* This function is deprecated, and is equivalent to:
|
1854
2338
|
*
|
1855
2339
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1858,9 +2342,9 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
|
|
1858
2342
|
* note: no dictionary will be used if dict == NULL or dictSize < 8
|
1859
2343
|
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
1860
2344
|
*/
|
1861
|
-
|
2345
|
+
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
|
1862
2346
|
|
1863
|
-
|
2347
|
+
/*!
|
1864
2348
|
* This function is deprecated, and is equivalent to:
|
1865
2349
|
*
|
1866
2350
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1869,9 +2353,9 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dic
|
|
1869
2353
|
* note : ddict is referenced, it must outlive decompression session
|
1870
2354
|
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
1871
2355
|
*/
|
1872
|
-
|
2356
|
+
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
|
1873
2357
|
|
1874
|
-
|
2358
|
+
/*!
|
1875
2359
|
* This function is deprecated, and is equivalent to:
|
1876
2360
|
*
|
1877
2361
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1879,7 +2363,7 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDi
|
|
1879
2363
|
* re-use decompression parameters from previous init; saves dictionary loading
|
1880
2364
|
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
1881
2365
|
*/
|
1882
|
-
|
2366
|
+
ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
1883
2367
|
|
1884
2368
|
|
1885
2369
|
/*********************************************************************
|
@@ -1898,8 +2382,7 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
|
1898
2382
|
ZSTD_CCtx object can be re-used multiple times within successive compression operations.
|
1899
2383
|
|
1900
2384
|
Start by initializing a context.
|
1901
|
-
Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression
|
1902
|
-
or ZSTD_compressBegin_advanced(), for finer parameter control.
|
2385
|
+
Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
|
1903
2386
|
It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
|
1904
2387
|
|
1905
2388
|
Then, consume your input using ZSTD_compressContinue().
|
@@ -1922,18 +2405,20 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
|
1922
2405
|
*/
|
1923
2406
|
|
1924
2407
|
/*===== Buffer-less streaming compression functions =====*/
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
2408
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
2409
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
2410
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
|
2411
|
+
ZSTDLIB_STATIC_API 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 */
|
2412
|
+
|
2413
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2414
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2415
|
+
|
2416
|
+
/* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */
|
2417
|
+
ZSTD_DEPRECATED("use advanced API to access custom parameters")
|
2418
|
+
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 */
|
2419
|
+
ZSTD_DEPRECATED("use advanced API to access custom parameters")
|
2420
|
+
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 */
|
2421
|
+
/**
|
1937
2422
|
Buffer-less streaming decompression (synchronous mode)
|
1938
2423
|
|
1939
2424
|
A ZSTD_DCtx object is required to track streaming operations.
|
@@ -2023,24 +2508,24 @@ typedef struct {
|
|
2023
2508
|
* @return : 0, `zfhPtr` is correctly filled,
|
2024
2509
|
* >0, `srcSize` is too small, value is wanted `srcSize` amount,
|
2025
2510
|
* or an error code, which can be tested using ZSTD_isError() */
|
2026
|
-
|
2511
|
+
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
2027
2512
|
/*! ZSTD_getFrameHeader_advanced() :
|
2028
2513
|
* same as ZSTD_getFrameHeader(),
|
2029
2514
|
* with added capability to select a format (like ZSTD_f_zstd1_magicless) */
|
2030
|
-
|
2031
|
-
|
2515
|
+
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
|
2516
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
|
2032
2517
|
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2518
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
|
2519
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
2520
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
2036
2521
|
|
2037
|
-
|
2038
|
-
|
2522
|
+
ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
|
2523
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2039
2524
|
|
2040
2525
|
/* misc */
|
2041
|
-
|
2526
|
+
ZSTDLIB_STATIC_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
|
2042
2527
|
typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
|
2043
|
-
|
2528
|
+
ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
|
2044
2529
|
|
2045
2530
|
|
2046
2531
|
|
@@ -2077,10 +2562,10 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
|
|
2077
2562
|
*/
|
2078
2563
|
|
2079
2564
|
/*===== Raw zstd block functions =====*/
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2565
|
+
ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
|
2566
|
+
ZSTDLIB_STATIC_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2567
|
+
ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2568
|
+
ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
|
2084
2569
|
|
2085
2570
|
|
2086
2571
|
#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
|