Macros | Typedefs | Enumerations | Functions | Variables
lz4.cxx File Reference
#include "lz4.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define HEAPMODE   0
 
#define ACCELERATION_DEFAULT   1
 
#define FORCE_INLINE   static
 
#define expect(expr, value)    (expr)
 
#define likely(expr)    expect((expr) != 0, 1)
 
#define unlikely(expr)    expect((expr) != 0, 0)
 
#define ALLOCATOR(n, s)   calloc(n,s)
 
#define FREEMEM   free
 
#define MEM_INIT   memset
 
#define MINMATCH   4
 
#define WILDCOPYLENGTH   8
 
#define LASTLITERALS   5
 
#define MFLIMIT   (WILDCOPYLENGTH+MINMATCH)
 
#define KB   *(1 <<10)
 
#define MB   *(1 <<20)
 
#define GB   *(1U<<30)
 
#define MAXD_LOG   16
 
#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)
 
#define ML_BITS   4
 
#define ML_MASK   ((1U<<ML_BITS)-1)
 
#define RUN_BITS   (8-ML_BITS)
 
#define RUN_MASK   ((1U<<RUN_BITS)-1)
 
#define LZ4_STATIC_ASSERT(c)    { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
 
#define STEPSIZE   sizeof(reg_t)
 
#define HASH_UNIT   sizeof(reg_t)
 

Typedefs

typedef unsigned char BYTE
 
typedef unsigned short U16
 
typedef unsigned int U32
 
typedef signed int S32
 
typedef unsigned long long U64
 
typedef size_t uptrval
 
typedef size_t reg_t
 

Enumerations

enum  limitedOutput_directive { notLimited = 0, limitedOutput = 1, noLimit = 0, limitedOutput = 1 }
 
enum  tableType_t { byPtr, byU32, byU16 }
 
enum  dict_directive { noDict = 0, withPrefix64k, usingExtDict }
 
enum  dictIssue_directive { noDictIssue = 0, dictSmall }
 
enum  endCondition_directive { endOnOutputSize = 0, endOnInputSize = 1 }
 
enum  earlyEnd_directive { full = 0, partial = 1 }
 

Functions

static unsigned LZ4_isLittleEndian (void)
 
static U16 LZ4_read16 (const void *memPtr)
 
static U32 LZ4_read32 (const void *memPtr)
 
static reg_t LZ4_read_ARCH (const void *memPtr)
 
static void LZ4_write16 (void *memPtr, U16 value)
 
static void LZ4_write32 (void *memPtr, U32 value)
 
static U16 LZ4_readLE16 (const void *memPtr)
 
static void LZ4_writeLE16 (void *memPtr, U16 value)
 
static void LZ4_copy8 (void *dst, const void *src)
 
static void LZ4_wildCopy (void *dstPtr, const void *srcPtr, void *dstEnd)
 
static unsigned LZ4_NbCommonBytes (reg_t val)
 
static unsigned LZ4_count (const BYTE *pIn, const BYTE *pMatch, const BYTE *pInLimit)
 
int LZ4_versionNumber (void)
 
const char * LZ4_versionString (void)
 
int LZ4_compressBound (int isize)
 
int LZ4_sizeofState ()
 
static U32 LZ4_hash4 (U32 sequence, tableType_t const tableType)
 
static U32 LZ4_hash5 (U64 sequence, tableType_t const tableType)
 
FORCE_INLINE U32 LZ4_hashPosition (const void *const p, tableType_t const tableType)
 
static void LZ4_putPositionOnHash (const BYTE *p, U32 h, void *tableBase, tableType_t const tableType, const BYTE *srcBase)
 
