Go to the documentation of this file.
50 #define ACCELERATION_DEFAULT 1
60 #if defined(_MSC_VER) && defined(_WIN32_WCE)
61 # define LZ4_FORCE_SW_BITCOUNT
75 # define FORCE_INLINE static __forceinline
77 # pragma warning(disable : 4127)
78 # pragma warning(disable : 4293)
80 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
81 # if defined(__GNUC__) || defined(__clang__)
82 # define FORCE_INLINE static inline __attribute__((always_inline))
84 # define FORCE_INLINE static inline
87 # define FORCE_INLINE static
92 #if (LZ4_GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__)
93 # define expect(expr,value) (__builtin_expect ((expr),(value)) )
95 # define expect(expr,value) (expr)
98 #define likely(expr) expect((expr) != 0, 1)
99 #define unlikely(expr) expect((expr) != 0, 0)
106 #define ALLOCATOR(n,s) calloc(n,s)
109 #define MEM_INIT memset
115 #if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
124 typedef unsigned short U16;
127 typedef unsigned long long U64;
134 #define STEPSIZE sizeof(size_t)
136 static unsigned LZ4_64bits(
void) {
return sizeof(
void*)==8; }
148 memcpy(&val16, memPtr, 2);
161 return (
U16)((
U16)
p[0] + (
p[1]<<8));
169 memcpy(memPtr, &
value, 2);
182 memcpy(&val32, memPtr, 4);
189 memcpy(&val64, memPtr, 8);
202 static void LZ4_copy4(
void* dstPtr,
const void* srcPtr) { memcpy(dstPtr, srcPtr, 4); }
204 static void LZ4_copy8(
void* dstPtr,
const void* srcPtr) { memcpy(dstPtr, srcPtr, 8); }
207 static void LZ4_wildCopy(
void* dstPtr,
const void* srcPtr,
void* dstEnd)
222 #define LASTLITERALS 5
223 #define MFLIMIT (COPYLENGTH+MINMATCH)
231 #define MAX_DISTANCE ((1 << MAXD_LOG) - 1)
234 #define ML_MASK ((1U<<ML_BITS)-1)
235 #define RUN_BITS (8-ML_BITS)
236 #define RUN_MASK ((1U<<RUN_BITS)-1)
242 #define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }
254 # if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
256 _BitScanForward64( &r, (
U64)val );
258 # elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT)
259 return (__builtin_ctzll((
U64)val) >> 3);
261 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 };
262 return DeBruijnBytePos[((
U64)((val & -(
long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
267 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
269 _BitScanForward( &r, (
U32)val );
271 # elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT)
272 return (__builtin_ctz((
U32)val) >> 3);
274 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 };
275 return DeBruijnBytePos[((
U32)((val & -(
S32)val) * 0x077CB531U)) >> 27];
283 # if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
285 _BitScanReverse64( &r, val );
286 return (
unsigned)(r>>3);
287 # elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT)
288 return (__builtin_clzll((
U64)val) >> 3);
291 if (!(val>>32)) { r=4; }
else { r=0; val>>=32; }
292 if (!(val>>16)) { r+=2; val>>=8; }
else { val>>=24; }
299 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
301 _BitScanReverse( &r, (
unsigned long)val );
302 return (
unsigned)(r>>3);
303 # elif (defined(__clang__) || (LZ4_GCC_VERSION >= 304)) && !defined(LZ4_FORCE_SW_BITCOUNT)
304 return (__builtin_clz((
U32)val) >> 3);
307 if (!(val>>16)) { r=2; val>>=8; }
else { r=0; val>>=24; }
317 const BYTE*
const pStart = pIn;
324 return (
unsigned)(pIn - pStart);
329 if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
330 return (
unsigned)(pIn - pStart);
334 #ifndef LZ4_COMMONDEFS_ONLY
338 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
339 #define HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
340 #define HASH_SIZE_U32 (1 << LZ4_HASHLOG)
383 if (tableType ==
byU16)
393 const U32 hashMask = (1<<hashLog) - 1;
410 case byPtr: {
const BYTE** hashTable = (
const BYTE**)tableBase; hashTable[
h] =
p;
return; }
411 case byU32: {
U32* hashTable = (
U32*) tableBase; hashTable[
h] = (
U32)(
p-srcBase);
return; }
412 case byU16: {
U16* hashTable = (
U16*) tableBase; hashTable[
h] = (
U16)(
p-srcBase);
return; }
424 if (tableType ==
byPtr) {
const BYTE** hashTable = (
const BYTE**) tableBase;
return hashTable[
h]; }
425 if (tableType ==
byU32) {
U32* hashTable = (
U32*) tableBase;
return hashTable[
h] + srcBase; }
426 {
U16* hashTable = (
U16*) tableBase;
return hashTable[
h] + srcBase; }
445 const U32 acceleration)
451 const BYTE* lowLimit;
454 const BYTE*
const dictEnd = dictionary + dictPtr->
dictSize;
455 const size_t dictDelta = dictEnd - (
const BYTE*)
source;
498 const BYTE* forwardIp = ip;
509 if (
unlikely(forwardIp > mflimit))
goto _last_literals;
516 refDelta = dictDelta;
517 lowLimit = dictionary;
538 unsigned litLength = (unsigned)(ip - anchor);
546 for(;
len >= 255 ;
len-=255) *
op++ = 255;
562 unsigned matchLength;
568 limit = ip + (dictEnd-
match);
569 if (limit > matchlimit) limit = matchlimit;
591 for (; matchLength >= 510 ; matchLength-=510) { *
op++ = 255; *
op++ = 255; }
592 if (matchLength >= 255) { matchLength-=255; *
op++ = 255; }
593 *
op++ = (
BYTE)matchLength;
595 else *token += (
BYTE)(matchLength);
601 if (ip > mflimit)
break;
612 refDelta = dictDelta;
613 lowLimit = dictionary;
625 { token=
op++; *token=0;
goto _next_match; }
634 const size_t lastRun = (
size_t)(iend - anchor);
639 size_t accumulator = lastRun -
RUN_MASK;
641 for(; accumulator >= 255 ; accumulator-=255) *
op++ = 255;
642 *
op++ = (
BYTE) accumulator;
648 memcpy(
op, anchor, lastRun);
653 return (
int) (((
char*)
op)-
dest);
724 const char*
const src,
726 int*
const srcSizePtr,
727 const int targetDstSize,
732 const BYTE* lowLimit = (
const BYTE*) src;
733 const BYTE* anchor = ip;
734 const BYTE*
const iend = ip + *srcSizePtr;
739 BYTE*
const oend =
op + targetDstSize;
740 BYTE*
const oMaxLit =
op + targetDstSize - 2 - 8 - 1 ;
742 BYTE*
const oMaxSeq = oMaxLit - 1 ;
748 if (targetDstSize < 1)
return 0;
764 const BYTE* forwardIp = ip;
791 unsigned litLength = (unsigned)(ip - anchor);
793 if (
op + ((litLength+240)/255) + litLength > oMaxLit)
803 for(;
len >= 255 ;
len-=255) *
op++ = 255;
823 if (
op + ((matchLength+240)/255) > oMaxMatch)
826 matchLength = (15-1) + (oMaxMatch-
op) * 255;
835 while (matchLength >= 255) { matchLength-=255; *
op++ = 255; }
836 *
op++ = (
BYTE)matchLength;
838 else *token += (
BYTE)(matchLength);
844 if (ip > mflimit)
break;
845 if (
op > oMaxSeq)
break;
855 { token=
op++; *token=0;
goto _next_match; }
864 size_t lastRunSize = (
size_t)(iend - anchor);
865 if (
op + 1 + ((lastRunSize+240)/255) + lastRunSize > oend)
868 lastRunSize = (oend-
op) - 1;
869 lastRunSize -= (lastRunSize+240)/255;
871 ip = anchor + lastRunSize;
875 size_t accumulator = lastRunSize -
RUN_MASK;
877 for(; accumulator >= 255 ; accumulator-=255) *
op++ = 255;
878 *
op++ = (
BYTE) accumulator;
884 memcpy(
op, anchor, lastRunSize);
889 *srcSizePtr = (
int) (((
const char*)ip)-src);
890 return (
int) (((
char*)
op)-
dst);
918 void* ctx = &ctxBody;
955 #define HASH_UNIT sizeof(size_t)
960 const BYTE*
const dictEnd =
p + dictSize;
963 if ((
dict->initCheck) || (
dict->currentOffset > 1
GB))
973 if ((dictEnd -
p) > 64
KB)
p = dictEnd - 64
KB;
974 dict->currentOffset += 64
KB;
976 dict->dictionary =
p;
977 dict->dictSize = (
U32)(dictEnd -
p);
978 dict->currentOffset +=
dict->dictSize;
986 return dict->dictSize;
1018 if ((streamPtr->
dictSize>0) && (smallest>dictEnd)) smallest = dictEnd;
1025 if ((sourceEnd > streamPtr->
dictionary) && (sourceEnd < dictEnd))
1069 const BYTE* smallest = dictEnd;
1086 const BYTE* previousDictEnd =
dict->dictionary +
dict->dictSize;
1088 if ((
U32)dictSize > 64
KB) dictSize = 64
KB;
1089 if ((
U32)dictSize >
dict->dictSize) dictSize =
dict->dictSize;
1091 memmove(safeBuffer, previousDictEnd - dictSize, dictSize);
1093 dict->dictionary = (
const BYTE*)safeBuffer;
1094 dict->dictSize = (
U32)dictSize;
1111 const char*
const source,
1117 int partialDecoding,
1118 int targetOutputSize,
1120 const BYTE*
const lowPrefix,
1121 const BYTE*
const dictStart,
1122 const size_t dictSize
1130 BYTE*
const oend =
op + outputSize;
1132 BYTE* oexit =
op + targetOutputSize;
1133 const BYTE*
const lowLimit = lowPrefix - dictSize;
1135 const BYTE*
const dictEnd = (
const BYTE*)dictStart + dictSize;
1136 const size_t dec32table[] = {4, 1, 2, 1, 4, 4, 4, 4};
1137 const size_t dec64table[] = {0, 0, 0, (
size_t)-1, 0, 1, 2, 3};
1140 const int checkOffset = ((safeDecode) && (dictSize < (
int)(64
KB)));
1144 if ((partialDecoding) && (oexit> oend-
MFLIMIT)) oexit = oend-
MFLIMIT;
1145 if ((endOnInput) && (
unlikely(outputSize==0)))
return ((
inputSize==1) && (*ip==0)) ? 0 : -1;
1146 if ((!endOnInput) && (
unlikely(outputSize==0)))
return (*ip==0?1:-1);
1168 if ((safeDecode) &&
unlikely((
size_t)(ip+
length)<(
size_t)(ip)))
goto _output_error;
1176 if (partialDecoding)
1178 if (cpy > oend)
goto _output_error;
1179 if ((endOnInput) && (ip+
length > iend))
goto _output_error;
1183 if ((!endOnInput) && (cpy != oend))
goto _output_error;
1184 if ((endOnInput) && ((ip+
length != iend) || (cpy > oend)))
goto _output_error;
1196 if ((checkOffset) && (
unlikely(
match < lowLimit)))
goto _output_error;
1205 if ((endOnInput) && (ip > iend-
LASTLITERALS))
goto _output_error;
1228 memcpy(
op, dictEnd - copySize, copySize);
1230 copySize =
length - copySize;
1231 if (copySize > (
size_t)(
op-lowPrefix))
1233 BYTE*
const endOfMatch =
op + copySize;
1234 const BYTE* copyFrom = lowPrefix;
1235 while (
op < endOfMatch) *
op++ = *copyFrom++;
1239 memcpy(
op, lowPrefix, copySize);
1250 const size_t dec64 = dec64table[
op-
match];
1278 return (
int) (((
char*)
op)-
dest);
1280 return (
int) (((
const char*)ip)-
source);
1284 return (
int) (-(((
const char*)ip)-
source))-1;
1290 return LZ4_decompress_generic(
source,
dest,
compressedSize, maxDecompressedSize,
endOnInputSize,
full, 0,
noDict, (
BYTE*)
dest,
NULL, 0);
1295 return LZ4_decompress_generic(
source,
dest,
compressedSize, maxDecompressedSize,
endOnInputSize,
partial, targetOutputSize,
noDict, (
BYTE*)
dest,
NULL, 0);
1300 return LZ4_decompress_generic(
source,
dest, 0,
originalSize,
endOnOutputSize,
full, 0,
withPrefix64k, (
BYTE*)(
dest - 64
KB),
NULL, 64
KB);
1424 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize, safe,
full, 0,
noDict, (
BYTE*)
dest,
NULL, 0);
1425 if (dictStart+dictSize ==
dest)
1427 if (dictSize >= (
int)(64
KB - 1))
1428 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize, safe,
full, 0,
withPrefix64k, (
BYTE*)
dest-64
KB,
NULL, 0);
1429 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize, safe,
full, 0,
noDict, (
BYTE*)
dest-dictSize,
NULL, 0);
1431 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize, safe,
full, 0,
usingExtDict, (
BYTE*)
dest, (
const BYTE*)dictStart, dictSize);
1447 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize,
endOnInputSize,
full, 0,
usingExtDict, (
BYTE*)
dest, (
const BYTE*)dictStart, dictSize);
1484 if ((((
size_t)
state) & 3) != 0)
return 1;
1507 return LZ4_decompress_generic(
source,
dest,
compressedSize,
maxOutputSize,
endOnInputSize,
full, 0,
withPrefix64k, (
BYTE*)
dest - 64
KB,
NULL, 64
KB);
1512 return LZ4_decompress_generic(
source,
dest, 0,
originalSize,
endOnOutputSize,
full, 0,
withPrefix64k, (
BYTE*)
dest - 64
KB,
NULL, 64
KB);
int LZ4_decompress_fast_withPrefix64k(const char *source, char *dest, int originalSize)
int LZ4_decompress_safe_forceExtDict(const char *source, char *dest, int compressedSize, int maxOutputSize, const char *dictStart, int dictSize)
int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize)
int LZ4_decompress_safe_withPrefix64k(const char *source, char *dest, int compressedSize, int maxOutputSize)
FORCE_INLINE int LZ4_decompress_usingDict_generic(const char *source, char *dest, int compressedSize, int maxOutputSize, int safe, const char *dictStart, int dictSize)
GLM_FUNC_DECL genType::value_type length(genType const &x)
#define LZ4_VERSION_NUMBER
static U32 LZ4_hashSequence64(size_t sequence, tableType_t const tableType)
int LZ4_sizeofStreamState()
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
#define ACCELERATION_DEFAULT
int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
int LZ4_compress_forceExtDict(LZ4_stream_t *LZ4_dict, const char *source, char *dest, int inputSize)
static const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
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)
#define LZ4_COMPRESSBOUND(isize)
static U16 LZ4_read16(const void *memPtr)
const char char int int maxOutputSize
int LZ4_compress_fast(const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
int LZ4_compress_fast_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
int LZ4_decompress_fast(const char *source, char *dest, int originalSize)
RecoveryProgressState state
int LZ4_uncompress(const char *source, char *dest, int outputSize)
static unsigned LZ4_isLittleEndian(void)
void * LZ4_create(char *inputBuffer)
LZ4_stream_t * LZ4_createStream(void)
static U16 LZ4_readLE16(const void *memPtr)
int LZ4_compress_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize)
static void LZ4_putPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
int LZ4_decompress_safe_partial(const char *source, char *dest, int compressedSize, int targetOutputSize, int maxDecompressedSize)
GLM_FUNC_DECL genType one()
const BYTE * externalDict
LZ4_streamDecode_t * LZ4_createStreamDecode(void)
static unsigned LZ4_NbCommonBytes(register size_t val)
static void LZ4_copy8(void *dstPtr, const void *srcPtr)
static const U32 LZ4_skipTrigger
static U32 LZ4_read32(const void *memPtr)
int LZ4_resetStreamState(void *state, char *inputBuffer)
int LZ4_loadDict(LZ4_stream_t *LZ4_dict, const char *dictionary, int dictSize)
static void LZ4_writeLE16(void *memPtr, U16 value)
int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
bool match(const T &xpr, std::string ref, std::string str_xpr="")
int LZ4_compress_default(const char *source, char *dest, int inputSize, int maxOutputSize)
static void LZ4_init(LZ4_stream_t_internal *lz4ds, BYTE *base)
int LZ4_compress_limitedOutput_withState(void *state, const char *src, char *dst, int srcSize, int dstSize)
static void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd)
static U32 LZ4_hashSequenceT(size_t sequence, tableType_t const tableType)
int LZ4_compress_fast_extState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
int LZ4_freeStream(LZ4_stream_t *LZ4_stream)
def step(data, isam, result, truth, currPoseIndex, isamArgs=())
int LZ4_decompress_fast_usingDict(const char *source, char *dest, int originalSize, const char *dictStart, int dictSize)
#define LZ4_STATIC_ASSERT(c)
#define LZ4_MAX_INPUT_SIZE
static const int LZ4_64Klimit
static U64 LZ4_read64(const void *memPtr)
static unsigned LZ4_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *pInLimit)
FORCE_INLINE int LZ4_compress_generic(void *const ctx, 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)
static void LZ4_copy4(void *dstPtr, const void *srcPtr)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
int LZ4_compressBound(int isize)
int LZ4_compress_fast_force(const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
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_usingDict(const char *source, char *dest, int compressedSize, int maxOutputSize, const char *dictStart, int dictSize)
int LZ4_compress_withState(void *state, const char *src, char *dst, int srcSize)
#define LZ4_STREAMSIZE_U64
int LZ4_compress(const char *source, char *dest, int inputSize)
static U32 LZ4_hashPosition(const void *p, tableType_t tableType)
static int LZ4_compress_destSize_generic(void *const ctx, const char *const src, char *const dst, int *const srcSizePtr, const int targetDstSize, const tableType_t tableType)
static void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t const tableType, const BYTE *srcBase)
int LZ4_compress_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize)
char * LZ4_slideInputBuffer(void *LZ4_Data)
static const U64 prime5bytes
static int LZ4_compress_destSize_extState(void *state, const char *src, char *dst, int *srcSizePtr, int targetDstSize)
static const BYTE * LZ4_getPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
int LZ4_versionNumber(void)
static size_t LZ4_read_ARCH(const void *p)
U32 hashTable[HASH_SIZE_U32]
void LZ4_resetStream(LZ4_stream_t *LZ4_stream)
int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_stream, const char *src, char *dst, int srcSize, int maxDstSize)
static U32 LZ4_hashSequence(U32 sequence, tableType_t const tableType)
static const int LZ4_minLength
const char char int inputSize
static void LZ4_renormDictT(LZ4_stream_t_internal *LZ4_dict, const BYTE *src)
static unsigned LZ4_64bits(void)
int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int originalSize)
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11