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-2015, 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/Cyan4973/lz4
32  - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
33 */
34 #pragma once
35 
36 
37 #if defined (__cplusplus)
38 extern "C" {
39 #endif
40 
41 /*****************************
42 * Includes
43 *****************************/
44 #include <stddef.h> /* size_t */
45 
46 
47 /**************************************
48 * Block Compression
49 **************************************/
50 int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
51 /*
52 LZ4_compress_HC :
53  Destination buffer 'dst' must be already allocated.
54  Compression completion is guaranteed if 'dst' buffer is sized to handle worst circumstances (data not compressible)
55  Worst size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
56  srcSize : Max supported value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
57  compressionLevel : Recommended values are between 4 and 9, although any value between 0 and 16 will work.
58  0 means "use default value" (see lz4hc.c).
59  Values >16 behave the same as 16.
60  return : the number of bytes written into buffer 'dst'
61  or 0 if compression fails.
62 */
63 
64 
65 /* Note :
66  Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
67 */
68 
69 
70 int LZ4_sizeofStateHC(void);
71 int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
72 /*
73 LZ4_compress_HC_extStateHC() :
74  Use this function if you prefer to manually allocate memory for compression tables.
75  To know how much memory must be allocated for the compression tables, use :
76  int LZ4_sizeofStateHC();
77 
78  Allocated memory must be aligned on 8-bytes boundaries (which a normal malloc() will do properly).
79 
80  The allocated memory can then be provided to the compression functions using 'void* state' parameter.
81  LZ4_compress_HC_extStateHC() is equivalent to previously described function.
82  It just uses externally allocated memory for stateHC.
83 */
84 
85 
86 /**************************************
87 * Streaming Compression
88 **************************************/
89 #define LZ4_STREAMHCSIZE 262192
90 #define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
91 typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t;
92 /*
93  LZ4_streamHC_t
94  This structure allows static allocation of LZ4 HC streaming state.
95  State must then be initialized using LZ4_resetStreamHC() before first use.
96 
97  Static allocation should only be used in combination with static linking.
98  If you want to use LZ4 as a DLL, please use construction functions below, which are future-proof.
99 */
100 
101 
103 int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
104 /*
105  These functions create and release memory for LZ4 HC streaming state.
106  Newly created states are already initialized.
107  Existing state space can be re-used anytime using LZ4_resetStreamHC().
108  If you use LZ4 as a DLL, use these functions instead of static structure allocation,
109  to avoid size mismatch between different versions.
110 */
111 
112 void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
113 int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
114 
115 int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
116 
117 int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
118 
119 /*
120  These functions compress data in successive blocks of any size, using previous blocks as dictionary.
121  One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
122  There is an exception for ring buffers, which can be smaller 64 KB.
123  Such case is automatically detected and correctly handled by LZ4_compress_HC_continue().
124 
125  Before starting compression, state must be properly initialized, using LZ4_resetStreamHC().
126  A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional).
127 
128  Then, use LZ4_compress_HC_continue() to compress each successive block.
129  It works like LZ4_compress_HC(), but use previous memory blocks as dictionary to improve compression.
130  Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression.
131  As a reminder, size 'dst' buffer to handle worst cases, using LZ4_compressBound(), to ensure success of compression operation.
132 
133  If, for any reason, previous data blocks can't be preserved unmodified in memory during next compression block,
134  you must save it to a safer memory space, using LZ4_saveDictHC().
135  Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'.
136 */
137 
138 
139 
140 /**************************************
141 * Deprecated Functions
142 **************************************/
143 /* Deprecate Warnings */
144 /* Should these warnings messages be a problem,
145  it is generally possible to disable them,
146  with -Wno-deprecated-declarations for gcc
147  or _CRT_SECURE_NO_WARNINGS in Visual for example.
148  You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */
149 #ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK
150 # define LZ4_DEPRECATE_WARNING_DEFBLOCK
151 # define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
152 # if (LZ4_GCC_VERSION >= 405) || defined(__clang__)
153 # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
154 # elif (LZ4_GCC_VERSION >= 301)
155 # define LZ4_DEPRECATED(message) __attribute__((deprecated))
156 # elif defined(_MSC_VER)
157 # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
158 # else
159 # pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
160 # define LZ4_DEPRECATED(message)
161 # endif
162 #endif // LZ4_DEPRECATE_WARNING_DEFBLOCK
163 
164 /* compression functions */
165 /* these functions are planned to trigger warning messages by r131 approximately */
166 int LZ4_compressHC (const char* source, char* dest, int inputSize);
167 int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
168 int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
169 int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
170 int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
171 int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
172 int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
174 int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
175 int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
176 
177 /* Streaming functions following the older model; should no longer be used */
178 LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer);
179 LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
180 LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data);
181 LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
185 
186 
187 #if defined (__cplusplus)
188 }
189 #endif
LZ4_sizeofStreamStateHC
int LZ4_sizeofStreamStateHC(void)
Definition: lz4hc.c:691
LZ4_compressHC2_limitedOutput_continue
int LZ4_compressHC2_limitedOutput_continue(void *LZ4HC_Data, const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel)
Definition: lz4hc.c:721
LZ4_compressHC_continue
int LZ4_compressHC_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize)
Definition: lz4hc.c:685
LZ4_compress_HC_continue
int LZ4_compress_HC_continue(LZ4_streamHC_t *streamHCPtr, const char *src, char *dst, int srcSize, int maxDstSize)
Definition: lz4hc.c:641
LZ4_DEPRECATED
#define LZ4_DEPRECATED(message)
Definition: lz4hc.h:160
LZ4_compressHC2_withStateHC
int LZ4_compressHC2_withStateHC(void *state, const char *source, char *dest, int inputSize, int compressionLevel)
Definition: lz4hc.c:683
LZ4_slideInputBufferHC
char * LZ4_slideInputBufferHC(void *LZ4HC_Data)
Definition: lz4hc.c:726
LZ4_freeStreamHC
int LZ4_freeStreamHC(LZ4_streamHC_t *streamHCPtr)
Definition: lz4hc.c:563
LZ4_resetStreamHC
void LZ4_resetStreamHC(LZ4_streamHC_t *streamHCPtr, int compressionLevel)
Definition: lz4hc.c:567
LZ4_compressHC_withStateHC
int LZ4_compressHC_withStateHC(void *state, const char *source, char *dest, int inputSize)
Definition: lz4hc.c:681
maxOutputSize
const char char int int maxOutputSize
Definition: lz4hc.h:182
LZ4_resetStreamStateHC
int LZ4_resetStreamStateHC(void *state, char *inputBuffer)
Definition: lz4hc.c:693
LZ4_compressHC_limitedOutput_withStateHC
int LZ4_compressHC_limitedOutput_withStateHC(void *state, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4hc.c:682
state
RecoveryProgressState state
Definition: tools/Recovery/main.cpp:56
LZ4_compressHC2_continue
int LZ4_compressHC2_continue(void *LZ4HC_Data, const char *source, char *dest, int inputSize, int compressionLevel)
Definition: lz4hc.c:716
LZ4_compress_HC
int LZ4_compress_HC(const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
Definition: lz4hc.c:550
LZ4_createHC
void * LZ4_createHC(char *inputBuffer)
Definition: lz4hc.c:701
LZ4_STREAMHCSIZE_SIZET
#define LZ4_STREAMHCSIZE_SIZET
Definition: lz4hc.h:90
LZ4_compressHC_limitedOutput_continue
int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4hc.c:686
LZ4_compressHC_limitedOutput
int LZ4_compressHC_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4hc.c:678
table
ArrayXXf table(10, 4)
LZ4_loadDictHC
int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary, int dictSize)
Definition: lz4hc.c:574
source
const char * source
Definition: lz4hc.h:181
LZ4_createStreamHC
LZ4_streamHC_t * LZ4_createStreamHC(void)
Definition: lz4hc.c:562
maxDstSize
char int int maxDstSize
Definition: lz4.h:354
LZ4_compressHC2_limitedOutput
int LZ4_compressHC2_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel)
Definition: lz4hc.c:680
compressionLevel
const char char int int compressionLevel
Definition: lz4hc.h:181
LZ4_saveDictHC
int LZ4_saveDictHC(LZ4_streamHC_t *streamHCPtr, char *safeBuffer, int maxDictSize)
Definition: lz4hc.c:652
LZ4_sizeofStateHC
int LZ4_sizeofStateHC(void)
Definition: lz4hc.c:538
LZ4_compress_HC_extStateHC
int LZ4_compress_HC_extStateHC(void *state, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
Definition: lz4hc.c:540
dest
const char char * dest
Definition: lz4hc.h:181
inputBuffer
char * inputBuffer
Definition: lz4hc.h:184
LZ4_compressHC
int LZ4_compressHC(const char *source, char *dest, int inputSize)
Definition: lz4hc.c:677
LZ4_freeHC
int LZ4_freeHC(void *LZ4HC_Data)
Definition: lz4hc.c:710
LZ4_streamHC_t
Definition: lz4hc.h:91
dst
char * dst
Definition: lz4.h:354
inputSize
const char char int inputSize
Definition: lz4hc.h:181
LZ4_compressHC2_limitedOutput_withStateHC
int LZ4_compressHC2_limitedOutput_withStateHC(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel)
Definition: lz4hc.c:684
LZ4_compressHC2
int LZ4_compressHC2(const char *source, char *dest, int inputSize, int compressionLevel)
Definition: lz4hc.c:679


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jul 1 2024 02:42:29