FORCE_INLINE void LZ4_putPosition (const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
static const BYTELZ4_getPositionOnHash (U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE const BYTELZ4_getPosition (const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE int LZ4_compress_generic (LZ4_stream_t_internal *const cctx, const char *const source, char *const dest, const int inputSize, const int maxOutputSize, const limitedOutput_directive outputLimited, const tableType_t tableType, const dict_directive dict, const dictIssue_directive dictIssue, const U32 acceleration)
 
int LZ4_compress_fast_extState (void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
 
int LZ4_compress_fast (const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
 
int LZ4_compress_default (const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_compress_fast_force (const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
 
static int LZ4_compress_destSize_generic (LZ4_stream_t_internal *const ctx, const char *const src, char *const dst, int *const srcSizePtr, const int targetDstSize, const tableType_t tableType)
 
static int LZ4_compress_destSize_extState (LZ4_stream_t *state, const char *src, char *dst, int *srcSizePtr, int targetDstSize)
 
int LZ4_compress_destSize (const char *src, char *dst, int *srcSizePtr, int targetDstSize)
 
LZ4_stream_tLZ4_createStream (void)
 
void LZ4_resetStream (LZ4_stream_t *LZ4_stream)
 
int LZ4_freeStream (LZ4_stream_t *LZ4_stream)
 
int LZ4_loadDict (LZ4_stream_t *LZ4_dict, const char *dictionary, int dictSize)
 
static void LZ4_renormDictT (LZ4_stream_t_internal *LZ4_dict, const BYTE *src)
 
int LZ4_compress_fast_continue (LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
 
int LZ4_compress_forceExtDict (LZ4_stream_t *LZ4_dict, const char *source, char *dest, int inputSize)
 
int LZ4_saveDict (LZ4_stream_t *LZ4_dict, char *safeBuffer, int dictSize)
 
FORCE_INLINE int LZ4_decompress_generic (const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
 
int LZ4_decompress_safe (const char *source, char *dest, int compressedSize, int maxDecompressedSize)
 
int LZ4_decompress_safe_partial (const char *source, char *dest, int compressedSize, int targetOutputSize, int maxDecompressedSize)
 
int LZ4_decompress_fast (const char *source, char *dest, int originalSize)
 
LZ4_streamDecode_tLZ4_createStreamDecode (void)
 
int LZ4_freeStreamDecode (LZ4_streamDecode_t *LZ4_stream)
 
int LZ4_setStreamDecode (LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
 
int LZ4_decompress_safe_continue (LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int compressedSize, int maxOutputSize)
 
int LZ4_decompress_fast_continue (LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int originalSize)
 
FORCE_INLINE int LZ4_decompress_usingDict_generic (const char *source, char *dest, int compressedSize, int maxOutputSize, int safe, const char *dictStart, int dictSize)
 
int LZ4_decompress_safe_usingDict (const char *source, char *dest, int compressedSize, int maxOutputSize, const char *dictStart, int dictSize)
 
int LZ4_decompress_fast_usingDict (const char *source, char *dest, int originalSize, const char *dictStart, int dictSize)
 
int LZ4_decompress_safe_forceExtDict (const char *source, char *dest, int compressedSize, int maxOutputSize, const char *dictStart, int dictSize)
 
int LZ4_compress_limitedOutput (const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_compress (const char *source, char *dest, int inputSize)
 
int LZ4_compress_limitedOutput_withState (void *state, const char *src, char *dst, int srcSize, int dstSize)
 
int LZ4_compress_withState (void *state, const char *src, char *dst, int srcSize)
 
int LZ4_compress_limitedOutput_continue (LZ4_stream_t *LZ4_stream, const char *src, char *dst, int srcSize, int maxDstSize)
 
int LZ4_compress_continue (LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize)
 
int LZ4_uncompress (const char *source, char *dest, int outputSize)
 
int LZ4_uncompress_unknownOutputSize (const char *source, char *dest, int isize, int maxOutputSize)
 
int LZ4_sizeofStreamState ()
 
static void LZ4_init (LZ4_stream_t *lz4ds, BYTE *base)
 
int LZ4_resetStreamState (void *state, char *inputBuffer)
 
voidLZ4_create (char *inputBuffer)
 
char * LZ4_slideInputBuffer (void *LZ4_Data)
 
int LZ4_decompress_safe_withPrefix64k (const char *source, char *dest, int compressedSize, int maxOutputSize)
 
int LZ4_decompress_fast_withPrefix64k (const char *source, char *dest, int originalSize)
 

Variables

static const int LZ4_minLength = (MFLIMIT+1)
 
static const int LZ4_64Klimit = ((64 KB) + (MFLIMIT-1))
 
static const U32 LZ4_skipTrigger = 6
 

Macro Definition Documentation

#define ACCELERATION_DEFAULT   1

Definition at line 52 of file lz4.cxx.

Referenced by LZ4_compress_fast_continue(), and LZ4_compress_fast_extState().

#define ALLOCATOR (   n,
  s 
)    calloc(n,s)
#define expect (   expr,
  value 
)    (expr)

Definition at line 117 of file lz4.cxx.

Referenced by photrans::ImprovedTransport::CreatePhotoElectrons().

#define FORCE_INLINE   static

Definition at line 110 of file lz4.cxx.

#define FREEMEM   free
#define GB   *(1U<<30)

Definition at line 272 of file lz4.cxx.

Referenced by LZ4_compressHC_continue_generic(), and LZ4_loadDict().

#define HASH_UNIT   sizeof(reg_t)

Definition at line 935 of file lz4.cxx.

Referenced by LZ4_loadDict().

#define HEAPMODE   0

Definition at line 45 of file lz4.cxx.

#define KB   *(1 <<10)
#define LASTLITERALS   5
#define likely (   expr)    expect((expr) != 0, 1)
#define LZ4_STATIC_ASSERT (   c)    { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */

Definition at line 286 of file lz4.cxx.

Referenced by LZ4_createStream(), and LZ4_resetStreamHC().

#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)
#define MAXD_LOG   16

Definition at line 274 of file lz4.cxx.

#define MB   *(1 <<20)

Definition at line 271 of file lz4.cxx.

#define MEM_INIT   memset

Definition at line 131 of file lz4.cxx.

Referenced by LZ4_init(), LZ4_resetStream(), and LZ4HC_init().

#define MFLIMIT   (WILDCOPYLENGTH+MINMATCH)
#define MINMATCH   4
#define ML_BITS   4
#define ML_MASK   ((1U<<ML_BITS)-1)
#define RUN_BITS   (8-ML_BITS)

Definition at line 279 of file lz4.cxx.

#define RUN_MASK   ((1U<<RUN_BITS)-1)
#define STEPSIZE   sizeof(reg_t)

Definition at line 350 of file lz4.cxx.

Referenced by LZ4_count().

#define unlikely (   expr)    expect((expr) != 0, 0)
#define WILDCOPYLENGTH   8

Definition at line 265 of file lz4.cxx.

Referenced by LZ4_decompress_generic().

Typedef Documentation

typedef unsigned char BYTE

Definition at line 146 of file lz4.cxx.

typedef size_t reg_t

Definition at line 157 of file lz4.cxx.

typedef signed int S32

Definition at line 149 of file lz4.cxx.

typedef unsigned short U16

Definition at line 147 of file lz4.cxx.

typedef unsigned int U32

Definition at line 148 of file lz4.cxx.

typedef unsigned long long U64

Definition at line 150 of file lz4.cxx.

typedef size_t uptrval

Definition at line 151 of file lz4.cxx.

Enumeration Type Documentation

Enumerator
noDict 
withPrefix64k 
usingExtDict 

Definition at line 383 of file lz4.cxx.

Enumerator
noDictIssue 
dictSmall 

Definition at line 384 of file lz4.cxx.

dictIssue_directive
Definition: lz4.cxx:384
Enumerator
full 
partial 

Definition at line 387 of file lz4.cxx.

387 { full = 0, partial = 1 } earlyEnd_directive;
Definition: lz4.cxx:387
Definition: lz4.cxx:387
earlyEnd_directive
Definition: lz4.cxx:387
Enumerator
endOnOutputSize 
endOnInputSize 

Definition at line 386 of file lz4.cxx.

Enumerator
notLimited 
limitedOutput 
noLimit 
limitedOutput 

Definition at line 380 of file lz4.cxx.

limitedOutput_directive
Definition: lz4.cxx:380
Enumerator
byPtr 
byU32 
byU16 

Definition at line 381 of file lz4.cxx.

tableType_t
Definition: lz4.cxx:381
Definition: lz4.cxx:381
Definition: lz4.cxx:381
Definition: lz4.cxx:381

Function Documentation

int LZ4_compress ( const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 1404 of file lz4.cxx.

References LZ4_compress_default(), and LZ4_compressBound().

int LZ4_compress_default(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.cxx:697
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
int LZ4_compress_continue ( LZ4_stream_t LZ4_stream,
const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 1408 of file lz4.cxx.

References LZ4_compress_fast_continue(), and LZ4_compressBound().

int LZ4_compress_fast_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:987
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
int LZ4_compress_default ( const char *  source,
char *  dest,
int  sourceSize,
int  maxDestSize 
)

LZ4_compress_default() : Compresses 'sourceSize' bytes from buffer 'source' into already allocated 'dest' buffer of size 'maxDestSize'. Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize). It also runs faster, so it's a recommended setting. If the function cannot compress 'source' into a more limited 'dest' budget, compression stops immediately, and the function result is zero. As a consequence, 'dest' content is not valid. This function never writes outside 'dest' buffer, nor read outside 'source' buffer. sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE maxDestSize : full or partial size of buffer 'dest' (which must be already allocated) return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize) or 0 if compression fails

Definition at line 697 of file lz4.cxx.

References LZ4_compress_fast().

Referenced by LZ4_compress(), and LZ4_compress_limitedOutput().

698 {
700 }
char int int maxOutputSize
Definition: lz4.h:435
const char * source
Definition: lz4.h:436
int LZ4_compress_fast(const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:679
const char char int inputSize
Definition: lz4.h:436
int LZ4_compress_destSize ( const char *  source,
char *  dest,
int sourceSizePtr,
int  targetDestSize 
)

LZ4_compress_destSize() : Reverse the logic, by compressing as much data as possible from 'source' buffer into already allocated buffer 'dest' of size 'targetDestSize'. This function either compresses the entire 'source' content into 'dest' if it's large enough, or fill 'dest' buffer completely with as much data as possible from 'source'. sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'. New value is necessarily <= old value. return : Nb bytes written into 'dest' (necessarily <= targetDestSize) or 0 if compression fails

Definition at line 892 of file lz4.cxx.

References ALLOCATOR, FREEMEM, LZ4_compress_destSize_extState(), and fillBadChanDBTables::result.

893 {
894 #if (HEAPMODE)
895  LZ4_stream_t* ctx = (LZ4_stream_t*)ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */
896 #else
897  LZ4_stream_t ctxBody;
898  LZ4_stream_t* ctx = &ctxBody;
899 #endif
900 
901  int result = LZ4_compress_destSize_extState(ctx, src, dst, srcSizePtr, targetDstSize);
902 
903 #if (HEAPMODE)
904  FREEMEM(ctx);
905 #endif
906  return result;
907 }
#define FREEMEM
Definition: lz4.cxx:129
#define ALLOCATOR(n, s)
Definition: lz4.cxx:128
char * dst
Definition: lz4.h:458
static int LZ4_compress_destSize_extState(LZ4_stream_t *state, const char *src, char *dst, int *srcSizePtr, int targetDstSize)
Definition: lz4.cxx:877
static int LZ4_compress_destSize_extState ( LZ4_stream_t state,
const char *  src,
char *  dst,
int srcSizePtr,
int  targetDstSize 
)
static

Definition at line 877 of file lz4.cxx.

References byPtr, byU16, byU32, LZ4_stream_u::internal_donotuse, LZ4_64Klimit, LZ4_compress_destSize_generic(), LZ4_compress_fast_extState(), LZ4_compressBound(), and LZ4_resetStream().

Referenced by LZ4_compress_destSize().

878 {
879  LZ4_resetStream(state);
880 
881  if (targetDstSize >= LZ4_compressBound(*srcSizePtr)) { /* compression success is guaranteed */
882  return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, 1);
883  } else {
884  if (*srcSizePtr < LZ4_64Klimit)
885  return LZ4_compress_destSize_generic(&state->internal_donotuse, src, dst, srcSizePtr, targetDstSize, byU16);
886  else
887  return LZ4_compress_destSize_generic(&state->internal_donotuse, src, dst, srcSizePtr, targetDstSize, sizeof(void*)==8 ? byU32 : byPtr);
888  }
889 }
static const int LZ4_64Klimit
Definition: lz4.cxx:373
char * dst
Definition: lz4.h:458
Definition: lz4.cxx:381
int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:659
Definition: lz4.cxx:381
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
Definition: lz4.cxx:381
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
Definition: lz4.cxx:923
int LZ4_compressBound(int isize)
Definition: lz4.cxx:395
static int LZ4_compress_destSize_generic(LZ4_stream_t_internal *const ctx, const char *const src, char *const dst, int *const srcSizePtr, const int targetDstSize, const tableType_t tableType)
Definition: lz4.cxx:721
static int LZ4_compress_destSize_generic ( LZ4_stream_t_internal *const  ctx,
const char *const  src,
char *const  dst,
int *const  srcSizePtr,
const int  targetDstSize,
const tableType_t  tableType 
)
static

Definition at line 721 of file lz4.cxx.

References byU16, dst, make_syst_table_plots::h, LZ4_stream_t_internal::hashTable, makeTrainCVSamples::int, ip, LASTLITERALS, LZ4_64Klimit, LZ4_count(), LZ4_getPosition(), LZ4_getPositionOnHash(), LZ4_hashPosition(), LZ4_MAX_INPUT_SIZE, LZ4_minLength, LZ4_putPosition(), LZ4_putPositionOnHash(), LZ4_read32(), LZ4_skipTrigger, LZ4_wildCopy(), LZ4_writeLE16(), cafExposure::match, MAX_DISTANCE, MFLIMIT, MINMATCH, ML_BITS, ML_MASK, RUN_MASK, fillBadChanDBTables::step, and unlikely.

Referenced by LZ4_compress_destSize_extState().

728 {
729  const BYTE* ip = (const BYTE*) src;
730  const BYTE* base = (const BYTE*) src;
731  const BYTE* lowLimit = (const BYTE*) src;
732  const BYTE* anchor = ip;
733  const BYTE* const iend = ip + *srcSizePtr;
734  const BYTE* const mflimit = iend - MFLIMIT;
735  const BYTE* const matchlimit = iend - LASTLITERALS;
736 
737  BYTE* op = (BYTE*) dst;
738  BYTE* const oend = op + targetDstSize;
739  BYTE* const oMaxLit = op + targetDstSize - 2 /* offset */ - 8 /* because 8+MINMATCH==MFLIMIT */ - 1 /* token */;
740  BYTE* const oMaxMatch = op + targetDstSize - (LASTLITERALS + 1 /* token */);
741  BYTE* const oMaxSeq = oMaxLit - 1 /* token */;
742 
743  U32 forwardH;
744 
745 
746  /* Init conditions */
747  if (targetDstSize < 1) return 0; /* Impossible to store anything */
748  if ((U32)*srcSizePtr > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */
749  if ((tableType == byU16) && (*srcSizePtr>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
750  if (*srcSizePtr<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
751 
752  /* First Byte */
753  *srcSizePtr = 0;
754  LZ4_putPosition(ip, ctx->hashTable, tableType, base);
755  ip++; forwardH = LZ4_hashPosition(ip, tableType);
756 
757  /* Main Loop */
758  for ( ; ; ) {
759  const BYTE* match;
760  BYTE* token;
761 
762  /* Find a match */
763  { const BYTE* forwardIp = ip;
764  unsigned step = 1;
765  unsigned searchMatchNb = 1 << LZ4_skipTrigger;
766 
767  do {
768  U32 h = forwardH;
769  ip = forwardIp;
770  forwardIp += step;
771  step = (searchMatchNb++ >> LZ4_skipTrigger);
772 
773  if (unlikely(forwardIp > mflimit)) goto _last_literals;
774 
775  match = LZ4_getPositionOnHash(h, ctx->hashTable, tableType, base);
776  forwardH = LZ4_hashPosition(forwardIp, tableType);
777  LZ4_putPositionOnHash(ip, h, ctx->hashTable, tableType, base);
778 
779  } while ( ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip))
780  || (LZ4_read32(match) != LZ4_read32(ip)) );
781  }
782 
783  /* Catch up */
784  while ((ip>anchor) && (match > lowLimit) && (unlikely(ip[-1]==match[-1]))) { ip--; match--; }
785 
786  /* Encode Literal length */
787  { unsigned litLength = (unsigned)(ip - anchor);
788  token = op++;
789  if (op + ((litLength+240)/255) + litLength > oMaxLit) {
790  /* Not enough space for a last match */
791  op--;
792  goto _last_literals;
793  }
794  if (litLength>=RUN_MASK) {
795  unsigned len = litLength - RUN_MASK;
796  *token=(RUN_MASK<<ML_BITS);
797  for(; len >= 255 ; len-=255) *op++ = 255;
798  *op++ = (BYTE)len;
799  }
800  else *token = (BYTE)(litLength<<ML_BITS);
801 
802  /* Copy Literals */
803  LZ4_wildCopy(op, anchor, op+litLength);
804  op += litLength;
805  }
806 
807 _next_match:
808  /* Encode Offset */
809  LZ4_writeLE16(op, (U16)(ip-match)); op+=2;
810 
811  /* Encode MatchLength */
812  { size_t matchLength = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
813 
814  if (op + ((matchLength+240)/255) > oMaxMatch) {
815  /* Match description too long : reduce it */
816  matchLength = (15-1) + (oMaxMatch-op) * 255;
817  }
818  ip += MINMATCH + matchLength;
819 
820  if (matchLength>=ML_MASK) {
821  *token += ML_MASK;
822  matchLength -= ML_MASK;
823  while (matchLength >= 255) { matchLength-=255; *op++ = 255; }
824  *op++ = (BYTE)matchLength;
825  }
826  else *token += (BYTE)(matchLength);
827  }
828 
829  anchor = ip;
830 
831  /* Test end of block */
832  if (ip > mflimit) break;
833  if (op > oMaxSeq) break;
834 
835  /* Fill table */
836  LZ4_putPosition(ip-2, ctx->hashTable, tableType, base);
837 
838  /* Test next position */
839  match = LZ4_getPosition(ip, ctx->hashTable, tableType, base);
840  LZ4_putPosition(ip, ctx->hashTable, tableType, base);
841  if ( (match+MAX_DISTANCE>=ip)
842  && (LZ4_read32(match)==LZ4_read32(ip)) )
843  { token=op++; *token=0; goto _next_match; }
844 
845  /* Prepare next loop */
846  forwardH = LZ4_hashPosition(++ip, tableType);
847  }
848 
849 _last_literals:
850  /* Encode Last Literals */
851  { size_t lastRunSize = (size_t)(iend - anchor);
852  if (op + 1 /* token */ + ((lastRunSize+240)/255) /* litLength */ + lastRunSize /* literals */ > oend) {
853  /* adapt lastRunSize to fill 'dst' */
854  lastRunSize = (oend-op) - 1;
855  lastRunSize -= (lastRunSize+240)/255;
856  }
857  ip = anchor + lastRunSize;
858 
859  if (lastRunSize >= RUN_MASK) {
860  size_t accumulator = lastRunSize - RUN_MASK;
861  *op++ = RUN_MASK << ML_BITS;
862  for(; accumulator >= 255 ; accumulator-=255) *op++ = 255;
863  *op++ = (BYTE) accumulator;
864  } else {
865  *op++ = (BYTE)(lastRunSize<<ML_BITS);
866  }
867  memcpy(op, anchor, lastRunSize);
868  op += lastRunSize;
869  }
870 
871  /* End */
872  *srcSizePtr = (int) (((const char*)ip)-src);
873  return (int) (((char*)op)-dst);
874 }
const XML_Char int len
Definition: expat.h:262
static const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:443
#define ML_BITS
Definition: lz4.cxx:277
#define MINMATCH
Definition: lz4.cxx:263
unsigned int U32
Definition: lz4.cxx:148
static const int LZ4_64Klimit
Definition: lz4.cxx:373
static void LZ4_writeLE16(void *memPtr, U16 value)
Definition: lz4.cxx:233
static unsigned LZ4_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *pInLimit)
Definition: lz4.cxx:351
char * dst
Definition: lz4.h:458
Definition: lz4.cxx:381
static U32 LZ4_read32(const void *memPtr)
Definition: lz4.cxx:200
TString ip
Definition: loadincs.C:5
static const U32 LZ4_skipTrigger
Definition: lz4.cxx:374
#define LASTLITERALS
Definition: lz4.cxx:266
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
#define MAX_DISTANCE
Definition: lz4.cxx:275
static void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t const tableType, const BYTE *srcBase)
Definition: lz4.cxx:427
unsigned int hashTable[LZ4_HASH_SIZE_U32]
Definition: lz4.h:356
static const int LZ4_minLength
Definition: lz4.cxx:268
FORCE_INLINE U32 LZ4_hashPosition(const void *const p, tableType_t const tableType)
Definition: lz4.cxx:421
#define RUN_MASK
Definition: lz4.cxx:280
unsigned char BYTE
Definition: lz4.cxx:146
FORCE_INLINE void LZ4_putPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:437
static void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd)
Definition: lz4.cxx:250
#define ML_MASK
Definition: lz4.cxx:278
#define unlikely(expr)
Definition: lz4.cxx:121
unsigned short U16
Definition: lz4.cxx:147
#define LZ4_MAX_INPUT_SIZE
Definition: lz4.h:148
FORCE_INLINE const BYTE * LZ4_getPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:450
#define MFLIMIT
Definition: lz4.cxx:267
::xsd::cxx::tree::token< char, normalized_string > token
Definition: Database.h:156
int LZ4_compress_fast ( const char *  source,
char *  dest,
int  sourceSize,
int  maxDestSize,
int  acceleration 
)

LZ4_compress_fast() : Same as LZ4_compress_default(), but allows to select an "acceleration" factor. The larger the acceleration value, the faster the algorithm, but also the lesser the compression. It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. An acceleration value of "1" is the same as regular LZ4_compress_default() Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.

Definition at line 679 of file lz4.cxx.

References ALLOCATOR, FREEMEM, LZ4_compress_fast_extState(), and fillBadChanDBTables::result.

Referenced by LZ4_compress_default().

680 {
681 #if (HEAPMODE)
682  void* ctxPtr = ALLOCATOR(1, sizeof(LZ4_stream_t)); /* malloc-calloc always properly aligned */
683 #else
684  LZ4_stream_t ctx;
685  void* const ctxPtr = &ctx;
686 #endif
687 
688  int const result = LZ4_compress_fast_extState(ctxPtr, source, dest, inputSize, maxOutputSize, acceleration);
689 
690 #if (HEAPMODE)
691  FREEMEM(ctxPtr);
692 #endif
693  return result;
694 }
char int int maxOutputSize
Definition: lz4.h:435
#define FREEMEM
Definition: lz4.cxx:129
#define ALLOCATOR(n, s)
Definition: lz4.cxx:128
int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:659
const char * source
Definition: lz4.h:436
const char char int inputSize
Definition: lz4.h:436
int LZ4_compress_fast_continue ( LZ4_stream_t streamPtr,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize,
int  acceleration 
)

LZ4_compress_fast_continue() : Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio. Important : Previous data blocks are assumed to still be present and unmodified ! 'dst' buffer must be already allocated. If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero.

Definition at line 987 of file lz4.cxx.

References ACCELERATION_DEFAULT, byU32, LZ4_stream_t_internal::currentOffset, LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, dictSmall, LZ4_stream_t_internal::initCheck, LZ4_stream_u::internal_donotuse, KB, limitedOutput, LZ4_compress_generic(), LZ4_renormDictT(), noDictIssue, fillBadChanDBTables::result, source, usingExtDict, and withPrefix64k.

Referenced by LZ4_compress_continue(), and LZ4_compress_limitedOutput_continue().

988 {
989  LZ4_stream_t_internal* streamPtr = &LZ4_stream->internal_donotuse;
990  const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
991 
992  const BYTE* smallest = (const BYTE*) source;
993  if (streamPtr->initCheck) return 0; /* Uninitialized structure detected */
994  if ((streamPtr->dictSize>0) && (smallest>dictEnd)) smallest = dictEnd;
995  LZ4_renormDictT(streamPtr, smallest);
996  if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
997 
998  /* Check overlapping input/dictionary space */
999  { const BYTE* sourceEnd = (const BYTE*) source + inputSize;
1000  if ((sourceEnd > streamPtr->dictionary) && (sourceEnd < dictEnd)) {
1001  streamPtr->dictSize = (U32)(dictEnd - sourceEnd);
1002  if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
1003  if (streamPtr->dictSize < 4) streamPtr->dictSize = 0;
1004  streamPtr->dictionary = dictEnd - streamPtr->dictSize;
1005  }
1006  }
1007 
1008  /* prefix mode : source data follows dictionary */
1009  if (dictEnd == (const BYTE*)source) {
1010  int result;
1011  if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset))
1013  else
1015  streamPtr->dictSize += (U32)inputSize;
1016  streamPtr->currentOffset += (U32)inputSize;
1017  return result;
1018  }
1019 
1020  /* external dictionary mode */
1021  { int result;
1022  if ((streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset))
1024  else
1026  streamPtr->dictionary = (const BYTE*)source;
1027  streamPtr->dictSize = (U32)inputSize;
1028  streamPtr->currentOffset += (U32)inputSize;
1029  return result;
1030  }
1031 }
char int int maxOutputSize
Definition: lz4.h:435
unsigned int initCheck
Definition: lz4.h:358
unsigned int currentOffset
Definition: lz4.h:357
unsigned int U32
Definition: lz4.cxx:148
static void LZ4_renormDictT(LZ4_stream_t_internal *LZ4_dict, const BYTE *src)
Definition: lz4.cxx:968
FORCE_INLINE int LZ4_compress_generic(LZ4_stream_t_internal *const cctx, const char *const source, char *const dest, const int inputSize, const int maxOutputSize, const limitedOutput_directive outputLimited, const tableType_t tableType, const dict_directive dict, const dictIssue_directive dictIssue, const U32 acceleration)
Definition: lz4.cxx:459
#define ACCELERATION_DEFAULT
Definition: lz4.cxx:52
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:381
const char char int inputSize
Definition: lz4.h:436
const unsigned char * dictionary
Definition: lz4.h:359
#define KB
Definition: lz4.cxx:270
int LZ4_compress_fast_extState ( void state,
const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize,
int  acceleration 
)

Definition at line 659 of file lz4.cxx.

References ACCELERATION_DEFAULT, byPtr, byU16, byU32, limitedOutput, LZ4_64Klimit, LZ4_compress_generic(), LZ4_compressBound(), LZ4_resetStream(), noDict, noDictIssue, and notLimited.

Referenced by LZ4_compress_destSize_extState(), LZ4_compress_fast(), LZ4_compress_limitedOutput_withState(), and LZ4_compress_withState().

660 {
661  LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)state)->internal_donotuse;
663  if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
664 
666  if (inputSize < LZ4_64Klimit)
667  return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue, acceleration);
668  else
669  return LZ4_compress_generic(ctx, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue, acceleration);
670  } else {
671  if (inputSize < LZ4_64Klimit)
673  else
674  return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, (sizeof(void*)==8) ? byU32 : byPtr, noDict, noDictIssue, acceleration);
675  }
676 }
char int int maxOutputSize
Definition: lz4.h:435
static const int LZ4_64Klimit
Definition: lz4.cxx:373
Definition: lz4.cxx:381
FORCE_INLINE int LZ4_compress_generic(LZ4_stream_t_internal *const cctx, const char *const source, char *const dest, const int inputSize, const int maxOutputSize, const limitedOutput_directive outputLimited, const tableType_t tableType, const dict_directive dict, const dictIssue_directive dictIssue, const U32 acceleration)
Definition: lz4.cxx:459
#define ACCELERATION_DEFAULT
Definition: lz4.cxx:52
Definition: lz4.cxx:381
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:381
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
Definition: lz4.cxx:923
const char char int inputSize
Definition: lz4.h:436
Definition: lz4.cxx:383
int LZ4_compressBound(int isize)
Definition: lz4.cxx:395
int LZ4_compress_fast_force ( const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize,
int  acceleration 
)

Definition at line 705 of file lz4.cxx.

References byPtr, byU16, byU32, LZ4_stream_u::internal_donotuse, limitedOutput, LZ4_64Klimit, LZ4_compress_generic(), LZ4_resetStream(), noDict, and noDictIssue.

706 {
707  LZ4_stream_t ctx;
708  LZ4_resetStream(&ctx);
709 
710  if (inputSize < LZ4_64Klimit)
712  else
713  return LZ4_compress_generic(&ctx.internal_donotuse, source, dest, inputSize, maxOutputSize, limitedOutput, sizeof(void*)==8 ? byU32 : byPtr, noDict, noDictIssue, acceleration);
714 }
char int int maxOutputSize
Definition: lz4.h:435
static const int LZ4_64Klimit
Definition: lz4.cxx:373
Definition: lz4.cxx:381
FORCE_INLINE int LZ4_compress_generic(LZ4_stream_t_internal *const cctx, const char *const source, char *const dest, const int inputSize, const int maxOutputSize, const limitedOutput_directive outputLimited, const tableType_t tableType, const dict_directive dict, const dictIssue_directive dictIssue, const U32 acceleration)
Definition: lz4.cxx:459
Definition: lz4.cxx:381
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:381
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
Definition: lz4.cxx:923
const char char int inputSize
Definition: lz4.h:436
Definition: lz4.cxx:383
int LZ4_compress_forceExtDict ( LZ4_stream_t LZ4_dict,
const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 1035 of file lz4.cxx.

References byU32, LZ4_stream_t_internal::currentOffset, LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, LZ4_stream_u::internal_donotuse, LZ4_compress_generic(), LZ4_renormDictT(), noDictIssue, notLimited, fillBadChanDBTables::result, and usingExtDict.

1036 {
1037  LZ4_stream_t_internal* streamPtr = &LZ4_dict->internal_donotuse;
1038  int result;
1039  const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
1040 
1041  const BYTE* smallest = dictEnd;
1042  if (smallest > (const BYTE*) source) smallest = (const BYTE*) source;
1043  LZ4_renormDictT(streamPtr, smallest);
1044 
1046 
1047  streamPtr->dictionary = (const BYTE*)source;
1048  streamPtr->dictSize = (U32)inputSize;
1049  streamPtr->currentOffset += (U32)inputSize;
1050 
1051  return result;
1052 }
unsigned int currentOffset
Definition: lz4.h:357
unsigned int U32
Definition: lz4.cxx:148
static void LZ4_renormDictT(LZ4_stream_t_internal *LZ4_dict, const BYTE *src)
Definition: lz4.cxx:968
FORCE_INLINE int LZ4_compress_generic(LZ4_stream_t_internal *const cctx, const char *const source, char *const dest, const int inputSize, const int maxOutputSize, const limitedOutput_directive outputLimited, const tableType_t tableType, const dict_directive dict, const dictIssue_directive dictIssue, const U32 acceleration)
Definition: lz4.cxx:459
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:381
const char char int inputSize
Definition: lz4.h:436
const unsigned char * dictionary
Definition: lz4.h:359
FORCE_INLINE int LZ4_compress_generic ( LZ4_stream_t_internal *const  cctx,
const char *const  source,
char *const  dest,
const int  inputSize,
const int  maxOutputSize,
const limitedOutput_directive  outputLimited,
const tableType_t  tableType,
const dict_directive  dict,
const dictIssue_directive  dictIssue,
const U32  acceleration 
)

LZ4_compress_generic() : inlined, to ensure branches are decided at compilation time

Definition at line 459 of file lz4.cxx.

References byU16, LZ4_stream_t_internal::currentOffset, make_syst_table_plots::dest, LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, dictSmall, make_syst_table_plots::h, LZ4_stream_t_internal::hashTable, inputSize, makeTrainCVSamples::int, ip, LASTLITERALS, fillBadChanDBTables::lastRun, PandAna.Demos.demo_prong::limit, LZ4_64Klimit, LZ4_count(), LZ4_getPosition(), LZ4_getPositionOnHash(), LZ4_hashPosition(), LZ4_MAX_INPUT_SIZE, LZ4_minLength, LZ4_putPosition(), LZ4_putPositionOnHash(), LZ4_read32(), LZ4_skipTrigger, LZ4_wildCopy(), LZ4_write32(), LZ4_writeLE16(), cafExposure::match, MAX_DISTANCE, maxOutputSize, MFLIMIT, MINMATCH, ML_BITS, ML_MASK, noDict, RUN_MASK, source, fillBadChanDBTables::step, unlikely, usingExtDict, and withPrefix64k.

Referenced by LZ4_compress_fast_continue(), LZ4_compress_fast_extState(), LZ4_compress_fast_force(), and LZ4_compress_forceExtDict().

470 {
471  const BYTE* ip = (const BYTE*) source;
472  const BYTE* base;
473  const BYTE* lowLimit;
474  const BYTE* const lowRefLimit = ip - cctx->dictSize;
475  const BYTE* const dictionary = cctx->dictionary;
476  const BYTE* const dictEnd = dictionary + cctx->dictSize;
477  const ptrdiff_t dictDelta = dictEnd - (const BYTE*)source;
478  const BYTE* anchor = (const BYTE*) source;
479  const BYTE* const iend = ip + inputSize;
480  const BYTE* const mflimit = iend - MFLIMIT;
481  const BYTE* const matchlimit = iend - LASTLITERALS;
482 
483  BYTE* op = (BYTE*) dest;
484  BYTE* const olimit = op + maxOutputSize;
485 
486  U32 forwardH;
487 
488  /* Init conditions */
489  if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */
490  switch(dict)
491  {
492  case noDict:
493  default:
494  base = (const BYTE*)source;
495  lowLimit = (const BYTE*)source;
496  break;
497  case withPrefix64k:
498  base = (const BYTE*)source - cctx->currentOffset;
499  lowLimit = (const BYTE*)source - cctx->dictSize;
500  break;
501  case usingExtDict:
502  base = (const BYTE*)source - cctx->currentOffset;
503  lowLimit = (const BYTE*)source;
504  break;
505  }
506  if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
507  if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
508 
509  /* First Byte */
510  LZ4_putPosition(ip, cctx->hashTable, tableType, base);
511  ip++; forwardH = LZ4_hashPosition(ip, tableType);
512 
513  /* Main Loop */
514  for ( ; ; ) {
515  ptrdiff_t refDelta = 0;
516  const BYTE* match;
517  BYTE* token;
518 
519  /* Find a match */
520  { const BYTE* forwardIp = ip;
521  unsigned step = 1;
522  unsigned searchMatchNb = acceleration << LZ4_skipTrigger;
523  do {
524  U32 const h = forwardH;
525  ip = forwardIp;
526  forwardIp += step;
527  step = (searchMatchNb++ >> LZ4_skipTrigger);
528 
529  if (unlikely(forwardIp > mflimit)) goto _last_literals;
530 
531  match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType, base);
532  if (dict==usingExtDict) {
533  if (match < (const BYTE*)source) {
534  refDelta = dictDelta;
535  lowLimit = dictionary;
536  } else {
537  refDelta = 0;
538  lowLimit = (const BYTE*)source;
539  } }
540  forwardH = LZ4_hashPosition(forwardIp, tableType);
541  LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType, base);
542 
543  } while ( ((dictIssue==dictSmall) ? (match < lowRefLimit) : 0)
544  || ((tableType==byU16) ? 0 : (match + MAX_DISTANCE < ip))
545  || (LZ4_read32(match+refDelta) != LZ4_read32(ip)) );
546  }
547 
548  /* Catch up */
549  while (((ip>anchor) & (match+refDelta > lowLimit)) && (unlikely(ip[-1]==match[refDelta-1]))) { ip--; match--; }
550 
551  /* Encode Literals */
552  { unsigned const litLength = (unsigned)(ip - anchor);
553  token = op++;
554  if ((outputLimited) && /* Check output buffer overflow */
555  (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
556  return 0;
557  if (litLength >= RUN_MASK) {
558  int len = (int)litLength-RUN_MASK;
559  *token = (RUN_MASK<<ML_BITS);
560  for(; len >= 255 ; len-=255) *op++ = 255;
561  *op++ = (BYTE)len;
562  }
563  else *token = (BYTE)(litLength<<ML_BITS);
564 
565  /* Copy Literals */
566  LZ4_wildCopy(op, anchor, op+litLength);
567  op+=litLength;
568  }
569 
570 _next_match:
571  /* Encode Offset */
572  LZ4_writeLE16(op, (U16)(ip-match)); op+=2;
573 
574  /* Encode MatchLength */
575  { unsigned matchCode;
576 
577  if ((dict==usingExtDict) && (lowLimit==dictionary)) {
578  const BYTE* limit;
579  match += refDelta;
580  limit = ip + (dictEnd-match);
581  if (limit > matchlimit) limit = matchlimit;
582  matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
583  ip += MINMATCH + matchCode;
584  if (ip==limit) {
585  unsigned const more = LZ4_count(ip, (const BYTE*)source, matchlimit);
586  matchCode += more;
587  ip += more;
588  }
589  } else {
590  matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
591  ip += MINMATCH + matchCode;
592  }
593 
594  if ( outputLimited && /* Check output buffer overflow */
595  (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit)) )
596  return 0;
597  if (matchCode >= ML_MASK) {
598  *token += ML_MASK;
599  matchCode -= ML_MASK;
600  LZ4_write32(op, 0xFFFFFFFF);
601  while (matchCode >= 4*255) op+=4, LZ4_write32(op, 0xFFFFFFFF), matchCode -= 4*255;
602  op += matchCode / 255;
603  *op++ = (BYTE)(matchCode % 255);
604  } else
605  *token += (BYTE)(matchCode);
606  }
607 
608  anchor = ip;
609 
610  /* Test end of chunk */
611  if (ip > mflimit) break;
612 
613  /* Fill table */
614  LZ4_putPosition(ip-2, cctx->hashTable, tableType, base);
615 
616  /* Test next position */
617  match = LZ4_getPosition(ip, cctx->hashTable, tableType, base);
618  if (dict==usingExtDict) {
619  if (match < (const BYTE*)source) {
620  refDelta = dictDelta;
621  lowLimit = dictionary;
622  } else {
623  refDelta = 0;
624  lowLimit = (const BYTE*)source;
625  } }
626  LZ4_putPosition(ip, cctx->hashTable, tableType, base);
627  if ( ((dictIssue==dictSmall) ? (match>=lowRefLimit) : 1)
628  && (match+MAX_DISTANCE>=ip)
629  && (LZ4_read32(match+refDelta)==LZ4_read32(ip)) )
630  { token=op++; *token=0; goto _next_match; }
631 
632  /* Prepare next loop */
633  forwardH = LZ4_hashPosition(++ip, tableType);
634  }
635 
636 _last_literals:
637  /* Encode Last Literals */
638  { size_t const lastRun = (size_t)(iend - anchor);
639  if ( (outputLimited) && /* Check output buffer overflow */
640  ((op - (BYTE*)dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize) )
641  return 0;
642  if (lastRun >= RUN_MASK) {
643  size_t accumulator = lastRun - RUN_MASK;
644  *op++ = RUN_MASK << ML_BITS;
645  for(; accumulator >= 255 ; accumulator-=255) *op++ = 255;
646  *op++ = (BYTE) accumulator;
647  } else {
648  *op++ = (BYTE)(lastRun<<ML_BITS);
649  }
650  memcpy(op, anchor, lastRun);
651  op += lastRun;
652  }
653 
654  /* End */
655  return (int) (((char*)op)-dest);
656 }
const XML_Char int len
Definition: expat.h:262
char int int maxOutputSize
Definition: lz4.h:435
static const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:443
#define ML_BITS
Definition: lz4.cxx:277
#define MINMATCH
Definition: lz4.cxx:263
unsigned int currentOffset
Definition: lz4.h:357
unsigned int U32
Definition: lz4.cxx:148
static const int LZ4_64Klimit
Definition: lz4.cxx:373
static void LZ4_writeLE16(void *memPtr, U16 value)
Definition: lz4.cxx:233
static unsigned LZ4_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *pInLimit)
Definition: lz4.cxx:351
Definition: lz4.cxx:381
static U32 LZ4_read32(const void *memPtr)
Definition: lz4.cxx:200
TString ip
Definition: loadincs.C:5
static const U32 LZ4_skipTrigger
Definition: lz4.cxx:374
#define LASTLITERALS
Definition: lz4.cxx:266
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
#define MAX_DISTANCE
Definition: lz4.cxx:275
static void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t const tableType, const BYTE *srcBase)
Definition: lz4.cxx:427
unsigned int hashTable[LZ4_HASH_SIZE_U32]
Definition: lz4.h:356
static const int LZ4_minLength
Definition: lz4.cxx:268
FORCE_INLINE U32 LZ4_hashPosition(const void *const p, tableType_t const tableType)
Definition: lz4.cxx:421
#define RUN_MASK
Definition: lz4.cxx:280
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
FORCE_INLINE void LZ4_putPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:437
static void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd)
Definition: lz4.cxx:250
#define ML_MASK
Definition: lz4.cxx:278
#define unlikely(expr)
Definition: lz4.cxx:121
const char * source
Definition: lz4.h:436
unsigned short U16
Definition: lz4.cxx:147
#define LZ4_MAX_INPUT_SIZE
Definition: lz4.h:148
FORCE_INLINE const BYTE * LZ4_getPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:450
const char char int inputSize
Definition: lz4.h:436
#define MFLIMIT
Definition: lz4.cxx:267
Definition: lz4.cxx:383
const unsigned char * dictionary
Definition: lz4.h:359
static void LZ4_write32(void *memPtr, U32 value)
Definition: lz4.cxx:215
::xsd::cxx::tree::token< char, normalized_string > token
Definition: Database.h:156
int LZ4_compress_limitedOutput ( const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 1403 of file lz4.cxx.

References LZ4_compress_default().

char int int maxOutputSize
Definition: lz4.h:435
int LZ4_compress_default(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.cxx:697
const char * source
Definition: lz4.h:436
const char char int inputSize
Definition: lz4.h:436
int LZ4_compress_limitedOutput_continue ( LZ4_stream_t LZ4_stream,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize 
)

Definition at line 1407 of file lz4.cxx.

References LZ4_compress_fast_continue().

1407 { return LZ4_compress_fast_continue(LZ4_stream, src, dst, srcSize, maxDstSize, 1); }
char * dst
Definition: lz4.h:458
char int int maxDstSize
Definition: lz4.h:458
int LZ4_compress_fast_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:987
int LZ4_compress_limitedOutput_withState ( void state,
const char *  src,
char *  dst,
int  srcSize,
int  dstSize 
)

Definition at line 1405 of file lz4.cxx.

References LZ4_compress_fast_extState().

1405 { return LZ4_compress_fast_extState(state, src, dst, srcSize, dstSize, 1); }
char * dst
Definition: lz4.h:458
int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:659
int LZ4_compress_withState ( void state,
const char *  src,
char *  dst,
int  srcSize 
)

Definition at line 1406 of file lz4.cxx.

References LZ4_compress_fast_extState(), and LZ4_compressBound().

1406 { return LZ4_compress_fast_extState(state, src, dst, srcSize, LZ4_compressBound(srcSize), 1); }
char * dst
Definition: lz4.h:458
int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
Definition: lz4.cxx:659
int LZ4_compressBound(int isize)
Definition: lz4.cxx:395
int LZ4_compressBound ( int  inputSize)

LZ4_compressBound() : Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) This function is primarily useful for memory allocation purposes (destination buffer size). Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize) inputSize : max supported value is LZ4_MAX_INPUT_SIZE return : maximum output size in a "worst case" scenario or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE)

