@@ -110,6 +110,7 @@ <h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
110
110
- ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
111
111
- ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
112
112
note 1 : a 0 return value means the frame is valid but "empty".
113
+ When invoking this method on a skippable frame, it will return 0.
113
114
note 2 : decompressed size is an optional field, it may not be present (typically in streaming mode).
114
115
When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
115
116
In which case, it's necessary to use streaming mode to decompress data.
@@ -128,9 +129,8 @@ <h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
128
129
</ p > </ pre > < BR >
129
130
130
131
< pre > < b > ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
131
- ZSTDLIB_API
132
132
unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
133
- </ b > < p > NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
133
+ </ b > < p > This function is now obsolete, in favor of ZSTD_getFrameContentSize().
134
134
Both functions work the same way, but ZSTD_getDecompressedSize() blends
135
135
"empty", "unknown" and "error" results to the same return value (0),
136
136
while ZSTD_getFrameContentSize() gives them separate return values.
@@ -142,7 +142,12 @@ <h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
142
142
`srcSize` must be > = first frame size
143
143
@return : the compressed size of the first frame starting at `src`,
144
144
suitable to pass as `srcSize` to `ZSTD_decompress` or similar,
145
- or an error code if input is invalid
145
+ or an error code if input is invalid
146
+ Note 1: this method is called _find*() because it's not enough to read the header,
147
+ it may have to scan through the frame's content, to reach its end.
148
+ Note 2: this method also works with Skippable Frames. In which case,
149
+ it returns the size of the complete skippable frame,
150
+ which is always equal to its content size + 8 bytes for headers.
146
151
</ p > </ pre > < BR >
147
152
148
153
< h3 > Compression helper functions</ h3 > < pre > </ pre > < b > < pre > </ pre > </ b > < BR >
@@ -166,8 +171,7 @@ <h3>Compression helper functions</h3><pre></pre><b><pre></pre></b><BR>
166
171
167
172
</ p > </ pre > < BR >
168
173
169
- < h3 > Error helper functions</ h3 > < pre > </ pre > < b > < pre > #include "zstd_errors.h" </ b > /* list of errors */< b >
170
- </ b > /* ZSTD_isError() :< b >
174
+ < h3 > Error helper functions</ h3 > < pre > </ pre > < b > < pre > </ b > /* ZSTD_isError() :< b >
171
175
* Most ZSTD_* functions returning a size_t value can be tested for error,
172
176
* using ZSTD_isError().
173
177
* @return 1 if error, 0 otherwise
@@ -1239,7 +1243,7 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1239
1243
</ p > </ pre > < BR >
1240
1244
1241
1245
< pre > < b > ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1242
- </ b > < p > srcSize must be > = ZSTD_FRAMEHEADERSIZE_PREFIX.
1246
+ </ b > < p > srcSize must be large enough, aka > = ZSTD_FRAMEHEADERSIZE_PREFIX.
1243
1247
@return : size of the Frame Header,
1244
1248
or an error code (if srcSize is too small)
1245
1249
</ p > </ pre > < BR >
@@ -1252,20 +1256,20 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1252
1256
unsigned blockSizeMax;
1253
1257
ZSTD_FrameType_e frameType; </ b > /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */< b >
1254
1258
unsigned headerSize;
1255
- unsigned dictID;
1259
+ unsigned dictID; </ b > /* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */ < b >
1256
1260
unsigned checksumFlag;
1257
1261
unsigned _reserved1;
1258
1262
unsigned _reserved2;
1259
- } ZSTD_frameHeader ;
1263
+ } ZSTD_FrameHeader ;
1260
1264
</ b > </ pre > < BR >
1261
- < pre > < b > ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize); </ b > /** < doesn 't consume input */ < b >
1265
+ < pre > < b > ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize);
1262
1266
</ b > /*! ZSTD_getFrameHeader_advanced() :< b >
1263
1267
* same as ZSTD_getFrameHeader(),
1264
1268
* with added capability to select a format (like ZSTD_f_zstd1_magicless) */
1265
1269
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_FrameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
1266
- </ b > < p > decode Frame Header, or requires larger `srcSize`.
1267
- @return : 0, `zfhPtr` is correctly filled,
1268
- > 0, `srcSize` is too small, value is wanted `srcSize` amount,
1270
+ </ b > < p > decode Frame Header into `zfhPtr` , or requires larger `srcSize`.
1271
+ @return : 0 = > header is complete , `zfhPtr` is correctly filled,
1272
+ > 0 = > `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled ,
1269
1273
or an error code, which can be tested using ZSTD_isError()
1270
1274
</ p > </ pre > < BR >
1271
1275
@@ -1421,7 +1425,7 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1421
1425
ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
1422
1426
void* dst, size_t dstCapacity,
1423
1427
const ZSTD_Sequence* inSeqs, size_t nbSequences,
1424
- const void* literals, size_t litSize, size_t litCapacity ,
1428
+ const void* literals, size_t litSize, size_t litBufCapacity ,
1425
1429
size_t decompressedSize);
1426
1430
</ b > < p > This is a variant of ZSTD_compressSequences() which,
1427
1431
instead of receiving (src,srcSize) as input parameter, receives (literals,litSize),
@@ -1435,20 +1439,22 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1435
1439
- Not compatible with frame checksum, which must be disabled
1436
1440
- If any block is incompressible, will fail and return an error
1437
1441
- @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error.
1438
- - the buffer @literals must have a size @litCapacity which is larger than @litSize by at least 8 bytes.
1442
+ - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals.
1443
+ @litBufCapacity must be at least 8 bytes larger than @litSize.
1439
1444
- @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
1440
1445
@return : final compressed size, or a ZSTD error code.
1441
1446
1442
1447
</ p > </ pre > < BR >
1443
1448
1444
1449
< pre > < b > ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
1445
- const void* src, size_t srcSize, unsigned magicVariant);
1450
+ const void* src, size_t srcSize,
1451
+ unsigned magicVariant);
1446
1452
</ b > < p > Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
1447
1453
1448
1454
Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number,
1449
1455
ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
1450
- As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
1451
- the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1456
+ As such, the parameter magicVariant controls the exact skippable frame magic number variant used,
1457
+ so the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
1452
1458
1453
1459
Returns an error if destination buffer is not large enough, if the source size is not representable
1454
1460
with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
@@ -1457,21 +1463,22 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
1457
1463
1458
1464
</ p > </ pre > < BR >
1459
1465
1460
- < pre > < b > size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
1461
- const void* src, size_t srcSize);
1462
- </ b > < p > Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.
1466
+ < pre > < b > ZSTDLIB_STATIC_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity,
1467
+ unsigned* magicVariant,
1468
+ const void* src, size_t srcSize);
1469
+ </ b > < p > Retrieves the content of a zstd skippable frame starting at @src, and writes it to @dst buffer.
1463
1470
1464
- The parameter magicVariant will receive the magicVariant that was supplied when the frame was written,
1465
- i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested
1466
- in the magicVariant.
1471
+ The parameter @ magicVariant will receive the magicVariant that was supplied when the frame was written,
1472
+ i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START.
1473
+ This can be NULL if the caller is not interested in the magicVariant.
1467
1474
1468
1475
Returns an error if destination buffer is not large enough, or if the frame is not skippable.
1469
1476
1470
1477
@return : number of bytes written or a ZSTD error.
1471
1478
1472
1479
</ p > </ pre > < BR >
1473
1480
1474
- < pre > < b > unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1481
+ < pre > < b > ZSTDLIB_STATIC_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1475
1482
</ b > < p > Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
1476
1483
1477
1484
</ p > </ pre > < BR >
0 commit comments