extlz4 0.2.5 → 0.3.4
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/HISTORY.ja.md +16 -1
- data/README.md +49 -51
- data/Rakefile +22 -0
- data/bin/extlz4 +1 -1
- data/contrib/lz4/LICENSE +2 -1
- data/contrib/lz4/Makefile.inc +111 -0
- data/contrib/lz4/NEWS +97 -0
- data/contrib/lz4/README.md +41 -36
- data/contrib/lz4/build/README.md +55 -0
- data/contrib/lz4/build/VS2010/datagen/datagen.vcxproj +169 -0
- data/contrib/lz4/build/VS2010/frametest/frametest.vcxproj +176 -0
- data/contrib/lz4/build/VS2010/fullbench/fullbench.vcxproj +176 -0
- data/contrib/lz4/build/VS2010/fullbench-dll/fullbench-dll.vcxproj +180 -0
- data/contrib/lz4/build/VS2010/fuzzer/fuzzer.vcxproj +173 -0
- data/contrib/lz4/build/VS2010/liblz4/liblz4.vcxproj +175 -0
- data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.rc +51 -0
- data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.vcxproj +179 -0
- data/contrib/lz4/build/VS2010/lz4/lz4.rc +51 -0
- data/contrib/lz4/build/VS2010/lz4/lz4.vcxproj +189 -0
- data/contrib/lz4/build/VS2010/lz4.sln +98 -0
- data/contrib/lz4/build/VS2017/datagen/datagen.vcxproj +173 -0
- data/contrib/lz4/build/VS2017/frametest/frametest.vcxproj +180 -0
- data/contrib/lz4/build/VS2017/fullbench/fullbench.vcxproj +180 -0
- data/contrib/lz4/build/VS2017/fullbench-dll/fullbench-dll.vcxproj +184 -0
- data/contrib/lz4/build/VS2017/fuzzer/fuzzer.vcxproj +177 -0
- data/contrib/lz4/build/VS2017/liblz4/liblz4.vcxproj +179 -0
- data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.rc +51 -0
- data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.vcxproj +183 -0
- data/contrib/lz4/build/VS2017/lz4/lz4.rc +51 -0
- data/contrib/lz4/build/VS2017/lz4/lz4.vcxproj +175 -0
- data/contrib/lz4/build/VS2017/lz4.sln +103 -0
- data/contrib/lz4/build/VS2022/datagen/datagen.vcxproj +173 -0
- data/contrib/lz4/build/VS2022/frametest/frametest.vcxproj +180 -0
- data/contrib/lz4/build/VS2022/fullbench/fullbench.vcxproj +180 -0
- data/contrib/lz4/build/VS2022/fullbench-dll/fullbench-dll.vcxproj +184 -0
- data/contrib/lz4/build/VS2022/fuzzer/fuzzer.vcxproj +177 -0
- data/contrib/lz4/build/VS2022/liblz4/liblz4.vcxproj +179 -0
- data/contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.rc +51 -0
- data/contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.vcxproj +183 -0
- data/contrib/lz4/build/VS2022/lz4.sln +103 -0
- data/contrib/lz4/build/cmake/CMakeLists.txt +273 -0
- data/contrib/lz4/build/cmake/lz4Config.cmake.in +2 -0
- data/contrib/lz4/lib/LICENSE +1 -1
- data/contrib/lz4/lib/README.md +111 -15
- data/contrib/lz4/lib/liblz4-dll.rc.in +35 -0
- data/contrib/lz4/lib/liblz4.pc.in +3 -3
- data/contrib/lz4/lib/lz4.c +1891 -733
- data/contrib/lz4/lib/lz4.h +597 -234
- data/contrib/lz4/lib/lz4file.c +311 -0
- data/contrib/lz4/lib/lz4file.h +93 -0
- data/contrib/lz4/lib/lz4frame.c +896 -493
- data/contrib/lz4/lib/lz4frame.h +408 -107
- data/contrib/lz4/lib/lz4frame_static.h +5 -112
- data/contrib/lz4/lib/lz4hc.c +1039 -301
- data/contrib/lz4/lib/lz4hc.h +264 -123
- data/contrib/lz4/lib/xxhash.c +376 -240
- data/contrib/lz4/lib/xxhash.h +128 -93
- data/contrib/lz4/ossfuzz/Makefile +79 -0
- data/contrib/lz4/ossfuzz/compress_frame_fuzzer.c +48 -0
- data/contrib/lz4/ossfuzz/compress_fuzzer.c +58 -0
- data/contrib/lz4/ossfuzz/compress_hc_fuzzer.c +64 -0
- data/contrib/lz4/ossfuzz/decompress_frame_fuzzer.c +75 -0
- data/contrib/lz4/ossfuzz/decompress_fuzzer.c +78 -0
- data/contrib/lz4/ossfuzz/fuzz.h +48 -0
- data/contrib/lz4/ossfuzz/fuzz_data_producer.c +77 -0
- data/contrib/lz4/ossfuzz/fuzz_data_producer.h +36 -0
- data/contrib/lz4/ossfuzz/fuzz_helpers.h +95 -0
- data/contrib/lz4/ossfuzz/lz4_helpers.c +51 -0
- data/contrib/lz4/ossfuzz/lz4_helpers.h +13 -0
- data/contrib/lz4/ossfuzz/ossfuzz.sh +23 -0
- data/contrib/lz4/ossfuzz/round_trip_frame_fuzzer.c +43 -0
- data/contrib/lz4/ossfuzz/round_trip_frame_uncompressed_fuzzer.c +134 -0
- data/contrib/lz4/ossfuzz/round_trip_fuzzer.c +117 -0
- data/contrib/lz4/ossfuzz/round_trip_hc_fuzzer.c +44 -0
- data/contrib/lz4/ossfuzz/round_trip_stream_fuzzer.c +302 -0
- data/contrib/lz4/ossfuzz/standaloneengine.c +74 -0
- data/contrib/lz4/ossfuzz/travisoss.sh +26 -0
- data/ext/blockapi.c +13 -48
- data/ext/extlz4.c +2 -0
- data/ext/extlz4.h +17 -0
- data/ext/frameapi.c +3 -14
- data/ext/hashargs.c +9 -3
- data/ext/hashargs.h +1 -1
- data/ext/lz4_amalgam.c +0 -23
- data/gemstub.rb +5 -16
- data/lib/extlz4/oldstream.rb +1 -1
- data/lib/extlz4.rb +51 -3
- data/test/common.rb +2 -2
- metadata +84 -16
- data/contrib/lz4/circle.yml +0 -38
- data/contrib/lz4/lib/lz4opt.h +0 -356
- data/lib/extlz4/version.rb +0 -3
data/contrib/lz4/lib/lz4hc.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
LZ4 HC - High Compression Mode of LZ4
|
3
3
|
Header File
|
4
|
-
Copyright (C) 2011-
|
4
|
+
Copyright (C) 2011-2020, Yann Collet.
|
5
5
|
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
6
6
|
|
7
7
|
Redistribution and use in source and binary forms, with or without
|
@@ -54,7 +54,7 @@ extern "C" {
|
|
54
54
|
* Block Compression
|
55
55
|
**************************************/
|
56
56
|
/*! LZ4_compress_HC() :
|
57
|
-
* Compress data from `src` into `dst`, using the
|
57
|
+
* Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm.
|
58
58
|
* `dst` must be already allocated.
|
59
59
|
* Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
|
60
60
|
* Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
|
@@ -77,7 +77,21 @@ LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dst
|
|
77
77
|
* Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
|
78
78
|
*/
|
79
79
|
LZ4LIB_API int LZ4_sizeofStateHC(void);
|
80
|
-
LZ4LIB_API int LZ4_compress_HC_extStateHC(void*
|
80
|
+
LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
|
81
|
+
|
82
|
+
|
83
|
+
/*! LZ4_compress_HC_destSize() : v1.9.0+
|
84
|
+
* Will compress as much data as possible from `src`
|
85
|
+
* to fit into `targetDstSize` budget.
|
86
|
+
* Result is provided in 2 parts :
|
87
|
+
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
88
|
+
* or 0 if compression fails.
|
89
|
+
* `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
|
90
|
+
*/
|
91
|
+
LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
|
92
|
+
const char* src, char* dst,
|
93
|
+
int* srcSizePtr, int targetDstSize,
|
94
|
+
int compressionLevel);
|
81
95
|
|
82
96
|
|
83
97
|
/*-************************************
|
@@ -89,46 +103,92 @@ LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* ds
|
|
89
103
|
/*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
|
90
104
|
* These functions create and release memory for LZ4 HC streaming state.
|
91
105
|
* Newly created states are automatically initialized.
|
92
|
-
*
|
93
|
-
*
|
106
|
+
* A same state can be used multiple times consecutively,
|
107
|
+
* starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
|
94
108
|
*/
|
95
109
|
LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void);
|
96
110
|
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
|
97
111
|
|
98
|
-
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
|
99
|
-
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
|
100
|
-
|
101
|
-
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
|
102
|
-
|
103
|
-
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
|
104
|
-
|
105
112
|
/*
|
106
|
-
These functions compress data in successive blocks of any size,
|
113
|
+
These functions compress data in successive blocks of any size,
|
114
|
+
using previous blocks as dictionary, to improve compression ratio.
|
107
115
|
One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
|
108
116
|
There is an exception for ring buffers, which can be smaller than 64 KB.
|
109
|
-
Ring
|
117
|
+
Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().
|
118
|
+
|
119
|
+
Before starting compression, state must be allocated and properly initialized.
|
120
|
+
LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.
|
121
|
+
|
122
|
+
Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream)
|
123
|
+
or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental).
|
124
|
+
LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once,
|
125
|
+
which is automatically the case when state is created using LZ4_createStreamHC().
|
126
|
+
|
127
|
+
After reset, a first "fictional block" can be designated as initial dictionary,
|
128
|
+
using LZ4_loadDictHC() (Optional).
|
129
|
+
|
130
|
+
Invoke LZ4_compress_HC_continue() to compress each successive block.
|
131
|
+
The number of blocks is unlimited.
|
132
|
+
Previous input blocks, including initial dictionary when present,
|
133
|
+
must remain accessible and unmodified during compression.
|
134
|
+
|
135
|
+
It's allowed to update compression level anytime between blocks,
|
136
|
+
using LZ4_setCompressionLevel() (experimental).
|
137
|
+
|
138
|
+
'dst' buffer should be sized to handle worst case scenarios
|
139
|
+
(see LZ4_compressBound(), it ensures compression success).
|
140
|
+
In case of failure, the API does not guarantee recovery,
|
141
|
+
so the state _must_ be reset.
|
142
|
+
To ensure compression success
|
143
|
+
whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
|
144
|
+
consider using LZ4_compress_HC_continue_destSize().
|
145
|
+
|
146
|
+
Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks,
|
147
|
+
it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC().
|
148
|
+
Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)
|
149
|
+
|
150
|
+
After completing a streaming compression,
|
151
|
+
it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,
|
152
|
+
just by resetting it, using LZ4_resetStreamHC_fast().
|
153
|
+
*/
|
154
|
+
|
155
|
+
LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */
|
156
|
+
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
|
110
157
|
|
111
|
-
|
112
|
-
|
158
|
+
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
|
159
|
+
const char* src, char* dst,
|
160
|
+
int srcSize, int maxDstSize);
|
113
161
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
162
|
+
/*! LZ4_compress_HC_continue_destSize() : v1.9.0+
|
163
|
+
* Similar to LZ4_compress_HC_continue(),
|
164
|
+
* but will read as much data as possible from `src`
|
165
|
+
* to fit into `targetDstSize` budget.
|
166
|
+
* Result is provided into 2 parts :
|
167
|
+
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
168
|
+
* or 0 if compression fails.
|
169
|
+
* `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
|
170
|
+
* Note that this function may not consume the entire input.
|
171
|
+
*/
|
172
|
+
LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
|
173
|
+
const char* src, char* dst,
|
174
|
+
int* srcSizePtr, int targetDstSize);
|
175
|
+
|
176
|
+
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
|
119
177
|
|
120
|
-
If, for any reason, previous data block can't be preserved unmodified in memory for next compression block,
|
121
|
-
you can save it to a more stable memory space, using LZ4_saveDictHC().
|
122
|
-
Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'.
|
123
|
-
*/
|
124
178
|
|
125
179
|
|
126
|
-
|
180
|
+
/*^**********************************************
|
181
|
+
* !!!!!! STATIC LINKING ONLY !!!!!!
|
182
|
+
***********************************************/
|
183
|
+
|
184
|
+
/*-******************************************************************
|
127
185
|
* PRIVATE DEFINITIONS :
|
128
|
-
* Do not use these definitions.
|
129
|
-
* They are exposed to allow static allocation of `LZ4_streamHC_t`.
|
130
|
-
*
|
131
|
-
|
186
|
+
* Do not use these definitions directly.
|
187
|
+
* They are merely exposed to allow static allocation of `LZ4_streamHC_t`.
|
188
|
+
* Declare an `LZ4_streamHC_t` directly, rather than any type below.
|
189
|
+
* Even then, only do so in the context of static linking, as definitions may change between versions.
|
190
|
+
********************************************************************/
|
191
|
+
|
132
192
|
#define LZ4HC_DICTIONARY_LOGSIZE 16
|
133
193
|
#define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
|
134
194
|
#define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
|
@@ -138,55 +198,51 @@ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, in
|
|
138
198
|
#define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
|
139
199
|
|
140
200
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
typedef struct
|
145
|
-
|
146
|
-
uint32_t hashTable[LZ4HC_HASHTABLESIZE];
|
147
|
-
uint16_t chainTable[LZ4HC_MAXD];
|
148
|
-
const uint8_t* end; /* next block here to continue on current prefix */
|
149
|
-
const uint8_t* base; /* All index relative to this position */
|
150
|
-
const uint8_t* dictBase; /* alternate base for extDict */
|
151
|
-
uint8_t* inputBuffer; /* deprecated */
|
152
|
-
uint32_t dictLimit; /* below that point, need extDict */
|
153
|
-
uint32_t lowLimit; /* below that point, no more dict */
|
154
|
-
uint32_t nextToUpdate; /* index from which to continue dictionary update */
|
155
|
-
int compressionLevel;
|
156
|
-
} LZ4HC_CCtx_internal;
|
157
|
-
|
158
|
-
#else
|
159
|
-
|
160
|
-
typedef struct
|
201
|
+
/* Never ever use these definitions directly !
|
202
|
+
* Declare or allocate an LZ4_streamHC_t instead.
|
203
|
+
**/
|
204
|
+
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
|
205
|
+
struct LZ4HC_CCtx_internal
|
161
206
|
{
|
162
|
-
|
163
|
-
|
164
|
-
const
|
165
|
-
const
|
166
|
-
const
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
#define
|
207
|
+
LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
|
208
|
+
LZ4_u16 chainTable[LZ4HC_MAXD];
|
209
|
+
const LZ4_byte* end; /* next block here to continue on current prefix */
|
210
|
+
const LZ4_byte* prefixStart; /* Indexes relative to this position */
|
211
|
+
const LZ4_byte* dictStart; /* alternate reference for extDict */
|
212
|
+
LZ4_u32 dictLimit; /* below that point, need extDict */
|
213
|
+
LZ4_u32 lowLimit; /* below that point, no more dict */
|
214
|
+
LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
|
215
|
+
short compressionLevel;
|
216
|
+
LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
|
217
|
+
otherwise, favor compression ratio */
|
218
|
+
LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
|
219
|
+
const LZ4HC_CCtx_internal* dictCtx;
|
220
|
+
};
|
221
|
+
|
222
|
+
#define LZ4_STREAMHC_MINSIZE 262200 /* static size, for inter-version compatibility */
|
178
223
|
union LZ4_streamHC_u {
|
179
|
-
|
224
|
+
char minStateSize[LZ4_STREAMHC_MINSIZE];
|
180
225
|
LZ4HC_CCtx_internal internal_donotuse;
|
181
|
-
};
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
226
|
+
}; /* previously typedef'd to LZ4_streamHC_t */
|
227
|
+
|
228
|
+
/* LZ4_streamHC_t :
|
229
|
+
* This structure allows static allocation of LZ4 HC streaming state.
|
230
|
+
* This can be used to allocate statically on stack, or as part of a larger structure.
|
231
|
+
*
|
232
|
+
* Such state **must** be initialized using LZ4_initStreamHC() before first use.
|
233
|
+
*
|
234
|
+
* Note that invoking LZ4_initStreamHC() is not required when
|
235
|
+
* the state was created using LZ4_createStreamHC() (which is recommended).
|
236
|
+
* Using the normal builder, a newly created state is automatically initialized.
|
237
|
+
*
|
238
|
+
* Static allocation shall only be used in combination with static linking.
|
239
|
+
*/
|
186
240
|
|
187
|
-
|
188
|
-
|
189
|
-
|
241
|
+
/* LZ4_initStreamHC() : v1.9.0+
|
242
|
+
* Required before first use of a statically allocated LZ4_streamHC_t.
|
243
|
+
* Before v1.9.0 : use LZ4_resetStreamHC() instead
|
244
|
+
*/
|
245
|
+
LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC(void* buffer, size_t size);
|
190
246
|
|
191
247
|
|
192
248
|
/*-************************************
|
@@ -195,25 +251,45 @@ union LZ4_streamHC_u {
|
|
195
251
|
/* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
|
196
252
|
|
197
253
|
/* deprecated compression functions */
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
/*
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
254
|
+
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize);
|
255
|
+
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
256
|
+
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
|
257
|
+
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
258
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
|
259
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
260
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
|
261
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
262
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
|
263
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
264
|
+
|
265
|
+
/* Obsolete streaming functions; degraded functionality; do not use!
|
266
|
+
*
|
267
|
+
* In order to perform streaming compression, these functions depended on data
|
268
|
+
* that is no longer tracked in the state. They have been preserved as well as
|
269
|
+
* possible: using them will still produce a correct output. However, use of
|
270
|
+
* LZ4_slideInputBufferHC() will truncate the history of the stream, rather
|
271
|
+
* than preserve a window-sized chunk of history.
|
272
|
+
*/
|
273
|
+
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
274
|
+
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer);
|
275
|
+
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data);
|
276
|
+
#endif
|
277
|
+
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
278
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
279
|
+
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
280
|
+
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
|
281
|
+
LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
|
282
|
+
|
283
|
+
|
284
|
+
/* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
|
285
|
+
* The intention is to emphasize the difference with LZ4_resetStreamHC_fast(),
|
286
|
+
* which is now the recommended function to start a new stream of blocks,
|
287
|
+
* but cannot be used to initialize a memory segment containing arbitrary garbage data.
|
288
|
+
*
|
289
|
+
* It is recommended to switch to LZ4_initStreamHC().
|
290
|
+
* LZ4_resetStreamHC() will generate deprecation warnings in a future version.
|
291
|
+
*/
|
292
|
+
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
|
217
293
|
|
218
294
|
|
219
295
|
#if defined (__cplusplus)
|
@@ -229,44 +305,109 @@ LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStr
|
|
229
305
|
* They should not be linked from DLL,
|
230
306
|
* as there is no guarantee of API stability yet.
|
231
307
|
* Prototypes will be promoted to "stable" status
|
232
|
-
* after
|
308
|
+
* after successful usage in real-life scenarios.
|
233
309
|
***************************************************/
|
234
310
|
#ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
|
235
311
|
#ifndef LZ4_HC_SLO_098092834
|
236
312
|
#define LZ4_HC_SLO_098092834
|
237
313
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
* `srcSizePtr` : value will be updated to indicate how much bytes were read from `src`
|
245
|
-
*/
|
246
|
-
int LZ4_compress_HC_destSize(void* LZ4HC_Data,
|
247
|
-
const char* src, char* dst,
|
248
|
-
int* srcSizePtr, int targetDstSize,
|
249
|
-
int compressionLevel);
|
250
|
-
|
251
|
-
/*! LZ4_compress_HC_continue_destSize() : v1.8.0 (experimental)
|
252
|
-
* Similar as LZ4_compress_HC_continue(),
|
253
|
-
* but will read a variable nb of bytes from `src`
|
254
|
-
* to fit into `targetDstSize` budget.
|
255
|
-
* Result is provided in 2 parts :
|
256
|
-
* @return : the number of bytes written into 'dst'
|
257
|
-
* or 0 if compression fails.
|
258
|
-
* `srcSizePtr` : value will be updated to indicate how much bytes were read from `src`.
|
259
|
-
*/
|
260
|
-
int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
|
261
|
-
const char* src, char* dst,
|
262
|
-
int* srcSizePtr, int targetDstSize);
|
314
|
+
#define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */
|
315
|
+
#include "lz4.h"
|
316
|
+
|
317
|
+
#if defined (__cplusplus)
|
318
|
+
extern "C" {
|
319
|
+
#endif
|
263
320
|
|
264
|
-
/*! LZ4_setCompressionLevel() : v1.8.0 (experimental)
|
265
|
-
* It's possible to change compression level
|
321
|
+
/*! LZ4_setCompressionLevel() : v1.8.0+ (experimental)
|
322
|
+
* It's possible to change compression level
|
323
|
+
* between successive invocations of LZ4_compress_HC_continue*()
|
324
|
+
* for dynamic adaptation.
|
266
325
|
*/
|
267
|
-
void LZ4_setCompressionLevel(
|
326
|
+
LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
|
327
|
+
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
268
328
|
|
329
|
+
/*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
|
330
|
+
* Opt. Parser will favor decompression speed over compression ratio.
|
331
|
+
* Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
|
332
|
+
*/
|
333
|
+
LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
|
334
|
+
LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
|
335
|
+
|
336
|
+
/*! LZ4_resetStreamHC_fast() : v1.9.0+
|
337
|
+
* When an LZ4_streamHC_t is known to be in a internally coherent state,
|
338
|
+
* it can often be prepared for a new compression with almost no work, only
|
339
|
+
* sometimes falling back to the full, expensive reset that is always required
|
340
|
+
* when the stream is in an indeterminate state (i.e., the reset performed by
|
341
|
+
* LZ4_resetStreamHC()).
|
342
|
+
*
|
343
|
+
* LZ4_streamHCs are guaranteed to be in a valid state when:
|
344
|
+
* - returned from LZ4_createStreamHC()
|
345
|
+
* - reset by LZ4_resetStreamHC()
|
346
|
+
* - memset(stream, 0, sizeof(LZ4_streamHC_t))
|
347
|
+
* - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast()
|
348
|
+
* - the stream was in a valid state and was then used in any compression call
|
349
|
+
* that returned success
|
350
|
+
* - the stream was in an indeterminate state and was used in a compression
|
351
|
+
* call that fully reset the state (LZ4_compress_HC_extStateHC()) and that
|
352
|
+
* returned success
|
353
|
+
*
|
354
|
+
* Note:
|
355
|
+
* A stream that was last used in a compression call that returned an error
|
356
|
+
* may be passed to this function. However, it will be fully reset, which will
|
357
|
+
* clear any existing history and settings from the context.
|
358
|
+
*/
|
359
|
+
LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
|
360
|
+
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
361
|
+
|
362
|
+
/*! LZ4_compress_HC_extStateHC_fastReset() :
|
363
|
+
* A variant of LZ4_compress_HC_extStateHC().
|
364
|
+
*
|
365
|
+
* Using this variant avoids an expensive initialization step. It is only safe
|
366
|
+
* to call if the state buffer is known to be correctly initialized already
|
367
|
+
* (see above comment on LZ4_resetStreamHC_fast() for a definition of
|
368
|
+
* "correctly initialized"). From a high level, the difference is that this
|
369
|
+
* function initializes the provided state with a call to
|
370
|
+
* LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
|
371
|
+
* call to LZ4_resetStreamHC().
|
372
|
+
*/
|
373
|
+
LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
|
374
|
+
void* state,
|
375
|
+
const char* src, char* dst,
|
376
|
+
int srcSize, int dstCapacity,
|
377
|
+
int compressionLevel);
|
378
|
+
|
379
|
+
/*! LZ4_attach_HC_dictionary() :
|
380
|
+
* This is an experimental API that allows for the efficient use of a
|
381
|
+
* static dictionary many times.
|
382
|
+
*
|
383
|
+
* Rather than re-loading the dictionary buffer into a working context before
|
384
|
+
* each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
|
385
|
+
* working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
|
386
|
+
* in which the working stream references the dictionary stream in-place.
|
387
|
+
*
|
388
|
+
* Several assumptions are made about the state of the dictionary stream.
|
389
|
+
* Currently, only streams which have been prepared by LZ4_loadDictHC() should
|
390
|
+
* be expected to work.
|
391
|
+
*
|
392
|
+
* Alternatively, the provided dictionary stream pointer may be NULL, in which
|
393
|
+
* case any existing dictionary stream is unset.
|
394
|
+
*
|
395
|
+
* A dictionary should only be attached to a stream without any history (i.e.,
|
396
|
+
* a stream that has just been reset).
|
397
|
+
*
|
398
|
+
* The dictionary will remain attached to the working stream only for the
|
399
|
+
* current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
|
400
|
+
* dictionary context association from the working stream. The dictionary
|
401
|
+
* stream (and source buffer) must remain in-place / accessible / unchanged
|
402
|
+
* through the lifetime of the stream session.
|
403
|
+
*/
|
404
|
+
LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
|
405
|
+
LZ4_streamHC_t *working_stream,
|
406
|
+
const LZ4_streamHC_t *dictionary_stream);
|
269
407
|
|
408
|
+
#if defined (__cplusplus)
|
409
|
+
}
|
410
|
+
#endif
|
270
411
|
|
271
412
|
#endif /* LZ4_HC_SLO_098092834 */
|
272
413
|
#endif /* LZ4_HC_STATIC_LINKING_ONLY */
|