Definition at line 395 of file lz4.cxx.

References LZ4_COMPRESSBOUND.

Referenced by calib::ADCShapeFitTable::ADCShapeFitTable(), LZ4_compress(), LZ4_compress_continue(), LZ4_compress_destSize_extState(), LZ4_compress_fast_extState(), LZ4_compress_HC_continue(), LZ4_compress_HC_extStateHC(), LZ4_compress_withState(), LZ4_compressHC(), LZ4_compressHC2(), LZ4_compressHC2_withStateHC(), LZ4_compressHC_continue(), and LZ4_compressHC_withStateHC().

395 { return LZ4_COMPRESSBOUND(isize); }
#define LZ4_COMPRESSBOUND(isize)
Definition: lz4.h:149
static void LZ4_copy8 ( void dst,
const void src 
)
static

Definition at line 244 of file lz4.cxx.

Referenced by LZ4_decompress_generic(), and LZ4_wildCopy().

245 {
246  memcpy(dst,src,8);
247 }
char * dst
Definition: lz4.h:458
static unsigned LZ4_count ( const BYTE pIn,
const BYTE pMatch,
const BYTE pInLimit 
)
static

Definition at line 351 of file lz4.cxx.

References release_diff::diff, likely, LZ4_NbCommonBytes(), LZ4_read16(), LZ4_read32(), LZ4_read_ARCH(), and STEPSIZE.

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), LZ4HC_BinTree_InsertAndGetAllMatches(), LZ4HC_InsertAndFindBestMatch(), and LZ4HC_InsertAndGetWiderMatch().

