void* entropyWorkspace, size_t entropyWkspSize,
const int bmi2)
{
- const int longOffsets = cctxParams->cParams.windowLog > STREAM_ACCUMULATOR_MIN;
+ const int longOffsets = cctxParams->cParams.windowLog >= STREAM_ACCUMULATOR_MIN;
ZSTD_strategy const strategy = cctxParams->cParams.strategy;
unsigned* count = (unsigned*)entropyWorkspace;
FSE_CTable* CTable_LitLength = nextEntropy->fse.litlengthCTable;
ZSTD_validateSequence(U32 offCode, U32 matchLength,
size_t posInSrc, U32 windowLog, size_t dictSize)
{
- U32 const windowSize = 1 << windowLog;
+ U32 const windowSize = 1u << windowLog;
/* posInSrc represents the amount of data the decoder would decode up to this point.
* As long as the amount of data decoded is less than or equal to window size, offsets may be
* larger than the total length of output decoded in order to reference the dict, even larger than
if (!cctx->isFirstBlock &&
ZSTD_maybeRLE(&cctx->seqStore) &&
- ZSTD_isRLE((BYTE const*)src, srcSize)) {
+ ZSTD_isRLE(ip, blockSize)) {
/* We don't want to emit our first block as a RLE even if it qualifies because
* doing so will cause the decoder (cli only) to throw a "should consume all input error."
* This is only an issue for zstd <= v1.4.3
return 0;
}
-static int basicUnitTests(U32 seed, double compressibility)
+static int basicUnitTests(U32 seed, double compressibility, int bigTests)
{
size_t const CNBufferSize = COMPRESSIBLE_NOISE_LENGTH;
void* CNBuffer = malloc(CNBufferSize);
CHECK(!ZSTD_isError(ZSTD_CCtx_setParameter(zc, ZSTD_c_srcSizeHint, -1)), "Out of range doesn't error");
DISPLAYLEVEL(3, "OK \n");
+ DISPLAYLEVEL(3, "test%3i : Test offset == windowSize : ", testNb++);
+ {
+ int windowLog;
+ int const kMaxWindowLog = bigTests ? 29 : 26;
+ size_t const kNbSequences = 10000;
+ size_t const kMaxSrcSize = (1u << kMaxWindowLog) + 10 * kNbSequences;
+ char* src = calloc(kMaxSrcSize, 1);
+ ZSTD_Sequence* sequences = malloc(sizeof(ZSTD_Sequence) * kNbSequences);
+ for (windowLog = ZSTD_WINDOWLOG_MIN; windowLog <= kMaxWindowLog; ++windowLog) {
+ size_t const srcSize = ((size_t)1 << windowLog) + 10 * (kNbSequences - 1);
+
+ sequences[0].offset = 32;
+ sequences[0].litLength = 32;
+ sequences[0].matchLength = (1u << windowLog) - 32;
+ sequences[0].rep = 0;
+ {
+ size_t i;
+ for (i = 1; i < kNbSequences; ++i) {
+ sequences[i].offset = (1u << windowLog) - (FUZ_rand(&seed) % 8);
+ sequences[i].litLength = FUZ_rand(&seed) & 7;
+ sequences[i].matchLength = 10 - sequences[i].litLength;
+ sequences[i].rep = 0;
+ }
+ }
+
+ CHECK_Z(ZSTD_CCtx_reset(zc, ZSTD_reset_session_and_parameters));
+ CHECK_Z(ZSTD_CCtx_setParameter(zc, ZSTD_c_checksumFlag, 1));
+ CHECK_Z(ZSTD_CCtx_setParameter(zc, ZSTD_c_minMatch, 3));
+ CHECK_Z(ZSTD_CCtx_setParameter(zc, ZSTD_c_validateSequences, 1));
+ CHECK_Z(ZSTD_CCtx_setParameter(zc, ZSTD_c_windowLog, windowLog));
+ assert(srcSize <= kMaxSrcSize);
+ cSize = ZSTD_compressSequences(zc, compressedBuffer, compressedBufferSize, sequences, kNbSequences, src, srcSize);
+ CHECK_Z(cSize);
+ CHECK_Z(ZSTD_DCtx_reset(zd, ZSTD_reset_session_and_parameters));
+ CHECK_Z(ZSTD_DCtx_setParameter(zd, ZSTD_d_windowLogMax, windowLog))
+ {
+ ZSTD_inBuffer in = {compressedBuffer, cSize, 0};
+ size_t decompressedBytes = 0;
+ for (;;) {
+ ZSTD_outBuffer out = {decodedBuffer, decodedBufferSize, 0};
+ size_t const ret = ZSTD_decompressStream(zd, &out, &in);
+ CHECK_Z(ret);
+ CHECK(decompressedBytes + out.pos > srcSize, "Output too large");
+ CHECK(memcmp(out.dst, src + decompressedBytes, out.pos), "Corrupted");
+ decompressedBytes += out.pos;
+ if (ret == 0) {
+ break;
+ }
+ }
+ CHECK(decompressedBytes != srcSize, "Output wrong size");
+ }
+ }
+ free(sequences);
+ free(src);
+ }
+ DISPLAYLEVEL(3, "OK \n");
+
/* Overlen overwriting window data bug */
DISPLAYLEVEL(3, "test%3i : wildcopy doesn't overwrite potential match data : ", testNb++);
{ /* This test has a window size of 1024 bytes and consists of 3 blocks:
if (nbTests<=0) nbTests=1;
if (testNb==0) {
- result = basicUnitTests(0, ((double)proba) / 100); /* constant seed for predictability */
+ result = basicUnitTests(0, ((double)proba) / 100, bigTests); /* constant seed for predictability */
}
if (!result) {