zstdlib 0.13.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +6 -0
- data/CHANGES.md +107 -0
- data/Gemfile +3 -0
- data/README.md +107 -0
- data/Rakefile +59 -0
- data/ext/zstdlib_c/extconf.rb +59 -0
- data/ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c +4675 -0
- data/ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c +4702 -0
- data/ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c +4859 -0
- data/ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c +4864 -0
- data/ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c +4906 -0
- data/ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c +5090 -0
- data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
- data/ext/zstdlib_c/zlib-1.3.1/adler32.c +164 -0
- data/ext/zstdlib_c/zlib-1.3.1/compress.c +75 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.c +1049 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.h +9446 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.c +2139 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.h +377 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzclose.c +23 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzguts.h +214 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzlib.c +582 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzread.c +602 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzwrite.c +631 -0
- data/ext/zstdlib_c/zlib-1.3.1/infback.c +628 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.c +320 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.h +11 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffixed.h +94 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.c +1526 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.h +126 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.h +62 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.c +1117 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.h +128 -0
- data/ext/zstdlib_c/zlib-1.3.1/uncompr.c +85 -0
- data/ext/zstdlib_c/zlib-1.3.1/zconf.h +543 -0
- data/ext/zstdlib_c/zlib-1.3.1/zlib.h +1938 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.h +254 -0
- data/ext/zstdlib_c/zlib.mk +14 -0
- data/ext/zstdlib_c/zlibwrapper/zlibwrapper.c +10 -0
- data/ext/zstdlib_c/zlibwrapper.mk +14 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/allocations.h +55 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bits.h +200 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bitstream.h +457 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/compiler.h +450 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/cpu.h +249 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.c +30 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.h +116 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/entropy_common.c +340 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.c +63 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.h +168 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse.h +640 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse_decompress.c +313 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/huf.h +286 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/mem.h +426 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.c +371 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.h +90 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/portability_macros.h +158 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.c +182 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.h +150 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.c +18 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.h +7020 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_common.c +48 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_internal.h +392 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/clevels.h +134 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/fse_compress.c +625 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.c +181 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.h +75 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/huf_compress.c +1464 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress.c +7153 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_internal.h +1534 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.c +235 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.h +39 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.c +688 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_cwksp.h +748 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.c +770 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.h +50 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.c +968 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.h +38 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.c +2199 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.h +202 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.c +730 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.h +117 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.c +1576 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.h +80 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.c +1882 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress.c +1944 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress_amd64.S +595 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.c +244 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.h +44 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress.c +2407 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.c +2215 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.h +73 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_internal.h +240 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zdict.h +474 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd.h +3089 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd_errors.h +114 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzclose.c +26 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzcompatibility.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzguts.h +229 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzlib.c +587 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzread.c +637 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzwrite.c +631 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.c +1200 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.h +91 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.so +0 -0
- data/lib/2.5/zstdlib_c.so +0 -0
- data/lib/2.6/zstdlib_c.so +0 -0
- data/lib/2.7/zstdlib_c.so +0 -0
- data/lib/3.0/zstdlib_c.so +0 -0
- data/lib/3.1/zstdlib_c.so +0 -0
- data/lib/3.2/zstdlib_c.so +0 -0
- data/lib/3.3/zstdlib_c.so +0 -0
- data/lib/zstdlib.rb +6 -0
- data/test/zstdlib_test.rb +21 -0
- metadata +243 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
#ifndef ZSTD_DEC_BLOCK_H
|
13
|
+
#define ZSTD_DEC_BLOCK_H
|
14
|
+
|
15
|
+
/*-*******************************************************
|
16
|
+
* Dependencies
|
17
|
+
*********************************************************/
|
18
|
+
#include "../common/zstd_deps.h" /* size_t */
|
19
|
+
#include "../zstd.h" /* DCtx, and some public functions */
|
20
|
+
#include "../common/zstd_internal.h" /* blockProperties_t, and some public functions */
|
21
|
+
#include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */
|
22
|
+
|
23
|
+
|
24
|
+
/* === Prototypes === */
|
25
|
+
|
26
|
+
/* note: prototypes already published within `zstd.h` :
|
27
|
+
* ZSTD_decompressBlock()
|
28
|
+
*/
|
29
|
+
|
30
|
+
/* note: prototypes already published within `zstd_internal.h` :
|
31
|
+
* ZSTD_getcBlockSize()
|
32
|
+
* ZSTD_decodeSeqHeaders()
|
33
|
+
*/
|
34
|
+
|
35
|
+
|
36
|
+
/* Streaming state is used to inform allocation of the literal buffer */
|
37
|
+
typedef enum {
|
38
|
+
not_streaming = 0,
|
39
|
+
is_streaming = 1
|
40
|
+
} streaming_operation;
|
41
|
+
|
42
|
+
/* ZSTD_decompressBlock_internal() :
|
43
|
+
* decompress block, starting at `src`,
|
44
|
+
* into destination buffer `dst`.
|
45
|
+
* @return : decompressed block size,
|
46
|
+
* or an error code (which can be tested using ZSTD_isError())
|
47
|
+
*/
|
48
|
+
size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
|
49
|
+
void* dst, size_t dstCapacity,
|
50
|
+
const void* src, size_t srcSize, const streaming_operation streaming);
|
51
|
+
|
52
|
+
/* ZSTD_buildFSETable() :
|
53
|
+
* generate FSE decoding table for one symbol (ll, ml or off)
|
54
|
+
* this function must be called with valid parameters only
|
55
|
+
* (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
|
56
|
+
* in which case it cannot fail.
|
57
|
+
* The workspace must be 4-byte aligned and at least ZSTD_BUILD_FSE_TABLE_WKSP_SIZE bytes, which is
|
58
|
+
* defined in zstd_decompress_internal.h.
|
59
|
+
* Internal use only.
|
60
|
+
*/
|
61
|
+
void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
|
62
|
+
const short* normalizedCounter, unsigned maxSymbolValue,
|
63
|
+
const U32* baseValue, const U8* nbAdditionalBits,
|
64
|
+
unsigned tableLog, void* wksp, size_t wkspSize,
|
65
|
+
int bmi2);
|
66
|
+
|
67
|
+
/* Internal definition of ZSTD_decompressBlock() to avoid deprecation warnings. */
|
68
|
+
size_t ZSTD_decompressBlock_deprecated(ZSTD_DCtx* dctx,
|
69
|
+
void* dst, size_t dstCapacity,
|
70
|
+
const void* src, size_t srcSize);
|
71
|
+
|
72
|
+
|
73
|
+
#endif /* ZSTD_DEC_BLOCK_H */
|
@@ -0,0 +1,240 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
/* zstd_decompress_internal:
|
13
|
+
* objects and definitions shared within lib/decompress modules */
|
14
|
+
|
15
|
+
#ifndef ZSTD_DECOMPRESS_INTERNAL_H
|
16
|
+
#define ZSTD_DECOMPRESS_INTERNAL_H
|
17
|
+
|
18
|
+
|
19
|
+
/*-*******************************************************
|
20
|
+
* Dependencies
|
21
|
+
*********************************************************/
|
22
|
+
#include "../common/mem.h" /* BYTE, U16, U32 */
|
23
|
+
#include "../common/zstd_internal.h" /* constants : MaxLL, MaxML, MaxOff, LLFSELog, etc. */
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
/*-*******************************************************
|
28
|
+
* Constants
|
29
|
+
*********************************************************/
|
30
|
+
static UNUSED_ATTR const U32 LL_base[MaxLL+1] = {
|
31
|
+
0, 1, 2, 3, 4, 5, 6, 7,
|
32
|
+
8, 9, 10, 11, 12, 13, 14, 15,
|
33
|
+
16, 18, 20, 22, 24, 28, 32, 40,
|
34
|
+
48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
|
35
|
+
0x2000, 0x4000, 0x8000, 0x10000 };
|
36
|
+
|
37
|
+
static UNUSED_ATTR const U32 OF_base[MaxOff+1] = {
|
38
|
+
0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D,
|
39
|
+
0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD,
|
40
|
+
0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD,
|
41
|
+
0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD };
|
42
|
+
|
43
|
+
static UNUSED_ATTR const U8 OF_bits[MaxOff+1] = {
|
44
|
+
0, 1, 2, 3, 4, 5, 6, 7,
|
45
|
+
8, 9, 10, 11, 12, 13, 14, 15,
|
46
|
+
16, 17, 18, 19, 20, 21, 22, 23,
|
47
|
+
24, 25, 26, 27, 28, 29, 30, 31 };
|
48
|
+
|
49
|
+
static UNUSED_ATTR const U32 ML_base[MaxML+1] = {
|
50
|
+
3, 4, 5, 6, 7, 8, 9, 10,
|
51
|
+
11, 12, 13, 14, 15, 16, 17, 18,
|
52
|
+
19, 20, 21, 22, 23, 24, 25, 26,
|
53
|
+
27, 28, 29, 30, 31, 32, 33, 34,
|
54
|
+
35, 37, 39, 41, 43, 47, 51, 59,
|
55
|
+
67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803,
|
56
|
+
0x1003, 0x2003, 0x4003, 0x8003, 0x10003 };
|
57
|
+
|
58
|
+
|
59
|
+
/*-*******************************************************
|
60
|
+
* Decompression types
|
61
|
+
*********************************************************/
|
62
|
+
typedef struct {
|
63
|
+
U32 fastMode;
|
64
|
+
U32 tableLog;
|
65
|
+
} ZSTD_seqSymbol_header;
|
66
|
+
|
67
|
+
typedef struct {
|
68
|
+
U16 nextState;
|
69
|
+
BYTE nbAdditionalBits;
|
70
|
+
BYTE nbBits;
|
71
|
+
U32 baseValue;
|
72
|
+
} ZSTD_seqSymbol;
|
73
|
+
|
74
|
+
#define SEQSYMBOL_TABLE_SIZE(log) (1 + (1 << (log)))
|
75
|
+
|
76
|
+
#define ZSTD_BUILD_FSE_TABLE_WKSP_SIZE (sizeof(S16) * (MaxSeq + 1) + (1u << MaxFSELog) + sizeof(U64))
|
77
|
+
#define ZSTD_BUILD_FSE_TABLE_WKSP_SIZE_U32 ((ZSTD_BUILD_FSE_TABLE_WKSP_SIZE + sizeof(U32) - 1) / sizeof(U32))
|
78
|
+
#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
|
79
|
+
|
80
|
+
typedef struct {
|
81
|
+
ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */
|
82
|
+
ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */
|
83
|
+
ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */
|
84
|
+
HUF_DTable hufTable[HUF_DTABLE_SIZE(ZSTD_HUFFDTABLE_CAPACITY_LOG)]; /* can accommodate HUF_decompress4X */
|
85
|
+
U32 rep[ZSTD_REP_NUM];
|
86
|
+
U32 workspace[ZSTD_BUILD_FSE_TABLE_WKSP_SIZE_U32];
|
87
|
+
} ZSTD_entropyDTables_t;
|
88
|
+
|
89
|
+
typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
|
90
|
+
ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock,
|
91
|
+
ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
|
92
|
+
ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
|
93
|
+
|
94
|
+
typedef enum { zdss_init=0, zdss_loadHeader,
|
95
|
+
zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
|
96
|
+
|
97
|
+
typedef enum {
|
98
|
+
ZSTD_use_indefinitely = -1, /* Use the dictionary indefinitely */
|
99
|
+
ZSTD_dont_use = 0, /* Do not use the dictionary (if one exists free it) */
|
100
|
+
ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */
|
101
|
+
} ZSTD_dictUses_e;
|
102
|
+
|
103
|
+
/* Hashset for storing references to multiple ZSTD_DDict within ZSTD_DCtx */
|
104
|
+
typedef struct {
|
105
|
+
const ZSTD_DDict** ddictPtrTable;
|
106
|
+
size_t ddictPtrTableSize;
|
107
|
+
size_t ddictPtrCount;
|
108
|
+
} ZSTD_DDictHashSet;
|
109
|
+
|
110
|
+
#ifndef ZSTD_DECODER_INTERNAL_BUFFER
|
111
|
+
# define ZSTD_DECODER_INTERNAL_BUFFER (1 << 16)
|
112
|
+
#endif
|
113
|
+
|
114
|
+
#define ZSTD_LBMIN 64
|
115
|
+
#define ZSTD_LBMAX (128 << 10)
|
116
|
+
|
117
|
+
/* extra buffer, compensates when dst is not large enough to store litBuffer */
|
118
|
+
#define ZSTD_LITBUFFEREXTRASIZE BOUNDED(ZSTD_LBMIN, ZSTD_DECODER_INTERNAL_BUFFER, ZSTD_LBMAX)
|
119
|
+
|
120
|
+
typedef enum {
|
121
|
+
ZSTD_not_in_dst = 0, /* Stored entirely within litExtraBuffer */
|
122
|
+
ZSTD_in_dst = 1, /* Stored entirely within dst (in memory after current output write) */
|
123
|
+
ZSTD_split = 2 /* Split between litExtraBuffer and dst */
|
124
|
+
} ZSTD_litLocation_e;
|
125
|
+
|
126
|
+
struct ZSTD_DCtx_s
|
127
|
+
{
|
128
|
+
const ZSTD_seqSymbol* LLTptr;
|
129
|
+
const ZSTD_seqSymbol* MLTptr;
|
130
|
+
const ZSTD_seqSymbol* OFTptr;
|
131
|
+
const HUF_DTable* HUFptr;
|
132
|
+
ZSTD_entropyDTables_t entropy;
|
133
|
+
U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */
|
134
|
+
const void* previousDstEnd; /* detect continuity */
|
135
|
+
const void* prefixStart; /* start of current segment */
|
136
|
+
const void* virtualStart; /* virtual start of previous segment if it was just before current one */
|
137
|
+
const void* dictEnd; /* end of previous segment */
|
138
|
+
size_t expected;
|
139
|
+
ZSTD_frameHeader fParams;
|
140
|
+
U64 processedCSize;
|
141
|
+
U64 decodedSize;
|
142
|
+
blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */
|
143
|
+
ZSTD_dStage stage;
|
144
|
+
U32 litEntropy;
|
145
|
+
U32 fseEntropy;
|
146
|
+
XXH64_state_t xxhState;
|
147
|
+
size_t headerSize;
|
148
|
+
ZSTD_format_e format;
|
149
|
+
ZSTD_forceIgnoreChecksum_e forceIgnoreChecksum; /* User specified: if == 1, will ignore checksums in compressed frame. Default == 0 */
|
150
|
+
U32 validateChecksum; /* if == 1, will validate checksum. Is == 1 if (fParams.checksumFlag == 1) and (forceIgnoreChecksum == 0). */
|
151
|
+
const BYTE* litPtr;
|
152
|
+
ZSTD_customMem customMem;
|
153
|
+
size_t litSize;
|
154
|
+
size_t rleSize;
|
155
|
+
size_t staticSize;
|
156
|
+
int isFrameDecompression;
|
157
|
+
#if DYNAMIC_BMI2 != 0
|
158
|
+
int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
|
159
|
+
#endif
|
160
|
+
|
161
|
+
/* dictionary */
|
162
|
+
ZSTD_DDict* ddictLocal;
|
163
|
+
const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
|
164
|
+
U32 dictID;
|
165
|
+
int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
|
166
|
+
ZSTD_dictUses_e dictUses;
|
167
|
+
ZSTD_DDictHashSet* ddictSet; /* Hash set for multiple ddicts */
|
168
|
+
ZSTD_refMultipleDDicts_e refMultipleDDicts; /* User specified: if == 1, will allow references to multiple DDicts. Default == 0 (disabled) */
|
169
|
+
int disableHufAsm;
|
170
|
+
int maxBlockSizeParam;
|
171
|
+
|
172
|
+
/* streaming */
|
173
|
+
ZSTD_dStreamStage streamStage;
|
174
|
+
char* inBuff;
|
175
|
+
size_t inBuffSize;
|
176
|
+
size_t inPos;
|
177
|
+
size_t maxWindowSize;
|
178
|
+
char* outBuff;
|
179
|
+
size_t outBuffSize;
|
180
|
+
size_t outStart;
|
181
|
+
size_t outEnd;
|
182
|
+
size_t lhSize;
|
183
|
+
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
|
184
|
+
void* legacyContext;
|
185
|
+
U32 previousLegacyVersion;
|
186
|
+
U32 legacyVersion;
|
187
|
+
#endif
|
188
|
+
U32 hostageByte;
|
189
|
+
int noForwardProgress;
|
190
|
+
ZSTD_bufferMode_e outBufferMode;
|
191
|
+
ZSTD_outBuffer expectedOutBuffer;
|
192
|
+
|
193
|
+
/* workspace */
|
194
|
+
BYTE* litBuffer;
|
195
|
+
const BYTE* litBufferEnd;
|
196
|
+
ZSTD_litLocation_e litBufferLocation;
|
197
|
+
BYTE litExtraBuffer[ZSTD_LITBUFFEREXTRASIZE + WILDCOPY_OVERLENGTH]; /* literal buffer can be split between storage within dst and within this scratch buffer */
|
198
|
+
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
199
|
+
|
200
|
+
size_t oversizedDuration;
|
201
|
+
|
202
|
+
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
203
|
+
void const* dictContentBeginForFuzzing;
|
204
|
+
void const* dictContentEndForFuzzing;
|
205
|
+
#endif
|
206
|
+
|
207
|
+
/* Tracing */
|
208
|
+
#if ZSTD_TRACE
|
209
|
+
ZSTD_TraceCtx traceCtx;
|
210
|
+
#endif
|
211
|
+
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
|
212
|
+
|
213
|
+
MEM_STATIC int ZSTD_DCtx_get_bmi2(const struct ZSTD_DCtx_s *dctx) {
|
214
|
+
#if DYNAMIC_BMI2 != 0
|
215
|
+
return dctx->bmi2;
|
216
|
+
#else
|
217
|
+
(void)dctx;
|
218
|
+
return 0;
|
219
|
+
#endif
|
220
|
+
}
|
221
|
+
|
222
|
+
/*-*******************************************************
|
223
|
+
* Shared internal functions
|
224
|
+
*********************************************************/
|
225
|
+
|
226
|
+
/*! ZSTD_loadDEntropy() :
|
227
|
+
* dict : must point at beginning of a valid zstd dictionary.
|
228
|
+
* @return : size of dictionary header (size of magic number + dict ID + entropy tables) */
|
229
|
+
size_t ZSTD_loadDEntropy(ZSTD_entropyDTables_t* entropy,
|
230
|
+
const void* const dict, size_t const dictSize);
|
231
|
+
|
232
|
+
/*! ZSTD_checkContinuity() :
|
233
|
+
* check if next `dst` follows previous position, where decompression ended.
|
234
|
+
* If yes, do nothing (continue on current segment).
|
235
|
+
* If not, classify previous segment as "external dictionary", and start a new segment.
|
236
|
+
* This function cannot fail. */
|
237
|
+
void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst, size_t dstSize);
|
238
|
+
|
239
|
+
|
240
|
+
#endif /* ZSTD_DECOMPRESS_INTERNAL_H */
|