352 {
353  const BYTE* const pStart = pIn;
354 
355  while (likely(pIn<pInLimit-(STEPSIZE-1))) {
356  reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
357  if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
358  pIn += LZ4_NbCommonBytes(diff);
359  return (unsigned)(pIn - pStart);
360  }
361 
362  if ((STEPSIZE==8) && (pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
363  if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
364  if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
365  return (unsigned)(pIn - pStart);
366 }
static U32 LZ4_read32(const void *memPtr)
Definition: lz4.cxx:200
static U16 LZ4_read16(const void *memPtr)
Definition: lz4.cxx:195
#define STEPSIZE
Definition: lz4.cxx:350
unsigned char BYTE
Definition: lz4.cxx:146
static reg_t LZ4_read_ARCH(const void *memPtr)
Definition: lz4.cxx:205
size_t reg_t
Definition: lz4.cxx:157
static unsigned LZ4_NbCommonBytes(reg_t val)
Definition: lz4.cxx:292
#define likely(expr)
Definition: lz4.cxx:120
void* LZ4_create ( char *  inputBuffer)

Definition at line 1437 of file lz4.cxx.

References ALLOCATOR, and LZ4_init().

1438 {
1439  LZ4_stream_t* lz4ds = (LZ4_stream_t*)ALLOCATOR(8, sizeof(LZ4_stream_t));
1440  LZ4_init (lz4ds, (BYTE*)inputBuffer);
1441  return lz4ds;
1442 }
#define ALLOCATOR(n, s)
Definition: lz4.cxx:128
char * inputBuffer
Definition: lz4.h:454
unsigned char BYTE
Definition: lz4.cxx:146
static void LZ4_init(LZ4_stream_t *lz4ds, BYTE *base)
Definition: lz4.cxx:1424
LZ4_stream_t* LZ4_createStream ( void  )

LZ4_createStream() and LZ4_freeStream() : LZ4_createStream() will allocate and initialize an LZ4_stream_t structure. LZ4_freeStream() releases its memory.

Definition at line 915 of file lz4.cxx.

References ALLOCATOR, LZ4_resetStream(), LZ4_STATIC_ASSERT, LZ4_STREAMSIZE, and LZ4_STREAMSIZE_U64.

916 {
918  LZ4_STATIC_ASSERT(LZ4_STREAMSIZE >= sizeof(LZ4_stream_t_internal)); /* A compilation error here means LZ4_STREAMSIZE is not large enough */
919  LZ4_resetStream(lz4s);
920  return lz4s;
921 }
#define LZ4_STREAMSIZE_U64
Definition: lz4.h:381
#define ALLOCATOR(n, s)
Definition: lz4.cxx:128
#define LZ4_STREAMSIZE
Definition: lz4.h:382
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
Definition: lz4.cxx:923
#define LZ4_STATIC_ASSERT(c)
Definition: lz4.cxx:286
LZ4_streamDecode_t* LZ4_createStreamDecode ( void  )

LZ4_createStreamDecode() and LZ4_freeStreamDecode() : creation / destruction of streaming decompression tracking structure

Definition at line 1274 of file lz4.cxx.

References ALLOCATOR.

1275 {
1277  return lz4s;
1278 }
#define ALLOCATOR(n, s)
Definition: lz4.cxx:128
int LZ4_decompress_fast ( const char *  source,
char *  dest,
int  originalSize 
)

LZ4_decompress_fast() : originalSize : is the original and therefore uncompressed size return : the number of bytes read from the source buffer (in other words, the compressed size) If the source stream is detected malformed, the function will stop decoding and return a negative result. Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes. note : This function fully respect memory boundaries for properly formed compressed data. It is a bit faster than LZ4_decompress_safe(). However, it does not provide any protection against intentionally modified data stream (malicious input). Use this function in trusted environment only (data to decode comes from a trusted source).

Definition at line 1261 of file lz4.cxx.

References endOnOutputSize, full, KB, LZ4_decompress_generic(), and withPrefix64k.

Referenced by LZ4_uncompress(), and calib::ADCShapeFitTable::Table().

1262 {
1264 }
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int originalSize
Definition: lz4.h:459
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
#define KB
Definition: lz4.cxx:270
int LZ4_decompress_fast_continue ( LZ4_streamDecode_t LZ4_streamDecode,
const char *  source,
char *  dest,
int  originalSize 
)

Definition at line 1336 of file lz4.cxx.

References endOnOutputSize, LZ4_streamDecode_t_internal::extDictSize, LZ4_streamDecode_t_internal::externalDict, full, LZ4_streamDecode_u::internal_donotuse, LZ4_decompress_generic(), originalSize, LZ4_streamDecode_t_internal::prefixEnd, LZ4_streamDecode_t_internal::prefixSize, fillBadChanDBTables::result, and usingExtDict.

1337 {
1338  LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
1339  int result;
1340 
1341  if (lz4sd->prefixEnd == (BYTE*)dest) {
1343  endOnOutputSize, full, 0,
1344  usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize);
1345  if (result <= 0) return result;
1346  lz4sd->prefixSize += originalSize;
1347  lz4sd->prefixEnd += originalSize;
1348  } else {
1349  lz4sd->extDictSize = lz4sd->prefixSize;
1350  lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
1352  endOnOutputSize, full, 0,
1353  usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize);
1354  if (result <= 0) return result;
1355  lz4sd->prefixSize = originalSize;
1356  lz4sd->prefixEnd = (BYTE*)dest + originalSize;
1357  }
1358 
1359  return result;
1360 }
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:401
const unsigned char * prefixEnd
Definition: lz4.h:367
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
const unsigned char * externalDict
Definition: lz4.h:365
char int originalSize
Definition: lz4.h:459
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
int LZ4_decompress_fast_usingDict ( const char *  source,
char *  dest,
int  originalSize,
const char *  dictStart,
int  dictSize 
)

