zstd-ruby 1.4.9.0 → 1.5.0.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/.github/dependabot.yml +8 -0
- data/README.md +1 -1
- data/ext/zstdruby/libzstd/BUCK +5 -7
- data/ext/zstdruby/libzstd/Makefile +42 -13
- data/ext/zstdruby/libzstd/README.md +8 -4
- data/ext/zstdruby/libzstd/common/bitstream.h +1 -1
- data/ext/zstdruby/libzstd/common/compiler.h +1 -1
- data/ext/zstdruby/libzstd/common/cpu.h +1 -1
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +1 -1
- data/ext/zstdruby/libzstd/common/entropy_common.c +1 -1
- data/ext/zstdruby/libzstd/common/error_private.c +1 -1
- data/ext/zstdruby/libzstd/common/error_private.h +3 -3
- data/ext/zstdruby/libzstd/common/fse.h +2 -2
- data/ext/zstdruby/libzstd/common/fse_decompress.c +25 -15
- data/ext/zstdruby/libzstd/common/huf.h +3 -2
- data/ext/zstdruby/libzstd/common/mem.h +3 -5
- data/ext/zstdruby/libzstd/common/pool.c +1 -1
- data/ext/zstdruby/libzstd/common/pool.h +1 -1
- data/ext/zstdruby/libzstd/common/xxhash.c +2 -4
- data/ext/zstdruby/libzstd/common/xxhash.h +1 -1
- data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
- data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +21 -9
- data/ext/zstdruby/libzstd/common/zstd_trace.h +7 -5
- data/ext/zstdruby/libzstd/compress/fse_compress.c +1 -1
- data/ext/zstdruby/libzstd/compress/hist.c +1 -1
- data/ext/zstdruby/libzstd/compress/hist.h +1 -1
- data/ext/zstdruby/libzstd/compress/huf_compress.c +51 -28
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1373 -275
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +164 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +2 -2
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +14 -6
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +5 -282
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +147 -46
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +3 -3
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +4 -4
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +914 -142
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +39 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +51 -15
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +2 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +15 -6
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +5 -5
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +44 -43
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +3 -4
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +44 -36
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +1 -1
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +1 -2
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +7 -6
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +6 -5
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +7 -6
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +8 -7
- data/ext/zstdruby/libzstd/dll/example/Makefile +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +148 -2
- data/ext/zstdruby/libzstd/zstd.h +165 -83
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +1 -1
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +5 -5
- data/ext/zstdruby/libzstd/common/zstd_trace.c +0 -42
@@ -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
|
@@ -36,6 +36,145 @@ extern "C" {
|
|
36
36
|
# define ZDICTLIB_API ZDICTLIB_VISIBILITY
|
37
37
|
#endif
|
38
38
|
|
39
|
+
/*******************************************************************************
|
40
|
+
* Zstd dictionary builder
|
41
|
+
*
|
42
|
+
* FAQ
|
43
|
+
* ===
|
44
|
+
* Why should I use a dictionary?
|
45
|
+
* ------------------------------
|
46
|
+
*
|
47
|
+
* Zstd can use dictionaries to improve compression ratio of small data.
|
48
|
+
* Traditionally small files don't compress well because there is very little
|
49
|
+
* repetion in a single sample, since it is small. But, if you are compressing
|
50
|
+
* many similar files, like a bunch of JSON records that share the same
|
51
|
+
* structure, you can train a dictionary on ahead of time on some samples of
|
52
|
+
* these files. Then, zstd can use the dictionary to find repetitions that are
|
53
|
+
* present across samples. This can vastly improve compression ratio.
|
54
|
+
*
|
55
|
+
* When is a dictionary useful?
|
56
|
+
* ----------------------------
|
57
|
+
*
|
58
|
+
* Dictionaries are useful when compressing many small files that are similar.
|
59
|
+
* The larger a file is, the less benefit a dictionary will have. Generally,
|
60
|
+
* we don't expect dictionary compression to be effective past 100KB. And the
|
61
|
+
* smaller a file is, the more we would expect the dictionary to help.
|
62
|
+
*
|
63
|
+
* How do I use a dictionary?
|
64
|
+
* --------------------------
|
65
|
+
*
|
66
|
+
* Simply pass the dictionary to the zstd compressor with
|
67
|
+
* `ZSTD_CCtx_loadDictionary()`. The same dictionary must then be passed to
|
68
|
+
* the decompressor, using `ZSTD_DCtx_loadDictionary()`. There are other
|
69
|
+
* more advanced functions that allow selecting some options, see zstd.h for
|
70
|
+
* complete documentation.
|
71
|
+
*
|
72
|
+
* What is a zstd dictionary?
|
73
|
+
* --------------------------
|
74
|
+
*
|
75
|
+
* A zstd dictionary has two pieces: Its header, and its content. The header
|
76
|
+
* contains a magic number, the dictionary ID, and entropy tables. These
|
77
|
+
* entropy tables allow zstd to save on header costs in the compressed file,
|
78
|
+
* which really matters for small data. The content is just bytes, which are
|
79
|
+
* repeated content that is common across many samples.
|
80
|
+
*
|
81
|
+
* What is a raw content dictionary?
|
82
|
+
* ---------------------------------
|
83
|
+
*
|
84
|
+
* A raw content dictionary is just bytes. It doesn't have a zstd dictionary
|
85
|
+
* header, a dictionary ID, or entropy tables. Any buffer is a valid raw
|
86
|
+
* content dictionary.
|
87
|
+
*
|
88
|
+
* How do I train a dictionary?
|
89
|
+
* ----------------------------
|
90
|
+
*
|
91
|
+
* Gather samples from your use case. These samples should be similar to each
|
92
|
+
* other. If you have several use cases, you could try to train one dictionary
|
93
|
+
* per use case.
|
94
|
+
*
|
95
|
+
* Pass those samples to `ZDICT_trainFromBuffer()` and that will train your
|
96
|
+
* dictionary. There are a few advanced versions of this function, but this
|
97
|
+
* is a great starting point. If you want to further tune your dictionary
|
98
|
+
* you could try `ZDICT_optimizeTrainFromBuffer_cover()`. If that is too slow
|
99
|
+
* you can try `ZDICT_optimizeTrainFromBuffer_fastCover()`.
|
100
|
+
*
|
101
|
+
* If the dictionary training function fails, that is likely because you
|
102
|
+
* either passed too few samples, or a dictionary would not be effective
|
103
|
+
* for your data. Look at the messages that the dictionary trainer printed,
|
104
|
+
* if it doesn't say too few samples, then a dictionary would not be effective.
|
105
|
+
*
|
106
|
+
* How large should my dictionary be?
|
107
|
+
* ----------------------------------
|
108
|
+
*
|
109
|
+
* A reasonable dictionary size, the `dictBufferCapacity`, is about 100KB.
|
110
|
+
* The zstd CLI defaults to a 110KB dictionary. You likely don't need a
|
111
|
+
* dictionary larger than that. But, most use cases can get away with a
|
112
|
+
* smaller dictionary. The advanced dictionary builders can automatically
|
113
|
+
* shrink the dictionary for you, and select a the smallest size that
|
114
|
+
* doesn't hurt compression ratio too much. See the `shrinkDict` parameter.
|
115
|
+
* A smaller dictionary can save memory, and potentially speed up
|
116
|
+
* compression.
|
117
|
+
*
|
118
|
+
* How many samples should I provide to the dictionary builder?
|
119
|
+
* ------------------------------------------------------------
|
120
|
+
*
|
121
|
+
* We generally recommend passing ~100x the size of the dictionary
|
122
|
+
* in samples. A few thousand should suffice. Having too few samples
|
123
|
+
* can hurt the dictionaries effectiveness. Having more samples will
|
124
|
+
* only improve the dictionaries effectiveness. But having too many
|
125
|
+
* samples can slow down the dictionary builder.
|
126
|
+
*
|
127
|
+
* How do I determine if a dictionary will be effective?
|
128
|
+
* -----------------------------------------------------
|
129
|
+
*
|
130
|
+
* Simply train a dictionary and try it out. You can use zstd's built in
|
131
|
+
* benchmarking tool to test the dictionary effectiveness.
|
132
|
+
*
|
133
|
+
* # Benchmark levels 1-3 without a dictionary
|
134
|
+
* zstd -b1e3 -r /path/to/my/files
|
135
|
+
* # Benchmark levels 1-3 with a dictioanry
|
136
|
+
* zstd -b1e3 -r /path/to/my/files -D /path/to/my/dictionary
|
137
|
+
*
|
138
|
+
* When should I retrain a dictionary?
|
139
|
+
* -----------------------------------
|
140
|
+
*
|
141
|
+
* You should retrain a dictionary when its effectiveness drops. Dictionary
|
142
|
+
* effectiveness drops as the data you are compressing changes. Generally, we do
|
143
|
+
* expect dictionaries to "decay" over time, as your data changes, but the rate
|
144
|
+
* at which they decay depends on your use case. Internally, we regularly
|
145
|
+
* retrain dictionaries, and if the new dictionary performs significantly
|
146
|
+
* better than the old dictionary, we will ship the new dictionary.
|
147
|
+
*
|
148
|
+
* I have a raw content dictionary, how do I turn it into a zstd dictionary?
|
149
|
+
* -------------------------------------------------------------------------
|
150
|
+
*
|
151
|
+
* If you have a raw content dictionary, e.g. by manually constructing it, or
|
152
|
+
* using a third-party dictionary builder, you can turn it into a zstd
|
153
|
+
* dictionary by using `ZDICT_finalizeDictionary()`. You'll also have to
|
154
|
+
* provide some samples of the data. It will add the zstd header to the
|
155
|
+
* raw content, which contains a dictionary ID and entropy tables, which
|
156
|
+
* will improve compression ratio, and allow zstd to write the dictionary ID
|
157
|
+
* into the frame, if you so choose.
|
158
|
+
*
|
159
|
+
* Do I have to use zstd's dictionary builder?
|
160
|
+
* -------------------------------------------
|
161
|
+
*
|
162
|
+
* No! You can construct dictionary content however you please, it is just
|
163
|
+
* bytes. It will always be valid as a raw content dictionary. If you want
|
164
|
+
* a zstd dictionary, which can improve compression ratio, use
|
165
|
+
* `ZDICT_finalizeDictionary()`.
|
166
|
+
*
|
167
|
+
* What is the attack surface of a zstd dictionary?
|
168
|
+
* ------------------------------------------------
|
169
|
+
*
|
170
|
+
* Zstd is heavily fuzz tested, including loading fuzzed dictionaries, so
|
171
|
+
* zstd should never crash, or access out-of-bounds memory no matter what
|
172
|
+
* the dictionary is. However, if an attacker can control the dictionary
|
173
|
+
* during decompression, they can cause zstd to generate arbitrary bytes,
|
174
|
+
* just like if they controlled the compressed data.
|
175
|
+
*
|
176
|
+
******************************************************************************/
|
177
|
+
|
39
178
|
|
40
179
|
/*! ZDICT_trainFromBuffer():
|
41
180
|
* Train a dictionary from an array of samples.
|
@@ -64,7 +203,14 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
|
|
64
203
|
typedef struct {
|
65
204
|
int compressionLevel; /*< optimize for a specific zstd compression level; 0 means default */
|
66
205
|
unsigned notificationLevel; /*< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
|
67
|
-
unsigned dictID; /*< force dictID value; 0 means auto mode (32-bits random value)
|
206
|
+
unsigned dictID; /*< force dictID value; 0 means auto mode (32-bits random value)
|
207
|
+
* NOTE: The zstd format reserves some dictionary IDs for future use.
|
208
|
+
* You may use them in private settings, but be warned that they
|
209
|
+
* may be used by zstd in a public dictionary registry in the future.
|
210
|
+
* These dictionary IDs are:
|
211
|
+
* - low range : <= 32767
|
212
|
+
* - high range : >= (2^31)
|
213
|
+
*/
|
68
214
|
} ZDICT_params_t;
|
69
215
|
|
70
216
|
/*! ZDICT_finalizeDictionary():
|
data/ext/zstdruby/libzstd/zstd.h
CHANGED
@@ -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
|
@@ -71,8 +71,8 @@ extern "C" {
|
|
71
71
|
|
72
72
|
/*------ Version ------*/
|
73
73
|
#define ZSTD_VERSION_MAJOR 1
|
74
|
-
#define ZSTD_VERSION_MINOR
|
75
|
-
#define ZSTD_VERSION_RELEASE
|
74
|
+
#define ZSTD_VERSION_MINOR 5
|
75
|
+
#define ZSTD_VERSION_RELEASE 0
|
76
76
|
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
|
77
77
|
|
78
78
|
/*! ZSTD_versionNumber() :
|
@@ -109,7 +109,6 @@ ZSTDLIB_API const char* ZSTD_versionString(void);
|
|
109
109
|
#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
|
110
110
|
|
111
111
|
|
112
|
-
|
113
112
|
/***************************************
|
114
113
|
* Simple API
|
115
114
|
***************************************/
|
@@ -166,7 +165,7 @@ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t
|
|
166
165
|
* @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
|
167
166
|
ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
|
168
167
|
|
169
|
-
/*! ZSTD_findFrameCompressedSize() :
|
168
|
+
/*! ZSTD_findFrameCompressedSize() : Requires v1.4.0+
|
170
169
|
* `src` should point to the start of a ZSTD frame or skippable frame.
|
171
170
|
* `srcSize` must be >= first frame size
|
172
171
|
* @return : the compressed size of the first frame starting at `src`,
|
@@ -180,8 +179,9 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
|
|
180
179
|
ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
|
181
180
|
ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
182
181
|
ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
|
183
|
-
ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */
|
182
|
+
ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed, requires v1.4.0+ */
|
184
183
|
ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
|
184
|
+
ZSTDLIB_API int ZSTD_defaultCLevel(void); /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
|
185
185
|
|
186
186
|
|
187
187
|
/***************************************
|
@@ -199,7 +199,7 @@ ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compres
|
|
199
199
|
*/
|
200
200
|
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
|
201
201
|
ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
|
202
|
-
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
|
202
|
+
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
|
203
203
|
|
204
204
|
/*! ZSTD_compressCCtx() :
|
205
205
|
* Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
|
@@ -222,7 +222,7 @@ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
|
|
222
222
|
* Use one context per thread for parallel execution. */
|
223
223
|
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
224
224
|
ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
|
225
|
-
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
|
225
|
+
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */
|
226
226
|
|
227
227
|
/*! ZSTD_decompressDCtx() :
|
228
228
|
* Same as ZSTD_decompress(),
|
@@ -234,9 +234,9 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
|
|
234
234
|
const void* src, size_t srcSize);
|
235
235
|
|
236
236
|
|
237
|
-
|
238
|
-
* Advanced compression API
|
239
|
-
|
237
|
+
/*********************************************
|
238
|
+
* Advanced compression API (Requires v1.4.0+)
|
239
|
+
**********************************************/
|
240
240
|
|
241
241
|
/* API design :
|
242
242
|
* Parameters are pushed one by one into an existing context,
|
@@ -266,7 +266,6 @@ typedef enum { ZSTD_fast=1,
|
|
266
266
|
Only the order (from fast to strong) is guaranteed */
|
267
267
|
} ZSTD_strategy;
|
268
268
|
|
269
|
-
|
270
269
|
typedef enum {
|
271
270
|
|
272
271
|
/* compression parameters
|
@@ -332,7 +331,6 @@ typedef enum {
|
|
332
331
|
* The higher the value of selected strategy, the more complex it is,
|
333
332
|
* resulting in stronger and slower compression.
|
334
333
|
* Special: value 0 means "use default strategy". */
|
335
|
-
|
336
334
|
/* LDM mode parameters */
|
337
335
|
ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
|
338
336
|
* This parameter is designed to improve compression ratio
|
@@ -389,7 +387,7 @@ typedef enum {
|
|
389
387
|
ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
|
390
388
|
* Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
|
391
389
|
* 0 means default, which is dynamically determined based on compression parameters.
|
392
|
-
* Job size must be a minimum of overlap size, or
|
390
|
+
* Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
|
393
391
|
* The minimum size is automatically and transparently enforced. */
|
394
392
|
ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
|
395
393
|
* The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
|
@@ -419,6 +417,8 @@ typedef enum {
|
|
419
417
|
* ZSTD_c_stableOutBuffer
|
420
418
|
* ZSTD_c_blockDelimiters
|
421
419
|
* ZSTD_c_validateSequences
|
420
|
+
* ZSTD_c_splitBlocks
|
421
|
+
* ZSTD_c_useRowMatchFinder
|
422
422
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
423
423
|
* note : never ever use experimentalParam? names directly;
|
424
424
|
* also, the enums values themselves are unstable and can still change.
|
@@ -434,7 +434,10 @@ typedef enum {
|
|
434
434
|
ZSTD_c_experimentalParam9=1006,
|
435
435
|
ZSTD_c_experimentalParam10=1007,
|
436
436
|
ZSTD_c_experimentalParam11=1008,
|
437
|
-
ZSTD_c_experimentalParam12=1009
|
437
|
+
ZSTD_c_experimentalParam12=1009,
|
438
|
+
ZSTD_c_experimentalParam13=1010,
|
439
|
+
ZSTD_c_experimentalParam14=1011,
|
440
|
+
ZSTD_c_experimentalParam15=1012
|
438
441
|
} ZSTD_cParameter;
|
439
442
|
|
440
443
|
typedef struct {
|
@@ -519,9 +522,9 @@ ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
|
|
519
522
|
const void* src, size_t srcSize);
|
520
523
|
|
521
524
|
|
522
|
-
|
523
|
-
* Advanced decompression API
|
524
|
-
|
525
|
+
/***********************************************
|
526
|
+
* Advanced decompression API (Requires v1.4.0+)
|
527
|
+
************************************************/
|
525
528
|
|
526
529
|
/* The advanced API pushes parameters one by one into an existing DCtx context.
|
527
530
|
* Parameters are sticky, and remain valid for all following frames
|
@@ -667,7 +670,7 @@ typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same
|
|
667
670
|
/* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
|
668
671
|
/*===== ZSTD_CStream management functions =====*/
|
669
672
|
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
|
670
|
-
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
|
673
|
+
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */
|
671
674
|
|
672
675
|
/*===== Streaming compression functions =====*/
|
673
676
|
typedef enum {
|
@@ -683,7 +686,7 @@ typedef enum {
|
|
683
686
|
: note : multithreaded compression will block to flush as much output as possible. */
|
684
687
|
} ZSTD_EndDirective;
|
685
688
|
|
686
|
-
/*! ZSTD_compressStream2() :
|
689
|
+
/*! ZSTD_compressStream2() : Requires v1.4.0+
|
687
690
|
* Behaves about the same as ZSTD_compressStream, with additional control on end directive.
|
688
691
|
* - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
|
689
692
|
* - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
|
@@ -729,11 +732,11 @@ ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output
|
|
729
732
|
|
730
733
|
|
731
734
|
/* *****************************************************************************
|
732
|
-
* This following is a legacy streaming API.
|
735
|
+
* This following is a legacy streaming API, available since v1.0+ .
|
733
736
|
* It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
|
734
737
|
* It is redundant, but remains fully supported.
|
735
|
-
*
|
736
|
-
* new API.
|
738
|
+
* Streaming in combination with advanced parameters and dictionary compression
|
739
|
+
* can only be used through the new API.
|
737
740
|
******************************************************************************/
|
738
741
|
|
739
742
|
/*!
|
@@ -788,7 +791,7 @@ typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same
|
|
788
791
|
/* For compatibility with versions <= v1.2.0, prefer differentiating them. */
|
789
792
|
/*===== ZSTD_DStream management functions =====*/
|
790
793
|
ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
|
791
|
-
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
|
794
|
+
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */
|
792
795
|
|
793
796
|
/*===== Streaming decompression functions =====*/
|
794
797
|
|
@@ -811,7 +814,7 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
|
|
811
814
|
/*! ZSTD_compress_usingDict() :
|
812
815
|
* Compression at an explicit compression level using a Dictionary.
|
813
816
|
* A dictionary can be any arbitrary data segment (also called a prefix),
|
814
|
-
* or a buffer with specified information (see
|
817
|
+
* or a buffer with specified information (see zdict.h).
|
815
818
|
* Note : This function loads the dictionary, resulting in significant startup delay.
|
816
819
|
* It's intended for a dictionary used only once.
|
817
820
|
* Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */
|
@@ -854,7 +857,8 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize
|
|
854
857
|
int compressionLevel);
|
855
858
|
|
856
859
|
/*! ZSTD_freeCDict() :
|
857
|
-
* Function frees memory allocated by ZSTD_createCDict().
|
860
|
+
* Function frees memory allocated by ZSTD_createCDict().
|
861
|
+
* If a NULL pointer is passed, no operation is performed. */
|
858
862
|
ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
|
859
863
|
|
860
864
|
/*! ZSTD_compress_usingCDict() :
|
@@ -876,7 +880,8 @@ typedef struct ZSTD_DDict_s ZSTD_DDict;
|
|
876
880
|
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
|
877
881
|
|
878
882
|
/*! ZSTD_freeDDict() :
|
879
|
-
* Function frees memory allocated with ZSTD_createDDict()
|
883
|
+
* Function frees memory allocated with ZSTD_createDDict()
|
884
|
+
* If a NULL pointer is passed, no operation is performed. */
|
880
885
|
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
|
881
886
|
|
882
887
|
/*! ZSTD_decompress_usingDDict() :
|
@@ -892,19 +897,25 @@ ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
|
|
892
897
|
* Dictionary helper functions
|
893
898
|
*******************************/
|
894
899
|
|
895
|
-
/*! ZSTD_getDictID_fromDict() :
|
900
|
+
/*! ZSTD_getDictID_fromDict() : Requires v1.4.0+
|
896
901
|
* Provides the dictID stored within dictionary.
|
897
902
|
* if @return == 0, the dictionary is not conformant with Zstandard specification.
|
898
903
|
* It can still be loaded, but as a content-only dictionary. */
|
899
904
|
ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
|
900
905
|
|
901
|
-
/*!
|
906
|
+
/*! ZSTD_getDictID_fromCDict() : Requires v1.5.0+
|
907
|
+
* Provides the dictID of the dictionary loaded into `cdict`.
|
908
|
+
* If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
|
909
|
+
* Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
|
910
|
+
ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
|
911
|
+
|
912
|
+
/*! ZSTD_getDictID_fromDDict() : Requires v1.4.0+
|
902
913
|
* Provides the dictID of the dictionary loaded into `ddict`.
|
903
914
|
* If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
|
904
915
|
* Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
|
905
916
|
ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
|
906
917
|
|
907
|
-
/*! ZSTD_getDictID_fromFrame() :
|
918
|
+
/*! ZSTD_getDictID_fromFrame() : Requires v1.4.0+
|
908
919
|
* Provides the dictID required to decompressed the frame stored within `src`.
|
909
920
|
* If @return == 0, the dictID could not be decoded.
|
910
921
|
* This could for one of the following reasons :
|
@@ -918,7 +929,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
918
929
|
|
919
930
|
|
920
931
|
/*******************************************************************************
|
921
|
-
* Advanced dictionary and prefix API
|
932
|
+
* Advanced dictionary and prefix API (Requires v1.4.0+)
|
922
933
|
*
|
923
934
|
* This API allows dictionaries to be used with ZSTD_compress2(),
|
924
935
|
* ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and
|
@@ -927,7 +938,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
927
938
|
******************************************************************************/
|
928
939
|
|
929
940
|
|
930
|
-
/*! ZSTD_CCtx_loadDictionary() :
|
941
|
+
/*! ZSTD_CCtx_loadDictionary() : Requires v1.4.0+
|
931
942
|
* Create an internal CDict from `dict` buffer.
|
932
943
|
* Decompression will have to use same dictionary.
|
933
944
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
@@ -946,7 +957,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
|
|
946
957
|
* to precisely select how dictionary content must be interpreted. */
|
947
958
|
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
|
948
959
|
|
949
|
-
/*! ZSTD_CCtx_refCDict() :
|
960
|
+
/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
|
950
961
|
* Reference a prepared dictionary, to be used for all next compressed frames.
|
951
962
|
* Note that compression parameters are enforced from within CDict,
|
952
963
|
* and supersede any compression parameter previously set within CCtx.
|
@@ -960,7 +971,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
|
|
960
971
|
* Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */
|
961
972
|
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
|
962
973
|
|
963
|
-
/*! ZSTD_CCtx_refPrefix() :
|
974
|
+
/*! ZSTD_CCtx_refPrefix() : Requires v1.4.0+
|
964
975
|
* Reference a prefix (single-usage dictionary) for next compressed frame.
|
965
976
|
* A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
|
966
977
|
* Decompression will need same prefix to properly regenerate data.
|
@@ -981,7 +992,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
|
|
981
992
|
ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
982
993
|
const void* prefix, size_t prefixSize);
|
983
994
|
|
984
|
-
/*! ZSTD_DCtx_loadDictionary() :
|
995
|
+
/*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
|
985
996
|
* Create an internal DDict from dict buffer,
|
986
997
|
* to be used to decompress next frames.
|
987
998
|
* The dictionary remains valid for all future frames, until explicitly invalidated.
|
@@ -998,7 +1009,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
|
|
998
1009
|
*/
|
999
1010
|
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
|
1000
1011
|
|
1001
|
-
/*! ZSTD_DCtx_refDDict() :
|
1012
|
+
/*! ZSTD_DCtx_refDDict() : Requires v1.4.0+
|
1002
1013
|
* Reference a prepared dictionary, to be used to decompress next frames.
|
1003
1014
|
* The dictionary remains active for decompression of future frames using same DCtx.
|
1004
1015
|
*
|
@@ -1016,7 +1027,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
|
|
1016
1027
|
*/
|
1017
1028
|
ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
1018
1029
|
|
1019
|
-
/*! ZSTD_DCtx_refPrefix() :
|
1030
|
+
/*! ZSTD_DCtx_refPrefix() : Requires v1.4.0+
|
1020
1031
|
* Reference a prefix (single-usage dictionary) to decompress next frame.
|
1021
1032
|
* This is the reverse operation of ZSTD_CCtx_refPrefix(),
|
1022
1033
|
* and must use the same prefix as the one used during compression.
|
@@ -1037,7 +1048,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
|
|
1037
1048
|
|
1038
1049
|
/* === Memory management === */
|
1039
1050
|
|
1040
|
-
/*! ZSTD_sizeof_*() :
|
1051
|
+
/*! ZSTD_sizeof_*() : Requires v1.4.0+
|
1041
1052
|
* These functions give the _current_ memory usage of selected object.
|
1042
1053
|
* Note that object memory usage can evolve (increase or decrease) over time. */
|
1043
1054
|
ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
|
@@ -1062,6 +1073,28 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|
1062
1073
|
#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
|
1063
1074
|
#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
|
1064
1075
|
|
1076
|
+
/* Deprecation warnings :
|
1077
|
+
* Should these warnings be a problem, it is generally possible to disable them,
|
1078
|
+
* typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual.
|
1079
|
+
* Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS.
|
1080
|
+
*/
|
1081
|
+
#ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS
|
1082
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
|
1083
|
+
#else
|
1084
|
+
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
1085
|
+
# define ZSTD_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
|
1086
|
+
# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
|
1087
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
|
1088
|
+
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
1089
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
|
1090
|
+
# elif defined(_MSC_VER)
|
1091
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
|
1092
|
+
# else
|
1093
|
+
# pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler")
|
1094
|
+
# define ZSTD_DEPRECATED(message) ZSTDLIB_API
|
1095
|
+
# endif
|
1096
|
+
#endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */
|
1097
|
+
|
1065
1098
|
/****************************************************************************************
|
1066
1099
|
* experimental API (static linking only)
|
1067
1100
|
****************************************************************************************
|
@@ -1268,6 +1301,11 @@ typedef enum {
|
|
1268
1301
|
ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */
|
1269
1302
|
} ZSTD_literalCompressionMode_e;
|
1270
1303
|
|
1304
|
+
typedef enum {
|
1305
|
+
ZSTD_urm_auto = 0, /* Automatically determine whether or not we use row matchfinder */
|
1306
|
+
ZSTD_urm_disableRowMatchFinder = 1, /* Never use row matchfinder */
|
1307
|
+
ZSTD_urm_enableRowMatchFinder = 2 /* Always use row matchfinder when applicable */
|
1308
|
+
} ZSTD_useRowMatchFinderMode_e;
|
1271
1309
|
|
1272
1310
|
/***************************************
|
1273
1311
|
* Frame size functions
|
@@ -1538,11 +1576,11 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictS
|
|
1538
1576
|
* Note that the lifetime of such pool must exist while being used.
|
1539
1577
|
* ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
|
1540
1578
|
* to use an internal thread pool).
|
1541
|
-
* ZSTD_freeThreadPool frees a thread pool.
|
1579
|
+
* ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer.
|
1542
1580
|
*/
|
1543
1581
|
typedef struct POOL_ctx_s ZSTD_threadPool;
|
1544
1582
|
ZSTDLIB_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
|
1545
|
-
ZSTDLIB_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool);
|
1583
|
+
ZSTDLIB_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */
|
1546
1584
|
ZSTDLIB_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
|
1547
1585
|
|
1548
1586
|
|
@@ -1575,12 +1613,6 @@ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(
|
|
1575
1613
|
* note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */
|
1576
1614
|
ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
|
1577
1615
|
|
1578
|
-
/*! ZSTD_getDictID_fromCDict() :
|
1579
|
-
* Provides the dictID of the dictionary loaded into `cdict`.
|
1580
|
-
* If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
|
1581
|
-
* Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
|
1582
|
-
ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
|
1583
|
-
|
1584
1616
|
/*! ZSTD_getCParams() :
|
1585
1617
|
* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
|
1586
1618
|
* `estimatedSrcSize` value is optional, select 0 if not known */
|
@@ -1607,18 +1639,20 @@ ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParame
|
|
1607
1639
|
/*! ZSTD_compress_advanced() :
|
1608
1640
|
* Note : this function is now DEPRECATED.
|
1609
1641
|
* It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters.
|
1610
|
-
* This prototype will
|
1611
|
-
|
1642
|
+
* This prototype will generate compilation warnings. */
|
1643
|
+
ZSTD_DEPRECATED("use ZSTD_compress2")
|
1644
|
+
size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
|
1612
1645
|
void* dst, size_t dstCapacity,
|
1613
1646
|
const void* src, size_t srcSize,
|
1614
1647
|
const void* dict,size_t dictSize,
|
1615
1648
|
ZSTD_parameters params);
|
1616
1649
|
|
1617
1650
|
/*! ZSTD_compress_usingCDict_advanced() :
|
1618
|
-
* Note : this function is now
|
1651
|
+
* Note : this function is now DEPRECATED.
|
1619
1652
|
* It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters.
|
1620
|
-
* This prototype will
|
1621
|
-
|
1653
|
+
* This prototype will generate compilation warnings. */
|
1654
|
+
ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary")
|
1655
|
+
size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
|
1622
1656
|
void* dst, size_t dstCapacity,
|
1623
1657
|
const void* src, size_t srcSize,
|
1624
1658
|
const ZSTD_CDict* cdict,
|
@@ -1680,7 +1714,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|
1680
1714
|
|
1681
1715
|
/* Controls how the literals are compressed (default is auto).
|
1682
1716
|
* The value must be of type ZSTD_literalCompressionMode_e.
|
1683
|
-
* See
|
1717
|
+
* See ZSTD_literalCompressionMode_e enum definition for details.
|
1684
1718
|
*/
|
1685
1719
|
#define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
|
1686
1720
|
|
@@ -1832,6 +1866,46 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|
1832
1866
|
*/
|
1833
1867
|
#define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
|
1834
1868
|
|
1869
|
+
/* ZSTD_c_splitBlocks
|
1870
|
+
* Default is 0 == disabled. Set to 1 to enable block splitting.
|
1871
|
+
*
|
1872
|
+
* Will attempt to split blocks in order to improve compression ratio at the cost of speed.
|
1873
|
+
*/
|
1874
|
+
#define ZSTD_c_splitBlocks ZSTD_c_experimentalParam13
|
1875
|
+
|
1876
|
+
/* ZSTD_c_useRowMatchFinder
|
1877
|
+
* Default is ZSTD_urm_auto.
|
1878
|
+
* Controlled with ZSTD_useRowMatchFinderMode_e enum.
|
1879
|
+
*
|
1880
|
+
* By default, in ZSTD_urm_auto, when finalizing the compression parameters, the library
|
1881
|
+
* will decide at runtime whether to use the row-based matchfinder based on support for SIMD
|
1882
|
+
* instructions as well as the windowLog.
|
1883
|
+
*
|
1884
|
+
* Set to ZSTD_urm_disableRowMatchFinder to never use row-based matchfinder.
|
1885
|
+
* Set to ZSTD_urm_enableRowMatchFinder to force usage of row-based matchfinder.
|
1886
|
+
*/
|
1887
|
+
#define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14
|
1888
|
+
|
1889
|
+
/* ZSTD_c_deterministicRefPrefix
|
1890
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1891
|
+
*
|
1892
|
+
* Zstd produces different results for prefix compression when the prefix is
|
1893
|
+
* directly adjacent to the data about to be compressed vs. when it isn't.
|
1894
|
+
* This is because zstd detects that the two buffers are contiguous and it can
|
1895
|
+
* use a more efficient match finding algorithm. However, this produces different
|
1896
|
+
* results than when the two buffers are non-contiguous. This flag forces zstd
|
1897
|
+
* to always load the prefix in non-contiguous mode, even if it happens to be
|
1898
|
+
* adjacent to the data, to guarantee determinism.
|
1899
|
+
*
|
1900
|
+
* If you really care about determinism when using a dictionary or prefix,
|
1901
|
+
* like when doing delta compression, you should select this option. It comes
|
1902
|
+
* at a speed penalty of about ~2.5% if the dictionary and data happened to be
|
1903
|
+
* contiguous, and is free if they weren't contiguous. We don't expect that
|
1904
|
+
* intentionally making the dictionary and data contiguous will be worth the
|
1905
|
+
* cost to memcpy() the data.
|
1906
|
+
*/
|
1907
|
+
#define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
|
1908
|
+
|
1835
1909
|
/*! ZSTD_CCtx_getParameter() :
|
1836
1910
|
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
|
1837
1911
|
* and store it into int* value.
|
@@ -1852,13 +1926,13 @@ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter
|
|
1852
1926
|
* These parameters will be applied to
|
1853
1927
|
* all subsequent frames.
|
1854
1928
|
* - ZSTD_compressStream2() : Do compression using the CCtx.
|
1855
|
-
* - ZSTD_freeCCtxParams() : Free the memory.
|
1929
|
+
* - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer.
|
1856
1930
|
*
|
1857
1931
|
* This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
|
1858
1932
|
* for static allocation of CCtx for single-threaded compression.
|
1859
1933
|
*/
|
1860
1934
|
ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
|
1861
|
-
ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
|
1935
|
+
ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */
|
1862
1936
|
|
1863
1937
|
/*! ZSTD_CCtxParams_reset() :
|
1864
1938
|
* Reset params to default values.
|
@@ -1877,7 +1951,7 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compre
|
|
1877
1951
|
*/
|
1878
1952
|
ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
|
1879
1953
|
|
1880
|
-
/*! ZSTD_CCtxParams_setParameter() :
|
1954
|
+
/*! ZSTD_CCtxParams_setParameter() : Requires v1.4.0+
|
1881
1955
|
* Similar to ZSTD_CCtx_setParameter.
|
1882
1956
|
* Set one compression parameter, selected by enum ZSTD_cParameter.
|
1883
1957
|
* Parameters must be applied to a ZSTD_CCtx using
|
@@ -2043,11 +2117,13 @@ ZSTDLIB_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param
|
|
2043
2117
|
|
2044
2118
|
|
2045
2119
|
/*! ZSTD_DCtx_setFormat() :
|
2120
|
+
* This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter().
|
2046
2121
|
* Instruct the decoder context about what kind of data to decode next.
|
2047
2122
|
* This instruction is mandatory to decode data without a fully-formed header,
|
2048
2123
|
* such ZSTD_f_zstd1_magicless for example.
|
2049
2124
|
* @return : 0, or an error code (which can be tested using ZSTD_isError()). */
|
2050
|
-
|
2125
|
+
ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
|
2126
|
+
size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
|
2051
2127
|
|
2052
2128
|
/*! ZSTD_decompressStream_simpleArgs() :
|
2053
2129
|
* Same as ZSTD_decompressStream(),
|
@@ -2071,7 +2147,7 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
|
|
2071
2147
|
/*===== Advanced Streaming compression functions =====*/
|
2072
2148
|
|
2073
2149
|
/*! ZSTD_initCStream_srcSize() :
|
2074
|
-
* This function is
|
2150
|
+
* This function is DEPRECATED, and equivalent to:
|
2075
2151
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
2076
2152
|
* ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
|
2077
2153
|
* ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
|
@@ -2080,15 +2156,15 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
|
|
2080
2156
|
* pledgedSrcSize must be correct. If it is not known at init time, use
|
2081
2157
|
* ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs,
|
2082
2158
|
* "0" also disables frame content size field. It may be enabled in the future.
|
2083
|
-
*
|
2159
|
+
* This prototype will generate compilation warnings.
|
2084
2160
|
*/
|
2085
|
-
|
2086
|
-
ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
2161
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2162
|
+
size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
2087
2163
|
int compressionLevel,
|
2088
2164
|
unsigned long long pledgedSrcSize);
|
2089
2165
|
|
2090
2166
|
/*! ZSTD_initCStream_usingDict() :
|
2091
|
-
* This function is
|
2167
|
+
* This function is DEPRECATED, and is equivalent to:
|
2092
2168
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
2093
2169
|
* ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
|
2094
2170
|
* ZSTD_CCtx_loadDictionary(zcs, dict, dictSize);
|
@@ -2097,15 +2173,15 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
|
2097
2173
|
* dict == NULL or dictSize < 8, in which case no dict is used.
|
2098
2174
|
* Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if
|
2099
2175
|
* it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.
|
2100
|
-
*
|
2176
|
+
* This prototype will generate compilation warnings.
|
2101
2177
|
*/
|
2102
|
-
|
2103
|
-
ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
2178
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2179
|
+
size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
2104
2180
|
const void* dict, size_t dictSize,
|
2105
2181
|
int compressionLevel);
|
2106
2182
|
|
2107
2183
|
/*! ZSTD_initCStream_advanced() :
|
2108
|
-
* This function is
|
2184
|
+
* This function is DEPRECATED, and is approximately equivalent to:
|
2109
2185
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
2110
2186
|
* // Pseudocode: Set each zstd parameter and leave the rest as-is.
|
2111
2187
|
* for ((param, value) : params) {
|
@@ -2117,23 +2193,24 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
|
2117
2193
|
* dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy.
|
2118
2194
|
* pledgedSrcSize must be correct.
|
2119
2195
|
* If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN.
|
2120
|
-
*
|
2196
|
+
* This prototype will generate compilation warnings.
|
2121
2197
|
*/
|
2122
|
-
|
2123
|
-
ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
2198
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2199
|
+
size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
2124
2200
|
const void* dict, size_t dictSize,
|
2125
2201
|
ZSTD_parameters params,
|
2126
2202
|
unsigned long long pledgedSrcSize);
|
2127
2203
|
|
2128
2204
|
/*! ZSTD_initCStream_usingCDict() :
|
2129
|
-
* This function is
|
2205
|
+
* This function is DEPRECATED, and equivalent to:
|
2130
2206
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
2131
2207
|
* ZSTD_CCtx_refCDict(zcs, cdict);
|
2132
|
-
*
|
2208
|
+
*
|
2133
2209
|
* note : cdict will just be referenced, and must outlive compression session
|
2134
|
-
*
|
2210
|
+
* This prototype will generate compilation warnings.
|
2135
2211
|
*/
|
2136
|
-
|
2212
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
|
2213
|
+
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
|
2137
2214
|
|
2138
2215
|
/*! ZSTD_initCStream_usingCDict_advanced() :
|
2139
2216
|
* This function is DEPRECATED, and is approximately equivalent to:
|
@@ -2148,18 +2225,21 @@ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDi
|
|
2148
2225
|
* same as ZSTD_initCStream_usingCDict(), with control over frame parameters.
|
2149
2226
|
* pledgedSrcSize must be correct. If srcSize is not known at init time, use
|
2150
2227
|
* value ZSTD_CONTENTSIZE_UNKNOWN.
|
2151
|
-
*
|
2228
|
+
* This prototype will generate compilation warnings.
|
2152
2229
|
*/
|
2153
|
-
|
2154
|
-
ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
2230
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
|
2231
|
+
size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
2155
2232
|
const ZSTD_CDict* cdict,
|
2156
2233
|
ZSTD_frameParameters fParams,
|
2157
2234
|
unsigned long long pledgedSrcSize);
|
2158
2235
|
|
2159
2236
|
/*! ZSTD_resetCStream() :
|
2160
|
-
* This function is
|
2237
|
+
* This function is DEPRECATED, and is equivalent to:
|
2161
2238
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
2162
2239
|
* ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
|
2240
|
+
* Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but
|
2241
|
+
* ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be
|
2242
|
+
* explicitly specified.
|
2163
2243
|
*
|
2164
2244
|
* start a new frame, using same parameters from previous frame.
|
2165
2245
|
* This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
|
@@ -2169,9 +2249,10 @@ ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
|
|
2169
2249
|
* For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
|
2170
2250
|
* but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
|
2171
2251
|
* @return : 0, or an error code (which can be tested using ZSTD_isError())
|
2172
|
-
*
|
2252
|
+
* This prototype will generate compilation warnings.
|
2173
2253
|
*/
|
2174
|
-
|
2254
|
+
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
|
2255
|
+
size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
|
2175
2256
|
|
2176
2257
|
|
2177
2258
|
typedef struct {
|
@@ -2258,8 +2339,7 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
|
2258
2339
|
ZSTD_CCtx object can be re-used multiple times within successive compression operations.
|
2259
2340
|
|
2260
2341
|
Start by initializing a context.
|
2261
|
-
Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression
|
2262
|
-
or ZSTD_compressBegin_advanced(), for finer parameter control.
|
2342
|
+
Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
|
2263
2343
|
It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
|
2264
2344
|
|
2265
2345
|
Then, consume your input using ZSTD_compressContinue().
|
@@ -2284,15 +2364,17 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
|
2284
2364
|
/*===== Buffer-less streaming compression functions =====*/
|
2285
2365
|
ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
2286
2366
|
ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
2287
|
-
ZSTDLIB_API 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 */
|
2288
2367
|
ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
|
2289
|
-
ZSTDLIB_API 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 */
|
2290
2368
|
ZSTDLIB_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 */
|
2291
2369
|
|
2292
2370
|
ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2293
2371
|
ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
2294
2372
|
|
2295
|
-
|
2373
|
+
/* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */
|
2374
|
+
ZSTD_DEPRECATED("use advanced API to access custom parameters")
|
2375
|
+
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 */
|
2376
|
+
ZSTD_DEPRECATED("use advanced API to access custom parameters")
|
2377
|
+
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 */
|
2296
2378
|
/**
|
2297
2379
|
Buffer-less streaming decompression (synchronous mode)
|
2298
2380
|
|