Rizin
unix-like reverse engineering framework and cli tools
|
#include <stdlib.h>
#include <string.h>
#include "lz4frame.h"
#include "lz4.h"
#include "lz4hc.h"
#include "xxhash.h"
Go to the source code of this file.
Classes | |
struct | LZ4F_cctx_s |
struct | LZ4F_CDict_s |
struct | LZ4F_dctx_s |
Macros | |
#define | LZ4F_HEAPMODE 0 |
#define | ALLOC(s) malloc(s) |
#define | ALLOC_AND_ZERO(s) calloc(1,(s)) |
#define | FREEMEM(p) free(p) |
#define | MEM_INIT(p, v, s) memset((p),(v),(s)) |
#define | LZ4F_STATIC_LINKING_ONLY |
#define | LZ4_STATIC_LINKING_ONLY |
#define | LZ4_HC_STATIC_LINKING_ONLY |
#define | XXH_STATIC_LINKING_ONLY |
#define | assert(condition) ((void)0) |
#define | LZ4F_STATIC_ASSERT(c) { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ |
#define | DEBUGLOG(l, ...) {} /* disabled */ |
#define | _1BIT 0x01 |
#define | _2BITS 0x03 |
#define | _3BITS 0x07 |
#define | _4BITS 0x0F |
#define | _8BITS 0xFF |
#define | LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U |
#define | LZ4F_MAGICNUMBER 0x184D2204U |
#define | LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U |
#define | LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB |
#define | LZ4F_GENERATE_STRING(STRING) #STRING, |
#define | MIN(a, b) ( (a) < (b) ? (a) : (b) ) |
Typedefs | |
typedef unsigned char | BYTE |
typedef unsigned short | U16 |
typedef unsigned int | U32 |
typedef signed int | S32 |
typedef unsigned long long | U64 |
typedef struct LZ4F_cctx_s | LZ4F_cctx_t |
typedef int(* | compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict) |
Variables | |
static const size_t | minFHSize = LZ4F_HEADER_SIZE_MIN |
static const size_t | maxFHSize = LZ4F_HEADER_SIZE_MAX |
static const size_t | BHSize = LZ4F_BLOCK_HEADER_SIZE |
static const size_t | BFSize = LZ4F_BLOCK_CHECKSUM_SIZE |
static const char * | LZ4F_errorStrings [] = { LZ4F_LIST_ERRORS(LZ4F_GENERATE_STRING) } |
#define _1BIT 0x01 |
Definition at line 203 of file lz4frame.c.
#define _2BITS 0x03 |
Definition at line 204 of file lz4frame.c.
#define _3BITS 0x07 |
Definition at line 205 of file lz4frame.c.
#define _4BITS 0x0F |
Definition at line 206 of file lz4frame.c.
#define _8BITS 0xFF |
Definition at line 207 of file lz4frame.c.
Definition at line 76 of file lz4frame.c.
Definition at line 77 of file lz4frame.c.
#define assert | ( | condition | ) | ((void)0) |
Definition at line 107 of file lz4frame.c.
#define DEBUGLOG | ( | l, | |
... | |||
) | {} /* disabled */ |
Definition at line 123 of file lz4frame.c.
Definition at line 78 of file lz4frame.c.
#define LZ4_HC_STATIC_LINKING_ONLY |
Definition at line 94 of file lz4frame.c.
#define LZ4_STATIC_LINKING_ONLY |
Definition at line 92 of file lz4frame.c.
#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB |
Definition at line 212 of file lz4frame.c.
#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U |
Definition at line 211 of file lz4frame.c.
#define LZ4F_GENERATE_STRING | ( | STRING | ) | #STRING, |
Definition at line 245 of file lz4frame.c.
#define LZ4F_HEAPMODE 0 |
Definition at line 61 of file lz4frame.c.
#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U |
Definition at line 209 of file lz4frame.c.
#define LZ4F_MAGICNUMBER 0x184D2204U |
Definition at line 210 of file lz4frame.c.
#define LZ4F_STATIC_ASSERT | ( | c | ) | { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ |
Definition at line 111 of file lz4frame.c.
#define LZ4F_STATIC_LINKING_ONLY |
Definition at line 90 of file lz4frame.c.
#define XXH_STATIC_LINKING_ONLY |
Definition at line 96 of file lz4frame.c.
Definition at line 138 of file lz4frame.c.
typedef int(* compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict) |
Definition at line 733 of file lz4frame.c.
typedef struct LZ4F_cctx_s LZ4F_cctx_t |
Definition at line 141 of file lz4frame.c.
Definition at line 139 of file lz4frame.c.
Definition at line 140 of file lz4frame.c.
enum dStage_t |
Definition at line 1029 of file lz4frame.c.
enum LZ4F_lastBlockStatus |
|
static |
Definition at line 267 of file lz4frame.c.
References LZ4F_STATIC_ASSERT.
Referenced by LZ4F_compressBegin_usingCDict(), LZ4F_compressEnd(), LZ4F_compressFrame_usingCDict(), LZ4F_compressUpdate(), LZ4F_createCompressionContext(), LZ4F_createDecompressionContext(), LZ4F_decodeHeader(), LZ4F_decompress(), LZ4F_flush(), LZ4F_getBlockSize(), LZ4F_getFrameInfo(), and LZ4F_headerSize().
size_t LZ4F_compressBegin | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_preferences_t * | preferencesPtr | ||
) |
LZ4F_compressBegin() : init streaming compression and writes frame header into dstBuffer. dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes. preferencesPtr can be NULL, in which case default parameters are selected.
Definition at line 710 of file lz4frame.c.
References LZ4F_compressBegin_usingCDict(), and NULL.
Referenced by basicTests(), compress_file_internal(), and fuzzerTests().
size_t LZ4F_compressBegin_usingCDict | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_CDict * | cdict, | ||
const LZ4F_preferences_t * | preferencesPtr | ||
) |
LZ4F_compressBegin_usingCDict() : init streaming compression and writes frame header into dstBuffer. dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes.
Definition at line 598 of file lz4frame.c.
References _1BIT, _2BITS, _3BITS, ALLOC_AND_ZERO, LZ4F_preferences_t::autoFlush, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, LZ4F_cctx_s::cdict, LZ4F_preferences_t::compressionLevel, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, LZ4F_cctx_s::cStage, LZ4F_frameInfo_t::dictID, err0r(), LZ4F_preferences_t::favorDecSpeed, LZ4F_preferences_t::frameInfo, FREEMEM, KB, LZ4_createStream(), LZ4_createStreamHC(), LZ4_favorDecompressionSpeed(), LZ4_initStream(), LZ4_initStreamHC(), LZ4_setCompressionLevel(), LZ4F_cctx_s::lz4CtxAlloc, LZ4F_cctx_s::lz4CtxPtr, LZ4F_cctx_s::lz4CtxState, LZ4F_blockLinked, LZ4F_BLOCKSIZEID_DEFAULT, LZ4F_getBlockSize(), LZ4F_headerChecksum(), LZ4F_initStream(), LZ4F_MAGICNUMBER, LZ4F_writeLE32(), LZ4F_writeLE64(), LZ4HC_CLEVEL_MIN, LZ4F_cctx_s::maxBlockSize, LZ4F_cctx_s::maxBufferSize, maxFHSize, MEM_INIT, NULL, LZ4F_cctx_s::prefs, LZ4F_cctx_s::tmpBuff, LZ4F_cctx_s::tmpIn, LZ4F_cctx_s::tmpInSize, LZ4F_cctx_s::totalInSize, unsigned, LZ4F_cctx_s::xxh, and XXH32_reset().
Referenced by LZ4F_compressBegin(), LZ4F_compressFrame_usingCDict(), and LZ4IO_compressFilename_extRess().
|
static |
Definition at line 766 of file lz4frame.c.
References dst, level, LZ4_compress_fast_continue(), LZ4_compress_fast_extState_fastReset(), LZ4F_blockIndependent, LZ4F_initStream(), src, and srcSize.
Referenced by LZ4F_selectCompression().
|
static |
Definition at line 777 of file lz4frame.c.
References dst, level, LZ4_compress_fast_continue(), src, and srcSize.
Referenced by LZ4F_selectCompression().
|
static |
Definition at line 784 of file lz4frame.c.
References dst, level, LZ4_compress_HC_continue(), LZ4_compress_HC_extStateHC_fastReset(), LZ4F_blockIndependent, LZ4F_initStream(), src, and srcSize.
Referenced by LZ4F_selectCompression().
|
static |
Definition at line 793 of file lz4frame.c.
References dst, level, LZ4_compress_HC_continue(), src, and srcSize.
Referenced by LZ4F_selectCompression().
size_t LZ4F_compressBound | ( | size_t | srcSize, |
const LZ4F_preferences_t * | prefsPtr | ||
) |
LZ4F_compressBound() : Provides minimum dstCapacity required to guarantee success of LZ4F_compressUpdate(), given a srcSize and preferences, for a worst case scenario. When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() instead. Note that the result is only valid for a single invocation of LZ4F_compressUpdate(). When invoking LZ4F_compressUpdate() multiple times, if the output buffer is gradually filled up instead of emptied and re-used from its start, one must check if there is enough remaining capacity before each invocation, using LZ4F_compressBound().
Definition at line 724 of file lz4frame.c.
References LZ4F_preferences_t::autoFlush, LZ4F_compressBound_internal(), and srcSize.
Referenced by basicTests(), compress_file(), compress_file_internal(), and fuzzerTests().
|
static |
LZ4F_compressBound_internal() : Provides dstCapacity given a srcSize to guarantee operation success in worst case situations. prefsPtr is optional : if NULL is provided, preferences will be set to cover worst case scenario.
Definition at line 324 of file lz4frame.c.
References LZ4F_preferences_t::autoFlush, BFSize, BHSize, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockSizeID, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_preferences_t::frameInfo, LZ4F_blockChecksumEnabled, LZ4F_contentChecksumEnabled, LZ4F_getBlockSize(), LZ4F_INIT_PREFERENCES, MIN, NULL, srcSize, and unsigned.
Referenced by LZ4F_compressBound(), LZ4F_compressFrameBound(), and LZ4F_compressUpdate().
size_t LZ4F_compressEnd | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr | ||
) |
LZ4F_compressEnd() : When you want to properly finish the compressed frame, just call LZ4F_compressEnd(). It will flush whatever data remained within compressionContext (like LZ4_flush()) but also properly finalize the frame, with an endMark and an (optional) checksum. LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
Definition at line 986 of file lz4frame.c.
References assert, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, LZ4F_cctx_s::cStage, DEBUGLOG, err0r(), LZ4F_preferences_t::frameInfo, LZ4F_contentChecksumEnabled, LZ4F_flush(), LZ4F_isError(), LZ4F_writeLE32(), LZ4F_cctx_s::maxBufferSize, LZ4F_cctx_s::prefs, LZ4F_cctx_s::totalInSize, LZ4F_cctx_s::xxh, and XXH32_digest().
Referenced by basicTests(), compress_file_internal(), fuzzerTests(), LZ4F_compressFrame_usingCDict(), and LZ4IO_compressFilename_extRess().
size_t LZ4F_compressFrame | ( | void * | dstBuffer, |
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_preferences_t * | preferencesPtr | ||
) |
LZ4F_compressFrame() : Compress an entire srcBuffer into a valid LZ4 frame, in a single step. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you can provide NULL as argument. All preferences will be set to default.
Definition at line 429 of file lz4frame.c.
References LZ4F_preferences_t::compressionLevel, DEBUGLOG, FREEMEM, LZ4_initStream(), LZ4F_cctx_s::lz4CtxAlloc, LZ4F_cctx_s::lz4CtxPtr, LZ4F_cctx_s::lz4CtxState, LZ4F_compressFrame_usingCDict(), LZ4F_createCompressionContext(), LZ4F_freeCompressionContext(), LZ4F_isError(), LZ4F_VERSION, LZ4HC_CLEVEL_MIN, LZ4F_cctx_s::maxBufferSize, MB, MEM_INIT, NULL, srcSize, and LZ4F_cctx_s::version.
Referenced by basicTests(), fullSpeedBench(), fuzzerTests(), LLVMFuzzerTestOneInput(), and local_LZ4F_compressFrame().
size_t LZ4F_compressFrame_usingCDict | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_CDict * | cdict, | ||
const LZ4F_preferences_t * | preferencesPtr | ||
) |
LZ4F_compressFrame_usingCDict() : Compress srcBuffer using a dictionary, in a single step. cdict can be NULL, in which case, no dictionary is used. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you may provide NULL as argument, however, it's the only way to provide a dictID, so it's not recommended.
Definition at line 373 of file lz4frame.c.
References assert, LZ4F_preferences_t::autoFlush, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, LZ4F_frameInfo_t::contentSize, err0r(), LZ4F_preferences_t::frameInfo, LZ4F_blockIndependent, LZ4F_compressBegin_usingCDict(), LZ4F_compressEnd(), LZ4F_compressFrameBound(), LZ4F_compressUpdate(), LZ4F_getBlockSize(), LZ4F_isError(), LZ4F_optimalBSID(), MEM_INIT, NULL, options, and srcSize.
Referenced by basicTests(), LZ4F_compressFrame(), and LZ4IO_compressFilename_extRess().
size_t LZ4F_compressFrameBound | ( | size_t | srcSize, |
const LZ4F_preferences_t * | preferencesPtr | ||
) |
LZ4F_compressFrameBound() : Returns the maximum possible compressed size with LZ4F_compressFrame() given srcSize and preferences. preferencesPtr
is optional. It can be replaced by NULL, in which case, the function will assume default preferences. Note : this result is only usable with LZ4F_compressFrame(). It may also be used with LZ4F_compressUpdate() if no flush() operation is performed.
Definition at line 351 of file lz4frame.c.
References LZ4F_preferences_t::autoFlush, LZ4F_compressBound_internal(), maxFHSize, MEM_INIT, NULL, and srcSize.
Referenced by basicTests(), fuzzerTests(), LLVMFuzzerTestOneInput(), local_LZ4F_compressFrame(), LZ4F_compressFrame_usingCDict(), and LZ4IO_createCResources().
int LZ4F_compressionLevel_max | ( | void | ) |
size_t LZ4F_compressUpdate | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr | ||
) |
LZ4F_compressUpdate() : LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. dstBuffer MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
Definition at line 825 of file lz4frame.c.
References LZ4F_preferences_t::autoFlush, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_cctx_s::cdict, compress(), LZ4F_preferences_t::compressionLevel, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_cctx_s::cStage, DEBUGLOG, err0r(), LZ4F_preferences_t::frameInfo, fromSrcBuffer, fromTmpBuffer, LZ4F_cctx_s::lz4CtxPtr, LZ4F_blockLinked, LZ4F_compressBound_internal(), LZ4F_contentChecksumEnabled, LZ4F_localSaveDict(), LZ4F_makeBlock(), LZ4F_selectCompression(), LZ4F_cctx_s::maxBlockSize, LZ4F_cctx_s::maxBufferSize, MEM_INIT, memcpy(), notDone, NULL, LZ4F_cctx_s::prefs, srcSize, LZ4F_compressOptions_t::stableSrc, LZ4F_cctx_s::tmpBuff, LZ4F_cctx_s::tmpIn, LZ4F_cctx_s::tmpInSize, LZ4F_cctx_s::totalInSize, LZ4F_cctx_s::xxh, and XXH32_update().
Referenced by basicTests(), compress_file_internal(), fuzzerTests(), LZ4F_compressFrame_usingCDict(), and LZ4IO_compressFilename_extRess().
LZ4F_createCDict() : When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. LZ4F_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. LZ4F_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. dictBuffer
can be released after LZ4F_CDict creation, since its content is copied within CDict
Definition at line 490 of file lz4frame.c.
References ALLOC, DEBUGLOG, KB, LZ4_createStream(), LZ4_createStreamHC(), LZ4_loadDict(), LZ4_loadDictHC(), LZ4_setCompressionLevel(), LZ4F_freeCDict(), LZ4HC_CLEVEL_DEFAULT, memcpy(), and NULL.
Referenced by basicTests(), and LZ4IO_createCDict().
LZ4F_errorCode_t LZ4F_createCompressionContext | ( | LZ4F_cctx ** | LZ4F_compressionContextPtr, |
unsigned | version | ||
) |
LZ4F_createCompressionContext() : The first thing to do is to create a compressionContext object, which will be used in all compression operations. This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure. The version provided MUST be LZ4F_VERSION. It is intended to track potential incompatible differences between different binaries. The function will provide a pointer to an allocated LZ4F_compressionContext_t object. If the result LZ4F_errorCode_t is not OK_NoError, there was an error during context creation. Object can release its memory using LZ4F_freeCompressionContext();
Definition at line 536 of file lz4frame.c.
References ALLOC_AND_ZERO, LZ4F_cctx_s::cStage, err0r(), NULL, LZ4F_cctx_s::version, and version.
Referenced by basicTests(), compress_file(), fuzzerTests(), LZ4F_compressFrame(), and LZ4IO_createCResources().
LZ4F_errorCode_t LZ4F_createDecompressionContext | ( | LZ4F_dctx ** | LZ4F_decompressionContextPtr, |
unsigned | versionNumber | ||
) |
LZ4F_createDecompressionContext() : Create a decompressionContext object, which will track all decompression operations. Provides a pointer to a fully allocated and initialized LZ4F_decompressionContext object. Object can later be released using LZ4F_freeDecompressionContext().
Definition at line 1069 of file lz4frame.c.
References ALLOC_AND_ZERO, err0r(), NULL, and LZ4F_dctx_s::version.
Referenced by basicTests(), createCResources(), decompress_file(), fullSpeedBench(), FUZZ_decompressFrame(), fuzzerTests(), LLVMFuzzerTestOneInput(), LZ4IO_createDResources(), and LZ4IO_getCompressedFileInfo().
LZ4F_decodeHeader() : input : src
points at the beginning of the frame output : set internal values of dctx, such as dctx->frameInfo and dctx->dStage. Also allocates internal buffers.
Definition at line 1113 of file lz4frame.c.
References _1BIT, _2BITS, _3BITS, _4BITS, assert, BD, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, DEBUGLOG, LZ4F_frameInfo_t::dictID, LZ4F_dctx_s::dStage, dstage_getSFrameSize, dstage_init, dstage_storeFrameHeader, dstage_storeSFrameSize, err0r(), FLG, LZ4F_dctx_s::frameInfo, LZ4F_dctx_s::frameRemainingSize, LZ4F_frameInfo_t::frameType, LZ4F_dctx_s::header, LZ4F_frame, LZ4F_getBlockSize(), LZ4F_headerChecksum(), LZ4F_MAGIC_SKIPPABLE_START, LZ4F_MAGICNUMBER, LZ4F_readLE32(), LZ4F_readLE64(), LZ4F_skippableFrame, LZ4F_dctx_s::maxBlockSize, MEM_INIT, memcpy(), minFHSize, src, srcSize, LZ4F_dctx_s::tmpInSize, and LZ4F_dctx_s::tmpInTarget.
Referenced by LZ4F_decompress(), and LZ4F_getFrameInfo().
size_t LZ4F_decompress | ( | LZ4F_dctx * | dctx, |
void * | dstBuffer, | ||
size_t * | dstSizePtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr, | ||
const LZ4F_decompressOptions_t * | decompressOptionsPtr | ||
) |
LZ4F_decompress() : Call this function repetitively to regenerate compressed data in srcBuffer. The function will attempt to decode up to *srcSizePtr bytes from srcBuffer into dstBuffer of capacity *dstSizePtr.
The number of bytes regenerated into dstBuffer will be provided within *dstSizePtr (necessarily <= original value).
The number of bytes effectively read from srcBuffer will be provided within *srcSizePtr (necessarily <= original value). If number of bytes read is < number of bytes provided, then decompression operation is not complete. Remaining data will have to be presented again in a subsequent invocation.
The function result is an hint of the better srcSize to use for next call to LZ4F_decompress. Schematically, it's the size of the current (or remaining) compressed block + header of next block. Respecting the hint provides a small boost to performance, since it allows less buffer shuffling. Note that this is just a hint, and it's always possible to any srcSize value. When a frame is fully decoded,
Definition at line 1384 of file lz4frame.c.
References ALLOC, assert, BFSize, BHSize, LZ4F_dctx_s::blockChecksum, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, DEBUGLOG, LZ4F_dctx_s::dict, LZ4F_dctx_s::dictSize, LZ4F_dctx_s::dStage, dstage_copyDirect, dstage_flushOut, dstage_getBlockChecksum, dstage_getBlockHeader, dstage_getCBlock, dstage_getFrameHeader, dstage_getSFrameSize, dstage_getSuffix, dstage_init, dstage_skipSkippable, dstage_storeBlockHeader, dstage_storeCBlock, dstage_storeFrameHeader, dstage_storeSFrameSize, dstage_storeSuffix, err0r(), LZ4F_dctx_s::frameInfo, LZ4F_dctx_s::frameRemainingSize, FREEMEM, GB, LZ4F_dctx_s::header, if(), KB, LZ4_decompress_safe_usingDict(), LZ4F_blockLinked, LZ4F_BLOCKUNCOMPRESSED_FLAG, LZ4F_decodeHeader(), LZ4F_isError(), LZ4F_readLE32(), LZ4F_resetDecompressionContext(), LZ4F_STATIC_ASSERT, LZ4F_updateDict(), LZ4F_dctx_s::maxBlockSize, LZ4F_dctx_s::maxBufferSize, maxFHSize, MEM_INIT, memcpy(), MIN, minFHSize, NULL, LZ4F_decompressOptions_t::stableDst, LZ4F_dctx_s::tmpIn, LZ4F_dctx_s::tmpInSize, LZ4F_dctx_s::tmpInTarget, LZ4F_dctx_s::tmpOut, LZ4F_dctx_s::tmpOutBuffer, LZ4F_dctx_s::tmpOutSize, LZ4F_dctx_s::tmpOutStart, LZ4F_dctx_s::xxh, XXH32(), XXH32_digest(), XXH32_reset(), and XXH32_update().
Referenced by basicTests(), decompress(), decompress_file_internal(), frameCheck(), FUZZ_decompressFrame(), local_LZ4F_decompress(), local_LZ4F_decompress_followHint(), local_LZ4F_decompress_noHint(), LZ4F_decompress_usingDict(), LZ4F_getFrameInfo(), and test_lz4f_decompression_wBuffers().
size_t LZ4F_decompress_usingDict | ( | LZ4F_dctx * | dctx, |
void * | dstBuffer, | ||
size_t * | dstSizePtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr, | ||
const void * | dict, | ||
size_t | dictSize, | ||
const LZ4F_decompressOptions_t * | decompressOptionsPtr | ||
) |
LZ4F_decompress_usingDict() : Same as LZ4F_decompress(), using a predefined dictionary. Dictionary is used "in place", without any preprocessing. It must remain accessible throughout the entire frame decoding.
Definition at line 1886 of file lz4frame.c.
References LZ4F_dctx_s::dict, LZ4F_dctx_s::dictSize, LZ4F_dctx_s::dStage, dstage_init, and LZ4F_decompress().
Referenced by basicTests(), decompress(), and LZ4IO_decompressLZ4F().
size_t LZ4F_flush | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr | ||
) |
LZ4F_flush() : When compressed data must be sent immediately, without waiting for a block to be filled, invoke LZ4_flush(), which will immediately compress any remaining data stored within LZ4F_cctx. The result of the function is the number of bytes written into dstBuffer. It can be zero, this means there was no data left within LZ4F_cctx. The function outputs an error code if it fails (can be tested using LZ4F_isError()) LZ4F_compressOptions_t* is optional. NULL is a valid argument.
Definition at line 938 of file lz4frame.c.
References assert, BFSize, BHSize, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_cctx_s::cdict, compress(), LZ4F_preferences_t::compressionLevel, LZ4F_cctx_s::cStage, err0r(), LZ4F_preferences_t::frameInfo, LZ4F_cctx_s::lz4CtxPtr, LZ4F_blockLinked, LZ4F_localSaveDict(), LZ4F_makeBlock(), LZ4F_selectCompression(), LZ4F_cctx_s::maxBlockSize, LZ4F_cctx_s::maxBufferSize, LZ4F_cctx_s::prefs, LZ4F_cctx_s::tmpBuff, LZ4F_cctx_s::tmpIn, and LZ4F_cctx_s::tmpInSize.
Referenced by fuzzerTests(), and LZ4F_compressEnd().
void LZ4F_freeCDict | ( | LZ4F_CDict * | cdict | ) |
Definition at line 514 of file lz4frame.c.
References FREEMEM, LZ4_freeStream(), LZ4_freeStreamHC(), and NULL.
Referenced by basicTests(), LZ4F_createCDict(), and LZ4IO_freeCResources().
LZ4F_errorCode_t LZ4F_freeCompressionContext | ( | LZ4F_cctx * | cctxPtr | ) |
Definition at line 550 of file lz4frame.c.
References FREEMEM, LZ4F_cctx_s::lz4CtxPtr, NULL, and LZ4F_cctx_s::tmpBuff.
Referenced by basicTests(), compress_file(), fuzzerTests(), LZ4F_compressFrame(), and LZ4IO_freeCResources().
LZ4F_errorCode_t LZ4F_freeDecompressionContext | ( | LZ4F_dctx * | dctx | ) |
Definition at line 1082 of file lz4frame.c.
References LZ4F_dctx_s::dStage, FREEMEM, NULL, LZ4F_dctx_s::tmpIn, and LZ4F_dctx_s::tmpOutBuffer.
Referenced by basicTests(), decompress_file(), freeCResources(), fullSpeedBench(), FUZZ_decompressFrame(), fuzzerTests(), LLVMFuzzerTestOneInput(), LZ4IO_freeDResources(), and LZ4IO_getCompressedFileInfo().
Definition at line 278 of file lz4frame.c.
References err0r(), KB, LZ4F_BLOCKSIZEID_DEFAULT, LZ4F_max4MB, LZ4F_max64KB, and MB.
Referenced by basicTests(), LZ4F_compressBegin_usingCDict(), LZ4F_compressBound_internal(), LZ4F_compressFrame_usingCDict(), and LZ4F_decodeHeader().
LZ4F_errorCodes LZ4F_getErrorCode | ( | size_t | functionResult | ) |
Definition at line 261 of file lz4frame.c.
References LZ4F_isError().
Referenced by basicTests(), and test_lz4f_decompression_wBuffers().
const char* LZ4F_getErrorName | ( | LZ4F_errorCode_t | code | ) |
return error code string; for debugging
Definition at line 254 of file lz4frame.c.
References int, LZ4F_errorStrings, and LZ4F_isError().
Referenced by basicTests(), decompress_file(), decompress_file_allocDst(), decompress_file_internal(), frameCheck(), fuzzerTests(), LZ4IO_compressFilename_extRess(), LZ4IO_createCResources(), LZ4IO_createDResources(), LZ4IO_decompressLZ4F(), LZ4IO_freeCResources(), and LZ4IO_freeDResources().
LZ4F_errorCode_t LZ4F_getFrameInfo | ( | LZ4F_dctx * | dctx, |
LZ4F_frameInfo_t * | frameInfoPtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr | ||
) |
LZ4F_getFrameInfo() : This function extracts frame parameters (max blockSize, frame checksum, etc.). Usage is optional. Objective is to provide relevant information for allocation purposes. This function works in 2 situations :
srcBuffer
, and start the decoding process. Amount of input data provided must be large enough to successfully decode the frame header. A header size is variable, but is guaranteed to be <= LZ4F_HEADER_SIZE_MAX bytes. It's possible to provide more input data than this minimum.Definition at line 1253 of file lz4frame.c.
References BHSize, LZ4F_dctx_s::dStage, dstage_getFrameHeader, dstage_storeFrameHeader, err0r(), LZ4F_dctx_s::frameInfo, i, LZ4F_decodeHeader(), LZ4F_decompress(), LZ4F_headerSize(), LZ4F_isError(), LZ4F_STATIC_ASSERT, and NULL.
Referenced by basicTests(), decompress_file_allocDst(), frameCheck(), and LZ4IO_getCompressedFileInfo().
unsigned LZ4F_getVersion | ( | void | ) |
Definition at line 294 of file lz4frame.c.
References header, length, and XXH32().
Referenced by LZ4F_compressBegin_usingCDict(), and LZ4F_decodeHeader().
Definition at line 1212 of file lz4frame.c.
References _1BIT, err0r(), FLG, LZ4F_MAGIC_SKIPPABLE_START, LZ4F_MAGICNUMBER, LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH, LZ4F_readLE32(), minFHSize, NULL, src, and srcSize.
Referenced by basicTests(), LZ4F_getFrameInfo(), and LZ4IO_getCompressedFileInfo().
|
static |
This function prepares the internal LZ4(HC) stream for a new compression, resetting the context and attaching the dictionary, if there is one.
It needs to be called at the beginning of each independent compression stream (i.e., at the beginning of a frame in blockLinked mode, or at the beginning of each block in blockIndependent mode).
Definition at line 570 of file lz4frame.c.
References level, LZ4_attach_dictionary(), LZ4_attach_HC_dictionary(), LZ4_resetStream_fast(), LZ4_resetStreamHC_fast(), LZ4F_blockLinked, LZ4HC_CLEVEL_MIN, and NULL.
Referenced by LZ4F_compressBegin_usingCDict(), LZ4F_compressBlock(), and LZ4F_compressBlockHC().
unsigned LZ4F_isError | ( | LZ4F_errorCode_t | code | ) |
tells when a function result is an error code
Definition at line 249 of file lz4frame.c.
Referenced by basicTests(), compress_file(), compress_file_internal(), createCResources(), decompress_file(), decompress_file_allocDst(), decompress_file_internal(), frameCheck(), fullSpeedBench(), FUZZ_decompressFrame(), fuzzerTests(), LLVMFuzzerTestOneInput(), local_LZ4F_decompress_followHint(), local_LZ4F_decompress_noHint(), LZ4F_compressEnd(), LZ4F_compressFrame(), LZ4F_compressFrame_usingCDict(), LZ4F_decompress(), LZ4F_getErrorCode(), LZ4F_getErrorName(), LZ4F_getFrameInfo(), LZ4IO_compressFilename_extRess(), LZ4IO_createCResources(), LZ4IO_createDResources(), LZ4IO_decompressLZ4F(), LZ4IO_freeCResources(), LZ4IO_freeDResources(), LZ4IO_getCompressedFileInfo(), and test_lz4f_decompression_wBuffers().
|
static |
Definition at line 809 of file lz4frame.c.
References LZ4F_preferences_t::compressionLevel, KB, LZ4_saveDict(), LZ4_saveDictHC(), LZ4F_cctx_s::lz4CtxPtr, LZ4HC_CLEVEL_MIN, LZ4F_cctx_s::prefs, and LZ4F_cctx_s::tmpBuff.
Referenced by LZ4F_compressUpdate(), and LZ4F_flush().
|
static |
LZ4F_makeBlock(): compress a single block, add header and optional checksum. assumption : dst buffer capacity is >= BHSize + srcSize + crcSize
Definition at line 740 of file lz4frame.c.
References BFSize, BHSize, compress(), crc32(), DEBUGLOG, dst, int, level, LZ4F_BLOCKUNCOMPRESSED_FLAG, LZ4F_writeLE32(), memcpy(), src, srcSize, and XXH32().
Referenced by LZ4F_compressUpdate(), and LZ4F_flush().
|
static |
Definition at line 304 of file lz4frame.c.
References KB, LZ4F_max64KB, and srcSize.
Referenced by LZ4F_compressFrame_usingCDict().
Definition at line 147 of file lz4frame.c.
References src.
Referenced by LZ4F_decodeHeader(), LZ4F_decompress(), and LZ4F_headerSize().
void LZ4F_resetDecompressionContext | ( | LZ4F_dctx * | dctx | ) |
LZ4F_resetDecompressionContext() : added in v1.8.0 In case of an error, the context is left in "undefined" state. In which case, it's necessary to reset it, before re-using it. This method can also be used to abruptly stop any unfinished decompression, and start a new one using same context resources.
Definition at line 1097 of file lz4frame.c.
References LZ4F_dctx_s::dict, LZ4F_dctx_s::dictSize, LZ4F_dctx_s::dStage, dstage_getFrameHeader, and NULL.
Referenced by basicTests(), decompress(), fuzzerTests(), and LZ4F_decompress().
|
static |
Definition at line 799 of file lz4frame.c.
References level, LZ4F_blockIndependent, LZ4F_compressBlock(), LZ4F_compressBlock_continue(), LZ4F_compressBlockHC(), LZ4F_compressBlockHC_continue(), and LZ4HC_CLEVEL_MIN.
Referenced by LZ4F_compressUpdate(), and LZ4F_flush().
|
static |
Definition at line 1295 of file lz4frame.c.
References assert, LZ4F_dctx_s::dict, LZ4F_dctx_s::dictSize, KB, LZ4F_dctx_s::maxBufferSize, memcpy(), NULL, LZ4F_dctx_s::tmpOut, LZ4F_dctx_s::tmpOutBuffer, LZ4F_dctx_s::tmpOutSize, and LZ4F_dctx_s::tmpOutStart.
Referenced by LZ4F_decompress().
|
static |
Definition at line 157 of file lz4frame.c.
References dst.
Referenced by LZ4F_compressBegin_usingCDict(), LZ4F_compressEnd(), and LZ4F_makeBlock().
|
static |
Definition at line 180 of file lz4frame.c.
References dst.
Referenced by LZ4F_compressBegin_usingCDict().
|
static |
Definition at line 217 of file lz4frame.c.
Referenced by LZ4F_compressBound_internal(), LZ4F_decompress(), LZ4F_flush(), and LZ4F_makeBlock().
|
static |
Definition at line 216 of file lz4frame.c.
Referenced by LZ4F_compressBound_internal(), LZ4F_decompress(), LZ4F_flush(), LZ4F_getFrameInfo(), and LZ4F_makeBlock().
|
static |
Definition at line 246 of file lz4frame.c.
Referenced by LZ4F_getErrorName().
|
static |
Definition at line 215 of file lz4frame.c.
Referenced by LZ4F_compressBegin_usingCDict(), LZ4F_compressFrameBound(), and LZ4F_decompress().
|
static |
Definition at line 214 of file lz4frame.c.
Referenced by LZ4F_decodeHeader(), LZ4F_decompress(), and LZ4F_headerSize().