@@ -262,9 +262,9 @@ ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer *
262
262
263
263
/* ! ZSTD_compressCCtx() :
264
264
* Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
265
- * Important : in order to behave similarly to `ZSTD_compress()`,
266
- * this function compresses at requested compression level,
267
- * __ignoring any other parameter__ .
265
+ * Important : in order to mirror `ZSTD_compress()` behavior ,
266
+ * this function compresses at the requested compression level,
267
+ * __ignoring any other advanced parameter__ .
268
268
* If any advanced parameter was set using the advanced API,
269
269
* they will all be reset. Only `compressionLevel` remains.
270
270
*/
@@ -286,7 +286,7 @@ ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer *
286
286
/* ! ZSTD_decompressDCtx() :
287
287
* Same as ZSTD_decompress(),
288
288
* requires an allocated ZSTD_DCtx.
289
- * Compatible with sticky parameters.
289
+ * Compatible with sticky parameters (see below) .
290
290
*/
291
291
ZSTDLIB_API size_t ZSTD_decompressDCtx (ZSTD_DCtx* dctx,
292
292
void * dst, size_t dstCapacity,
@@ -302,12 +302,12 @@ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
302
302
* using ZSTD_CCtx_set*() functions.
303
303
* Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame.
304
304
* "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` !
305
- * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ .
305
+ * __They do not apply to one-shot variants such as ZSTD_compressCCtx()__ .
306
306
*
307
307
* It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
308
308
*
309
309
* This API supersedes all other "advanced" API entry points in the experimental section.
310
- * In the future, we expect to remove from experimental API entry points which are redundant with this API.
310
+ * In the future, we expect to remove API entry points from experimental which are redundant with this API.
311
311
*/
312
312
313
313
@@ -390,16 +390,19 @@ typedef enum {
390
390
* The higher the value of selected strategy, the more complex it is,
391
391
* resulting in stronger and slower compression.
392
392
* Special: value 0 means "use default strategy". */
393
- ZSTD_c_targetCBlockSize=130 , /* Tries to fit compressed block size to be
394
- * around targetCBlockSize. No target when
395
- * targetCBlockSize == 0. There is no guarantee
396
- * on compressed block size (default:0).
397
- * Since the decoder has to buffer a complete
398
- * block to begin decoding it, in low band-
399
- * width streaming environments this may
400
- * improve end-to-end latency. Bound by
401
- * ZSTD_TARGETCBLOCKSIZE_MIN and
402
- * ZSTD_TARGETCBLOCKSIZE_MAX. */
393
+
394
+ ZSTD_c_targetCBlockSize=130 , /* v1.5.6+
395
+ * Attempts to fit compressed block size into approximatively targetCBlockSize.
396
+ * Bound by ZSTD_TARGETCBLOCKSIZE_MIN and ZSTD_TARGETCBLOCKSIZE_MAX.
397
+ * Note that it's not a guarantee, just a convergence target (default:0).
398
+ * No target when targetCBlockSize == 0.
399
+ * This is helpful in low bandwidth streaming environments to improve end-to-end latency,
400
+ * when a client can make use of partial documents (a prominent example being Chrome).
401
+ * Note: this parameter is stable since v1.5.6.
402
+ * It was present as an experimental parameter in earlier versions,
403
+ * but it's not recommended using it with earlier library versions
404
+ * due to massive performance regressions.
405
+ */
403
406
/* LDM mode parameters */
404
407
ZSTD_c_enableLongDistanceMatching=160 , /* Enable long distance matching.
405
408
* This parameter is designed to improve compression ratio
@@ -584,6 +587,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
584
587
585
588
/* ! ZSTD_compress2() :
586
589
* Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.
590
+ * (note that this entry point doesn't even expose a compression level parameter).
587
591
* ZSTD_compress2() always starts a new frame.
588
592
* Should cctx hold data from a previously unfinished frame, everything about it is forgotten.
589
593
* - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
@@ -787,6 +791,11 @@ typedef enum {
787
791
* only ZSTD_e_end or ZSTD_e_flush operations are allowed.
788
792
* Before starting a new compression job, or changing compression parameters,
789
793
* it is required to fully flush internal buffers.
794
+ * - note: if an operation ends with an error, it may leave @cctx in an undefined state.
795
+ * Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state.
796
+ * In order to be re-employed after an error, a state must be reset,
797
+ * which can be done explicitly (ZSTD_CCtx_reset()),
798
+ * or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())
790
799
*/
791
800
ZSTDLIB_API size_t ZSTD_compressStream2 ( ZSTD_CCtx* cctx,
792
801
ZSTD_outBuffer* output,
@@ -900,6 +909,12 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
900
909
* @return : 0 when a frame is completely decoded and fully flushed,
901
910
* or an error code, which can be tested using ZSTD_isError(),
902
911
* or any other value > 0, which means there is some decoding or flushing to do to complete current frame.
912
+ *
913
+ * Note: when an operation returns with an error code, the @zds state may be left in undefined state.
914
+ * It's UB to invoke `ZSTD_decompressStream()` on such a state.
915
+ * In order to re-use such a state, it must be first reset,
916
+ * which can be done explicitly (`ZSTD_DCtx_reset()`),
917
+ * or is implied for operations starting some new decompression job (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
903
918
*/
904
919
ZSTDLIB_API size_t ZSTD_decompressStream (ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
905
920
@@ -1250,7 +1265,7 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1250
1265
#define ZSTD_LDM_HASHRATELOG_MAX (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
1251
1266
1252
1267
/* Advanced parameter bounds */
1253
- #define ZSTD_TARGETCBLOCKSIZE_MIN 64
1268
+ #define ZSTD_TARGETCBLOCKSIZE_MIN 1340 /* suitable to fit into an ethernet / wifi / 4G transport frame */
1254
1269
#define ZSTD_TARGETCBLOCKSIZE_MAX ZSTD_BLOCKSIZE_MAX
1255
1270
#define ZSTD_SRCSIZEHINT_MIN 0
1256
1271
#define ZSTD_SRCSIZEHINT_MAX INT_MAX
0 commit comments