lz4hc.h
Go to the documentation of this file.
1 /*
2  LZ4 HC - High Compression Mode of LZ4
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 #ifndef LZ4_HC_H_19834876238432
35 #define LZ4_HC_H_19834876238432
36 
37 #if defined (__cplusplus)
38 extern "C" {
39 #endif
40 
41 /* --- Dependency --- */
42 /* note : lz4hc is not an independent module, it requires lz4.h/lz4.c for proper compilation */
43 #include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
44 
45 
46 /* --- Useful constants --- */
47 #define LZ4HC_CLEVEL_MIN 3
48 #define LZ4HC_CLEVEL_DEFAULT 9
49 #define LZ4HC_CLEVEL_OPT_MIN 11
50 #define LZ4HC_CLEVEL_MAX 12
51 
52 
53 /*-************************************
54  * Block Compression
55  **************************************/
66 LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel);
67 
68 
69 /* Note :
70  * Decompression functions are provided within "lz4.h" (BSD license)
71  */
72 
73 
79 LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
81 
82 
83 /*-************************************
84  * Streaming Compression
85  * Bufferless synchronous API
86  **************************************/
87  typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
88 
96 LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
97 
99 LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
100 
101 LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
102 
103 LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
104 
105 /*
106  These functions compress data in successive blocks of any size, using previous blocks as dictionary.
107  One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
108  There is an exception for ring buffers, which can be smaller than 64 KB.
109  Ring buffers scenario is automatically detected and handled by LZ4_compress_HC_continue().
110 
111  Before starting compression, state must be properly initialized, using LZ4_resetStreamHC().
112  A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional).
113 
114  Then, use LZ4_compress_HC_continue() to compress each successive block.
115  Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression.
116  'dst' buffer should be sized to handle worst case scenarios (see LZ4_compressBound()), to ensure operation success.
117  Because in case of failure, the API does not guarantee context recovery, and context will have to be reset.
118  If `dst` buffer budget cannot be >= LZ4_compressBound(), consider using LZ4_compress_HC_continue_destSize() instead.
119 
120  If, for any reason, previous data block can't be preserved unmodified in memory for next compression block,
121  you can save it to a more stable memory space, using LZ4_saveDictHC().
122  Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'.
123 */
124 
125 
126  /*-*************************************
127  * PRIVATE DEFINITIONS :
128  * Do not use these definitions.
129  * They are exposed to allow static allocation of `LZ4_streamHC_t`.
130  * Using these definitions makes the code vulnerable to potential API break when upgrading LZ4
131  **************************************/
132 #define LZ4HC_DICTIONARY_LOGSIZE 17 /* because of btopt, hc would only need 16 */
133 #define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
134 #define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
135 
136 #define LZ4HC_HASH_LOG 15
137 #define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
138 #define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
139 
140 
141 #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
142 #include <stdint.h>
143 
144 typedef struct
145 {
146  uint32_t hashTable[LZ4HC_HASHTABLESIZE];
147  uint16_t chainTable[LZ4HC_MAXD];
148  const uint8_t* end; /* next block here to continue on current prefix */
149  const uint8_t* base; /* All index relative to this position */
150  const uint8_t* dictBase; /* alternate base for extDict */
151  uint8_t* inputBuffer; /* deprecated */
152  uint32_t dictLimit; /* below that point, need extDict */
153  uint32_t lowLimit; /* below that point, no more dict */
154  uint32_t nextToUpdate; /* index from which to continue dictionary update */
155  uint32_t searchNum; /* only for optimal parser */
158 
159 #else
160 
161 typedef struct
162 {
163  unsigned int hashTable[LZ4HC_HASHTABLESIZE];
164  unsigned short chainTable[LZ4HC_MAXD];
165  const unsigned char* end; /* next block here to continue on current prefix */
166  const unsigned char* base; /* All index relative to this position */
167  const unsigned char* dictBase; /* alternate base for extDict */
168  unsigned char* inputBuffer; /* deprecated */
169  unsigned int dictLimit; /* below that point, need extDict */
170  unsigned int lowLimit; /* below that point, no more dict */
171  unsigned int nextToUpdate; /* index from which to continue dictionary update */
172  unsigned int searchNum; /* only for optimal parser */
175 
176 #endif
177 
178 #define LZ4_STREAMHCSIZE (4*LZ4HC_HASHTABLESIZE + 2*LZ4HC_MAXD + 56) /* 393268 */
179 #define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
183 }; /* previously typedef'd to LZ4_streamHC_t */
184 /*
185  LZ4_streamHC_t :
186  This structure allows static allocation of LZ4 HC streaming state.
187  State must be initialized using LZ4_resetStreamHC() before first use.
188 
189  Static allocation shall only be used in combination with static linking.
190  When invoking LZ4 from a DLL, use create/free functions instead, which are API and ABI stable.
191 */
192 
193 
194 /*-************************************
195 * Deprecated Functions
196 **************************************/
197 /* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
198 
199 /* deprecated compression functions */
200 /* these functions will trigger warning messages in future releases */
201 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC (const char* source, char* dest, int inputSize);
202 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
203 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
204 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
205 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
206 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
207 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
208 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
209 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
210 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
211 
212 /* Deprecated Streaming functions using older model; should no longer be used */
214 LZ4LIB_API LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
215 LZ4LIB_API LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data);
216 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
217 LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
219 LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
220 
221 
222 #if defined (__cplusplus)
223 }
224 #endif
225 
226 #endif /* LZ4_HC_H_19834876238432 */
227 
228 /*-************************************************
229  * !!!!! STATIC LINKING ONLY !!!!!
230  * Following definitions are considered experimental.
231  * They should not be linked from DLL,
232  * as there is no guarantee of API stability yet.
233  * Prototypes will be promoted to "stable" status
234  * after successfull usage in real-life scenarios.
235  *************************************************/
236 #ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
237 #ifndef LZ4_HC_SLO_098092834
238 #define LZ4_HC_SLO_098092834
239 
248 LZ4LIB_API int LZ4_compress_HC_destSize(void* LZ4HC_Data,
249  const char* src, char* dst,
250  int* srcSizePtr, int targetDstSize,
251  int compressionLevel);
252 
265  const char* src, char* dst,
266  int* srcSizePtr, int targetDstSize);
267 
268 #endif /* LZ4_HC_SLO_098092834 */
269 #endif /* LZ4_HC_STATIC_LINKING_ONLY */
unsigned char * inputBuffer
Definition: lz4hc.h:168
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC(const char *source
int LZ4_freeHC(void *LZ4HC_Data)
Definition: lz4hc.c:770
LZ4LIB_API int LZ4_compress_HC(const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
Definition: lz4hc.c:581
GLuint GLuint end
#define LZ4LIB_API
Definition: lz4.h:85
int LZ4_compressHC2_withStateHC(void *state, const char *src, char *dst, int srcSize, int cLevel)
Definition: lz4hc.c:743
int LZ4_compressHC(const char *src, char *dst, int srcSize)
Definition: lz4hc.c:737
int LZ4_compressHC_withStateHC(void *state, const char *src, char *dst, int srcSize)
Definition: lz4hc.c:741
unsigned int dictLimit
Definition: lz4hc.h:169
LZ4LIB_API char * dest
Definition: lz4hc.h:201
LZ4LIB_API int LZ4_compress_HC_continue(LZ4_streamHC_t *streamHCPtr, const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4hc.c:694
GLenum GLenum dst
Definition: glext.h:1751
LZ4HC_CCtx_internal internal_donotuse
Definition: lz4hc.h:182
unsigned short uint16_t
Definition: stdint.h:79
LZ4LIB_API void LZ4_resetStreamHC(LZ4_streamHC_t *streamHCPtr, int compressionLevel)
Definition: lz4hc.c:617
LZ4LIB_API char int int compressionLevel
Definition: lz4hc.h:203
GLenum src
Definition: glext.h:1751
unsigned char uint8_t
Definition: stdint.h:78
#define LZ4HC_MAXD
Definition: lz4hc.h:133
const unsigned char * dictBase
Definition: lz4hc.h:167
int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_t *ctx, const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4hc.c:746
LZ4LIB_API int LZ4_compress_HC_extStateHC(void *state, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
Definition: lz4hc.c:570
LZ4LIB_API char int int maxOutputSize
Definition: lz4hc.h:202
int LZ4_compressHC2_continue(void *LZ4HC_Data, const char *src, char *dst, int srcSize, int cLevel)
Definition: lz4hc.c:772
int LZ4_compressHC_limitedOutput(const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4hc.c:738
LZ4LIB_API int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary, int dictSize)
Definition: lz4hc.c:626
int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int *srcSizePtr, int targetDestSize)
Definition: lz4hc.c:702
int LZ4_compressHC2_limitedOutput_continue(void *LZ4HC_Data, const char *src, char *dst, int srcSize, int dstCapacity, int cLevel)
Definition: lz4hc.c:777
int LZ4_compress_HC_destSize(void *LZ4HC_Data, const char *source, char *dest, int *sourceSizePtr, int targetDestSize, int cLevel)
Definition: lz4hc.c:599
unsigned int lowLimit
Definition: lz4hc.h:170
int LZ4_compressHC2_limitedOutput_withStateHC(void *state, const char *src, char *dst, int srcSize, int maxDstSize, int cLevel)
Definition: lz4hc.c:744
#define LZ4HC_HASHTABLESIZE
Definition: lz4hc.h:137
LZ4LIB_API char int inputSize
Definition: lz4hc.h:201
int LZ4_resetStreamStateHC(void *state, char *inputBuffer)
Definition: lz4hc.c:752
unsigned int uint32_t
Definition: stdint.h:80
unsigned int nextToUpdate
Definition: lz4hc.h:171
void * LZ4_createHC(char *inputBuffer)
Definition: lz4hc.c:761
LZ4LIB_API int LZ4_sizeofStateHC(void)
Definition: lz4hc.c:568
int LZ4_compressHC_continue(LZ4_streamHC_t *ctx, const char *src, char *dst, int srcSize)
Definition: lz4hc.c:745
LZ4LIB_API char * inputBuffer
Definition: lz4hc.h:219
unsigned int searchNum
Definition: lz4hc.h:172
GLenum GLenum GLsizei void * table
const unsigned char * base
Definition: lz4hc.h:166
LZ4LIB_API int LZ4_freeStreamHC(LZ4_streamHC_t *streamHCPtr)
Definition: lz4hc.c:613
int LZ4_compressHC2_limitedOutput(const char *src, char *dst, int srcSize, int maxDstSize, int cLevel)
Definition: lz4hc.c:740
LZ4LIB_API char int int maxDstSize
Definition: lz4.h:456
int LZ4_compressHC2(const char *src, char *dst, int srcSize, int cLevel)
Definition: lz4hc.c:739
GLsizei GLsizei GLchar * source
#define LZ4_STREAMHCSIZE_SIZET
Definition: lz4hc.h:179
int LZ4_sizeofStreamStateHC(void)
Definition: lz4hc.c:750
char * LZ4_slideInputBufferHC(void *LZ4HC_Data)
Definition: lz4hc.c:782
LZ4LIB_API LZ4_streamHC_t * LZ4_createStreamHC(void)
Definition: lz4hc.c:612
int LZ4_compressHC_limitedOutput_withStateHC(void *state, const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4hc.c:742
LZ4LIB_API int LZ4_saveDictHC(LZ4_streamHC_t *streamHCPtr, char *safeBuffer, int maxDictSize)
Definition: lz4hc.c:713
int compressionLevel
Definition: lz4hc.h:173
const unsigned char * end
Definition: lz4hc.h:165


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