Definition at line 1387 of file lz4.cxx.

References LZ4_decompress_usingDict_generic().

1388 {
1389  return LZ4_decompress_usingDict_generic(source, dest, 0, originalSize, 0, dictStart, dictSize);
1390 }
char int originalSize
Definition: lz4.h:459
const char * source
Definition: lz4.h:436
FORCE_INLINE int LZ4_decompress_usingDict_generic(const char *source, char *dest, int compressedSize, int maxOutputSize, int safe, const char *dictStart, int dictSize)
Definition: lz4.cxx:1370
int LZ4_decompress_fast_withPrefix64k ( const char *  source,
char *  dest,
int  originalSize 
)

Definition at line 1458 of file lz4.cxx.

References endOnOutputSize, full, KB, LZ4_decompress_generic(), and withPrefix64k.

1459 {
1461 }
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int originalSize
Definition: lz4.h:459
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
#define KB
Definition: lz4.cxx:270
FORCE_INLINE int LZ4_decompress_generic ( const char *const  source,
char *const  dest,
int  inputSize,
int  outputSize,
int  endOnInput,
int  partialDecoding,
int  targetOutputSize,
int  dict,
const BYTE *const  lowPrefix,
const BYTE *const  dictStart,
const size_t  dictSize 
)

LZ4_decompress_generic() : This generic decompression function cover all use cases. It shall be instantiated several times, using different sets of directives Note that it is important this generic function is really inlined, in order to remove useless branches during compilation optimization.

Definition at line 1089 of file lz4.cxx.

References make_syst_table_plots::dest, endOnInputSize, inputSize, ip, KB, LASTLITERALS, demo0::length, likely, LZ4_copy8(), LZ4_readLE16(), LZ4_wildCopy(), LZ4_write32(), cafExposure::match, MFLIMIT, MINMATCH, ML_BITS, ML_MASK, PandAna.reco_validation.add_data::offset, RUN_MASK, source, unlikely, usingExtDict, and WILDCOPYLENGTH.

Referenced by LZ4_decompress_fast(), LZ4_decompress_fast_continue(), LZ4_decompress_fast_withPrefix64k(), LZ4_decompress_safe(), LZ4_decompress_safe_continue(), LZ4_decompress_safe_forceExtDict(), LZ4_decompress_safe_partial(), LZ4_decompress_safe_withPrefix64k(), and LZ4_decompress_usingDict_generic().

