source: thirdparty/blosc/internal-complibs/lz4-1.7.2/lz4hc.h @ 8ebc79b

Revision 8ebc79b, 9.4 KB checked in by Hal Finkel <hfinkel@…>, 8 years ago (diff)

Add the other internal compression libraries from blocs

  • Property mode set to 100644
RevLine 
[8ebc79b]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)
38extern "C" {
39#endif
40
41/*****************************
42*  Includes
43*****************************/
44#include <stddef.h>   /* size_t */
45
46
47/**************************************
48*  Block Compression
49**************************************/
50int LZ4_compress_HC (const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
51/*
52LZ4_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
70int LZ4_sizeofStateHC(void);
71int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
72/*
73LZ4_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))
91typedef 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
102LZ4_streamHC_t* LZ4_createStreamHC(void);
103int             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
112void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
113int  LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
114
115int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
116
117int 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 */
166int LZ4_compressHC                (const char* source, char* dest, int inputSize);
167int LZ4_compressHC_limitedOutput  (const char* source, char* dest, int inputSize, int maxOutputSize);
168int LZ4_compressHC2               (const char* source, char* dest, int inputSize, int compressionLevel);
169int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
170int LZ4_compressHC_withStateHC               (void* state, const char* source, char* dest, int inputSize);
171int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
172int LZ4_compressHC2_withStateHC              (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
173int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
174int LZ4_compressHC_continue               (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
175int 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 */
178LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer);
179LZ4_DEPRECATED("use LZ4_saveDictHC() instead")     char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
180LZ4_DEPRECATED("use LZ4_freeStreamHC() instead")   int   LZ4_freeHC (void* LZ4HC_Data);
181LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int   LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
182LZ4_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);
183LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int   LZ4_sizeofStreamStateHC(void);
184LZ4_DEPRECATED("use LZ4_resetStreamHC() instead")  int   LZ4_resetStreamStateHC(void* state, char* inputBuffer);
185
186
187#if defined (__cplusplus)
188}
189#endif
Note: See TracBrowser for help on using the repository browser.