GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
lz4.h
Go to the documentation of this file.
1/*
2 * LZ4 - Fast LZ compression algorithm
3 * Header File
4 * Copyright (C) 2011-2017, Yann Collet.
5
6 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11
12 * Redistributions of source code must retain the above copyright
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 - LZ4 homepage : http://www.lz4.org
33 - LZ4 source repository : https://github.com/lz4/lz4
34 */
35#if defined(__cplusplus)
36extern "C" {
37#endif
38
39#ifndef LZ4_H_2983827168210
40#define LZ4_H_2983827168210
41
42/* --- Dependency --- */
43#include <stddef.h> /* size_t */
44
45/**
46 Introduction
47
48 LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s
49 per core, scalable with multi-cores CPU. It features an extremely fast
50 decoder, with speed in multiple GB/s per core, typically reaching RAM speed
51 limits on multi-core systems.
52
53 The LZ4 compression library provides in-memory compression and decompression
54 functions. Compression can be done in:
55 - a single step (described as Simple Functions)
56 - a single step, reusing a context (described in Advanced Functions)
57 - unbounded multiple steps (described as Streaming compression)
58
59 lz4.h provides block compression functions. It gives full buffer control to
60 user. Decompressing an lz4-compressed block also requires metadata (such as
61 compressed size). Each application is free to encode such metadata in
62 whichever way it wants.
63
64 An additional format, called LZ4 frame specification
65 (doc/lz4_Frame_format.md), take care of encoding standard metadata alongside
66 LZ4-compressed blocks. If your application requires interoperability, it's
67 recommended to use it. A library is provided to take care of it, see
68 lz4frame.h.
69*/
70
71/*^***************************************************************
72 * Export parameters
73 *****************************************************************/
74/*
75 * LZ4_DLL_EXPORT :
76 * Enable exporting of functions when building a Windows DLL
77 * LZ4LIB_VISIBILITY :
78 * Control library symbols visibility.
79 */
80#ifndef LZ4LIB_VISIBILITY
81#if defined(__GNUC__) && (__GNUC__ >= 4)
82#define LZ4LIB_VISIBILITY __attribute__((visibility("default")))
83#else
84#define LZ4LIB_VISIBILITY
85#endif
86#endif
87#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT == 1)
88#define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
89#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT == 1)
90#define LZ4LIB_API \
91 __declspec(dllimport) \
92 LZ4LIB_VISIBILITY /* It isn't required but allows generating better \
93 code, saving a function pointer load from the IAT \
94 and an indirect jump. */
95#else
96#define LZ4LIB_API LZ4LIB_VISIBILITY
97#endif
98
99/*------ Version ------*/
100#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
101#define LZ4_VERSION_MINOR \
102 8 /* for new (non-breaking) interface capabilities \
103 */
104#define LZ4_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */
106#define LZ4_VERSION_NUMBER \
107 (LZ4_VERSION_MAJOR * 100 * 100 + LZ4_VERSION_MINOR * 100 + \
108 LZ4_VERSION_RELEASE)
110#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
111#define LZ4_QUOTE(str) #str
112#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
113#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
114
116/**< library version number; useful to check dll version */
117
118LZ4LIB_API const char *LZ4_versionString(
119 void); /**< library version string; unseful to check dll version */
120
121/*-************************************
122 * Tuning parameter
123 **************************************/
124/*!
125 * LZ4_MEMORY_USAGE :
126 * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 ->
127 * 64KB; 20 -> 1MB; etc.) Increasing memory usage improves compression ratio
128 * Reduced memory usage may improve speed, thanks to cache effect
129 * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
130 */
131#ifndef LZ4_MEMORY_USAGE
132#define LZ4_MEMORY_USAGE 14
133#endif
134
135/*-************************************
136 * Simple Functions
137 **************************************/
138/*! LZ4_compress_default() :
139 Compresses 'srcSize' bytes from buffer 'src'
140 into already allocated 'dst' buffer of size 'dstCapacity'.
141 Compression is guaranteed to succeed if 'dstCapacity' >=
142 LZ4_compressBound(srcSize). It also runs faster, so it's a recommended
143 setting. If the function cannot compress 'src' into a more limited 'dst'
144 budget, compression stops *immediately*, and the function result is zero.
145 Note : as a consequence, 'dst' content is not valid.
146 Note 2 : This function is protected against buffer overflow scenarios (never
147 writes outside 'dst' buffer, nor read outside 'source' buffer). srcSize : max
148 supported value is LZ4_MAX_INPUT_SIZE. dstCapacity : size of buffer 'dst'
149 (which must be already allocated) return : the number of bytes written into
150 buffer 'dst' (necessarily <= dstCapacity) or 0 if compression fails */
151LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize,
152 int dstCapacity);
153
154/*! LZ4_decompress_safe() :
155 compressedSize : is the exact complete size of the compressed block.
156 dstCapacity : is the size of destination buffer, which must be already
157 allocated. return : the number of bytes decompressed into destination buffer
158 (necessarily <= dstCapacity) If destination buffer is not large enough,
159 decoding will stop and output an error code (negative value). If the source
160 stream is detected malformed, the function will stop decoding and return a
161 negative result. This function is protected against malicious data packets.
162 */
163LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst,
164 int compressedSize, int dstCapacity);
165
166/*-************************************
167 * Advanced Functions
168 **************************************/
169#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
170#define LZ4_COMPRESSBOUND(isize) \
171 ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE \
172 ? 0 \
173 : (isize) + ((isize) / 255) + 16)
174
175/*!
176 LZ4_compressBound() :
177 Provides the maximum size that LZ4 compression may output in a "worst case"
178 scenario (input data not compressible) This function is primarily useful for
179 memory allocation purposes (destination buffer size). Macro
180 LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack
181 memory allocation for example). Note that LZ4_compress_default() compresses
182 faster when dstCapacity is >= LZ4_compressBound(srcSize) inputSize : max
183 supported value is LZ4_MAX_INPUT_SIZE return : maximum output size in a
184 "worst case" scenario or 0, if input size is incorrect (too large or
185 negative)
186 */
187LZ4LIB_API int LZ4_compressBound(int inputSize);
188
189/*!
190 LZ4_compress_fast() :
191 Same as LZ4_compress_default(), but allows selection of "acceleration"
192 factor. The larger the acceleration value, the faster the algorithm, but also
193 the lesser the compression. It's a trade-off. It can be fine tuned, with each
194 successive value providing roughly +~3% to speed. An acceleration value of
195 "1" is the same as regular LZ4_compress_default() Values <= 0 will be
196 replaced by ACCELERATION_DEFAULT (currently == 1, see lz4.c).
197 */
198LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize,
199 int dstCapacity, int acceleration);
200
201/*!
202 LZ4_compress_fast_extState() :
203 Same compression function, just using an externally allocated memory space to
204 store compression state. Use LZ4_sizeofState() to know how much memory must
205 be allocated, and allocate it on 8-bytes boundaries (using malloc()
206 typically). Then, provide it as 'void* state' to compression function.
207 */
209LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src,
210 char *dst, int srcSize,
211 int dstCapacity, int acceleration);
212
213/*!
214 LZ4_compress_destSize() :
215 Reverse the logic : compresses as much data as possible from 'src' buffer
216 into already allocated buffer 'dst' of size 'targetDestSize'.
217 This function either compresses the entire 'src' content into 'dst' if it's
218 large enough, or fill 'dst' buffer completely with as much data as possible
219 from 'src'. *srcSizePtr : will be modified to indicate how many bytes where
220 read from 'src' to fill 'dst'. New value is necessarily <= old value. return
221 : Nb bytes written into 'dst' (necessarily <= targetDestSize) or 0 if
222 compression fails
223 */
224LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst,
225 int *srcSizePtr, int targetDstSize);
226
227/*!
228 LZ4_decompress_fast() : **unsafe!**
229 This function is a bit faster than LZ4_decompress_safe(),
230 but it may misbehave on malformed input because it doesn't perform full
231 validation of compressed data. originalSize : is the uncompressed size to
232 regenerate Destination buffer must be already allocated, and its size must be
233 >= 'originalSize' bytes. return : number of bytes read from source buffer (==
234 compressed size). If the source stream is detected malformed, the function
235 stops decoding and return a negative result. note : This function is only
236 usable if the originalSize of uncompressed data is known in advance. The
237 caller should also check that all the compressed input has been consumed
238 properly, i.e. that the return value matches the size of the buffer with
239 compressed input. The function never writes past the output buffer. However,
240 since it doesn't know its 'src' size, it may read past the intended input.
241 Also, because match offsets are not validated during decoding, reads from
242 'src' may underflow. Use this function in trusted environment **only**.
243 */
244LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst,
245 int originalSize);
246
247/*!
248 LZ4_decompress_safe_partial() :
249 This function decompress a compressed block of size 'srcSize' at position
250 'src' into destination buffer 'dst' of size 'dstCapacity'. The function will
251 decompress a minimum of 'targetOutputSize' bytes, and stop after that.
252 However, it's not accurate, and may write more than 'targetOutputSize' (but
253 always <= dstCapacity).
254 @return : the number of bytes decoded in the destination buffer (necessarily
255 <= dstCapacity) Note : this number can also be < targetOutputSize, if
256 compressed block contains less data. Therefore, always control how many bytes
257 were decoded. If source stream is detected malformed, function returns a
258 negative result. This function is protected against malicious data packets.
259 */
260LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst,
261 int srcSize, int targetOutputSize,
262 int dstCapacity);
263
264/*-*********************************************
265 * Streaming Compression Functions
266 ***********************************************/
267typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
268
269/*! LZ4_createStream() and LZ4_freeStream() :
270 * LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure.
271 * LZ4_freeStream() releases its memory.
272 */
275
276/*! LZ4_resetStream() :
277 * An LZ4_stream_t structure can be allocated once and re-used multiple times.
278 * Use this function to start compressing a new stream.
279 */
281
282/*! LZ4_loadDict() :
283 * Use this function to load a static dictionary into LZ4_stream_t.
284 * Any previous data will be forgotten, only 'dictionary' will remain in
285 * memory. Loading a size of 0 is allowed, and is the same as reset.
286 * @return : dictionary size, in bytes (necessarily <= 64 KB)
287 */
288LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary,
289 int dictSize);
290
291/*! LZ4_compress_fast_continue() :
292 * Compress 'src' content using data from previously compressed blocks, for
293 * better compression ratio. 'dst' buffer must be already allocated. If
294 * dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to
295 * succeed, and runs faster.
296 *
297 * Important : The previous 64KB of compressed data is assumed to remain
298 * present and unmodified in memory!
299 *
300 * Special 1 : When input is a double-buffer, they can have any size, including
301 * < 64 KB. Make sure that buffers are separated by at least one byte. This way,
302 * each block only depends on previous block. Special 2 : If input buffer is a
303 * ring-buffer, it can have any size, including < 64 KB.
304 *
305 * @return : size of compressed block
306 * or 0 if there is an error (typically, cannot fit into 'dst').
307 * After an error, the stream status is invalid, it can only be reset or freed.
308 */
310 const char *src, char *dst,
311 int srcSize, int dstCapacity,
312 int acceleration);
313
314/*! LZ4_saveDict() :
315 * If last 64KB data cannot be guaranteed to remain available at its current
316 * memory location, save it into a safer place (char* safeBuffer). This is
317 * schematically equivalent to a memcpy() followed by LZ4_loadDict(), but is
318 * much faster, because LZ4_saveDict() doesn't need to rebuild tables.
319 * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0
320 * if error.
321 */
322LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer,
323 int maxDictSize);
324
325/*-**********************************************
326 * Streaming Decompression Functions
327 * Bufferless synchronous API
328 ************************************************/
329typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
330
331/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
332 * creation / destruction of streaming decompression tracking context.
333 * A tracking context can be re-used multiple times.
334 */
337
338/*! LZ4_setStreamDecode() :
339 * An LZ4_streamDecode_t context can be allocated once and re-used multiple
340 * times. Use this function to start decompression of a new stream of blocks. A
341 * dictionary can optionnally be set. Use NULL or size 0 for a reset order.
342 * Dictionary is presumed stable : it must remain accessible and unmodified
343 * during next decompression.
344 * @return : 1 if OK, 0 if error
345 */
347 const char *dictionary, int dictSize);
348
349/*! LZ4_decoderRingBufferSize() : v1.8.2
350 * Note : in a ring buffer scenario (optional),
351 * blocks are presumed decompressed next to each other
352 * up to the moment there is not enough remaining space for next block
353 * (remainingSize < maxBlockSize), at which stage it resumes from beginning of
354 * ring buffer. When setting such a ring buffer for streaming decompression,
355 * provides the minimum size of this ring buffer
356 * to be compatible with any source respecting maxBlockSize condition.
357 * @return : minimum ring buffer size,
358 * or 0 if there is an error (invalid maxBlockSize).
359 */
361#define LZ4_DECODER_RING_BUFFER_SIZE(mbs) \
362 (65536 + 14 + (mbs)) /* for static allocation; mbs presumed valid */
363
364/*! LZ4_decompress_*_continue() :
365 * These decoding functions allow decompression of consecutive blocks in
366 * "streaming" mode. A block is an unsplittable entity, it must be presented
367 * entirely to a decompression function. Decompression functions only accepts
368 * one block at a time. The last 64KB of previously decoded data *must* remain
369 * available and unmodified at the memory position where they were decoded. If
370 * less than 64KB of data has been decoded, all the data must be present.
371 *
372 * Special : if decompression side sets a ring buffer, it must respect one of
373 * the following conditions :
374 * - Decompression buffer size is _at least_
375 * LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of
376 * any single block. It can have any value > 16 bytes. In which case, encoding
377 * and decoding buffers do not need to be synchronized. Actually, data can be
378 * produced by any source compliant with LZ4 format specification, and
379 * respecting maxBlockSize.
380 * - Synchronized mode :
381 * Decompression buffer size is _exactly_ the same as compression buffer
382 * size, and follows exactly same update rule (block boundaries at same
383 * positions), and decoding function is provided with exact decompressed size of
384 * each block (exception for last block of the stream), _then_ decoding &
385 * encoding ring buffer can have any size, including small ones ( < 64 KB).
386 * - Decompression buffer is larger than encoding buffer, by a minimum of
387 * maxBlockSize more bytes. In which case, encoding and decoding buffers do not
388 * need to be synchronized, and encoding ring buffer can have any size,
389 * including small ones ( < 64 KB).
390 *
391 * Whenever these conditions are not possible,
392 * save the last 64KB of decoded data into a safe buffer where it can't be
393 * modified during decompression, then indicate where this data is saved using
394 * LZ4_setStreamDecode(), before decompressing next block.
395 */
396LZ4LIB_API int
398 const char *src, char *dst, int srcSize,
399 int dstCapacity);
400LZ4LIB_API int
402 const char *src, char *dst, int originalSize);
403
404/*! LZ4_decompress_*_usingDict() :
405 * These decoding functions work the same as
406 * a combination of LZ4_setStreamDecode() followed by
407 * LZ4_decompress_*_continue() They are stand-alone, and don't need an
408 * LZ4_streamDecode_t structure. Dictionary is presumed stable : it must remain
409 * accessible and unmodified during next decompression.
410 */
411LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst,
412 int srcSize, int dstCapcity,
413 const char *dictStart,
414 int dictSize);
415LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst,
416 int originalSize,
417 const char *dictStart,
418 int dictSize);
419
420/*^**********************************************
421 * !!!!!! STATIC LINKING ONLY !!!!!!
422 ***********************************************/
423
424/*-************************************
425 * Unstable declarations
426 **************************************
427 * Declarations in this section should be considered unstable.
428 * Use at your own peril, etc., etc.
429 * They may be removed in the future.
430 * Their signatures may change.
431 **************************************/
432
433#ifdef LZ4_STATIC_LINKING_ONLY
434
435/*! LZ4_resetStream_fast() :
436 * Use this, like LZ4_resetStream(), to prepare a context for a new chain of
437 * calls to a streaming API (e.g., LZ4_compress_fast_continue()).
438 *
439 * Note:
440 * Using this in advance of a non- streaming-compression function is redundant,
441 * and potentially bad for performance, since they all perform their own custom
442 * reset internally.
443 *
444 * Differences from LZ4_resetStream():
445 * When an LZ4_stream_t is known to be in a internally coherent state,
446 * it can often be prepared for a new compression with almost no work, only
447 * sometimes falling back to the full, expensive reset that is always required
448 * when the stream is in an indeterminate state (i.e., the reset performed by
449 * LZ4_resetStream()).
450 *
451 * LZ4_streams are guaranteed to be in a valid state when:
452 * - returned from LZ4_createStream()
453 * - reset by LZ4_resetStream()
454 * - memset(stream, 0, sizeof(LZ4_stream_t)), though this is discouraged
455 * - the stream was in a valid state and was reset by LZ4_resetStream_fast()
456 * - the stream was in a valid state and was then used in any compression call
457 * that returned success
458 * - the stream was in an indeterminate state and was used in a compression
459 * call that fully reset the state (e.g., LZ4_compress_fast_extState()) and
460 * that returned success
461 *
462 * When a stream isn't known to be in a valid state, it is not safe to pass to
463 * any fastReset or streaming function. It must first be cleansed by the full
464 * LZ4_resetStream().
465 */
467
468/*! LZ4_compress_fast_extState_fastReset() :
469 * A variant of LZ4_compress_fast_extState().
470 *
471 * Using this variant avoids an expensive initialization step. It is only safe
472 * to call if the state buffer is known to be correctly initialized already
473 * (see above comment on LZ4_resetStream_fast() for a definition of "correctly
474 * initialized"). From a high level, the difference is that this function
475 * initializes the provided state with a call to something like
476 * LZ4_resetStream_fast() while LZ4_compress_fast_extState() starts with a
477 * call to LZ4_resetStream().
478 */
480 const char *src, char *dst,
481 int srcSize,
482 int dstCapacity,
483 int acceleration);
484
485/*! LZ4_attach_dictionary() :
486 * This is an experimental API that allows for the efficient use of a
487 * static dictionary many times.
488 *
489 * Rather than re-loading the dictionary buffer into a working context before
490 * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
491 * working LZ4_stream_t, this function introduces a no-copy setup mechanism,
492 * in which the working stream references the dictionary stream in-place.
493 *
494 * Several assumptions are made about the state of the dictionary stream.
495 * Currently, only streams which have been prepared by LZ4_loadDict() should
496 * be expected to work.
497 *
498 * Alternatively, the provided dictionary stream pointer may be NULL, in which
499 * case any existing dictionary stream is unset.
500 *
501 * If a dictionary is provided, it replaces any pre-existing stream history.
502 * The dictionary contents are the only history that can be referenced and
503 * logically immediately precede the data compressed in the first subsequent
504 * compression call.
505 *
506 * The dictionary will only remain attached to the working stream through the
507 * first compression call, at the end of which it is cleared. The dictionary
508 * stream (and source buffer) must remain in-place / accessible / unchanged
509 * through the completion of the first compression call on the stream.
510 */
512 const LZ4_stream_t *dictionary_stream);
513
514#endif
515
516/*-************************************
517 * Private definitions
518 **************************************
519 * Do not use these definitions.
520 * They are exposed to allow static allocation of `LZ4_stream_t` and
521 *`LZ4_streamDecode_t`. Using these definitions will expose code to API and/or
522 *ABI break in future versions of the library.
523 **************************************/
524#define LZ4_HASHLOG (LZ4_MEMORY_USAGE - 2)
525#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
526#define LZ4_HASH_SIZE_U32 \
527 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
528
529#if defined(__cplusplus) || \
530 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
531#include <stdint.h>
532
536 uint32_t currentOffset;
537 uint16_t initCheck;
538 uint16_t tableType;
539 const uint8_t *dictionary;
541 uint32_t dictSize;
542};
543
544typedef struct {
545 const uint8_t *externalDict;
546 size_t extDictSize;
547 const uint8_t *prefixEnd;
548 size_t prefixSize;
550
551#else
556 unsigned int currentOffset;
557 unsigned short initCheck;
558 unsigned short tableType;
559 const unsigned char *dictionary;
561 unsigned int dictSize;
562};
564typedef struct {
565 const unsigned char *externalDict;
566 size_t extDictSize;
567 const unsigned char *prefixEnd;
568 size_t prefixSize;
570
571#endif
572
573/*!
574 * LZ4_stream_t :
575 * information structure to track an LZ4 stream.
576 * init this structure before first use.
577 * note : only use in association with static linking !
578 * this definition is not API/ABI safe,
579 * it may change in a future version !
580 */
581#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE - 3)) + 4)
582#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
584 unsigned long long table[LZ4_STREAMSIZE_U64];
586}; /* previously typedef'd to LZ4_stream_t */
587
588/*!
589 * LZ4_streamDecode_t :
590 * information structure to track an LZ4 stream during decompression.
591 * init this structure using LZ4_setStreamDecode (or memset()) before first use
592 * note : only use in association with static linking !
593 * this definition is not API/ABI safe,
594 * and may change in a future version !
595 */
596#define LZ4_STREAMDECODESIZE_U64 4
597#define LZ4_STREAMDECODESIZE \
598 (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
600 unsigned long long table[LZ4_STREAMDECODESIZE_U64];
602}; /* previously typedef'd to LZ4_streamDecode_t */
603
604/*-************************************
605 * Obsolete Functions
606 **************************************/
607
608/*! Deprecation warnings
609 Should deprecation warnings be a problem,
610 it is generally possible to disable them,
611 typically with -Wno-deprecated-declarations for gcc
612 or _CRT_SECURE_NO_WARNINGS in Visual.
613 Otherwise, it's also possible to define LZ4_DISABLE_DEPRECATE_WARNINGS */
614#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
615#define LZ4_DEPRECATED(message) /* disable deprecation warnings */
616#else
617#define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
618#if defined(__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
619#define LZ4_DEPRECATED(message) [[deprecated(message)]]
620#elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
621#define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
622#elif (LZ4_GCC_VERSION >= 301)
623#define LZ4_DEPRECATED(message) __attribute__((deprecated))
624#elif defined(_MSC_VER)
625#define LZ4_DEPRECATED(message) __declspec(deprecated(message))
626#else
627#pragma message( \
628 "WARNING: You need to implement LZ4_DEPRECATED for this compiler")
629#define LZ4_DEPRECATED(message)
630#endif
631#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
632
633/* Obsolete compression functions */
634LZ4_DEPRECATED("use LZ4_compress_default() instead")
635LZ4LIB_API int LZ4_compress(const char *source, char *dest, int sourceSize);
637LZ4LIB_API int LZ4_compress_limitedOutput(const char *source, char *dest,
638 int sourceSize, int maxOutputSize);
640LZ4LIB_API int LZ4_compress_withState(void *state, const char *source,
641 char *dest, int inputSize);
644int LZ4_compress_limitedOutput_withState(void *state, const char *source,
645 char *dest, int inputSize,
646 int maxOutputSize);
649int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source,
650 char *dest, int inputSize);
654 const char *source, char *dest,
655 int inputSize, int maxOutputSize);
656
657/* Obsolete decompression functions */
658LZ4_DEPRECATED("use LZ4_decompress_fast() instead")
659LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize);
660LZ4_DEPRECATED("use LZ4_decompress_safe() instead")
661LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
662 int isize, int maxOutputSize);
663
664/* Obsolete streaming functions; degraded functionality; do not use!
665 *
666 * In order to perform streaming compression, these functions depended on data
667 * that is no longer tracked in the state. They have been preserved as well as
668 * possible: using them will still produce a correct output. However, they don't
669 * actually retain any history between compression calls. The compression ratio
670 * achieved will therefore be no better than compressing each chunk
671 * independently.
672 */
673LZ4_DEPRECATED("Use LZ4_createStream() instead")
674LZ4LIB_API void *LZ4_create(char *inputBuffer);
675LZ4_DEPRECATED("Use LZ4_createStream() instead")
677LZ4_DEPRECATED("Use LZ4_resetStream() instead")
678LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer);
679LZ4_DEPRECATED("Use LZ4_saveDict() instead")
680LZ4LIB_API char *LZ4_slideInputBuffer(void *state);
681
682/* Obsolete streaming decoding functions */
685int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst,
686 int compressedSize, int maxDstSize);
688LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst,
689 int originalSize);
690
691#endif /* LZ4_H_2983827168210 */
692
693#if defined(__cplusplus)
694}
695#endif
void LZ4_resetStream_fast(LZ4_stream_t *ctx)
Definition lz4.c:1557
void LZ4_attach_dictionary(LZ4_stream_t *working_stream, const LZ4_stream_t *dictionary_stream)
Definition lz4.c:1616
int LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.c:1359
#define LZ4LIB_API
Definition lz4.h:96
LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst, int originalSize, const char *dictStart, int dictSize)
Definition lz4.c:2383
LZ4LIB_API int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.c:1659
LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst, int srcSize, int dstCapcity, const char *dictStart, int dictSize)
Definition lz4.c:2366
LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.c:1424
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize)
Definition lz4.c:2246
LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
Definition lz4.c:2209
LZ4LIB_API int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int originalSize)
Definition lz4.c:2317
#define LZ4_STREAMDECODESIZE_U64
Definition lz4.h:595
LZ4LIB_API int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst, int compressedSize, int maxDstSize)
Definition lz4.c:2123
LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int maxDictSize)
Definition lz4.c:1800
LZ4LIB_API const char * LZ4_versionString(void)
Definition lz4.c:633
LZ4LIB_API int LZ4_versionNumber(void)
Definition lz4.c:628
LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize)
Definition lz4.c:2443
LZ4LIB_API int LZ4_compress(const char *source, char *dest, int sourceSize)
Definition lz4.c:2403
LZ4LIB_API LZ4_stream_t * LZ4_createStream(void)
Definition lz4.c:1536
LZ4LIB_API int LZ4_sizeofState(void)
Definition lz4.c:643
LZ4LIB_API int LZ4_compress_limitedOutput(const char *source, char *dest, int sourceSize, int maxOutputSize)
Definition lz4.c:2397
#define LZ4_HASH_SIZE_U32
Definition lz4.h:525
LZ4LIB_API int LZ4_compressBound(int inputSize)
Definition lz4.c:638
LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity)
Definition lz4.c:2093
LZ4LIB_API int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize)
Definition lz4.c:2429
LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer)
Definition lz4.c:2461
LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
Definition lz4.c:2223
LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr)
Definition lz4.c:1562
LZ4LIB_API int LZ4_compress_limitedOutput_withState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition lz4.c:2409
LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
Definition lz4.c:2448
LZ4LIB_API LZ4_streamDecode_t * LZ4_createStreamDecode(void)
Definition lz4.c:2202
LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.c:1306
LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst, int srcSize, int targetOutputSize, int dstCapacity)
Definition lz4.c:2102
LZ4LIB_API void * LZ4_create(char *inputBuffer)
Definition lz4.c:2468
LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst, int originalSize)
Definition lz4.c:2132
LZ4LIB_API int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition lz4.c:2421
LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition lz4.c:1572
LZ4LIB_API int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int srcSize, int dstCapacity)
Definition lz4.c:2266
LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr)
Definition lz4.c:1551
#define LZ4_STREAMSIZE_U64
Definition lz4.h:580
LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize)
Definition lz4.c:1509
LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst, int originalSize)
Definition lz4.c:2112
LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity)
Definition lz4.c:1448
LZ4LIB_API int LZ4_sizeofStreamState(void)
Definition lz4.c:2456
LZ4LIB_API int LZ4_compress_withState(void *state, const char *source, char *dest, int inputSize)
Definition lz4.c:2415
#define LZ4_DEPRECATED(message)
Definition lz4.h:628
LZ4LIB_API char * LZ4_slideInputBuffer(void *state)
Definition lz4.c:2474
unsigned short initCheck
Definition lz4.h:556
const LZ4_stream_t_internal * dictCtx
Definition lz4.h:559
unsigned short tableType
Definition lz4.h:557
unsigned int currentOffset
Definition lz4.h:555
unsigned int dictSize
Definition lz4.h:560
unsigned int hashTable[LZ4_HASH_SIZE_U32]
Definition lz4.h:554
const unsigned char * dictionary
Definition lz4.h:558
LZ4_streamDecode_t_internal internal_donotuse
Definition lz4.h:600
unsigned long long table[LZ4_STREAMDECODESIZE_U64]
Definition lz4.h:599
LZ4_stream_t_internal internal_donotuse
Definition lz4.h:584
unsigned long long table[LZ4_STREAMSIZE_U64]
Definition lz4.h:583