Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
lz4frame.c File Reference
#include <limits.h>
#include "lz4frame.h"
#include "lz4.h"
#include "lz4hc.h"
#include "xxhash.h"
#include <string.h>

Data Structures

struct  LZ4F_cctx_s
 
struct  LZ4F_CDict_s
 
struct  LZ4F_dctx_s
 

Macros

#define LZ4F_HEAPMODE   0
 
#define LZ4F_STATIC_LINKING_ONLY
 
#define LZ4_STATIC_LINKING_ONLY
 
#define LZ4_HC_STATIC_LINKING_ONLY
 
#define XXH_STATIC_LINKING_ONLY
 
#define assert(condition)
 
#define LZ4F_STATIC_ASSERT(c)
 
#define DEBUGLOG(l, ...)
 
#define _1BIT   0x01
 
#define _2BITS   0x03
 
#define _3BITS   0x07
 
#define _4BITS   0x0F
 
#define _8BITS   0xFF
 
#define LZ4F_BLOCKUNCOMPRESSED_FLAG   0x80000000U
 
#define LZ4F_BLOCKSIZEID_DEFAULT   LZ4F_max64KB
 
#define LZ4F_GENERATE_STRING(STRING)
 
#define RETURN_ERROR(e)
 
#define RETURN_ERROR_IF(c, e)
 
#define FORWARD_IF_ERROR(r)
 
#define MIN(a, b)
 

Typedefs

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)
 

Enumerations

enum  LZ4F_BlockCompressMode_e { LZ4B_COMPRESSED , LZ4B_UNCOMPRESSED }
 
enum  LZ4F_CtxType_e { ctxNone , ctxFast , ctxHC }
 
enum  LZ4F_lastBlockStatus { notDone , fromTmpBuffer , fromSrcBuffer }
 
enum  dStage_t {
  dstage_getFrameHeader =0 , dstage_storeFrameHeader , dstage_init , dstage_getBlockHeader ,
  dstage_storeBlockHeader , dstage_copyDirect , dstage_getBlockChecksum , dstage_getCBlock ,
  dstage_storeCBlock , dstage_flushOut , dstage_getSuffix , dstage_storeSuffix ,
  dstage_getSFrameSize , dstage_storeSFrameSize , dstage_skipSkippable
}
 

Functions

unsigned LZ4F_isError (LZ4F_errorCode_t code)
 
const char * LZ4F_getErrorName (LZ4F_errorCode_t code)
 
LZ4F_errorCodes LZ4F_getErrorCode (size_t functionResult)
 
unsigned LZ4F_getVersion (void)
 
int LZ4F_compressionLevel_max (void)
 
size_t LZ4F_getBlockSize (LZ4F_blockSizeID_t blockSizeID)
 
size_t LZ4F_compressFrameBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
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)
 
