Classes | Macros | Typedefs | Functions | Variables
lz4hc.h File Reference
#include "lz4.h"

Go to the source code of this file.

Classes

struct  LZ4HC_CCtx_internal
 
union  LZ4_streamHC_u
 

Macros

#define LZ4HC_CLEVEL_MIN   3
 
#define LZ4HC_CLEVEL_DEFAULT   9
 
#define LZ4HC_CLEVEL_OPT_MIN   11
 
#define LZ4HC_CLEVEL_MAX   12
 
#define LZ4HC_DICTIONARY_LOGSIZE   17
 
#define LZ4HC_MAXD   (1<<LZ4HC_DICTIONARY_LOGSIZE)
 
#define LZ4HC_MAXD_MASK   (LZ4HC_MAXD - 1)
 
#define LZ4HC_HASH_LOG   15
 
#define LZ4HC_HASHTABLESIZE   (1 << LZ4HC_HASH_LOG)
 
#define LZ4HC_HASH_MASK   (LZ4HC_HASHTABLESIZE - 1)
 
#define LZ4_STREAMHCSIZE   (4*LZ4HC_HASHTABLESIZE + 2*LZ4HC_MAXD + 56) /* 393268 */
 
#define LZ4_STREAMHCSIZE_SIZET   (LZ4_STREAMHCSIZE / sizeof(size_t))
 

Typedefs

typedef union LZ4_streamHC_u LZ4_streamHC_t
 

Functions

