zstd-ruby 1.5.2.0 → 1.5.2.1
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/.gitignore +2 -0
- data/README.md +55 -2
- data/Rakefile +8 -2
- data/ext/zstdruby/{zstdruby.h → common.h} +2 -0
- data/ext/zstdruby/main.c +14 -0
- data/ext/zstdruby/streaming_compress.c +185 -0
- data/ext/zstdruby/streaming_compress.h +5 -0
- data/ext/zstdruby/streaming_decompress.c +125 -0
- data/ext/zstdruby/zstdruby.c +4 -6
- data/lib/zstd-ruby/version.rb +1 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +7 -36
- data/.github/dependabot.yml +0 -8
- data/.github/workflows/ruby.yml +0 -35
- data/ext/zstdruby/libzstd/.gitignore +0 -3
- data/ext/zstdruby/libzstd/BUCK +0 -232
- data/ext/zstdruby/libzstd/Makefile +0 -357
- data/ext/zstdruby/libzstd/README.md +0 -217
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -167
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
- data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
- data/ext/zstdruby/libzstd/dll/example/README.md +0 -63
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
- data/ext/zstdruby/libzstd/libzstd.mk +0 -203
- data/ext/zstdruby/libzstd/libzstd.pc.in +0 -16
- data/ext/zstdruby/libzstd/module.modulemap +0 -25
@@ -1,217 +0,0 @@
|
|
1
|
-
Zstandard library files
|
2
|
-
================================
|
3
|
-
|
4
|
-
The __lib__ directory is split into several sub-directories,
|
5
|
-
in order to make it easier to select or exclude features.
|
6
|
-
|
7
|
-
|
8
|
-
#### Building
|
9
|
-
|
10
|
-
`Makefile` script is provided, supporting [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
|
11
|
-
including commands variables, staged install, directory variables and standard targets.
|
12
|
-
- `make` : generates both static and dynamic libraries
|
13
|
-
- `make install` : install libraries and headers in target system directories
|
14
|
-
|
15
|
-
`libzstd` default scope is pretty large, including compression, decompression, dictionary builder,
|
16
|
-
and support for decoding legacy formats >= v0.5.0.
|
17
|
-
The scope can be reduced on demand (see paragraph _modular build_).
|
18
|
-
|
19
|
-
|
20
|
-
#### Multithreading support
|
21
|
-
|
22
|
-
When building with `make`, by default the dynamic library is multithreaded and static library is single-threaded (for compatibility reasons).
|
23
|
-
|
24
|
-
Enabling multithreading requires 2 conditions :
|
25
|
-
- set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
|
26
|
-
- for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
|
27
|
-
|
28
|
-
For convenience, we provide a build target to generate multi and single threaded libraries:
|
29
|
-
- Force enable multithreading on both dynamic and static libraries by appending `-mt` to the target, e.g. `make lib-mt`.
|
30
|
-
- Force disable multithreading on both dynamic and static libraries by appending `-nomt` to the target, e.g. `make lib-nomt`.
|
31
|
-
- By default, as mentioned before, dynamic library is multithreaded, and static library is single-threaded, e.g. `make lib`.
|
32
|
-
|
33
|
-
When linking a POSIX program with a multithreaded version of `libzstd`,
|
34
|
-
note that it's necessary to invoke the `-pthread` flag during link stage.
|
35
|
-
|
36
|
-
Multithreading capabilities are exposed
|
37
|
-
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
38
|
-
|
39
|
-
|
40
|
-
#### API
|
41
|
-
|
42
|
-
Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
|
43
|
-
|
44
|
-
|
45
|
-
#### Advanced API
|
46
|
-
|
47
|
-
Optional advanced features are exposed via :
|
48
|
-
|
49
|
-
- `lib/zstd_errors.h` : translates `size_t` function results
|
50
|
-
into a `ZSTD_ErrorCode`, for accurate error handling.
|
51
|
-
|
52
|
-
- `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
|
53
|
-
it unlocks access to the experimental API,
|
54
|
-
exposed in the second part of `zstd.h`.
|
55
|
-
All definitions in the experimental APIs are unstable,
|
56
|
-
they may still change in the future, or even be removed.
|
57
|
-
As a consequence, experimental definitions shall ___never be used with dynamic library___ !
|
58
|
-
Only static linking is allowed.
|
59
|
-
|
60
|
-
|
61
|
-
#### Modular build
|
62
|
-
|
63
|
-
It's possible to compile only a limited set of features within `libzstd`.
|
64
|
-
The file structure is designed to make this selection manually achievable for any build system :
|
65
|
-
|
66
|
-
- Directory `lib/common` is always required, for all variants.
|
67
|
-
|
68
|
-
- Compression source code lies in `lib/compress`
|
69
|
-
|
70
|
-
- Decompression source code lies in `lib/decompress`
|
71
|
-
|
72
|
-
- It's possible to include only `compress` or only `decompress`, they don't depend on each other.
|
73
|
-
|
74
|
-
- `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
|
75
|
-
The API is exposed in `lib/dictBuilder/zdict.h`.
|
76
|
-
This module depends on both `lib/common` and `lib/compress` .
|
77
|
-
|
78
|
-
- `lib/legacy` : makes it possible to decompress legacy zstd formats, starting from `v0.1.0`.
|
79
|
-
This module depends on `lib/common` and `lib/decompress`.
|
80
|
-
To enable this feature, define `ZSTD_LEGACY_SUPPORT` during compilation.
|
81
|
-
Specifying a number limits versions supported to that version onward.
|
82
|
-
For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
|
83
|
-
Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
|
84
|
-
By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`.
|
85
|
-
Decoding supported legacy format is a transparent capability triggered within decompression functions.
|
86
|
-
It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`.
|
87
|
-
Each version does also provide its own set of advanced API.
|
88
|
-
For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
|
89
|
-
|
90
|
-
- While invoking `make libzstd`, it's possible to define build macros
|
91
|
-
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
|
92
|
-
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
93
|
-
corresponding features. This will also disable compilation of all
|
94
|
-
dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
|
95
|
-
dictBuilder).
|
96
|
-
|
97
|
-
- There are a number of options that can help minimize the binary size of
|
98
|
-
`libzstd`.
|
99
|
-
|
100
|
-
The first step is to select the components needed (using the above-described
|
101
|
-
`ZSTD_LIB_COMPRESSION` etc.).
|
102
|
-
|
103
|
-
The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
|
104
|
-
disables various optional components and changes the compilation flags to
|
105
|
-
prioritize space-saving.
|
106
|
-
|
107
|
-
Detailed options: Zstandard's code and build environment is set up by default
|
108
|
-
to optimize above all else for performance. In pursuit of this goal, Zstandard
|
109
|
-
makes significant trade-offs in code size. For example, Zstandard often has
|
110
|
-
more than one implementation of a particular component, with each
|
111
|
-
implementation optimized for different scenarios. For example, the Huffman
|
112
|
-
decoder has complementary implementations that decode the stream one symbol at
|
113
|
-
a time or two symbols at a time. Zstd normally includes both (and dispatches
|
114
|
-
between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
|
115
|
-
`HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
|
116
|
-
compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
|
117
|
-
and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
|
118
|
-
only one or the other of two decompression implementations. The smallest
|
119
|
-
binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
|
120
|
-
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
|
121
|
-
|
122
|
-
For squeezing the last ounce of size out, you can also define
|
123
|
-
`ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
|
124
|
-
which removes the error messages that are otherwise returned by
|
125
|
-
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
126
|
-
|
127
|
-
Finally, when integrating into your application, make sure you're doing link-
|
128
|
-
time optimization and unused symbol garbage collection (via some combination of,
|
129
|
-
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
130
|
-
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
131
|
-
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
132
|
-
the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
|
133
|
-
compiler's documentation.
|
134
|
-
|
135
|
-
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
|
136
|
-
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
137
|
-
the shared library, which is now hidden by default.
|
138
|
-
|
139
|
-
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
140
|
-
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
141
|
-
These instructions contribute to better performance, notably on the decoder side.
|
142
|
-
By default, this feature is automatically enabled on detecting
|
143
|
-
the right instruction set (x64) and compiler (clang or gcc >= 5).
|
144
|
-
It's obviously disabled for different cpus,
|
145
|
-
or when BMI2 instruction set is _required_ by the compiler command line
|
146
|
-
(in this case, only the BMI2 code path is generated).
|
147
|
-
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
148
|
-
or prevent it (0). It overrides automatic detection.
|
149
|
-
|
150
|
-
- The build macro `ZSTD_NO_UNUSED_FUNCTIONS` can be defined to hide the definitions of functions
|
151
|
-
that zstd does not use. Not all unused functions are hidden, but they can be if needed.
|
152
|
-
Currently, this macro will hide function definitions in FSE and HUF that use an excessive
|
153
|
-
amount of stack space.
|
154
|
-
|
155
|
-
- The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics.
|
156
|
-
Compiler builtins are still used.
|
157
|
-
|
158
|
-
- The build macro `ZSTD_DECODER_INTERNAL_BUFFER` can be set to control
|
159
|
-
the amount of extra memory used during decompression to store literals.
|
160
|
-
This defaults to 64kB. Reducing this value reduces the memory footprint of
|
161
|
-
`ZSTD_DCtx` decompression contexts,
|
162
|
-
but might also result in a small decompression speed cost.
|
163
|
-
|
164
|
-
|
165
|
-
#### Windows : using MinGW+MSYS to create DLL
|
166
|
-
|
167
|
-
DLL can be created using MinGW+MSYS with the `make libzstd` command.
|
168
|
-
This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
|
169
|
-
The import library is only required with Visual C++.
|
170
|
-
The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
|
171
|
-
compile a project using gcc/MinGW.
|
172
|
-
The dynamic library has to be added to linking options.
|
173
|
-
It means that if a project that uses ZSTD consists of a single `test-dll.c`
|
174
|
-
file it should be linked with `dll\libzstd.dll`. For example:
|
175
|
-
```
|
176
|
-
gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
|
177
|
-
```
|
178
|
-
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
179
|
-
|
180
|
-
|
181
|
-
#### Advanced Build options
|
182
|
-
|
183
|
-
The build system requires a hash function in order to
|
184
|
-
separate object files created with different compilation flags.
|
185
|
-
By default, it tries to use `md5sum` or equivalent.
|
186
|
-
The hash function can be manually switched by setting the `HASH` variable.
|
187
|
-
For example : `make HASH=xxhsum`
|
188
|
-
The hash function needs to generate at least 64-bit using hexadecimal format.
|
189
|
-
When no hash function is found,
|
190
|
-
the Makefile just generates all object files into the same default directory,
|
191
|
-
irrespective of compilation flags.
|
192
|
-
This functionality only matters if `libzstd` is compiled multiple times
|
193
|
-
with different build flags.
|
194
|
-
|
195
|
-
The build directory, where object files are stored
|
196
|
-
can also be manually controlled using variable `BUILD_DIR`,
|
197
|
-
for example `make BUILD_DIR=objectDir/v1`.
|
198
|
-
In which case, the hash function doesn't matter.
|
199
|
-
|
200
|
-
|
201
|
-
#### Deprecated API
|
202
|
-
|
203
|
-
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
204
|
-
At this stage, it contains older streaming prototypes, in `lib/deprecated/zbuff.h`.
|
205
|
-
These prototypes will be removed in some future version.
|
206
|
-
Consider migrating code towards supported streaming API exposed in `zstd.h`.
|
207
|
-
|
208
|
-
|
209
|
-
#### Miscellaneous
|
210
|
-
|
211
|
-
The other files are not source code. There are :
|
212
|
-
|
213
|
-
- `BUCK` : support for `buck` build system (https://buckbuild.com/)
|
214
|
-
- `Makefile` : `make` script to build and install zstd library (static and dynamic)
|
215
|
-
- `README.md` : this file
|
216
|
-
- `dll/` : resources directory for Windows compilation
|
217
|
-
- `libzstd.pc.in` : script for `pkg-config` (used in `make install`)
|
@@ -1,214 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 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
|
-
* NOTES/WARNINGS
|
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
|
-
*****************************************************************/
|
18
|
-
|
19
|
-
|
20
|
-
#if defined (__cplusplus)
|
21
|
-
extern "C" {
|
22
|
-
#endif
|
23
|
-
|
24
|
-
#ifndef ZSTD_BUFFERED_H_23987
|
25
|
-
#define ZSTD_BUFFERED_H_23987
|
26
|
-
|
27
|
-
/* *************************************
|
28
|
-
* Dependencies
|
29
|
-
***************************************/
|
30
|
-
#include <stddef.h> /* size_t */
|
31
|
-
#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
|
32
|
-
|
33
|
-
|
34
|
-
/* ***************************************************************
|
35
|
-
* Compiler specifics
|
36
|
-
*****************************************************************/
|
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 */
|
46
|
-
#else
|
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 */
|
60
|
-
|
61
|
-
|
62
|
-
/* *************************************
|
63
|
-
* Streaming functions
|
64
|
-
***************************************/
|
65
|
-
/* This is the easier "buffered" streaming API,
|
66
|
-
* using an internal buffer to lift all restrictions on user-provided buffers
|
67
|
-
* which can be any size, any place, for both input and output.
|
68
|
-
* ZBUFF and ZSTD are 100% interoperable,
|
69
|
-
* frames created by one can be decoded by the other one */
|
70
|
-
|
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);
|
74
|
-
|
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);
|
77
|
-
|
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);
|
81
|
-
|
82
|
-
/*-*************************************************
|
83
|
-
* Streaming compression - howto
|
84
|
-
*
|
85
|
-
* A ZBUFF_CCtx object is required to track streaming operation.
|
86
|
-
* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
|
87
|
-
* ZBUFF_CCtx objects can be reused multiple times.
|
88
|
-
*
|
89
|
-
* Start by initializing ZBUF_CCtx.
|
90
|
-
* Use ZBUFF_compressInit() to start a new compression operation.
|
91
|
-
* Use ZBUFF_compressInitDictionary() for a compression which requires a dictionary.
|
92
|
-
*
|
93
|
-
* Use ZBUFF_compressContinue() repetitively to consume input stream.
|
94
|
-
* *srcSizePtr and *dstCapacityPtr can be any size.
|
95
|
-
* The function will report how many bytes were read or written within *srcSizePtr and *dstCapacityPtr.
|
96
|
-
* Note that it may not consume the entire input, in which case it's up to the caller to present again remaining data.
|
97
|
-
* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each call, so save its content if it matters or change @dst .
|
98
|
-
* @return : a hint to preferred nb of bytes to use as input for next function call (it's just a hint, to improve latency)
|
99
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
100
|
-
*
|
101
|
-
* At any moment, it's possible to flush whatever data remains within buffer, using ZBUFF_compressFlush().
|
102
|
-
* The nb of bytes written into `dst` will be reported into *dstCapacityPtr.
|
103
|
-
* Note that the function cannot output more than *dstCapacityPtr,
|
104
|
-
* therefore, some content might still be left into internal buffer if *dstCapacityPtr is too small.
|
105
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
106
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
107
|
-
*
|
108
|
-
* ZBUFF_compressEnd() instructs to finish a frame.
|
109
|
-
* It will perform a flush and write frame epilogue.
|
110
|
-
* The epilogue is required for decoders to consider a frame completed.
|
111
|
-
* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
|
112
|
-
* In which case, call again ZBUFF_compressFlush() to complete the flush.
|
113
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
114
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
115
|
-
*
|
116
|
-
* Hint : _recommended buffer_ sizes (not compulsory) : ZBUFF_recommendedCInSize() / ZBUFF_recommendedCOutSize()
|
117
|
-
* input : ZBUFF_recommendedCInSize==128 KB block size is the internal unit, use this value to reduce intermediate stages (better latency)
|
118
|
-
* output : ZBUFF_recommendedCOutSize==ZSTD_compressBound(128 KB) + 3 + 3 : ensures it's always possible to write/flush/end a full block. Skip some buffering.
|
119
|
-
* By using both, it ensures that input will be entirely consumed, and output will always contain the result, reducing intermediate buffering.
|
120
|
-
* **************************************************/
|
121
|
-
|
122
|
-
|
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);
|
126
|
-
|
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);
|
129
|
-
|
130
|
-
ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
|
131
|
-
void* dst, size_t* dstCapacityPtr,
|
132
|
-
const void* src, size_t* srcSizePtr);
|
133
|
-
|
134
|
-
/*-***************************************************************************
|
135
|
-
* Streaming decompression howto
|
136
|
-
*
|
137
|
-
* A ZBUFF_DCtx object is required to track streaming operations.
|
138
|
-
* Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
|
139
|
-
* Use ZBUFF_decompressInit() to start a new decompression operation,
|
140
|
-
* or ZBUFF_decompressInitDictionary() if decompression requires a dictionary.
|
141
|
-
* Note that ZBUFF_DCtx objects can be re-init multiple times.
|
142
|
-
*
|
143
|
-
* Use ZBUFF_decompressContinue() repetitively to consume your input.
|
144
|
-
* *srcSizePtr and *dstCapacityPtr can be any size.
|
145
|
-
* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
|
146
|
-
* Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
|
147
|
-
* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
|
148
|
-
* @return : 0 when a frame is completely decoded and fully flushed,
|
149
|
-
* 1 when there is still some data left within internal buffer to flush,
|
150
|
-
* >1 when more data is expected, with value being a suggested next input size (it's just a hint, which helps latency),
|
151
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
152
|
-
*
|
153
|
-
* Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize() and ZBUFF_recommendedDOutSize()
|
154
|
-
* output : ZBUFF_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
|
155
|
-
* input : ZBUFF_recommendedDInSize == 128KB + 3;
|
156
|
-
* just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
|
157
|
-
* *******************************************************************************/
|
158
|
-
|
159
|
-
|
160
|
-
/* *************************************
|
161
|
-
* Tool functions
|
162
|
-
***************************************/
|
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);
|
165
|
-
|
166
|
-
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
167
|
-
* These sizes are just hints, they tend to offer better latency */
|
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 */
|
174
|
-
|
175
|
-
|
176
|
-
#ifdef ZBUFF_STATIC_LINKING_ONLY
|
177
|
-
#ifndef ZBUFF_STATIC_H_30298098432
|
178
|
-
#define ZBUFF_STATIC_H_30298098432
|
179
|
-
|
180
|
-
/* ====================================================================================
|
181
|
-
* The definitions in this section are considered experimental.
|
182
|
-
* They should never be used in association with a dynamic library, as they may change in the future.
|
183
|
-
* They are provided for advanced usages.
|
184
|
-
* Use them only in association with static linking.
|
185
|
-
* ==================================================================================== */
|
186
|
-
|
187
|
-
/*--- Dependency ---*/
|
188
|
-
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
|
189
|
-
#include "../zstd.h"
|
190
|
-
|
191
|
-
|
192
|
-
/*--- Custom memory allocator ---*/
|
193
|
-
/*! ZBUFF_createCCtx_advanced() :
|
194
|
-
* Create a ZBUFF compression context using external alloc and free functions */
|
195
|
-
ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
|
196
|
-
|
197
|
-
/*! ZBUFF_createDCtx_advanced() :
|
198
|
-
* Create a ZBUFF decompression context using external alloc and free functions */
|
199
|
-
ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
|
200
|
-
|
201
|
-
|
202
|
-
/*--- Advanced Streaming Initialization ---*/
|
203
|
-
ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
|
204
|
-
const void* dict, size_t dictSize,
|
205
|
-
ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
206
|
-
|
207
|
-
|
208
|
-
#endif /* ZBUFF_STATIC_H_30298098432 */
|
209
|
-
#endif /* ZBUFF_STATIC_LINKING_ONLY */
|
210
|
-
|
211
|
-
|
212
|
-
#if defined (__cplusplus)
|
213
|
-
}
|
214
|
-
#endif
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 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); }
|
@@ -1,167 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 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
|
-
|
13
|
-
/* *************************************
|
14
|
-
* Dependencies
|
15
|
-
***************************************/
|
16
|
-
#define ZBUFF_STATIC_LINKING_ONLY
|
17
|
-
#include "zbuff.h"
|
18
|
-
#include "../common/error_private.h"
|
19
|
-
|
20
|
-
|
21
|
-
/*-***********************************************************
|
22
|
-
* Streaming compression
|
23
|
-
*
|
24
|
-
* A ZBUFF_CCtx object is required to track streaming operation.
|
25
|
-
* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
|
26
|
-
* Use ZBUFF_compressInit() to start a new compression operation.
|
27
|
-
* ZBUFF_CCtx objects can be reused multiple times.
|
28
|
-
*
|
29
|
-
* Use ZBUFF_compressContinue() repetitively to consume your input.
|
30
|
-
* *srcSizePtr and *dstCapacityPtr can be any size.
|
31
|
-
* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
|
32
|
-
* Note that it may not consume the entire input, in which case it's up to the caller to call again the function with remaining input.
|
33
|
-
* The content of dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change dst .
|
34
|
-
* @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
|
35
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
36
|
-
*
|
37
|
-
* ZBUFF_compressFlush() can be used to instruct ZBUFF to compress and output whatever remains within its buffer.
|
38
|
-
* Note that it will not output more than *dstCapacityPtr.
|
39
|
-
* Therefore, some content might still be left into its internal buffer if dst buffer is too small.
|
40
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
41
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
42
|
-
*
|
43
|
-
* ZBUFF_compressEnd() instructs to finish a frame.
|
44
|
-
* It will perform a flush and write frame epilogue.
|
45
|
-
* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
|
46
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
47
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
48
|
-
*
|
49
|
-
* Hint : recommended buffer sizes (not compulsory)
|
50
|
-
* input : ZSTD_BLOCKSIZE_MAX (128 KB), internal unit size, it improves latency to use this value.
|
51
|
-
* output : ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + ZBUFF_endFrameSize : ensures it's always possible to write/flush/end a full block at best speed.
|
52
|
-
* ***********************************************************/
|
53
|
-
|
54
|
-
ZBUFF_CCtx* ZBUFF_createCCtx(void)
|
55
|
-
{
|
56
|
-
return ZSTD_createCStream();
|
57
|
-
}
|
58
|
-
|
59
|
-
ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
|
60
|
-
{
|
61
|
-
return ZSTD_createCStream_advanced(customMem);
|
62
|
-
}
|
63
|
-
|
64
|
-
size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
|
65
|
-
{
|
66
|
-
return ZSTD_freeCStream(zbc);
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
/* ====== Initialization ====== */
|
71
|
-
|
72
|
-
size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
|
73
|
-
const void* dict, size_t dictSize,
|
74
|
-
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
75
|
-
{
|
76
|
-
if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* preserve "0 == unknown" behavior */
|
77
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
|
78
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setPledgedSrcSize(zbc, pledgedSrcSize), "");
|
79
|
-
|
80
|
-
FORWARD_IF_ERROR(ZSTD_checkCParams(params.cParams), "");
|
81
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_windowLog, params.cParams.windowLog), "");
|
82
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_hashLog, params.cParams.hashLog), "");
|
83
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_chainLog, params.cParams.chainLog), "");
|
84
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_searchLog, params.cParams.searchLog), "");
|
85
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_minMatch, params.cParams.minMatch), "");
|
86
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_targetLength, params.cParams.targetLength), "");
|
87
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_strategy, params.cParams.strategy), "");
|
88
|
-
|
89
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_contentSizeFlag, params.fParams.contentSizeFlag), "");
|
90
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_checksumFlag, params.fParams.checksumFlag), "");
|
91
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_dictIDFlag, params.fParams.noDictIDFlag), "");
|
92
|
-
|
93
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
|
94
|
-
return 0;
|
95
|
-
}
|
96
|
-
|
97
|
-
size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
|
98
|
-
{
|
99
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
|
100
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_compressionLevel, compressionLevel), "");
|
101
|
-
FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
|
102
|
-
return 0;
|
103
|
-
}
|
104
|
-
|
105
|
-
size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)
|
106
|
-
{
|
107
|
-
return ZSTD_initCStream(zbc, compressionLevel);
|
108
|
-
}
|
109
|
-
|
110
|
-
/* ====== Compression ====== */
|
111
|
-
|
112
|
-
|
113
|
-
size_t ZBUFF_compressContinue(ZBUFF_CCtx* zbc,
|
114
|
-
void* dst, size_t* dstCapacityPtr,
|
115
|
-
const void* src, size_t* srcSizePtr)
|
116
|
-
{
|
117
|
-
size_t result;
|
118
|
-
ZSTD_outBuffer outBuff;
|
119
|
-
ZSTD_inBuffer inBuff;
|
120
|
-
outBuff.dst = dst;
|
121
|
-
outBuff.pos = 0;
|
122
|
-
outBuff.size = *dstCapacityPtr;
|
123
|
-
inBuff.src = src;
|
124
|
-
inBuff.pos = 0;
|
125
|
-
inBuff.size = *srcSizePtr;
|
126
|
-
result = ZSTD_compressStream(zbc, &outBuff, &inBuff);
|
127
|
-
*dstCapacityPtr = outBuff.pos;
|
128
|
-
*srcSizePtr = inBuff.pos;
|
129
|
-
return result;
|
130
|
-
}
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
/* ====== Finalize ====== */
|
135
|
-
|
136
|
-
size_t ZBUFF_compressFlush(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
|
137
|
-
{
|
138
|
-
size_t result;
|
139
|
-
ZSTD_outBuffer outBuff;
|
140
|
-
outBuff.dst = dst;
|
141
|
-
outBuff.pos = 0;
|
142
|
-
outBuff.size = *dstCapacityPtr;
|
143
|
-
result = ZSTD_flushStream(zbc, &outBuff);
|
144
|
-
*dstCapacityPtr = outBuff.pos;
|
145
|
-
return result;
|
146
|
-
}
|
147
|
-
|
148
|
-
|
149
|
-
size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
|
150
|
-
{
|
151
|
-
size_t result;
|
152
|
-
ZSTD_outBuffer outBuff;
|
153
|
-
outBuff.dst = dst;
|
154
|
-
outBuff.pos = 0;
|
155
|
-
outBuff.size = *dstCapacityPtr;
|
156
|
-
result = ZSTD_endStream(zbc, &outBuff);
|
157
|
-
*dstCapacityPtr = outBuff.pos;
|
158
|
-
return result;
|
159
|
-
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
/* *************************************
|
164
|
-
* Tool functions
|
165
|
-
***************************************/
|
166
|
-
size_t ZBUFF_recommendedCInSize(void) { return ZSTD_CStreamInSize(); }
|
167
|
-
size_t ZBUFF_recommendedCOutSize(void) { return ZSTD_CStreamOutSize(); }
|