zstdlib 0.2.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +30 -1
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/ext/zstdlib/extconf.rb +3 -3
- data/ext/zstdlib/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/bitstream.h +38 -39
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/compiler.h +40 -5
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/cpu.h +1 -1
- data/ext/zstdlib/zstd-1.4.5/lib/common/debug.c +24 -0
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/debug.h +11 -31
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/entropy_common.c +13 -33
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/error_private.c +2 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/error_private.h +6 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/fse.h +12 -32
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/fse_decompress.c +12 -35
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/huf.h +15 -33
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/mem.h +75 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/pool.c +8 -4
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/pool.h +2 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/threading.c +50 -4
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/threading.h +36 -4
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/xxhash.c +23 -35
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/xxhash.h +11 -31
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/zstd_common.c +1 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/zstd_errors.h +2 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/common/zstd_internal.h +154 -26
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/fse_compress.c +17 -40
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/hist.c +15 -35
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/hist.h +12 -32
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/huf_compress.c +92 -92
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_compress.c +1191 -1330
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_compress_internal.h +317 -55
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_literals.c +158 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_literals.h +29 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_sequences.c +419 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_superblock.c +845 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_cwksp.h +525 -0
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_double_fast.c +65 -43
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_double_fast.h +2 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_fast.c +92 -66
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_fast.h +2 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_lazy.c +74 -42
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_lazy.h +1 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_ldm.c +32 -10
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_ldm.h +7 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_opt.c +81 -114
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstd_opt.h +1 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstdmt_compress.c +95 -51
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/compress/zstdmt_compress.h +3 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/huf_decompress.c +76 -60
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_ddict.c +12 -8
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_ddict.h +2 -2
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_decompress.c +292 -172
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_decompress_block.c +459 -338
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_decompress_block.h +3 -3
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/decompress/zstd_decompress_internal.h +18 -4
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/lib/zstd.h +265 -88
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzclose.c +1 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzcompatibility.h +1 -1
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzguts.h +0 -0
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzlib.c +9 -9
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzread.c +16 -8
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/gzwrite.c +8 -8
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/zstd_zlibwrapper.c +16 -12
- data/ext/zstdlib/{zstd-1.4.0 → zstd-1.4.5}/zlibWrapper/zstd_zlibwrapper.h +1 -1
- metadata +69 -62
- data/ext/zstdlib/zstd-1.4.0/lib/common/debug.c +0 -44
@@ -1,35 +1,15 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
14
|
-
* Redistributions in binary form must reproduce the above
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
16
|
-
in the documentation and/or other materials provided with the
|
17
|
-
distribution.
|
18
|
-
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
You can contact the author at :
|
32
|
-
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
2
|
+
* xxHash - Extremely Fast Hash algorithm
|
3
|
+
* Header File
|
4
|
+
* Copyright (c) 2012-2020, Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
7
|
+
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
8
|
+
*
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
33
13
|
*/
|
34
14
|
|
35
15
|
/* Notice extracted from xxHash homepage :
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2020, 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
|
@@ -76,6 +76,7 @@ typedef enum {
|
|
76
76
|
/* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
|
77
77
|
ZSTD_error_frameIndex_tooLarge = 100,
|
78
78
|
ZSTD_error_seekableIO = 102,
|
79
|
+
ZSTD_error_dstBuffer_wrong = 104,
|
79
80
|
ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
|
80
81
|
} ZSTD_ErrorCode;
|
81
82
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2020, 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
|
@@ -19,12 +19,15 @@
|
|
19
19
|
/*-*************************************
|
20
20
|
* Dependencies
|
21
21
|
***************************************/
|
22
|
+
#ifdef __aarch64__
|
23
|
+
#include <arm_neon.h>
|
24
|
+
#endif
|
22
25
|
#include "compiler.h"
|
23
26
|
#include "mem.h"
|
24
27
|
#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
|
25
28
|
#include "error_private.h"
|
26
29
|
#define ZSTD_STATIC_LINKING_ONLY
|
27
|
-
#include "zstd.h"
|
30
|
+
#include "../zstd.h"
|
28
31
|
#define FSE_STATIC_LINKING_ONLY
|
29
32
|
#include "fse.h"
|
30
33
|
#define HUF_STATIC_LINKING_ONLY
|
@@ -34,7 +37,6 @@
|
|
34
37
|
#endif
|
35
38
|
#include "xxhash.h" /* XXH_reset, update, digest */
|
36
39
|
|
37
|
-
|
38
40
|
#if defined (__cplusplus)
|
39
41
|
extern "C" {
|
40
42
|
#endif
|
@@ -54,16 +56,43 @@ extern "C" {
|
|
54
56
|
#define MIN(a,b) ((a)<(b) ? (a) : (b))
|
55
57
|
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
56
58
|
|
59
|
+
/**
|
60
|
+
* Ignore: this is an internal helper.
|
61
|
+
*
|
62
|
+
* This is a helper function to help force C99-correctness during compilation.
|
63
|
+
* Under strict compilation modes, variadic macro arguments can't be empty.
|
64
|
+
* However, variadic function arguments can be. Using a function therefore lets
|
65
|
+
* us statically check that at least one (string) argument was passed,
|
66
|
+
* independent of the compilation flags.
|
67
|
+
*/
|
68
|
+
static INLINE_KEYWORD UNUSED_ATTR
|
69
|
+
void _force_has_format_string(const char *format, ...) {
|
70
|
+
(void)format;
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Ignore: this is an internal helper.
|
75
|
+
*
|
76
|
+
* We want to force this function invocation to be syntactically correct, but
|
77
|
+
* we don't want to force runtime evaluation of its arguments.
|
78
|
+
*/
|
79
|
+
#define _FORCE_HAS_FORMAT_STRING(...) \
|
80
|
+
if (0) { \
|
81
|
+
_force_has_format_string(__VA_ARGS__); \
|
82
|
+
}
|
83
|
+
|
57
84
|
/**
|
58
85
|
* Return the specified error if the condition evaluates to true.
|
59
86
|
*
|
60
|
-
* In debug modes, prints additional information.
|
61
|
-
* (particularly, printing the conditional that failed),
|
62
|
-
* RETURN_ERROR().
|
87
|
+
* In debug modes, prints additional information.
|
88
|
+
* In order to do that (particularly, printing the conditional that failed),
|
89
|
+
* this can't just wrap RETURN_ERROR().
|
63
90
|
*/
|
64
91
|
#define RETURN_ERROR_IF(cond, err, ...) \
|
65
92
|
if (cond) { \
|
66
|
-
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",
|
93
|
+
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
|
94
|
+
__FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
|
95
|
+
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
67
96
|
RAWLOG(3, ": " __VA_ARGS__); \
|
68
97
|
RAWLOG(3, "\n"); \
|
69
98
|
return ERROR(err); \
|
@@ -76,7 +105,9 @@ extern "C" {
|
|
76
105
|
*/
|
77
106
|
#define RETURN_ERROR(err, ...) \
|
78
107
|
do { \
|
79
|
-
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s",
|
108
|
+
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
|
109
|
+
__FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \
|
110
|
+
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
80
111
|
RAWLOG(3, ": " __VA_ARGS__); \
|
81
112
|
RAWLOG(3, "\n"); \
|
82
113
|
return ERROR(err); \
|
@@ -91,7 +122,9 @@ extern "C" {
|
|
91
122
|
do { \
|
92
123
|
size_t const err_code = (err); \
|
93
124
|
if (ERR_isError(err_code)) { \
|
94
|
-
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",
|
125
|
+
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
|
126
|
+
__FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \
|
127
|
+
_FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
|
95
128
|
RAWLOG(3, ": " __VA_ARGS__); \
|
96
129
|
RAWLOG(3, "\n"); \
|
97
130
|
return err_code; \
|
@@ -129,6 +162,8 @@ static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
|
|
129
162
|
static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
|
130
163
|
typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
|
131
164
|
|
165
|
+
#define ZSTD_FRAMECHECKSUMSIZE 4
|
166
|
+
|
132
167
|
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
133
168
|
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
|
134
169
|
|
@@ -192,32 +227,99 @@ static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
|
192
227
|
/*-*******************************************
|
193
228
|
* Shared functions to include for inlining
|
194
229
|
*********************************************/
|
195
|
-
static void ZSTD_copy8(void* dst, const void* src) {
|
230
|
+
static void ZSTD_copy8(void* dst, const void* src) {
|
231
|
+
#ifdef __aarch64__
|
232
|
+
vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src));
|
233
|
+
#else
|
234
|
+
memcpy(dst, src, 8);
|
235
|
+
#endif
|
236
|
+
}
|
237
|
+
|
196
238
|
#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
|
239
|
+
static void ZSTD_copy16(void* dst, const void* src) {
|
240
|
+
#ifdef __aarch64__
|
241
|
+
vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
|
242
|
+
#else
|
243
|
+
memcpy(dst, src, 16);
|
244
|
+
#endif
|
245
|
+
}
|
246
|
+
#define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
|
247
|
+
|
248
|
+
#define WILDCOPY_OVERLENGTH 32
|
249
|
+
#define WILDCOPY_VECLEN 16
|
250
|
+
|
251
|
+
typedef enum {
|
252
|
+
ZSTD_no_overlap,
|
253
|
+
ZSTD_overlap_src_before_dst
|
254
|
+
/* ZSTD_overlap_dst_before_src, */
|
255
|
+
} ZSTD_overlap_e;
|
197
256
|
|
198
257
|
/*! ZSTD_wildcopy() :
|
199
|
-
*
|
200
|
-
|
201
|
-
|
258
|
+
* Custom version of memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
|
259
|
+
* @param ovtype controls the overlap detection
|
260
|
+
* - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
|
261
|
+
* - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
|
262
|
+
* The src buffer must be before the dst buffer.
|
263
|
+
*/
|
264
|
+
MEM_STATIC FORCE_INLINE_ATTR
|
265
|
+
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
|
202
266
|
{
|
267
|
+
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
203
268
|
const BYTE* ip = (const BYTE*)src;
|
204
269
|
BYTE* op = (BYTE*)dst;
|
205
270
|
BYTE* const oend = op + length;
|
206
|
-
|
207
|
-
|
208
|
-
|
271
|
+
|
272
|
+
assert(diff >= 8 || (ovtype == ZSTD_no_overlap && diff <= -WILDCOPY_VECLEN));
|
273
|
+
|
274
|
+
if (ovtype == ZSTD_overlap_src_before_dst && diff < WILDCOPY_VECLEN) {
|
275
|
+
/* Handle short offset copies. */
|
276
|
+
do {
|
277
|
+
COPY8(op, ip)
|
278
|
+
} while (op < oend);
|
279
|
+
} else {
|
280
|
+
assert(diff >= WILDCOPY_VECLEN || diff <= -WILDCOPY_VECLEN);
|
281
|
+
/* Separate out the first COPY16() call because the copy length is
|
282
|
+
* almost certain to be short, so the branches have different
|
283
|
+
* probabilities. Since it is almost certain to be short, only do
|
284
|
+
* one COPY16() in the first call. Then, do two calls per loop since
|
285
|
+
* at that point it is more likely to have a high trip count.
|
286
|
+
*/
|
287
|
+
#ifndef __aarch64__
|
288
|
+
do {
|
289
|
+
COPY16(op, ip);
|
290
|
+
}
|
291
|
+
while (op < oend);
|
292
|
+
#else
|
293
|
+
COPY16(op, ip);
|
294
|
+
if (op >= oend) return;
|
295
|
+
do {
|
296
|
+
COPY16(op, ip);
|
297
|
+
COPY16(op, ip);
|
298
|
+
}
|
299
|
+
while (op < oend);
|
300
|
+
#endif
|
301
|
+
}
|
209
302
|
}
|
210
303
|
|
211
|
-
MEM_STATIC
|
304
|
+
MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
212
305
|
{
|
213
|
-
const
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
while (op < oend);
|
306
|
+
size_t const length = MIN(dstCapacity, srcSize);
|
307
|
+
if (length > 0) {
|
308
|
+
memcpy(dst, src, length);
|
309
|
+
}
|
310
|
+
return length;
|
219
311
|
}
|
220
312
|
|
313
|
+
/* define "workspace is too large" as this number of times larger than needed */
|
314
|
+
#define ZSTD_WORKSPACETOOLARGE_FACTOR 3
|
315
|
+
|
316
|
+
/* when workspace is continuously too large
|
317
|
+
* during at least this number of times,
|
318
|
+
* context's memory usage is considered wasteful,
|
319
|
+
* because it's sized to handle a worst case scenario which rarely happens.
|
320
|
+
* In which case, resize it down to free some memory */
|
321
|
+
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
|
322
|
+
|
221
323
|
|
222
324
|
/*-*******************************************
|
223
325
|
* Private declarations
|
@@ -242,6 +344,31 @@ typedef struct {
|
|
242
344
|
U32 longLengthPos;
|
243
345
|
} seqStore_t;
|
244
346
|
|
347
|
+
typedef struct {
|
348
|
+
U32 litLength;
|
349
|
+
U32 matchLength;
|
350
|
+
} ZSTD_sequenceLength;
|
351
|
+
|
352
|
+
/**
|
353
|
+
* Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences
|
354
|
+
* indicated by longLengthPos and longLengthID, and adds MINMATCH back to matchLength.
|
355
|
+
*/
|
356
|
+
MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq)
|
357
|
+
{
|
358
|
+
ZSTD_sequenceLength seqLen;
|
359
|
+
seqLen.litLength = seq->litLength;
|
360
|
+
seqLen.matchLength = seq->matchLength + MINMATCH;
|
361
|
+
if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
|
362
|
+
if (seqStore->longLengthID == 1) {
|
363
|
+
seqLen.litLength += 0xFFFF;
|
364
|
+
}
|
365
|
+
if (seqStore->longLengthID == 2) {
|
366
|
+
seqLen.matchLength += 0xFFFF;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
return seqLen;
|
370
|
+
}
|
371
|
+
|
245
372
|
/**
|
246
373
|
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
247
374
|
* Note: before using `compressedSize`, check for errors using ZSTD_isError().
|
@@ -268,10 +395,11 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus
|
|
268
395
|
{
|
269
396
|
# if defined(_MSC_VER) /* Visual */
|
270
397
|
unsigned long r=0;
|
271
|
-
_BitScanReverse(&r, val);
|
272
|
-
return (unsigned)r;
|
398
|
+
return _BitScanReverse(&r, val) ? (unsigned)r : 0;
|
273
399
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
|
274
|
-
return
|
400
|
+
return __builtin_clz (val) ^ 31;
|
401
|
+
# elif defined(__ICCARM__) /* IAR Intrinsic */
|
402
|
+
return 31 - __CLZ(val);
|
275
403
|
# else /* Software version */
|
276
404
|
static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
|
277
405
|
U32 v = val;
|
@@ -1,35 +1,15 @@
|
|
1
1
|
/* ******************************************************************
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
15
|
-
in the documentation and/or other materials provided with the
|
16
|
-
distribution.
|
17
|
-
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
|
30
|
-
You can contact the author at :
|
31
|
-
- FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
32
|
-
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
2
|
+
* FSE : Finite State Entropy encoder
|
3
|
+
* Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
|
4
|
+
*
|
5
|
+
* You can contact the author at :
|
6
|
+
* - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
7
|
+
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
8
|
+
*
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
33
13
|
****************************************************************** */
|
34
14
|
|
35
15
|
/* **************************************************************
|
@@ -37,14 +17,14 @@
|
|
37
17
|
****************************************************************/
|
38
18
|
#include <stdlib.h> /* malloc, free, qsort */
|
39
19
|
#include <string.h> /* memcpy, memset */
|
40
|
-
#include "compiler.h"
|
41
|
-
#include "mem.h" /* U32, U16, etc. */
|
42
|
-
#include "debug.h" /* assert, DEBUGLOG */
|
20
|
+
#include "../common/compiler.h"
|
21
|
+
#include "../common/mem.h" /* U32, U16, etc. */
|
22
|
+
#include "../common/debug.h" /* assert, DEBUGLOG */
|
43
23
|
#include "hist.h" /* HIST_count_wksp */
|
44
|
-
#include "bitstream.h"
|
24
|
+
#include "../common/bitstream.h"
|
45
25
|
#define FSE_STATIC_LINKING_ONLY
|
46
|
-
#include "fse.h"
|
47
|
-
#include "error_private.h"
|
26
|
+
#include "../common/fse.h"
|
27
|
+
#include "../common/error_private.h"
|
48
28
|
|
49
29
|
|
50
30
|
/* **************************************************************
|
@@ -645,9 +625,6 @@ size_t FSE_compress_usingCTable (void* dst, size_t dstSize,
|
|
645
625
|
|
646
626
|
size_t FSE_compressBound(size_t size) { return FSE_COMPRESSBOUND(size); }
|
647
627
|
|
648
|
-
#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e
|
649
|
-
#define CHECK_F(f) { CHECK_V_F(_var_err__, f); }
|
650
|
-
|
651
628
|
/* FSE_compress_wksp() :
|
652
629
|
* Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
|
653
630
|
* `wkspSize` size must be `(1<<tableLog)`.
|
@@ -1,42 +1,22 @@
|
|
1
1
|
/* ******************************************************************
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
* Redistributions in binary form must reproduce the above
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
16
|
-
in the documentation and/or other materials provided with the
|
17
|
-
distribution.
|
18
|
-
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
You can contact the author at :
|
32
|
-
- FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
33
|
-
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
2
|
+
* hist : Histogram functions
|
3
|
+
* part of Finite State Entropy project
|
4
|
+
* Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
7
|
+
* - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
8
|
+
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
9
|
+
*
|
10
|
+
* This source code is licensed under both the BSD-style license (found in the
|
11
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
12
|
+
* in the COPYING file in the root directory of this source tree).
|
13
|
+
* You may select, at your option, one of the above-listed licenses.
|
34
14
|
****************************************************************** */
|
35
15
|
|
36
16
|
/* --- dependencies --- */
|
37
|
-
#include "mem.h" /* U32, BYTE, etc. */
|
38
|
-
#include "debug.h" /* assert, DEBUGLOG */
|
39
|
-
#include "error_private.h" /* ERROR */
|
17
|
+
#include "../common/mem.h" /* U32, BYTE, etc. */
|
18
|
+
#include "../common/debug.h" /* assert, DEBUGLOG */
|
19
|
+
#include "../common/error_private.h" /* ERROR */
|
40
20
|
#include "hist.h"
|
41
21
|
|
42
22
|
|