LZ4LIB_API int LZ4_compress_HC (const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
 
LZ4LIB_API int LZ4_compress_HC_extStateHC (void *state, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
 
LZ4LIB_API int LZ4_sizeofStateHC (void)
 
LZ4LIB_API LZ4_streamHC_tLZ4_createStreamHC (void)
 
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t *streamHCPtr)
 
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t *streamHCPtr, int compressionLevel)
 
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t *streamHCPtr, const char *dictionary, int dictSize)
 
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t *streamHCPtr, const char *src, char *dst, int srcSize, int maxDstSize)
 
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t *streamHCPtr, char *safeBuffer, int maxDictSize)
 
 LZ4_DEPRECATED ("use LZ4_compress_HC() instead") int LZ4_compressHC(const char *source
 
 LZ4_DEPRECATED ("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_withStateHC(void *state
 
 LZ4_DEPRECATED ("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_continue(LZ4_streamHC_t *LZ4_streamHCPtr
 
 LZ4_DEPRECATED ("use LZ4_createStreamHC() instead") void *LZ4_createHC(char *inputBuffer)
 
 LZ4_DEPRECATED ("use LZ4_saveDictHC() instead") char *LZ4_slideInputBufferHC(void *LZ4HC_Data)
 
 LZ4_DEPRECATED ("use LZ4_freeStreamHC() instead") int LZ4_freeHC(void *LZ4HC_Data)
 
 LZ4_DEPRECATED ("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void *state
 

Variables

char * dest
 
char int inputSize
 
char int int maxOutputSize
 
char int int compressionLevel
 
const char * source
 
char * inputBuffer
 

Macro Definition Documentation

#define LZ4_STREAMHCSIZE   (4*LZ4HC_HASHTABLESIZE + 2*LZ4HC_MAXD + 56) /* 393268 */

Definition at line 180 of file lz4hc.h.

Referenced by LZ4_sizeofStreamStateHC().

#define LZ4_STREAMHCSIZE_SIZET   (LZ4_STREAMHCSIZE / sizeof(size_t))

Definition at line 181 of file lz4hc.h.

Referenced by LZ4_resetStreamHC().

#define LZ4HC_CLEVEL_DEFAULT   9

Definition at line 48 of file lz4hc.h.

Referenced by calib::ADCShapeFitTable::ADCShapeFitTable(), and LZ4HC_compress_generic().

#define LZ4HC_CLEVEL_MAX   12

Definition at line 50 of file lz4hc.h.

#define LZ4HC_CLEVEL_MIN   3

Definition at line 47 of file lz4hc.h.

#define LZ4HC_CLEVEL_OPT_MIN   11

Definition at line 49 of file lz4hc.h.

Referenced by LZ4_loadDictHC(), and LZ4HC_setExternalDict().

#define LZ4HC_DICTIONARY_LOGSIZE   17

Definition at line 134 of file lz4hc.h.

#define LZ4HC_HASH_LOG   15

Definition at line 138 of file lz4hc.h.

#define LZ4HC_HASH_MASK   (LZ4HC_HASHTABLESIZE - 1)

Definition at line 140 of file lz4hc.h.

#define LZ4HC_HASHTABLESIZE   (1 << LZ4HC_HASH_LOG)

Definition at line 139 of file lz4hc.h.

#define LZ4HC_MAXD   (1<<LZ4HC_DICTIONARY_LOGSIZE)

Definition at line 135 of file lz4hc.h.

#define LZ4HC_MAXD_MASK   (LZ4HC_MAXD - 1)

Definition at line 136 of file lz4hc.h.

Typedef Documentation

Definition at line 87 of file lz4hc.h.

Function Documentation

LZ4LIB_API 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 more 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 : Recommended values are between 4 and 9, although any value between 1 and LZ4HC_MAX_CLEVEL will work. Values >LZ4HC_MAX_CLEVEL behave the same as LZ4HC_MAX_CLEVEL.

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

Definition at line 534 of file lz4hc.cxx.

References LZ4_compress_HC_extStateHC(), and makeDatasetsPage::state.

Referenced by calib::ADCShapeFitTable::ADCShapeFitTable(), LZ4_compressHC(), LZ4_compressHC2(), LZ4_compressHC2_limitedOutput(), and LZ4_compressHC_limitedOutput().

535 {
536 #if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
537  LZ4_streamHC_t* const statePtr = (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t));
538 #else
540  LZ4_streamHC_t* const statePtr = &state;
541 #endif
542  int const cSize = LZ4_compress_HC_extStateHC(statePtr, src, dst, srcSize, maxDstSize, compressionLevel);
543 #if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
544  free(statePtr);
545 #endif
546  return cSize;
547 }
char * dst
Definition: lz4.h:458
char int int maxDstSize
Definition: lz4.h:458
char int int compressionLevel
Definition: lz4hc.h:205
int LZ4_compress_HC_extStateHC(void *state, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
Definition: lz4hc.cxx:523
LZ4LIB_API int LZ4_compress_HC_continue ( LZ4_streamHC_t streamHCPtr,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize 
)

Definition at line 635 of file lz4hc.cxx.

References limitedOutput, LZ4_compressBound(), LZ4_compressHC_continue_generic(), and noLimit.

Referenced by LZ4_compressHC_continue(), and LZ4_compressHC_limitedOutput_continue().

636 {
639  else
641 }
char int int maxOutputSize
Definition: lz4.h:435
static int LZ4_compressHC_continue_generic(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limit)
Definition: lz4hc.cxx:603
const char * source
Definition: lz4.h:436
const char char int inputSize
Definition: lz4.h:436
int LZ4_compressBound(int isize)
Definition: lz4.cxx:395
LZ4LIB_API int LZ4_compress_HC_extStateHC ( void state,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize,
int  compressionLevel 
)

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() will do properly).

Definition at line 523 of file lz4hc.cxx.

References limitedOutput, LZ4_compressBound(), LZ4HC_compress_generic(), LZ4HC_init(), noLimit, and makeDatasetsPage::state.

Referenced by LZ4_compress_HC(), LZ4_compressHC2_limitedOutput_withStateHC(), LZ4_compressHC2_withStateHC(), LZ4_compressHC_limitedOutput_withStateHC(), and LZ4_compressHC_withStateHC().

524 {
525  LZ4HC_CCtx_internal* ctx = &((LZ4_streamHC_t*)state)->internal_donotuse;
526  if (((size_t)(state)&(sizeof(void*)-1)) != 0) return 0; /* Error : state is not aligned for pointers (32 or 64 bits) */
527  LZ4HC_init (ctx, (const BYTE*)src);
528  if (maxDstSize < LZ4_compressBound(srcSize))
529  return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, limitedOutput);
530  else
531  return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, noLimit);
532 }
static void LZ4HC_init(LZ4HC_CCtx_internal *hc4, const BYTE *start)
Definition: lz4hc.cxx:97
char * dst
Definition: lz4.h:458
char int int maxDstSize
Definition: lz4.h:458
static int LZ4HC_compress_generic(LZ4HC_CCtx_internal *const ctx, const char *const source, char *const dest, int const inputSize, int const maxOutputSize, int compressionLevel, limitedOutput_directive limit)
Definition: lz4hc.cxx:498
char int int compressionLevel
Definition: lz4hc.h:205
unsigned char BYTE
Definition: lz4.cxx:146
int LZ4_compressBound(int isize)
Definition: lz4.cxx:395
LZ4LIB_API 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. Existing states can be re-used several times, using LZ4_resetStreamHC(). These methods are API and ABI stable, they can be used in combination with a DLL.

Definition at line 555 of file lz4hc.cxx.

555 { return (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t)); }
LZ4_DEPRECATED ( "use LZ4_compress_HC() instead"  ) const
LZ4_DEPRECATED ( "use LZ4_compress_HC_extStateHC() instead"  )
LZ4_DEPRECATED ( "use LZ4_compress_HC_continue() instead"  )
LZ4_DEPRECATED ( "use LZ4_createStreamHC() instead"  )
LZ4_DEPRECATED ( "use LZ4_saveDictHC() instead"  )
LZ4_DEPRECATED ( "use LZ4_freeStreamHC() instead"  )
LZ4_DEPRECATED ( "use LZ4_resetStreamHC() instead"  )
LZ4LIB_API int LZ4_freeStreamHC ( LZ4_streamHC_t streamHCPtr)

