mirror of
https://github.com/facebook/zstd.git
synced 2025-03-06 16:56:49 +02:00
fixed RLE detection test
This commit is contained in:
parent
83a3402a92
commit
f83ed087f6
@ -4491,14 +4491,14 @@ static void ZSTD_overflowCorrectIfNeeded(ZSTD_matchState_t* ms,
|
||||
|
||||
static size_t ZSTD_optimalBlockSize(const void* src, size_t srcSize, size_t blockSizeMax, ZSTD_strategy strat, S64 savings)
|
||||
{
|
||||
if (srcSize <= 128 KB || blockSizeMax < 128 KB)
|
||||
return MIN(srcSize, blockSizeMax);
|
||||
(void)strat;
|
||||
if (strat >= ZSTD_btlazy2)
|
||||
return ZSTD_splitBlock_4k(src, srcSize, blockSizeMax);
|
||||
if (srcSize <= 128 KB || blockSizeMax < 128 KB)
|
||||
return MIN(srcSize, blockSizeMax);
|
||||
/* blind split strategy
|
||||
* heuristic, just tested as being "generally better"
|
||||
* do not split incompressible data though: just respect the 3 bytes per block overhead limit.
|
||||
* no cpu cost, but can over-split homegeneous data.
|
||||
* heuristic, tested as being "generally better".
|
||||
* do not split incompressible data though: respect the 3 bytes per block overhead limit.
|
||||
*/
|
||||
return savings ? 92 KB : 128 KB;
|
||||
}
|
||||
|
@ -3653,16 +3653,19 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
ZSTD_freeDCtx(dctx);
|
||||
}
|
||||
|
||||
/* long rle test */
|
||||
/* rle detection test: must compress better blocks with a single identical byte repeated */
|
||||
{ size_t sampleSize = 0;
|
||||
size_t expectedCompressedSize = 39; /* block 1, 2: compressed, block 3: RLE, zstd 1.4.4 */
|
||||
DISPLAYLEVEL(3, "test%3i : Long RLE test : ", testNb++);
|
||||
memset((char*)CNBuffer+sampleSize, 'B', 256 KB - 1);
|
||||
sampleSize += 256 KB - 1;
|
||||
memset((char*)CNBuffer+sampleSize, 'A', 96 KB);
|
||||
sampleSize += 96 KB;
|
||||
size_t maxCompressedSize = 46; /* block 1, 2: compressed, block 3: RLE, zstd 1.4.4 */
|
||||
DISPLAYLEVEL(3, "test%3i : RLE detection test : ", testNb++);
|
||||
memset((char*)CNBuffer+sampleSize, 'B', 256 KB - 2);
|
||||
sampleSize += 256 KB - 2;
|
||||
memset((char*)CNBuffer+sampleSize, 'A', 100 KB);
|
||||
sampleSize += 100 KB;
|
||||
cSize = ZSTD_compress(compressedBuffer, ZSTD_compressBound(sampleSize), CNBuffer, sampleSize, 1);
|
||||
if (ZSTD_isError(cSize) || cSize > expectedCompressedSize) goto _output_error;
|
||||
if (ZSTD_isError(cSize) || cSize > maxCompressedSize) {
|
||||
DISPLAYLEVEL(4, "error: cSize %u > %u expected ! \n", (unsigned)cSize, (unsigned)maxCompressedSize);
|
||||
goto _output_error;
|
||||
}
|
||||
{ CHECK_NEWV(regenSize, ZSTD_decompress(decodedBuffer, sampleSize, compressedBuffer, cSize));
|
||||
if (regenSize!=sampleSize) goto _output_error; }
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user