UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
lz4hc.cpp File Reference
#include "Compression/lz4hc.h"
#include "lz4.cpp"

Classes

struct  LZ4HC_optimal_t
 
struct  LZ4HC_match_t
 

Macros

#define LZ4HC_HEAPMODE   1
 
#define LZ4_HC_STATIC_LINKING_ONLY
 
#define LZ4_COMMONDEFS_ONLY
 
#define OPTIMAL_ML   (int)((ML_MASK-1)+MINMATCH)
 
#define LZ4_OPT_NUM   (1<<12)
 
#define HASH_FUNCTION(i)   (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
 
#define DELTANEXTMAXD(p)   chainTable[(p) & LZ4HC_MAXD_MASK] /* flexible, LZ4HC_MAXD dependent */
 
#define DELTANEXTU16(table, pos)   table[(U16)(pos)] /* faster */
 
#define UPDATABLE(ip, op, anchor)   &ip, &op, &anchor
 
#define LZ4HC_rotl32(x, r)   ((x << r) | (x >> (32 - r)))
 
#define ip   (*_ip)
 
#define op   (*_op)
 
#define anchor   (*_anchor)
 
#define TRAILING_LITERALS   3
 

Enumerations

enum  dictCtx_directive { noDictCtx , usingDictCtxHc }
 
enum  repeat_state_e { rep_untested , rep_not , rep_confirmed }
 
enum  HCfavor_e { favorCompressionRatio =0 , favorDecompressionSpeed }
 

Functions

LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal *hc4, const BYTE *ip)
 
LZ4_FORCE_INLINE int LZ4HC_countBack (const BYTE *const ip, const BYTE *const match, const BYTE *const iMin, const BYTE *const mMin)
 
LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (LZ4HC_CCtx_internal *const hc4, const BYTE *const ip, const BYTE *const iLowLimit, const BYTE *const iHighLimit, int longest, const BYTE **matchpos, const BYTE **startpos, const int maxNbAttempts, const int patternAnalysis, const int chainSwap, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)
 
LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal *const hc4, const BYTE *const ip, const BYTE *const iLimit, const BYTE **matchpos, const int maxNbAttempts, const int patternAnalysis, const dictCtx_directive dict)
 
LZ4_FORCE_INLINE int LZ4HC_encodeSequence (const BYTE **_ip, BYTE **_op, const BYTE **_anchor, int matchLength, const BYTE *const match, limitedOutput_directive limit, BYTE *oend)
 
LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (LZ4HC_CCtx_internal *const ctx, const char *const source, char *const dest, int *srcSizePtr, int const maxOutputSize, int maxNbAttempts, const limitedOutput_directive limit, const dictCtx_directive dict)
 
LZ4_FORCE_INLINE int LZ4HC_compress_generic_internal (LZ4HC_CCtx_internal *const ctx, const char *const src, char *const dst, int *const srcSizePtr, int const dstCapacity, int cLevel, const limitedOutput_directive limit, const dictCtx_directive dict)
 
int LZ4_sizeofStateHC (void)
 