Definition at line 556 of file lz4hc.cxx.

556 { free(LZ4_streamHCPtr); return 0; }
LZ4LIB_API int LZ4_loadDictHC ( LZ4_streamHC_t streamHCPtr,
const char *  dictionary,
int  dictSize 
)

Definition at line 568 of file lz4hc.cxx.

References LZ4HC_CCtx_internal::compressionLevel, LZ4HC_CCtx_internal::end, LZ4_streamHC_u::internal_donotuse, KB, LASTLITERALS, LZ4HC_CLEVEL_OPT_MIN, LZ4HC_init(), LZ4HC_Insert(), LZ4HC_updateBinTree(), and MFLIMIT.

Referenced by LZ4_compressHC_continue_generic().

569 {
570  LZ4HC_CCtx_internal* ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
571  if (dictSize > 64 KB) {
572  dictionary += dictSize - 64 KB;
573  dictSize = 64 KB;
574  }
575  LZ4HC_init (ctxPtr, (const BYTE*)dictionary);
576  ctxPtr->end = (const BYTE*)dictionary + dictSize;
577  if (ctxPtr->compressionLevel >= LZ4HC_CLEVEL_OPT_MIN)
578  LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS);
579  else
580  if (dictSize >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3);
581  return dictSize;
582 }
static void LZ4HC_init(LZ4HC_CCtx_internal *hc4, const BYTE *start)
Definition: lz4hc.cxx:97
#define LZ4HC_CLEVEL_OPT_MIN
Definition: lz4hc.h:49
#define LASTLITERALS
Definition: lz4.cxx:266
FORCE_INLINE void LZ4HC_updateBinTree(LZ4HC_CCtx_internal *ctx, const BYTE *const ip, const BYTE *const iHighLimit)
Definition: lz4opt.h:170
unsigned int compressionLevel
Definition: lz4hc.h:175
unsigned char BYTE
Definition: lz4.cxx:146
FORCE_INLINE void LZ4HC_Insert(LZ4HC_CCtx_internal *hc4, const BYTE *ip)
Definition: lz4hc.cxx:111
#define MFLIMIT
Definition: lz4.cxx:267
#define KB
Definition: lz4.cxx:270
const unsigned char * end
Definition: lz4hc.h:167
LZ4LIB_API void LZ4_resetStreamHC ( LZ4_streamHC_t streamHCPtr,
int  compressionLevel 
)

