Merge pull request #2965 from facebook/offbase

Converge sumtype (offset | repcode) numeric representation towards offBase
This commit is contained in:
Yann Collet
2022-01-24 15:47:42 -08:00
committed by GitHub
12 changed files with 275 additions and 218 deletions
+7 -7
View File
@@ -671,7 +671,7 @@ generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
: 0;
/* actual offset, code to send, and point to copy up to when shifting
* codes in the repeat offsets history */
U32 offset, offsetCode, repIndex;
U32 offset, offBase, repIndex;
/* bounds checks */
matchLen = (U32) MIN(matchLen, excessMatch + MIN_SEQ_LEN);
@@ -707,12 +707,12 @@ generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
}
}
}
offsetCode = STORE_OFFSET(offset);
offBase = OFFSET_TO_OFFBASE(offset);
repIndex = 2;
} else {
/* do a repeat offset */
U32 const randomRepIndex = RAND(seed) % 3;
offsetCode = STORE_REPCODE(randomRepIndex + 1); /* expects values between 1 & 3 */
offBase = REPCODE_TO_OFFBASE(randomRepIndex + 1); /* expects values between 1 & 3 */
if (literalLen > 0) {
offset = frame->stats.rep[randomRepIndex];
repIndex = randomRepIndex;
@@ -751,12 +751,12 @@ generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
DISPLAYLEVEL(7, " srcPos: %8u seqNb: %3u",
(unsigned)((BYTE*)srcPtr - (BYTE*)frame->srcStart), (unsigned)i);
DISPLAYLEVEL(6, "\n");
if (STORED_IS_REPCODE(offsetCode)) { /* expects sumtype numeric representation of ZSTD_storeSeq() */
if (OFFBASE_IS_REPCODE(offBase)) { /* expects sumtype numeric representation of ZSTD_storeSeq() */
DISPLAYLEVEL(7, " repeat offset: %d\n", (int)repIndex);
}
/* use libzstd sequence handling */
ZSTD_storeSeq(seqStore, literalLen, literals, literals + literalLen,
offsetCode, matchLen);
offBase, matchLen);
literalsSize -= literalLen;
excessMatch -= (matchLen - MIN_SEQ_LEN);
@@ -765,8 +765,8 @@ generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore,
memcpy(srcPtr, literals, literalsSize);
srcPtr += literalsSize;
DISPLAYLEVEL(6, " excess literals: %5u", (unsigned)literalsSize);
DISPLAYLEVEL(7, " srcPos: %8u", (unsigned)((BYTE*)srcPtr - (BYTE*)frame->srcStart));
DISPLAYLEVEL(6, " excess literals: %5u ", (unsigned)literalsSize);
DISPLAYLEVEL(7, "srcPos: %8u ", (unsigned)((BYTE*)srcPtr - (BYTE*)frame->srcStart));
DISPLAYLEVEL(6, "\n");
return numSequences;
+1 -2
View File
@@ -3283,8 +3283,7 @@ static int basicUnitTests(U32 const seed, double compressibility)
{ U32 u;
for (u = 0; u < CNBuffSize; ++u) {
((BYTE*)CNBuffer)[u] = 255 - ((BYTE*)CNBuffer)[u];
}
}
} }
{ /* Compress the data */
size_t const inputSize = 500;
size_t const outputSize = ZSTD_compressBound(inputSize);
+1
View File
@@ -1,3 +1,4 @@
# regression test artifacts
data-cache
cache
test