[linux-kernel] Update zstd.diff
This commit is contained in:
parent
358280f107
commit
fb10c91b4f
@ -1203,10 +1203,10 @@ index 0000000..aa5eb4d
|
|||||||
+ huf_decompress.o decompress.o
|
+ huf_decompress.o decompress.o
|
||||||
diff --git a/lib/zstd/bitstream.h b/lib/zstd/bitstream.h
|
diff --git a/lib/zstd/bitstream.h b/lib/zstd/bitstream.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..9d21540
|
index 0000000..9b5d2bc
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/bitstream.h
|
+++ b/lib/zstd/bitstream.h
|
||||||
@@ -0,0 +1,391 @@
|
@@ -0,0 +1,376 @@
|
||||||
+/* ******************************************************************
|
+/* ******************************************************************
|
||||||
+ bitstream
|
+ bitstream
|
||||||
+ Part of FSE library
|
+ Part of FSE library
|
||||||
@ -1356,22 +1356,7 @@ index 0000000..9d21540
|
|||||||
+****************************************************************/
|
+****************************************************************/
|
||||||
+MEM_STATIC unsigned BIT_highbit32 (register U32 val)
|
+MEM_STATIC unsigned BIT_highbit32 (register U32 val)
|
||||||
+{
|
+{
|
||||||
+# if defined(_MSC_VER) /* Visual */
|
+ return 31 - __builtin_clz(val);
|
||||||
+ unsigned long r=0;
|
|
||||||
+ _BitScanReverse ( &r, val );
|
|
||||||
+ return (unsigned) r;
|
|
||||||
+# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
|
|
||||||
+ return 31 - __builtin_clz (val);
|
|
||||||
+# else /* Software version */
|
|
||||||
+ static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
|
|
||||||
+ U32 v = val;
|
|
||||||
+ v |= v >> 1;
|
|
||||||
+ v |= v >> 2;
|
|
||||||
+ v |= v >> 4;
|
|
||||||
+ v |= v >> 8;
|
|
||||||
+ v |= v >> 16;
|
|
||||||
+ return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
|
|
||||||
+# endif
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+/*===== Local Constants =====*/
|
+/*===== Local Constants =====*/
|
||||||
@ -1600,10 +1585,10 @@ index 0000000..9d21540
|
|||||||
+#endif /* BITSTREAM_H_MODULE */
|
+#endif /* BITSTREAM_H_MODULE */
|
||||||
diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
|
diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..79c3207
|
index 0000000..4f1e184
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/compress.c
|
+++ b/lib/zstd/compress.c
|
||||||
@@ -0,0 +1,3384 @@
|
@@ -0,0 +1,3297 @@
|
||||||
+/**
|
+/**
|
||||||
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
+ * All rights reserved.
|
+ * All rights reserved.
|
||||||
@ -1625,10 +1610,6 @@ index 0000000..79c3207
|
|||||||
+#include "huf.h"
|
+#include "huf.h"
|
||||||
+#include "zstd_internal.h" /* includes zstd.h */
|
+#include "zstd_internal.h" /* includes zstd.h */
|
||||||
+
|
+
|
||||||
+#ifdef current
|
|
||||||
+# undef current
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+/*-*************************************
|
+/*-*************************************
|
||||||
+* Constants
|
+* Constants
|
||||||
+***************************************/
|
+***************************************/
|
||||||
@ -1659,7 +1640,7 @@ index 0000000..79c3207
|
|||||||
+* Context memory management
|
+* Context memory management
|
||||||
+***************************************/
|
+***************************************/
|
||||||
+struct ZSTD_CCtx_s {
|
+struct ZSTD_CCtx_s {
|
||||||
+ const BYTE* nextSrc; /* next block here to continue on current prefix */
|
+ const BYTE* nextSrc; /* next block here to continue on curr prefix */
|
||||||
+ const BYTE* base; /* All regular indexes relative to this position */
|
+ const BYTE* base; /* All regular indexes relative to this position */
|
||||||
+ const BYTE* dictBase; /* extDict indexes relative to this position */
|
+ const BYTE* dictBase; /* extDict indexes relative to this position */
|
||||||
+ U32 dictLimit; /* below that point, need extDict */
|
+ U32 dictLimit; /* below that point, need extDict */
|
||||||
@ -2384,12 +2365,6 @@ index 0000000..79c3207
|
|||||||
+ return op - ostart;
|
+ return op - ostart;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+#if 0 /* for debug */
|
|
||||||
+# define STORESEQ_DEBUG
|
|
||||||
+U32 g_startDebug = 0;
|
|
||||||
+const BYTE* g_start = NULL;
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+/*! ZSTD_storeSeq() :
|
+/*! ZSTD_storeSeq() :
|
||||||
+ Store a sequence (literal length, literals, offset code and match length code) into seqStore_t.
|
+ Store a sequence (literal length, literals, offset code and match length code) into seqStore_t.
|
||||||
+ `offsetCode` : distance to match, or 0 == repCode.
|
+ `offsetCode` : distance to match, or 0 == repCode.
|
||||||
@ -2397,15 +2372,6 @@ index 0000000..79c3207
|
|||||||
+*/
|
+*/
|
||||||
+MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const void* literals, U32 offsetCode, size_t matchCode)
|
+MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const void* literals, U32 offsetCode, size_t matchCode)
|
||||||
+{
|
+{
|
||||||
+#ifdef STORESEQ_DEBUG
|
|
||||||
+ if (g_startDebug) {
|
|
||||||
+ const U32 pos = (U32)((const BYTE*)literals - g_start);
|
|
||||||
+ if (g_start==NULL) g_start = (const BYTE*)literals;
|
|
||||||
+ if ((pos > 1895000) && (pos < 1895300))
|
|
||||||
+ fprintf(stderr, "Cpos %6u :%5u literals & match %3u bytes at distance %6u \n",
|
|
||||||
+ pos, (U32)litLength, (U32)matchCode+MINMATCH, (U32)offsetCode);
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+ /* copy Literals */
|
+ /* copy Literals */
|
||||||
+ ZSTD_wildcopy(seqStorePtr->lit, literals, litLength);
|
+ ZSTD_wildcopy(seqStorePtr->lit, literals, litLength);
|
||||||
+ seqStorePtr->lit += litLength;
|
+ seqStorePtr->lit += litLength;
|
||||||
@ -2432,57 +2398,15 @@ index 0000000..79c3207
|
|||||||
+{
|
+{
|
||||||
+ if (MEM_isLittleEndian()) {
|
+ if (MEM_isLittleEndian()) {
|
||||||
+ if (MEM_64bits()) {
|
+ if (MEM_64bits()) {
|
||||||
+# if defined(_MSC_VER) && defined(_WIN64)
|
|
||||||
+ unsigned long r = 0;
|
|
||||||
+ _BitScanForward64( &r, (U64)val );
|
|
||||||
+ return (unsigned)(r>>3);
|
|
||||||
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
|
||||||
+ return (__builtin_ctzll((U64)val) >> 3);
|
+ return (__builtin_ctzll((U64)val) >> 3);
|
||||||
+# else
|
|
||||||
+ 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 };
|
|
||||||
+ return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
|
|
||||||
+# endif
|
|
||||||
+ } else { /* 32 bits */
|
+ } else { /* 32 bits */
|
||||||
+# if defined(_MSC_VER)
|
|
||||||
+ unsigned long r=0;
|
|
||||||
+ _BitScanForward( &r, (U32)val );
|
|
||||||
+ return (unsigned)(r>>3);
|
|
||||||
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
|
||||||
+ return (__builtin_ctz((U32)val) >> 3);
|
+ return (__builtin_ctz((U32)val) >> 3);
|
||||||
+# else
|
|
||||||
+ 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 };
|
|
||||||
+ return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
|
|
||||||
+# endif
|
|
||||||
+ }
|
+ }
|
||||||
+ } else { /* Big Endian CPU */
|
+ } else { /* Big Endian CPU */
|
||||||
+ if (MEM_64bits()) {
|
+ if (MEM_64bits()) {
|
||||||
+# if defined(_MSC_VER) && defined(_WIN64)
|
|
||||||
+ unsigned long r = 0;
|
|
||||||
+ _BitScanReverse64( &r, val );
|
|
||||||
+ return (unsigned)(r>>3);
|
|
||||||
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
|
||||||
+ return (__builtin_clzll(val) >> 3);
|
+ return (__builtin_clzll(val) >> 3);
|
||||||
+# else
|
|
||||||
+ unsigned r;
|
|
||||||
+ const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
|
|
||||||
+ if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
|
|
||||||
+ if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
|
|
||||||
+ r += (!val);
|
|
||||||
+ return r;
|
|
||||||
+# endif
|
|
||||||
+ } else { /* 32 bits */
|
+ } else { /* 32 bits */
|
||||||
+# if defined(_MSC_VER)
|
|
||||||
+ unsigned long r = 0;
|
|
||||||
+ _BitScanReverse( &r, (unsigned long)val );
|
|
||||||
+ return (unsigned)(r>>3);
|
|
||||||
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
|
||||||
+ return (__builtin_clz((U32)val) >> 3);
|
+ return (__builtin_clz((U32)val) >> 3);
|
||||||
+# else
|
|
||||||
+ unsigned r;
|
|
||||||
+ if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
|
|
||||||
+ r += (!val);
|
|
||||||
+ return r;
|
|
||||||
+# endif
|
|
||||||
+ } }
|
+ } }
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -2608,10 +2532,10 @@ index 0000000..79c3207
|
|||||||
+ while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
|
+ while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
|
||||||
+ size_t mLength;
|
+ size_t mLength;
|
||||||
+ size_t const h = ZSTD_hashPtr(ip, hBits, mls);
|
+ size_t const h = ZSTD_hashPtr(ip, hBits, mls);
|
||||||
+ U32 const current = (U32)(ip-base);
|
+ U32 const curr = (U32)(ip-base);
|
||||||
+ U32 const matchIndex = hashTable[h];
|
+ U32 const matchIndex = hashTable[h];
|
||||||
+ const BYTE* match = base + matchIndex;
|
+ const BYTE* match = base + matchIndex;
|
||||||
+ hashTable[h] = current; /* update hash table */
|
+ hashTable[h] = curr; /* update hash table */
|
||||||
+
|
+
|
||||||
+ if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) {
|
+ if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) {
|
||||||
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
|
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
|
||||||
@ -2638,7 +2562,7 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ if (ip <= ilimit) {
|
+ if (ip <= ilimit) {
|
||||||
+ /* Fill Table */
|
+ /* Fill Table */
|
||||||
+ hashTable[ZSTD_hashPtr(base+current+2, hBits, mls)] = current+2; /* here because current+2 could be > iend-8 */
|
+ hashTable[ZSTD_hashPtr(base+curr+2, hBits, mls)] = curr+2; /* here because curr+2 could be > iend-8 */
|
||||||
+ hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
+ hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
||||||
+ /* check immediate repcode */
|
+ /* check immediate repcode */
|
||||||
+ while ( (ip <= ilimit)
|
+ while ( (ip <= ilimit)
|
||||||
@ -2712,12 +2636,12 @@ index 0000000..79c3207
|
|||||||
+ const U32 matchIndex = hashTable[h];
|
+ const U32 matchIndex = hashTable[h];
|
||||||
+ const BYTE* matchBase = matchIndex < dictLimit ? dictBase : base;
|
+ const BYTE* matchBase = matchIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* match = matchBase + matchIndex;
|
+ const BYTE* match = matchBase + matchIndex;
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 repIndex = current + 1 - offset_1; /* offset_1 expected <= current +1 */
|
+ const U32 repIndex = curr + 1 - offset_1; /* offset_1 expected <= curr +1 */
|
||||||
+ const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* repMatch = repBase + repIndex;
|
+ const BYTE* repMatch = repBase + repIndex;
|
||||||
+ size_t mLength;
|
+ size_t mLength;
|
||||||
+ hashTable[h] = current; /* update hash table */
|
+ hashTable[h] = curr; /* update hash table */
|
||||||
+
|
+
|
||||||
+ if ( (((U32)((dictLimit-1) - repIndex) >= 3) /* intentional underflow */ & (repIndex > lowestIndex))
|
+ if ( (((U32)((dictLimit-1) - repIndex) >= 3) /* intentional underflow */ & (repIndex > lowestIndex))
|
||||||
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
|
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
|
||||||
@ -2736,7 +2660,7 @@ index 0000000..79c3207
|
|||||||
+ U32 offset;
|
+ U32 offset;
|
||||||
+ mLength = ZSTD_count_2segments(ip+EQUAL_READ32, match+EQUAL_READ32, iend, matchEnd, lowPrefixPtr) + EQUAL_READ32;
|
+ mLength = ZSTD_count_2segments(ip+EQUAL_READ32, match+EQUAL_READ32, iend, matchEnd, lowPrefixPtr) + EQUAL_READ32;
|
||||||
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
|
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
|
||||||
+ offset = current - matchIndex;
|
+ offset = curr - matchIndex;
|
||||||
+ offset_2 = offset_1;
|
+ offset_2 = offset_1;
|
||||||
+ offset_1 = offset;
|
+ offset_1 = offset;
|
||||||
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
|
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
|
||||||
@ -2748,12 +2672,12 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ if (ip <= ilimit) {
|
+ if (ip <= ilimit) {
|
||||||
+ /* Fill Table */
|
+ /* Fill Table */
|
||||||
+ hashTable[ZSTD_hashPtr(base+current+2, hBits, mls)] = current+2;
|
+ hashTable[ZSTD_hashPtr(base+curr+2, hBits, mls)] = curr+2;
|
||||||
+ hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
+ hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
||||||
+ /* check immediate repcode */
|
+ /* check immediate repcode */
|
||||||
+ while (ip <= ilimit) {
|
+ while (ip <= ilimit) {
|
||||||
+ U32 const current2 = (U32)(ip-base);
|
+ U32 const curr2 = (U32)(ip-base);
|
||||||
+ U32 const repIndex2 = current2 - offset_2;
|
+ U32 const repIndex2 = curr2 - offset_2;
|
||||||
+ const BYTE* repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2;
|
+ const BYTE* repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2;
|
||||||
+ if ( (((U32)((dictLimit-1) - repIndex2) >= 3) & (repIndex2 > lowestIndex)) /* intentional overflow */
|
+ if ( (((U32)((dictLimit-1) - repIndex2) >= 3) & (repIndex2 > lowestIndex)) /* intentional overflow */
|
||||||
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
|
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
|
||||||
@ -2761,7 +2685,7 @@ index 0000000..79c3207
|
|||||||
+ size_t repLength2 = ZSTD_count_2segments(ip+EQUAL_READ32, repMatch2+EQUAL_READ32, iend, repEnd2, lowPrefixPtr) + EQUAL_READ32;
|
+ size_t repLength2 = ZSTD_count_2segments(ip+EQUAL_READ32, repMatch2+EQUAL_READ32, iend, repEnd2, lowPrefixPtr) + EQUAL_READ32;
|
||||||
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
||||||
+ ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, repLength2-MINMATCH);
|
+ ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, repLength2-MINMATCH);
|
||||||
+ hashTable[ZSTD_hashPtr(ip, hBits, mls)] = current2;
|
+ hashTable[ZSTD_hashPtr(ip, hBits, mls)] = curr2;
|
||||||
+ ip += repLength2;
|
+ ip += repLength2;
|
||||||
+ anchor = ip;
|
+ anchor = ip;
|
||||||
+ continue;
|
+ continue;
|
||||||
@ -2854,14 +2778,14 @@ index 0000000..79c3207
|
|||||||
+ size_t mLength;
|
+ size_t mLength;
|
||||||
+ size_t const h2 = ZSTD_hashPtr(ip, hBitsL, 8);
|
+ size_t const h2 = ZSTD_hashPtr(ip, hBitsL, 8);
|
||||||
+ size_t const h = ZSTD_hashPtr(ip, hBitsS, mls);
|
+ size_t const h = ZSTD_hashPtr(ip, hBitsS, mls);
|
||||||
+ U32 const current = (U32)(ip-base);
|
+ U32 const curr = (U32)(ip-base);
|
||||||
+ U32 const matchIndexL = hashLong[h2];
|
+ U32 const matchIndexL = hashLong[h2];
|
||||||
+ U32 const matchIndexS = hashSmall[h];
|
+ U32 const matchIndexS = hashSmall[h];
|
||||||
+ const BYTE* matchLong = base + matchIndexL;
|
+ const BYTE* matchLong = base + matchIndexL;
|
||||||
+ const BYTE* match = base + matchIndexS;
|
+ const BYTE* match = base + matchIndexS;
|
||||||
+ hashLong[h2] = hashSmall[h] = current; /* update hash tables */
|
+ hashLong[h2] = hashSmall[h] = curr; /* update hash tables */
|
||||||
+
|
+
|
||||||
+ if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) { /* note : by construction, offset_1 <= current */
|
+ if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) { /* note : by construction, offset_1 <= curr */
|
||||||
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
|
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
|
||||||
+ ip++;
|
+ ip++;
|
||||||
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, 0, mLength-MINMATCH);
|
+ ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, 0, mLength-MINMATCH);
|
||||||
@ -2875,7 +2799,7 @@ index 0000000..79c3207
|
|||||||
+ size_t const h3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
+ size_t const h3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
||||||
+ U32 const matchIndex3 = hashLong[h3];
|
+ U32 const matchIndex3 = hashLong[h3];
|
||||||
+ const BYTE* match3 = base + matchIndex3;
|
+ const BYTE* match3 = base + matchIndex3;
|
||||||
+ hashLong[h3] = current + 1;
|
+ hashLong[h3] = curr + 1;
|
||||||
+ if ( (matchIndex3 > lowestIndex) && (MEM_read64(match3) == MEM_read64(ip+1)) ) {
|
+ if ( (matchIndex3 > lowestIndex) && (MEM_read64(match3) == MEM_read64(ip+1)) ) {
|
||||||
+ mLength = ZSTD_count(ip+9, match3+8, iend) + 8;
|
+ mLength = ZSTD_count(ip+9, match3+8, iend) + 8;
|
||||||
+ ip++;
|
+ ip++;
|
||||||
@ -2903,8 +2827,8 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ if (ip <= ilimit) {
|
+ if (ip <= ilimit) {
|
||||||
+ /* Fill Table */
|
+ /* Fill Table */
|
||||||
+ hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] =
|
+ hashLong[ZSTD_hashPtr(base+curr+2, hBitsL, 8)] =
|
||||||
+ hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2; /* here because current+2 could be > iend-8 */
|
+ hashSmall[ZSTD_hashPtr(base+curr+2, hBitsS, mls)] = curr+2; /* here because curr+2 could be > iend-8 */
|
||||||
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] =
|
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] =
|
||||||
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
|
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
|
||||||
+
|
+
|
||||||
@ -2988,12 +2912,12 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* matchLongBase = matchLongIndex < dictLimit ? dictBase : base;
|
+ const BYTE* matchLongBase = matchLongIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* matchLong = matchLongBase + matchLongIndex;
|
+ const BYTE* matchLong = matchLongBase + matchLongIndex;
|
||||||
+
|
+
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 repIndex = current + 1 - offset_1; /* offset_1 expected <= current +1 */
|
+ const U32 repIndex = curr + 1 - offset_1; /* offset_1 expected <= curr +1 */
|
||||||
+ const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* repMatch = repBase + repIndex;
|
+ const BYTE* repMatch = repBase + repIndex;
|
||||||
+ size_t mLength;
|
+ size_t mLength;
|
||||||
+ hashSmall[hSmall] = hashLong[hLong] = current; /* update hash table */
|
+ hashSmall[hSmall] = hashLong[hLong] = curr; /* update hash table */
|
||||||
+
|
+
|
||||||
+ if ( (((U32)((dictLimit-1) - repIndex) >= 3) /* intentional underflow */ & (repIndex > lowestIndex))
|
+ if ( (((U32)((dictLimit-1) - repIndex) >= 3) /* intentional underflow */ & (repIndex > lowestIndex))
|
||||||
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
|
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
|
||||||
@ -3007,7 +2931,7 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* lowMatchPtr = matchLongIndex < dictLimit ? dictStart : lowPrefixPtr;
|
+ const BYTE* lowMatchPtr = matchLongIndex < dictLimit ? dictStart : lowPrefixPtr;
|
||||||
+ U32 offset;
|
+ U32 offset;
|
||||||
+ mLength = ZSTD_count_2segments(ip+8, matchLong+8, iend, matchEnd, lowPrefixPtr) + 8;
|
+ mLength = ZSTD_count_2segments(ip+8, matchLong+8, iend, matchEnd, lowPrefixPtr) + 8;
|
||||||
+ offset = current - matchLongIndex;
|
+ offset = curr - matchLongIndex;
|
||||||
+ while (((ip>anchor) & (matchLong>lowMatchPtr)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
|
+ while (((ip>anchor) & (matchLong>lowMatchPtr)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
|
||||||
+ offset_2 = offset_1;
|
+ offset_2 = offset_1;
|
||||||
+ offset_1 = offset;
|
+ offset_1 = offset;
|
||||||
@ -3019,19 +2943,19 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* const match3Base = matchIndex3 < dictLimit ? dictBase : base;
|
+ const BYTE* const match3Base = matchIndex3 < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* match3 = match3Base + matchIndex3;
|
+ const BYTE* match3 = match3Base + matchIndex3;
|
||||||
+ U32 offset;
|
+ U32 offset;
|
||||||
+ hashLong[h3] = current + 1;
|
+ hashLong[h3] = curr + 1;
|
||||||
+ if ( (matchIndex3 > lowestIndex) && (MEM_read64(match3) == MEM_read64(ip+1)) ) {
|
+ if ( (matchIndex3 > lowestIndex) && (MEM_read64(match3) == MEM_read64(ip+1)) ) {
|
||||||
+ const BYTE* matchEnd = matchIndex3 < dictLimit ? dictEnd : iend;
|
+ const BYTE* matchEnd = matchIndex3 < dictLimit ? dictEnd : iend;
|
||||||
+ const BYTE* lowMatchPtr = matchIndex3 < dictLimit ? dictStart : lowPrefixPtr;
|
+ const BYTE* lowMatchPtr = matchIndex3 < dictLimit ? dictStart : lowPrefixPtr;
|
||||||
+ mLength = ZSTD_count_2segments(ip+9, match3+8, iend, matchEnd, lowPrefixPtr) + 8;
|
+ mLength = ZSTD_count_2segments(ip+9, match3+8, iend, matchEnd, lowPrefixPtr) + 8;
|
||||||
+ ip++;
|
+ ip++;
|
||||||
+ offset = current+1 - matchIndex3;
|
+ offset = curr+1 - matchIndex3;
|
||||||
+ while (((ip>anchor) & (match3>lowMatchPtr)) && (ip[-1] == match3[-1])) { ip--; match3--; mLength++; } /* catch up */
|
+ while (((ip>anchor) & (match3>lowMatchPtr)) && (ip[-1] == match3[-1])) { ip--; match3--; mLength++; } /* catch up */
|
||||||
+ } else {
|
+ } else {
|
||||||
+ const BYTE* matchEnd = matchIndex < dictLimit ? dictEnd : iend;
|
+ const BYTE* matchEnd = matchIndex < dictLimit ? dictEnd : iend;
|
||||||
+ const BYTE* lowMatchPtr = matchIndex < dictLimit ? dictStart : lowPrefixPtr;
|
+ const BYTE* lowMatchPtr = matchIndex < dictLimit ? dictStart : lowPrefixPtr;
|
||||||
+ mLength = ZSTD_count_2segments(ip+4, match+4, iend, matchEnd, lowPrefixPtr) + 4;
|
+ mLength = ZSTD_count_2segments(ip+4, match+4, iend, matchEnd, lowPrefixPtr) + 4;
|
||||||
+ offset = current - matchIndex;
|
+ offset = curr - matchIndex;
|
||||||
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
|
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
|
||||||
+ }
|
+ }
|
||||||
+ offset_2 = offset_1;
|
+ offset_2 = offset_1;
|
||||||
@ -3049,14 +2973,14 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ if (ip <= ilimit) {
|
+ if (ip <= ilimit) {
|
||||||
+ /* Fill Table */
|
+ /* Fill Table */
|
||||||
+ hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2;
|
+ hashSmall[ZSTD_hashPtr(base+curr+2, hBitsS, mls)] = curr+2;
|
||||||
+ hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] = current+2;
|
+ hashLong[ZSTD_hashPtr(base+curr+2, hBitsL, 8)] = curr+2;
|
||||||
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
|
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
|
||||||
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base);
|
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base);
|
||||||
+ /* check immediate repcode */
|
+ /* check immediate repcode */
|
||||||
+ while (ip <= ilimit) {
|
+ while (ip <= ilimit) {
|
||||||
+ U32 const current2 = (U32)(ip-base);
|
+ U32 const curr2 = (U32)(ip-base);
|
||||||
+ U32 const repIndex2 = current2 - offset_2;
|
+ U32 const repIndex2 = curr2 - offset_2;
|
||||||
+ const BYTE* repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2;
|
+ const BYTE* repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2;
|
||||||
+ if ( (((U32)((dictLimit-1) - repIndex2) >= 3) & (repIndex2 > lowestIndex)) /* intentional overflow */
|
+ if ( (((U32)((dictLimit-1) - repIndex2) >= 3) & (repIndex2 > lowestIndex)) /* intentional overflow */
|
||||||
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
|
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
|
||||||
@ -3064,8 +2988,8 @@ index 0000000..79c3207
|
|||||||
+ size_t const repLength2 = ZSTD_count_2segments(ip+EQUAL_READ32, repMatch2+EQUAL_READ32, iend, repEnd2, lowPrefixPtr) + EQUAL_READ32;
|
+ size_t const repLength2 = ZSTD_count_2segments(ip+EQUAL_READ32, repMatch2+EQUAL_READ32, iend, repEnd2, lowPrefixPtr) + EQUAL_READ32;
|
||||||
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
|
||||||
+ ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, repLength2-MINMATCH);
|
+ ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, repLength2-MINMATCH);
|
||||||
+ hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = current2;
|
+ hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = curr2;
|
||||||
+ hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = current2;
|
+ hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = curr2;
|
||||||
+ ip += repLength2;
|
+ ip += repLength2;
|
||||||
+ anchor = ip;
|
+ anchor = ip;
|
||||||
+ continue;
|
+ continue;
|
||||||
@ -3126,47 +3050,21 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
||||||
+ const BYTE* const prefixStart = base + dictLimit;
|
+ const BYTE* const prefixStart = base + dictLimit;
|
||||||
+ const BYTE* match;
|
+ const BYTE* match;
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 btLow = btMask >= current ? 0 : current - btMask;
|
+ const U32 btLow = btMask >= curr ? 0 : curr - btMask;
|
||||||
+ U32* smallerPtr = bt + 2*(current&btMask);
|
+ U32* smallerPtr = bt + 2*(curr&btMask);
|
||||||
+ U32* largerPtr = smallerPtr + 1;
|
+ U32* largerPtr = smallerPtr + 1;
|
||||||
+ U32 dummy32; /* to be nullified at the end */
|
+ U32 dummy32; /* to be nullified at the end */
|
||||||
+ U32 const windowLow = zc->lowLimit;
|
+ U32 const windowLow = zc->lowLimit;
|
||||||
+ U32 matchEndIdx = current+8;
|
+ U32 matchEndIdx = curr+8;
|
||||||
+ size_t bestLength = 8;
|
+ size_t bestLength = 8;
|
||||||
+#ifdef ZSTD_C_PREDICT
|
|
||||||
+ U32 predictedSmall = *(bt + 2*((current-1)&btMask) + 0);
|
|
||||||
+ U32 predictedLarge = *(bt + 2*((current-1)&btMask) + 1);
|
|
||||||
+ predictedSmall += (predictedSmall>0);
|
|
||||||
+ predictedLarge += (predictedLarge>0);
|
|
||||||
+#endif /* ZSTD_C_PREDICT */
|
|
||||||
+
|
+
|
||||||
+ hashTable[h] = current; /* Update Hash Table */
|
+ hashTable[h] = curr; /* Update Hash Table */
|
||||||
+
|
+
|
||||||
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
||||||
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
|
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
|
||||||
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
|
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
|
||||||
+
|
+
|
||||||
+#ifdef ZSTD_C_PREDICT /* note : can create issues when hlog small <= 11 */
|
|
||||||
+ const U32* predictPtr = bt + 2*((matchIndex-1) & btMask); /* written this way, as bt is a roll buffer */
|
|
||||||
+ if (matchIndex == predictedSmall) {
|
|
||||||
+ /* no need to check length, result known */
|
|
||||||
+ *smallerPtr = matchIndex;
|
|
||||||
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
|
||||||
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
|
||||||
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
|
|
||||||
+ predictedSmall = predictPtr[1] + (predictPtr[1]>0);
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ if (matchIndex == predictedLarge) {
|
|
||||||
+ *largerPtr = matchIndex;
|
|
||||||
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
|
||||||
+ largerPtr = nextPtr;
|
|
||||||
+ matchIndex = nextPtr[0];
|
|
||||||
+ predictedLarge = predictPtr[0] + (predictPtr[0]>0);
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+ if ((!extDict) || (matchIndex+matchLength >= dictLimit)) {
|
+ if ((!extDict) || (matchIndex+matchLength >= dictLimit)) {
|
||||||
+ match = base + matchIndex;
|
+ match = base + matchIndex;
|
||||||
+ if (match[matchLength] == ip[matchLength])
|
+ if (match[matchLength] == ip[matchLength])
|
||||||
@ -3188,14 +3086,14 @@ index 0000000..79c3207
|
|||||||
+ break; /* drop , to guarantee consistency ; miss a bit of compression, but other solutions can corrupt the tree */
|
+ break; /* drop , to guarantee consistency ; miss a bit of compression, but other solutions can corrupt the tree */
|
||||||
+
|
+
|
||||||
+ if (match[matchLength] < ip[matchLength]) { /* necessarily within correct buffer */
|
+ if (match[matchLength] < ip[matchLength]) { /* necessarily within correct buffer */
|
||||||
+ /* match is smaller than current */
|
+ /* match is smaller than curr */
|
||||||
+ *smallerPtr = matchIndex; /* update smaller idx */
|
+ *smallerPtr = matchIndex; /* update smaller idx */
|
||||||
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
||||||
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
||||||
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
|
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to curr) */
|
||||||
+ } else {
|
+ } else {
|
||||||
+ /* match is larger than current */
|
+ /* match is larger than curr */
|
||||||
+ *largerPtr = matchIndex;
|
+ *largerPtr = matchIndex;
|
||||||
+ commonLengthLarger = matchLength;
|
+ commonLengthLarger = matchLength;
|
||||||
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
@ -3205,7 +3103,7 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ *smallerPtr = *largerPtr = 0;
|
+ *smallerPtr = *largerPtr = 0;
|
||||||
+ if (bestLength > 384) return MIN(192, (U32)(bestLength - 384)); /* speed optimization */
|
+ if (bestLength > 384) return MIN(192, (U32)(bestLength - 384)); /* speed optimization */
|
||||||
+ if (matchEndIdx > current + 8) return matchEndIdx - current - 8;
|
+ if (matchEndIdx > curr + 8) return matchEndIdx - curr - 8;
|
||||||
+ return 1;
|
+ return 1;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -3230,16 +3128,16 @@ index 0000000..79c3207
|
|||||||
+ const U32 dictLimit = zc->dictLimit;
|
+ const U32 dictLimit = zc->dictLimit;
|
||||||
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
||||||
+ const BYTE* const prefixStart = base + dictLimit;
|
+ const BYTE* const prefixStart = base + dictLimit;
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 btLow = btMask >= current ? 0 : current - btMask;
|
+ const U32 btLow = btMask >= curr ? 0 : curr - btMask;
|
||||||
+ const U32 windowLow = zc->lowLimit;
|
+ const U32 windowLow = zc->lowLimit;
|
||||||
+ U32* smallerPtr = bt + 2*(current&btMask);
|
+ U32* smallerPtr = bt + 2*(curr&btMask);
|
||||||
+ U32* largerPtr = bt + 2*(current&btMask) + 1;
|
+ U32* largerPtr = bt + 2*(curr&btMask) + 1;
|
||||||
+ U32 matchEndIdx = current+8;
|
+ U32 matchEndIdx = curr+8;
|
||||||
+ U32 dummy32; /* to be nullified at the end */
|
+ U32 dummy32; /* to be nullified at the end */
|
||||||
+ size_t bestLength = 0;
|
+ size_t bestLength = 0;
|
||||||
+
|
+
|
||||||
+ hashTable[h] = current; /* Update Hash Table */
|
+ hashTable[h] = curr; /* Update Hash Table */
|
||||||
+
|
+
|
||||||
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
||||||
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
|
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
|
||||||
@ -3260,21 +3158,21 @@ index 0000000..79c3207
|
|||||||
+ if (matchLength > bestLength) {
|
+ if (matchLength > bestLength) {
|
||||||
+ if (matchLength > matchEndIdx - matchIndex)
|
+ if (matchLength > matchEndIdx - matchIndex)
|
||||||
+ matchEndIdx = matchIndex + (U32)matchLength;
|
+ matchEndIdx = matchIndex + (U32)matchLength;
|
||||||
+ if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(current-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) )
|
+ if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(curr-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) )
|
||||||
+ bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + current - matchIndex;
|
+ bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + curr - matchIndex;
|
||||||
+ if (ip+matchLength == iend) /* equal : no way to know if inf or sup */
|
+ if (ip+matchLength == iend) /* equal : no way to know if inf or sup */
|
||||||
+ break; /* drop, to guarantee consistency (miss a little bit of compression) */
|
+ break; /* drop, to guarantee consistency (miss a little bit of compression) */
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (match[matchLength] < ip[matchLength]) {
|
+ if (match[matchLength] < ip[matchLength]) {
|
||||||
+ /* match is smaller than current */
|
+ /* match is smaller than curr */
|
||||||
+ *smallerPtr = matchIndex; /* update smaller idx */
|
+ *smallerPtr = matchIndex; /* update smaller idx */
|
||||||
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
||||||
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
||||||
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
|
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to curr) */
|
||||||
+ } else {
|
+ } else {
|
||||||
+ /* match is larger than current */
|
+ /* match is larger than curr */
|
||||||
+ *largerPtr = matchIndex;
|
+ *largerPtr = matchIndex;
|
||||||
+ commonLengthLarger = matchLength;
|
+ commonLengthLarger = matchLength;
|
||||||
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
@ -3284,7 +3182,7 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ *smallerPtr = *largerPtr = 0;
|
+ *smallerPtr = *largerPtr = 0;
|
||||||
+
|
+
|
||||||
+ zc->nextToUpdate = (matchEndIdx > current + 8) ? matchEndIdx - 8 : current+1;
|
+ zc->nextToUpdate = (matchEndIdx > curr + 8) ? matchEndIdx - 8 : curr+1;
|
||||||
+ return bestLength;
|
+ return bestLength;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -3417,8 +3315,8 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* const prefixStart = base + dictLimit;
|
+ const BYTE* const prefixStart = base + dictLimit;
|
||||||
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
||||||
+ const U32 lowLimit = zc->lowLimit;
|
+ const U32 lowLimit = zc->lowLimit;
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 minChain = current > chainSize ? current - chainSize : 0;
|
+ const U32 minChain = curr > chainSize ? curr - chainSize : 0;
|
||||||
+ int nbAttempts=maxNbAttempts;
|
+ int nbAttempts=maxNbAttempts;
|
||||||
+ size_t ml=EQUAL_READ32-1;
|
+ size_t ml=EQUAL_READ32-1;
|
||||||
+
|
+
|
||||||
@ -3427,19 +3325,19 @@ index 0000000..79c3207
|
|||||||
+
|
+
|
||||||
+ for ( ; (matchIndex>lowLimit) & (nbAttempts>0) ; nbAttempts--) {
|
+ for ( ; (matchIndex>lowLimit) & (nbAttempts>0) ; nbAttempts--) {
|
||||||
+ const BYTE* match;
|
+ const BYTE* match;
|
||||||
+ size_t currentMl=0;
|
+ size_t currMl=0;
|
||||||
+ if ((!extDict) || matchIndex >= dictLimit) {
|
+ if ((!extDict) || matchIndex >= dictLimit) {
|
||||||
+ match = base + matchIndex;
|
+ match = base + matchIndex;
|
||||||
+ if (match[ml] == ip[ml]) /* potentially better */
|
+ if (match[ml] == ip[ml]) /* potentially better */
|
||||||
+ currentMl = ZSTD_count(ip, match, iLimit);
|
+ currMl = ZSTD_count(ip, match, iLimit);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ match = dictBase + matchIndex;
|
+ match = dictBase + matchIndex;
|
||||||
+ if (MEM_read32(match) == MEM_read32(ip)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
+ if (MEM_read32(match) == MEM_read32(ip)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
||||||
+ currentMl = ZSTD_count_2segments(ip+EQUAL_READ32, match+EQUAL_READ32, iLimit, dictEnd, prefixStart) + EQUAL_READ32;
|
+ currMl = ZSTD_count_2segments(ip+EQUAL_READ32, match+EQUAL_READ32, iLimit, dictEnd, prefixStart) + EQUAL_READ32;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* save best solution */
|
+ /* save best solution */
|
||||||
+ if (currentMl > ml) { ml = currentMl; *offsetPtr = current - matchIndex + ZSTD_REP_MOVE; if (ip+currentMl == iLimit) break; /* best possible, and avoid read overflow*/ }
|
+ if (currMl > ml) { ml = currMl; *offsetPtr = curr - matchIndex + ZSTD_REP_MOVE; if (ip+currMl == iLimit) break; /* best possible, and avoid read overflow*/ }
|
||||||
+
|
+
|
||||||
+ if (matchIndex <= minChain) break;
|
+ if (matchIndex <= minChain) break;
|
||||||
+ matchIndex = NEXT_IN_CHAIN(matchIndex, chainMask);
|
+ matchIndex = NEXT_IN_CHAIN(matchIndex, chainMask);
|
||||||
@ -3680,10 +3578,10 @@ index 0000000..79c3207
|
|||||||
+ size_t matchLength=0;
|
+ size_t matchLength=0;
|
||||||
+ size_t offset=0;
|
+ size_t offset=0;
|
||||||
+ const BYTE* start=ip+1;
|
+ const BYTE* start=ip+1;
|
||||||
+ U32 current = (U32)(ip-base);
|
+ U32 curr = (U32)(ip-base);
|
||||||
+
|
+
|
||||||
+ /* check repCode */
|
+ /* check repCode */
|
||||||
+ { const U32 repIndex = (U32)(current+1 - offset_1);
|
+ { const U32 repIndex = (U32)(curr+1 - offset_1);
|
||||||
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* const repMatch = repBase + repIndex;
|
+ const BYTE* const repMatch = repBase + repIndex;
|
||||||
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
||||||
@ -3710,10 +3608,10 @@ index 0000000..79c3207
|
|||||||
+ if (depth>=1)
|
+ if (depth>=1)
|
||||||
+ while (ip<ilimit) {
|
+ while (ip<ilimit) {
|
||||||
+ ip ++;
|
+ ip ++;
|
||||||
+ current++;
|
+ curr++;
|
||||||
+ /* check repCode */
|
+ /* check repCode */
|
||||||
+ if (offset) {
|
+ if (offset) {
|
||||||
+ const U32 repIndex = (U32)(current - offset_1);
|
+ const U32 repIndex = (U32)(curr - offset_1);
|
||||||
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* const repMatch = repBase + repIndex;
|
+ const BYTE* const repMatch = repBase + repIndex;
|
||||||
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
||||||
@ -3740,10 +3638,10 @@ index 0000000..79c3207
|
|||||||
+ /* let's find an even better one */
|
+ /* let's find an even better one */
|
||||||
+ if ((depth==2) && (ip<ilimit)) {
|
+ if ((depth==2) && (ip<ilimit)) {
|
||||||
+ ip ++;
|
+ ip ++;
|
||||||
+ current++;
|
+ curr++;
|
||||||
+ /* check repCode */
|
+ /* check repCode */
|
||||||
+ if (offset) {
|
+ if (offset) {
|
||||||
+ const U32 repIndex = (U32)(current - offset_1);
|
+ const U32 repIndex = (U32)(curr - offset_1);
|
||||||
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* const repMatch = repBase + repIndex;
|
+ const BYTE* const repMatch = repBase + repIndex;
|
||||||
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
|
||||||
@ -3898,11 +3796,11 @@ index 0000000..79c3207
|
|||||||
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->params.cParams.strategy, zc->lowLimit < zc->dictLimit);
|
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->params.cParams.strategy, zc->lowLimit < zc->dictLimit);
|
||||||
+ const BYTE* const base = zc->base;
|
+ const BYTE* const base = zc->base;
|
||||||
+ const BYTE* const istart = (const BYTE*)src;
|
+ const BYTE* const istart = (const BYTE*)src;
|
||||||
+ const U32 current = (U32)(istart-base);
|
+ const U32 curr = (U32)(istart-base);
|
||||||
+ if (srcSize < MIN_CBLOCK_SIZE+ZSTD_blockHeaderSize+1) return 0; /* don't even attempt compression below a certain srcSize */
|
+ if (srcSize < MIN_CBLOCK_SIZE+ZSTD_blockHeaderSize+1) return 0; /* don't even attempt compression below a certain srcSize */
|
||||||
+ ZSTD_resetSeqStore(&(zc->seqStore));
|
+ ZSTD_resetSeqStore(&(zc->seqStore));
|
||||||
+ if (current > zc->nextToUpdate + 384)
|
+ if (curr > zc->nextToUpdate + 384)
|
||||||
+ zc->nextToUpdate = current - MIN(192, (U32)(current - zc->nextToUpdate - 384)); /* update tree not updated after finding very long rep matches */
|
+ zc->nextToUpdate = curr - MIN(192, (U32)(curr - zc->nextToUpdate - 384)); /* update tree not updated after finding very long rep matches */
|
||||||
+ blockCompressor(zc, src, srcSize);
|
+ blockCompressor(zc, src, srcSize);
|
||||||
+ return ZSTD_compressSequences(zc, dst, dstCapacity, srcSize);
|
+ return ZSTD_compressSequences(zc, dst, dstCapacity, srcSize);
|
||||||
+}
|
+}
|
||||||
@ -3940,9 +3838,9 @@ index 0000000..79c3207
|
|||||||
+ /* preemptive overflow correction */
|
+ /* preemptive overflow correction */
|
||||||
+ if (cctx->lowLimit > (3U<<29)) {
|
+ if (cctx->lowLimit > (3U<<29)) {
|
||||||
+ U32 const cycleMask = (1 << ZSTD_cycleLog(cctx->params.cParams.hashLog, cctx->params.cParams.strategy)) - 1;
|
+ U32 const cycleMask = (1 << ZSTD_cycleLog(cctx->params.cParams.hashLog, cctx->params.cParams.strategy)) - 1;
|
||||||
+ U32 const current = (U32)(ip - cctx->base);
|
+ U32 const curr = (U32)(ip - cctx->base);
|
||||||
+ U32 const newCurrent = (current & cycleMask) + (1 << cctx->params.cParams.windowLog);
|
+ U32 const newCurr = (curr & cycleMask) + (1 << cctx->params.cParams.windowLog);
|
||||||
+ U32 const correction = current - newCurrent;
|
+ U32 const correction = curr - newCurr;
|
||||||
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_64 <= 30);
|
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_64 <= 30);
|
||||||
+ ZSTD_reduceIndex(cctx, correction);
|
+ ZSTD_reduceIndex(cctx, correction);
|
||||||
+ cctx->base += correction;
|
+ cctx->base += correction;
|
||||||
@ -4103,7 +4001,7 @@ index 0000000..79c3207
|
|||||||
+ const BYTE* const ip = (const BYTE*) src;
|
+ const BYTE* const ip = (const BYTE*) src;
|
||||||
+ const BYTE* const iend = ip + srcSize;
|
+ const BYTE* const iend = ip + srcSize;
|
||||||
+
|
+
|
||||||
+ /* input becomes current prefix */
|
+ /* input becomes curr prefix */
|
||||||
+ zc->lowLimit = zc->dictLimit;
|
+ zc->lowLimit = zc->dictLimit;
|
||||||
+ zc->dictLimit = (U32)(zc->nextSrc - zc->base);
|
+ zc->dictLimit = (U32)(zc->nextSrc - zc->base);
|
||||||
+ zc->dictBase = zc->base;
|
+ zc->dictBase = zc->base;
|
||||||
@ -4678,7 +4576,7 @@ index 0000000..79c3207
|
|||||||
+ if ( (zcs->inBuffPos==zcs->inToCompress) || (!flush && (toLoad != loaded)) ) {
|
+ if ( (zcs->inBuffPos==zcs->inToCompress) || (!flush && (toLoad != loaded)) ) {
|
||||||
+ someMoreWork = 0; break; /* not enough input to get a full block : stop there, wait for more */
|
+ someMoreWork = 0; break; /* not enough input to get a full block : stop there, wait for more */
|
||||||
+ } }
|
+ } }
|
||||||
+ /* compress current block (note : this stage cannot be stopped in the middle) */
|
+ /* compress curr block (note : this stage cannot be stopped in the middle) */
|
||||||
+ { void* cDst;
|
+ { void* cDst;
|
||||||
+ size_t cSize;
|
+ size_t cSize;
|
||||||
+ size_t const iSize = zcs->inBuffPos - zcs->inToCompress;
|
+ size_t const iSize = zcs->inBuffPos - zcs->inToCompress;
|
||||||
@ -4990,10 +4888,10 @@ index 0000000..79c3207
|
|||||||
+MODULE_DESCRIPTION("Zstd Compressor");
|
+MODULE_DESCRIPTION("Zstd Compressor");
|
||||||
diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
|
diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..98508b1
|
index 0000000..378d2c5
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/decompress.c
|
+++ b/lib/zstd/decompress.c
|
||||||
@@ -0,0 +1,2377 @@
|
@@ -0,0 +1,2349 @@
|
||||||
+/**
|
+/**
|
||||||
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
+ * All rights reserved.
|
+ * All rights reserved.
|
||||||
@ -5068,8 +4966,8 @@ index 0000000..98508b1
|
|||||||
+ const HUF_DTable* HUFptr;
|
+ const HUF_DTable* HUFptr;
|
||||||
+ ZSTD_entropyTables_t entropy;
|
+ ZSTD_entropyTables_t entropy;
|
||||||
+ const void* previousDstEnd; /* detect continuity */
|
+ const void* previousDstEnd; /* detect continuity */
|
||||||
+ const void* base; /* start of current segment */
|
+ const void* base; /* start of curr segment */
|
||||||
+ const void* vBase; /* virtual start of previous segment if it was just before current one */
|
+ const void* vBase; /* virtual start of previous segment if it was just before curr one */
|
||||||
+ const void* dictEnd; /* end of previous segment */
|
+ const void* dictEnd; /* end of previous segment */
|
||||||
+ size_t expected;
|
+ size_t expected;
|
||||||
+ ZSTD_frameParams fParams;
|
+ ZSTD_frameParams fParams;
|
||||||
@ -5145,30 +5043,6 @@ index 0000000..98508b1
|
|||||||
+ memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */
|
+ memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+#if 0
|
|
||||||
+/* deprecated */
|
|
||||||
+static void ZSTD_refDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
|
|
||||||
+{
|
|
||||||
+ ZSTD_decompressBegin(dstDCtx); /* init */
|
|
||||||
+ if (srcDCtx) { /* support refDCtx on NULL */
|
|
||||||
+ dstDCtx->dictEnd = srcDCtx->dictEnd;
|
|
||||||
+ dstDCtx->vBase = srcDCtx->vBase;
|
|
||||||
+ dstDCtx->base = srcDCtx->base;
|
|
||||||
+ dstDCtx->previousDstEnd = srcDCtx->previousDstEnd;
|
|
||||||
+ dstDCtx->dictID = srcDCtx->dictID;
|
|
||||||
+ dstDCtx->litEntropy = srcDCtx->litEntropy;
|
|
||||||
+ dstDCtx->fseEntropy = srcDCtx->fseEntropy;
|
|
||||||
+ dstDCtx->LLTptr = srcDCtx->entropy.LLTable;
|
|
||||||
+ dstDCtx->MLTptr = srcDCtx->entropy.MLTable;
|
|
||||||
+ dstDCtx->OFTptr = srcDCtx->entropy.OFTable;
|
|
||||||
+ dstDCtx->HUFptr = srcDCtx->entropy.hufTable;
|
|
||||||
+ dstDCtx->entropy.rep[0] = srcDCtx->entropy.rep[0];
|
|
||||||
+ dstDCtx->entropy.rep[1] = srcDCtx->entropy.rep[1];
|
|
||||||
+ dstDCtx->entropy.rep[2] = srcDCtx->entropy.rep[2];
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict);
|
+static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict);
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
@ -5860,7 +5734,7 @@ index 0000000..98508b1
|
|||||||
+ memmove(oLitEnd, match, sequence.matchLength);
|
+ memmove(oLitEnd, match, sequence.matchLength);
|
||||||
+ return sequenceLength;
|
+ return sequenceLength;
|
||||||
+ }
|
+ }
|
||||||
+ /* span extDict & currentPrefixSegment */
|
+ /* span extDict & currPrefixSegment */
|
||||||
+ { size_t const length1 = dictEnd - match;
|
+ { size_t const length1 = dictEnd - match;
|
||||||
+ memmove(oLitEnd, match, length1);
|
+ memmove(oLitEnd, match, length1);
|
||||||
+ op = oLitEnd + length1;
|
+ op = oLitEnd + length1;
|
||||||
@ -5983,7 +5857,7 @@ index 0000000..98508b1
|
|||||||
+ memmove(oLitEnd, match, sequence.matchLength);
|
+ memmove(oLitEnd, match, sequence.matchLength);
|
||||||
+ return sequenceLength;
|
+ return sequenceLength;
|
||||||
+ }
|
+ }
|
||||||
+ /* span extDict & currentPrefixSegment */
|
+ /* span extDict & currPrefixSegment */
|
||||||
+ { size_t const length1 = dictEnd - match;
|
+ { size_t const length1 = dictEnd - match;
|
||||||
+ memmove(oLitEnd, match, length1);
|
+ memmove(oLitEnd, match, length1);
|
||||||
+ op = oLitEnd + length1;
|
+ op = oLitEnd + length1;
|
||||||
@ -6196,11 +6070,9 @@ index 0000000..98508b1
|
|||||||
+ const BYTE* match = sequence.match;
|
+ const BYTE* match = sequence.match;
|
||||||
+
|
+
|
||||||
+ /* check */
|
+ /* check */
|
||||||
+#if 1
|
|
||||||
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
|
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
|
||||||
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
|
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
|
||||||
+ if (oLitEnd>oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, base, vBase, dictEnd);
|
+ if (oLitEnd>oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, base, vBase, dictEnd);
|
||||||
+#endif
|
|
||||||
+
|
+
|
||||||
+ /* copy Literals */
|
+ /* copy Literals */
|
||||||
+ ZSTD_copy8(op, *litPtr);
|
+ ZSTD_copy8(op, *litPtr);
|
||||||
@ -6210,7 +6082,6 @@ index 0000000..98508b1
|
|||||||
+ *litPtr = iLitEnd; /* update for next sequence */
|
+ *litPtr = iLitEnd; /* update for next sequence */
|
||||||
+
|
+
|
||||||
+ /* copy Match */
|
+ /* copy Match */
|
||||||
+#if 1
|
|
||||||
+ if (sequence.offset > (size_t)(oLitEnd - base)) {
|
+ if (sequence.offset > (size_t)(oLitEnd - base)) {
|
||||||
+ /* offset beyond prefix */
|
+ /* offset beyond prefix */
|
||||||
+ if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
|
+ if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
|
||||||
@ -6218,7 +6089,7 @@ index 0000000..98508b1
|
|||||||
+ memmove(oLitEnd, match, sequence.matchLength);
|
+ memmove(oLitEnd, match, sequence.matchLength);
|
||||||
+ return sequenceLength;
|
+ return sequenceLength;
|
||||||
+ }
|
+ }
|
||||||
+ /* span extDict & currentPrefixSegment */
|
+ /* span extDict & currPrefixSegment */
|
||||||
+ { size_t const length1 = dictEnd - match;
|
+ { size_t const length1 = dictEnd - match;
|
||||||
+ memmove(oLitEnd, match, length1);
|
+ memmove(oLitEnd, match, length1);
|
||||||
+ op = oLitEnd + length1;
|
+ op = oLitEnd + length1;
|
||||||
@ -6231,7 +6102,6 @@ index 0000000..98508b1
|
|||||||
+ }
|
+ }
|
||||||
+ } }
|
+ } }
|
||||||
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
|
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
|
||||||
+#endif
|
|
||||||
+
|
+
|
||||||
+ /* match within prefix */
|
+ /* match within prefix */
|
||||||
+ if (sequence.offset < 8) {
|
+ if (sequence.offset < 8) {
|
||||||
@ -7373,7 +7243,7 @@ index 0000000..98508b1
|
|||||||
+MODULE_DESCRIPTION("Zstd Decompressor");
|
+MODULE_DESCRIPTION("Zstd Decompressor");
|
||||||
diff --git a/lib/zstd/entropy_common.c b/lib/zstd/entropy_common.c
|
diff --git a/lib/zstd/entropy_common.c b/lib/zstd/entropy_common.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..68d88082
|
index 0000000..36ad266
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/entropy_common.c
|
+++ b/lib/zstd/entropy_common.c
|
||||||
@@ -0,0 +1,217 @@
|
@@ -0,0 +1,217 @@
|
||||||
@ -7646,7 +7516,7 @@ index 0000000..8cf148b
|
|||||||
+#endif /* ERROR_H_MODULE */
|
+#endif /* ERROR_H_MODULE */
|
||||||
diff --git a/lib/zstd/fse.h b/lib/zstd/fse.h
|
diff --git a/lib/zstd/fse.h b/lib/zstd/fse.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..14fa439
|
index 0000000..6a78957
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/fse.h
|
+++ b/lib/zstd/fse.h
|
||||||
@@ -0,0 +1,606 @@
|
@@ -0,0 +1,606 @@
|
||||||
@ -8258,10 +8128,10 @@ index 0000000..14fa439
|
|||||||
+#endif /* FSE_H */
|
+#endif /* FSE_H */
|
||||||
diff --git a/lib/zstd/fse_compress.c b/lib/zstd/fse_compress.c
|
diff --git a/lib/zstd/fse_compress.c b/lib/zstd/fse_compress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..b6a6d46
|
index 0000000..d0b5673
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/fse_compress.c
|
+++ b/lib/zstd/fse_compress.c
|
||||||
@@ -0,0 +1,788 @@
|
@@ -0,0 +1,774 @@
|
||||||
+/* ******************************************************************
|
+/* ******************************************************************
|
||||||
+ FSE : Finite State Entropy encoder
|
+ FSE : Finite State Entropy encoder
|
||||||
+ Copyright (C) 2013-2015, Yann Collet.
|
+ Copyright (C) 2013-2015, Yann Collet.
|
||||||
@ -8845,20 +8715,6 @@ index 0000000..b6a6d46
|
|||||||
+ else normalizedCounter[largest] += (short)stillToDistribute;
|
+ else normalizedCounter[largest] += (short)stillToDistribute;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+#if 0
|
|
||||||
+ { /* Print Table (debug) */
|
|
||||||
+ U32 s;
|
|
||||||
+ U32 nTotal = 0;
|
|
||||||
+ for (s=0; s<=maxSymbolValue; s++)
|
|
||||||
+ printf("%3i: %4i \n", s, normalizedCounter[s]);
|
|
||||||
+ for (s=0; s<=maxSymbolValue; s++)
|
|
||||||
+ nTotal += abs(normalizedCounter[s]);
|
|
||||||
+ if (nTotal != (1U<<tableLog))
|
|
||||||
+ printf("Warning !!! Total == %u != %u !!!", nTotal, 1U<<tableLog);
|
|
||||||
+ getchar();
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ return tableLog;
|
+ return tableLog;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -9052,7 +8908,7 @@ index 0000000..b6a6d46
|
|||||||
+#endif /* FSE_COMMONDEFS_ONLY */
|
+#endif /* FSE_COMMONDEFS_ONLY */
|
||||||
diff --git a/lib/zstd/fse_decompress.c b/lib/zstd/fse_decompress.c
|
diff --git a/lib/zstd/fse_decompress.c b/lib/zstd/fse_decompress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..2a35f17
|
index 0000000..6de5411
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/fse_decompress.c
|
+++ b/lib/zstd/fse_decompress.c
|
||||||
@@ -0,0 +1,292 @@
|
@@ -0,0 +1,292 @@
|
||||||
@ -9559,7 +9415,7 @@ index 0000000..f36aded
|
|||||||
+#endif /* HUF_H_298734234 */
|
+#endif /* HUF_H_298734234 */
|
||||||
diff --git a/lib/zstd/huf_compress.c b/lib/zstd/huf_compress.c
|
diff --git a/lib/zstd/huf_compress.c b/lib/zstd/huf_compress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..a1a1d45
|
index 0000000..41b9ce0
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/huf_compress.c
|
+++ b/lib/zstd/huf_compress.c
|
||||||
@@ -0,0 +1,644 @@
|
@@ -0,0 +1,644 @@
|
||||||
@ -9737,9 +9593,9 @@ index 0000000..a1a1d45
|
|||||||
+ /* Prepare base value per rank */
|
+ /* Prepare base value per rank */
|
||||||
+ { U32 n, nextRankStart = 0;
|
+ { U32 n, nextRankStart = 0;
|
||||||
+ for (n=1; n<=tableLog; n++) {
|
+ for (n=1; n<=tableLog; n++) {
|
||||||
+ U32 current = nextRankStart;
|
+ U32 curr = nextRankStart;
|
||||||
+ nextRankStart += (rankVal[n] << (n-1));
|
+ nextRankStart += (rankVal[n] << (n-1));
|
||||||
+ rankVal[n] = current;
|
+ rankVal[n] = curr;
|
||||||
+ } }
|
+ } }
|
||||||
+
|
+
|
||||||
+ /* fill nbBits */
|
+ /* fill nbBits */
|
||||||
@ -9802,11 +9658,11 @@ index 0000000..a1a1d45
|
|||||||
+
|
+
|
||||||
+ /* Get pos of last (smallest) symbol per rank */
|
+ /* Get pos of last (smallest) symbol per rank */
|
||||||
+ memset(rankLast, 0xF0, sizeof(rankLast));
|
+ memset(rankLast, 0xF0, sizeof(rankLast));
|
||||||
+ { U32 currentNbBits = maxNbBits;
|
+ { U32 currNbBits = maxNbBits;
|
||||||
+ for (pos=n ; pos >= 0; pos--) {
|
+ for (pos=n ; pos >= 0; pos--) {
|
||||||
+ if (huffNode[pos].nbBits >= currentNbBits) continue;
|
+ if (huffNode[pos].nbBits >= currNbBits) continue;
|
||||||
+ currentNbBits = huffNode[pos].nbBits; /* < maxNbBits */
|
+ currNbBits = huffNode[pos].nbBits; /* < maxNbBits */
|
||||||
+ rankLast[maxNbBits-currentNbBits] = pos;
|
+ rankLast[maxNbBits-currNbBits] = pos;
|
||||||
+ } }
|
+ } }
|
||||||
+
|
+
|
||||||
+ while (totalCost > 0) {
|
+ while (totalCost > 0) {
|
||||||
@ -9854,7 +9710,7 @@ index 0000000..a1a1d45
|
|||||||
+
|
+
|
||||||
+typedef struct {
|
+typedef struct {
|
||||||
+ U32 base;
|
+ U32 base;
|
||||||
+ U32 current;
|
+ U32 curr;
|
||||||
+} rankPos;
|
+} rankPos;
|
||||||
+
|
+
|
||||||
+static void HUF_sort(nodeElt* huffNode, const U32* count, U32 maxSymbolValue)
|
+static void HUF_sort(nodeElt* huffNode, const U32* count, U32 maxSymbolValue)
|
||||||
@ -9868,11 +9724,11 @@ index 0000000..a1a1d45
|
|||||||
+ rank[r].base ++;
|
+ rank[r].base ++;
|
||||||
+ }
|
+ }
|
||||||
+ for (n=30; n>0; n--) rank[n-1].base += rank[n].base;
|
+ for (n=30; n>0; n--) rank[n-1].base += rank[n].base;
|
||||||
+ for (n=0; n<32; n++) rank[n].current = rank[n].base;
|
+ for (n=0; n<32; n++) rank[n].curr = rank[n].base;
|
||||||
+ for (n=0; n<=maxSymbolValue; n++) {
|
+ for (n=0; n<=maxSymbolValue; n++) {
|
||||||
+ U32 const c = count[n];
|
+ U32 const c = count[n];
|
||||||
+ U32 const r = BIT_highbit32(c+1) + 1;
|
+ U32 const r = BIT_highbit32(c+1) + 1;
|
||||||
+ U32 pos = rank[r].current++;
|
+ U32 pos = rank[r].curr++;
|
||||||
+ while ((pos > rank[r].base) && (c > huffNode[pos-1].count)) huffNode[pos]=huffNode[pos-1], pos--;
|
+ while ((pos > rank[r].base) && (c > huffNode[pos-1].count)) huffNode[pos]=huffNode[pos-1], pos--;
|
||||||
+ huffNode[pos].count = c;
|
+ huffNode[pos].count = c;
|
||||||
+ huffNode[pos].byte = (BYTE)n;
|
+ huffNode[pos].byte = (BYTE)n;
|
||||||
@ -10114,7 +9970,7 @@ index 0000000..a1a1d45
|
|||||||
+ if (wkspSize < sizeof(huffNodeTable) + countSize + CTableSize) return ERROR(GENERIC);
|
+ if (wkspSize < sizeof(huffNodeTable) + countSize + CTableSize) return ERROR(GENERIC);
|
||||||
+ if (!srcSize) return 0; /* Uncompressed (note : 1 means rle, so first byte must be correct) */
|
+ if (!srcSize) return 0; /* Uncompressed (note : 1 means rle, so first byte must be correct) */
|
||||||
+ if (!dstSize) return 0; /* cannot fit within dst budget */
|
+ if (!dstSize) return 0; /* cannot fit within dst budget */
|
||||||
+ if (srcSize > HUF_BLOCKSIZE_MAX) return ERROR(srcSize_wrong); /* current block size limit */
|
+ if (srcSize > HUF_BLOCKSIZE_MAX) return ERROR(srcSize_wrong); /* curr block size limit */
|
||||||
+ if (huffLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
|
+ if (huffLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
|
||||||
+ if (!maxSymbolValue) maxSymbolValue = HUF_SYMBOLVALUE_MAX;
|
+ if (!maxSymbolValue) maxSymbolValue = HUF_SYMBOLVALUE_MAX;
|
||||||
+ if (!huffLog) huffLog = HUF_TABLELOG_DEFAULT;
|
+ if (!huffLog) huffLog = HUF_TABLELOG_DEFAULT;
|
||||||
@ -10209,7 +10065,7 @@ index 0000000..a1a1d45
|
|||||||
+}
|
+}
|
||||||
diff --git a/lib/zstd/huf_decompress.c b/lib/zstd/huf_decompress.c
|
diff --git a/lib/zstd/huf_decompress.c b/lib/zstd/huf_decompress.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..f73223c
|
index 0000000..2d9b33b
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/huf_decompress.c
|
+++ b/lib/zstd/huf_decompress.c
|
||||||
@@ -0,0 +1,835 @@
|
@@ -0,0 +1,835 @@
|
||||||
@ -10316,9 +10172,9 @@ index 0000000..f73223c
|
|||||||
+ /* Calculate starting value for each rank */
|
+ /* Calculate starting value for each rank */
|
||||||
+ { U32 n, nextRankStart = 0;
|
+ { U32 n, nextRankStart = 0;
|
||||||
+ for (n=1; n<tableLog+1; n++) {
|
+ for (n=1; n<tableLog+1; n++) {
|
||||||
+ U32 const current = nextRankStart;
|
+ U32 const curr = nextRankStart;
|
||||||
+ nextRankStart += (rankVal[n] << (n-1));
|
+ nextRankStart += (rankVal[n] << (n-1));
|
||||||
+ rankVal[n] = current;
|
+ rankVal[n] = curr;
|
||||||
+ } }
|
+ } }
|
||||||
+
|
+
|
||||||
+ /* fill DTable */
|
+ /* fill DTable */
|
||||||
@ -10667,9 +10523,9 @@ index 0000000..f73223c
|
|||||||
+ /* Get start index of each weight */
|
+ /* Get start index of each weight */
|
||||||
+ { U32 w, nextRankStart = 0;
|
+ { U32 w, nextRankStart = 0;
|
||||||
+ for (w=1; w<maxW+1; w++) {
|
+ for (w=1; w<maxW+1; w++) {
|
||||||
+ U32 current = nextRankStart;
|
+ U32 curr = nextRankStart;
|
||||||
+ nextRankStart += rankStats[w];
|
+ nextRankStart += rankStats[w];
|
||||||
+ rankStart[w] = current;
|
+ rankStart[w] = curr;
|
||||||
+ }
|
+ }
|
||||||
+ rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/
|
+ rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/
|
||||||
+ sizeOfSort = nextRankStart;
|
+ sizeOfSort = nextRankStart;
|
||||||
@ -10692,9 +10548,9 @@ index 0000000..f73223c
|
|||||||
+ U32 nextRankVal = 0;
|
+ U32 nextRankVal = 0;
|
||||||
+ U32 w;
|
+ U32 w;
|
||||||
+ for (w=1; w<maxW+1; w++) {
|
+ for (w=1; w<maxW+1; w++) {
|
||||||
+ U32 current = nextRankVal;
|
+ U32 curr = nextRankVal;
|
||||||
+ nextRankVal += rankStats[w] << (w+rescale);
|
+ nextRankVal += rankStats[w] << (w+rescale);
|
||||||
+ rankVal0[w] = current;
|
+ rankVal0[w] = curr;
|
||||||
+ } }
|
+ } }
|
||||||
+ { U32 const minBits = tableLog+1 - maxW;
|
+ { U32 const minBits = tableLog+1 - maxW;
|
||||||
+ U32 consumed;
|
+ U32 consumed;
|
||||||
@ -11340,10 +11196,10 @@ index 0000000..106f540
|
|||||||
+}
|
+}
|
||||||
diff --git a/lib/zstd/zstd_internal.h b/lib/zstd/zstd_internal.h
|
diff --git a/lib/zstd/zstd_internal.h b/lib/zstd/zstd_internal.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..a61bd27
|
index 0000000..5ed5419
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/zstd_internal.h
|
+++ b/lib/zstd/zstd_internal.h
|
||||||
@@ -0,0 +1,274 @@
|
@@ -0,0 +1,261 @@
|
||||||
+/**
|
+/**
|
||||||
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
+ * All rights reserved.
|
+ * All rights reserved.
|
||||||
@ -11584,20 +11440,7 @@ index 0000000..a61bd27
|
|||||||
+
|
+
|
||||||
+MEM_STATIC U32 ZSTD_highbit32(U32 val)
|
+MEM_STATIC U32 ZSTD_highbit32(U32 val)
|
||||||
+{
|
+{
|
||||||
+# if defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
|
|
||||||
+ return 31 - __builtin_clz(val);
|
+ return 31 - __builtin_clz(val);
|
||||||
+# else /* Software version */
|
|
||||||
+ static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
|
|
||||||
+ U32 v = val;
|
|
||||||
+ int r;
|
|
||||||
+ v |= v >> 1;
|
|
||||||
+ v |= v >> 2;
|
|
||||||
+ v |= v >> 4;
|
|
||||||
+ v |= v >> 8;
|
|
||||||
+ v |= v >> 16;
|
|
||||||
+ r = DeBruijnClz[(U32)(v * 0x07C4ACDDU) >> 27];
|
|
||||||
+ return r;
|
|
||||||
+# endif
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
@ -11620,7 +11463,7 @@ index 0000000..a61bd27
|
|||||||
+#endif /* ZSTD_CCOMMON_H_MODULE */
|
+#endif /* ZSTD_CCOMMON_H_MODULE */
|
||||||
diff --git a/lib/zstd/zstd_opt.h b/lib/zstd/zstd_opt.h
|
diff --git a/lib/zstd/zstd_opt.h b/lib/zstd/zstd_opt.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..297a715
|
index 0000000..9bd5303
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/zstd/zstd_opt.h
|
+++ b/lib/zstd/zstd_opt.h
|
||||||
@@ -0,0 +1,921 @@
|
@@ -0,0 +1,921 @@
|
||||||
@ -11859,7 +11702,7 @@ index 0000000..297a715
|
|||||||
+ U32 extDict, ZSTD_match_t* matches, const U32 minMatchLen)
|
+ U32 extDict, ZSTD_match_t* matches, const U32 minMatchLen)
|
||||||
+{
|
+{
|
||||||
+ const BYTE* const base = zc->base;
|
+ const BYTE* const base = zc->base;
|
||||||
+ const U32 current = (U32)(ip-base);
|
+ const U32 curr = (U32)(ip-base);
|
||||||
+ const U32 hashLog = zc->params.cParams.hashLog;
|
+ const U32 hashLog = zc->params.cParams.hashLog;
|
||||||
+ const size_t h = ZSTD_hashPtr(ip, hashLog, mls);
|
+ const size_t h = ZSTD_hashPtr(ip, hashLog, mls);
|
||||||
+ U32* const hashTable = zc->hashTable;
|
+ U32* const hashTable = zc->hashTable;
|
||||||
@ -11872,11 +11715,11 @@ index 0000000..297a715
|
|||||||
+ const U32 dictLimit = zc->dictLimit;
|
+ const U32 dictLimit = zc->dictLimit;
|
||||||
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
+ const BYTE* const dictEnd = dictBase + dictLimit;
|
||||||
+ const BYTE* const prefixStart = base + dictLimit;
|
+ const BYTE* const prefixStart = base + dictLimit;
|
||||||
+ const U32 btLow = btMask >= current ? 0 : current - btMask;
|
+ const U32 btLow = btMask >= curr ? 0 : curr - btMask;
|
||||||
+ const U32 windowLow = zc->lowLimit;
|
+ const U32 windowLow = zc->lowLimit;
|
||||||
+ U32* smallerPtr = bt + 2*(current&btMask);
|
+ U32* smallerPtr = bt + 2*(curr&btMask);
|
||||||
+ U32* largerPtr = bt + 2*(current&btMask) + 1;
|
+ U32* largerPtr = bt + 2*(curr&btMask) + 1;
|
||||||
+ U32 matchEndIdx = current+8;
|
+ U32 matchEndIdx = curr+8;
|
||||||
+ U32 dummy32; /* to be nullified at the end */
|
+ U32 dummy32; /* to be nullified at the end */
|
||||||
+ U32 mnum = 0;
|
+ U32 mnum = 0;
|
||||||
+
|
+
|
||||||
@ -11885,31 +11728,31 @@ index 0000000..297a715
|
|||||||
+
|
+
|
||||||
+ if (minMatch == 3) { /* HC3 match finder */
|
+ if (minMatch == 3) { /* HC3 match finder */
|
||||||
+ U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
|
+ U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
|
||||||
+ if (matchIndex3>windowLow && (current - matchIndex3 < (1<<18))) {
|
+ if (matchIndex3>windowLow && (curr - matchIndex3 < (1<<18))) {
|
||||||
+ const BYTE* match;
|
+ const BYTE* match;
|
||||||
+ size_t currentMl=0;
|
+ size_t currMl=0;
|
||||||
+ if ((!extDict) || matchIndex3 >= dictLimit) {
|
+ if ((!extDict) || matchIndex3 >= dictLimit) {
|
||||||
+ match = base + matchIndex3;
|
+ match = base + matchIndex3;
|
||||||
+ if (match[bestLength] == ip[bestLength]) currentMl = ZSTD_count(ip, match, iLimit);
|
+ if (match[bestLength] == ip[bestLength]) currMl = ZSTD_count(ip, match, iLimit);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ match = dictBase + matchIndex3;
|
+ match = dictBase + matchIndex3;
|
||||||
+ if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
|
+ if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
|
||||||
+ currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
|
+ currMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /* save best solution */
|
+ /* save best solution */
|
||||||
+ if (currentMl > bestLength) {
|
+ if (currMl > bestLength) {
|
||||||
+ bestLength = currentMl;
|
+ bestLength = currMl;
|
||||||
+ matches[mnum].off = ZSTD_REP_MOVE_OPT + current - matchIndex3;
|
+ matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex3;
|
||||||
+ matches[mnum].len = (U32)currentMl;
|
+ matches[mnum].len = (U32)currMl;
|
||||||
+ mnum++;
|
+ mnum++;
|
||||||
+ if (currentMl > ZSTD_OPT_NUM) goto update;
|
+ if (currMl > ZSTD_OPT_NUM) goto update;
|
||||||
+ if (ip+currentMl == iLimit) goto update; /* best possible, and avoid read overflow*/
|
+ if (ip+currMl == iLimit) goto update; /* best possible, and avoid read overflow*/
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ hashTable[h] = current; /* Update Hash Table */
|
+ hashTable[h] = curr; /* Update Hash Table */
|
||||||
+
|
+
|
||||||
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
+ while (nbCompares-- && (matchIndex > windowLow)) {
|
||||||
+ U32* nextPtr = bt + 2*(matchIndex & btMask);
|
+ U32* nextPtr = bt + 2*(matchIndex & btMask);
|
||||||
@ -11931,7 +11774,7 @@ index 0000000..297a715
|
|||||||
+ if (matchLength > bestLength) {
|
+ if (matchLength > bestLength) {
|
||||||
+ if (matchLength > matchEndIdx - matchIndex) matchEndIdx = matchIndex + (U32)matchLength;
|
+ if (matchLength > matchEndIdx - matchIndex) matchEndIdx = matchIndex + (U32)matchLength;
|
||||||
+ bestLength = matchLength;
|
+ bestLength = matchLength;
|
||||||
+ matches[mnum].off = ZSTD_REP_MOVE_OPT + current - matchIndex;
|
+ matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex;
|
||||||
+ matches[mnum].len = (U32)matchLength;
|
+ matches[mnum].len = (U32)matchLength;
|
||||||
+ mnum++;
|
+ mnum++;
|
||||||
+ if (matchLength > ZSTD_OPT_NUM) break;
|
+ if (matchLength > ZSTD_OPT_NUM) break;
|
||||||
@ -11940,14 +11783,14 @@ index 0000000..297a715
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (match[matchLength] < ip[matchLength]) {
|
+ if (match[matchLength] < ip[matchLength]) {
|
||||||
+ /* match is smaller than current */
|
+ /* match is smaller than curr */
|
||||||
+ *smallerPtr = matchIndex; /* update smaller idx */
|
+ *smallerPtr = matchIndex; /* update smaller idx */
|
||||||
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
|
||||||
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
|
||||||
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
|
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to curr) */
|
||||||
+ } else {
|
+ } else {
|
||||||
+ /* match is larger than current */
|
+ /* match is larger than curr */
|
||||||
+ *largerPtr = matchIndex;
|
+ *largerPtr = matchIndex;
|
||||||
+ commonLengthLarger = matchLength;
|
+ commonLengthLarger = matchLength;
|
||||||
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
|
||||||
@ -11958,7 +11801,7 @@ index 0000000..297a715
|
|||||||
+ *smallerPtr = *largerPtr = 0;
|
+ *smallerPtr = *largerPtr = 0;
|
||||||
+
|
+
|
||||||
+update:
|
+update:
|
||||||
+ zc->nextToUpdate = (matchEndIdx > current + 8) ? matchEndIdx - 8 : current+1;
|
+ zc->nextToUpdate = (matchEndIdx > curr + 8) ? matchEndIdx - 8 : curr+1;
|
||||||
+ return mnum;
|
+ return mnum;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -12310,7 +12153,7 @@ index 0000000..297a715
|
|||||||
+ while (ip < ilimit) {
|
+ while (ip < ilimit) {
|
||||||
+ U32 cur, match_num, last_pos, litlen, price;
|
+ U32 cur, match_num, last_pos, litlen, price;
|
||||||
+ U32 u, mlen, best_mlen, best_off, litLength;
|
+ U32 u, mlen, best_mlen, best_off, litLength;
|
||||||
+ U32 current = (U32)(ip-base);
|
+ U32 curr = (U32)(ip-base);
|
||||||
+ memset(opt, 0, sizeof(ZSTD_optimal_t));
|
+ memset(opt, 0, sizeof(ZSTD_optimal_t));
|
||||||
+ last_pos = 0;
|
+ last_pos = 0;
|
||||||
+ opt[0].litlen = (U32)(ip - anchor);
|
+ opt[0].litlen = (U32)(ip - anchor);
|
||||||
@ -12319,10 +12162,10 @@ index 0000000..297a715
|
|||||||
+ { U32 i, last_i = ZSTD_REP_CHECK + (ip==anchor);
|
+ { U32 i, last_i = ZSTD_REP_CHECK + (ip==anchor);
|
||||||
+ for (i = (ip==anchor); i<last_i; i++) {
|
+ for (i = (ip==anchor); i<last_i; i++) {
|
||||||
+ const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i];
|
+ const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i];
|
||||||
+ const U32 repIndex = (U32)(current - repCur);
|
+ const U32 repIndex = (U32)(curr - repCur);
|
||||||
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* const repMatch = repBase + repIndex;
|
+ const BYTE* const repMatch = repBase + repIndex;
|
||||||
+ if ( (repCur > 0 && repCur <= (S32)current)
|
+ if ( (repCur > 0 && repCur <= (S32)curr)
|
||||||
+ && (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
|
+ && (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
|
||||||
+ && (MEM_readMINMATCH(ip, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
|
+ && (MEM_readMINMATCH(ip, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
|
||||||
+ /* repcode detected we should take it */
|
+ /* repcode detected we should take it */
|
||||||
@ -12415,10 +12258,10 @@ index 0000000..297a715
|
|||||||
+ { U32 i, last_i = ZSTD_REP_CHECK + (mlen != 1);
|
+ { U32 i, last_i = ZSTD_REP_CHECK + (mlen != 1);
|
||||||
+ for (i = (mlen != 1); i<last_i; i++) {
|
+ for (i = (mlen != 1); i<last_i; i++) {
|
||||||
+ const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i];
|
+ const S32 repCur = (i==ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i];
|
||||||
+ const U32 repIndex = (U32)(current+cur - repCur);
|
+ const U32 repIndex = (U32)(curr+cur - repCur);
|
||||||
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
+ const BYTE* const repMatch = repBase + repIndex;
|
+ const BYTE* const repMatch = repBase + repIndex;
|
||||||
+ if ( (repCur > 0 && repCur <= (S32)(current+cur))
|
+ if ( (repCur > 0 && repCur <= (S32)(curr+cur))
|
||||||
+ && (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
|
+ && (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex>lowestIndex)) /* intentional overflow */
|
||||||
+ && (MEM_readMINMATCH(inr, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
|
+ && (MEM_readMINMATCH(inr, minMatch) == MEM_readMINMATCH(repMatch, minMatch)) ) {
|
||||||
+ /* repcode detected */
|
+ /* repcode detected */
|
||||||
|
Loading…
Reference in New Issue
Block a user