Definition at line 560 of file lz4hc.cxx.

References LZ4HC_CCtx_internal::base, LZ4HC_CCtx_internal::compressionLevel, LZ4_streamHC_u::internal_donotuse, LZ4_STATIC_ASSERT, LZ4_STREAMHCSIZE_SIZET, LZ4HC_getSearchNum(), and LZ4HC_CCtx_internal::searchNum.

561 {
562  LZ4_STATIC_ASSERT(sizeof(LZ4HC_CCtx_internal) <= sizeof(size_t) * LZ4_STREAMHCSIZE_SIZET); /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */
563  LZ4_streamHCPtr->internal_donotuse.base = NULL;
564  LZ4_streamHCPtr->internal_donotuse.compressionLevel = (unsigned)compressionLevel;
565  LZ4_streamHCPtr->internal_donotuse.searchNum = LZ4HC_getSearchNum(compressionLevel);
566 }
char int int compressionLevel
Definition: lz4hc.h:205
static int LZ4HC_getSearchNum(int compressionLevel)
Definition: lz4hc.cxx:489
#define LZ4_STATIC_ASSERT(c)
Definition: lz4.cxx:286
#define LZ4_STREAMHCSIZE_SIZET
Definition: lz4hc.h:181
LZ4LIB_API int LZ4_saveDictHC ( LZ4_streamHC_t streamHCPtr,
char *  safeBuffer,
int  maxDictSize 
)

Definition at line 646 of file lz4hc.cxx.

References LZ4HC_CCtx_internal::base, LZ4HC_CCtx_internal::dictLimit, LZ4HC_CCtx_internal::end, makeTrainCVSamples::int, LZ4_streamHC_u::internal_donotuse, KB, LZ4HC_CCtx_internal::lowLimit, and LZ4HC_CCtx_internal::nextToUpdate.

Referenced by LZ4_slideInputBufferHC().

647 {
648  LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
649  int const prefixSize = (int)(streamPtr->end - (streamPtr->base + streamPtr->dictLimit));
650  if (dictSize > 64 KB) dictSize = 64 KB;
651  if (dictSize < 4) dictSize = 0;
652  if (dictSize > prefixSize) dictSize = prefixSize;
653  memmove(safeBuffer, streamPtr->end - dictSize, dictSize);
654  { U32 const endIndex = (U32)(streamPtr->end - streamPtr->base);
655  streamPtr->end = (const BYTE*)safeBuffer + dictSize;
656  streamPtr->base = streamPtr->end - endIndex;
657  streamPtr->dictLimit = endIndex - dictSize;
658  streamPtr->lowLimit = endIndex - dictSize;
659  if (streamPtr->nextToUpdate < streamPtr->dictLimit) streamPtr->nextToUpdate = streamPtr->dictLimit;
660  }
661  return dictSize;
662 }
unsigned int dictLimit
Definition: lz4hc.h:171
unsigned int U32
Definition: lz4.cxx:148
unsigned int lowLimit
Definition: lz4hc.h:172
unsigned int nextToUpdate
Definition: lz4hc.h:173
unsigned char BYTE
Definition: lz4.cxx:146
const unsigned char * base
Definition: lz4hc.h:168
#define KB
Definition: lz4.cxx:270
const unsigned char * end
Definition: lz4hc.h:167
LZ4LIB_API int LZ4_sizeofStateHC ( void  )

Definition at line 521 of file lz4hc.cxx.

521 { return sizeof(LZ4_streamHC_t); }
union LZ4_streamHC_u LZ4_streamHC_t
Definition: lz4hc.h:87

Variable Documentation

const char char int int int compressionLevel

Definition at line 205 of file lz4hc.h.

Referenced by hdf5::HDF5Header< Tidx >::Fill(), and hdf5::make_col().

const char char* dest

Definition at line 203 of file lz4hc.h.

char* inputBuffer

Definition at line 221 of file lz4hc.h.

const char char int inputSize

Definition at line 203 of file lz4hc.h.

const char char int int maxOutputSize

Definition at line 204 of file lz4hc.h.

const char* source

Definition at line 207 of file lz4hc.h.