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

Data Structures

struct  cParams_t
 
struct  LZ4HC_match_t
 
struct  LZ4HC_optimal_t
 

Macros

#define LZ4HC_HEAPMODE   1
 
#define LZ4_HC_STATIC_LINKING_ONLY
 
#define OPTIMAL_ML   (int)((ML_MASK-1)+MINMATCH)
 
#define LZ4_OPT_NUM   (1<<12)
 
#define MIN(a, b)
 
#define MAX(a, b)
 
#define LZ4HC_HASHSIZE   4
 
#define HASH_FUNCTION(i)
 
#define LZ4MID_HASHSIZE   8
 
#define LZ4MID_HASHLOG   (LZ4HC_HASH_LOG-1)
 
#define LZ4MID_HASHTABLESIZE   (1 << LZ4MID_HASHLOG)
 
#define DELTANEXTU16(table, pos)
 
#define UPDATABLE(ip, op, anchor)
 
#define ip   (*_ip)
 
#define op   (*_op)
 
#define anchor   (*_anchor)
 
#define ADDPOS8(_p, _idx)
 
#define ADDPOS4(_p, _idx)
 
#define LZ4HC_rotl32(x, r)
 
#define TRAILING_LITERALS   3
 

Typedefs

typedef LZ4HC_match_t(* LZ4MID_searchIntoDict_f) (const BYTE *ip, U32 ipIndex, const BYTE *const iHighLimit, const LZ4HC_CCtx_internal *dictCtx, U32 gDictEndIndex)
 

Enumerations

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

Functions

LZ4_FORCE_INLINE unsigned LZ4HC_NbCommonBytes32 (U32 val)
 
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_encodeSequence (const BYTE **_ip, BYTE **_op, const BYTE **_anchor, int matchLength, int offset, limitedOutput_directive limit, BYTE *oend)
 
LZ4HC_match_t LZ4HC_searchExtDict (const BYTE *ip, U32 ipIndex, const BYTE *const iLowLimit, const BYTE *const iHighLimit, const LZ4HC_CCtx_internal *dictCtx, U32 gDictEndIndex, int currentBestML, int nbAttempts)
 
LZ4_FORCE_INLINE void LZ4MID_addPosition (U32 *hTable, U32 hValue, U32 index)
 
LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal *hc4, const BYTE *ip)
 
LZ4_FORCE_INLINE LZ4HC_match_t LZ4HC_InsertAndGetWiderMatch (LZ4HC_CCtx_internal *const hc4, const BYTE *const ip, const BYTE *const iLowLimit, const BYTE *const iHighLimit, int longest, const int maxNbAttempts, const int patternAnalysis, const int chainSwap, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)
 
LZ4_FORCE_INLINE LZ4HC_match_t LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal *const hc4, const BYTE *const ip, const BYTE *const iLimit, const int maxNbAttempts, const int patternAnalysis, const dictCtx_directive dict)
 
LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (LZ4HC_CCtx_internal *const ctx, const char *const src, char *const dst, int *srcSizePtr, int const maxOutputSize, int maxNbAttempts, 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)
 
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)
 
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)
 
void * LZ4_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)
 
char * LZ4_slideInputBufferHC (void *LZ4HC_Data)
 

Macro Definition Documentation

◆ ADDPOS4

#define ADDPOS4 ( _p,
_idx )
Value:
LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
LZ4_FORCE_INLINE void LZ4MID_addPosition(U32 *hTable, U32 hValue, U32 index)
Definition lz4hc.c:477

◆ ADDPOS8

#define ADDPOS8 ( _p,
_idx )
Value:
LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)

◆ anchor

#define anchor   (*_anchor)

◆ DELTANEXTU16

#define DELTANEXTU16 ( table,
pos )
Value:
table[(U16)(pos)] /* faster */
static const void size_t const UInt64 * table
Definition XzCrc64.c:50
unsigned short U16
Definition lz4.c:315

◆ HASH_FUNCTION

