lz4frame.h
Go to the documentation of this file.
1 /*
2  LZ4 auto-framing library
3  Header File
4  Copyright (C) 2011-2017, Yann Collet.
5  BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions are
9  met:
10 
11  * Redistributions of source code must retain the above copyright
12  notice, this list of conditions and the following disclaimer.
13  * Redistributions in binary form must reproduce the above
14  copyright notice, this list of conditions and the following disclaimer
15  in the documentation and/or other materials provided with the
16  distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30  You can contact the author at :
31  - LZ4 source repository : https://github.com/lz4/lz4
32  - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
33 */
34 
35 /* LZ4F is a stand-alone API to create LZ4-compressed frames
36  * conformant with specification v1.5.1.
37  * It also offers streaming capabilities.
38  * lz4.h is not required when using lz4frame.h.
39  * */
40 
41 #ifndef LZ4F_H_09782039843
42 #define LZ4F_H_09782039843
43 
44 #if defined (__cplusplus)
45 extern "C" {
46 #endif
47 
48 /* --- Dependency --- */
49 #include <stddef.h> /* size_t */
50 
51 
60 /*-***************************************************************
61  * Compiler specifics
62  *****************************************************************/
63 /* LZ4_DLL_EXPORT :
64  * Enable exporting of functions when building a Windows DLL
65  * LZ4FLIB_API :
66  * Control library symbols visibility.
67  */
68 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
69 # define LZ4FLIB_API __declspec(dllexport)
70 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
71 # define LZ4FLIB_API __declspec(dllimport)
72 #elif defined(__GNUC__) && (__GNUC__ >= 4)
73 # define LZ4FLIB_API __attribute__ ((__visibility__ ("default")))
74 #else
75 # define LZ4FLIB_API
76 #endif
77 
78 #ifdef LZ4F_DISABLE_DEPRECATE_WARNINGS
79 # define LZ4F_DEPRECATE(x) x
80 #else
81 # if defined(_MSC_VER)
82 # define LZ4F_DEPRECATE(x) x /* __declspec(deprecated) x - only works with C++ */
83 # elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
84 # define LZ4F_DEPRECATE(x) x __attribute__((deprecated))
85 # else
86 # define LZ4F_DEPRECATE(x) x /* no deprecation warning for this compiler */
87 # endif
88 #endif
89 
90 
91 /*-************************************
92  * Error management
93  **************************************/
94 typedef size_t LZ4F_errorCode_t;
95 
96 LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code);
97 LZ4FLIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code);
100 /*-************************************
101  * Frame compression types
102  **************************************/
103 /* #define LZ4F_DISABLE_OBSOLETE_ENUMS */ /* uncomment to disable obsolete enums */
104 #ifndef LZ4F_DISABLE_OBSOLETE_ENUMS
105 # define LZ4F_OBSOLETE_ENUM(x) , LZ4F_DEPRECATE(x) = LZ4F_##x
106 #else
107 # define LZ4F_OBSOLETE_ENUM(x)
108 #endif
109 
110 /* The larger the block size, the (slightly) better the compression ratio,
111  * though there are diminishing returns.
112  * Larger blocks also increase memory usage on both compression and decompression sides. */
113 typedef enum {
119  LZ4F_OBSOLETE_ENUM(max64KB)
120  LZ4F_OBSOLETE_ENUM(max256KB)
121  LZ4F_OBSOLETE_ENUM(max1MB)
122  LZ4F_OBSOLETE_ENUM(max4MB)
124 
125 /* Linked blocks sharply reduce inefficiencies when using small blocks,
126  * they compress better.
127  * However, some LZ4 decoders are only compatible with independent blocks */
128 typedef enum {
131  LZ4F_OBSOLETE_ENUM(blockLinked)
132  LZ4F_OBSOLETE_ENUM(blockIndependent)
134 
135 typedef enum {
138  LZ4F_OBSOLETE_ENUM(noContentChecksum)
139  LZ4F_OBSOLETE_ENUM(contentChecksumEnabled)
141 
142 typedef enum {
145  LZ4F_OBSOLETE_ENUM(skippableFrame)
147 
148 #ifndef LZ4F_DISABLE_OBSOLETE_ENUMS
149 typedef LZ4F_blockSizeID_t blockSizeID_t;
150 typedef LZ4F_blockMode_t blockMode_t;
151 typedef LZ4F_frameType_t frameType_t;
153 #endif
154 
159 typedef struct {
160  LZ4F_blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB ; 0 == default */
161  LZ4F_blockMode_t blockMode; /* blockLinked, blockIndependent ; 0 == default */
162  LZ4F_contentChecksum_t contentChecksumFlag; /* noContentChecksum, contentChecksumEnabled ; 0 == default */
163  LZ4F_frameType_t frameType; /* LZ4F_frame, skippableFrame ; 0 == default */
164  unsigned long long contentSize; /* Size of uncompressed (original) content ; 0 == unknown */
165  unsigned reserved[2]; /* must be zero for forward compatibility */
167 
172 typedef struct {
174  int compressionLevel; /* 0 == default (fast mode); values above LZ4HC_CLEVEL_MAX count as LZ4HC_CLEVEL_MAX; values below 0 trigger "fast acceleration", proportional to value */
175  unsigned autoFlush; /* 1 == always flush (reduce usage of tmp buffer) */
176  unsigned reserved[4]; /* must be zero for forward compatibility */
178 
179 
180 /*-*********************************
181 * Simple compression function
182 ***********************************/
187 LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr);
188 
198 LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr);
199 
200 
201 
202 /*-***********************************
203 * Advanced compression functions
204 *************************************/
205 typedef struct LZ4F_cctx_s LZ4F_cctx; /* incomplete type */
206 typedef LZ4F_cctx* LZ4F_compressionContext_t; /* for compatibility with previous API version */
207 
208 typedef struct {
209  unsigned stableSrc; /* 1 == src content will remain present on future calls to LZ4F_compress(); skip copying src content within tmp buffer */
210  unsigned reserved[3];
212 
213 /*--- Resource Management ---*/
214 
215 #define LZ4F_VERSION 100
216 LZ4FLIB_API unsigned LZ4F_getVersion(void);
225 LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx** cctxPtr, unsigned version);
226 LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx* cctx);
227 
228 
229 /*---- Compression ----*/
230 
231 #define LZ4F_HEADER_SIZE_MAX 15
232 
239 LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_preferences_t* prefsPtr);
240 
247 LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr);
248 
259 LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const void* srcBuffer, size_t srcSize, const LZ4F_compressOptions_t* cOptPtr);
260 
269 LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* cOptPtr);
270 
280 LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* cOptPtr);
281 
282 
283 /*-*********************************
284 * Decompression functions
285 ***********************************/
286 typedef struct LZ4F_dctx_s LZ4F_dctx; /* incomplete type */
287 typedef LZ4F_dctx* LZ4F_decompressionContext_t; /* compatibility with previous API versions */
288 
289 typedef struct {
290  unsigned stableDst; /* pledge that at least 64KB+64Bytes of previously decompressed data remain unmodifed where it was decoded. This optimization skips storage operations in tmp buffers */
291  unsigned reserved[3];
293 
294 
295 /* Resource management */
296 
306 LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** dctxPtr, unsigned version);
307 LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx);
308 
309 
310 /*-***********************************
311 * Streaming decompression functions
312 *************************************/
313 
335  LZ4F_frameInfo_t* frameInfoPtr,
336  const void* srcBuffer, size_t* srcSizePtr);
337 
363  void* dstBuffer, size_t* dstSizePtr,
364  const void* srcBuffer, size_t* srcSizePtr,
365  const LZ4F_decompressOptions_t* dOptPtr);
366 
367 
373 LZ4FLIB_API void LZ4F_resetDecompressionContext(LZ4F_dctx* dctx); /* always successful */
374 
375 
376 
377 #if defined (__cplusplus)
378 }
379 #endif
380 
381 #endif /* LZ4F_H_09782039843 */
LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *cOptPtr)
Definition: lz4frame.c:702
LZ4F_contentChecksum_t
Definition: lz4frame.h:135
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **cctxPtr, unsigned version)
LZ4F_contentChecksum_t contentChecksumFlag
Definition: lz4frame.h:162
LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code)
Definition: lz4frame.c:192
LZ4F_frameType_t frameType
Definition: lz4frame.h:163
LZ4FLIB_API unsigned LZ4F_getVersion(void)
Definition: lz4frame.c:217
LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *cOptPtr)
Definition: lz4frame.c:664
size_t LZ4F_errorCode_t
Definition: lz4frame.h:94
LZ4F_blockSizeID_t blockSizeID_t
Definition: lz4frame.h:149
LZ4F_blockMode_t blockMode_t
Definition: lz4frame.h:150
LZ4F_frameType_t
Definition: lz4frame.h:142
LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *cOptPtr)
Definition: lz4frame.c:568
LZ4FLIB_API size_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
Definition: lz4frame.c:933
LZ4F_cctx * LZ4F_compressionContext_t
Definition: lz4frame.h:206
LZ4F_blockSizeID_t blockSizeID
Definition: lz4frame.h:160
LZ4F_dctx * LZ4F_decompressionContext_t
Definition: lz4frame.h:287
LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *prefsPtr)
Definition: lz4frame.c:416
LZ4F_frameInfo_t frameInfo
Definition: lz4frame.h:173
LZ4F_blockSizeID_t
Definition: lz4frame.h:113
LZ4F_contentChecksum_t contentChecksum_t
Definition: lz4frame.h:152
#define LZ4FLIB_API
Definition: lz4frame.h:75
LZ4FLIB_API size_t LZ4F_decompress(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *dOptPtr)
Definition: lz4frame.c:1059
LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t *prefsPtr)
Definition: lz4frame.c:499
unsigned autoFlush
Definition: lz4frame.h:175
unsigned long long contentSize
Definition: lz4frame.h:164
U32 version
Definition: lz4frame.c:171
LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
Definition: lz4frame.c:291
LZ4F_blockMode_t blockMode
Definition: lz4frame.h:161
LZ4FLIB_API const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
Definition: lz4frame.c:197
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctx)
LZ4FLIB_API void LZ4F_resetDecompressionContext(LZ4F_dctx *dctx)
Definition: lz4frame.c:801
LZ4F_blockMode_t
Definition: lz4frame.h:128
LZ4FLIB_API size_t LZ4F_compressFrame(void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
Definition: lz4frame.c:313
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *dctx)
Definition: lz4frame.c:773
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **dctxPtr, unsigned version)
Definition: lz4frame.c:763
#define LZ4F_OBSOLETE_ENUM(x)
Definition: lz4frame.h:105
LZ4F_frameType_t frameType_t
Definition: lz4frame.h:151


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