1103 {
1104  /* Local Variables */
1105  const BYTE* ip = (const BYTE*) source;
1106  const BYTE* const iend = ip + inputSize;
1107 
1108  BYTE* op = (BYTE*) dest;
1109  BYTE* const oend = op + outputSize;
1110  BYTE* cpy;
1111  BYTE* oexit = op + targetOutputSize;
1112  const BYTE* const lowLimit = lowPrefix - dictSize;
1113 
1114  const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
1115  const unsigned dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4};
1116  const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
1117 
1118  const int safeDecode = (endOnInput==endOnInputSize);
1119  const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB)));
1120 
1121 
1122  /* Special cases */
1123  if ((partialDecoding) && (oexit > oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => decode everything */
1124  if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */
1125  if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1);
1126 
1127  /* Main Loop : decode sequences */
1128  while (1) {
1129  size_t length;
1130  const BYTE* match;
1131  size_t offset;
1132 
1133  /* get literal length */
1134  unsigned const token = *ip++;
1135  if ((length=(token>>ML_BITS)) == RUN_MASK) {
1136  unsigned s;
1137  do {
1138  s = *ip++;
1139  length += s;
1140  } while ( likely(endOnInput ? ip<iend-RUN_MASK : 1) & (s==255) );
1141  if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)(op))) goto _output_error; /* overflow detection */
1142  if ((safeDecode) && unlikely((uptrval)(ip)+length<(uptrval)(ip))) goto _output_error; /* overflow detection */
1143  }
1144 
1145  /* copy literals */
1146  cpy = op+length;
1147  if ( ((endOnInput) && ((cpy>(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) )
1148  || ((!endOnInput) && (cpy>oend-WILDCOPYLENGTH)) )
1149  {
1150  if (partialDecoding) {
1151  if (cpy > oend) goto _output_error; /* Error : write attempt beyond end of output buffer */
1152  if ((endOnInput) && (ip+length > iend)) goto _output_error; /* Error : read attempt beyond end of input buffer */
1153  } else {
1154  if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */
1155  if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */
1156  }
1157  memcpy(op, ip, length);
1158  ip += length;
1159  op += length;
1160  break; /* Necessarily EOF, due to parsing restrictions */
1161  }
1162  LZ4_wildCopy(op, ip, cpy);
1163  ip += length; op = cpy;
1164 
1165  /* get offset */
1166  offset = LZ4_readLE16(ip); ip+=2;
1167  match = op - offset;
1168  if ((checkOffset) && (unlikely(match < lowLimit))) goto _output_error; /* Error : offset outside buffers */
1169  LZ4_write32(op, (U32)offset); /* costs ~1%; silence an msan warning when offset==0 */
1170 
1171  /* get matchlength */
1172  length = token & ML_MASK;
1173  if (length == ML_MASK) {
1174  unsigned s;
1175  do {
1176  s = *ip++;
1177  if ((endOnInput) && (ip > iend-LASTLITERALS)) goto _output_error;
1178  length += s;
1179  } while (s==255);
1180  if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error; /* overflow detection */
1181  }
1182  length += MINMATCH;
1183 
1184  /* check external dictionary */
1185  if ((dict==usingExtDict) && (match < lowPrefix)) {
1186  if (unlikely(op+length > oend-LASTLITERALS)) goto _output_error; /* doesn't respect parsing restriction */
1187 
1188  if (length <= (size_t)(lowPrefix-match)) {
1189  /* match can be copied as a single segment from external dictionary */
1190  memmove(op, dictEnd - (lowPrefix-match), length);
1191  op += length;
1192  } else {
1193  /* match encompass external dictionary and current block */
1194  size_t const copySize = (size_t)(lowPrefix-match);
1195  size_t const restSize = length - copySize;
1196  memcpy(op, dictEnd - copySize, copySize);
1197  op += copySize;
1198  if (restSize > (size_t)(op-lowPrefix)) { /* overlap copy */
1199  BYTE* const endOfMatch = op + restSize;
1200  const BYTE* copyFrom = lowPrefix;
1201  while (op < endOfMatch) *op++ = *copyFrom++;
1202  } else {
1203  memcpy(op, lowPrefix, restSize);
1204  op += restSize;
1205  } }
1206  continue;
1207  }
1208 
1209  /* copy match within block */
1210  cpy = op + length;
1211  if (unlikely(offset<8)) {
1212  const int dec64 = dec64table[offset];
1213  op[0] = match[0];
1214  op[1] = match[1];
1215  op[2] = match[2];
1216  op[3] = match[3];
1217  match += dec32table[offset];
1218  memcpy(op+4, match, 4);
1219  match -= dec64;
1220  } else { LZ4_copy8(op, match); match+=8; }
1221  op += 8;
1222 
1223  if (unlikely(cpy>oend-12)) {
1224  BYTE* const oCopyLimit = oend-(WILDCOPYLENGTH-1);
1225  if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last LASTLITERALS bytes must be literals (uncompressed) */
1226  if (op < oCopyLimit) {
1227  LZ4_wildCopy(op, match, oCopyLimit);
1228  match += oCopyLimit - op;
1229  op = oCopyLimit;
1230  }
1231  while (op<cpy) *op++ = *match++;
1232  } else {
1233  LZ4_copy8(op, match);
1234  if (length>16) LZ4_wildCopy(op+8, match+8, cpy);
1235  }
1236  op=cpy; /* correction */
1237  }
1238 
1239  /* end of decoding */
1240  if (endOnInput)
1241  return (int) (((char*)op)-dest); /* Nb of output bytes decoded */
1242  else
1243  return (int) (((const char*)ip)-source); /* Nb of input bytes read */
1244 
1245  /* Overflow error detected */
1246 _output_error:
1247  return (int) (-(((const char*)ip)-source))-1;
1248 }
#define WILDCOPYLENGTH
Definition: lz4.cxx:265
#define ML_BITS
Definition: lz4.cxx:277
#define MINMATCH
Definition: lz4.cxx:263
static void LZ4_copy8(void *dst, const void *src)
Definition: lz4.cxx:244
unsigned int U32
Definition: lz4.cxx:148
TString ip
Definition: loadincs.C:5
#define LASTLITERALS
Definition: lz4.cxx:266
const XML_Char * s
Definition: expat.h:262
length
Definition: demo0.py:21
#define RUN_MASK
Definition: lz4.cxx:280
unsigned char BYTE
Definition: lz4.cxx:146
static void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd)
Definition: lz4.cxx:250
#define ML_MASK
Definition: lz4.cxx:278
#define unlikely(expr)
Definition: lz4.cxx:121
const char * source
Definition: lz4.h:436
static U16 LZ4_readLE16(const void *memPtr)
Definition: lz4.cxx:223
const char char int inputSize
Definition: lz4.h:436
#define MFLIMIT
Definition: lz4.cxx:267
static void LZ4_write32(void *memPtr, U32 value)
Definition: lz4.cxx:215
size_t uptrval
Definition: lz4.cxx:151
#define KB
Definition: lz4.cxx:270
::xsd::cxx::tree::token< char, normalized_string > token
Definition: Database.h:156
#define likely(expr)
Definition: lz4.cxx:120
int LZ4_decompress_safe ( const char *  source,
char *  dest,
int  compressedSize,
int  maxDecompressedSize 
)

LZ4_decompress_safe() : compressedSize : is the precise full size of the compressed block. maxDecompressedSize : is the size of destination buffer, which must be already allocated. return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize) If destination buffer is not large enough, decoding will stop and output an error code (<0). If the source stream is detected malformed, the function will stop decoding and return a negative result. This function is protected against buffer overflow exploits, including malicious data packets. It never writes outside output buffer, nor reads outside input buffer.

Definition at line 1251 of file lz4.cxx.

References endOnInputSize, full, LZ4_decompress_generic(), and noDict.

Referenced by LZ4_uncompress_unknownOutputSize().

1252 {
1253  return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, full, 0, noDict, (BYTE*)dest, NULL, 0);
1254 }
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int compressedSize
Definition: lz4.h:458
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:383
int LZ4_decompress_safe_continue ( LZ4_streamDecode_t LZ4_streamDecode,
const char *  source,
char *  dest,
int  compressedSize,
int  maxDecompressedSize 
)

LZ4_decompress_*_continue() : These decoding functions allow decompression of multiple blocks in "streaming" mode. Previously decoded blocks must remain available at the memory position where they were decoded (up to 64 KB) In the case of a ring buffers, decoding buffer must be either :

  • Exactly same size as encoding buffer, with same update rule (block boundaries at same positions) In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB).
  • Larger than encoding buffer, by a minimum of maxBlockSize more bytes. maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block. In which case, encoding and decoding buffers do not need to be synchronized, and encoding ring buffer can have any size, including small ones ( < 64 KB).
  • At least 64 KB + 8 bytes + maxBlockSize. In which case, encoding and decoding buffers do not need to be synchronized, and encoding ring buffer can have any size, including larger than decoding buffer. Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer, and indicate where it is saved using LZ4_setStreamDecode()

Definition at line 1310 of file lz4.cxx.

References endOnInputSize, LZ4_streamDecode_t_internal::extDictSize, LZ4_streamDecode_t_internal::externalDict, full, LZ4_streamDecode_u::internal_donotuse, LZ4_decompress_generic(), LZ4_streamDecode_t_internal::prefixEnd, LZ4_streamDecode_t_internal::prefixSize, fillBadChanDBTables::result, and usingExtDict.

1311 {
1312  LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
1313  int result;
1314 
1315  if (lz4sd->prefixEnd == (BYTE*)dest) {
1317  endOnInputSize, full, 0,
1318  usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, lz4sd->externalDict, lz4sd->extDictSize);
1319  if (result <= 0) return result;
1320  lz4sd->prefixSize += result;
1321  lz4sd->prefixEnd += result;
1322  } else {
1323  lz4sd->extDictSize = lz4sd->prefixSize;
1324  lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize;
1326  endOnInputSize, full, 0,
1327  usingExtDict, (BYTE*)dest, lz4sd->externalDict, lz4sd->extDictSize);
1328  if (result <= 0) return result;
1329  lz4sd->prefixSize = result;
1330  lz4sd->prefixEnd = (BYTE*)dest + result;
1331  }
1332 
1333  return result;
1334 }
char int int maxOutputSize
Definition: lz4.h:435
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:401
const unsigned char * prefixEnd
Definition: lz4.h:367
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
const unsigned char * externalDict
Definition: lz4.h:365
char int compressedSize
Definition: lz4.h:458
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
int LZ4_decompress_safe_forceExtDict ( const char *  source,
char *  dest,
int  compressedSize,
int  maxOutputSize,
const char *  dictStart,
int  dictSize 
)

Definition at line 1393 of file lz4.cxx.

References endOnInputSize, full, LZ4_decompress_generic(), and usingExtDict.

1394 {
1395  return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
1396 }
char int int maxOutputSize
Definition: lz4.h:435
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int compressedSize
Definition: lz4.h:458
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
int LZ4_decompress_safe_partial ( const char *  source,
char *  dest,
int  compressedSize,
int  targetOutputSize,
int  maxDecompressedSize 
)

LZ4_decompress_safe_partial() : This function decompress a compressed block of size 'compressedSize' at position 'source' into destination buffer 'dest' of size 'maxDecompressedSize'. The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached, reducing decompression time. return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize) Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller. Always control how many bytes were decoded. If the source stream is detected malformed, the function will stop decoding and return a negative result. This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets

Definition at line 1256 of file lz4.cxx.

References endOnInputSize, LZ4_decompress_generic(), noDict, and partial.

1257 {
1258  return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize, endOnInputSize, partial, targetOutputSize, noDict, (BYTE*)dest, NULL, 0);
1259 }
Definition: lz4.cxx:387
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int compressedSize
Definition: lz4.h:458
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:383
int LZ4_decompress_safe_usingDict ( const char *  source,
char *  dest,
int  compressedSize,
int  maxDecompressedSize,
const char *  dictStart,
int  dictSize 
)

LZ4_decompress_*_usingDict() : These decoding functions work the same as a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue() They are stand-alone, and don't need an LZ4_streamDecode_t structure.

Definition at line 1382 of file lz4.cxx.

References LZ4_decompress_usingDict_generic().

1383 {
1384  return LZ4_decompress_usingDict_generic(source, dest, compressedSize, maxOutputSize, 1, dictStart, dictSize);
1385 }
char int int maxOutputSize
Definition: lz4.h:435
char int compressedSize
Definition: lz4.h:458
const char * source
Definition: lz4.h:436
FORCE_INLINE int LZ4_decompress_usingDict_generic(const char *source, char *dest, int compressedSize, int maxOutputSize, int safe, const char *dictStart, int dictSize)
Definition: lz4.cxx:1370
int LZ4_decompress_safe_withPrefix64k ( const char *  source,
char *  dest,
int  compressedSize,
int  maxOutputSize 
)

Definition at line 1453 of file lz4.cxx.

References endOnInputSize, full, KB, LZ4_decompress_generic(), and withPrefix64k.

1454 {
1456 }
char int int maxOutputSize
Definition: lz4.h:435
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int compressedSize
Definition: lz4.h:458
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
#define KB
Definition: lz4.cxx:270
FORCE_INLINE int LZ4_decompress_usingDict_generic ( const char *  source,
char *  dest,
int  compressedSize,
int  maxOutputSize,
int  safe,
const char *  dictStart,
int  dictSize 
)

Definition at line 1370 of file lz4.cxx.

References full, KB, LZ4_decompress_generic(), noDict, usingExtDict, and withPrefix64k.

Referenced by LZ4_decompress_fast_usingDict(), and LZ4_decompress_safe_usingDict().

1371 {
1372  if (dictSize==0)
1374  if (dictStart+dictSize == dest) {
1375  if (dictSize >= (int)(64 KB - 1))
1377  return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, noDict, (BYTE*)dest-dictSize, NULL, 0);
1378  }
1379  return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, safe, full, 0, usingExtDict, (BYTE*)dest, (const BYTE*)dictStart, dictSize);
1380 }
char int int maxOutputSize
Definition: lz4.h:435
FORCE_INLINE int LZ4_decompress_generic(const char *const source, char *const dest, int inputSize, int outputSize, int endOnInput, int partialDecoding, int targetOutputSize, int dict, const BYTE *const lowPrefix, const BYTE *const dictStart, const size_t dictSize)
Definition: lz4.cxx:1089
char int compressedSize
Definition: lz4.h:458
Definition: lz4.cxx:387
unsigned char BYTE
Definition: lz4.cxx:146
const char * source
Definition: lz4.h:436
Definition: lz4.cxx:383
#define KB
Definition: lz4.cxx:270
int LZ4_freeStream ( LZ4_stream_t LZ4_stream)

Definition at line 928 of file lz4.cxx.

References FREEMEM.

929 {
930  FREEMEM(LZ4_stream);
931  return (0);
932 }
#define FREEMEM
Definition: lz4.cxx:129
int LZ4_freeStreamDecode ( LZ4_streamDecode_t LZ4_stream)

Definition at line 1280 of file lz4.cxx.

