1
1
< html >
2
2
< head >
3
3
< meta http-equiv ="Content-Type " content ="text/html; charset=ISO-8859-1 ">
4
- < title > zstd 1.5.6 Manual</ title >
4
+ < title > zstd 1.5.7 Manual</ title >
5
5
</ head >
6
6
< body >
7
- < h1 > zstd 1.5.6 Manual</ h1 >
7
+ < h1 > zstd 1.5.7 Manual</ h1 >
8
+ Note: the content of this file has been automatically generated by parsing "zstd.h"
8
9
< hr >
9
10
< a name ="Contents "> </ a > < h2 > Contents</ h2 >
10
11
< ol >
11
12
< li > < a href ="#Chapter1 "> Introduction</ a > </ li >
12
13
< li > < a href ="#Chapter2 "> Version</ a > </ li >
13
- < li > < a href ="#Chapter3 "> Simple API</ a > </ li >
14
+ < li > < a href ="#Chapter3 "> Simple Core API</ a > </ li >
14
15
< li > < a href ="#Chapter4 "> Explicit context</ a > </ li >
15
16
< li > < a href ="#Chapter5 "> Advanced compression API (Requires v1.4.0+)</ a > </ li >
16
17
< li > < a href ="#Chapter6 "> Advanced decompression API (Requires v1.4.0+)</ a > </ li >
@@ -74,7 +75,7 @@ <h1>zstd 1.5.6 Manual</h1>
74
75
</ b > < p > Return runtime library version, like "1.4.5". Requires v1.3.0+.
75
76
</ p > </ pre > < BR >
76
77
77
- < a name ="Chapter3 "> </ a > < h2 > Simple API</ h2 > < pre > </ pre >
78
+ < a name ="Chapter3 "> </ a > < h2 > Simple Core API</ h2 > < pre > </ pre >
78
79
79
80
< pre > < b > size_t ZSTD_compress( void* dst, size_t dstCapacity,
80
81
const void* src, size_t srcSize,
@@ -88,38 +89,42 @@ <h1>zstd 1.5.6 Manual</h1>
88
89
89
90
< pre > < b > size_t ZSTD_decompress( void* dst, size_t dstCapacity,
90
91
const void* src, size_t compressedSize);
91
- </ b > < p > `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
92
- `dstCapacity` is an upper bound of originalSize to regenerate.
93
- If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
94
- @return : the number of bytes decompressed into `dst` (< = `dstCapacity`),
95
- or an errorCode if it fails (which can be tested using ZSTD_isError()).
92
+ </ b > < p > `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
93
+ Multiple compressed frames can be decompressed at once with this method.
94
+ The result will be the concatenation of all decompressed frames, back to back.
95
+ `dstCapacity` is an upper bound of originalSize to regenerate.
96
+ First frame's decompressed size can be extracted using ZSTD_getFrameContentSize().
97
+ If maximum upper bound isn't known, prefer using streaming mode to decompress data.
98
+ @return : the number of bytes decompressed into `dst` (< = `dstCapacity`),
99
+ or an errorCode if it fails (which can be tested using ZSTD_isError()).
96
100
</ p > </ pre > < BR >
97
101
102
+ < h3 > Decompression helper functions</ h3 > < pre > </ pre > < b > < pre > </ pre > </ b > < BR >
98
103
< pre > < b > #define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
99
104
#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
100
105
unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
101
- </ b > < p > `src` should point to the start of a ZSTD encoded frame.
102
- `srcSize` must be at least as large as the frame header.
103
- hint : any size > = `ZSTD_frameHeaderSize_max` is large enough.
104
- @return : - decompressed size of `src` frame content, if known
105
- - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
106
- - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
107
- note 1 : a 0 return value means the frame is valid but "empty".
108
- note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
109
- When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
110
- In which case, it's necessary to use streaming mode to decompress data.
111
- Optionally, application can rely on some implicit limit,
112
- as ZSTD_decompress() only needs an upper bound of decompressed size.
113
- (For example, data could be necessarily cut into blocks < = 16 KB).
114
- note 3 : decompressed size is always present when compression is completed using single-pass functions,
115
- such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
116
- note 4 : decompressed size can be very large (64-bits value),
117
- potentially larger than what local system can handle as a single memory segment.
118
- In which case, it's necessary to use streaming mode to decompress data.
119
- note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
120
- Always ensure return value fits within application's authorized limits.
121
- Each application can set its own limits.
122
- note 6 : This function replaces ZSTD_getDecompressedSize()
106
+ </ b > < p > `src` should point to the start of a ZSTD encoded frame.
107
+ `srcSize` must be at least as large as the frame header.
108
+ hint : any size > = `ZSTD_frameHeaderSize_max` is large enough.
109
+ @return : - decompressed size of `src` frame content, if known
110
+ - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
111
+ - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
112
+ note 1 : a 0 return value means the frame is valid but "empty".
113
+ note 2 : decompressed size is an optional field, it may not be present ( typically in streaming mode) .
114
+ When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
115
+ In which case, it's necessary to use streaming mode to decompress data.
116
+ Optionally, application can rely on some implicit limit,
117
+ as ZSTD_decompress() only needs an upper bound of decompressed size.
118
+ (For example, data could be necessarily cut into blocks < = 16 KB).
119
+ note 3 : decompressed size is always present when compression is completed using single-pass functions,
120
+ such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
121
+ note 4 : decompressed size can be very large (64-bits value),
122
+ potentially larger than what local system can handle as a single memory segment.
123
+ In which case, it's necessary to use streaming mode to decompress data.
124
+ note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
125
+ Always ensure return value fits within application's authorized limits.
126
+ Each application can set its own limits.
127
+ note 6 : This function replaces ZSTD_getDecompressedSize()
123
128
</ p > </ pre > < BR >
124
129
125
130
< pre > < b > ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
@@ -140,50 +145,54 @@ <h1>zstd 1.5.6 Manual</h1>
140
145
or an error code if input is invalid
141
146
</ p > </ pre > < BR >
142
147
143
- < h3 > Helper functions</ h3 > < pre > </ pre > < b > < pre > </ b > /* ZSTD_compressBound() :< b >
144
- * maximum compressed size in worst case single-pass scenario.
145
- * When invoking `ZSTD_compress()` or any other one-pass compression function,
146
- * it's recommended to provide @dstCapacity > = ZSTD_compressBound(srcSize)
147
- * as it eliminates one potential failure scenario,
148
- * aka not enough room in dst buffer to write the compressed frame.
149
- * Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
150
- * In which case, ZSTD_compressBound() will return an error code
151
- * which can be tested using ZSTD_isError().
152
- *
153
- * ZSTD_COMPRESSBOUND() :
154
- * same as ZSTD_compressBound(), but as a macro.
155
- * It can be used to produce constants, which can be useful for static allocation,
156
- * for example to size a static array on stack.
157
- * Will produce constant value 0 if srcSize too large.
158
- */
159
- #define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
148
+ < h3 > Compression helper functions</ h3 > < pre > </ pre > < b > < pre > </ pre > </ b > < BR >
149
+ < pre > < b > #define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00ULL : 0xFF00FF00U)
160
150
#define ZSTD_COMPRESSBOUND(srcSize) (((size_t)(srcSize) > = ZSTD_MAX_INPUT_SIZE) ? 0 : (srcSize) + ((srcSize)> > 8) + (((srcSize) < (128< < 10 )) ? (((128 < < 10 ) - (srcSize)) > > 11) </ b > /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) < = bound(A+B) as long as A and B > = 128 KB */< b >
161
151
size_t ZSTD_compressBound(size_t srcSize); </ b > /*!< maximum compressed size in worst case single-pass scenario * /< b>
152
+ </ b > < p > maximum compressed size in worst case single-pass scenario.
153
+ When invoking `ZSTD_compress()`, or any other one-pass compression function,
154
+ it's recommended to provide @dstCapacity > = ZSTD_compressBound(srcSize)
155
+ as it eliminates one potential failure scenario,
156
+ aka not enough room in dst buffer to write the compressed frame.
157
+ Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
158
+ In which case, ZSTD_compressBound() will return an error code
159
+ which can be tested using ZSTD_isError().
160
+
161
+ ZSTD_COMPRESSBOUND() :
162
+ same as ZSTD_compressBound(), but as a macro.
163
+ It can be used to produce constants, which can be useful for static allocation,
164
+ for example to size a static array on stack.
165
+ Will produce constant value 0 if srcSize is too large.
166
+
167
+ </ p > </ pre > < BR >
168
+
169
+ < h3 > Error helper functions</ h3 > < pre > </ pre > < b > < pre > #include "zstd_errors.h" </ b > /* list of errors */< b >
162
170
</ b > /* ZSTD_isError() :< b >
163
171
* Most ZSTD_* functions returning a size_t value can be tested for error,
164
172
* using ZSTD_isError().
165
173
* @return 1 if error, 0 otherwise
166
174
*/
167
- unsigned ZSTD_isError(size_t code); </ b > /*!< tells if a `size_t` function result is an error code * /< b>
168
- const char* ZSTD_getErrorName(size_t code); </ b > /*!< provides readable string from an error code * /< b>
169
- int ZSTD_minCLevel(void); </ b > /*!< minimum negative compression level allowed, requires v1.4.0+ * /< b>
170
- int ZSTD_maxCLevel(void); </ b > /*!< maximum compression level available * /< b>
171
- int ZSTD_defaultCLevel(void); </ b > /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ * /< b>
175
+ unsigned ZSTD_isError(size_t result); </ b > /*!< tells if a `size_t` function result is an error code * /< b>
176
+ ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); </ b > /* convert a result into an error code, which can be compared to error enum list */< b >
177
+ const char* ZSTD_getErrorName(size_t result); </ b > /*!< provides readable string from a function result * /< b>
178
+ int ZSTD_minCLevel(void); </ b > /*!< minimum negative compression level allowed, requires v1.4.0+ * /< b>
179
+ int ZSTD_maxCLevel(void); </ b > /*!< maximum compression level available * /< b>
180
+ int ZSTD_defaultCLevel(void); </ b > /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ * /< b>
172
181
</ pre > </ b > < BR >
173
182
< a name ="Chapter4 "> </ a > < h2 > Explicit context</ h2 > < pre > </ pre >
174
183
175
184
< h3 > Compression context</ h3 > < pre > When compressing many times,
176
- it is recommended to allocate a context just once,
185
+ it is recommended to allocate a compression context just once,
177
186
and reuse it for each successive compression operation.
178
- This will make workload friendlier for system's memory.
187
+ This will make the workload easier for system's memory.
179
188
Note : re-using context is just a speed / resource optimization.
180
189
It doesn't change the compression ratio, which remains identical.
181
- Note 2 : In multi-threaded environments,
182
- use one different context per thread for parallel execution .
190
+ Note 2: For parallel execution in multi-threaded environments,
191
+ use one different context per thread .
183
192
184
193
</ pre > < b > < pre > typedef struct ZSTD_CCtx_s ZSTD_CCtx;
185
194
ZSTD_CCtx* ZSTD_createCCtx(void);
186
- size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); </ b > /* accept NULL pointer */< b >
195
+ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); </ b > /* compatible with NULL pointer */< b >
187
196
</ pre > </ b > < BR >
188
197
< pre > < b > size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
189
198
void* dst, size_t dstCapacity,
@@ -194,7 +203,7 @@ <h3>Compression context</h3><pre> When compressing many times,
194
203
this function compresses at the requested compression level,
195
204
__ignoring any other advanced parameter__ .
196
205
If any advanced parameter was set using the advanced API,
197
- they will all be reset. Only ` compressionLevel` remains.
206
+ they will all be reset. Only @ compressionLevel remains.
198
207
199
208
</ p > </ pre > < BR >
200
209
@@ -394,7 +403,8 @@ <h3>Decompression context</h3><pre> When decompressing many times,
394
403
* ZSTD_c_stableOutBuffer
395
404
* ZSTD_c_blockDelimiters
396
405
* ZSTD_c_validateSequences
397
- * ZSTD_c_useBlockSplitter
406
+ * ZSTD_c_blockSplitterLevel
407
+ * ZSTD_c_splitAfterSequences
398
408
* ZSTD_c_useRowMatchFinder
399
409
* ZSTD_c_prefetchCDictTables
400
410
* ZSTD_c_enableSeqProducerFallback
@@ -421,7 +431,8 @@ <h3>Decompression context</h3><pre> When decompressing many times,
421
431
ZSTD_c_experimentalParam16=1013,
422
432
ZSTD_c_experimentalParam17=1014,
423
433
ZSTD_c_experimentalParam18=1015,
424
- ZSTD_c_experimentalParam19=1016
434
+ ZSTD_c_experimentalParam19=1016,
435
+ ZSTD_c_experimentalParam20=1017
425
436
} ZSTD_cParameter;
426
437
</ b > </ pre > < BR >
427
438
< pre > < b > typedef struct {
@@ -718,7 +729,7 @@ <h3>Streaming compression functions</h3><pre></pre><b><pre>typedef enum {
718
729
< a name ="Chapter9 "> </ a > < h2 > Streaming decompression - HowTo</ h2 > < pre >
719
730
A ZSTD_DStream object is required to track streaming operations.
720
731
Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
721
- ZSTD_DStream objects can be reused multiple times.
732
+ ZSTD_DStream objects can be re-employed multiple times.
722
733
723
734
Use ZSTD_initDStream() to start a new decompression operation.
724
735
@return : recommended first input size
@@ -728,16 +739,21 @@ <h3>Streaming compression functions</h3><pre></pre><b><pre>typedef enum {
728
739
The function will update both `pos` fields.
729
740
If `input.pos < input .size`, some input has not been consumed.
730
741
It 's up to the caller to present again remaining data.
742
+
731
743
The function tries to flush all data decoded immediately, respecting output buffer size.
732
744
If `output.pos < output .size`, decoder has flushed everything it could.
733
- But if `output.pos == output.size`, there might be some data left within internal buffers.,
745
+
746
+ However, when `output.pos == output.size`, it 's more difficult to know.
747
+ If @return > 0, the frame is not complete, meaning
748
+ either there is still some data left to flush within internal buffers,
749
+ or there is more input to read to complete the frame (or both).
734
750
In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
735
751
Note : with no additional input provided, amount of data flushed is necessarily < = ZSTD_BLOCKSIZE_MAX.
736
752
@return : 0 when a frame is completely decoded and fully flushed,
737
753
or an error code, which can be tested using ZSTD_isError(),
738
754
or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
739
755
the return value is a suggested next input size (just a hint for better latency)
740
- that will never request more than the remaining frame size .
756
+ that will never request more than the remaining content of the compressed frame .
741
757
742
758
< BR > </ pre >
743
759
@@ -763,9 +779,10 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
763
779
Function will update both input and output `pos` fields exposing current state via these fields:
764
780
- `input.pos < input .size`, some input remaining and caller should provide remaining input
765
781
on the next call.
766
- - `output.pos < output .size`, decoder finished and flushed all remaining buffers.
767
- - `output.pos == output.size`, potentially uncflushed data present in the internal buffers,
768
- call ZSTD_decompressStream() again to flush remaining data to output.
782
+ - `output.pos < output .size`, decoder flushed internal output buffer.
783
+ - `output.pos == output.size`, unflushed data potentially present in the internal buffers,
784
+ check ZSTD_decompressStream() @return value,
785
+ if > 0, invoke it again to flush remaining data to output.
769
786
Note : with no additional input, amount of data flushed < = ZSTD_BLOCKSIZE_MAX.
770
787
771
788
@return : 0 when a frame is completely decoded and fully flushed,
@@ -1311,19 +1328,37 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1311
1328
1312
1329
</ p > </ pre > < BR >
1313
1330
1314
- < pre > < b > </ b > < p > Generate sequences using ZSTD_compress2(), given a source buffer.
1331
+ < pre > < b > ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()")
1332
+ ZSTDLIB_STATIC_API size_t
1333
+ ZSTD_generateSequences(ZSTD_CCtx* zc,
1334
+ ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1335
+ const void* src, size_t srcSize);
1336
+ </ b > < p > WARNING: This function is meant for debugging and informational purposes ONLY!
1337
+ Its implementation is flawed, and it will be deleted in a future version.
1338
+ It is not guaranteed to succeed, as there are several cases where it will give
1339
+ up and fail. You should NOT use this function in production code.
1340
+
1341
+ This function is deprecated, and will be removed in a future version.
1342
+
1343
+ Generate sequences using ZSTD_compress2(), given a source buffer.
1344
+
1345
+ @param zc The compression context to be used for ZSTD_compress2(). Set any
1346
+ compression parameters you need on this context.
1347
+ @param outSeqs The output sequences buffer of size @p outSeqsSize
1348
+ @param outSeqsSize The size of the output sequences buffer.
1349
+ ZSTD_sequenceBound(srcSize) is an upper bound on the number
1350
+ of sequences that can be generated.
1351
+ @param src The source buffer to generate sequences from of size @p srcSize.
1352
+ @param srcSize The size of the source buffer.
1315
1353
1316
1354
Each block will end with a dummy sequence
1317
1355
with offset == 0, matchLength == 0, and litLength == length of last literals.
1318
1356
litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
1319
1357
simply acts as a block delimiter.
1320
1358
1321
- @zc can be used to insert custom compression params.
1322
- This function invokes ZSTD_compress2().
1323
-
1324
- The output of this function can be fed into ZSTD_compressSequences() with CCtx
1325
- setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
1326
- @return : number of sequences generated
1359
+ @returns The number of sequences generated, necessarily less than
1360
+ ZSTD_sequenceBound(srcSize), or an error code that can be checked
1361
+ with ZSTD_isError().
1327
1362
1328
1363
</ p > </ pre > < BR >
1329
1364
@@ -1512,13 +1547,14 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1512
1547
#ifdef __GNUC__
1513
1548
__attribute__((__unused__))
1514
1549
#endif
1515
- ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; </ b > /**< this constant defers to stdlib 's functions */< b>
1516
1550
</ b > < p > These prototypes make it possible to pass your own allocation/free functions.
1517
1551
ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below.
1518
1552
All allocation/free operations will be completed using these custom variants instead of regular < stdlib .h > ones.
1519
1553
1520
1554
</ p > </ pre > < BR >
1521
1555
1556
+ < pre > < b > ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; </ b > /**< this constant defers to stdlib 's functions */< b>
1557
+ </ b > </ pre > < BR >
1522
1558
< pre > < b > typedef struct POOL_ctx_s ZSTD_threadPool;
1523
1559
ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
1524
1560
ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); </ b > /* accept NULL pointer */< b >
0 commit comments