size_t LZ4F_compressFrame (void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
LZ4F_CDictLZ4F_createCDict_advanced (LZ4F_CustomMem cmem, const void *dictBuffer, size_t dictSize)
 
LZ4F_CDictLZ4F_createCDict (const void *dictBuffer, size_t dictSize)
 
void LZ4F_freeCDict (LZ4F_CDict *cdict)
 
LZ4F_cctxLZ4F_createCompressionContext_advanced (LZ4F_CustomMem customMem, unsigned version)
 
LZ4F_errorCode_t LZ4F_createCompressionContext (LZ4F_cctx **LZ4F_compressionContextPtr, unsigned version)
 
LZ4F_errorCode_t LZ4F_freeCompressionContext (LZ4F_cctx *cctxPtr)
 
size_t LZ4F_compressBegin_internal (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dictBuffer, size_t dictSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBegin (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBegin_usingDictOnce (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dict, size_t dictSize, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBegin_usingDict (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dict, size_t dictSize, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBegin_usingCDict (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressUpdate (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
 
size_t LZ4F_uncompressedUpdate (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
 
size_t LZ4F_flush (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
 
size_t LZ4F_compressEnd (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
 
LZ4F_dctxLZ4F_createDecompressionContext_advanced (LZ4F_CustomMem customMem, unsigned version)
 
LZ4F_errorCode_t LZ4F_createDecompressionContext (LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber)
 
LZ4F_errorCode_t LZ4F_freeDecompressionContext (LZ4F_dctx *dctx)
 
void LZ4F_resetDecompressionContext (LZ4F_dctx *dctx)
 
size_t LZ4F_headerSize (const void *src, size_t srcSize)
 
LZ4F_errorCode_t LZ4F_getFrameInfo (LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
 
size_t LZ4F_decompress (LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr)
 
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)
 

Macro Definition Documentation

◆ _1BIT

#define _1BIT   0x01

◆ _2BITS

#define _2BITS   0x03

◆ _3BITS

#define _3BITS   0x07

◆ _4BITS

#define _4BITS   0x0F

◆ _8BITS

#define _8BITS   0xFF

◆ assert

#define assert ( condition)
Value:
((void)0)

◆ DEBUGLOG

#define DEBUGLOG ( l,
... )
Value:
{} /* disabled */

◆ FORWARD_IF_ERROR

#define FORWARD_IF_ERROR ( r)
Value:
do { if (LZ4F_isError(r)) return (r); } while (0)
unsigned LZ4F_isError(LZ4F_errorCode_t code)
Definition lz4frame.c:293

◆ LZ4_HC_STATIC_LINKING_ONLY

#define LZ4_HC_STATIC_LINKING_ONLY

◆ LZ4_STATIC_LINKING_ONLY

#define LZ4_STATIC_LINKING_ONLY

◆ LZ4F_BLOCKSIZEID_DEFAULT

#define LZ4F_BLOCKSIZEID_DEFAULT   LZ4F_max64KB

◆ LZ4F_BLOCKUNCOMPRESSED_FLAG

#define LZ4F_BLOCKUNCOMPRESSED_FLAG   0x80000000U

◆ LZ4F_GENERATE_STRING

#define LZ4F_GENERATE_STRING ( STRING)
Value:
#STRING,

◆ LZ4F_HEAPMODE

#define LZ4F_HEAPMODE   0

◆ LZ4F_STATIC_ASSERT

#define LZ4F_STATIC_ASSERT ( c)
Value:
{ enum { LZ4F_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
int
Definition lzoconf.h:340
#define c(i)
Definition sha256.c:43

◆ LZ4F_STATIC_LINKING_ONLY

#define LZ4F_STATIC_LINKING_ONLY

◆ MIN

#define MIN ( a,
b )
Value:
( (a) < (b) ? (a) : (b) )
#define b(i)
Definition sha256.c:42
#define a(i)
Definition sha256.c:41

◆ RETURN_ERROR

#define RETURN_ERROR ( e)
Value:
return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
#define e(i)
Definition sha256.c:45

◆ RETURN_ERROR_IF

#define RETURN_ERROR_IF ( c,
e )
Value:
do { \
if (c) { \
DEBUGLOG(3, "Error: " #c); \
RETURN_ERROR(e); \
} \
} while (0)

◆ XXH_STATIC_LINKING_ONLY

#define XXH_STATIC_LINKING_ONLY

Typedef Documentation

◆ compressFunc_t

typedef int(* compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict)

◆ LZ4F_cctx_t

typedef struct LZ4F_cctx_s LZ4F_cctx_t

Enumeration Type Documentation

◆ dStage_t

enum dStage_t
Enumerator
dstage_getFrameHeader 
dstage_storeFrameHeader 
dstage_init 
dstage_getBlockHeader 
dstage_storeBlockHeader 
dstage_copyDirect 
dstage_getBlockChecksum 
dstage_getCBlock 
dstage_storeCBlock 
dstage_flushOut 
dstage_getSuffix 
dstage_storeSuffix 
dstage_getSFrameSize 
dstage_storeSFrameSize 
dstage_skipSkippable 

◆ LZ4F_BlockCompressMode_e

Enumerator
LZ4B_COMPRESSED 
LZ4B_UNCOMPRESSED 

◆ LZ4F_CtxType_e

Enumerator
ctxNone 
ctxFast 
ctxHC 

◆ LZ4F_lastBlockStatus

Enumerator
notDone 
fromTmpBuffer 
fromSrcBuffer 

Function Documentation

◆ LZ4F_compressBegin()

size_t LZ4F_compressBegin ( LZ4F_cctx * cctx,
void * dstBuffer,
size_t dstCapacity,
const LZ4F_preferences_t * prefsPtr )

LZ4F_compressBegin() : will write the frame header into dstBuffer. dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. prefsPtr is optional : NULL can be provided to set all preferences to default.

Returns
: number of bytes written into dstBuffer for the header or an error code (which can be tested using LZ4F_isError())

◆ LZ4F_compressBegin_internal()

size_t LZ4F_compressBegin_internal ( LZ4F_cctx * cctx,
void * dstBuffer,
size_t dstCapacity,
const void * dictBuffer,
size_t dictSize,
const LZ4F_CDict * cdict,
const LZ4F_preferences_t * preferencesPtr )

◆ LZ4F_compressBegin_usingCDict()

size_t LZ4F_compressBegin_usingCDict ( LZ4F_cctx * cctx,
void * dstBuffer,
size_t dstCapacity,
const LZ4F_CDict * cdict,
const LZ4F_preferences_t * prefsPtr )

LZ4F_compressBegin_usingCDict() : stable since v1.10 Inits streaming dictionary compression, and writes the frame header into dstBuffer. @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. @prefsPtr is optional : one may provide NULL as argument, note however that it's the only way to insert a @dictID in the frame header. @cdict must outlive the compression session.

Returns
: number of bytes written into dstBuffer for the header, or an error code, which can be tested using LZ4F_isError().

◆ LZ4F_compressBegin_usingDict()

size_t LZ4F_compressBegin_usingDict ( LZ4F_cctx * cctx,
void * dstBuffer,
size_t dstCapacity,
const void * dictBuffer,
size_t dictSize,
const LZ4F_preferences_t * prefsPtr )

LZ4F_compressBegin_usingDict() : stable since v1.10 Inits dictionary compression streaming, and writes the frame header into dstBuffer. @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. @prefsPtr is optional : one may provide NULL as argument, however, it's the only way to provide dictID in the frame header. @dictBuffer must outlive the compression session.

Returns
: number of bytes written into dstBuffer for the header, or an error code (which can be tested using LZ4F_isError()) NOTE: The LZ4Frame spec allows each independent block to be compressed with the dictionary, but this entry supports a more limited scenario, where only the first block uses the dictionary. This is still useful for small data, which only need one block anyway. For larger inputs, one may be more interested in LZ4F_compressFrame_usingCDict() below.

◆ LZ4F_compressBegin_usingDictOnce()

size_t LZ4F_compressBegin_usingDictOnce ( LZ4F_cctx * cctx,
void * dstBuffer,
size_t dstCapacity,
const void * dict,
size_t dictSize,
const LZ4F_preferences_t * preferencesPtr )

◆ LZ4F_compressBound()

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().

Returns
is always the same for a srcSize and prefsPtr. prefsPtr is optional : when NULL is provided, preferences will be set to cover worst case scenario. tech details :
if automatic flushing is not enabled, includes the possibility that internal buffer might already be filled by up to (blockSize-1) bytes. It also includes frame footer (ending + checksum), since it might be generated by LZ4F_compressEnd().
doesn't include frame header, as it was already generated by LZ4F_compressBegin().

◆ LZ4F_compressEnd()

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.

Returns
: the number of bytes written into dstBuffer (necessarily >= 4 (endMark size)) or an error code if it fails (can be tested using LZ4F_isError()) The context can then be used again to compress a new frame, starting with LZ4F_compressBegin().

◆ LZ4F_compressFrame()

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.

Returns
: number of bytes written into dstBuffer. or an error code if it fails (can be tested using LZ4F_isError())

◆ LZ4F_compressFrame_usingCDict()

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.

Returns
: number of bytes written into dstBuffer, or an error code if it fails (can be tested using LZ4F_isError())

◆ LZ4F_compressFrameBound()

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 relevant to LZ4F_compressUpdate() only if no flush() operation is ever performed.

◆ LZ4F_compressionLevel_max()

int LZ4F_compressionLevel_max ( void )

LZ4F_compressionLevel_max() :

Returns
maximum allowed compression level (currently: 12)

◆ LZ4F_compressUpdate()

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. When successful, the function always entirely consumes @srcBuffer. src data is either buffered or compressed into @dstBuffer. If previously an uncompressed block was written, buffered data is flushed before appending compressed data is continued. @dstCapacity MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). @compressOptionsPtr is optional : provide NULL to mean "default".

Returns
: the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered. or an error code if it fails (which can be tested using LZ4F_isError()) After an error, the state is left in a UB state, and must be re-initialized.

◆ LZ4F_createCDict()

LZ4F_CDict * LZ4F_createCDict ( const void * dictBuffer,
size_t dictSize )

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

Returns
: digested dictionary for compression, or NULL if failed

◆ LZ4F_createCDict_advanced()

LZ4F_CDict * LZ4F_createCDict_advanced ( LZ4F_CustomMem cmem,
const void * dictBuffer,
size_t dictSize )

◆ LZ4F_createCompressionContext()

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();

◆ LZ4F_createCompressionContext_advanced()

LZ4F_cctx * LZ4F_createCompressionContext_advanced ( LZ4F_CustomMem customMem,
unsigned version )

◆ LZ4F_createDecompressionContext()

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().

Returns
: if != 0, there was an error during context creation.

◆ LZ4F_createDecompressionContext_advanced()

LZ4F_dctx * LZ4F_createDecompressionContext_advanced ( LZ4F_CustomMem customMem,
unsigned version )

◆ LZ4F_decompress()

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,

Returns
will be 0. If decompression failed,
is an error code which can be tested using LZ4F_isError().

◆ LZ4F_decompress_usingDict()

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.

◆ LZ4F_flush()

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.

◆ LZ4F_freeCDict()

void LZ4F_freeCDict ( LZ4F_CDict * cdict)

◆ LZ4F_freeCompressionContext()

LZ4F_errorCode_t LZ4F_freeCompressionContext ( LZ4F_cctx * cctxPtr)

◆ LZ4F_freeDecompressionContext()

LZ4F_errorCode_t LZ4F_freeDecompressionContext ( LZ4F_dctx * dctx)

◆ LZ4F_getBlockSize()

size_t LZ4F_getBlockSize ( LZ4F_blockSizeID_t blockSizeID)

◆ LZ4F_getErrorCode()

LZ4F_errorCodes LZ4F_getErrorCode ( size_t functionResult)

◆ LZ4F_getErrorName()

const char * LZ4F_getErrorName ( LZ4F_errorCode_t code)

return error code string; for debugging

◆ LZ4F_getFrameInfo()

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 :

  • At the beginning of a new frame, in which case it will decode this information from 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.
  • After decoding has been started. In which case, no input is read, frame parameters are extracted from dctx. The number of bytes consumed from srcBuffer will be updated within *srcSizePtr (necessarily <= original value). Decompression must resume from (srcBuffer + *srcSizePtr).
    Returns
    : an hint about how many srcSize bytes LZ4F_decompress() expects for next call, or an error code which can be tested using LZ4F_isError() note 1 : in case of error, dctx is not modified. Decoding operations can resume from where they stopped. note 2 : frame parameters are copied into an already allocated LZ4F_frameInfo_t structure.

◆ LZ4F_getVersion()

unsigned LZ4F_getVersion ( void )

◆ LZ4F_headerSize()

size_t LZ4F_headerSize ( const void * src,
size_t srcSize )

LZ4F_headerSize() :

Returns
: size of frame header or an error code, which can be tested using LZ4F_isError()

◆ LZ4F_isError()

unsigned LZ4F_isError ( LZ4F_errorCode_t code)

tells when a function result is an error code

◆ LZ4F_resetDecompressionContext()

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.

◆ LZ4F_uncompressedUpdate()

size_t LZ4F_uncompressedUpdate ( LZ4F_cctx * cctxPtr,
void * dstBuffer,
size_t dstCapacity,
const void * srcBuffer,
size_t srcSize,
const LZ4F_compressOptions_t * compressOptionsPtr )

LZ4F_uncompressedUpdate() : Same as LZ4F_compressUpdate(), but requests blocks to be sent uncompressed. This symbol is only supported when LZ4F_blockIndependent is used @dstCapacity MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). @compressOptionsPtr is optional : provide NULL to mean "default".

Returns
: the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered. or an error code if it fails (which can be tested using LZ4F_isError()) After an error, the state is left in a UB state, and must be re-initialized.