References FREEMEM.

1281 {
1282  FREEMEM(LZ4_stream);
1283  return 0;
1284 }
#define FREEMEM
Definition: lz4.cxx:129
FORCE_INLINE const BYTE* LZ4_getPosition ( const BYTE p,
void tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 450 of file lz4.cxx.

References make_syst_table_plots::h, LZ4_getPositionOnHash(), and LZ4_hashPosition().

Referenced by LZ4_compress_destSize_generic(), and LZ4_compress_generic().

451 {
452  U32 const h = LZ4_hashPosition(p, tableType);
453  return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
454 }
static const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:443
unsigned int U32
Definition: lz4.cxx:148
const char * p
Definition: xmltok.h:285
FORCE_INLINE U32 LZ4_hashPosition(const void *const p, tableType_t const tableType)
Definition: lz4.cxx:421
static const BYTE* LZ4_getPositionOnHash ( U32  h,
void tableBase,
tableType_t  tableType,
const BYTE srcBase 
)
static

Definition at line 443 of file lz4.cxx.

References byPtr, byU32, and make_syst_table_plots::h.

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), and LZ4_getPosition().

444 {
445  if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; }
446  if (tableType == byU32) { const U32* const hashTable = (U32*) tableBase; return hashTable[h] + srcBase; }
447  { const U16* const hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } /* default, to ensure a return */
448 }
unsigned int U32
Definition: lz4.cxx:148
Definition: lz4.cxx:381
unsigned char BYTE
Definition: lz4.cxx:146
unsigned short U16
Definition: lz4.cxx:147
Definition: lz4.cxx:381
static U32 LZ4_hash4 ( U32  sequence,
tableType_t const  tableType 
)
static

Definition at line 402 of file lz4.cxx.

References byU16, LZ4_HASHLOG, and MINMATCH.

Referenced by LZ4_hashPosition().

403 {
404  if (tableType == byU16)
405  return ((sequence * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
406  else
407  return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
408 }
#define MINMATCH
Definition: lz4.cxx:263
#define LZ4_HASHLOG
Definition: lz4.h:330
Definition: lz4.cxx:381
static U32 LZ4_hash5 ( U64  sequence,
tableType_t const  tableType 
)
static

Definition at line 410 of file lz4.cxx.

References byU16, LZ4_HASHLOG, and LZ4_isLittleEndian().

Referenced by LZ4_hashPosition().

411 {
412  static const U64 prime5bytes = 889523592379ULL;
413  static const U64 prime8bytes = 11400714785074694791ULL;
414  const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
415  if (LZ4_isLittleEndian())
416  return (U32)(((sequence << 24) * prime5bytes) >> (64 - hashLog));
417  else
418  return (U32)(((sequence >> 24) * prime8bytes) >> (64 - hashLog));
419 }
unsigned int U32
Definition: lz4.cxx:148
unsigned long long U64
Definition: lz4.cxx:150
#define LZ4_HASHLOG
Definition: lz4.h:330
Definition: lz4.cxx:381
static unsigned LZ4_isLittleEndian(void)
Definition: lz4.cxx:163
FORCE_INLINE U32 LZ4_hashPosition ( const void *const  p,
tableType_t const  tableType 
)

Definition at line 421 of file lz4.cxx.

References byU16, LZ4_hash4(), LZ4_hash5(), LZ4_read32(), and LZ4_read_ARCH().

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), LZ4_getPosition(), and LZ4_putPosition().

422 {
423  if ((sizeof(reg_t)==8) && (tableType != byU16)) return LZ4_hash5(LZ4_read_ARCH(p), tableType);
424  return LZ4_hash4(LZ4_read32(p), tableType);
425 }
const char * p
Definition: xmltok.h:285
Definition: lz4.cxx:381
static U32 LZ4_read32(const void *memPtr)
Definition: lz4.cxx:200
static U32 LZ4_hash4(U32 sequence, tableType_t const tableType)
Definition: lz4.cxx:402
static reg_t LZ4_read_ARCH(const void *memPtr)
Definition: lz4.cxx:205
size_t reg_t
Definition: lz4.cxx:157
static U32 LZ4_hash5(U64 sequence, tableType_t const tableType)
Definition: lz4.cxx:410
static void LZ4_init ( LZ4_stream_t lz4ds,
BYTE base 
)
static

Definition at line 1424 of file lz4.cxx.

References LZ4_stream_t_internal::bufferStart, LZ4_stream_u::internal_donotuse, and MEM_INIT.

Referenced by LZ4_create(), and LZ4_resetStreamState().

1425 {
1426  MEM_INIT(lz4ds, 0, sizeof(LZ4_stream_t));
1428 }
#define MEM_INIT
Definition: lz4.cxx:131
unsigned char * bufferStart
Definition: lz4.h:360
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
static unsigned LZ4_isLittleEndian ( void  )
static

Definition at line 163 of file lz4.cxx.

References __attribute__(), plot_validation_datamc::c, LZ4_read16(), LZ4_read32(), LZ4_read_ARCH(), LZ4_write16(), LZ4_write32(), one(), and submit_hadd::u.

Referenced by LZ4_hash5(), LZ4_NbCommonBytes(), LZ4_readLE16(), and LZ4_writeLE16().

164 {
165  const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
166  return one.c[0];
167 }
unsigned int U32
Definition: lz4.cxx:148
unsigned char BYTE
Definition: lz4.cxx:146
auto one()
Definition: PMNS.cxx:49
int LZ4_loadDict ( LZ4_stream_t streamPtr,
const char *  dictionary,
int  dictSize 
)

LZ4_loadDict() : Use this function to load a static dictionary into LZ4_stream. Any previous data will be forgotten, only 'dictionary' will remain in memory. Loading a size of 0 is allowed. Return : dictionary size, in bytes (necessarily <= 64 KB)

Definition at line 936 of file lz4.cxx.

References byU32, LZ4_stream_t_internal::currentOffset, LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, GB, HASH_UNIT, LZ4_stream_t_internal::hashTable, LZ4_stream_t_internal::initCheck, LZ4_stream_u::internal_donotuse, KB, LZ4_putPosition(), and LZ4_resetStream().

937 {
938  LZ4_stream_t_internal* dict = &LZ4_dict->internal_donotuse;
939  const BYTE* p = (const BYTE*)dictionary;
940  const BYTE* const dictEnd = p + dictSize;
941  const BYTE* base;
942 
943  if ((dict->initCheck) || (dict->currentOffset > 1 GB)) /* Uninitialized structure, or reuse overflow */
944  LZ4_resetStream(LZ4_dict);
945 
946  if (dictSize < (int)HASH_UNIT) {
947  dict->dictionary = NULL;
948  dict->dictSize = 0;
949  return 0;
950  }
951 
952  if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB;
953  dict->currentOffset += 64 KB;
954  base = p - dict->currentOffset;
955  dict->dictionary = p;
956  dict->dictSize = (U32)(dictEnd - p);
957  dict->currentOffset += dict->dictSize;
958 
959  while (p <= dictEnd-HASH_UNIT) {
960  LZ4_putPosition(p, dict->hashTable, byU32, base);
961  p+=3;
962  }
963 
964  return dict->dictSize;
965 }
unsigned int initCheck
Definition: lz4.h:358
unsigned int currentOffset
Definition: lz4.h:357
unsigned int U32
Definition: lz4.cxx:148
const char * p
Definition: xmltok.h:285
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
unsigned int hashTable[LZ4_HASH_SIZE_U32]
Definition: lz4.h:356
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
FORCE_INLINE void LZ4_putPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.cxx:437
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
#define HASH_UNIT
Definition: lz4.cxx:935
Definition: lz4.cxx:381
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
Definition: lz4.cxx:923
#define GB
Definition: lz4.cxx:272
const unsigned char * dictionary
Definition: lz4.h:359
#define KB
Definition: lz4.cxx:270
static unsigned LZ4_NbCommonBytes ( reg_t  val)
static

Definition at line 292 of file lz4.cxx.

References LZ4_isLittleEndian(), r(), and febshutoff_auto::val.

Referenced by LZ4_count().

293 {
294  if (LZ4_isLittleEndian()) {
295  if (sizeof(val)==8) {
296 # if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
297  unsigned long r = 0;
298  _BitScanForward64( &r, (U64)val );
299  return (int)(r>>3);
300 # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
301  return (__builtin_ctzll((U64)val) >> 3);
302 # else
303  static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
304  return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
305 # endif
306  } else /* 32 bits */ {
307 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
308  unsigned long r;
309  _BitScanForward( &r, (U32)val );
310  return (int)(r>>3);
311 # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
312  return (__builtin_ctz((U32)val) >> 3);
313 # else
314  static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
315  return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
316 # endif
317  }
318  } else /* Big Endian CPU */ {
319  if (sizeof(val)==8) {
320 # if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
321  unsigned long r = 0;
322  _BitScanReverse64( &r, val );
323  return (unsigned)(r>>3);
324 # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
325  return (__builtin_clzll((U64)val) >> 3);
326 # else
327  unsigned r;
328  if (!(val>>32)) { r=4; } else { r=0; val>>=32; }
329  if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
330  r += (!val);
331  return r;
332 # endif
333  } else /* 32 bits */ {
334 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
335  unsigned long r = 0;
336  _BitScanReverse( &r, (unsigned long)val );
337  return (unsigned)(r>>3);
338 # elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && !defined(LZ4_FORCE_SW_BITCOUNT)
339  return (__builtin_clz((U32)val) >> 3);
340 # else
341  unsigned r;
342  if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
343  r += (!val);
344  return r;
345 # endif
346  }
347  }
348 }
unsigned int U32
Definition: lz4.cxx:148
unsigned long long U64
Definition: lz4.cxx:150
signed int S32
Definition: lz4.cxx:149
TRandom3 r(0)
static unsigned LZ4_isLittleEndian(void)
Definition: lz4.cxx:163
FORCE_INLINE void LZ4_putPosition ( const BYTE p,
void tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 437 of file lz4.cxx.

References make_syst_table_plots::h, LZ4_hashPosition(), and LZ4_putPositionOnHash().

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), and LZ4_loadDict().

438 {
439  U32 const h = LZ4_hashPosition(p, tableType);
440  LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase);
441 }
unsigned int U32
Definition: lz4.cxx:148
const char * p
Definition: xmltok.h:285
static void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t const tableType, const BYTE *srcBase)
Definition: lz4.cxx:427
FORCE_INLINE U32 LZ4_hashPosition(const void *const p, tableType_t const tableType)
Definition: lz4.cxx:421
static void LZ4_putPositionOnHash ( const BYTE p,
U32  h,
void tableBase,
tableType_t const  tableType,
const BYTE srcBase 
)
static

Definition at line 427 of file lz4.cxx.

References byPtr, byU16, byU32, and make_syst_table_plots::h.

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), and LZ4_putPosition().

428 {
429  switch (tableType)
430  {
431  case byPtr: { const BYTE** hashTable = (const BYTE**)tableBase; hashTable[h] = p; return; }
432  case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); return; }
433  case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); return; }
434  }
435 }
unsigned int U32
Definition: lz4.cxx:148
const char * p
Definition: xmltok.h:285
Definition: lz4.cxx:381
Definition: lz4.cxx:381
unsigned char BYTE
Definition: lz4.cxx:146
unsigned short U16
Definition: lz4.cxx:147
Definition: lz4.cxx:381
static U16 LZ4_read16 ( const void memPtr)
static

Definition at line 195 of file lz4.cxx.

References febshutoff_auto::val.

Referenced by LZ4_count(), LZ4_isLittleEndian(), and LZ4_readLE16().

196 {
197  U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
198 }
unsigned short U16
Definition: lz4.cxx:147
static U32 LZ4_read32 ( const void memPtr)
static

Definition at line 200 of file lz4.cxx.

References febshutoff_auto::val.

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), LZ4_count(), LZ4_hashPosition(), LZ4_isLittleEndian(), LZ4HC_hashPtr(), LZ4HC_InsertAndFindBestMatch(), and LZ4HC_InsertAndGetWiderMatch().

