ROOTANA
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
lz4frame.c File Reference
#include <stdlib.h>
#include <string.h>
#include "lz4frame_static.h"
#include "lz4.h"
#include "lz4hc.h"
#include "xxhash.h"
Include dependency graph for lz4frame.c:

Go to the source code of this file.

Data Structures

struct  LZ4F_cctx_s
 
struct  LZ4F_dctx_s
 

Macros

#define ALLOCATOR(s)   calloc(1,s)
 
#define FREEMEM   free
 
#define MEM_INIT   memset
 
#define KB   *(1<<10)
 
#define MB   *(1<<20)
 
#define GB   *(1<<30)
 
#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,
 

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 struct LZ4F_dctx_s LZ4F_dctx_t
 
typedef int(* compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level)
 

Enumerations

enum  LZ4F_lastBlockStatus { notDone , fromTmpBuffer , fromSrcBuffer }
 
enum  dStage_t {
  dstage_getHeader =0 , dstage_storeHeader , dstage_getCBlockSize , dstage_storeCBlockSize ,
  dstage_copyDirect , dstage_getCBlock , dstage_storeCBlock , dstage_decodeCBlock ,
  dstage_decodeCBlock_intoDst , dstage_decodeCBlock_intoTmp , 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)
 
static size_t LZ4F_getBlockSize (unsigned blockSizeID)
 
static U32 LZ4F_readLE32 (const BYTE *srcPtr)
 
static void LZ4F_writeLE32 (BYTE *dstPtr, U32 value32)
 
static U64 LZ4F_readLE64 (const BYTE *srcPtr)
 
static void LZ4F_writeLE64 (BYTE *dstPtr, U64 value64)
 
static BYTE LZ4F_headerChecksum (const void *header, size_t length)
 
static LZ4F_blockSizeID_t LZ4F_optimalBSID (const LZ4F_blockSizeID_t requestedBSID, const size_t srcSize)
 