#define HASH_FUNCTION ( i)
Value:
(((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
#define MINMATCH
Definition lz4.c:242
#define LZ4HC_HASH_LOG
Definition lz4hc.h:226
lzma_index ** i
Definition index.h:629

◆ ip

#define ip   (*_ip)

◆ LZ4_HC_STATIC_LINKING_ONLY

#define LZ4_HC_STATIC_LINKING_ONLY

◆ LZ4_OPT_NUM

#define LZ4_OPT_NUM   (1<<12)

◆ LZ4HC_HASHSIZE

#define LZ4HC_HASHSIZE   4

◆ LZ4HC_HEAPMODE

#define LZ4HC_HEAPMODE   1

HEAPMODE : Select how stateless HC compression functions like LZ4_compress_HC() allocate memory for their workspace: in stack (0:fastest), or in heap (1:default, requires malloc()). Since workspace is rather large, heap mode is recommended.

◆ LZ4HC_rotl32

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

◆ LZ4MID_HASHLOG

#define LZ4MID_HASHLOG   (LZ4HC_HASH_LOG-1)

◆ LZ4MID_HASHSIZE

#define LZ4MID_HASHSIZE   8

◆ LZ4MID_HASHTABLESIZE

#define LZ4MID_HASHTABLESIZE   (1 << LZ4MID_HASHLOG)

◆ MAX

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

◆ MIN

#define MIN ( a,
b )
Value:
( (a) < (b) ? (a) : (b) )

◆ 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 )
Value:
&ip, &op, &anchor
#define op
#define anchor
#define ip

Typedef Documentation

◆ LZ4MID_searchIntoDict_f

typedef LZ4HC_match_t(* LZ4MID_searchIntoDict_f) (const BYTE *ip, U32 ipIndex, const BYTE *const iHighLimit, const LZ4HC_CCtx_internal *dictCtx, U32 gDictEndIndex)

Enumeration Type Documentation

◆ dictCtx_directive

Enumerator
noDictCtx 
usingDictCtxHc 

◆ HCfavor_e

enum HCfavor_e
Enumerator
favorCompressionRatio 
favorDecompressionSpeed 

◆ lz4hc_strat_e

Enumerator
lz4mid 
lz4hc 
lz4opt 

◆ 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_attach_HC_dictionary() : stable since v1.10.0 This API allows for the efficient re-use of a static dictionary many times.

Rather than re-loading the dictionary buffer into a working context before each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a working LZ4_streamHC_t, this function introduces a no-copy setup mechanism, in which the working stream references the dictionary stream in-place.

Several assumptions are made about the state of the dictionary stream. Currently, only streams which have been prepared by LZ4_loadDictHC() should be expected to work.

Alternatively, the provided dictionary stream pointer may be NULL, in which case any existing dictionary stream is unset.

A dictionary should only be attached to a stream without any history (i.e., a stream that has just been reset).

The dictionary will remain attached to the working stream only for the current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the dictionary context association from the working stream. The dictionary stream (and source buffer) must remain in-place / accessible / unchanged through the lifetime of the stream session.

◆ 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_hashChain()

LZ4_FORCE_INLINE int LZ4HC_compress_hashChain ( LZ4HC_CCtx_internal *const ctx,
const char *const src,
char *const dst,
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,
int offset,
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 LZ4HC_match_t LZ4HC_InsertAndFindBestMatch ( LZ4HC_CCtx_internal *const hc4,
const BYTE *const ip,
const BYTE *const iLimit,
const int maxNbAttempts,
const int patternAnalysis,
const dictCtx_directive dict )

◆ LZ4HC_InsertAndGetWiderMatch()

LZ4_FORCE_INLINE LZ4HC_match_t LZ4HC_InsertAndGetWiderMatch ( LZ4HC_CCtx_internal *const hc4,
const BYTE *const ip,
const BYTE *const iLowLimit,
const BYTE *const iHighLimit,
int longest,
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_NbCommonBytes32()

LZ4_FORCE_INLINE unsigned LZ4HC_NbCommonBytes32 ( U32 val)

◆ LZ4HC_searchExtDict()

LZ4HC_match_t LZ4HC_searchExtDict ( const BYTE * ip,
U32 ipIndex,
const BYTE *const iLowLimit,
const BYTE *const iHighLimit,
const LZ4HC_CCtx_internal * dictCtx,
U32 gDictEndIndex,
int currentBestML,
int nbAttempts )

◆ LZ4HC_sequencePrice()

LZ4_FORCE_INLINE int LZ4HC_sequencePrice ( int litlen,
int mlen )

◆ LZ4MID_addPosition()

LZ4_FORCE_INLINE void LZ4MID_addPosition ( U32 * hTable,
U32 hValue,
U32 index )