zstd-ruby 1.4.5.0 → 1.4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +2 -2
- data/ext/zstdruby/libzstd/Makefile +237 -138
- data/ext/zstdruby/libzstd/README.md +28 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +25 -16
- data/ext/zstdruby/libzstd/common/compiler.h +118 -4
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +12 -19
- data/ext/zstdruby/libzstd/common/entropy_common.c +189 -43
- data/ext/zstdruby/libzstd/common/error_private.c +2 -1
- data/ext/zstdruby/libzstd/common/error_private.h +2 -2
- data/ext/zstdruby/libzstd/common/fse.h +40 -12
- data/ext/zstdruby/libzstd/common/fse_decompress.c +124 -17
- data/ext/zstdruby/libzstd/common/huf.h +27 -6
- data/ext/zstdruby/libzstd/common/mem.h +67 -94
- data/ext/zstdruby/libzstd/common/pool.c +23 -17
- data/ext/zstdruby/libzstd/common/pool.h +2 -2
- data/ext/zstdruby/libzstd/common/threading.c +6 -5
- data/ext/zstdruby/libzstd/common/xxhash.c +19 -57
- data/ext/zstdruby/libzstd/common/xxhash.h +2 -2
- data/ext/zstdruby/libzstd/common/zstd_common.c +10 -10
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_errors.h +2 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +90 -59
- data/ext/zstdruby/libzstd/common/zstd_trace.c +42 -0
- data/ext/zstdruby/libzstd/common/zstd_trace.h +152 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +31 -24
- data/ext/zstdruby/libzstd/compress/hist.c +27 -29
- data/ext/zstdruby/libzstd/compress/hist.h +2 -2
- data/ext/zstdruby/libzstd/compress/huf_compress.c +217 -101
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1495 -478
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +143 -44
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +7 -7
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +18 -4
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +62 -26
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +23 -23
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +21 -21
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +352 -78
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +21 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +276 -209
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +8 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +103 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +191 -46
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +79 -410
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +27 -109
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +303 -201
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +9 -9
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +370 -87
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +153 -45
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +6 -3
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +28 -11
- 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 +40 -31
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +2 -2
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +26 -25
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +22 -24
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +5 -4
- data/ext/zstdruby/libzstd/dll/example/Makefile +1 -1
- data/ext/zstdruby/libzstd/dll/example/README.md +16 -22
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +7 -3
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/libzstd.pc.in +3 -3
- data/ext/zstdruby/libzstd/zstd.h +414 -54
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +7 -3
- data/.travis.yml +0 -14
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -82,7 +82,11 @@ extern "C" {
|
|
82
82
|
* Basic Types
|
83
83
|
*****************************************************************/
|
84
84
|
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
|
85
|
-
#
|
85
|
+
# if defined(_AIX)
|
86
|
+
# include <inttypes.h>
|
87
|
+
# else
|
88
|
+
# include <stdint.h> /* intptr_t */
|
89
|
+
# endif
|
86
90
|
typedef uint8_t BYTE;
|
87
91
|
typedef uint16_t U16;
|
88
92
|
typedef int16_t S16;
|
@@ -3025,7 +3029,7 @@ typedef struct
|
|
3025
3029
|
* Provides the size of compressed block from block header `src` */
|
3026
3030
|
static size_t ZSTDv06_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
|
3027
3031
|
{
|
3028
|
-
const BYTE* const in = (const BYTE*
|
3032
|
+
const BYTE* const in = (const BYTE*)src;
|
3029
3033
|
U32 cSize;
|
3030
3034
|
|
3031
3035
|
if (srcSize < ZSTDv06_blockHeaderSize) return ERROR(srcSize_wrong);
|
@@ -3219,7 +3223,7 @@ static size_t ZSTDv06_decodeSeqHeaders(int* nbSeqPtr,
|
|
3219
3223
|
FSEv06_DTable* DTableLL, FSEv06_DTable* DTableML, FSEv06_DTable* DTableOffb, U32 flagRepeatTable,
|
3220
3224
|
const void* src, size_t srcSize)
|
3221
3225
|
{
|
3222
|
-
const BYTE* const istart = (const BYTE*
|
3226
|
+
const BYTE* const istart = (const BYTE*)src;
|
3223
3227
|
const BYTE* const iend = istart + srcSize;
|
3224
3228
|
const BYTE* ip = istart;
|
3225
3229
|
|
@@ -3441,7 +3445,7 @@ static size_t ZSTDv06_decompressSequences(
|
|
3441
3445
|
{
|
3442
3446
|
const BYTE* ip = (const BYTE*)seqStart;
|
3443
3447
|
const BYTE* const iend = ip + seqSize;
|
3444
|
-
BYTE* const ostart = (BYTE*
|
3448
|
+
BYTE* const ostart = (BYTE*)dst;
|
3445
3449
|
BYTE* const oend = ostart + maxDstSize;
|
3446
3450
|
BYTE* op = ostart;
|
3447
3451
|
const BYTE* litPtr = dctx->litPtr;
|
@@ -3557,7 +3561,7 @@ static size_t ZSTDv06_decompressFrame(ZSTDv06_DCtx* dctx,
|
|
3557
3561
|
{
|
3558
3562
|
const BYTE* ip = (const BYTE*)src;
|
3559
3563
|
const BYTE* const iend = ip + srcSize;
|
3560
|
-
BYTE* const ostart = (BYTE*
|
3564
|
+
BYTE* const ostart = (BYTE*)dst;
|
3561
3565
|
BYTE* op = ostart;
|
3562
3566
|
BYTE* const oend = ostart + dstCapacity;
|
3563
3567
|
size_t remainingSize = srcSize;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -242,7 +242,11 @@ extern "C" {
|
|
242
242
|
* Basic Types
|
243
243
|
*****************************************************************/
|
244
244
|
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
|
245
|
-
#
|
245
|
+
# if defined(_AIX)
|
246
|
+
# include <inttypes.h>
|
247
|
+
# else
|
248
|
+
# include <stdint.h> /* intptr_t */
|
249
|
+
# endif
|
246
250
|
typedef uint8_t BYTE;
|
247
251
|
typedef uint16_t U16;
|
248
252
|
typedef int16_t S16;
|
@@ -3254,7 +3258,7 @@ typedef struct
|
|
3254
3258
|
* Provides the size of compressed block from block header `src` */
|
3255
3259
|
static size_t ZSTDv07_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
|
3256
3260
|
{
|
3257
|
-
const BYTE* const in = (const BYTE*
|
3261
|
+
const BYTE* const in = (const BYTE*)src;
|
3258
3262
|
U32 cSize;
|
3259
3263
|
|
3260
3264
|
if (srcSize < ZSTDv07_blockHeaderSize) return ERROR(srcSize_wrong);
|
@@ -3449,7 +3453,7 @@ static size_t ZSTDv07_decodeSeqHeaders(int* nbSeqPtr,
|
|
3449
3453
|
FSEv07_DTable* DTableLL, FSEv07_DTable* DTableML, FSEv07_DTable* DTableOffb, U32 flagRepeatTable,
|
3450
3454
|
const void* src, size_t srcSize)
|
3451
3455
|
{
|
3452
|
-
const BYTE* const istart = (const BYTE*
|
3456
|
+
const BYTE* const istart = (const BYTE*)src;
|
3453
3457
|
const BYTE* const iend = istart + srcSize;
|
3454
3458
|
const BYTE* ip = istart;
|
3455
3459
|
|
@@ -3668,7 +3672,7 @@ static size_t ZSTDv07_decompressSequences(
|
|
3668
3672
|
{
|
3669
3673
|
const BYTE* ip = (const BYTE*)seqStart;
|
3670
3674
|
const BYTE* const iend = ip + seqSize;
|
3671
|
-
BYTE* const ostart = (BYTE*
|
3675
|
+
BYTE* const ostart = (BYTE*)dst;
|
3672
3676
|
BYTE* const oend = ostart + maxDstSize;
|
3673
3677
|
BYTE* op = ostart;
|
3674
3678
|
const BYTE* litPtr = dctx->litPtr;
|
@@ -3795,7 +3799,7 @@ static size_t ZSTDv07_decompressFrame(ZSTDv07_DCtx* dctx,
|
|
3795
3799
|
{
|
3796
3800
|
const BYTE* ip = (const BYTE*)src;
|
3797
3801
|
const BYTE* const iend = ip + srcSize;
|
3798
|
-
BYTE* const ostart = (BYTE*
|
3802
|
+
BYTE* const ostart = (BYTE*)dst;
|
3799
3803
|
BYTE* const oend = ostart + dstCapacity;
|
3800
3804
|
BYTE* op = ostart;
|
3801
3805
|
size_t remainingSize = srcSize;
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
4
4
|
|
5
5
|
prefix=@PREFIX@
|
6
|
-
exec_prefix
|
7
|
-
includedir
|
8
|
-
libdir
|
6
|
+
exec_prefix=@EXEC_PREFIX@
|
7
|
+
includedir=@INCLUDEDIR@
|
8
|
+
libdir=@LIBDIR@
|
9
9
|
|
10
10
|
Name: zstd
|
11
11
|
Description: fast lossless compression algorithm library
|
data/ext/zstdruby/libzstd/zstd.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -72,16 +72,21 @@ extern "C" {
|
|
72
72
|
/*------ Version ------*/
|
73
73
|
#define ZSTD_VERSION_MAJOR 1
|
74
74
|
#define ZSTD_VERSION_MINOR 4
|
75
|
-
#define ZSTD_VERSION_RELEASE
|
76
|
-
|
75
|
+
#define ZSTD_VERSION_RELEASE 9
|
77
76
|
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
|
78
|
-
|
77
|
+
|
78
|
+
/*! ZSTD_versionNumber() :
|
79
|
+
* Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). */
|
80
|
+
ZSTDLIB_API unsigned ZSTD_versionNumber(void);
|
79
81
|
|
80
82
|
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
|
81
83
|
#define ZSTD_QUOTE(str) #str
|
82
84
|
#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
|
83
85
|
#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
|
84
|
-
|
86
|
+
|
87
|
+
/*! ZSTD_versionString() :
|
88
|
+
* Return runtime library version, like "1.4.5". Requires v1.3.0+. */
|
89
|
+
ZSTDLIB_API const char* ZSTD_versionString(void);
|
85
90
|
|
86
91
|
/* *************************************
|
87
92
|
* Default constant
|
@@ -334,7 +339,9 @@ typedef enum {
|
|
334
339
|
* for large inputs, by finding large matches at long distance.
|
335
340
|
* It increases memory usage and window size.
|
336
341
|
* Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
|
337
|
-
* except when expressly set to a different value.
|
342
|
+
* except when expressly set to a different value.
|
343
|
+
* Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
|
344
|
+
* compression strategy >= ZSTD_btopt (== compression level 16+) */
|
338
345
|
ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
|
339
346
|
* Larger values increase memory usage and compression ratio,
|
340
347
|
* but decrease compression speed.
|
@@ -365,16 +372,20 @@ typedef enum {
|
|
365
372
|
ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
|
366
373
|
|
367
374
|
/* multi-threading parameters */
|
368
|
-
/* These parameters are only
|
369
|
-
*
|
375
|
+
/* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
|
376
|
+
* Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
|
377
|
+
* In a situation where it's unknown if the linked library supports multi-threading or not,
|
378
|
+
* setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
|
379
|
+
*/
|
370
380
|
ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
|
371
|
-
* When nbWorkers >= 1, triggers asynchronous mode when
|
381
|
+
* When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
|
372
382
|
* ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
|
373
|
-
* while compression
|
383
|
+
* while compression is performed in parallel, within worker thread(s).
|
374
384
|
* (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
|
375
385
|
* in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
|
376
386
|
* More workers improve speed, but also increase memory usage.
|
377
|
-
* Default value is `0`, aka "single-threaded mode" : no worker is spawned,
|
387
|
+
* Default value is `0`, aka "single-threaded mode" : no worker is spawned,
|
388
|
+
* compression is performed inside Caller's thread, and all invocations are blocking */
|
378
389
|
ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
|
379
390
|
* Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
|
380
391
|
* 0 means default, which is dynamically determined based on compression parameters.
|
@@ -403,6 +414,11 @@ typedef enum {
|
|
403
414
|
* ZSTD_c_literalCompressionMode
|
404
415
|
* ZSTD_c_targetCBlockSize
|
405
416
|
* ZSTD_c_srcSizeHint
|
417
|
+
* ZSTD_c_enableDedicatedDictSearch
|
418
|
+
* ZSTD_c_stableInBuffer
|
419
|
+
* ZSTD_c_stableOutBuffer
|
420
|
+
* ZSTD_c_blockDelimiters
|
421
|
+
* ZSTD_c_validateSequences
|
406
422
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
407
423
|
* note : never ever use experimentalParam? names directly;
|
408
424
|
* also, the enums values themselves are unstable and can still change.
|
@@ -413,7 +429,12 @@ typedef enum {
|
|
413
429
|
ZSTD_c_experimentalParam4=1001,
|
414
430
|
ZSTD_c_experimentalParam5=1002,
|
415
431
|
ZSTD_c_experimentalParam6=1003,
|
416
|
-
ZSTD_c_experimentalParam7=1004
|
432
|
+
ZSTD_c_experimentalParam7=1004,
|
433
|
+
ZSTD_c_experimentalParam8=1005,
|
434
|
+
ZSTD_c_experimentalParam9=1006,
|
435
|
+
ZSTD_c_experimentalParam10=1007,
|
436
|
+
ZSTD_c_experimentalParam11=1008,
|
437
|
+
ZSTD_c_experimentalParam12=1009
|
417
438
|
} ZSTD_cParameter;
|
418
439
|
|
419
440
|
typedef struct {
|
@@ -524,11 +545,15 @@ typedef enum {
|
|
524
545
|
* At the time of this writing, they include :
|
525
546
|
* ZSTD_d_format
|
526
547
|
* ZSTD_d_stableOutBuffer
|
548
|
+
* ZSTD_d_forceIgnoreChecksum
|
549
|
+
* ZSTD_d_refMultipleDDicts
|
527
550
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
528
551
|
* note : never ever use experimentalParam? names directly
|
529
552
|
*/
|
530
553
|
ZSTD_d_experimentalParam1=1000,
|
531
|
-
ZSTD_d_experimentalParam2=1001
|
554
|
+
ZSTD_d_experimentalParam2=1001,
|
555
|
+
ZSTD_d_experimentalParam3=1002,
|
556
|
+
ZSTD_d_experimentalParam4=1003
|
532
557
|
|
533
558
|
} ZSTD_dParameter;
|
534
559
|
|
@@ -664,8 +689,9 @@ typedef enum {
|
|
664
689
|
* - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
|
665
690
|
* - output->pos must be <= dstCapacity, input->pos must be <= srcSize
|
666
691
|
* - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
|
692
|
+
* - endOp must be a valid directive
|
667
693
|
* - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
|
668
|
-
* - When nbWorkers>=1, function is non-blocking : it
|
694
|
+
* - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available,
|
669
695
|
* and then immediately returns, just indicating that there is some data remaining to be flushed.
|
670
696
|
* The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
|
671
697
|
* - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.
|
@@ -924,7 +950,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
|
|
924
950
|
* Reference a prepared dictionary, to be used for all next compressed frames.
|
925
951
|
* Note that compression parameters are enforced from within CDict,
|
926
952
|
* and supersede any compression parameter previously set within CCtx.
|
927
|
-
* The parameters ignored are
|
953
|
+
* The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
|
928
954
|
* The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.
|
929
955
|
* The dictionary will remain valid for future compressed frames using same CCtx.
|
930
956
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
@@ -975,6 +1001,13 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
|
|
975
1001
|
/*! ZSTD_DCtx_refDDict() :
|
976
1002
|
* Reference a prepared dictionary, to be used to decompress next frames.
|
977
1003
|
* The dictionary remains active for decompression of future frames using same DCtx.
|
1004
|
+
*
|
1005
|
+
* If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
|
1006
|
+
* will store the DDict references in a table, and the DDict used for decompression
|
1007
|
+
* will be determined at decompression time, as per the dict ID in the frame.
|
1008
|
+
* The memory for the table is allocated on the first call to refDDict, and can be
|
1009
|
+
* freed with ZSTD_freeDCtx().
|
1010
|
+
*
|
978
1011
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
979
1012
|
* Note 1 : Currently, only one dictionary can be managed.
|
980
1013
|
* Referencing a new dictionary effectively "discards" any previous one.
|
@@ -1100,21 +1133,40 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
|
1100
1133
|
typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
|
1101
1134
|
|
1102
1135
|
typedef struct {
|
1103
|
-
unsigned int
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1136
|
+
unsigned int offset; /* The offset of the match. (NOT the same as the offset code)
|
1137
|
+
* If offset == 0 and matchLength == 0, this sequence represents the last
|
1138
|
+
* literals in the block of litLength size.
|
1139
|
+
*/
|
1140
|
+
|
1141
|
+
unsigned int litLength; /* Literal length of the sequence. */
|
1142
|
+
unsigned int matchLength; /* Match length of the sequence. */
|
1143
|
+
|
1144
|
+
/* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
|
1145
|
+
* In this case, we will treat the sequence as a marker for a block boundary.
|
1146
|
+
*/
|
1147
|
+
|
1148
|
+
unsigned int rep; /* Represents which repeat offset is represented by the field 'offset'.
|
1149
|
+
* Ranges from [0, 3].
|
1150
|
+
*
|
1151
|
+
* Repeat offsets are essentially previous offsets from previous sequences sorted in
|
1152
|
+
* recency order. For more detail, see doc/zstd_compression_format.md
|
1153
|
+
*
|
1154
|
+
* If rep == 0, then 'offset' does not contain a repeat offset.
|
1155
|
+
* If rep > 0:
|
1156
|
+
* If litLength != 0:
|
1157
|
+
* rep == 1 --> offset == repeat_offset_1
|
1158
|
+
* rep == 2 --> offset == repeat_offset_2
|
1159
|
+
* rep == 3 --> offset == repeat_offset_3
|
1160
|
+
* If litLength == 0:
|
1161
|
+
* rep == 1 --> offset == repeat_offset_2
|
1162
|
+
* rep == 2 --> offset == repeat_offset_3
|
1163
|
+
* rep == 3 --> offset == repeat_offset_1 - 1
|
1164
|
+
*
|
1165
|
+
* Note: This field is optional. ZSTD_generateSequences() will calculate the value of
|
1166
|
+
* 'rep', but repeat offsets do not necessarily need to be calculated from an external
|
1167
|
+
* sequence provider's perspective. For example, ZSTD_compressSequences() does not
|
1168
|
+
* use this 'rep' field at all (as of now).
|
1169
|
+
*/
|
1118
1170
|
} ZSTD_Sequence;
|
1119
1171
|
|
1120
1172
|
typedef struct {
|
@@ -1156,6 +1208,18 @@ typedef enum {
|
|
1156
1208
|
* Decoder cannot recognise automatically this format, requiring this instruction. */
|
1157
1209
|
} ZSTD_format_e;
|
1158
1210
|
|
1211
|
+
typedef enum {
|
1212
|
+
/* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
|
1213
|
+
ZSTD_d_validateChecksum = 0,
|
1214
|
+
ZSTD_d_ignoreChecksum = 1
|
1215
|
+
} ZSTD_forceIgnoreChecksum_e;
|
1216
|
+
|
1217
|
+
typedef enum {
|
1218
|
+
/* Note: this enum controls ZSTD_d_refMultipleDDicts */
|
1219
|
+
ZSTD_rmd_refSingleDDict = 0,
|
1220
|
+
ZSTD_rmd_refMultipleDDicts = 1
|
1221
|
+
} ZSTD_refMultipleDDicts_e;
|
1222
|
+
|
1159
1223
|
typedef enum {
|
1160
1224
|
/* Note: this enum and the behavior it controls are effectively internal
|
1161
1225
|
* implementation details of the compressor. They are expected to continue
|
@@ -1237,7 +1301,7 @@ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t
|
|
1237
1301
|
* `srcSize` must be the _exact_ size of this series
|
1238
1302
|
* (i.e. there should be a frame boundary at `src + srcSize`)
|
1239
1303
|
* @return : - upper-bound for the decompressed size of all data in all successive frames
|
1240
|
-
* - if an error
|
1304
|
+
* - if an error occurred: ZSTD_CONTENTSIZE_ERROR
|
1241
1305
|
*
|
1242
1306
|
* note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame.
|
1243
1307
|
* note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`.
|
@@ -1253,14 +1317,91 @@ ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcS
|
|
1253
1317
|
* or an error code (if srcSize is too small) */
|
1254
1318
|
ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
1255
1319
|
|
1256
|
-
|
1257
|
-
|
1320
|
+
typedef enum {
|
1321
|
+
ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
|
1322
|
+
ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
1323
|
+
} ZSTD_sequenceFormat_e;
|
1324
|
+
|
1325
|
+
/*! ZSTD_generateSequences() :
|
1326
|
+
* Generate sequences using ZSTD_compress2, given a source buffer.
|
1327
|
+
*
|
1328
|
+
* Each block will end with a dummy sequence
|
1329
|
+
* with offset == 0, matchLength == 0, and litLength == length of last literals.
|
1330
|
+
* litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
|
1331
|
+
* simply acts as a block delimiter.
|
1332
|
+
*
|
1258
1333
|
* zc can be used to insert custom compression params.
|
1259
1334
|
* This function invokes ZSTD_compress2
|
1260
|
-
*
|
1335
|
+
*
|
1336
|
+
* The output of this function can be fed into ZSTD_compressSequences() with CCtx
|
1337
|
+
* setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
|
1338
|
+
* @return : number of sequences generated
|
1339
|
+
*/
|
1340
|
+
|
1341
|
+
ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
1342
|
+
size_t outSeqsSize, const void* src, size_t srcSize);
|
1343
|
+
|
1344
|
+
/*! ZSTD_mergeBlockDelimiters() :
|
1345
|
+
* Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals
|
1346
|
+
* by merging them into into the literals of the next sequence.
|
1347
|
+
*
|
1348
|
+
* As such, the final generated result has no explicit representation of block boundaries,
|
1349
|
+
* and the final last literals segment is not represented in the sequences.
|
1350
|
+
*
|
1351
|
+
* The output of this function can be fed into ZSTD_compressSequences() with CCtx
|
1352
|
+
* setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters
|
1353
|
+
* @return : number of sequences left after merging
|
1354
|
+
*/
|
1355
|
+
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
1356
|
+
|
1357
|
+
/*! ZSTD_compressSequences() :
|
1358
|
+
* Compress an array of ZSTD_Sequence, generated from the original source buffer, into dst.
|
1359
|
+
* If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.)
|
1360
|
+
* The entire source is compressed into a single frame.
|
1361
|
+
*
|
1362
|
+
* The compression behavior changes based on cctx params. In particular:
|
1363
|
+
* If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain
|
1364
|
+
* no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on
|
1365
|
+
* the block size derived from the cctx, and sequences may be split. This is the default setting.
|
1366
|
+
*
|
1367
|
+
* If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain
|
1368
|
+
* block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
|
1369
|
+
*
|
1370
|
+
* If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined
|
1371
|
+
* behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for
|
1372
|
+
* specifics regarding offset/matchlength requirements) then the function will bail out and return an error.
|
1373
|
+
*
|
1374
|
+
* In addition to the two adjustable experimental params, there are other important cctx params.
|
1375
|
+
* - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN.
|
1376
|
+
* - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression.
|
1377
|
+
* - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset
|
1378
|
+
* is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md
|
1379
|
+
*
|
1380
|
+
* Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.
|
1381
|
+
* Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly,
|
1382
|
+
* and cannot emit an RLE block that disagrees with the repcode history
|
1383
|
+
* @return : final compressed size or a ZSTD error.
|
1261
1384
|
*/
|
1262
|
-
ZSTDLIB_API size_t
|
1263
|
-
|
1385
|
+
ZSTDLIB_API size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
|
1386
|
+
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
|
1387
|
+
const void* src, size_t srcSize);
|
1388
|
+
|
1389
|
+
|
1390
|
+
/*! ZSTD_writeSkippableFrame() :
|
1391
|
+
* Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.
|
1392
|
+
*
|
1393
|
+
* Skippable frames begin with a a 4-byte magic number. There are 16 possible choices of magic number,
|
1394
|
+
* ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15.
|
1395
|
+
* As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so
|
1396
|
+
* the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.
|
1397
|
+
*
|
1398
|
+
* Returns an error if destination buffer is not large enough, if the source size is not representable
|
1399
|
+
* with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).
|
1400
|
+
*
|
1401
|
+
* @return : number of bytes written or a ZSTD error.
|
1402
|
+
*/
|
1403
|
+
ZSTDLIB_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
|
1404
|
+
const void* src, size_t srcSize, unsigned magicVariant);
|
1264
1405
|
|
1265
1406
|
|
1266
1407
|
/***************************************
|
@@ -1372,7 +1513,11 @@ ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
|
|
1372
1513
|
typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
|
1373
1514
|
typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
|
1374
1515
|
typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
|
1375
|
-
static
|
1516
|
+
static
|
1517
|
+
#ifdef __GNUC__
|
1518
|
+
__attribute__((__unused__))
|
1519
|
+
#endif
|
1520
|
+
ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
|
1376
1521
|
|
1377
1522
|
ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
|
1378
1523
|
ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
|
@@ -1385,11 +1530,37 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictS
|
|
1385
1530
|
ZSTD_compressionParameters cParams,
|
1386
1531
|
ZSTD_customMem customMem);
|
1387
1532
|
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1533
|
+
/* ! Thread pool :
|
1534
|
+
* These prototypes make it possible to share a thread pool among multiple compression contexts.
|
1535
|
+
* This can limit resources for applications with multiple threads where each one uses
|
1536
|
+
* a threaded compression mode (via ZSTD_c_nbWorkers parameter).
|
1537
|
+
* ZSTD_createThreadPool creates a new thread pool with a given number of threads.
|
1538
|
+
* Note that the lifetime of such pool must exist while being used.
|
1539
|
+
* ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value
|
1540
|
+
* to use an internal thread pool).
|
1541
|
+
* ZSTD_freeThreadPool frees a thread pool.
|
1542
|
+
*/
|
1543
|
+
typedef struct POOL_ctx_s ZSTD_threadPool;
|
1544
|
+
ZSTDLIB_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
|
1545
|
+
ZSTDLIB_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool);
|
1546
|
+
ZSTDLIB_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
|
1547
|
+
|
1548
|
+
|
1549
|
+
/*
|
1550
|
+
* This API is temporary and is expected to change or disappear in the future!
|
1551
|
+
*/
|
1552
|
+
ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced2(
|
1553
|
+
const void* dict, size_t dictSize,
|
1554
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1555
|
+
ZSTD_dictContentType_e dictContentType,
|
1556
|
+
const ZSTD_CCtx_params* cctxParams,
|
1557
|
+
ZSTD_customMem customMem);
|
1392
1558
|
|
1559
|
+
ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(
|
1560
|
+
const void* dict, size_t dictSize,
|
1561
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
1562
|
+
ZSTD_dictContentType_e dictContentType,
|
1563
|
+
ZSTD_customMem customMem);
|
1393
1564
|
|
1394
1565
|
|
1395
1566
|
/***************************************
|
@@ -1404,6 +1575,12 @@ ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictS
|
|
1404
1575
|
* note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */
|
1405
1576
|
ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
|
1406
1577
|
|
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
|
+
|
1407
1584
|
/*! ZSTD_getCParams() :
|
1408
1585
|
* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
|
1409
1586
|
* `estimatedSrcSize` value is optional, select 0 if not known */
|
@@ -1518,12 +1695,149 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|
1518
1695
|
* but compression ratio may regress significantly if guess considerably underestimates */
|
1519
1696
|
#define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
|
1520
1697
|
|
1698
|
+
/* Controls whether the new and experimental "dedicated dictionary search
|
1699
|
+
* structure" can be used. This feature is still rough around the edges, be
|
1700
|
+
* prepared for surprising behavior!
|
1701
|
+
*
|
1702
|
+
* How to use it:
|
1703
|
+
*
|
1704
|
+
* When using a CDict, whether to use this feature or not is controlled at
|
1705
|
+
* CDict creation, and it must be set in a CCtxParams set passed into that
|
1706
|
+
* construction (via ZSTD_createCDict_advanced2()). A compression will then
|
1707
|
+
* use the feature or not based on how the CDict was constructed; the value of
|
1708
|
+
* this param, set in the CCtx, will have no effect.
|
1709
|
+
*
|
1710
|
+
* However, when a dictionary buffer is passed into a CCtx, such as via
|
1711
|
+
* ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control
|
1712
|
+
* whether the CDict that is created internally can use the feature or not.
|
1713
|
+
*
|
1714
|
+
* What it does:
|
1715
|
+
*
|
1716
|
+
* Normally, the internal data structures of the CDict are analogous to what
|
1717
|
+
* would be stored in a CCtx after compressing the contents of a dictionary.
|
1718
|
+
* To an approximation, a compression using a dictionary can then use those
|
1719
|
+
* data structures to simply continue what is effectively a streaming
|
1720
|
+
* compression where the simulated compression of the dictionary left off.
|
1721
|
+
* Which is to say, the search structures in the CDict are normally the same
|
1722
|
+
* format as in the CCtx.
|
1723
|
+
*
|
1724
|
+
* It is possible to do better, since the CDict is not like a CCtx: the search
|
1725
|
+
* structures are written once during CDict creation, and then are only read
|
1726
|
+
* after that, while the search structures in the CCtx are both read and
|
1727
|
+
* written as the compression goes along. This means we can choose a search
|
1728
|
+
* structure for the dictionary that is read-optimized.
|
1729
|
+
*
|
1730
|
+
* This feature enables the use of that different structure.
|
1731
|
+
*
|
1732
|
+
* Note that some of the members of the ZSTD_compressionParameters struct have
|
1733
|
+
* different semantics and constraints in the dedicated search structure. It is
|
1734
|
+
* highly recommended that you simply set a compression level in the CCtxParams
|
1735
|
+
* you pass into the CDict creation call, and avoid messing with the cParams
|
1736
|
+
* directly.
|
1737
|
+
*
|
1738
|
+
* Effects:
|
1739
|
+
*
|
1740
|
+
* This will only have any effect when the selected ZSTD_strategy
|
1741
|
+
* implementation supports this feature. Currently, that's limited to
|
1742
|
+
* ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2.
|
1743
|
+
*
|
1744
|
+
* Note that this means that the CDict tables can no longer be copied into the
|
1745
|
+
* CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be
|
1746
|
+
* useable. The dictionary can only be attached or reloaded.
|
1747
|
+
*
|
1748
|
+
* In general, you should expect compression to be faster--sometimes very much
|
1749
|
+
* so--and CDict creation to be slightly slower. Eventually, we will probably
|
1750
|
+
* make this mode the default.
|
1751
|
+
*/
|
1752
|
+
#define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8
|
1753
|
+
|
1754
|
+
/* ZSTD_c_stableInBuffer
|
1755
|
+
* Experimental parameter.
|
1756
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1757
|
+
*
|
1758
|
+
* Tells the compressor that the ZSTD_inBuffer will ALWAYS be the same
|
1759
|
+
* between calls, except for the modifications that zstd makes to pos (the
|
1760
|
+
* caller must not modify pos). This is checked by the compressor, and
|
1761
|
+
* compression will fail if it ever changes. This means the only flush
|
1762
|
+
* mode that makes sense is ZSTD_e_end, so zstd will error if ZSTD_e_end
|
1763
|
+
* is not used. The data in the ZSTD_inBuffer in the range [src, src + pos)
|
1764
|
+
* MUST not be modified during compression or you will get data corruption.
|
1765
|
+
*
|
1766
|
+
* When this flag is enabled zstd won't allocate an input window buffer,
|
1767
|
+
* because the user guarantees it can reference the ZSTD_inBuffer until
|
1768
|
+
* the frame is complete. But, it will still allocate an output buffer
|
1769
|
+
* large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also
|
1770
|
+
* avoid the memcpy() from the input buffer to the input window buffer.
|
1771
|
+
*
|
1772
|
+
* NOTE: ZSTD_compressStream2() will error if ZSTD_e_end is not used.
|
1773
|
+
* That means this flag cannot be used with ZSTD_compressStream().
|
1774
|
+
*
|
1775
|
+
* NOTE: So long as the ZSTD_inBuffer always points to valid memory, using
|
1776
|
+
* this flag is ALWAYS memory safe, and will never access out-of-bounds
|
1777
|
+
* memory. However, compression WILL fail if you violate the preconditions.
|
1778
|
+
*
|
1779
|
+
* WARNING: The data in the ZSTD_inBuffer in the range [dst, dst + pos) MUST
|
1780
|
+
* not be modified during compression or you will get data corruption. This
|
1781
|
+
* is because zstd needs to reference data in the ZSTD_inBuffer to find
|
1782
|
+
* matches. Normally zstd maintains its own window buffer for this purpose,
|
1783
|
+
* but passing this flag tells zstd to use the user provided buffer.
|
1784
|
+
*/
|
1785
|
+
#define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9
|
1786
|
+
|
1787
|
+
/* ZSTD_c_stableOutBuffer
|
1788
|
+
* Experimental parameter.
|
1789
|
+
* Default is 0 == disabled. Set to 1 to enable.
|
1790
|
+
*
|
1791
|
+
* Tells he compressor that the ZSTD_outBuffer will not be resized between
|
1792
|
+
* calls. Specifically: (out.size - out.pos) will never grow. This gives the
|
1793
|
+
* compressor the freedom to say: If the compressed data doesn't fit in the
|
1794
|
+
* output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to
|
1795
|
+
* always decompress directly into the output buffer, instead of decompressing
|
1796
|
+
* into an internal buffer and copying to the output buffer.
|
1797
|
+
*
|
1798
|
+
* When this flag is enabled zstd won't allocate an output buffer, because
|
1799
|
+
* it can write directly to the ZSTD_outBuffer. It will still allocate the
|
1800
|
+
* input window buffer (see ZSTD_c_stableInBuffer).
|
1801
|
+
*
|
1802
|
+
* Zstd will check that (out.size - out.pos) never grows and return an error
|
1803
|
+
* if it does. While not strictly necessary, this should prevent surprises.
|
1804
|
+
*/
|
1805
|
+
#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
|
1806
|
+
|
1807
|
+
/* ZSTD_c_blockDelimiters
|
1808
|
+
* Default is 0 == ZSTD_sf_noBlockDelimiters.
|
1809
|
+
*
|
1810
|
+
* For use with sequence compression API: ZSTD_compressSequences().
|
1811
|
+
*
|
1812
|
+
* Designates whether or not the given array of ZSTD_Sequence contains block delimiters
|
1813
|
+
* and last literals, which are defined as sequences with offset == 0 and matchLength == 0.
|
1814
|
+
* See the definition of ZSTD_Sequence for more specifics.
|
1815
|
+
*/
|
1816
|
+
#define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
|
1817
|
+
|
1818
|
+
/* ZSTD_c_validateSequences
|
1819
|
+
* Default is 0 == disabled. Set to 1 to enable sequence validation.
|
1820
|
+
*
|
1821
|
+
* For use with sequence compression API: ZSTD_compressSequences().
|
1822
|
+
* Designates whether or not we validate sequences provided to ZSTD_compressSequences()
|
1823
|
+
* during function execution.
|
1824
|
+
*
|
1825
|
+
* Without validation, providing a sequence that does not conform to the zstd spec will cause
|
1826
|
+
* undefined behavior, and may produce a corrupted block.
|
1827
|
+
*
|
1828
|
+
* With validation enabled, a if sequence is invalid (see doc/zstd_compression_format.md for
|
1829
|
+
* specifics regarding offset/matchlength requirements) then the function will bail out and
|
1830
|
+
* return an error.
|
1831
|
+
*
|
1832
|
+
*/
|
1833
|
+
#define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
|
1834
|
+
|
1521
1835
|
/*! ZSTD_CCtx_getParameter() :
|
1522
1836
|
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
|
1523
1837
|
* and store it into int* value.
|
1524
1838
|
* @return : 0, or an error code (which can be tested with ZSTD_isError()).
|
1525
1839
|
*/
|
1526
|
-
ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
|
1840
|
+
ZSTDLIB_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
|
1527
1841
|
|
1528
1842
|
|
1529
1843
|
/*! ZSTD_CCtx_params :
|
@@ -1566,8 +1880,10 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, Z
|
|
1566
1880
|
/*! ZSTD_CCtxParams_setParameter() :
|
1567
1881
|
* Similar to ZSTD_CCtx_setParameter.
|
1568
1882
|
* Set one compression parameter, selected by enum ZSTD_cParameter.
|
1569
|
-
* Parameters must be applied to a ZSTD_CCtx using
|
1570
|
-
*
|
1883
|
+
* Parameters must be applied to a ZSTD_CCtx using
|
1884
|
+
* ZSTD_CCtx_setParametersUsingCCtxParams().
|
1885
|
+
* @result : a code representing success or failure (which can be tested with
|
1886
|
+
* ZSTD_isError()).
|
1571
1887
|
*/
|
1572
1888
|
ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
|
1573
1889
|
|
@@ -1576,7 +1892,7 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_c
|
|
1576
1892
|
* Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
|
1577
1893
|
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
1578
1894
|
*/
|
1579
|
-
ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
|
1895
|
+
ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
|
1580
1896
|
|
1581
1897
|
/*! ZSTD_CCtx_setParametersUsingCCtxParams() :
|
1582
1898
|
* Apply a set of ZSTD_CCtx_params to the compression context.
|
@@ -1647,6 +1963,13 @@ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* pre
|
|
1647
1963
|
*/
|
1648
1964
|
ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
|
1649
1965
|
|
1966
|
+
/*! ZSTD_DCtx_getParameter() :
|
1967
|
+
* Get the requested decompression parameter value, selected by enum ZSTD_dParameter,
|
1968
|
+
* and store it into int* value.
|
1969
|
+
* @return : 0, or an error code (which can be tested with ZSTD_isError()).
|
1970
|
+
*/
|
1971
|
+
ZSTDLIB_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
|
1972
|
+
|
1650
1973
|
/* ZSTD_d_format
|
1651
1974
|
* experimental parameter,
|
1652
1975
|
* allowing selection between ZSTD_format_e input compression formats
|
@@ -1684,6 +2007,41 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
|
|
1684
2007
|
*/
|
1685
2008
|
#define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
|
1686
2009
|
|
2010
|
+
/* ZSTD_d_forceIgnoreChecksum
|
2011
|
+
* Experimental parameter.
|
2012
|
+
* Default is 0 == disabled. Set to 1 to enable
|
2013
|
+
*
|
2014
|
+
* Tells the decompressor to skip checksum validation during decompression, regardless
|
2015
|
+
* of whether checksumming was specified during compression. This offers some
|
2016
|
+
* slight performance benefits, and may be useful for debugging.
|
2017
|
+
* Param has values of type ZSTD_forceIgnoreChecksum_e
|
2018
|
+
*/
|
2019
|
+
#define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
|
2020
|
+
|
2021
|
+
/* ZSTD_d_refMultipleDDicts
|
2022
|
+
* Experimental parameter.
|
2023
|
+
* Default is 0 == disabled. Set to 1 to enable
|
2024
|
+
*
|
2025
|
+
* If enabled and dctx is allocated on the heap, then additional memory will be allocated
|
2026
|
+
* to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
|
2027
|
+
* using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
|
2028
|
+
* store all references. At decompression time, the appropriate dictID is selected
|
2029
|
+
* from the set of DDicts based on the dictID in the frame.
|
2030
|
+
*
|
2031
|
+
* Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
|
2032
|
+
*
|
2033
|
+
* Param has values of byte ZSTD_refMultipleDDicts_e
|
2034
|
+
*
|
2035
|
+
* WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory
|
2036
|
+
* allocation for the hash table. ZSTD_freeDCtx() also frees this memory.
|
2037
|
+
* Memory is allocated as per ZSTD_DCtx::customMem.
|
2038
|
+
*
|
2039
|
+
* Although this function allocates memory for the table, the user is still responsible for
|
2040
|
+
* memory management of the underlying ZSTD_DDict* themselves.
|
2041
|
+
*/
|
2042
|
+
#define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4
|
2043
|
+
|
2044
|
+
|
1687
2045
|
/*! ZSTD_DCtx_setFormat() :
|
1688
2046
|
* Instruct the decoder context about what kind of data to decode next.
|
1689
2047
|
* This instruction is mandatory to decode data without a fully-formed header,
|
@@ -1711,7 +2069,8 @@ ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
|
|
1711
2069
|
********************************************************************/
|
1712
2070
|
|
1713
2071
|
/*===== Advanced Streaming compression functions =====*/
|
1714
|
-
|
2072
|
+
|
2073
|
+
/*! ZSTD_initCStream_srcSize() :
|
1715
2074
|
* This function is deprecated, and equivalent to:
|
1716
2075
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1717
2076
|
* ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
|
@@ -1728,7 +2087,7 @@ ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
|
|
1728
2087
|
int compressionLevel,
|
1729
2088
|
unsigned long long pledgedSrcSize);
|
1730
2089
|
|
1731
|
-
|
2090
|
+
/*! ZSTD_initCStream_usingDict() :
|
1732
2091
|
* This function is deprecated, and is equivalent to:
|
1733
2092
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1734
2093
|
* ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
|
@@ -1745,7 +2104,7 @@ ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
|
1745
2104
|
const void* dict, size_t dictSize,
|
1746
2105
|
int compressionLevel);
|
1747
2106
|
|
1748
|
-
|
2107
|
+
/*! ZSTD_initCStream_advanced() :
|
1749
2108
|
* This function is deprecated, and is approximately equivalent to:
|
1750
2109
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1751
2110
|
* // Pseudocode: Set each zstd parameter and leave the rest as-is.
|
@@ -1766,7 +2125,7 @@ ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
|
1766
2125
|
ZSTD_parameters params,
|
1767
2126
|
unsigned long long pledgedSrcSize);
|
1768
2127
|
|
1769
|
-
|
2128
|
+
/*! ZSTD_initCStream_usingCDict() :
|
1770
2129
|
* This function is deprecated, and equivalent to:
|
1771
2130
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1772
2131
|
* ZSTD_CCtx_refCDict(zcs, cdict);
|
@@ -1776,7 +2135,7 @@ ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
|
1776
2135
|
*/
|
1777
2136
|
ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
|
1778
2137
|
|
1779
|
-
|
2138
|
+
/*! ZSTD_initCStream_usingCDict_advanced() :
|
1780
2139
|
* This function is DEPRECATED, and is approximately equivalent to:
|
1781
2140
|
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
1782
2141
|
* // Pseudocode: Set each zstd frame parameter and leave the rest as-is.
|
@@ -1849,7 +2208,8 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
|
|
1849
2208
|
|
1850
2209
|
|
1851
2210
|
/*===== Advanced Streaming decompression functions =====*/
|
1852
|
-
|
2211
|
+
|
2212
|
+
/*!
|
1853
2213
|
* This function is deprecated, and is equivalent to:
|
1854
2214
|
*
|
1855
2215
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1860,7 +2220,7 @@ ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
|
|
1860
2220
|
*/
|
1861
2221
|
ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
|
1862
2222
|
|
1863
|
-
|
2223
|
+
/*!
|
1864
2224
|
* This function is deprecated, and is equivalent to:
|
1865
2225
|
*
|
1866
2226
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1871,7 +2231,7 @@ ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dic
|
|
1871
2231
|
*/
|
1872
2232
|
ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
|
1873
2233
|
|
1874
|
-
|
2234
|
+
/*!
|
1875
2235
|
* This function is deprecated, and is equivalent to:
|
1876
2236
|
*
|
1877
2237
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
@@ -1933,7 +2293,7 @@ ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstC
|
|
1933
2293
|
ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
1934
2294
|
|
1935
2295
|
|
1936
|
-
|
2296
|
+
/**
|
1937
2297
|
Buffer-less streaming decompression (synchronous mode)
|
1938
2298
|
|
1939
2299
|
A ZSTD_DCtx object is required to track streaming operations.
|