size_t LZ4F_compressFrameBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressFrame (void *dstBuffer, size_t dstMaxSize, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
LZ4F_errorCode_t LZ4F_createCompressionContext (LZ4F_compressionContext_t *LZ4F_compressionContextPtr, unsigned version)
 
LZ4F_errorCode_t LZ4F_freeCompressionContext (LZ4F_compressionContext_t LZ4F_compressionContext)
 
size_t LZ4F_compressBegin (LZ4F_compressionContext_t compressionContext, void *dstBuffer, size_t dstMaxSize, const LZ4F_preferences_t *preferencesPtr)
 
size_t LZ4F_compressBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
 
static size_t LZ4F_compressBlock (void *dst, const void *src, size_t srcSize, compressFunc_t compress, void *lz4ctx, int level)
 
static int LZ4F_localLZ4_compress_limitedOutput_withState (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level)
 
static int LZ4F_localLZ4_compress_limitedOutput_continue (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level)
 
static int LZ4F_localLZ4_compressHC_limitedOutput_continue (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level)
 
static compressFunc_t LZ4F_selectCompression (LZ4F_blockMode_t blockMode, int level)
 
static int LZ4F_localSaveDict (LZ4F_cctx_t *cctxPtr)
 
size_t LZ4F_compressUpdate (LZ4F_compressionContext_t compressionContext, void *dstBuffer, size_t dstMaxSize, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
 
size_t LZ4F_flush (LZ4F_compressionContext_t compressionContext, void *dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t *compressOptionsPtr)
 
size_t LZ4F_compressEnd (LZ4F_compressionContext_t compressionContext, void *dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t *compressOptionsPtr)
 
LZ4F_errorCode_t LZ4F_createDecompressionContext (LZ4F_decompressionContext_t *LZ4F_decompressionContextPtr, unsigned versionNumber)
 
LZ4F_errorCode_t LZ4F_freeDecompressionContext (LZ4F_decompressionContext_t LZ4F_decompressionContext)
 
static size_t LZ4F_decodeHeader (LZ4F_dctx_t *dctxPtr, const void *srcVoidPtr, size_t srcSize)
 
LZ4F_errorCode_t LZ4F_getFrameInfo (LZ4F_decompressionContext_t dCtx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
 
static int LZ4F_decompress_safe (const char *source, char *dest, int compressedSize, int maxDecompressedSize, const char *dictStart, int dictSize)
 
static void LZ4F_updateDict (LZ4F_dctx_t *dctxPtr, const BYTE *dstPtr, size_t dstSize, const BYTE *dstPtr0, unsigned withinTmp)
 
size_t LZ4F_decompress (LZ4F_decompressionContext_t decompressionContext, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr)
 

Variables

static const size_t minFHSize = 7
 
static const size_t maxFHSize = 15
 
static const size_t BHSize = 4
 
static const int minHClevel = 3
 
static const char * LZ4F_errorStrings [] = { LZ4F_LIST_ERRORS(LZ4F_GENERATE_STRING) }
 

Macro Definition Documentation

◆ _1BIT

#define _1BIT   0x01

Definition at line 94 of file lz4frame.c.

◆ _2BITS

#define _2BITS   0x03

Definition at line 95 of file lz4frame.c.

◆ _3BITS

#define _3BITS   0x07

Definition at line 96 of file lz4frame.c.

◆ _4BITS

#define _4BITS   0x0F

Definition at line 97 of file lz4frame.c.

◆ _8BITS

#define _8BITS   0xFF

Definition at line 98 of file lz4frame.c.

◆ ALLOCATOR

#define ALLOCATOR (   s)    calloc(1,s)

Definition at line 53 of file lz4frame.c.

◆ FREEMEM

#define FREEMEM   free

Definition at line 54 of file lz4frame.c.

◆ GB

#define GB   *(1<<30)

Definition at line 92 of file lz4frame.c.

◆ KB

#define KB   *(1<<10)

Definition at line 90 of file lz4frame.c.

◆ LZ4F_BLOCKSIZEID_DEFAULT

#define LZ4F_BLOCKSIZEID_DEFAULT   LZ4F_max64KB

Definition at line 103 of file lz4frame.c.

◆ LZ4F_BLOCKUNCOMPRESSED_FLAG

#define LZ4F_BLOCKUNCOMPRESSED_FLAG   0x80000000U

Definition at line 102 of file lz4frame.c.

◆ LZ4F_GENERATE_STRING

#define LZ4F_GENERATE_STRING (   STRING)    #STRING,

Definition at line 156 of file lz4frame.c.

◆ LZ4F_MAGIC_SKIPPABLE_START

#define LZ4F_MAGIC_SKIPPABLE_START   0x184D2A50U

Definition at line 100 of file lz4frame.c.

◆ LZ4F_MAGICNUMBER

#define LZ4F_MAGICNUMBER   0x184D2204U

Definition at line 101 of file lz4frame.c.

◆ MB

#define MB   *(1<<20)

Definition at line 91 of file lz4frame.c.

◆ MEM_INIT

#define MEM_INIT   memset

Definition at line 56 of file lz4frame.c.

Typedef Documentation

◆ BYTE

typedef unsigned char BYTE

Definition at line 79 of file lz4frame.c.

◆ compressFunc_t

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

Definition at line 496 of file lz4frame.c.

◆ LZ4F_cctx_t

typedef struct LZ4F_cctx_s LZ4F_cctx_t

◆ LZ4F_dctx_t

typedef struct LZ4F_dctx_s LZ4F_dctx_t

◆ S32

typedef signed int S32

Definition at line 82 of file lz4frame.c.

◆ U16

typedef unsigned short U16

Definition at line 80 of file lz4frame.c.

◆ U32

typedef unsigned int U32

Definition at line 81 of file lz4frame.c.

◆ U64

typedef unsigned long long U64

Definition at line 83 of file lz4frame.c.

Enumeration Type Documentation

◆ dStage_t

enum dStage_t
Enumerator
dstage_getHeader 
dstage_storeHeader 
dstage_getCBlockSize 
dstage_storeCBlockSize 
dstage_copyDirect 
dstage_getCBlock 
dstage_storeCBlock 
dstage_decodeCBlock 
dstage_decodeCBlock_intoDst 
dstage_decodeCBlock_intoTmp 
dstage_flushOut 
dstage_getSuffix 
dstage_storeSuffix 
dstage_getSFrameSize 
dstage_storeSFrameSize 
dstage_skipSkippable 

Definition at line 791 of file lz4frame.c.

◆ LZ4F_lastBlockStatus

Enumerator
notDone 
fromTmpBuffer 
fromSrcBuffer 

Definition at line 551 of file lz4frame.c.

Function Documentation

◆ LZ4F_compressBegin()

size_t LZ4F_compressBegin ( LZ4F_compressionContext_t  compressionContext,
void *  dstBuffer,
size_t  dstMaxSize,
const LZ4F_preferences_t preferencesPtr 
)

Definition at line 392 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_compressBlock()

static size_t LZ4F_compressBlock ( void *  dst,
const void *  src,
size_t  srcSize,
compressFunc_t  compress,
void *  lz4ctx,
int  level 
)
static

Definition at line 498 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_compressBound()

size_t LZ4F_compressBound ( size_t  srcSize,
const LZ4F_preferences_t preferencesPtr 
)

Definition at line 477 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_compressEnd()

size_t LZ4F_compressEnd ( LZ4F_compressionContext_t  compressionContext,
void *  dstBuffer,
size_t  dstMaxSize,
const LZ4F_compressOptions_t compressOptionsPtr 
)

Definition at line 714 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_compressFrame()

size_t LZ4F_compressFrame ( void *  dstBuffer,
size_t  dstMaxSize,
const void *  srcBuffer,
size_t  srcSize,
const LZ4F_preferences_t preferencesPtr 
)

Definition at line 284 of file lz4frame.c.

Here is the call graph for this function:

◆ LZ4F_compressFrameBound()

size_t LZ4F_compressFrameBound ( size_t  srcSize,
const LZ4F_preferences_t preferencesPtr 
)

Definition at line 256 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_compressUpdate()

size_t LZ4F_compressUpdate ( LZ4F_compressionContext_t  compressionContext,
void *  dstBuffer,
size_t  dstMaxSize,
const void *  srcBuffer,
size_t  srcSize,
const LZ4F_compressOptions_t compressOptionsPtr 
)

Definition at line 562 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_createCompressionContext()

LZ4F_errorCode_t LZ4F_createCompressionContext ( LZ4F_compressionContext_t LZ4F_compressionContextPtr,
unsigned  version 
)

Definition at line 355 of file lz4frame.c.

◆ LZ4F_createDecompressionContext()

LZ4F_errorCode_t LZ4F_createDecompressionContext ( LZ4F_decompressionContext_t LZ4F_decompressionContextPtr,
unsigned  versionNumber 
)

Definition at line 760 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_decodeHeader()

static size_t LZ4F_decodeHeader ( LZ4F_dctx_t dctxPtr,
const void *  srcVoidPtr,
size_t  srcSize 
)
static

Definition at line 810 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_decompress()

size_t LZ4F_decompress ( LZ4F_decompressionContext_t  decompressionContext,
void *  dstBuffer,
size_t *  dstSizePtr,
const void *  srcBuffer,
size_t *  srcSizePtr,
const LZ4F_decompressOptions_t decompressOptionsPtr 
)

Definition at line 1044 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_decompress_safe()

static int LZ4F_decompress_safe ( const char *  source,
char *  dest,
int  compressedSize,
int  maxDecompressedSize,
const char *  dictStart,
int  dictSize 
)
static

Definition at line 954 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_flush()

size_t LZ4F_flush ( LZ4F_compressionContext_t  compressionContext,
void *  dstBuffer,
size_t  dstMaxSize,
const LZ4F_compressOptions_t compressOptionsPtr 
)

Definition at line 673 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_freeCompressionContext()

LZ4F_errorCode_t LZ4F_freeCompressionContext ( LZ4F_compressionContext_t  LZ4F_compressionContext)

Definition at line 371 of file lz4frame.c.

◆ LZ4F_freeDecompressionContext()

LZ4F_errorCode_t LZ4F_freeDecompressionContext ( LZ4F_decompressionContext_t  LZ4F_decompressionContext)

Definition at line 772 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_getBlockSize()

static size_t LZ4F_getBlockSize ( unsigned  blockSizeID)
static

Definition at line 176 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_getErrorName()

const char* LZ4F_getErrorName ( LZ4F_errorCode_t  code)

Definition at line 165 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_getFrameInfo()

LZ4F_errorCode_t LZ4F_getFrameInfo ( LZ4F_decompressionContext_t  dCtx,
LZ4F_frameInfo_t frameInfoPtr,
const void *  srcBuffer,
size_t *  srcSizePtr 
)

Definition at line 928 of file lz4frame.c.

Here is the call graph for this function:

◆ LZ4F_headerChecksum()

static BYTE LZ4F_headerChecksum ( const void *  header,
size_t  length 
)
static

Definition at line 231 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_isError()

unsigned LZ4F_isError ( LZ4F_errorCode_t  code)

Definition at line 160 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_localLZ4_compress_limitedOutput_continue()

static int LZ4F_localLZ4_compress_limitedOutput_continue ( void *  ctx,
const char *  src,
char *  dst,
int  srcSize,
int  dstSize,
int  level 
)
static

Definition at line 521 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_localLZ4_compress_limitedOutput_withState()

static int LZ4F_localLZ4_compress_limitedOutput_withState ( void *  ctx,
const char *  src,
char *  dst,
int  srcSize,
int  dstSize,
int  level 
)
static

Definition at line 515 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_localLZ4_compressHC_limitedOutput_continue()

static int LZ4F_localLZ4_compressHC_limitedOutput_continue ( void *  ctx,
const char *  src,
char *  dst,
int  srcSize,
int  dstSize,
int  level 
)
static

Definition at line 527 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_localSaveDict()

static int LZ4F_localSaveDict ( LZ4F_cctx_t cctxPtr)
static

Definition at line 544 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_optimalBSID()

static LZ4F_blockSizeID_t LZ4F_optimalBSID ( const LZ4F_blockSizeID_t  requestedBSID,
const size_t  srcSize 
)
static

Definition at line 241 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_readLE32()

static U32 LZ4F_readLE32 ( const BYTE srcPtr)
static

Definition at line 188 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_readLE64()

static U64 LZ4F_readLE64 ( const BYTE srcPtr)
static

Definition at line 205 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_selectCompression()

static compressFunc_t LZ4F_selectCompression ( LZ4F_blockMode_t  blockMode,
int  level 
)
static

Definition at line 533 of file lz4frame.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LZ4F_updateDict()

static void LZ4F_updateDict ( LZ4F_dctx_t dctxPtr,
const BYTE dstPtr,
size_t  dstSize,
const BYTE dstPtr0,
unsigned  withinTmp 
)
static

Definition at line 961 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_writeLE32()

static void LZ4F_writeLE32 ( BYTE dstPtr,
U32  value32 
)
static

Definition at line 197 of file lz4frame.c.

Here is the caller graph for this function:

◆ LZ4F_writeLE64()

static void LZ4F_writeLE64 ( BYTE dstPtr,
U64  value64 
)
static

Definition at line 218 of file lz4frame.c.

Here is the caller graph for this function:

Variable Documentation

◆ BHSize

const size_t BHSize = 4
static

Definition at line 107 of file lz4frame.c.

◆ LZ4F_errorStrings

const char* LZ4F_errorStrings[] = { LZ4F_LIST_ERRORS(LZ4F_GENERATE_STRING) }
static

Definition at line 157 of file lz4frame.c.

◆ maxFHSize

const size_t maxFHSize = 15
static

Definition at line 106 of file lz4frame.c.

◆ minFHSize

const size_t minFHSize = 7
static

Definition at line 105 of file lz4frame.c.

◆ minHClevel

const int minHClevel = 3
static

Definition at line 108 of file lz4frame.c.