forked from enlightenment/efl
lz4: Update our internal copy to release r128
Looking through the git log it is unclear which release we used before as nobody stated it there. :/ We updated after the security issues last year so my best guess is that we have something like r119. To see what changed I now included the NEWS file and also the LICENSE file from upstream. Upstream in now hosted here: https://github.com/Cyan4973/lz4 and http://www.lz4.info I recommend STRONGLY that you check if your distro ships liblz4 as an up to date library package and use the --enable-liblz4 configure option to use the system version. I consider making the system version default for upcoming releases and only carry the internal one as fallback for systems that do not provide it. Fix T2374
This commit is contained in:
parent
6d87ac2991
commit
4314257d8c
|
@ -58,7 +58,9 @@ if ! ENABLE_LIBLZ4
|
|||
lib_emile_libemile_la_LIBADD += @LIBLZ4_LIBS@
|
||||
endif
|
||||
|
||||
EXTRA_DIST += static_libs/lz4/README \
|
||||
EXTRA_DIST += static_libs/lz4/README.md \
|
||||
static_libs/lz4/LICENSE \
|
||||
static_libs/lz4/NEWS \
|
||||
static_libs/lz4/lz4.c \
|
||||
static_libs/lz4/lz4.h \
|
||||
static_libs/lz4/lz4hc.c \
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
LZ4 Library
|
||||
Copyright (c) 2011-2014, Yann Collet
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,153 @@
|
|||
r128:
|
||||
New : lz4cli sparse file support
|
||||
New : command -m, to compress multiple files in a single command
|
||||
Fixed : Restored lz4hc compression ratio (was slightly lower since r124)
|
||||
New : lz4 cli supports long commands
|
||||
New : lz4frame & lz4cli frame content size support
|
||||
New : lz4frame supports skippable frames
|
||||
Changed:Default "make install" directory is /usr/local
|
||||
New : lz4 cli supports "pass-through" mode
|
||||
New : datagen can generate sparse files
|
||||
New : scan-build tests
|
||||
New : g++ compatibility tests
|
||||
New : arm cross-compilation test
|
||||
Fixed : Fuzzer + frametest compatibility with NetBSD (issue #48)
|
||||
Added : Visual project directory
|
||||
Updated:Man page & Specification
|
||||
|
||||
r127:
|
||||
N/A : added a file on SVN
|
||||
|
||||
r126:
|
||||
New : lz4frame API is now integrated into liblz4
|
||||
Fixed : GCC 4.9 bug on highest performance settings, reported by Greg Slazinski
|
||||
Fixed : bug within LZ4 HC streaming mode, reported by James Boyle
|
||||
Fixed : older compiler don't like nameless unions, reported by Cheyi Lin
|
||||
Changed : lz4 is C90 compatible
|
||||
Changed : added -pedantic option, fixed a few mminor warnings
|
||||
|
||||
r125:
|
||||
Changed : endian and alignment code
|
||||
Changed : directory structure : new "lib" directory
|
||||
Updated : lz4io, now uses lz4frame
|
||||
Improved: slightly improved decoding speed
|
||||
Fixed : LZ4_compress_limitedOutput(); Special thanks to Christopher Speller !
|
||||
Fixed : some alignment warnings under clang
|
||||
Fixed : deprecated function LZ4_slideInputBufferHC()
|
||||
|
||||
r124:
|
||||
New : LZ4 HC streaming mode
|
||||
Fixed : LZ4F_compressBound() using null preferencesPtr
|
||||
Updated : xxHash to r38
|
||||
Updated library number, to 1.4.0
|
||||
|
||||
r123:
|
||||
Added : experimental lz4frame API, thanks to Takayuki Matsuoka and Christopher Jackson for testings
|
||||
Fix : s390x support, thanks to Nobuhiro Iwamatsu
|
||||
Fix : test mode (-t) no longer requires confirmation, thanks to Thary Nguyen
|
||||
|
||||
r122:
|
||||
Fix : AIX & AIX64 support (SamG)
|
||||
Fix : mips 64-bits support (lew van)
|
||||
Added : Examples directory, using code examples from Takayuki Matsuoka
|
||||
Updated : Framing specification, to v1.4.1
|
||||
Updated : xxHash, to r36
|
||||
|
||||
r121:
|
||||
Added : Makefile : install for kFreeBSD and Hurd (Nobuhiro Iwamatsu)
|
||||
Fix : Makefile : install for OS-X and BSD, thanks to Takayuki Matsuoka
|
||||
|
||||
r120:
|
||||
Modified : Streaming API, using strong types
|
||||
Added : LZ4_versionNumber(), thanks to Takayuki Matsuoka
|
||||
Fix : OS-X : library install name, thanks to Clemens Lang
|
||||
Updated : Makefile : synchronize library version number with lz4.h, thanks to Takayuki Matsuoka
|
||||
Updated : Makefile : stricter compilation flags
|
||||
Added : pkg-config, thanks to Zbigniew Jędrzejewski-Szmek (issue 135)
|
||||
Makefile : lz4-test only test native binaries, as suggested by Michał Górny (issue 136)
|
||||
Updated : xxHash to r35
|
||||
|
||||
r119:
|
||||
Fix : Issue 134 : extended malicious address space overflow in 32-bits mode for some specific configurations
|
||||
|
||||
r118:
|
||||
New : LZ4 Streaming API (Fast version), special thanks to Takayuki Matsuoka
|
||||
New : datagen : parametrable synthetic data generator for tests
|
||||
Improved : fuzzer, support more test cases, more parameters, ability to jump to specific test
|
||||
fix : support ppc64le platform (issue 131)
|
||||
fix : Issue 52 (malicious address space overflow in 32-bits mode when using large custom format)
|
||||
fix : Makefile : minor issue 130 : header files permissions
|
||||
|
||||
r117:
|
||||
Added : man pages for lz4c and lz4cat
|
||||
Added : automated tests on Travis, thanks to Takayuki Matsuoka !
|
||||
fix : block-dependency command line (issue 127)
|
||||
fix : lz4fullbench (issue 128)
|
||||
|
||||
r116:
|
||||
hotfix (issue 124 & 125)
|
||||
|
||||
r115:
|
||||
Added : lz4cat utility, installed on POSX systems (issue 118)
|
||||
OS-X compatible compilation of dynamic library (issue 115)
|
||||
|
||||
r114:
|
||||
Makefile : library correctly compiled with -O3 switch (issue 114)
|
||||
Makefile : library compilation compatible with clang
|
||||
Makefile : library is versioned and linked (issue 119)
|
||||
lz4.h : no more static inline prototypes (issue 116)
|
||||
man : improved header/footer (issue 111)
|
||||
Makefile : Use system default $(CC) & $(MAKE) variables (issue 112)
|
||||
xxhash : updated to r34
|
||||
|
||||
r113:
|
||||
Large decompression speed improvement for GCC 32-bits. Thanks to Valery Croizier !
|
||||
LZ4HC : Compression Level is now a programmable parameter (CLI from 4 to 9)
|
||||
Separated IO routines from command line (lz4io.c)
|
||||
Version number into lz4.h (suggested by Francesc Alted)
|
||||
|
||||
r112:
|
||||
quickfix
|
||||
|
||||
r111 :
|
||||
Makefile : added capability to install libraries
|
||||
Modified Directory tree, to better separate libraries from programs.
|
||||
|
||||
r110 :
|
||||
lz4 & lz4hc : added capability to allocate state & stream state with custom allocator (issue 99)
|
||||
fuzzer & fullbench : updated to test new functions
|
||||
man : documented -l command (Legacy format, for Linux kernel compression) (issue 102)
|
||||
cmake : improved version by Mika Attila, building programs and libraries (issue 100)
|
||||
xxHash : updated to r33
|
||||
Makefile : clean also delete local package .tar.gz
|
||||
|
||||
r109 :
|
||||
lz4.c : corrected issue 98 (LZ4_compress_limitedOutput())
|
||||
Makefile : can specify version number from makefile
|
||||
|
||||
r108 :
|
||||
lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting)
|
||||
|
||||
r107 :
|
||||
Makefile : support DESTDIR for staged installs. Thanks Jorge Aparicio.
|
||||
Makefile : make install installs both lz4 and lz4c (Jorge Aparicio)
|
||||
Makefile : removed -Wno-implicit-declaration compilation switch
|
||||
lz4cli.c : include <stduni.h> for isatty() (Luca Barbato)
|
||||
lz4.h : introduced LZ4_MAX_INPUT_SIZE constant (Shay Green)
|
||||
lz4.h : LZ4_compressBound() : unified macro and inline definitions (Shay Green)
|
||||
lz4.h : LZ4_decompressSafe_partial() : clarify comments (Shay Green)
|
||||
lz4.c : LZ4_compress() verify input size condition (Shay Green)
|
||||
bench.c : corrected a bug in free memory size evaluation
|
||||
cmake : install into bin/ directory (Richard Yao)
|
||||
cmake : check for just C compiler (Elan Ruusamae)
|
||||
|
||||
r106 :
|
||||
Makefile : make dist modify text files in the package to respect Unix EoL convention
|
||||
lz4cli.c : corrected small display bug in HC mode
|
||||
|
||||
r105 :
|
||||
Makefile : New install script and man page, contributed by Prasad Pandit
|
||||
lz4cli.c : Minor modifications, for easier extensibility
|
||||
COPYING : added license file
|
||||
LZ4_Streaming_Format.odt : modified file name to remove white space characters
|
||||
Makefile : .exe suffix now properly added only for Windows target
|
|
@ -1,7 +0,0 @@
|
|||
This iz the lz4 tree copied in:
|
||||
http://lz4.googlecode.com/svn/trunk
|
||||
by:
|
||||
yann.collet.73@gmail.com
|
||||
Copyright/licensing info in source files here.
|
||||
|
||||
this was from revision 84.
|
|
@ -0,0 +1,19 @@
|
|||
LZ4 - Library Files
|
||||
================================
|
||||
|
||||
This directory contains many files, but you don't necessarily need them all.
|
||||
|
||||
If you want to integrate LZ4 compression/decompression into your program, you basically need to include "**lz4.c**" and "**lz4.h**" only.
|
||||
|
||||
If you want more compression, at the cost of compression speed (but preserving decompression speed), you will also have to include "**lz4hc.c**" and "**lz4hc.h**". Note that lz4hc needs lz4 to work properly.
|
||||
|
||||
Next level, if you want to produce files or data streams compatible with lz4 utility, you will have to use and include "**lz4frame.c**" and **lz4frame.h**". This library encapsulate lz4-compressed blocks into the official interoperable frame format. In order to work properly, lz4frame needs lz4 and lz4hc, and also "**xxhash.c**" and "**xxhash.h**", which provide the error detection algorithm.
|
||||
|
||||
A more complex "lz4frame_static.h" is also provided, although its usage is not recommended. It contains definitions which are not guaranteed to remain stable within future versions. Use only if you don't plan to update your lz4 version.
|
||||
|
||||
The other files are not source code. There are :
|
||||
|
||||
- LICENSE : contains the BSD license text
|
||||
- Makefile : script to compile or install lz4 library (static or dynamic)
|
||||
- liblz4.pc.in : for pkg-config (make install)
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,8 @@
|
|||
/*
|
||||
LZ4 - Fast LZ compression algorithm
|
||||
Header File
|
||||
Copyright (C) 2011-2014, Yann Collet.
|
||||
Copyright (C) 2011-2015, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -28,7 +29,7 @@
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 source repository : http://code.google.com/p/lz4/
|
||||
- LZ4 source repository : https://github.com/Cyan4973/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
*/
|
||||
#pragma once
|
||||
|
@ -37,17 +38,23 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* lz4.h provides block compression functions, for optimal performance.
|
||||
* If you need to generate inter-operable compressed data (respecting LZ4 frame specification),
|
||||
* please use lz4frame.h instead.
|
||||
*/
|
||||
|
||||
/**************************************
|
||||
Version
|
||||
* Version
|
||||
**************************************/
|
||||
#define LZ4_VERSION_MAJOR 1 /* for major interface/format changes */
|
||||
#define LZ4_VERSION_MINOR 2 /* for minor interface/format changes */
|
||||
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
||||
#define LZ4_VERSION_MINOR 6 /* for new (non-breaking) interface capabilities */
|
||||
#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
|
||||
|
||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
||||
int LZ4_versionNumber (void);
|
||||
|
||||
/**************************************
|
||||
Tuning parameter
|
||||
* Tuning parameter
|
||||
**************************************/
|
||||
/*
|
||||
* LZ4_MEMORY_USAGE :
|
||||
|
@ -60,52 +67,45 @@ extern "C" {
|
|||
|
||||
|
||||
/**************************************
|
||||
Simple Functions
|
||||
* Simple Functions
|
||||
**************************************/
|
||||
|
||||
int LZ4_compress (const char* source, char* dest, int inputSize);
|
||||
int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxOutputSize);
|
||||
int LZ4_compress (const char* source, char* dest, int sourceSize);
|
||||
int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
||||
|
||||
/*
|
||||
LZ4_compress() :
|
||||
Compresses 'inputSize' bytes from 'source' into 'dest'.
|
||||
Compresses 'sourceSize' bytes from 'source' into 'dest'.
|
||||
Destination buffer must be already allocated,
|
||||
and must be sized to handle worst cases situations (input data not compressible)
|
||||
Worst case size evaluation is provided by function LZ4_compressBound()
|
||||
inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
||||
inputSize : Max supported value is LZ4_MAX_INPUT_SIZE
|
||||
return : the number of bytes written in buffer dest
|
||||
or 0 if the compression fails
|
||||
|
||||
LZ4_decompress_safe() :
|
||||
compressedSize : is obviously the source size
|
||||
maxOutputSize : is the size of the destination buffer, which must be already allocated.
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
|
||||
maxDecompressedSize : is the size of the destination buffer, which must be already allocated.
|
||||
return : the number of bytes decompressed into the destination buffer (necessarily <= maxDecompressedSize)
|
||||
If the destination buffer is not large enough, decoding will stop and output an error code (<0).
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
This function is protected against buffer overflow exploits :
|
||||
it never writes outside of output buffer, and never reads outside of input buffer.
|
||||
Therefore, it is protected against malicious data packets.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Note :
|
||||
Should you prefer to explicitly allocate compression-table memory using your own allocation method,
|
||||
use the streaming functions provided below, simply reset the memory area between each call to LZ4_compress_continue()
|
||||
This function is protected against buffer overflow exploits,
|
||||
and never writes outside of output buffer, nor reads outside of input buffer.
|
||||
It is also protected against malicious data packets.
|
||||
*/
|
||||
|
||||
|
||||
/**************************************
|
||||
Advanced Functions
|
||||
* Advanced Functions
|
||||
**************************************/
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
||||
|
||||
/*
|
||||
LZ4_compressBound() :
|
||||
Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
|
||||
primarily useful for memory allocation of output buffer.
|
||||
macro is also provided when result needs to be evaluated at compilation (such as stack memory allocation).
|
||||
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
||||
This function is primarily useful for memory allocation purposes (output buffer size).
|
||||
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
|
||||
|
||||
isize : is the input size. Max supported value is LZ4_MAX_INPUT_SIZE
|
||||
return : maximum output size in a "worst case" scenario
|
||||
|
@ -116,28 +116,40 @@ int LZ4_compressBound(int isize);
|
|||
|
||||
/*
|
||||
LZ4_compress_limitedOutput() :
|
||||
Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
|
||||
Compress 'sourceSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
|
||||
If it cannot achieve it, compression will stop, and result of the function will be zero.
|
||||
This saves time and memory on detecting non-compressible (or barely compressible) data.
|
||||
This function never writes outside of provided output buffer.
|
||||
|
||||
inputSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
||||
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
||||
maxOutputSize : is the size of the destination buffer (which must be already allocated)
|
||||
return : the number of bytes written in buffer 'dest'
|
||||
or 0 if the compression fails
|
||||
or 0 if compression fails
|
||||
*/
|
||||
int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
|
||||
|
||||
|
||||
/*
|
||||
LZ4_compress_withState() :
|
||||
Same compression functions, but using an externally allocated memory space to store compression state.
|
||||
Use LZ4_sizeofState() to know how much memory must be allocated,
|
||||
and then, provide it as 'void* state' to compression functions.
|
||||
*/
|
||||
int LZ4_sizeofState(void);
|
||||
int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
|
||||
/*
|
||||
LZ4_decompress_fast() :
|
||||
originalSize : is the original and therefore uncompressed size
|
||||
return : the number of bytes read from the source buffer (in other words, the compressed size)
|
||||
If the source stream is malformed, the function will stop decoding and return a negative result.
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
|
||||
note : This function is a bit faster than LZ4_decompress_safe()
|
||||
It provides fast decompression and fully respect memory boundaries for properly formed compressed data.
|
||||
It does not provide full protection against intentionnally modified data stream.
|
||||
Use this function in a trusted environment (data to decode comes from a trusted source).
|
||||
note : This function fully respect memory boundaries for properly formed compressed data.
|
||||
It is a bit faster than LZ4_decompress_safe().
|
||||
However, it does not provide any protection against intentionally modified data stream (malicious input).
|
||||
Use this function in trusted environment only (data to decode comes from a trusted source).
|
||||
*/
|
||||
int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
||||
|
||||
|
@ -145,117 +157,120 @@ int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
|||
/*
|
||||
LZ4_decompress_safe_partial() :
|
||||
This function decompress a compressed block of size 'compressedSize' at position 'source'
|
||||
into output buffer 'dest' of size 'maxOutputSize'.
|
||||
into destination buffer 'dest' of size 'maxDecompressedSize'.
|
||||
The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
|
||||
reducing decompression time.
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
|
||||
return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize)
|
||||
Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
|
||||
Always control how many bytes were decoded.
|
||||
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
|
||||
*/
|
||||
int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxOutputSize);
|
||||
int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
|
||||
|
||||
|
||||
/***********************************************
|
||||
Experimental Streaming Compression Functions
|
||||
* Streaming Compression Functions
|
||||
***********************************************/
|
||||
|
||||
#define LZ4_STREAMSIZE_U32 ((1 << (LZ4_MEMORY_USAGE-2)) + 8)
|
||||
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U32 * sizeof(unsigned int))
|
||||
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
|
||||
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
|
||||
/*
|
||||
* LZ4_stream_t
|
||||
* information structure to track an LZ4 stream.
|
||||
* important : set this structure content to zero before first use !
|
||||
* important : init this structure content before first use !
|
||||
* note : only allocated directly the structure if you are statically linking LZ4
|
||||
* If you are using liblz4 as a DLL, please use below construction methods instead.
|
||||
*/
|
||||
typedef struct { unsigned int table[LZ4_STREAMSIZE_U32]; } LZ4_stream_t;
|
||||
typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t;
|
||||
|
||||
/*
|
||||
* If you prefer dynamic allocation methods,
|
||||
* LZ4_createStream
|
||||
* provides a pointer (void*) towards an initialized LZ4_stream_t structure.
|
||||
* LZ4_free just frees it.
|
||||
* LZ4_resetStream
|
||||
* Use this function to init an allocated LZ4_stream_t structure
|
||||
*/
|
||||
void* LZ4_createStream();
|
||||
int LZ4_free (void* LZ4_stream);
|
||||
void LZ4_resetStream (LZ4_stream_t* LZ4_streamPtr);
|
||||
|
||||
/*
|
||||
* LZ4_createStream will allocate and initialize an LZ4_stream_t structure
|
||||
* LZ4_freeStream releases its memory.
|
||||
* In the context of a DLL (liblz4), please use these methods rather than the static struct.
|
||||
* They are more future proof, in case of a change of LZ4_stream_t size.
|
||||
*/
|
||||
LZ4_stream_t* LZ4_createStream(void);
|
||||
int LZ4_freeStream (LZ4_stream_t* LZ4_streamPtr);
|
||||
|
||||
/*
|
||||
* LZ4_loadDict
|
||||
* Use this function to load a static dictionary into LZ4_stream.
|
||||
* Any previous data will be forgotten, only 'dictionary' will remain in memory.
|
||||
* Loading a size of 0 is allowed (same effect as init).
|
||||
* Return : 1 if OK, 0 if error
|
||||
* Loading a size of 0 is allowed.
|
||||
* Return : dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
int LZ4_loadDict (void* LZ4_stream, const char* dictionary, int dictSize);
|
||||
int LZ4_loadDict (LZ4_stream_t* LZ4_streamPtr, const char* dictionary, int dictSize);
|
||||
|
||||
/*
|
||||
* LZ4_compress_continue
|
||||
* Compress data block 'source', using blocks compressed before as dictionary to improve compression ratio
|
||||
* Previous data blocks are assumed to still be present at their previous location.
|
||||
* dest buffer must be already allocated, and sized to at least LZ4_compressBound(inputSize)
|
||||
*/
|
||||
int LZ4_compress_continue (void* LZ4_stream, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
|
||||
|
||||
/*
|
||||
* LZ4_compress_limitedOutput_continue
|
||||
* Same as before, but also specify a maximum target compressed size (maxOutputSize)
|
||||
* If objective cannot be met, compression exits, and returns a zero.
|
||||
*/
|
||||
int LZ4_compress_limitedOutput_continue (void* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/*
|
||||
* LZ4_saveDict
|
||||
* If previously compressed data block is not guaranteed to remain at its previous memory location
|
||||
* save it into a safe place (char* safeBuffer)
|
||||
* If previously compressed data block is not guaranteed to remain available at its memory location
|
||||
* save it into a safer place (char* safeBuffer)
|
||||
* Note : you don't need to call LZ4_loadDict() afterwards,
|
||||
* dictionary is immediately usable, you can therefore call again LZ4_compress_continue()
|
||||
* Return : 1 if OK, 0 if error
|
||||
* Note : any dictSize > 64 KB will be interpreted as 64KB.
|
||||
* Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error
|
||||
*/
|
||||
int LZ4_saveDict (void* LZ4_stream, char* safeBuffer, int dictSize);
|
||||
int LZ4_saveDict (LZ4_stream_t* LZ4_streamPtr, char* safeBuffer, int dictSize);
|
||||
|
||||
|
||||
/************************************************
|
||||
Experimental Streaming Decompression Functions
|
||||
* Streaming Decompression Functions
|
||||
************************************************/
|
||||
|
||||
#define LZ4_STREAMDECODESIZE_U32 4
|
||||
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U32 * sizeof(unsigned int))
|
||||
#define LZ4_STREAMDECODESIZE_U64 4
|
||||
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
|
||||
typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_streamDecode_t;
|
||||
/*
|
||||
* LZ4_streamDecode_t
|
||||
* information structure to track an LZ4 stream.
|
||||
* important : set this structure content to zero before first use !
|
||||
* init this structure content using LZ4_setStreamDecode or memset() before first use !
|
||||
*
|
||||
* In the context of a DLL (liblz4) please prefer usage of construction methods below.
|
||||
* They are more future proof, in case of a change of LZ4_streamDecode_t size in the future.
|
||||
* LZ4_createStreamDecode will allocate and initialize an LZ4_streamDecode_t structure
|
||||
* LZ4_freeStreamDecode releases its memory.
|
||||
*/
|
||||
typedef struct { unsigned int table[LZ4_STREAMDECODESIZE_U32]; } LZ4_streamDecode_t;
|
||||
LZ4_streamDecode_t* LZ4_createStreamDecode(void);
|
||||
int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
|
||||
|
||||
/*
|
||||
* If you prefer dynamic allocation methods,
|
||||
* LZ4_createStreamDecode()
|
||||
* provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure.
|
||||
* LZ4_free just frees it.
|
||||
* LZ4_setStreamDecode
|
||||
* Use this function to instruct where to find the dictionary.
|
||||
* Setting a size of 0 is allowed (same effect as reset).
|
||||
* Return : 1 if OK, 0 if error
|
||||
*/
|
||||
void* LZ4_createStreamDecode();
|
||||
int LZ4_free (void* LZ4_stream); /* yes, it's the same one as for compression */
|
||||
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
|
||||
|
||||
/*
|
||||
*_continue() :
|
||||
These decoding functions allow decompression of multiple blocks in "streaming" mode.
|
||||
Previously decoded blocks must still be available at the memory position where they were decoded.
|
||||
If it's not possible, save the relevant part of decoded data into a safe buffer,
|
||||
and indicate where it stands using LZ4_setDictDecode()
|
||||
Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB)
|
||||
If this condition is not possible, save the relevant part of decoded data into a safe buffer,
|
||||
and indicate where is its new address using LZ4_setStreamDecode()
|
||||
*/
|
||||
int LZ4_decompress_safe_continue (void* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize);
|
||||
int LZ4_decompress_fast_continue (void* LZ4_streamDecode, const char* source, char* dest, int originalSize);
|
||||
|
||||
/*
|
||||
* LZ4_setDictDecode
|
||||
* Use this function to instruct where to find the dictionary.
|
||||
* This function can be used to specify a static dictionary,
|
||||
* or to instruct where to find some previously decoded data saved into a different memory space.
|
||||
* Setting a size of 0 is allowed (same effect as no dictionary).
|
||||
* Return : 1 if OK, 0 if error
|
||||
*/
|
||||
int LZ4_setDictDecode (void* LZ4_streamDecode, const char* dictionary, int dictSize);
|
||||
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
||||
int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -263,17 +278,15 @@ Advanced decoding functions :
|
|||
*_usingDict() :
|
||||
These decoding functions work the same as
|
||||
a combination of LZ4_setDictDecode() followed by LZ4_decompress_x_continue()
|
||||
all together into a single function call.
|
||||
It doesn't use nor update an LZ4_streamDecode_t structure.
|
||||
They are stand-alone and don't use nor update an LZ4_streamDecode_t structure.
|
||||
*/
|
||||
int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxOutputSize, const char* dictStart, int dictSize);
|
||||
int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
|
||||
int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************
|
||||
Obsolete Functions
|
||||
* Obsolete Functions
|
||||
**************************************/
|
||||
/*
|
||||
Obsolete decompression functions
|
||||
|
@ -281,14 +294,11 @@ These function names are deprecated and should no longer be used.
|
|||
They are only provided here for compatibility with older user programs.
|
||||
- LZ4_uncompress is the same as LZ4_decompress_fast
|
||||
- LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe
|
||||
*/
|
||||
int LZ4_uncompress (const char* source, char* dest, int outputSize);
|
||||
int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
|
||||
These function prototypes are now disabled; uncomment them if you really need them.
|
||||
It is highly recommended to stop using these functions and migrate to newer ones */
|
||||
/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */
|
||||
/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */
|
||||
|
||||
/* Obsolete functions for externally allocated state; use streaming interface instead */
|
||||
int LZ4_sizeofState(void);
|
||||
int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/* Obsolete streaming functions; use new streaming interface whenever possible */
|
||||
void* LZ4_create (const char* inputBuffer);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LZ4 HC - High Compression Mode of LZ4
|
||||
Header File
|
||||
Copyright (C) 2011-2014, Yann Collet.
|
||||
Copyright (C) 2011-2015, Yann Collet.
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -28,8 +28,8 @@
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
|
||||
- LZ4 source repository : http://code.google.com/p/lz4/
|
||||
- LZ4 source repository : https://github.com/Cyan4973/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
@ -74,12 +74,12 @@ int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize
|
|||
*/
|
||||
|
||||
/* Note :
|
||||
Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
|
||||
Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
|
||||
*/
|
||||
|
||||
|
||||
/**************************************
|
||||
Using an external allocation
|
||||
* Using an external allocation
|
||||
**************************************/
|
||||
int LZ4_sizeofStateHC(void);
|
||||
int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
|
||||
|
@ -95,78 +95,85 @@ int LZ4_sizeofStateHC();
|
|||
|
||||
Note that tables must be aligned for pointer (32 or 64 bits), otherwise compression will fail (return code 0).
|
||||
|
||||
The allocated memory can be provided to the compressions functions using 'void* state' parameter.
|
||||
The allocated memory can be provided to the compression functions using 'void* state' parameter.
|
||||
LZ4_compress_withStateHC() and LZ4_compress_limitedOutput_withStateHC() are equivalent to previously described functions.
|
||||
They just use the externally allocated memory area instead of allocating their own (on stack, or on heap).
|
||||
They just use the externally allocated memory for state instead of allocating their own (on stack, or on heap).
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*****************************
|
||||
* Includes
|
||||
*****************************/
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
|
||||
/**************************************
|
||||
Streaming Functions
|
||||
* Experimental Streaming Functions
|
||||
**************************************/
|
||||
/* Note : these streaming functions still follows the older model */
|
||||
#define LZ4_STREAMHCSIZE 262192
|
||||
#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
|
||||
typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t;
|
||||
/*
|
||||
LZ4_streamHC_t
|
||||
This structure allows static allocation of LZ4 HC streaming state.
|
||||
State must then be initialized using LZ4_resetStreamHC() before first use.
|
||||
|
||||
Static allocation should only be used with statically linked library.
|
||||
If you want to use LZ4 as a DLL, please use construction functions below, which are more future-proof.
|
||||
*/
|
||||
|
||||
|
||||
LZ4_streamHC_t* LZ4_createStreamHC(void);
|
||||
int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr);
|
||||
/*
|
||||
These functions create and release memory for LZ4 HC streaming state.
|
||||
Newly created states are already initialized.
|
||||
Existing state space can be re-used anytime using LZ4_resetStreamHC().
|
||||
If you use LZ4 as a DLL, please use these functions instead of direct struct allocation,
|
||||
to avoid size mismatch between different versions.
|
||||
*/
|
||||
|
||||
void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||
int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int dictSize);
|
||||
|
||||
int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int maxDictSize);
|
||||
|
||||
/*
|
||||
These functions compress data in successive blocks of any size, using previous blocks as dictionary.
|
||||
One key assumption is that each previous block will remain read-accessible while compressing next block.
|
||||
|
||||
Before starting compression, state must be properly initialized, using LZ4_resetStreamHC().
|
||||
A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional).
|
||||
|
||||
Then, use LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue() to compress each successive block.
|
||||
They work like usual LZ4_compressHC() or LZ4_compressHC_limitedOutput(), but use previous memory blocks to improve compression.
|
||||
Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression.
|
||||
|
||||
If, for any reason, previous data block can't be preserved in memory during next compression block,
|
||||
you must save it to a safer memory space,
|
||||
using LZ4_saveDictHC().
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**************************************
|
||||
* Deprecated Streaming Functions
|
||||
* ************************************/
|
||||
/* Note : these streaming functions follows the older model, and should no longer be used */
|
||||
void* LZ4_createHC (const char* inputBuffer);
|
||||
int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
|
||||
int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
||||
int LZ4_freeHC (void* LZ4HC_Data);
|
||||
|
||||
int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
|
||||
/*
|
||||
These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
|
||||
In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function :
|
||||
|
||||
void* LZ4_createHC (const char* inputBuffer);
|
||||
The result of the function is the (void*) pointer on the LZ4HC Data Structure.
|
||||
This pointer will be needed in all other functions.
|
||||
If the pointer returned is NULL, then the allocation has failed, and compression must be aborted.
|
||||
The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
|
||||
The input buffer must be already allocated, and size at least 192KB.
|
||||
'inputBuffer' will also be the 'const char* source' of the first block.
|
||||
|
||||
All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'.
|
||||
To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue().
|
||||
Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(),
|
||||
but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one.
|
||||
If next block does not begin immediately after the previous one, the compression will fail (return 0).
|
||||
|
||||
When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to :
|
||||
char* LZ4_slideInputBufferHC(void* LZ4HC_Data);
|
||||
must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer.
|
||||
Note that, for this function to work properly, minimum size of an input buffer must be 192KB.
|
||||
==> The memory position where the next input data block must start is provided as the result of the function.
|
||||
|
||||
Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual.
|
||||
|
||||
When compression is completed, a call to LZ4_freeHC() will release the memory used by the LZ4HC Data Structure.
|
||||
*/
|
||||
|
||||
int LZ4_sizeofStreamStateHC(void);
|
||||
int LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
|
||||
|
||||
/*
|
||||
These functions achieve the same result as :
|
||||
void* LZ4_createHC (const char* inputBuffer);
|
||||
|
||||
They are provided here to allow the user program to allocate memory using its own routines.
|
||||
|
||||
To know how much space must be allocated, use LZ4_sizeofStreamStateHC();
|
||||
Note also that space must be aligned for pointers (32 or 64 bits).
|
||||
|
||||
Once space is allocated, you must initialize it using : LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
|
||||
void* state is a pointer to the space allocated.
|
||||
It must be aligned for pointers (32 or 64 bits), and be large enough.
|
||||
The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
|
||||
The input buffer must be already allocated, and size at least 192KB.
|
||||
'inputBuffer' will also be the 'const char* source' of the first block.
|
||||
|
||||
The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState().
|
||||
return value of LZ4_resetStreamStateHC() must be 0 is OK.
|
||||
Any other value means there was an error (typically, state is not aligned for pointers (32 or 64 bits)).
|
||||
*/
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue