zstd-ruby 1.3.2.0 → 1.3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/zstdruby/libzstd/BUCK +31 -10
- data/ext/zstdruby/libzstd/common/bitstream.h +1 -1
- data/ext/zstdruby/libzstd/common/mem.h +15 -13
- data/ext/zstdruby/libzstd/common/pool.c +1 -2
- data/ext/zstdruby/libzstd/common/zstd_common.c +10 -4
- data/ext/zstdruby/libzstd/common/zstd_internal.h +52 -170
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +434 -337
- data/ext/zstdruby/libzstd/compress/{zstd_compress.h → zstd_compress_internal.h} +191 -36
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +1 -0
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +1 -0
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +66 -50
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +504 -676
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +2 -2
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +130 -80
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +15 -7
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +41 -31
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -0
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +1 -74
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +1 -74
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +1 -72
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +1 -73
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +1 -77
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +1 -77
- data/ext/zstdruby/libzstd/zstd.h +43 -30
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5fcad8a810e6565963ca4bd38db6723e579f84
|
4
|
+
data.tar.gz: 059c0bfd179080c58371dc513e7aa088fdd67db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7273691052d4aa702351531f1dc314a9f99b460269a65c3b448b71da813315d07a00c60e4b6005e8377e5535e2f245777afecbf4b443d7058df6ac4f77f695a
|
7
|
+
data.tar.gz: ff0aa695180188f1f7919415dec65e9a01756a8481446f4f02298e6b131eea2ca42f3da61c316fcaa9e92d07eb07a988a5e8e0c9091c9b60d169d477b19436b8
|
data/README.md
CHANGED
data/ext/zstdruby/libzstd/BUCK
CHANGED
@@ -15,15 +15,9 @@ cxx_library(
|
|
15
15
|
header_namespace='',
|
16
16
|
visibility=['PUBLIC'],
|
17
17
|
exported_headers=subdir_glob([
|
18
|
-
('compress', '
|
18
|
+
('compress', 'zstd*.h'),
|
19
19
|
]),
|
20
|
-
|
21
|
-
('compress', 'zstd_opt.h'),
|
22
|
-
]),
|
23
|
-
srcs=[
|
24
|
-
'compress/zstd_compress.c',
|
25
|
-
'compress/zstdmt_compress.c',
|
26
|
-
],
|
20
|
+
srcs=glob(['compress/zstd*.c']),
|
27
21
|
deps=[':common'],
|
28
22
|
)
|
29
23
|
|
@@ -31,7 +25,7 @@ cxx_library(
|
|
31
25
|
name='decompress',
|
32
26
|
header_namespace='',
|
33
27
|
visibility=['PUBLIC'],
|
34
|
-
srcs=['decompress/
|
28
|
+
srcs=glob(['decompress/zstd*.c']),
|
35
29
|
deps=[
|
36
30
|
':common',
|
37
31
|
':legacy',
|
@@ -58,6 +52,9 @@ cxx_library(
|
|
58
52
|
]),
|
59
53
|
srcs=glob(['legacy/*.c']),
|
60
54
|
deps=[':common'],
|
55
|
+
exported_preprocessor_flags=[
|
56
|
+
'-DZSTD_LEGACY_SUPPORT=4',
|
57
|
+
],
|
61
58
|
)
|
62
59
|
|
63
60
|
cxx_library(
|
@@ -74,6 +71,15 @@ cxx_library(
|
|
74
71
|
deps=[':common'],
|
75
72
|
)
|
76
73
|
|
74
|
+
cxx_library(
|
75
|
+
name='compiler',
|
76
|
+
header_namespace='',
|
77
|
+
visibility=['PUBLIC'],
|
78
|
+
exported_headers=subdir_glob([
|
79
|
+
('common', 'compiler.h'),
|
80
|
+
]),
|
81
|
+
)
|
82
|
+
|
77
83
|
cxx_library(
|
78
84
|
name='bitstream',
|
79
85
|
header_namespace='',
|
@@ -100,6 +106,7 @@ cxx_library(
|
|
100
106
|
],
|
101
107
|
deps=[
|
102
108
|
':bitstream',
|
109
|
+
':compiler',
|
103
110
|
':errors',
|
104
111
|
':mem',
|
105
112
|
],
|
@@ -133,7 +140,10 @@ cxx_library(
|
|
133
140
|
('common', 'pool.h'),
|
134
141
|
]),
|
135
142
|
srcs=['common/pool.c'],
|
136
|
-
deps=[
|
143
|
+
deps=[
|
144
|
+
':threading',
|
145
|
+
':zstd_common',
|
146
|
+
],
|
137
147
|
)
|
138
148
|
|
139
149
|
cxx_library(
|
@@ -144,6 +154,12 @@ cxx_library(
|
|
144
154
|
('common', 'threading.h'),
|
145
155
|
]),
|
146
156
|
srcs=['common/threading.c'],
|
157
|
+
exported_preprocessor_flags=[
|
158
|
+
'-DZSTD_MULTITHREAD',
|
159
|
+
],
|
160
|
+
exported_linker_flags=[
|
161
|
+
'-pthread',
|
162
|
+
],
|
147
163
|
)
|
148
164
|
|
149
165
|
cxx_library(
|
@@ -154,6 +170,9 @@ cxx_library(
|
|
154
170
|
('common', 'xxhash.h'),
|
155
171
|
]),
|
156
172
|
srcs=['common/xxhash.c'],
|
173
|
+
exported_preprocessor_flags=[
|
174
|
+
'-DXXH_NAMESPACE=ZSTD_',
|
175
|
+
],
|
157
176
|
)
|
158
177
|
|
159
178
|
cxx_library(
|
@@ -166,6 +185,7 @@ cxx_library(
|
|
166
185
|
]),
|
167
186
|
srcs=['common/zstd_common.c'],
|
168
187
|
deps=[
|
188
|
+
':compiler',
|
169
189
|
':errors',
|
170
190
|
':mem',
|
171
191
|
],
|
@@ -175,6 +195,7 @@ cxx_library(
|
|
175
195
|
name='common',
|
176
196
|
deps=[
|
177
197
|
':bitstream',
|
198
|
+
':compiler',
|
178
199
|
':entropy',
|
179
200
|
':errors',
|
180
201
|
':mem',
|
@@ -167,7 +167,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
|
|
167
167
|
/*-**************************************************************
|
168
168
|
* Internal functions
|
169
169
|
****************************************************************/
|
170
|
-
MEM_STATIC unsigned BIT_highbit32 (
|
170
|
+
MEM_STATIC unsigned BIT_highbit32 (U32 val)
|
171
171
|
{
|
172
172
|
assert(val != 0);
|
173
173
|
{
|
@@ -56,8 +56,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size
|
|
56
56
|
typedef int32_t S32;
|
57
57
|
typedef uint64_t U64;
|
58
58
|
typedef int64_t S64;
|
59
|
-
typedef intptr_t iPtrDiff;
|
60
|
-
typedef uintptr_t uPtrDiff;
|
61
59
|
#else
|
62
60
|
typedef unsigned char BYTE;
|
63
61
|
typedef unsigned short U16;
|
@@ -66,8 +64,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size
|
|
66
64
|
typedef signed int S32;
|
67
65
|
typedef unsigned long long U64;
|
68
66
|
typedef signed long long S64;
|
69
|
-
typedef ptrdiff_t iPtrDiff;
|
70
|
-
typedef size_t uPtrDiff;
|
71
67
|
#endif
|
72
68
|
|
73
69
|
|
@@ -123,20 +119,26 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
|
|
123
119
|
/* currently only defined for gcc and icc */
|
124
120
|
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
|
125
121
|
__pragma( pack(push, 1) )
|
126
|
-
typedef
|
122
|
+
typedef struct { U16 v; } unalign16;
|
123
|
+
typedef struct { U32 v; } unalign32;
|
124
|
+
typedef struct { U64 v; } unalign64;
|
125
|
+
typedef struct { size_t v; } unalignArch;
|
127
126
|
__pragma( pack(pop) )
|
128
127
|
#else
|
129
|
-
typedef
|
128
|
+
typedef struct { U16 v; } __attribute__((packed)) unalign16;
|
129
|
+
typedef struct { U32 v; } __attribute__((packed)) unalign32;
|
130
|
+
typedef struct { U64 v; } __attribute__((packed)) unalign64;
|
131
|
+
typedef struct { size_t v; } __attribute__((packed)) unalignArch;
|
130
132
|
#endif
|
131
133
|
|
132
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const
|
133
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const
|
134
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const
|
135
|
-
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const
|
134
|
+
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; }
|
135
|
+
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; }
|
136
|
+
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; }
|
137
|
+
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; }
|
136
138
|
|
137
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((
|
138
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((
|
139
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((
|
139
|
+
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; }
|
140
|
+
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; }
|
141
|
+
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; }
|
140
142
|
|
141
143
|
#else
|
142
144
|
|
@@ -11,7 +11,6 @@
|
|
11
11
|
|
12
12
|
/* ====== Dependencies ======= */
|
13
13
|
#include <stddef.h> /* size_t */
|
14
|
-
#include <stdlib.h> /* malloc, calloc, free */
|
15
14
|
#include "pool.h"
|
16
15
|
|
17
16
|
/* ====== Compiler specifics ====== */
|
@@ -115,7 +114,7 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customM
|
|
115
114
|
* and full queues.
|
116
115
|
*/
|
117
116
|
ctx->queueSize = queueSize + 1;
|
118
|
-
ctx->queue = (POOL_job*)
|
117
|
+
ctx->queue = (POOL_job*)ZSTD_malloc(ctx->queueSize * sizeof(POOL_job), customMem);
|
119
118
|
ctx->queueHead = 0;
|
120
119
|
ctx->queueTail = 0;
|
121
120
|
ctx->numThreadsBusy = 0;
|
@@ -31,21 +31,27 @@ const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
|
|
31
31
|
* ZSTD Error Management
|
32
32
|
******************************************/
|
33
33
|
/*! ZSTD_isError() :
|
34
|
-
*
|
34
|
+
* tells if a return value is an error code */
|
35
35
|
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
36
36
|
|
37
37
|
/*! ZSTD_getErrorName() :
|
38
|
-
*
|
38
|
+
* provides error code string from function result (useful for debugging) */
|
39
39
|
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
40
40
|
|
41
41
|
/*! ZSTD_getError() :
|
42
|
-
*
|
42
|
+
* convert a `size_t` function result into a proper ZSTD_errorCode enum */
|
43
43
|
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
44
44
|
|
45
45
|
/*! ZSTD_getErrorString() :
|
46
|
-
*
|
46
|
+
* provides error code string from enum */
|
47
47
|
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
48
48
|
|
49
|
+
/*! g_debuglog_enable :
|
50
|
+
* turn on/off debug traces (global switch) */
|
51
|
+
#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG >= 2)
|
52
|
+
int g_debuglog_enable = 1;
|
53
|
+
#endif
|
54
|
+
|
49
55
|
|
50
56
|
/*=**************************************************************
|
51
57
|
* Custom allocator
|
@@ -11,6 +11,10 @@
|
|
11
11
|
#ifndef ZSTD_CCOMMON_H_MODULE
|
12
12
|
#define ZSTD_CCOMMON_H_MODULE
|
13
13
|
|
14
|
+
/* this module contains definitions which must be identical
|
15
|
+
* across compression, decompression and dictBuilder.
|
16
|
+
* It also contains a few functions useful to at least 2 of them
|
17
|
+
* and which benefit from being inlined */
|
14
18
|
|
15
19
|
/*-*************************************
|
16
20
|
* Dependencies
|
@@ -50,21 +54,26 @@ extern "C" {
|
|
50
54
|
|
51
55
|
#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG>=2)
|
52
56
|
# include <stdio.h>
|
57
|
+
extern int g_debuglog_enable;
|
53
58
|
/* recommended values for ZSTD_DEBUG display levels :
|
54
59
|
* 1 : no display, enables assert() only
|
55
|
-
* 2 : reserved for currently active
|
56
|
-
* 3 : events once per object lifetime (CCtx, CDict)
|
60
|
+
* 2 : reserved for currently active debug path
|
61
|
+
* 3 : events once per object lifetime (CCtx, CDict, etc.)
|
57
62
|
* 4 : events once per frame
|
58
63
|
* 5 : events once per block
|
59
64
|
* 6 : events once per sequence (*very* verbose) */
|
60
|
-
# define
|
61
|
-
if (l<=ZSTD_DEBUG) {
|
62
|
-
fprintf(stderr,
|
63
|
-
|
64
|
-
|
65
|
+
# define RAWLOG(l, ...) { \
|
66
|
+
if ((g_debuglog_enable) & (l<=ZSTD_DEBUG)) { \
|
67
|
+
fprintf(stderr, __VA_ARGS__); \
|
68
|
+
} }
|
69
|
+
# define DEBUGLOG(l, ...) { \
|
70
|
+
if ((g_debuglog_enable) & (l<=ZSTD_DEBUG)) { \
|
71
|
+
fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
|
72
|
+
fprintf(stderr, " \n"); \
|
65
73
|
} }
|
66
74
|
#else
|
67
|
-
# define
|
75
|
+
# define RAWLOG(l, ...) {} /* disabled */
|
76
|
+
# define DEBUGLOG(l, ...) {} /* disabled */
|
68
77
|
#endif
|
69
78
|
|
70
79
|
|
@@ -85,9 +94,7 @@ extern "C" {
|
|
85
94
|
#define ZSTD_OPT_NUM (1<<12)
|
86
95
|
|
87
96
|
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
88
|
-
#define ZSTD_REP_CHECK (ZSTD_REP_NUM) /* number of repcodes to check by the optimal parser */
|
89
97
|
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
90
|
-
#define ZSTD_REP_MOVE_OPT (ZSTD_REP_NUM)
|
91
98
|
static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
92
99
|
|
93
100
|
#define KB *(1 <<10)
|
@@ -134,28 +141,40 @@ typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingTy
|
|
134
141
|
#define LLFSELog 9
|
135
142
|
#define OffFSELog 8
|
136
143
|
|
137
|
-
static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
138
|
-
|
144
|
+
static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
145
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
146
|
+
1, 1, 1, 1, 2, 2, 3, 3,
|
147
|
+
4, 6, 7, 8, 9,10,11,12,
|
139
148
|
13,14,15,16 };
|
140
|
-
static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
|
141
|
-
2, 2, 2, 2, 2,
|
149
|
+
static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
|
150
|
+
2, 2, 2, 2, 2, 1, 1, 1,
|
151
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
152
|
+
2, 3, 2, 1, 1, 1, 1, 1,
|
142
153
|
-1,-1,-1,-1 };
|
143
154
|
#define LL_DEFAULTNORMLOG 6 /* for static allocation */
|
144
155
|
static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
145
156
|
|
146
|
-
static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
147
|
-
0, 0, 0, 0, 0, 0, 0, 0,
|
148
|
-
|
157
|
+
static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
|
158
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
159
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
160
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
161
|
+
1, 1, 1, 1, 2, 2, 3, 3,
|
162
|
+
4, 4, 5, 7, 8, 9,10,11,
|
149
163
|
12,13,14,15,16 };
|
150
|
-
static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
|
151
|
-
|
152
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
164
|
+
static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
|
165
|
+
2, 1, 1, 1, 1, 1, 1, 1,
|
166
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
167
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
168
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
169
|
+
1, 1, 1, 1, 1, 1,-1,-1,
|
153
170
|
-1,-1,-1,-1,-1 };
|
154
171
|
#define ML_DEFAULTNORMLOG 6 /* for static allocation */
|
155
172
|
static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
156
173
|
|
157
|
-
static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
|
158
|
-
|
174
|
+
static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
|
175
|
+
2, 1, 1, 1, 1, 1, 1, 1,
|
176
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
177
|
+
-1,-1,-1,-1,-1 };
|
159
178
|
#define OF_DEFAULTNORMLOG 5 /* for static allocation */
|
160
179
|
static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
161
180
|
|
@@ -167,7 +186,7 @@ static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
|
|
167
186
|
#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
|
168
187
|
|
169
188
|
/*! ZSTD_wildcopy() :
|
170
|
-
*
|
189
|
+
* custom version of memcpy(), can overwrite up to WILDCOPY_OVERLENGTH bytes (if length==0) */
|
171
190
|
#define WILDCOPY_OVERLENGTH 8
|
172
191
|
MEM_STATIC void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length)
|
173
192
|
{
|
@@ -191,17 +210,14 @@ MEM_STATIC void ZSTD_wildcopy_e(void* dst, const void* src, void* dstEnd) /* s
|
|
191
210
|
|
192
211
|
|
193
212
|
/*-*******************************************
|
194
|
-
* Private
|
213
|
+
* Private declarations
|
195
214
|
*********************************************/
|
196
|
-
typedef struct ZSTD_stats_s ZSTD_stats_t;
|
197
|
-
|
198
215
|
typedef struct seqDef_s {
|
199
216
|
U32 offset;
|
200
217
|
U16 litLength;
|
201
218
|
U16 matchLength;
|
202
219
|
} seqDef;
|
203
220
|
|
204
|
-
|
205
221
|
typedef struct {
|
206
222
|
seqDef* sequencesStart;
|
207
223
|
seqDef* sequences;
|
@@ -216,100 +232,8 @@ typedef struct {
|
|
216
232
|
U32 repToConfirm[ZSTD_REP_NUM];
|
217
233
|
} seqStore_t;
|
218
234
|
|
219
|
-
|
220
|
-
|
221
|
-
U32 len;
|
222
|
-
} ZSTD_match_t;
|
223
|
-
|
224
|
-
typedef struct {
|
225
|
-
U32 price;
|
226
|
-
U32 off;
|
227
|
-
U32 mlen;
|
228
|
-
U32 litlen;
|
229
|
-
U32 rep[ZSTD_REP_NUM];
|
230
|
-
} ZSTD_optimal_t;
|
231
|
-
|
232
|
-
typedef struct {
|
233
|
-
U32* litFreq;
|
234
|
-
U32* litLengthFreq;
|
235
|
-
U32* matchLengthFreq;
|
236
|
-
U32* offCodeFreq;
|
237
|
-
ZSTD_match_t* matchTable;
|
238
|
-
ZSTD_optimal_t* priceTable;
|
239
|
-
|
240
|
-
U32 matchLengthSum;
|
241
|
-
U32 matchSum;
|
242
|
-
U32 litLengthSum;
|
243
|
-
U32 litSum;
|
244
|
-
U32 offCodeSum;
|
245
|
-
U32 log2matchLengthSum;
|
246
|
-
U32 log2matchSum;
|
247
|
-
U32 log2litLengthSum;
|
248
|
-
U32 log2litSum;
|
249
|
-
U32 log2offCodeSum;
|
250
|
-
U32 factor;
|
251
|
-
U32 staticPrices;
|
252
|
-
U32 cachedPrice;
|
253
|
-
U32 cachedLitLength;
|
254
|
-
const BYTE* cachedLiterals;
|
255
|
-
} optState_t;
|
256
|
-
|
257
|
-
typedef struct {
|
258
|
-
U32 offset;
|
259
|
-
U32 checksum;
|
260
|
-
} ldmEntry_t;
|
261
|
-
|
262
|
-
typedef struct {
|
263
|
-
ldmEntry_t* hashTable;
|
264
|
-
BYTE* bucketOffsets; /* Next position in bucket to insert entry */
|
265
|
-
U64 hashPower; /* Used to compute the rolling hash.
|
266
|
-
* Depends on ldmParams.minMatchLength */
|
267
|
-
} ldmState_t;
|
268
|
-
|
269
|
-
typedef struct {
|
270
|
-
U32 enableLdm; /* 1 if enable long distance matching */
|
271
|
-
U32 hashLog; /* Log size of hashTable */
|
272
|
-
U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
|
273
|
-
U32 minMatchLength; /* Minimum match length */
|
274
|
-
U32 hashEveryLog; /* Log number of entries to skip */
|
275
|
-
} ldmParams_t;
|
276
|
-
|
277
|
-
typedef struct {
|
278
|
-
U32 hufCTable[HUF_CTABLE_SIZE_U32(255)];
|
279
|
-
FSE_CTable offcodeCTable[FSE_CTABLE_SIZE_U32(OffFSELog, MaxOff)];
|
280
|
-
FSE_CTable matchlengthCTable[FSE_CTABLE_SIZE_U32(MLFSELog, MaxML)];
|
281
|
-
FSE_CTable litlengthCTable[FSE_CTABLE_SIZE_U32(LLFSELog, MaxLL)];
|
282
|
-
U32 workspace[HUF_WORKSPACE_SIZE_U32];
|
283
|
-
HUF_repeat hufCTable_repeatMode;
|
284
|
-
FSE_repeat offcode_repeatMode;
|
285
|
-
FSE_repeat matchlength_repeatMode;
|
286
|
-
FSE_repeat litlength_repeatMode;
|
287
|
-
} ZSTD_entropyCTables_t;
|
288
|
-
|
289
|
-
struct ZSTD_CCtx_params_s {
|
290
|
-
ZSTD_format_e format;
|
291
|
-
ZSTD_compressionParameters cParams;
|
292
|
-
ZSTD_frameParameters fParams;
|
293
|
-
|
294
|
-
int compressionLevel;
|
295
|
-
U32 forceWindow; /* force back-references to respect limit of
|
296
|
-
* 1<<wLog, even for dictionary */
|
297
|
-
|
298
|
-
/* Multithreading: used to pass parameters to mtctx */
|
299
|
-
U32 nbThreads;
|
300
|
-
unsigned jobSize;
|
301
|
-
unsigned overlapSizeLog;
|
302
|
-
|
303
|
-
/* Long distance matching parameters */
|
304
|
-
ldmParams_t ldmParams;
|
305
|
-
|
306
|
-
/* For use with createCCtxParams() and freeCCtxParams() only */
|
307
|
-
ZSTD_customMem customMem;
|
308
|
-
|
309
|
-
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
|
310
|
-
|
311
|
-
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx);
|
312
|
-
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr);
|
235
|
+
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
236
|
+
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
313
237
|
|
314
238
|
/* custom memory allocation functions */
|
315
239
|
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
|
@@ -317,9 +241,7 @@ void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
|
|
317
241
|
void ZSTD_free(void* ptr, ZSTD_customMem customMem);
|
318
242
|
|
319
243
|
|
320
|
-
|
321
|
-
|
322
|
-
MEM_STATIC U32 ZSTD_highbit32(U32 val)
|
244
|
+
MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
323
245
|
{
|
324
246
|
assert(val != 0);
|
325
247
|
{
|
@@ -330,66 +252,25 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
|
|
330
252
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
|
331
253
|
return 31 - __builtin_clz(val);
|
332
254
|
# else /* Software version */
|
333
|
-
static const
|
255
|
+
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 };
|
334
256
|
U32 v = val;
|
335
|
-
int r;
|
336
257
|
v |= v >> 1;
|
337
258
|
v |= v >> 2;
|
338
259
|
v |= v >> 4;
|
339
260
|
v |= v >> 8;
|
340
261
|
v |= v >> 16;
|
341
|
-
|
342
|
-
return r;
|
262
|
+
return DeBruijnClz[(v * 0x07C4ACDDU) >> 27];
|
343
263
|
# endif
|
344
264
|
}
|
345
265
|
}
|
346
266
|
|
347
267
|
|
348
|
-
/* hidden functions */
|
349
|
-
|
350
268
|
/* ZSTD_invalidateRepCodes() :
|
351
269
|
* ensures next compression will not use repcodes from previous block.
|
352
270
|
* Note : only works with regular variant;
|
353
271
|
* do not use with extDict variant ! */
|
354
|
-
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx);
|
355
|
-
|
356
|
-
|
357
|
-
/*! ZSTD_initCStream_internal() :
|
358
|
-
* Private use only. Init streaming operation.
|
359
|
-
* expects params to be valid.
|
360
|
-
* must receive dict, or cdict, or none, but not both.
|
361
|
-
* @return : 0, or an error code */
|
362
|
-
size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
|
363
|
-
const void* dict, size_t dictSize,
|
364
|
-
const ZSTD_CDict* cdict,
|
365
|
-
ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
|
366
|
-
|
367
|
-
/*! ZSTD_compressStream_generic() :
|
368
|
-
* Private use only. To be called from zstdmt_compress.c in single-thread mode. */
|
369
|
-
size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
370
|
-
ZSTD_outBuffer* output,
|
371
|
-
ZSTD_inBuffer* input,
|
372
|
-
ZSTD_EndDirective const flushMode);
|
373
|
-
|
374
|
-
/*! ZSTD_getCParamsFromCDict() :
|
375
|
-
* as the name implies */
|
376
|
-
ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict);
|
377
|
-
|
378
|
-
/* ZSTD_compressBegin_advanced_internal() :
|
379
|
-
* Private use only. To be called from zstdmt_compress.c. */
|
380
|
-
size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,
|
381
|
-
const void* dict, size_t dictSize,
|
382
|
-
ZSTD_dictMode_e dictMode,
|
383
|
-
ZSTD_CCtx_params params,
|
384
|
-
unsigned long long pledgedSrcSize);
|
385
|
-
|
386
|
-
/* ZSTD_compress_advanced_internal() :
|
387
|
-
* Private use only. To be called from zstdmt_compress.c. */
|
388
|
-
size_t ZSTD_compress_advanced_internal(ZSTD_CCtx* cctx,
|
389
|
-
void* dst, size_t dstCapacity,
|
390
|
-
const void* src, size_t srcSize,
|
391
|
-
const void* dict,size_t dictSize,
|
392
|
-
ZSTD_CCtx_params params);
|
272
|
+
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */
|
273
|
+
|
393
274
|
|
394
275
|
typedef struct {
|
395
276
|
blockType_e blockType;
|
@@ -398,7 +279,8 @@ typedef struct {
|
|
398
279
|
} blockProperties_t;
|
399
280
|
|
400
281
|
/*! ZSTD_getcBlockSize() :
|
401
|
-
*
|
282
|
+
* Provides the size of compressed block from block header `src` */
|
283
|
+
/* Used by: decompress, fullbench (does not get its definition from here) */
|
402
284
|
size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
|
403
285
|
blockProperties_t* bpPtr);
|
404
286
|
|