Merge pull request #863 from facebook/newFormats
magicless frames (#591)
This commit is contained in:
@@ -376,6 +376,7 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb)
|
||||
skippedSize = frameHeaderSize + ZSTD_blockHeaderSize;
|
||||
memcpy(buff2, dstBuff+skippedSize, g_cSize-skippedSize);
|
||||
srcSize = srcSize > 128 KB ? 128 KB : srcSize; /* speed relative to block */
|
||||
ZSTD_decompressBegin(g_zdc);
|
||||
break;
|
||||
}
|
||||
case 32: /* ZSTD_decodeSeqHeaders */
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# test artefacts
|
||||
corpora
|
||||
block_decompress
|
||||
block_round_trip
|
||||
simple_round_trip
|
||||
+38
-1
@@ -918,6 +918,43 @@ static int basicUnitTests(U32 seed, double compressibility)
|
||||
ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
|
||||
/* custom formats tests */
|
||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||
size_t const inputSize = CNBuffSize / 2; /* won't cause pb with small dict size */
|
||||
|
||||
/* basic block compression */
|
||||
DISPLAYLEVEL(4, "test%3i : magic-less format test : ", testNb++);
|
||||
CHECK( ZSTD_CCtx_setParameter(cctx, ZSTD_p_format, ZSTD_f_zstd1_magicless) );
|
||||
{ ZSTD_inBuffer in = { CNBuffer, inputSize, 0 };
|
||||
ZSTD_outBuffer out = { compressedBuffer, ZSTD_compressBound(inputSize), 0 };
|
||||
size_t const result = ZSTD_compress_generic(cctx, &out, &in, ZSTD_e_end);
|
||||
if (result != 0) goto _output_error;
|
||||
if (in.pos != in.size) goto _output_error;
|
||||
cSize = out.pos;
|
||||
}
|
||||
DISPLAYLEVEL(4, "OK (compress : %u -> %u bytes)\n", (U32)inputSize, (U32)cSize);
|
||||
|
||||
DISPLAYLEVEL(4, "test%3i : decompress normally (should fail) : ", testNb++);
|
||||
{ size_t const decodeResult = ZSTD_decompressDCtx(dctx, decodedBuffer, CNBuffSize, compressedBuffer, cSize);
|
||||
if (ZSTD_getErrorCode(decodeResult) != ZSTD_error_prefix_unknown) goto _output_error;
|
||||
DISPLAYLEVEL(4, "OK : %s \n", ZSTD_getErrorName(decodeResult));
|
||||
}
|
||||
|
||||
DISPLAYLEVEL(4, "test%3i : decompress with magic-less instruction : ", testNb++);
|
||||
ZSTD_DCtx_reset(dctx);
|
||||
CHECK( ZSTD_DCtx_setFormat(dctx, ZSTD_f_zstd1_magicless) );
|
||||
{ ZSTD_inBuffer in = { compressedBuffer, cSize, 0 };
|
||||
ZSTD_outBuffer out = { decodedBuffer, CNBuffSize, 0 };
|
||||
size_t const result = ZSTD_decompress_generic(dctx, &out, &in);
|
||||
if (result != 0) goto _output_error;
|
||||
if (in.pos != in.size) goto _output_error;
|
||||
if (out.pos != inputSize) goto _output_error;
|
||||
DISPLAYLEVEL(4, "OK : regenerated %u bytes \n", (U32)out.pos);
|
||||
}
|
||||
|
||||
ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
|
||||
/* block API tests */
|
||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||
static const size_t dictSize = 65 KB;
|
||||
@@ -961,8 +998,8 @@ static int basicUnitTests(U32 seed, double compressibility)
|
||||
DISPLAYLEVEL(4, "OK \n");
|
||||
|
||||
ZSTD_freeCCtx(cctx);
|
||||
ZSTD_freeDCtx(dctx);
|
||||
}
|
||||
ZSTD_freeDCtx(dctx);
|
||||
|
||||
/* long rle test */
|
||||
{ size_t sampleSize = 0;
|
||||
|
||||
+2
-2
@@ -391,8 +391,8 @@ static int BMK_seed(winnerInfo_t* winners, const ZSTD_compressionParameters para
|
||||
double W_DMemUsed_note = W_ratioNote * ( 40 + 9*cLevel) - log((double)W_DMemUsed);
|
||||
double O_DMemUsed_note = O_ratioNote * ( 40 + 9*cLevel) - log((double)O_DMemUsed);
|
||||
|
||||
size_t W_CMemUsed = (1 << params.windowLog) + ZSTD_estimateCCtxSize_advanced_usingCParams(params);
|
||||
size_t O_CMemUsed = (1 << winners[cLevel].params.windowLog) + ZSTD_estimateCCtxSize_advanced_usingCParams(winners[cLevel].params);
|
||||
size_t W_CMemUsed = (1 << params.windowLog) + ZSTD_estimateCCtxSize_usingCParams(params);
|
||||
size_t O_CMemUsed = (1 << winners[cLevel].params.windowLog) + ZSTD_estimateCCtxSize_usingCParams(winners[cLevel].params);
|
||||
double W_CMemUsed_note = W_ratioNote * ( 50 + 13*cLevel) - log((double)W_CMemUsed);
|
||||
double O_CMemUsed_note = O_ratioNote * ( 50 + 13*cLevel) - log((double)O_CMemUsed);
|
||||
|
||||
|
||||
+5
-1
@@ -55,7 +55,6 @@ then
|
||||
fi
|
||||
|
||||
isWindows=false
|
||||
ECHO="echo -e"
|
||||
INTOVOID="/dev/null"
|
||||
case "$OS" in
|
||||
Windows*)
|
||||
@@ -76,6 +75,11 @@ case "$UNAME" in
|
||||
SunOS) DIFF="gdiff" ;;
|
||||
esac
|
||||
|
||||
ECHO="echo -e"
|
||||
case "$UNAME" in
|
||||
Darwin) ECHO="echo" ;;
|
||||
esac
|
||||
|
||||
$ECHO "\nStarting playTests.sh isWindows=$isWindows ZSTD='$ZSTD'"
|
||||
|
||||
[ -n "$ZSTD" ] || die "ZSTD variable must be defined!"
|
||||
|
||||
+8
-8
@@ -201,11 +201,11 @@ static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem custo
|
||||
/* context size functions */
|
||||
DISPLAYLEVEL(3, "test%3i : estimate CStream size : ", testNb++);
|
||||
{ ZSTD_compressionParameters const cParams = ZSTD_getCParams(1, CNBufferSize, dictSize);
|
||||
size_t const s = ZSTD_estimateCStreamSize_advanced_usingCParams(cParams)
|
||||
/* uses ZSTD_initCStream_usingDict() */
|
||||
+ ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy);
|
||||
if (ZSTD_isError(s)) goto _output_error;
|
||||
DISPLAYLEVEL(3, "OK (%u bytes) \n", (U32)s);
|
||||
size_t const cstreamSize = ZSTD_estimateCStreamSize_usingCParams(cParams);
|
||||
size_t const cdictSize = ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy); /* uses ZSTD_initCStream_usingDict() */
|
||||
if (ZSTD_isError(cstreamSize)) goto _output_error;
|
||||
if (ZSTD_isError(cdictSize)) goto _output_error;
|
||||
DISPLAYLEVEL(3, "OK (%u bytes) \n", (U32)(cstreamSize + cdictSize));
|
||||
}
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : check actual CStream size : ", testNb++);
|
||||
@@ -915,7 +915,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
||||
size_t const randomDstSize = FUZ_randomLength(&lseed, maxSampleLog);
|
||||
size_t const dstBuffSize = MIN(dstBufferSize - totalGenSize, randomDstSize);
|
||||
inBuff.size = inBuff.pos + readCSrcSize;
|
||||
outBuff.size = inBuff.pos + dstBuffSize;
|
||||
outBuff.size = outBuff.pos + dstBuffSize;
|
||||
decompressionResult = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||
if (ZSTD_getErrorCode(decompressionResult) == ZSTD_error_checksum_wrong) {
|
||||
DISPLAY("checksum error : \n");
|
||||
@@ -1179,7 +1179,7 @@ static int fuzzerTests_MT(U32 seed, U32 nbTests, unsigned startTest, double comp
|
||||
size_t const randomDstSize = FUZ_randomLength(&lseed, maxSampleLog);
|
||||
size_t const dstBuffSize = MIN(dstBufferSize - totalGenSize, randomDstSize);
|
||||
inBuff.size = inBuff.pos + readCSrcSize;
|
||||
outBuff.size = inBuff.pos + dstBuffSize;
|
||||
outBuff.size = outBuff.pos + dstBuffSize;
|
||||
DISPLAYLEVEL(5, "ZSTD_decompressStream input %u bytes \n", (U32)readCSrcSize);
|
||||
decompressionResult = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||
CHECK (ZSTD_isError(decompressionResult), "decompression error : %s", ZSTD_getErrorName(decompressionResult));
|
||||
@@ -1507,7 +1507,7 @@ static int fuzzerTests_newAPI(U32 seed, U32 nbTests, unsigned startTest, double
|
||||
size_t const randomDstSize = FUZ_randomLength(&lseed, maxSampleLog);
|
||||
size_t const dstBuffSize = MIN(dstBufferSize - totalGenSize, randomDstSize);
|
||||
inBuff.size = inBuff.pos + readCSrcSize;
|
||||
outBuff.size = inBuff.pos + dstBuffSize;
|
||||
outBuff.size = outBuff.pos + dstBuffSize;
|
||||
DISPLAYLEVEL(5, "ZSTD_decompressStream input %u bytes (pos:%u/%u)\n",
|
||||
(U32)readCSrcSize, (U32)inBuff.pos, (U32)cSize);
|
||||
decompressionResult = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||
|
||||
Reference in New Issue
Block a user