int LZ4_compress_HC_extStateHC_fastReset (void *state, const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
 
int LZ4_compress_HC_extStateHC (void *state, const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
 
int LZ4_compress_HC (const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
 
int LZ4_compress_HC_destSize (void *state, const char *source, char *dest, int *sourceSizePtr, int targetDestSize, int cLevel)
 
LZ4_streamHC_tLZ4_createStreamHC (void)
 
int LZ4_freeStreamHC (LZ4_streamHC_t *LZ4_streamHCPtr)
 
LZ4_streamHC_tLZ4_initStreamHC (void *buffer, size_t size)
 
void LZ4_resetStreamHC (LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
 
void LZ4_resetStreamHC_fast (LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
 
void LZ4_setCompressionLevel (LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
 
void LZ4_favorDecompressionSpeed (LZ4_streamHC_t *LZ4_streamHCPtr, int favor)
 
int LZ4_loadDictHC (LZ4_streamHC_t *LZ4_streamHCPtr, const char *dictionary, int dictSize)
 
void LZ4_attach_HC_dictionary (LZ4_streamHC_t *working_stream, const LZ4_streamHC_t *dictionary_stream)
 
int LZ4_compress_HC_continue (LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int srcSize, int dstCapacity)
 
int LZ4_compress_HC_continue_destSize (LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int *srcSizePtr, int targetDestSize)
 
int LZ4_saveDictHC (LZ4_streamHC_t *LZ4_streamHCPtr, char *safeBuffer, int dictSize)
 
int LZ4_compressHC (const char *src, char *dst, int srcSize)
 
int LZ4_compressHC_limitedOutput (const char *src, char *dst, int srcSize, int maxDstSize)
 
int LZ4_compressHC2 (const char *src, char *dst, int srcSize, int cLevel)
 
int LZ4_compressHC2_limitedOutput (const char *src, char *dst, int srcSize, int maxDstSize, int cLevel)
 
int LZ4_compressHC_withStateHC (void *state, const char *src, char *dst, int srcSize)
 
int LZ4_compressHC_limitedOutput_withStateHC (void *state, const char *src, char *dst, int srcSize, int maxDstSize)
 
int LZ4_compressHC2_withStateHC (void *state, const char *src, char *dst, int srcSize, int cLevel)
 
int LZ4_compressHC2_limitedOutput_withStateHC (void *state, const char *src, char *dst, int srcSize, int maxDstSize, int cLevel)
 
int LZ4_compressHC_continue (LZ4_streamHC_t *ctx, const char *src, char *dst, int srcSize)
 
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t *ctx, const char *src, char *dst, int srcSize, int maxDstSize)
 
int LZ4_sizeofStreamStateHC (void)
 
int LZ4_resetStreamStateHC (void *state, char *inputBuffer)
 
voidLZ4_createHC (const char *inputBuffer)
 
int LZ4_freeHC (void *LZ4HC_Data)
 
int LZ4_compressHC2_continue (void *LZ4HC_Data, const char *src, char *dst, int srcSize, int cLevel)
 
int LZ4_compressHC2_limitedOutput_continue (void *LZ4HC_Data, const char *src, char *dst, int srcSize, int dstCapacity, int cLevel)
 
charLZ4_slideInputBufferHC (void *LZ4HC_Data)
 
LZ4_FORCE_INLINE int LZ4HC_literalsPrice (int const litlen)
 
LZ4_FORCE_INLINE int LZ4HC_sequencePrice (int litlen, int mlen)
 
LZ4_FORCE_INLINE LZ4HC_match_t LZ4HC_FindLongerMatch (LZ4HC_CCtx_internal *const ctx, const BYTE *ip, const BYTE *const iHighLimit, int minLen, int nbSearches, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)
 

Macro Definition Documentation

◆ anchor

#define anchor   (*_anchor)

◆ DELTANEXTMAXD

#define DELTANEXTMAXD (   p)    chainTable[(p) & LZ4HC_MAXD_MASK] /* flexible, LZ4HC_MAXD dependent */

◆ DELTANEXTU16

#define DELTANEXTU16 (   table,
  pos 
)    table[(U16)(pos)] /* faster */

◆ HASH_FUNCTION

#define HASH_FUNCTION (   i)    (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))

◆ ip

#define ip   (*_ip)

◆ LZ4_COMMONDEFS_ONLY

#define LZ4_COMMONDEFS_ONLY

◆ LZ4_HC_STATIC_LINKING_ONLY

#define LZ4_HC_STATIC_LINKING_ONLY

◆ LZ4_OPT_NUM

#define LZ4_OPT_NUM   (1<<12)

◆ LZ4HC_HEAPMODE

#define LZ4HC_HEAPMODE   1

HEAPMODE : Select how default compression function will allocate workplace memory, in stack (0:fastest), or in heap (1:requires malloc()). Since workplace is rather large, heap mode is recommended.

◆ LZ4HC_rotl32

#define LZ4HC_rotl32 (   x,
 
)    ((x << r) | (x >> (32 - r)))

◆ op

#define op   (*_op)

◆ OPTIMAL_ML

#define OPTIMAL_ML   (int)((ML_MASK-1)+MINMATCH)

◆ TRAILING_LITERALS

#define TRAILING_LITERALS   3

◆ UPDATABLE

#define UPDATABLE (   ip,
  op,
  anchor 
)    &ip, &op, &anchor

Enumeration Type Documentation

◆ dictCtx_directive

Enumerator
noDictCtx 
usingDictCtxHc 

◆ HCfavor_e

Enumerator
favorCompressionRatio 
favorDecompressionSpeed 

◆ repeat_state_e

Enumerator
rep_untested 
rep_not 
rep_confirmed 

Function Documentation

◆ LZ4_attach_HC_dictionary()

void LZ4_attach_HC_dictionary ( LZ4_streamHC_t working_stream,
const LZ4_streamHC_t dictionary_stream 
)

◆ LZ4_compress_HC()

int LZ4_compress_HC ( const char src,
char dst,
int  srcSize,
int  dstCapacity,
int  compressionLevel 
)

LZ4_compress_HC() : Compress data from src into dst, using the powerful but slower "HC" algorithm. dst must be already allocated. Compression is guaranteed to succeed if dstCapacity >= LZ4_compressBound(srcSize) (see "lz4.h") Max supported srcSize value is LZ4_MAX_INPUT_SIZE (see "lz4.h") compressionLevel : any value between 1 and LZ4HC_CLEVEL_MAX will work. Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.

Returns
: the number of bytes written into 'dst' or 0 if compression fails.

◆ LZ4_compress_HC_continue()

int LZ4_compress_HC_continue ( LZ4_streamHC_t LZ4_streamHCPtr,
const char src,
char dst,
int  srcSize,
int  dstCapacity 
)

◆ LZ4_compress_HC_continue_destSize()

int LZ4_compress_HC_continue_destSize ( LZ4_streamHC_t LZ4_streamHCPtr,
const char src,
char dst,
int *  srcSizePtr,
int  targetDstSize 
)

LZ4_compress_HC_continue_destSize() : v1.9.0+ Similar to LZ4_compress_HC_continue(), but will read as much data as possible from src to fit into targetDstSize budget. Result is provided into 2 parts :

Returns
: the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr will be updated to indicate how much bytes were read from src. Note that this function may not consume the entire input.

◆ LZ4_compress_HC_destSize()

int LZ4_compress_HC_destSize ( void stateHC,
const char src,
char dst,
int *  srcSizePtr,
int  targetDstSize,
int  compressionLevel 
)

LZ4_compress_HC_destSize() : v1.9.0+ Will compress as much data as possible from src to fit into targetDstSize budget. Result is provided in 2 parts :

Returns
: the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr is updated to indicate how much bytes were read from src

◆ LZ4_compress_HC_extStateHC()

int LZ4_compress_HC_extStateHC ( void state,
const char src,
char dst,
int  srcSize,
int  dstCapacity,
int  compressionLevel 
)

◆ LZ4_compress_HC_extStateHC_fastReset()

int LZ4_compress_HC_extStateHC_fastReset ( void state,
const char src,
char dst,
int  srcSize,
int  dstCapacity,
int  compressionLevel 
)

◆ LZ4_compressHC()

int LZ4_compressHC ( const char src,
char dst,
int  srcSize 
)

◆ LZ4_compressHC2()

int LZ4_compressHC2 ( const char src,
char dst,
int  srcSize,
int  cLevel 
)

◆ LZ4_compressHC2_continue()

int LZ4_compressHC2_continue ( void LZ4HC_Data,
const char src,
char dst,
int  srcSize,
int  cLevel 
)

◆ LZ4_compressHC2_limitedOutput()

int LZ4_compressHC2_limitedOutput ( const char src,
char dst,
int  srcSize,
int  maxDstSize,
int  cLevel 
)

◆ LZ4_compressHC2_limitedOutput_continue()

int LZ4_compressHC2_limitedOutput_continue ( void LZ4HC_Data,
const char src,
char dst,
int  srcSize,
int  dstCapacity,
int  cLevel 
)

◆ LZ4_compressHC2_limitedOutput_withStateHC()

int LZ4_compressHC2_limitedOutput_withStateHC ( void state,
const char src,
char dst,
int  srcSize,
int  maxDstSize,
int  cLevel 
)

◆ LZ4_compressHC2_withStateHC()

int LZ4_compressHC2_withStateHC ( void state,
const char src,
char dst,
int  srcSize,
int  cLevel 
)

◆ LZ4_compressHC_continue()

int LZ4_compressHC_continue ( LZ4_streamHC_t ctx,
const char src,
char dst,
int  srcSize 
)

◆ LZ4_compressHC_limitedOutput()

int LZ4_compressHC_limitedOutput ( const char src,
char dst,
int  srcSize,
int  maxDstSize 
)

◆ LZ4_compressHC_limitedOutput_continue()

int LZ4_compressHC_limitedOutput_continue ( LZ4_streamHC_t ctx,
const char src,
char dst,
int  srcSize,
int  maxDstSize 
)

◆ LZ4_compressHC_limitedOutput_withStateHC()

int LZ4_compressHC_limitedOutput_withStateHC ( void state,
const char src,
char dst,
int  srcSize,
int  maxDstSize 
)

◆ LZ4_compressHC_withStateHC()

int LZ4_compressHC_withStateHC ( void state,
const char src,
char dst,
int  srcSize 
)

◆ LZ4_createHC()

void * LZ4_createHC ( const char inputBuffer)

◆ LZ4_createStreamHC()

LZ4_streamHC_t * LZ4_createStreamHC ( void  )

LZ4_createStreamHC() and LZ4_freeStreamHC() : These functions create and release memory for LZ4 HC streaming state. Newly created states are automatically initialized. A same state can be used multiple times consecutively, starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.

◆ LZ4_favorDecompressionSpeed()

void LZ4_favorDecompressionSpeed ( LZ4_streamHC_t LZ4_streamHCPtr,
int  favor 
)

◆ LZ4_freeHC()

int LZ4_freeHC ( void LZ4HC_Data)

◆ LZ4_freeStreamHC()

int LZ4_freeStreamHC ( LZ4_streamHC_t LZ4_streamHCPtr)

◆ LZ4_initStreamHC()

LZ4_streamHC_t * LZ4_initStreamHC ( void buffer,
size_t  size 
)

◆ LZ4_loadDictHC()

int LZ4_loadDictHC ( LZ4_streamHC_t LZ4_streamHCPtr,
const char dictionary,
int  dictSize 
)

◆ LZ4_resetStreamHC()

void LZ4_resetStreamHC ( LZ4_streamHC_t LZ4_streamHCPtr,
int  compressionLevel 
)

◆ LZ4_resetStreamHC_fast()

void LZ4_resetStreamHC_fast ( LZ4_streamHC_t LZ4_streamHCPtr,
int  compressionLevel 
)

◆ LZ4_resetStreamStateHC()

int LZ4_resetStreamStateHC ( void state,
char inputBuffer 
)

◆ LZ4_saveDictHC()

int LZ4_saveDictHC ( LZ4_streamHC_t LZ4_streamHCPtr,
char safeBuffer,
int  dictSize 
)

◆ LZ4_setCompressionLevel()

void LZ4_setCompressionLevel ( LZ4_streamHC_t LZ4_streamHCPtr,
int  compressionLevel 
)

◆ LZ4_sizeofStateHC()

int LZ4_sizeofStateHC ( void  )

LZ4_compress_HC_extStateHC() : Same as LZ4_compress_HC(), but using an externally allocated memory segment for state. state size is provided by LZ4_sizeofStateHC(). Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).

◆ LZ4_sizeofStreamStateHC()

int LZ4_sizeofStreamStateHC ( void  )

◆ LZ4_slideInputBufferHC()

char * LZ4_slideInputBufferHC ( void LZ4HC_Data)

◆ LZ4HC_compress_generic_internal()

LZ4_FORCE_INLINE int LZ4HC_compress_generic_internal ( LZ4HC_CCtx_internal *const  ctx,
const char *const  src,
char *const  dst,
int *const  srcSizePtr,
int const  dstCapacity,
int  cLevel,
const limitedOutput_directive  limit,
const dictCtx_directive  dict 
)

◆ LZ4HC_compress_hashChain()

LZ4_FORCE_INLINE int LZ4HC_compress_hashChain ( LZ4HC_CCtx_internal *const  ctx,
const char *const  source,
char *const  dest,
int *  srcSizePtr,
int const  maxOutputSize,
int  maxNbAttempts,
const limitedOutput_directive  limit,
const dictCtx_directive  dict 
)

◆ LZ4HC_countBack()

LZ4_FORCE_INLINE int LZ4HC_countBack ( const BYTE *const  ip,
const BYTE *const  match,
const BYTE *const  iMin,
const BYTE *const  mMin 
)

LZ4HC_countBack() :

Returns
: negative value, nb of common bytes before ip/match

◆ LZ4HC_encodeSequence()

LZ4_FORCE_INLINE int LZ4HC_encodeSequence ( const BYTE **  _ip,
BYTE **  _op,
const BYTE **  _anchor,
int  matchLength,
const BYTE *const  match,
limitedOutput_directive  limit,
BYTE oend 
)

◆ LZ4HC_FindLongerMatch()

LZ4_FORCE_INLINE LZ4HC_match_t LZ4HC_FindLongerMatch ( LZ4HC_CCtx_internal *const  ctx,
const BYTE ip,
const BYTE *const  iHighLimit,
int  minLen,
int  nbSearches,
const dictCtx_directive  dict,
const HCfavor_e  favorDecSpeed 
)

◆ LZ4HC_Insert()

LZ4_FORCE_INLINE void LZ4HC_Insert ( LZ4HC_CCtx_internal hc4,
const BYTE ip 
)

◆ LZ4HC_InsertAndFindBestMatch()

LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch ( LZ4HC_CCtx_internal *const  hc4,
const BYTE *const  ip,
const BYTE *const  iLimit,
const BYTE **  matchpos,
const int  maxNbAttempts,
const int  patternAnalysis,
const dictCtx_directive  dict 
)

◆ LZ4HC_InsertAndGetWiderMatch()

LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( LZ4HC_CCtx_internal *const  hc4,
const BYTE *const  ip,
const BYTE *const  iLowLimit,
const BYTE *const  iHighLimit,
int  longest,
const BYTE **  matchpos,
const BYTE **  startpos,
const int  maxNbAttempts,
const int  patternAnalysis,
const int  chainSwap,
const dictCtx_directive  dict,
const HCfavor_e  favorDecSpeed 
)

◆ LZ4HC_literalsPrice()

LZ4_FORCE_INLINE int LZ4HC_literalsPrice ( int const  litlen)

◆ LZ4HC_sequencePrice()

LZ4_FORCE_INLINE int LZ4HC_sequencePrice ( int  litlen,
int  mlen 
)