201 {
202  U32 val; memcpy(&val, memPtr, sizeof(val)); return val;
203 }
unsigned int U32
Definition: lz4.cxx:148
static reg_t LZ4_read_ARCH ( const void memPtr)
static

Definition at line 205 of file lz4.cxx.

References febshutoff_auto::val.

Referenced by LZ4_count(), LZ4_hashPosition(), and LZ4_isLittleEndian().

206 {
207  reg_t val; memcpy(&val, memPtr, sizeof(val)); return val;
208 }
size_t reg_t
Definition: lz4.cxx:157
static U16 LZ4_readLE16 ( const void memPtr)
static

Definition at line 223 of file lz4.cxx.

References LZ4_isLittleEndian(), and LZ4_read16().

Referenced by LZ4_decompress_generic().

224 {
225  if (LZ4_isLittleEndian()) {
226  return LZ4_read16(memPtr);
227  } else {
228  const BYTE* p = (const BYTE*)memPtr;
229  return (U16)((U16)p[0] + (p[1]<<8));
230  }
231 }
const char * p
Definition: xmltok.h:285
static U16 LZ4_read16(const void *memPtr)
Definition: lz4.cxx:195
unsigned char BYTE
Definition: lz4.cxx:146
unsigned short U16
Definition: lz4.cxx:147
static unsigned LZ4_isLittleEndian(void)
Definition: lz4.cxx:163
static void LZ4_renormDictT ( LZ4_stream_t_internal LZ4_dict,
const BYTE src 
)
static

Definition at line 968 of file lz4.cxx.

References LZ4_stream_t_internal::currentOffset, delta, LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, LZ4_stream_t_internal::hashTable, MECModelEnuComparisons::i, KB, and LZ4_HASH_SIZE_U32.

Referenced by LZ4_compress_fast_continue(), and LZ4_compress_forceExtDict().

969 {
970  if ((LZ4_dict->currentOffset > 0x80000000) ||
971  ((uptrval)LZ4_dict->currentOffset > (uptrval)src)) { /* address space overflow */
972  /* rescale hash table */
973  U32 const delta = LZ4_dict->currentOffset - 64 KB;
974  const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize;
975  int i;
976  for (i=0; i<LZ4_HASH_SIZE_U32; i++) {
977  if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i]=0;
978  else LZ4_dict->hashTable[i] -= delta;
979  }
980  LZ4_dict->currentOffset = 64 KB;
981  if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
982  LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize;
983  }
984 }
#define LZ4_HASH_SIZE_U32
Definition: lz4.h:332
unsigned int currentOffset
Definition: lz4.h:357
double delta
Definition: runWimpSim.h:98
unsigned int U32
Definition: lz4.cxx:148
unsigned int hashTable[LZ4_HASH_SIZE_U32]
Definition: lz4.h:356
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
const unsigned char * dictionary
Definition: lz4.h:359
size_t uptrval
Definition: lz4.cxx:151
#define KB
Definition: lz4.cxx:270
void LZ4_resetStream ( LZ4_stream_t streamPtr)

LZ4_resetStream() : An LZ4_stream_t structure can be allocated once and re-used multiple times. Use this function to init an allocated LZ4_stream_t structure and start a new compression.

Definition at line 923 of file lz4.cxx.

References MEM_INIT.

Referenced by LZ4_compress_destSize_extState(), LZ4_compress_fast_extState(), LZ4_compress_fast_force(), LZ4_createStream(), and LZ4_loadDict().

924 {
925  MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t));
926 }
#define MEM_INIT
Definition: lz4.cxx:131
int LZ4_resetStreamState ( void state,
char *  inputBuffer 
)

Definition at line 1430 of file lz4.cxx.

References LZ4_init().

1431 {
1432  if ((((uptrval)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */
1433  LZ4_init((LZ4_stream_t*)state, (BYTE*)inputBuffer);
1434  return 0;
1435 }
char * inputBuffer
Definition: lz4.h:454
unsigned char BYTE
Definition: lz4.cxx:146
static void LZ4_init(LZ4_stream_t *lz4ds, BYTE *base)
Definition: lz4.cxx:1424
size_t uptrval
Definition: lz4.cxx:151
int LZ4_saveDict ( LZ4_stream_t LZ4_dict,
char *  safeBuffer,
int  dictSize 
)

LZ4_saveDict() : If previously compressed data block is not guaranteed to remain available at its memory location, save it into a safer place (char* safeBuffer). Note : you don't need to call LZ4_loadDict() afterwards, dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue(). Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error.

Definition at line 1062 of file lz4.cxx.

References LZ4_stream_t_internal::dictionary, LZ4_stream_t_internal::dictSize, LZ4_stream_u::internal_donotuse, and KB.

Referenced by LZ4_slideInputBuffer().

1063 {
1064  LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;
1065  const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize;
1066 
1067  if ((U32)dictSize > 64 KB) dictSize = 64 KB; /* useless to define a dictionary > 64 KB */
1068  if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize;
1069 
1070  memmove(safeBuffer, previousDictEnd - dictSize, dictSize);
1071 
1072  dict->dictionary = (const BYTE*)safeBuffer;
1073  dict->dictSize = (U32)dictSize;
1074 
1075  return dictSize;
1076 }
unsigned int U32
Definition: lz4.cxx:148
unsigned char BYTE
Definition: lz4.cxx:146
unsigned int dictSize
Definition: lz4.h:361
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:385
const unsigned char * dictionary
Definition: lz4.h:359
#define KB
Definition: lz4.cxx:270
int LZ4_setStreamDecode ( LZ4_streamDecode_t LZ4_streamDecode,
const char *  dictionary,
int  dictSize 
)

LZ4_setStreamDecode() : Use this function to instruct where to find the dictionary. This function is not necessary if previous data is still available where it was decoded. Loading a size of 0 is allowed (same effect as no dictionary). Return : 1 if OK, 0 if error

Definition at line 1293 of file lz4.cxx.

References LZ4_streamDecode_t_internal::extDictSize, LZ4_streamDecode_t_internal::externalDict, LZ4_streamDecode_u::internal_donotuse, LZ4_streamDecode_t_internal::prefixEnd, and LZ4_streamDecode_t_internal::prefixSize.

1294 {
1295  LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;
1296  lz4sd->prefixSize = (size_t) dictSize;
1297  lz4sd->prefixEnd = (const BYTE*) dictionary + dictSize;
1298  lz4sd->externalDict = NULL;
1299  lz4sd->extDictSize = 0;
1300  return 1;
1301 }
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:401
const unsigned char * prefixEnd
Definition: lz4.h:367
const unsigned char * externalDict
Definition: lz4.h:365
unsigned char BYTE
Definition: lz4.cxx:146
int LZ4_sizeofState ( void  )

LZ4_compress_fast_extState() : Same compression function, just using an externally allocated memory space to store compression state. Use LZ4_sizeofState() to know how much memory must be allocated, and allocate it on 8-bytes boundaries (using malloc() typically). Then, provide it as 'void* state' to compression function.

Definition at line 396 of file lz4.cxx.

References LZ4_STREAMSIZE.

396 { return LZ4_STREAMSIZE; }
#define LZ4_STREAMSIZE
Definition: lz4.h:382
int LZ4_sizeofStreamState ( )

Definition at line 1422 of file lz4.cxx.

References LZ4_STREAMSIZE.

1422 { return LZ4_STREAMSIZE; }
#define LZ4_STREAMSIZE
Definition: lz4.h:382
char* LZ4_slideInputBuffer ( void LZ4_Data)

Definition at line 1444 of file lz4.cxx.

References LZ4_stream_t_internal::bufferStart, KB, and LZ4_saveDict().

1445 {
1446  LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)LZ4_Data)->internal_donotuse;
1447  int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB);
1448  return (char*)(ctx->bufferStart + dictSize);
1449 }
unsigned char * bufferStart
Definition: lz4.h:360
int LZ4_saveDict(LZ4_stream_t *LZ4_dict, char *safeBuffer, int dictSize)
Definition: lz4.cxx:1062
#define KB
Definition: lz4.cxx:270
int LZ4_uncompress ( const char *  source,
char *  dest,
int  outputSize 
)

Definition at line 1416 of file lz4.cxx.

References LZ4_decompress_fast().

1416 { return LZ4_decompress_fast(source, dest, outputSize); }
int LZ4_decompress_fast(const char *source, char *dest, int originalSize)
Definition: lz4.cxx:1261
const char * source
Definition: lz4.h:436
int LZ4_uncompress_unknownOutputSize ( const char *  source,
char *  dest,
int  isize,
int  maxOutputSize 
)

Definition at line 1417 of file lz4.cxx.

References LZ4_decompress_safe().

1417 { return LZ4_decompress_safe(source, dest, isize, maxOutputSize); }
char int int maxOutputSize
Definition: lz4.h:435
int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
Definition: lz4.cxx:1251
const char * source
Definition: lz4.h:436
int LZ4_versionNumber ( void  )

library version number; to be used when checking dll version

Definition at line 393 of file lz4.cxx.

References LZ4_VERSION_NUMBER.

393 { return LZ4_VERSION_NUMBER; }
#define LZ4_VERSION_NUMBER
Definition: lz4.h:90
const char* LZ4_versionString ( void  )

library version string; to be used when checking dll version

Definition at line 394 of file lz4.cxx.

References LZ4_VERSION_STRING.

394 { return LZ4_VERSION_STRING; }
#define LZ4_VERSION_STRING
Definition: lz4.h:95
static void LZ4_wildCopy ( void dstPtr,
const void srcPtr,
void dstEnd 
)
static

Definition at line 250 of file lz4.cxx.

References d, e, and LZ4_copy8().

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), LZ4_decompress_generic(), and LZ4HC_encodeSequence().

251 {
252  BYTE* d = (BYTE*)dstPtr;
253  const BYTE* s = (const BYTE*)srcPtr;
254  BYTE* const e = (BYTE*)dstEnd;
255 
256  do { LZ4_copy8(d,s); d+=8; s+=8; } while (d<e);
257 }
static void LZ4_copy8(void *dst, const void *src)
Definition: lz4.cxx:244
const XML_Char * s
Definition: expat.h:262
unsigned char BYTE
Definition: lz4.cxx:146
Float_t d
Definition: plot.C:236
Float_t e
Definition: plot.C:35
static void LZ4_write16 ( void memPtr,
U16  value 
)
static

Definition at line 210 of file lz4.cxx.

Referenced by LZ4_isLittleEndian(), and LZ4_writeLE16().

211 {
212  memcpy(memPtr, &value, sizeof(value));
213 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
static void LZ4_write32 ( void memPtr,
U32  value 
)
static

Definition at line 215 of file lz4.cxx.

Referenced by LZ4_compress_generic(), LZ4_decompress_generic(), and LZ4_isLittleEndian().

216 {
217  memcpy(memPtr, &value, sizeof(value));
218 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
static void LZ4_writeLE16 ( void memPtr,
U16  value 
)
static

Definition at line 233 of file lz4.cxx.

References LZ4_isLittleEndian(), and LZ4_write16().

Referenced by LZ4_compress_destSize_generic(), LZ4_compress_generic(), and LZ4HC_encodeSequence().

234 {
235  if (LZ4_isLittleEndian()) {
236  LZ4_write16(memPtr, value);
237  } else {
238  BYTE* p = (BYTE*)memPtr;
239  p[0] = (BYTE) value;
240  p[1] = (BYTE)(value>>8);
241  }
242 }
const char * p
Definition: xmltok.h:285
const XML_Char int const XML_Char * value
Definition: expat.h:331
static void LZ4_write16(void *memPtr, U16 value)
Definition: lz4.cxx:210
unsigned char BYTE
Definition: lz4.cxx:146
static unsigned LZ4_isLittleEndian(void)
Definition: lz4.cxx:163

Variable Documentation

const int LZ4_64Klimit = ((64 KB) + (MFLIMIT-1))
static
const int LZ4_minLength = (MFLIMIT+1)
static

Definition at line 268 of file lz4.cxx.

Referenced by LZ4_compress_destSize_generic(), and LZ4_compress_generic().

const U32 LZ4_skipTrigger = 6
static

Definition at line 374 of file lz4.cxx.

Referenced by LZ4_compress_destSize_generic(), and LZ4_compress_generic().