extzstd 0.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/HISTORY.ja.md +39 -0
- data/README.md +38 -56
- data/contrib/zstd/CHANGELOG +613 -0
- data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
- data/contrib/zstd/CONTRIBUTING.md +406 -0
- data/contrib/zstd/COPYING +339 -0
- data/contrib/zstd/Makefile +420 -0
- data/contrib/zstd/README.md +179 -41
- data/contrib/zstd/TESTING.md +44 -0
- data/contrib/zstd/appveyor.yml +292 -0
- data/contrib/zstd/lib/BUCK +234 -0
- data/contrib/zstd/lib/Makefile +451 -0
- data/contrib/zstd/lib/README.md +207 -0
- data/contrib/zstd/{common → lib/common}/bitstream.h +187 -138
- data/contrib/zstd/lib/common/compiler.h +288 -0
- data/contrib/zstd/lib/common/cpu.h +213 -0
- data/contrib/zstd/lib/common/debug.c +24 -0
- data/contrib/zstd/lib/common/debug.h +107 -0
- data/contrib/zstd/lib/common/entropy_common.c +362 -0
- data/contrib/zstd/{common → lib/common}/error_private.c +25 -12
- data/contrib/zstd/{common → lib/common}/error_private.h +14 -10
- data/contrib/zstd/{common → lib/common}/fse.h +173 -92
- data/contrib/zstd/{common → lib/common}/fse_decompress.c +149 -85
- data/contrib/zstd/lib/common/huf.h +361 -0
- data/contrib/zstd/{common → lib/common}/mem.h +115 -59
- data/contrib/zstd/lib/common/pool.c +350 -0
- data/contrib/zstd/lib/common/pool.h +84 -0
- data/contrib/zstd/lib/common/threading.c +122 -0
- data/contrib/zstd/lib/common/threading.h +155 -0
- data/contrib/zstd/{common → lib/common}/xxhash.c +55 -96
- data/contrib/zstd/{common → lib/common}/xxhash.h +23 -47
- data/contrib/zstd/lib/common/zstd_common.c +83 -0
- data/contrib/zstd/lib/common/zstd_deps.h +111 -0
- data/contrib/zstd/lib/common/zstd_errors.h +95 -0
- data/contrib/zstd/lib/common/zstd_internal.h +478 -0
- data/contrib/zstd/{compress → lib/compress}/fse_compress.c +214 -319
- data/contrib/zstd/lib/compress/hist.c +181 -0
- data/contrib/zstd/lib/compress/hist.h +75 -0
- data/contrib/zstd/lib/compress/huf_compress.c +913 -0
- data/contrib/zstd/lib/compress/zstd_compress.c +5208 -0
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +1203 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +433 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +849 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
- data/contrib/zstd/lib/compress/zstd_cwksp.h +561 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
- data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
- data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
- data/contrib/zstd/lib/compress/zstd_lazy.c +1412 -0
- data/contrib/zstd/lib/compress/zstd_lazy.h +87 -0
- data/contrib/zstd/lib/compress/zstd_ldm.c +660 -0
- data/contrib/zstd/lib/compress/zstd_ldm.h +116 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +1345 -0
- data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.c +1811 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.h +110 -0
- data/contrib/zstd/lib/decompress/huf_decompress.c +1350 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
- data/contrib/zstd/lib/decompress/zstd_decompress.c +1930 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1540 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +62 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +190 -0
- data/contrib/zstd/{common → lib/deprecated}/zbuff.h +68 -45
- data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +1245 -0
- data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
- data/contrib/zstd/lib/dictBuilder/fastcover.c +758 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +318 -194
- data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +171 -15
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +191 -124
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +125 -125
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +125 -124
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +20 -6
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +151 -299
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +237 -243
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +19 -6
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +130 -143
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +18 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +158 -157
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +19 -5
- data/contrib/zstd/lib/libzstd.pc.in +15 -0
- data/contrib/zstd/lib/zstd.h +2391 -0
- data/ext/depend +2 -0
- data/ext/extconf.rb +15 -6
- data/ext/extzstd.c +76 -145
- data/ext/extzstd.h +80 -31
- data/ext/extzstd_stream.c +417 -142
- data/ext/libzstd_conf.h +8 -0
- data/ext/zstd_common.c +10 -7
- data/ext/zstd_compress.c +14 -5
- data/ext/zstd_decompress.c +5 -4
- data/ext/zstd_dictbuilder.c +9 -4
- data/ext/zstd_dictbuilder_fastcover.c +3 -0
- data/ext/zstd_legacy_v01.c +3 -1
- data/ext/zstd_legacy_v02.c +3 -1
- data/ext/zstd_legacy_v03.c +3 -1
- data/ext/zstd_legacy_v04.c +3 -1
- data/ext/zstd_legacy_v05.c +3 -1
- data/ext/zstd_legacy_v06.c +3 -1
- data/ext/zstd_legacy_v07.c +3 -1
- data/gemstub.rb +10 -24
- data/lib/extzstd.rb +64 -179
- data/lib/extzstd/version.rb +6 -1
- data/test/test_basic.rb +9 -6
- metadata +113 -57
- data/HISTORY.ja +0 -5
- data/contrib/zstd/common/entropy_common.c +0 -225
- data/contrib/zstd/common/huf.h +0 -228
- data/contrib/zstd/common/zstd_common.c +0 -83
- data/contrib/zstd/common/zstd_errors.h +0 -60
- data/contrib/zstd/common/zstd_internal.h +0 -267
- data/contrib/zstd/compress/huf_compress.c +0 -533
- data/contrib/zstd/compress/zbuff_compress.c +0 -319
- data/contrib/zstd/compress/zstd_compress.c +0 -3264
- data/contrib/zstd/compress/zstd_opt.h +0 -900
- data/contrib/zstd/decompress/huf_decompress.c +0 -883
- data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
- data/contrib/zstd/decompress/zstd_decompress.c +0 -1842
- data/contrib/zstd/dictBuilder/zdict.h +0 -111
- data/contrib/zstd/zstd.h +0 -640
@@ -0,0 +1,62 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
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
|
+
/* ZSTD_decompressBlock_internal() :
|
37
|
+
* decompress block, starting at `src`,
|
38
|
+
* into destination buffer `dst`.
|
39
|
+
* @return : decompressed block size,
|
40
|
+
* or an error code (which can be tested using ZSTD_isError())
|
41
|
+
*/
|
42
|
+
size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
|
43
|
+
void* dst, size_t dstCapacity,
|
44
|
+
const void* src, size_t srcSize, const int frame);
|
45
|
+
|
46
|
+
/* ZSTD_buildFSETable() :
|
47
|
+
* generate FSE decoding table for one symbol (ll, ml or off)
|
48
|
+
* this function must be called with valid parameters only
|
49
|
+
* (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
|
50
|
+
* in which case it cannot fail.
|
51
|
+
* The workspace must be 4-byte aligned and at least ZSTD_BUILD_FSE_TABLE_WKSP_SIZE bytes, which is
|
52
|
+
* defined in zstd_decompress_internal.h.
|
53
|
+
* Internal use only.
|
54
|
+
*/
|
55
|
+
void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
|
56
|
+
const short* normalizedCounter, unsigned maxSymbolValue,
|
57
|
+
const U32* baseValue, const U32* nbAdditionalBits,
|
58
|
+
unsigned tableLog, void* wksp, size_t wkspSize,
|
59
|
+
int bmi2);
|
60
|
+
|
61
|
+
|
62
|
+
#endif /* ZSTD_DEC_BLOCK_H */
|
@@ -0,0 +1,190 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
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" /* ZSTD_seqSymbol */
|
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 U32 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
|
+
|
79
|
+
typedef struct {
|
80
|
+
ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */
|
81
|
+
ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */
|
82
|
+
ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */
|
83
|
+
HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */
|
84
|
+
U32 rep[ZSTD_REP_NUM];
|
85
|
+
U32 workspace[ZSTD_BUILD_FSE_TABLE_WKSP_SIZE_U32];
|
86
|
+
} ZSTD_entropyDTables_t;
|
87
|
+
|
88
|
+
typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
|
89
|
+
ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock,
|
90
|
+
ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
|
91
|
+
ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
|
92
|
+
|
93
|
+
typedef enum { zdss_init=0, zdss_loadHeader,
|
94
|
+
zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
|
95
|
+
|
96
|
+
typedef enum {
|
97
|
+
ZSTD_use_indefinitely = -1, /* Use the dictionary indefinitely */
|
98
|
+
ZSTD_dont_use = 0, /* Do not use the dictionary (if one exists free it) */
|
99
|
+
ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */
|
100
|
+
} ZSTD_dictUses_e;
|
101
|
+
|
102
|
+
struct ZSTD_DCtx_s
|
103
|
+
{
|
104
|
+
const ZSTD_seqSymbol* LLTptr;
|
105
|
+
const ZSTD_seqSymbol* MLTptr;
|
106
|
+
const ZSTD_seqSymbol* OFTptr;
|
107
|
+
const HUF_DTable* HUFptr;
|
108
|
+
ZSTD_entropyDTables_t entropy;
|
109
|
+
U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */
|
110
|
+
const void* previousDstEnd; /* detect continuity */
|
111
|
+
const void* prefixStart; /* start of current segment */
|
112
|
+
const void* virtualStart; /* virtual start of previous segment if it was just before current one */
|
113
|
+
const void* dictEnd; /* end of previous segment */
|
114
|
+
size_t expected;
|
115
|
+
ZSTD_frameHeader fParams;
|
116
|
+
U64 decodedSize;
|
117
|
+
blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */
|
118
|
+
ZSTD_dStage stage;
|
119
|
+
U32 litEntropy;
|
120
|
+
U32 fseEntropy;
|
121
|
+
XXH64_state_t xxhState;
|
122
|
+
size_t headerSize;
|
123
|
+
ZSTD_format_e format;
|
124
|
+
ZSTD_forceIgnoreChecksum_e forceIgnoreChecksum; /* User specified: if == 1, will ignore checksums in compressed frame. Default == 0 */
|
125
|
+
U32 validateChecksum; /* if == 1, will validate checksum. Is == 1 if (fParams.checksumFlag == 1) and (forceIgnoreChecksum == 0). */
|
126
|
+
const BYTE* litPtr;
|
127
|
+
ZSTD_customMem customMem;
|
128
|
+
size_t litSize;
|
129
|
+
size_t rleSize;
|
130
|
+
size_t staticSize;
|
131
|
+
int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
|
132
|
+
|
133
|
+
/* dictionary */
|
134
|
+
ZSTD_DDict* ddictLocal;
|
135
|
+
const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
|
136
|
+
U32 dictID;
|
137
|
+
int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
|
138
|
+
ZSTD_dictUses_e dictUses;
|
139
|
+
|
140
|
+
/* streaming */
|
141
|
+
ZSTD_dStreamStage streamStage;
|
142
|
+
char* inBuff;
|
143
|
+
size_t inBuffSize;
|
144
|
+
size_t inPos;
|
145
|
+
size_t maxWindowSize;
|
146
|
+
char* outBuff;
|
147
|
+
size_t outBuffSize;
|
148
|
+
size_t outStart;
|
149
|
+
size_t outEnd;
|
150
|
+
size_t lhSize;
|
151
|
+
void* legacyContext;
|
152
|
+
U32 previousLegacyVersion;
|
153
|
+
U32 legacyVersion;
|
154
|
+
U32 hostageByte;
|
155
|
+
int noForwardProgress;
|
156
|
+
ZSTD_bufferMode_e outBufferMode;
|
157
|
+
ZSTD_outBuffer expectedOutBuffer;
|
158
|
+
|
159
|
+
/* workspace */
|
160
|
+
BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH];
|
161
|
+
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
|
162
|
+
|
163
|
+
size_t oversizedDuration;
|
164
|
+
|
165
|
+
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
166
|
+
void const* dictContentBeginForFuzzing;
|
167
|
+
void const* dictContentEndForFuzzing;
|
168
|
+
#endif
|
169
|
+
}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
|
170
|
+
|
171
|
+
|
172
|
+
/*-*******************************************************
|
173
|
+
* Shared internal functions
|
174
|
+
*********************************************************/
|
175
|
+
|
176
|
+
/*! ZSTD_loadDEntropy() :
|
177
|
+
* dict : must point at beginning of a valid zstd dictionary.
|
178
|
+
* @return : size of dictionary header (size of magic number + dict ID + entropy tables) */
|
179
|
+
size_t ZSTD_loadDEntropy(ZSTD_entropyDTables_t* entropy,
|
180
|
+
const void* const dict, size_t const dictSize);
|
181
|
+
|
182
|
+
/*! ZSTD_checkContinuity() :
|
183
|
+
* check if next `dst` follows previous position, where decompression ended.
|
184
|
+
* If yes, do nothing (continue on current segment).
|
185
|
+
* If not, classify previous segment as "external dictionary", and start a new segment.
|
186
|
+
* This function cannot fail. */
|
187
|
+
void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst);
|
188
|
+
|
189
|
+
|
190
|
+
#endif /* ZSTD_DECOMPRESS_INTERNAL_H */
|
@@ -1,43 +1,62 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2016-
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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.
|
8
9
|
*/
|
9
10
|
|
10
11
|
/* ***************************************************************
|
11
12
|
* NOTES/WARNINGS
|
12
|
-
|
13
|
-
/* The streaming API defined here
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*****************************************************************/
|
13
|
+
******************************************************************/
|
14
|
+
/* The streaming API defined here is deprecated.
|
15
|
+
* Consider migrating towards ZSTD_compressStream() API in `zstd.h`
|
16
|
+
* See 'lib/README.md'.
|
17
|
+
*****************************************************************/
|
17
18
|
|
18
|
-
#ifndef ZSTD_BUFFERED_H_23987
|
19
|
-
#define ZSTD_BUFFERED_H_23987
|
20
19
|
|
21
20
|
#if defined (__cplusplus)
|
22
21
|
extern "C" {
|
23
22
|
#endif
|
24
23
|
|
24
|
+
#ifndef ZSTD_BUFFERED_H_23987
|
25
|
+
#define ZSTD_BUFFERED_H_23987
|
26
|
+
|
25
27
|
/* *************************************
|
26
28
|
* Dependencies
|
27
29
|
***************************************/
|
28
30
|
#include <stddef.h> /* size_t */
|
31
|
+
#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
|
29
32
|
|
30
33
|
|
31
34
|
/* ***************************************************************
|
32
35
|
* Compiler specifics
|
33
36
|
*****************************************************************/
|
34
|
-
/*
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
/* Deprecation warnings */
|
38
|
+
/* Should these warnings be a problem,
|
39
|
+
* it is generally possible to disable them,
|
40
|
+
* typically with -Wno-deprecated-declarations for gcc
|
41
|
+
* or _CRT_SECURE_NO_WARNINGS in Visual.
|
42
|
+
* Otherwise, it's also possible to define ZBUFF_DISABLE_DEPRECATE_WARNINGS
|
43
|
+
*/
|
44
|
+
#ifdef ZBUFF_DISABLE_DEPRECATE_WARNINGS
|
45
|
+
# define ZBUFF_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
|
38
46
|
#else
|
39
|
-
#
|
40
|
-
#
|
47
|
+
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
48
|
+
# define ZBUFF_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
|
49
|
+
# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
|
50
|
+
# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
|
51
|
+
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
52
|
+
# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
|
53
|
+
# elif defined(_MSC_VER)
|
54
|
+
# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
|
55
|
+
# else
|
56
|
+
# pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
|
57
|
+
# define ZBUFF_DEPRECATED(message) ZSTDLIB_API
|
58
|
+
# endif
|
59
|
+
#endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
|
41
60
|
|
42
61
|
|
43
62
|
/* *************************************
|
@@ -49,16 +68,16 @@ extern "C" {
|
|
49
68
|
* ZBUFF and ZSTD are 100% interoperable,
|
50
69
|
* frames created by one can be decoded by the other one */
|
51
70
|
|
52
|
-
typedef
|
53
|
-
|
54
|
-
|
71
|
+
typedef ZSTD_CStream ZBUFF_CCtx;
|
72
|
+
ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
|
73
|
+
ZBUFF_DEPRECATED("use ZSTD_freeCStream") size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
|
55
74
|
|
56
|
-
|
57
|
-
|
75
|
+
ZBUFF_DEPRECATED("use ZSTD_initCStream") size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
|
76
|
+
ZBUFF_DEPRECATED("use ZSTD_initCStream_usingDict") size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
58
77
|
|
59
|
-
|
60
|
-
|
61
|
-
|
78
|
+
ZBUFF_DEPRECATED("use ZSTD_compressStream") size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
|
79
|
+
ZBUFF_DEPRECATED("use ZSTD_flushStream") size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
|
80
|
+
ZBUFF_DEPRECATED("use ZSTD_endStream") size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
|
62
81
|
|
63
82
|
/*-*************************************************
|
64
83
|
* Streaming compression - howto
|
@@ -101,14 +120,14 @@ ZSTDLIB_API size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCap
|
|
101
120
|
* **************************************************/
|
102
121
|
|
103
122
|
|
104
|
-
typedef
|
105
|
-
|
106
|
-
|
123
|
+
typedef ZSTD_DStream ZBUFF_DCtx;
|
124
|
+
ZBUFF_DEPRECATED("use ZSTD_createDStream") ZBUFF_DCtx* ZBUFF_createDCtx(void);
|
125
|
+
ZBUFF_DEPRECATED("use ZSTD_freeDStream") size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
|
107
126
|
|
108
|
-
|
109
|
-
|
127
|
+
ZBUFF_DEPRECATED("use ZSTD_initDStream") size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
|
128
|
+
ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
|
110
129
|
|
111
|
-
|
130
|
+
ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
|
112
131
|
void* dst, size_t* dstCapacityPtr,
|
113
132
|
const void* src, size_t* srcSizePtr);
|
114
133
|
|
@@ -141,18 +160,22 @@ ZSTDLIB_API size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
|
|
141
160
|
/* *************************************
|
142
161
|
* Tool functions
|
143
162
|
***************************************/
|
144
|
-
|
145
|
-
|
163
|
+
ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
|
164
|
+
ZBUFF_DEPRECATED("use ZSTD_getErrorName") const char* ZBUFF_getErrorName(size_t errorCode);
|
146
165
|
|
147
166
|
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
148
167
|
* These sizes are just hints, they tend to offer better latency */
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
168
|
+
ZBUFF_DEPRECATED("use ZSTD_CStreamInSize") size_t ZBUFF_recommendedCInSize(void);
|
169
|
+
ZBUFF_DEPRECATED("use ZSTD_CStreamOutSize") size_t ZBUFF_recommendedCOutSize(void);
|
170
|
+
ZBUFF_DEPRECATED("use ZSTD_DStreamInSize") size_t ZBUFF_recommendedDInSize(void);
|
171
|
+
ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(void);
|
172
|
+
|
173
|
+
#endif /* ZSTD_BUFFERED_H_23987 */
|
153
174
|
|
154
175
|
|
155
176
|
#ifdef ZBUFF_STATIC_LINKING_ONLY
|
177
|
+
#ifndef ZBUFF_STATIC_H_30298098432
|
178
|
+
#define ZBUFF_STATIC_H_30298098432
|
156
179
|
|
157
180
|
/* ====================================================================================
|
158
181
|
* The definitions in this section are considered experimental.
|
@@ -163,29 +186,29 @@ ZSTDLIB_API size_t ZBUFF_recommendedDOutSize(void);
|
|
163
186
|
|
164
187
|
/*--- Dependency ---*/
|
165
188
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
|
166
|
-
#include "zstd.h"
|
189
|
+
#include "../zstd.h"
|
167
190
|
|
168
191
|
|
169
192
|
/*--- Custom memory allocator ---*/
|
170
193
|
/*! ZBUFF_createCCtx_advanced() :
|
171
194
|
* Create a ZBUFF compression context using external alloc and free functions */
|
172
|
-
|
195
|
+
ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
|
173
196
|
|
174
197
|
/*! ZBUFF_createDCtx_advanced() :
|
175
198
|
* Create a ZBUFF decompression context using external alloc and free functions */
|
176
|
-
|
199
|
+
ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
|
177
200
|
|
178
201
|
|
179
202
|
/*--- Advanced Streaming Initialization ---*/
|
180
|
-
|
203
|
+
ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
|
181
204
|
const void* dict, size_t dictSize,
|
182
205
|
ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
183
206
|
|
184
|
-
|
207
|
+
|
208
|
+
#endif /* ZBUFF_STATIC_H_30298098432 */
|
209
|
+
#endif /* ZBUFF_STATIC_LINKING_ONLY */
|
185
210
|
|
186
211
|
|
187
212
|
#if defined (__cplusplus)
|
188
213
|
}
|
189
214
|
#endif
|
190
|
-
|
191
|
-
#endif /* ZSTD_BUFFERED_H_23987 */
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
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
|
+
* Dependencies
|
13
|
+
***************************************/
|
14
|
+
#include "../common/error_private.h"
|
15
|
+
#include "zbuff.h"
|
16
|
+
|
17
|
+
/*-****************************************
|
18
|
+
* ZBUFF Error Management (deprecated)
|
19
|
+
******************************************/
|
20
|
+
|
21
|
+
/*! ZBUFF_isError() :
|
22
|
+
* tells if a return value is an error code */
|
23
|
+
unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
|
24
|
+
/*! ZBUFF_getErrorName() :
|
25
|
+
* provides error code string from function result (useful for debugging) */
|
26
|
+
const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
|