mb/google/nissa/var/telith: Configure Acoustic noise mitigation
[coreboot2.git] / util / cbfstool / lz4 / lib / lz4hc.h
blob431f7c87c863f203f3cb08bc9cf471203899bbb4
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)
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
9 met:
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.
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.
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
34 #pragma once
37 #if defined (__cplusplus)
38 extern "C" {
39 #endif
41 /*****************************
42 * Includes
43 *****************************/
44 #include <stddef.h> /* size_t */
47 /**************************************
48 * Block Compression
49 **************************************/
50 int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
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.
65 /* Note :
66 Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
70 int LZ4_sizeofStateHC(void);
71 int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
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();
78 Allocated memory must be aligned on 8-bytes boundaries (which a normal malloc() will do properly).
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.
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;
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.
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.
102 LZ4_streamHC_t* LZ4_createStreamHC(void);
103 int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
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.
112 void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
113 int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
115 int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
117 int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
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().
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).
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.
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'.
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
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);
173 int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, 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);
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);
182 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);
183 LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void);
184 LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
187 #if defined (__cplusplus)
189 #endif