VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lz4frame.h
Go to the documentation of this file.
1 /*
2  LZ4 auto-framing library
3  Header File
4  Copyright (C) 2011-2016, 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 /*
64 * LZ4_DLL_EXPORT :
65 * Enable exporting of functions when building a Windows DLL
66 */
67 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
68 # define LZ4FLIB_API __declspec(dllexport)
69 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
70 # define LZ4FLIB_API __declspec(dllimport)
71 #else
72 # define LZ4FLIB_API
73 #endif
74 
75 #if defined(_MSC_VER)
76 # define LZ4F_DEPRECATE(x) x /* __declspec(deprecated) x - only works with C++ */
77 #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
78 # define LZ4F_DEPRECATE(x) x __attribute__((deprecated))
79 #else
80 # define LZ4F_DEPRECATE(x) x /* no deprecation warning for this compiler */
81 #endif
82 
83 
84 /*-************************************
85 * Error management
86 **************************************/
87 typedef size_t LZ4F_errorCode_t;
88 
89 LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code);
90 LZ4FLIB_API const char* LZ4F_getErrorName(LZ4F_errorCode_t code);
93 /*-************************************
94 * Frame compression types
95 **************************************/
96 /* #define LZ4F_DISABLE_OBSOLETE_ENUMS */ /* uncomment to disable obsolete enums */
97 #ifndef LZ4F_DISABLE_OBSOLETE_ENUMS
98 # define LZ4F_OBSOLETE_ENUM(x) , LZ4F_DEPRECATE(x) = LZ4F_##x
99 #else
100 # define LZ4F_OBSOLETE_ENUM(x)
101 #endif
102 
103 typedef enum {
109  LZ4F_OBSOLETE_ENUM(max64KB)
110  LZ4F_OBSOLETE_ENUM(max256KB)
111  LZ4F_OBSOLETE_ENUM(max1MB)
112  LZ4F_OBSOLETE_ENUM(max4MB)
114 
115 typedef enum {
118  LZ4F_OBSOLETE_ENUM(blockLinked)
119  LZ4F_OBSOLETE_ENUM(blockIndependent)
121 
122 typedef enum {
125  LZ4F_OBSOLETE_ENUM(noContentChecksum)
126  LZ4F_OBSOLETE_ENUM(contentChecksumEnabled)
128 
129 typedef enum {
132  LZ4F_OBSOLETE_ENUM(skippableFrame)
134 
135 #ifndef LZ4F_DISABLE_OBSOLETE_ENUMS
136 typedef LZ4F_blockSizeID_t blockSizeID_t;
137 typedef LZ4F_blockMode_t blockMode_t;
140 #endif
141 
146 typedef struct {
147  LZ4F_blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB ; 0 == default */
148  LZ4F_blockMode_t blockMode; /* blockLinked, blockIndependent ; 0 == default */
149  LZ4F_contentChecksum_t contentChecksumFlag; /* noContentChecksum, contentChecksumEnabled ; 0 == default */
150  LZ4F_frameType_t frameType; /* LZ4F_frame, skippableFrame ; 0 == default */
151  unsigned long long contentSize; /* Size of uncompressed (original) content ; 0 == unknown */
152  unsigned reserved[2]; /* must be zero for forward compatibility */
154 
159 typedef struct {
161  int compressionLevel; /* 0 == default (fast mode); values above 16 count as 16; values below 0 count as 0 */
162  unsigned autoFlush; /* 1 == always flush (reduce usage of tmp buffer) */
163  unsigned reserved[4]; /* must be zero for forward compatibility */
165 
166 
167 /*-*********************************
168 * Simple compression function
169 ***********************************/
174 LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr);
175 
185 LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity, const void* srcBuffer, size_t srcSize, const LZ4F_preferences_t* preferencesPtr);
186 
187 
188 
189 /*-***********************************
190 * Advanced compression functions
191 *************************************/
192 typedef struct LZ4F_cctx_s LZ4F_cctx; /* incomplete type */
193 typedef LZ4F_cctx* LZ4F_compressionContext_t; /* for compatibility with previous API version */
194 
195 typedef struct {
196  unsigned stableSrc; /* 1 == src content will remain present on future calls to LZ4F_compress(); skip copying src content within tmp buffer */
197  unsigned reserved[3];
199 
200 /* Resource Management */
201 
202 #define LZ4F_VERSION 100
203 LZ4FLIB_API unsigned LZ4F_getVersion(void);
212 LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx** cctxPtr, unsigned version);
213 LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx* cctx);
214 
215 
216 /* Compression */
217 
218 #define LZ4F_HEADER_SIZE_MAX 15
219 
226 LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_preferences_t* prefsPtr);
227 
234 LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr);
235 
246 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);
247 
256 LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* cOptPtr);
257 
267 LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* cOptPtr);
268 
269 
270 /*-*********************************
271 * Decompression functions
272 ***********************************/
273 typedef struct LZ4F_dctx_s LZ4F_dctx; /* incomplete type */
274 typedef LZ4F_dctx* LZ4F_decompressionContext_t; /* compatibility with previous API versions */
275 
276 typedef struct {
277  unsigned stableDst; /* guarantee that decompressed data will still be there on next function calls (avoid storage into tmp buffers) */
278  unsigned reserved[3];
280 
281 
282 /* Resource management */
283 
293 LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** dctxPtr, unsigned version);
294 LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* const dctx);
295 
296 
297 /* ====== Decompression ======*/
298 
312  LZ4F_frameInfo_t* frameInfoPtr,
313  const void* srcBuffer, size_t* srcSizePtr);
314 
339  void* dstBuffer, size_t* dstSizePtr,
340  const void* srcBuffer, size_t* srcSizePtr,
341  const LZ4F_decompressOptions_t* dOptPtr);
342 
343 
344 
345 #if defined (__cplusplus)
346 }
347 #endif
348 
349 #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.h:107
Definition: lz4frame.h:108
LZ4F_contentChecksum_t
Definition: lz4frame.h:122
LZ4F_contentChecksum_t contentChecksumFlag
Definition: lz4frame.h:149
struct LZ4F_cctx_s LZ4F_cctx
Definition: lz4frame.h:192
LZ4F_frameType_t frameType
Definition: lz4frame.h:150
Definition: lz4frame.h:105
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **cctxPtr, unsigned version)
Definition: lz4frame.h:131
Definition: lz4frame.h:116
int compressionLevel
Definition: lz4frame.h:161
LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code)
tells if a LZ4F_errorCode_t function result is an error code
LZ4FLIB_API unsigned LZ4F_getVersion(void)
LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *cOptPtr)
Definition: lz4frame.h:123
size_t LZ4F_errorCode_t
Definition: lz4frame.h:87
Definition: lz4frame.h:124
Definition: lz4frame.h:130
LZ4F_blockSizeID_t blockSizeID_t
Definition: lz4frame.h:136
LZ4F_blockMode_t blockMode_t
Definition: lz4frame.h:137
LZ4F_frameType_t
Definition: lz4frame.h:129
LZ4F_blockSizeID_t blockSizeID
Definition: lz4frame.h:147
struct LZ4F_dctx_s LZ4F_dctx
Definition: lz4frame.h:273
Definition: lz4frame.h:104
Definition: lz4frame.h:195
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)
LZ4FLIB_API size_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4F_cctx * LZ4F_compressionContext_t
Definition: lz4frame.h:193
unsigned long long contentSize
Definition: lz4frame.h:151
Definition: lz4frame.h:146
Definition: lz4frame.h:106
LZ4F_frameInfo_t frameInfo
Definition: lz4frame.h:160
LZ4F_dctx * LZ4F_decompressionContext_t
Definition: lz4frame.h:274
LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *prefsPtr)
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *const dctx)
LZ4F_blockSizeID_t
Definition: lz4frame.h:103
LZ4F_contentChecksum_t contentChecksum_t
Definition: lz4frame.h:139
#define LZ4FLIB_API
Introduction.
Definition: lz4frame.h:72
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)
LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t *prefsPtr)
Definition: lz4frame.h:117
unsigned stableSrc
Definition: lz4frame.h:196
unsigned autoFlush
Definition: lz4frame.h:162
LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
unsigned stableDst
Definition: lz4frame.h:277
LZ4F_blockMode_t blockMode
Definition: lz4frame.h:148
LZ4FLIB_API const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
return error code string; useful for debugging
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctx)
LZ4F_blockMode_t
Definition: lz4frame.h:115
LZ4FLIB_API size_t LZ4F_compressFrame(void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
Definition: lz4frame.h:159
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **dctxPtr, unsigned version)
#define LZ4F_OBSOLETE_ENUM(x)
Definition: lz4frame.h:98
Definition: lz4frame.h:276
LZ4F_frameType_t frameType_t
Definition: lz4frame.h:138

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)