VR-Vantage
Loading...
Searching...
No Matches
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)
45extern "C" {
46#endif
47
48/* --- Dependency --- */
49#include <stddef.h> /* size_t */
50
51
59
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**************************************/
87typedef size_t LZ4F_errorCode_t;
88
91
92
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
114
115typedef enum {
118 LZ4F_OBSOLETE_ENUM(blockLinked)
119 LZ4F_OBSOLETE_ENUM(blockIndependent)
121
122typedef enum {
125 LZ4F_OBSOLETE_ENUM(noContentChecksum)
126 LZ4F_OBSOLETE_ENUM(contentChecksumEnabled)
128
134
135#ifndef LZ4F_DISABLE_OBSOLETE_ENUMS
140#endif
141
146typedef 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
159typedef 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***********************************/
174LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr);
175
185LZ4FLIB_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*************************************/
192typedef struct LZ4F_cctx_s LZ4F_cctx; /* incomplete type */
193typedef LZ4F_cctx* LZ4F_compressionContext_t; /* for compatibility with previous API version */
194
195typedef 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
214
215
216/* Compression */
217
218#define LZ4F_HEADER_SIZE_MAX 15
226LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_preferences_t* prefsPtr);
227
234LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* prefsPtr);
235
246LZ4FLIB_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
256LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* cOptPtr);
257
267LZ4FLIB_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***********************************/
273typedef struct LZ4F_dctx_s LZ4F_dctx; /* incomplete type */
274typedef LZ4F_dctx* LZ4F_decompressionContext_t; /* compatibility with previous API versions */
275
276typedef 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
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 */
LZ4F_blockMode_t
Definition lz4frame.h:115
@ LZ4F_blockLinked
Definition lz4frame.h:116
@ LZ4F_blockIndependent
Definition lz4frame.h:117
LZ4F_contentChecksum_t contentChecksum_t
Definition lz4frame.h:139
LZ4F_blockSizeID_t blockSizeID_t
Definition lz4frame.h:136
size_t LZ4F_errorCode_t
Definition lz4frame.h:87
#define LZ4FLIB_API
Introduction.
Definition lz4frame.h:72
#define LZ4F_OBSOLETE_ENUM(x)
Definition lz4frame.h:98
LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
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 LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *const dctx)
LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctx)
LZ4F_blockMode_t blockMode_t
Definition lz4frame.h:137
struct LZ4F_cctx_s LZ4F_cctx
Definition lz4frame.h:192
LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *cOptPtr)
LZ4F_blockSizeID_t
Definition lz4frame.h:103
@ LZ4F_max256KB
Definition lz4frame.h:106
@ LZ4F_default
Definition lz4frame.h:104
@ LZ4F_max1MB
Definition lz4frame.h:107
@ LZ4F_max64KB
Definition lz4frame.h:105
@ LZ4F_max4MB
Definition lz4frame.h:108
LZ4FLIB_API unsigned LZ4F_isError(LZ4F_errorCode_t code)
tells if a LZ4F_errorCode_t function result is an error code
LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *cOptPtr)
LZ4FLIB_API const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
return error code string; useful for debugging
LZ4F_cctx * LZ4F_compressionContext_t
Definition lz4frame.h:193
LZ4F_frameType_t frameType_t
Definition lz4frame.h:138
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **dctxPtr, unsigned version)
LZ4F_dctx * LZ4F_decompressionContext_t
Definition lz4frame.h:274
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)
struct LZ4F_dctx_s LZ4F_dctx
Definition lz4frame.h:273
LZ4FLIB_API size_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *prefsPtr)
LZ4FLIB_API unsigned LZ4F_getVersion(void)
LZ4F_contentChecksum_t
Definition lz4frame.h:122
@ LZ4F_noContentChecksum
Definition lz4frame.h:123
@ LZ4F_contentChecksumEnabled
Definition lz4frame.h:124
LZ4FLIB_API LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **cctxPtr, unsigned version)
LZ4F_frameType_t
Definition lz4frame.h:129
@ LZ4F_skippableFrame
Definition lz4frame.h:131
@ LZ4F_frame
Definition lz4frame.h:130
LZ4FLIB_API size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t *prefsPtr)
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:195
unsigned reserved[3]
Definition lz4frame.h:197
unsigned stableSrc
Definition lz4frame.h:196
Definition lz4frame.h:276
unsigned reserved[3]
Definition lz4frame.h:278
unsigned stableDst
Definition lz4frame.h:277
Definition lz4frame.h:146
LZ4F_contentChecksum_t contentChecksumFlag
Definition lz4frame.h:149
unsigned long long contentSize
Definition lz4frame.h:151
unsigned reserved[2]
Definition lz4frame.h:152
LZ4F_frameType_t frameType
Definition lz4frame.h:150
LZ4F_blockMode_t blockMode
Definition lz4frame.h:148
LZ4F_blockSizeID_t blockSizeID
Definition lz4frame.h:147
Definition lz4frame.h:159
unsigned reserved[4]
Definition lz4frame.h:163
int compressionLevel
Definition lz4frame.h:161
LZ4F_frameInfo_t frameInfo
Definition lz4frame.h:160
unsigned autoFlush
Definition lz4frame.h:162