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)
36 extern "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 
69 /*^***************************************************************
70 * Export parameters
71 *****************************************************************/
72 /*
73 * LZ4_DLL_EXPORT :
74 * Enable exporting of functions when building a Windows DLL
75 * LZ4LIB_API :
76 * Control library symbols visibility.
77 */
78 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
79 # define LZ4LIB_API __declspec(dllexport)
80 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
81 # define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
82 #elif defined(__GNUC__) && (__GNUC__ >= 4)
83 # define LZ4LIB_API __attribute__ ((__visibility__ ("default")))
84 #else
85 # define LZ4LIB_API
86 #endif
87 
88 
89 /*------ Version ------*/
90 #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
91 #define LZ4_VERSION_MINOR 8 /* for new (non-breaking) interface capabilities */
92 #define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
93 
94 #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
95 
96 #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
97 #define LZ4_QUOTE(str) #str
98 #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
99 #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
100 
101 LZ4LIB_API int LZ4_versionNumber (void);
102 LZ4LIB_API const char* LZ4_versionString (void);
105 /*-************************************
106 * Tuning parameter
107 **************************************/
115 #ifndef LZ4_MEMORY_USAGE
116 # define LZ4_MEMORY_USAGE 14
117 #endif
118 
119 /*-************************************
120 * Simple Functions
121 **************************************/
135 LZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize);
136 
146 LZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
147 
148 
149 /*-************************************
150 * Advanced Functions
151 **************************************/
152 #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
153 #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
154 
166 
175 LZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
176 
177 
185 LZ4LIB_API int LZ4_sizeofState(void);
186 LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration);
187 
188 
200 LZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
201 
202 
214 LZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
215 
228 LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
229 
230 
231 /*-*********************************************
232 * Streaming Compression Functions
233 ***********************************************/
234 typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
235 
241 LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
242 
247 LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
248 
255 LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
256 
265 LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
266 
273 LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize);
274 
275 
276 /*-**********************************************
277 * Streaming Decompression Functions
278 * Bufferless synchronous API
279 ************************************************/
280 typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */
281 
286 
292 LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
293 
311 LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
312 LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
313 
314 
320 LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
321 LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
322 
323 
324 /*^**********************************************
325  * !!!!!! STATIC LINKING ONLY !!!!!!
326  ***********************************************/
327 /*-************************************
328  * Private definitions
329  **************************************
330  * Do not use these definitions.
331  * They are exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
332  * Using these definitions will expose code to API and/or ABI break in future versions of the library.
333  **************************************/
334 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
335 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
336 #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
337 
338 #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
339 #include <stdint.h>
340 
341 typedef struct {
342  uint32_t hashTable[LZ4_HASH_SIZE_U32];
343  uint32_t currentOffset;
344  uint32_t initCheck;
345  const uint8_t* dictionary;
346  uint8_t* bufferStart; /* obsolete, used for slideInputBuffer */
347  uint32_t dictSize;
349 
350 typedef struct {
351  const uint8_t* externalDict;
352  size_t extDictSize;
353  const uint8_t* prefixEnd;
354  size_t prefixSize;
356 
357 #else
358 
359 typedef struct {
360  unsigned int hashTable[LZ4_HASH_SIZE_U32];
361  unsigned int currentOffset;
362  unsigned int initCheck;
363  const unsigned char* dictionary;
364  unsigned char* bufferStart; /* obsolete, used for slideInputBuffer */
365  unsigned int dictSize;
367 
368 typedef struct {
369  const unsigned char* externalDict;
370  size_t extDictSize;
371  const unsigned char* prefixEnd;
372  size_t prefixSize;
374 
375 #endif
376 
385 #define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
386 #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
388  unsigned long long table[LZ4_STREAMSIZE_U64];
390 } ; /* previously typedef'd to LZ4_stream_t */
391 
392 
401 #define LZ4_STREAMDECODESIZE_U64 4
402 #define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
404  unsigned long long table[LZ4_STREAMDECODESIZE_U64];
406 } ; /* previously typedef'd to LZ4_streamDecode_t */
407 
408 
409 /*-************************************
410 * Obsolete Functions
411 **************************************/
412 
419 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
420 # define LZ4_DEPRECATED(message) /* disable deprecation warnings */
421 #else
422 # define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
423 # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
424 # define LZ4_DEPRECATED(message) [[deprecated(message)]]
425 # elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
426 # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
427 # elif (LZ4_GCC_VERSION >= 301)
428 # define LZ4_DEPRECATED(message) __attribute__((deprecated))
429 # elif defined(_MSC_VER)
430 # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
431 # else
432 # pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
433 # define LZ4_DEPRECATED(message)
434 # endif
435 #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
436 
437 /* Obsolete compression functions */
438 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress (const char* source, char* dest, int sourceSize);
439 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
440 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
441 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
442 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
443 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
444 
445 /* Obsolete decompression functions */
446 LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_fast() instead") int LZ4_uncompress (const char* source, char* dest, int outputSize);
447 LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_safe() instead") int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
448 
449 /* Obsolete streaming functions; use new streaming interface whenever possible */
450 LZ4LIB_API LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer);
452 LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer);
453 LZ4LIB_API LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
454 
455 /* Obsolete streaming decoding functions */
458 
459 #endif /* LZ4_H_2983827168210 */
460 
461 #if defined (__cplusplus)
462 }
463 #endif
void * LZ4_create(char *inputBuffer)
Definition: lz4.c:1448
char * LZ4_slideInputBuffer(void *LZ4_Data)
Definition: lz4.c:1455
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:405
unsigned int initCheck
Definition: lz4.h:362
int LZ4_compress_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.c:1414
#define LZ4LIB_API
Definition: lz4.h:85
#define LZ4_HASH_SIZE_U32
Definition: lz4.h:336
unsigned int currentOffset
Definition: lz4.h:361
LZ4LIB_API int LZ4_sizeofState(void)
Definition: lz4.c:407
LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:934
int LZ4_resetStreamState(void *state, char *inputBuffer)
Definition: lz4.c:1441
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
Definition: lz4.c:1428
LZ4LIB_API char * inputBuffer
Definition: lz4.h:452
#define LZ4_STREAMSIZE_U64
Definition: lz4.h:385
LZ4LIB_API int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int compressedSize, int maxDecompressedSize)
Definition: lz4.c:1321
unsigned char * bufferStart
Definition: lz4.h:364
#define LZ4_STREAMDECODESIZE_U64
Definition: lz4.h:401
int LZ4_decompress_safe_withPrefix64k(const char *source, char *dest, int compressedSize, int maxOutputSize)
Definition: lz4.c:1464
GLenum GLenum dst
Definition: glext.h:1751
const unsigned char * prefixEnd
Definition: lz4.h:371
GLenum src
Definition: glext.h:1751
int LZ4_uncompress(const char *source, char *dest, int outputSize)
Definition: lz4.c:1427
unsigned char uint8_t
Definition: stdint.h:78
LZ4LIB_API int LZ4_decompress_safe_partial(const char *source, char *dest, int compressedSize, int targetOutputSize, int maxDecompressedSize)
Definition: lz4.c:1267
int LZ4_decompress_fast_withPrefix64k(const char *source, char *dest, int originalSize)
Definition: lz4.c:1469
const unsigned char * externalDict
Definition: lz4.h:369
LZ4LIB_API char int originalSize
Definition: lz4.h:457
LZ4LIB_API char int sourceSize
Definition: lz4.h:438
LZ4LIB_API int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int originalSize)
Definition: lz4.c:1347
int LZ4_compress_withState(void *state, const char *src, char *dst, int srcSize)
Definition: lz4.c:1417
LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxDestSize, int acceleration)
Definition: lz4.c:670
unsigned int uint32_t
Definition: stdint.h:80
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:998
#define LZ4_DEPRECATED(message)
Definition: lz4.h:433
unsigned int dictSize
Definition: lz4.h:365
LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:939
LZ4LIB_API LZ4_stream_t * LZ4_createStream(void)
Definition: lz4.c:926
LZ4LIB_API const char * LZ4_versionString(void)
Definition: lz4.c:405
LZ4LIB_API int LZ4_compress_default(const char *source, char *dest, int sourceSize, int maxDestSize)
Definition: lz4.c:708
LZ4LIB_API char int isize
Definition: lz4.h:447
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:389
int LZ4_compress_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize)
Definition: lz4.c:1419
LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int dictSize)
Definition: lz4.c:1073
LZ4LIB_API char int compressedSize
Definition: lz4.h:456
LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *source, char *dest, int originalSize, const char *dictStart, int dictSize)
Definition: lz4.c:1398
LZ4LIB_API int LZ4_versionNumber(void)
Definition: lz4.c:404
GLenum GLenum GLsizei void * table
LZ4LIB_API int LZ4_compress_fast(const char *source, char *dest, int sourceSize, int maxDestSize, int acceleration)
Definition: lz4.c:690
LZ4LIB_API const char char int inputSize
Definition: lz4.h:440
int LZ4_compress_limitedOutput_withState(void *state, const char *src, char *dst, int srcSize, int dstSize)
Definition: lz4.c:1416
LZ4LIB_API char int outputSize
Definition: lz4.h:446
LZ4LIB_API int LZ4_compress_destSize(const char *source, char *dest, int *sourceSizePtr, int targetDestSize)
Definition: lz4.c:903
LZ4LIB_API char int int maxDstSize
Definition: lz4.h:456
LZ4LIB_API char int int maxOutputSize
Definition: lz4.h:439
int LZ4_sizeofStreamState()
Definition: lz4.c:1433
int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_stream, const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4.c:1418
LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *source, char *dest, int compressedSize, int maxDecompressedSize, const char *dictStart, int dictSize)
Definition: lz4.c:1393
LZ4LIB_API LZ4_streamDecode_t * LZ4_createStreamDecode(void)
Definition: lz4.c:1285
int LZ4_compress(const char *source, char *dest, int inputSize)
Definition: lz4.c:1415
GLsizei GLsizei GLchar * source
LZ4LIB_API int LZ4_decompress_fast(const char *source, char *dest, int originalSize)
Definition: lz4.c:1272
LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition: lz4.c:947
LZ4LIB_API char * dest
Definition: lz4.h:438
LZ4LIB_API int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
Definition: lz4.c:1262
const unsigned char * dictionary
Definition: lz4.h:363
LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
Definition: lz4.c:1304
LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
Definition: lz4.c:1291
LZ4LIB_API int LZ4_compressBound(int inputSize)
Definition: lz4.c:406


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21