@@ -110,6 +110,7 @@ <h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
110110 - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
111111 - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
112112 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.
113114 note 2 : decompressed size is an optional field, it may not be present (typically in streaming mode).
114115 When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
115116 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>
128129</ p > </ pre > < BR >
129130
130131< pre > < b > ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
131- ZSTDLIB_API
132132unsigned 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().
134134 Both functions work the same way, but ZSTD_getDecompressedSize() blends
135135 "empty", "unknown" and "error" results to the same return value (0),
136136 while ZSTD_getFrameContentSize() gives them separate return values.
@@ -142,7 +142,12 @@ <h3>Decompression helper functions</h3><pre></pre><b><pre></pre></b><BR>
142142 `srcSize` must be > = first frame size
143143 @return : the compressed size of the first frame starting at `src`,
144144 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.
146151</ p > </ pre > < BR >
147152
148153< 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>
166171
167172</ p > </ pre > < BR >
168173
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 >
171175 * Most ZSTD_* functions returning a size_t value can be tested for error,
172176 * using ZSTD_isError().
173177 * @return 1 if error, 0 otherwise
@@ -1239,7 +1243,7 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
12391243</ p > </ pre > < BR >
12401244
12411245< 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.
12431247 @return : size of the Frame Header,
12441248 or an error code (if srcSize is too small)
12451249</ p > </ pre > < BR >
@@ -1252,20 +1256,20 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
12521256 unsigned blockSizeMax;
12531257 ZSTD_FrameType_e frameType; </ b > /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */< b >
12541258 unsigned headerSize;
1255- unsigned dictID;
1259+ unsigned dictID; </ b > /* for ZSTD_skippableFrame, contains the skippable magic variant [0-15] */ < b >
12561260 unsigned checksumFlag;
12571261 unsigned _reserved1;
12581262 unsigned _reserved2;
1259- } ZSTD_frameHeader ;
1263+ } ZSTD_FrameHeader ;
12601264</ 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);
12621266</ b > /*! ZSTD_getFrameHeader_advanced() :< b >
12631267 * same as ZSTD_getFrameHeader(),
12641268 * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
12651269ZSTDLIB_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 ,
12691273 or an error code, which can be tested using ZSTD_isError()
12701274</ p > </ pre > < BR >
12711275
@@ -1421,7 +1425,7 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
14211425ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
14221426 void* dst, size_t dstCapacity,
14231427 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 ,
14251429 size_t decompressedSize);
14261430</ b > < p > This is a variant of ZSTD_compressSequences() which,
14271431 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>
14351439 - Not compatible with frame checksum, which must be disabled
14361440 - If any block is incompressible, will fail and return an error
14371441 - @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.
14391444 - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
14401445 @return : final compressed size, or a ZSTD error code.
14411446
14421447</ p > </ pre > < BR >
14431448
14441449< 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);
14461452</ b > < p > Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
14471453
14481454 Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number,
14491455 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.
14521458
14531459 Returns an error if destination buffer is not large enough, if the source size is not representable
14541460 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>
14571463
14581464</ p > </ pre > < BR >
14591465
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.
14631470
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.
14671474
14681475 Returns an error if destination buffer is not large enough, or if the frame is not skippable.
14691476
14701477 @return : number of bytes written or a ZSTD error.
14711478
14721479</ p > </ pre > < BR >
14731480
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);
14751482</ b > < p > Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame.
14761483
14771484</ p > </ pre > < BR >
0 commit comments