mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 12:07:03 -06:00
update to zstd 1.1.0
- also reverted multithreading encoder (it is in testing)
This commit is contained in:
@@ -32,8 +32,8 @@ extern "C" {
|
|||||||
|
|
||||||
/*======= Version =======*/
|
/*======= Version =======*/
|
||||||
#define ZSTD_VERSION_MAJOR 1
|
#define ZSTD_VERSION_MAJOR 1
|
||||||
#define ZSTD_VERSION_MINOR 0
|
#define ZSTD_VERSION_MINOR 1
|
||||||
#define ZSTD_VERSION_RELEASE 1
|
#define ZSTD_VERSION_RELEASE 0
|
||||||
|
|
||||||
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
|
#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
|
||||||
#define ZSTD_QUOTE(str) #str
|
#define ZSTD_QUOTE(str) #str
|
||||||
@@ -290,11 +290,11 @@ ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* outp
|
|||||||
#define ZSTD_WINDOWLOG_MAX_32 25
|
#define ZSTD_WINDOWLOG_MAX_32 25
|
||||||
#define ZSTD_WINDOWLOG_MAX_64 27
|
#define ZSTD_WINDOWLOG_MAX_64 27
|
||||||
#define ZSTD_WINDOWLOG_MAX ((U32)(MEM_32bits() ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
|
#define ZSTD_WINDOWLOG_MAX ((U32)(MEM_32bits() ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
|
||||||
#define ZSTD_WINDOWLOG_MIN 18
|
#define ZSTD_WINDOWLOG_MIN 10
|
||||||
#define ZSTD_CHAINLOG_MAX (ZSTD_WINDOWLOG_MAX+1)
|
|
||||||
#define ZSTD_CHAINLOG_MIN 4
|
|
||||||
#define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX
|
#define ZSTD_HASHLOG_MAX ZSTD_WINDOWLOG_MAX
|
||||||
#define ZSTD_HASHLOG_MIN 12
|
#define ZSTD_HASHLOG_MIN 6
|
||||||
|
#define ZSTD_CHAINLOG_MAX (ZSTD_WINDOWLOG_MAX+1)
|
||||||
|
#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN
|
||||||
#define ZSTD_HASHLOG3_MAX 17
|
#define ZSTD_HASHLOG3_MAX 17
|
||||||
#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
|
#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
|
||||||
#define ZSTD_SEARCHLOG_MIN 1
|
#define ZSTD_SEARCHLOG_MIN 1
|
||||||
@@ -447,7 +447,7 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
|
|||||||
ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
|
||||||
ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
|
||||||
ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
|
||||||
ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx);
|
ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|||||||
@@ -142,21 +142,8 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** ZSTD_checkCParams_advanced() :
|
|
||||||
temporary work-around, while the compressor compatibility remains limited regarding windowLog < 18 */
|
|
||||||
size_t ZSTD_checkCParams_advanced(ZSTD_compressionParameters cParams, U64 srcSize)
|
|
||||||
{
|
|
||||||
if (srcSize > (1ULL << ZSTD_WINDOWLOG_MIN)) return ZSTD_checkCParams(cParams);
|
|
||||||
if (cParams.windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN) return ERROR(compressionParameter_unsupported);
|
|
||||||
if (srcSize <= (1ULL << cParams.windowLog)) cParams.windowLog = ZSTD_WINDOWLOG_MIN; /* fake value - temporary work around */
|
|
||||||
if (srcSize <= (1ULL << cParams.chainLog)) cParams.chainLog = ZSTD_CHAINLOG_MIN; /* fake value - temporary work around */
|
|
||||||
if ((srcSize <= (1ULL << cParams.hashLog)) & ((U32)cParams.strategy < (U32)ZSTD_btlazy2)) cParams.hashLog = ZSTD_HASHLOG_MIN; /* fake value - temporary work around */
|
|
||||||
return ZSTD_checkCParams(cParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** ZSTD_adjustCParams() :
|
/** ZSTD_adjustCParams() :
|
||||||
optimize cPar for a given input (`srcSize` and `dictSize`).
|
optimize `cPar` for a given input (`srcSize` and `dictSize`).
|
||||||
mostly downsizing to reduce memory consumption and initialization.
|
mostly downsizing to reduce memory consumption and initialization.
|
||||||
Both `srcSize` and `dictSize` are optional (use 0 if unknown),
|
Both `srcSize` and `dictSize` are optional (use 0 if unknown),
|
||||||
but if both are 0, no optimization can be done.
|
but if both are 0, no optimization can be done.
|
||||||
@@ -169,7 +156,7 @@ ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, u
|
|||||||
{ U32 const minSrcSize = (srcSize==0) ? 500 : 0;
|
{ U32 const minSrcSize = (srcSize==0) ? 500 : 0;
|
||||||
U64 const rSize = srcSize + dictSize + minSrcSize;
|
U64 const rSize = srcSize + dictSize + minSrcSize;
|
||||||
if (rSize < ((U64)1<<ZSTD_WINDOWLOG_MAX)) {
|
if (rSize < ((U64)1<<ZSTD_WINDOWLOG_MAX)) {
|
||||||
U32 const srcLog = MAX(4, ZSTD_highbit32((U32)(rSize)-1) + 1);
|
U32 const srcLog = MAX(ZSTD_HASHLOG_MIN, ZSTD_highbit32((U32)(rSize)-1) + 1);
|
||||||
if (cPar.windowLog > srcLog) cPar.windowLog = srcLog;
|
if (cPar.windowLog > srcLog) cPar.windowLog = srcLog;
|
||||||
} }
|
} }
|
||||||
if (cPar.hashLog > cPar.windowLog) cPar.hashLog = cPar.windowLog;
|
if (cPar.hashLog > cPar.windowLog) cPar.hashLog = cPar.windowLog;
|
||||||
@@ -178,7 +165,6 @@ ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, u
|
|||||||
if (cPar.chainLog > maxChainLog) cPar.chainLog = maxChainLog; } /* <= ZSTD_CHAINLOG_MAX */
|
if (cPar.chainLog > maxChainLog) cPar.chainLog = maxChainLog; } /* <= ZSTD_CHAINLOG_MAX */
|
||||||
|
|
||||||
if (cPar.windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN) cPar.windowLog = ZSTD_WINDOWLOG_ABSOLUTEMIN; /* required for frame header */
|
if (cPar.windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN) cPar.windowLog = ZSTD_WINDOWLOG_ABSOLUTEMIN; /* required for frame header */
|
||||||
if ((cPar.hashLog < ZSTD_HASHLOG_MIN) & ((U32)cPar.strategy >= (U32)ZSTD_btlazy2)) cPar.hashLog = ZSTD_HASHLOG_MIN; /* required to ensure collision resistance in bt */
|
|
||||||
|
|
||||||
return cPar;
|
return cPar;
|
||||||
}
|
}
|
||||||
@@ -322,13 +308,12 @@ static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
|
|||||||
* Duplicate an existing context `srcCCtx` into another one `dstCCtx`.
|
* Duplicate an existing context `srcCCtx` into another one `dstCCtx`.
|
||||||
* Only works during stage ZSTDcs_init (i.e. after creation, but before first call to ZSTD_compressContinue()).
|
* Only works during stage ZSTDcs_init (i.e. after creation, but before first call to ZSTD_compressContinue()).
|
||||||
* @return : 0, or an error code */
|
* @return : 0, or an error code */
|
||||||
size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx)
|
size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx, unsigned long long pledgedSrcSize)
|
||||||
{
|
{
|
||||||
if (srcCCtx->stage!=ZSTDcs_init) return ERROR(stage_wrong);
|
if (srcCCtx->stage!=ZSTDcs_init) return ERROR(stage_wrong);
|
||||||
|
|
||||||
memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
|
memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
|
||||||
ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, srcCCtx->frameContentSize, ZSTDcrp_noMemset);
|
ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, pledgedSrcSize, ZSTDcrp_noMemset);
|
||||||
dstCCtx->params.fParams.contentSizeFlag = 0; /* content size different from the one set during srcCCtx init */
|
|
||||||
|
|
||||||
/* copy tables */
|
/* copy tables */
|
||||||
{ size_t const chainSize = (srcCCtx->params.cParams.strategy == ZSTD_fast) ? 0 : (1 << srcCCtx->params.cParams.chainLog);
|
{ size_t const chainSize = (srcCCtx->params.cParams.strategy == ZSTD_fast) ? 0 : (1 << srcCCtx->params.cParams.chainLog);
|
||||||
@@ -2557,7 +2542,7 @@ size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx,
|
|||||||
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
||||||
{
|
{
|
||||||
/* compression parameters verification and optimization */
|
/* compression parameters verification and optimization */
|
||||||
CHECK_F(ZSTD_checkCParams_advanced(params.cParams, pledgedSrcSize));
|
CHECK_F(ZSTD_checkCParams(params.cParams));
|
||||||
return ZSTD_compressBegin_internal(cctx, dict, dictSize, params, pledgedSrcSize);
|
return ZSTD_compressBegin_internal(cctx, dict, dictSize, params, pledgedSrcSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2645,7 +2630,7 @@ size_t ZSTD_compress_advanced (ZSTD_CCtx* ctx,
|
|||||||
const void* dict,size_t dictSize,
|
const void* dict,size_t dictSize,
|
||||||
ZSTD_parameters params)
|
ZSTD_parameters params)
|
||||||
{
|
{
|
||||||
CHECK_F(ZSTD_checkCParams_advanced(params.cParams, srcSize));
|
CHECK_F(ZSTD_checkCParams(params.cParams));
|
||||||
return ZSTD_compress_internal(ctx, dst, dstCapacity, src, srcSize, dict, dictSize, params);
|
return ZSTD_compress_internal(ctx, dst, dstCapacity, src, srcSize, dict, dictSize, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2730,7 +2715,7 @@ ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionL
|
|||||||
size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
|
size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
|
||||||
{
|
{
|
||||||
if (cdict==NULL) return 0; /* support free on NULL */
|
if (cdict==NULL) return 0; /* support free on NULL */
|
||||||
{ ZSTD_customMem cMem = cdict->refContext->customMem;
|
{ ZSTD_customMem const cMem = cdict->refContext->customMem;
|
||||||
ZSTD_freeCCtx(cdict->refContext);
|
ZSTD_freeCCtx(cdict->refContext);
|
||||||
ZSTD_free(cdict->dictContent, cMem);
|
ZSTD_free(cdict->dictContent, cMem);
|
||||||
ZSTD_free(cdict, cMem);
|
ZSTD_free(cdict, cMem);
|
||||||
@@ -2740,7 +2725,7 @@ size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
|
|||||||
|
|
||||||
size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, U64 pledgedSrcSize)
|
size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict, U64 pledgedSrcSize)
|
||||||
{
|
{
|
||||||
if (cdict->dictContentSize) CHECK_F(ZSTD_copyCCtx(cctx, cdict->refContext))
|
if (cdict->dictContentSize) CHECK_F(ZSTD_copyCCtx(cctx, cdict->refContext, pledgedSrcSize))
|
||||||
else CHECK_F(ZSTD_compressBegin_advanced(cctx, NULL, 0, cdict->refContext->params, pledgedSrcSize));
|
else CHECK_F(ZSTD_compressBegin_advanced(cctx, NULL, 0, cdict->refContext->params, pledgedSrcSize));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2852,7 +2837,7 @@ size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
|||||||
{ size_t const neededInBuffSize = (size_t)1 << params.cParams.windowLog;
|
{ size_t const neededInBuffSize = (size_t)1 << params.cParams.windowLog;
|
||||||
if (zcs->inBuffSize < neededInBuffSize) {
|
if (zcs->inBuffSize < neededInBuffSize) {
|
||||||
zcs->inBuffSize = neededInBuffSize;
|
zcs->inBuffSize = neededInBuffSize;
|
||||||
ZSTD_free(zcs->inBuff, zcs->customMem); /* should not be necessary */
|
ZSTD_free(zcs->inBuff, zcs->customMem);
|
||||||
zcs->inBuff = (char*) ZSTD_malloc(neededInBuffSize, zcs->customMem);
|
zcs->inBuff = (char*) ZSTD_malloc(neededInBuffSize, zcs->customMem);
|
||||||
if (zcs->inBuff == NULL) return ERROR(memory_allocation);
|
if (zcs->inBuff == NULL) return ERROR(memory_allocation);
|
||||||
}
|
}
|
||||||
@@ -2860,7 +2845,7 @@ size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
|
|||||||
}
|
}
|
||||||
if (zcs->outBuffSize < ZSTD_compressBound(zcs->blockSize)+1) {
|
if (zcs->outBuffSize < ZSTD_compressBound(zcs->blockSize)+1) {
|
||||||
zcs->outBuffSize = ZSTD_compressBound(zcs->blockSize)+1;
|
zcs->outBuffSize = ZSTD_compressBound(zcs->blockSize)+1;
|
||||||
ZSTD_free(zcs->outBuff, zcs->customMem); /* should not be necessary */
|
ZSTD_free(zcs->outBuff, zcs->customMem);
|
||||||
zcs->outBuff = (char*) ZSTD_malloc(zcs->outBuffSize, zcs->customMem);
|
zcs->outBuff = (char*) ZSTD_malloc(zcs->outBuffSize, zcs->customMem);
|
||||||
if (zcs->outBuff == NULL) return ERROR(memory_allocation);
|
if (zcs->outBuff == NULL) return ERROR(memory_allocation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,23 +482,203 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
FSE_decode_t realData;
|
||||||
|
U32 alignedBy4;
|
||||||
|
} FSE_decode_t4;
|
||||||
|
|
||||||
|
static const FSE_decode_t4 LL_defaultDTable[(1<<LL_DEFAULTNORMLOG)+1] = {
|
||||||
|
{ { LL_DEFAULTNORMLOG, 1, 1 } }, /* header : tableLog, fastMode, fastMode */
|
||||||
|
{ { 0, 0, 4 } }, /* 0 : base, symbol, bits */
|
||||||
|
{ { 16, 0, 4 } },
|
||||||
|
{ { 32, 1, 5 } },
|
||||||
|
{ { 0, 3, 5 } },
|
||||||
|
{ { 0, 4, 5 } },
|
||||||
|
{ { 0, 6, 5 } },
|
||||||
|
{ { 0, 7, 5 } },
|
||||||
|
{ { 0, 9, 5 } },
|
||||||
|
{ { 0, 10, 5 } },
|
||||||
|
{ { 0, 12, 5 } },
|
||||||
|
{ { 0, 14, 6 } },
|
||||||
|
{ { 0, 16, 5 } },
|
||||||
|
{ { 0, 18, 5 } },
|
||||||
|
{ { 0, 19, 5 } },
|
||||||
|
{ { 0, 21, 5 } },
|
||||||
|
{ { 0, 22, 5 } },
|
||||||
|
{ { 0, 24, 5 } },
|
||||||
|
{ { 32, 25, 5 } },
|
||||||
|
{ { 0, 26, 5 } },
|
||||||
|
{ { 0, 27, 6 } },
|
||||||
|
{ { 0, 29, 6 } },
|
||||||
|
{ { 0, 31, 6 } },
|
||||||
|
{ { 32, 0, 4 } },
|
||||||
|
{ { 0, 1, 4 } },
|
||||||
|
{ { 0, 2, 5 } },
|
||||||
|
{ { 32, 4, 5 } },
|
||||||
|
{ { 0, 5, 5 } },
|
||||||
|
{ { 32, 7, 5 } },
|
||||||
|
{ { 0, 8, 5 } },
|
||||||
|
{ { 32, 10, 5 } },
|
||||||
|
{ { 0, 11, 5 } },
|
||||||
|
{ { 0, 13, 6 } },
|
||||||
|
{ { 32, 16, 5 } },
|
||||||
|
{ { 0, 17, 5 } },
|
||||||
|
{ { 32, 19, 5 } },
|
||||||
|
{ { 0, 20, 5 } },
|
||||||
|
{ { 32, 22, 5 } },
|
||||||
|
{ { 0, 23, 5 } },
|
||||||
|
{ { 0, 25, 4 } },
|
||||||
|
{ { 16, 25, 4 } },
|
||||||
|
{ { 32, 26, 5 } },
|
||||||
|
{ { 0, 28, 6 } },
|
||||||
|
{ { 0, 30, 6 } },
|
||||||
|
{ { 48, 0, 4 } },
|
||||||
|
{ { 16, 1, 4 } },
|
||||||
|
{ { 32, 2, 5 } },
|
||||||
|
{ { 32, 3, 5 } },
|
||||||
|
{ { 32, 5, 5 } },
|
||||||
|
{ { 32, 6, 5 } },
|
||||||
|
{ { 32, 8, 5 } },
|
||||||
|
{ { 32, 9, 5 } },
|
||||||
|
{ { 32, 11, 5 } },
|
||||||
|
{ { 32, 12, 5 } },
|
||||||
|
{ { 0, 15, 6 } },
|
||||||
|
{ { 32, 17, 5 } },
|
||||||
|
{ { 32, 18, 5 } },
|
||||||
|
{ { 32, 20, 5 } },
|
||||||
|
{ { 32, 21, 5 } },
|
||||||
|
{ { 32, 23, 5 } },
|
||||||
|
{ { 32, 24, 5 } },
|
||||||
|
{ { 0, 35, 6 } },
|
||||||
|
{ { 0, 34, 6 } },
|
||||||
|
{ { 0, 33, 6 } },
|
||||||
|
{ { 0, 32, 6 } },
|
||||||
|
}; /* LL_defaultDTable */
|
||||||
|
|
||||||
|
static const FSE_decode_t4 ML_defaultDTable[(1<<ML_DEFAULTNORMLOG)+1] = {
|
||||||
|
{ { ML_DEFAULTNORMLOG, 1, 1 } }, /* header : tableLog, fastMode, fastMode */
|
||||||
|
{ { 0, 0, 6 } }, /* 0 : base, symbol, bits */
|
||||||
|
{ { 0, 1, 4 } },
|
||||||
|
{ { 32, 2, 5 } },
|
||||||
|
{ { 0, 3, 5 } },
|
||||||
|
{ { 0, 5, 5 } },
|
||||||
|
{ { 0, 6, 5 } },
|
||||||
|
{ { 0, 8, 5 } },
|
||||||
|
{ { 0, 10, 6 } },
|
||||||
|
{ { 0, 13, 6 } },
|
||||||
|
{ { 0, 16, 6 } },
|
||||||
|
{ { 0, 19, 6 } },
|
||||||
|
{ { 0, 22, 6 } },
|
||||||
|
{ { 0, 25, 6 } },
|
||||||
|
{ { 0, 28, 6 } },
|
||||||
|
{ { 0, 31, 6 } },
|
||||||
|
{ { 0, 33, 6 } },
|
||||||
|
{ { 0, 35, 6 } },
|
||||||
|
{ { 0, 37, 6 } },
|
||||||
|
{ { 0, 39, 6 } },
|
||||||
|
{ { 0, 41, 6 } },
|
||||||
|
{ { 0, 43, 6 } },
|
||||||
|
{ { 0, 45, 6 } },
|
||||||
|
{ { 16, 1, 4 } },
|
||||||
|
{ { 0, 2, 4 } },
|
||||||
|
{ { 32, 3, 5 } },
|
||||||
|
{ { 0, 4, 5 } },
|
||||||
|
{ { 32, 6, 5 } },
|
||||||
|
{ { 0, 7, 5 } },
|
||||||
|
{ { 0, 9, 6 } },
|
||||||
|
{ { 0, 12, 6 } },
|
||||||
|
{ { 0, 15, 6 } },
|
||||||
|
{ { 0, 18, 6 } },
|
||||||
|
{ { 0, 21, 6 } },
|
||||||
|
{ { 0, 24, 6 } },
|
||||||
|
{ { 0, 27, 6 } },
|
||||||
|
{ { 0, 30, 6 } },
|
||||||
|
{ { 0, 32, 6 } },
|
||||||
|
{ { 0, 34, 6 } },
|
||||||
|
{ { 0, 36, 6 } },
|
||||||
|
{ { 0, 38, 6 } },
|
||||||
|
{ { 0, 40, 6 } },
|
||||||
|
{ { 0, 42, 6 } },
|
||||||
|
{ { 0, 44, 6 } },
|
||||||
|
{ { 32, 1, 4 } },
|
||||||
|
{ { 48, 1, 4 } },
|
||||||
|
{ { 16, 2, 4 } },
|
||||||
|
{ { 32, 4, 5 } },
|
||||||
|
{ { 32, 5, 5 } },
|
||||||
|
{ { 32, 7, 5 } },
|
||||||
|
{ { 32, 8, 5 } },
|
||||||
|
{ { 0, 11, 6 } },
|
||||||
|
{ { 0, 14, 6 } },
|
||||||
|
{ { 0, 17, 6 } },
|
||||||
|
{ { 0, 20, 6 } },
|
||||||
|
{ { 0, 23, 6 } },
|
||||||
|
{ { 0, 26, 6 } },
|
||||||
|
{ { 0, 29, 6 } },
|
||||||
|
{ { 0, 52, 6 } },
|
||||||
|
{ { 0, 51, 6 } },
|
||||||
|
{ { 0, 50, 6 } },
|
||||||
|
{ { 0, 49, 6 } },
|
||||||
|
{ { 0, 48, 6 } },
|
||||||
|
{ { 0, 47, 6 } },
|
||||||
|
{ { 0, 46, 6 } },
|
||||||
|
}; /* ML_defaultDTable */
|
||||||
|
|
||||||
|
static const FSE_decode_t4 OF_defaultDTable[(1<<OF_DEFAULTNORMLOG)+1] = {
|
||||||
|
{ { OF_DEFAULTNORMLOG, 1, 1 } }, /* header : tableLog, fastMode, fastMode */
|
||||||
|
{ { 0, 0, 5 } }, /* 0 : base, symbol, bits */
|
||||||
|
{ { 0, 6, 4 } },
|
||||||
|
{ { 0, 9, 5 } },
|
||||||
|
{ { 0, 15, 5 } },
|
||||||
|
{ { 0, 21, 5 } },
|
||||||
|
{ { 0, 3, 5 } },
|
||||||
|
{ { 0, 7, 4 } },
|
||||||
|
{ { 0, 12, 5 } },
|
||||||
|
{ { 0, 18, 5 } },
|
||||||
|
{ { 0, 23, 5 } },
|
||||||
|
{ { 0, 5, 5 } },
|
||||||
|
{ { 0, 8, 4 } },
|
||||||
|
{ { 0, 14, 5 } },
|
||||||
|
{ { 0, 20, 5 } },
|
||||||
|
{ { 0, 2, 5 } },
|
||||||
|
{ { 16, 7, 4 } },
|
||||||
|
{ { 0, 11, 5 } },
|
||||||
|
{ { 0, 17, 5 } },
|
||||||
|
{ { 0, 22, 5 } },
|
||||||
|
{ { 0, 4, 5 } },
|
||||||
|
{ { 16, 8, 4 } },
|
||||||
|
{ { 0, 13, 5 } },
|
||||||
|
{ { 0, 19, 5 } },
|
||||||
|
{ { 0, 1, 5 } },
|
||||||
|
{ { 16, 6, 4 } },
|
||||||
|
{ { 0, 10, 5 } },
|
||||||
|
{ { 0, 16, 5 } },
|
||||||
|
{ { 0, 28, 5 } },
|
||||||
|
{ { 0, 27, 5 } },
|
||||||
|
{ { 0, 26, 5 } },
|
||||||
|
{ { 0, 25, 5 } },
|
||||||
|
{ { 0, 24, 5 } },
|
||||||
|
}; /* OF_defaultDTable */
|
||||||
|
|
||||||
/*! ZSTD_buildSeqTable() :
|
/*! ZSTD_buildSeqTable() :
|
||||||
@return : nb bytes read from src,
|
@return : nb bytes read from src,
|
||||||
or an error code if it fails, testable with ZSTD_isError()
|
or an error code if it fails, testable with ZSTD_isError()
|
||||||
*/
|
*/
|
||||||
static size_t ZSTD_buildSeqTable(FSE_DTable* DTable, symbolEncodingType_e type, U32 max, U32 maxLog,
|
static size_t ZSTD_buildSeqTable(FSE_DTable* DTableSpace, const FSE_DTable** DTablePtr,
|
||||||
|
symbolEncodingType_e type, U32 max, U32 maxLog,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
const S16* defaultNorm, U32 defaultLog, U32 flagRepeatTable)
|
const FSE_decode_t4* defaultTable, U32 flagRepeatTable)
|
||||||
{
|
{
|
||||||
|
const void* const tmpPtr = defaultTable; /* bypass strict aliasing */
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case set_rle :
|
case set_rle :
|
||||||
if (!srcSize) return ERROR(srcSize_wrong);
|
if (!srcSize) return ERROR(srcSize_wrong);
|
||||||
if ( (*(const BYTE*)src) > max) return ERROR(corruption_detected);
|
if ( (*(const BYTE*)src) > max) return ERROR(corruption_detected);
|
||||||
FSE_buildDTable_rle(DTable, *(const BYTE*)src); /* if *src > max, data is corrupted */
|
FSE_buildDTable_rle(DTableSpace, *(const BYTE*)src);
|
||||||
|
*DTablePtr = DTableSpace;
|
||||||
return 1;
|
return 1;
|
||||||
case set_basic :
|
case set_basic :
|
||||||
FSE_buildDTable(DTable, defaultNorm, max, defaultLog);
|
*DTablePtr = (const FSE_DTable*)tmpPtr;
|
||||||
return 0;
|
return 0;
|
||||||
case set_repeat:
|
case set_repeat:
|
||||||
if (!flagRepeatTable) return ERROR(corruption_detected);
|
if (!flagRepeatTable) return ERROR(corruption_detected);
|
||||||
@@ -510,12 +690,12 @@ static size_t ZSTD_buildSeqTable(FSE_DTable* DTable, symbolEncodingType_e type,
|
|||||||
size_t const headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize);
|
size_t const headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize);
|
||||||
if (FSE_isError(headerSize)) return ERROR(corruption_detected);
|
if (FSE_isError(headerSize)) return ERROR(corruption_detected);
|
||||||
if (tableLog > maxLog) return ERROR(corruption_detected);
|
if (tableLog > maxLog) return ERROR(corruption_detected);
|
||||||
FSE_buildDTable(DTable, norm, max, tableLog);
|
FSE_buildDTable(DTableSpace, norm, max, tableLog);
|
||||||
|
*DTablePtr = DTableSpace;
|
||||||
return headerSize;
|
return headerSize;
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
||||||
const void* src, size_t srcSize)
|
const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
@@ -546,21 +726,25 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
|
|||||||
ip++;
|
ip++;
|
||||||
|
|
||||||
/* Build DTables */
|
/* Build DTables */
|
||||||
{ size_t const llhSize = ZSTD_buildSeqTable(dctx->LLTable, LLtype, MaxLL, LLFSELog, ip, iend-ip, LL_defaultNorm, LL_defaultNormLog, dctx->fseEntropy);
|
{ size_t const llhSize = ZSTD_buildSeqTable(dctx->LLTable, &dctx->LLTptr,
|
||||||
|
LLtype, MaxLL, LLFSELog,
|
||||||
|
ip, iend-ip, LL_defaultDTable, dctx->fseEntropy);
|
||||||
if (ZSTD_isError(llhSize)) return ERROR(corruption_detected);
|
if (ZSTD_isError(llhSize)) return ERROR(corruption_detected);
|
||||||
if (LLtype != set_repeat) dctx->LLTptr = dctx->LLTable;
|
|
||||||
ip += llhSize;
|
ip += llhSize;
|
||||||
}
|
}
|
||||||
{ size_t const ofhSize = ZSTD_buildSeqTable(dctx->OFTable, OFtype, MaxOff, OffFSELog, ip, iend-ip, OF_defaultNorm, OF_defaultNormLog, dctx->fseEntropy);
|
{ size_t const ofhSize = ZSTD_buildSeqTable(dctx->OFTable, &dctx->OFTptr,
|
||||||
|
OFtype, MaxOff, OffFSELog,
|
||||||
|
ip, iend-ip, OF_defaultDTable, dctx->fseEntropy);
|
||||||
if (ZSTD_isError(ofhSize)) return ERROR(corruption_detected);
|
if (ZSTD_isError(ofhSize)) return ERROR(corruption_detected);
|
||||||
if (OFtype != set_repeat) dctx->OFTptr = dctx->OFTable;
|
|
||||||
ip += ofhSize;
|
ip += ofhSize;
|
||||||
}
|
}
|
||||||
{ size_t const mlhSize = ZSTD_buildSeqTable(dctx->MLTable, MLtype, MaxML, MLFSELog, ip, iend-ip, ML_defaultNorm, ML_defaultNormLog, dctx->fseEntropy);
|
{ size_t const mlhSize = ZSTD_buildSeqTable(dctx->MLTable, &dctx->MLTptr,
|
||||||
|
MLtype, MaxML, MLFSELog,
|
||||||
|
ip, iend-ip, ML_defaultDTable, dctx->fseEntropy);
|
||||||
if (ZSTD_isError(mlhSize)) return ERROR(corruption_detected);
|
if (ZSTD_isError(mlhSize)) return ERROR(corruption_detected);
|
||||||
if (MLtype != set_repeat) dctx->MLTptr = dctx->MLTable;
|
|
||||||
ip += mlhSize;
|
ip += mlhSize;
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ip-istart;
|
return ip-istart;
|
||||||
}
|
}
|
||||||
@@ -1370,6 +1554,7 @@ size_t ZSTD_initDStream(ZSTD_DStream* zds)
|
|||||||
|
|
||||||
size_t ZSTD_resetDStream(ZSTD_DStream* zds)
|
size_t ZSTD_resetDStream(ZSTD_DStream* zds)
|
||||||
{
|
{
|
||||||
|
if (zds->ddict == NULL) return ERROR(stage_wrong); /* must be init at least once */
|
||||||
zds->stage = zdss_loadHeader;
|
zds->stage = zdss_loadHeader;
|
||||||
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
|
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
|
||||||
zds->legacyVersion = 0;
|
zds->legacyVersion = 0;
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|||||||
static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1,
|
||||||
-1,-1,-1,-1 };
|
-1,-1,-1,-1 };
|
||||||
static const U32 LL_defaultNormLog = 6;
|
#define LL_DEFAULTNORMLOG 6 /* for static allocation */
|
||||||
|
static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
||||||
|
|
||||||
static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@@ -118,11 +119,13 @@ static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,
|
||||||
-1,-1,-1,-1,-1 };
|
-1,-1,-1,-1,-1 };
|
||||||
static const U32 ML_defaultNormLog = 6;
|
#define ML_DEFAULTNORMLOG 6 /* for static allocation */
|
||||||
|
static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
||||||
|
|
||||||
static const S16 OF_defaultNorm[MaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
static const S16 OF_defaultNorm[MaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1 };
|
1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1 };
|
||||||
static const U32 OF_defaultNormLog = 5;
|
#define OF_DEFAULTNORMLOG 5 /* for static allocation */
|
||||||
|
static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
||||||
|
|
||||||
|
|
||||||
/*-*******************************************
|
/*-*******************************************
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ extern "C" {
|
|||||||
#include "mem.h" /* MEM_STATIC */
|
#include "mem.h" /* MEM_STATIC */
|
||||||
#include "error_private.h" /* ERROR */
|
#include "error_private.h" /* ERROR */
|
||||||
#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer */
|
#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer */
|
||||||
|
#include "zstd_v01.h"
|
||||||
|
#include "zstd_v02.h"
|
||||||
|
#include "zstd_v03.h"
|
||||||
|
#include "zstd_v04.h"
|
||||||
#include "zstd_v05.h"
|
#include "zstd_v05.h"
|
||||||
#include "zstd_v06.h"
|
#include "zstd_v06.h"
|
||||||
#include "zstd_v07.h"
|
#include "zstd_v07.h"
|
||||||
@@ -36,6 +40,10 @@ MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize)
|
|||||||
magicNumberLE = MEM_readLE32(src);
|
magicNumberLE = MEM_readLE32(src);
|
||||||
switch(magicNumberLE)
|
switch(magicNumberLE)
|
||||||
{
|
{
|
||||||
|
case ZSTDv01_magicNumberLE:return 1;
|
||||||
|
case ZSTDv02_magicNumber : return 2;
|
||||||
|
case ZSTDv03_magicNumber : return 3;
|
||||||
|
case ZSTDv04_magicNumber : return 4;
|
||||||
case ZSTDv05_MAGICNUMBER : return 5;
|
case ZSTDv05_MAGICNUMBER : return 5;
|
||||||
case ZSTDv06_MAGICNUMBER : return 6;
|
case ZSTDv06_MAGICNUMBER : return 6;
|
||||||
case ZSTDv07_MAGICNUMBER : return 7;
|
case ZSTDv07_MAGICNUMBER : return 7;
|
||||||
@@ -43,6 +51,7 @@ MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, size_t srcSize)
|
MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
U32 const version = ZSTD_isLegacy(src, srcSize);
|
U32 const version = ZSTD_isLegacy(src, srcSize);
|
||||||
@@ -65,11 +74,10 @@ MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, s
|
|||||||
if (frResult != 0) return 0;
|
if (frResult != 0) return 0;
|
||||||
return fParams.frameContentSize;
|
return fParams.frameContentSize;
|
||||||
}
|
}
|
||||||
|
return 0; /* should not be possible */
|
||||||
/* should not be possible */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MEM_STATIC size_t ZSTD_decompressLegacy(
|
MEM_STATIC size_t ZSTD_decompressLegacy(
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t compressedSize,
|
const void* src, size_t compressedSize,
|
||||||
@@ -78,6 +86,14 @@ MEM_STATIC size_t ZSTD_decompressLegacy(
|
|||||||
U32 const version = ZSTD_isLegacy(src, compressedSize);
|
U32 const version = ZSTD_isLegacy(src, compressedSize);
|
||||||
switch(version)
|
switch(version)
|
||||||
{
|
{
|
||||||
|
case 1 :
|
||||||
|
return ZSTDv01_decompress(dst, dstCapacity, src, compressedSize);
|
||||||
|
case 2 :
|
||||||
|
return ZSTDv02_decompress(dst, dstCapacity, src, compressedSize);
|
||||||
|
case 3 :
|
||||||
|
return ZSTDv03_decompress(dst, dstCapacity, src, compressedSize);
|
||||||
|
case 4 :
|
||||||
|
return ZSTDv04_decompress(dst, dstCapacity, src, compressedSize);
|
||||||
case 5 :
|
case 5 :
|
||||||
{ size_t result;
|
{ size_t result;
|
||||||
ZSTDv05_DCtx* const zd = ZSTDv05_createDCtx();
|
ZSTDv05_DCtx* const zd = ZSTDv05_createDCtx();
|
||||||
@@ -112,13 +128,16 @@ MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
|
|||||||
{
|
{
|
||||||
switch(version)
|
switch(version)
|
||||||
{
|
{
|
||||||
|
default :
|
||||||
|
case 1 :
|
||||||
|
case 2 :
|
||||||
|
case 3 :
|
||||||
|
return ERROR(version_unsupported);
|
||||||
|
case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext);
|
||||||
case 5 : return ZBUFFv05_freeDCtx((ZBUFFv05_DCtx*)legacyContext);
|
case 5 : return ZBUFFv05_freeDCtx((ZBUFFv05_DCtx*)legacyContext);
|
||||||
case 6 : return ZBUFFv06_freeDCtx((ZBUFFv06_DCtx*)legacyContext);
|
case 6 : return ZBUFFv06_freeDCtx((ZBUFFv06_DCtx*)legacyContext);
|
||||||
case 7 : return ZBUFFv07_freeDCtx((ZBUFFv07_DCtx*)legacyContext);
|
case 7 : return ZBUFFv07_freeDCtx((ZBUFFv07_DCtx*)legacyContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should not be possible */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,6 +147,20 @@ MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U
|
|||||||
if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion);
|
if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion);
|
||||||
switch(newVersion)
|
switch(newVersion)
|
||||||
{
|
{
|
||||||
|
default :
|
||||||
|
case 1 :
|
||||||
|
case 2 :
|
||||||
|
case 3 :
|
||||||
|
return 0;
|
||||||
|
case 4 :
|
||||||
|
{
|
||||||
|
ZBUFFv04_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv04_createDCtx() : (ZBUFFv04_DCtx*)*legacyContext;
|
||||||
|
if (dctx==NULL) return ERROR(memory_allocation);
|
||||||
|
ZBUFFv04_decompressInit(dctx);
|
||||||
|
ZBUFFv04_decompressWithDictionary(dctx, dict, dictSize);
|
||||||
|
*legacyContext = dctx;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case 5 :
|
case 5 :
|
||||||
{
|
{
|
||||||
ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext;
|
ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext;
|
||||||
@@ -153,9 +186,6 @@ MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should not be possible */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -165,6 +195,23 @@ MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
|
|||||||
{
|
{
|
||||||
switch(version)
|
switch(version)
|
||||||
{
|
{
|
||||||
|
default :
|
||||||
|
case 1 :
|
||||||
|
case 2 :
|
||||||
|
case 3 :
|
||||||
|
return ERROR(version_unsupported);
|
||||||
|
case 4 :
|
||||||
|
{
|
||||||
|
ZBUFFv04_DCtx* dctx = (ZBUFFv04_DCtx*) legacyContext;
|
||||||
|
const void* src = (const char*)input->src + input->pos;
|
||||||
|
size_t readSize = input->size - input->pos;
|
||||||
|
void* dst = (char*)output->dst + output->pos;
|
||||||
|
size_t decodedSize = output->size - output->pos;
|
||||||
|
size_t const hintSize = ZBUFFv04_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
|
||||||
|
output->pos += decodedSize;
|
||||||
|
input->pos += readSize;
|
||||||
|
return hintSize;
|
||||||
|
}
|
||||||
case 5 :
|
case 5 :
|
||||||
{
|
{
|
||||||
ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext;
|
ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext;
|
||||||
@@ -202,9 +249,6 @@ MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
|
|||||||
return hintSize;
|
return hintSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should not be possible */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2090
C/zstd/zstd_v01.c
Normal file
2090
C/zstd/zstd_v01.c
Normal file
File diff suppressed because it is too large
Load Diff
80
C/zstd/zstd_v01.h
Normal file
80
C/zstd/zstd_v01.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_V01_H_28739879432
|
||||||
|
#define ZSTD_V01_H_28739879432
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Includes
|
||||||
|
***************************************/
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Simple one-step function
|
||||||
|
***************************************/
|
||||||
|
/**
|
||||||
|
ZSTDv01_decompress() : decompress ZSTD frames compliant with v0.1.x format
|
||||||
|
compressedSize : is the exact source size
|
||||||
|
maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.
|
||||||
|
It must be equal or larger than originalSize, otherwise decompression will fail.
|
||||||
|
return : the number of bytes decompressed into destination buffer (originalSize)
|
||||||
|
or an errorCode if it fails (which can be tested using ZSTDv01_isError())
|
||||||
|
*/
|
||||||
|
size_t ZSTDv01_decompress( void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
ZSTDv01_isError() : tells if the result of ZSTDv01_decompress() is an error
|
||||||
|
*/
|
||||||
|
unsigned ZSTDv01_isError(size_t code);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Advanced functions
|
||||||
|
***************************************/
|
||||||
|
typedef struct ZSTDv01_Dctx_s ZSTDv01_Dctx;
|
||||||
|
ZSTDv01_Dctx* ZSTDv01_createDCtx(void);
|
||||||
|
size_t ZSTDv01_freeDCtx(ZSTDv01_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv01_decompressDCtx(void* ctx,
|
||||||
|
void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Streaming functions
|
||||||
|
***************************************/
|
||||||
|
size_t ZSTDv01_resetDCtx(ZSTDv01_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv01_nextSrcSizeToDecompress(ZSTDv01_Dctx* dctx);
|
||||||
|
size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
|
||||||
|
/**
|
||||||
|
Use above functions alternatively.
|
||||||
|
ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
|
||||||
|
ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.
|
||||||
|
Result is the number of bytes regenerated within 'dst'.
|
||||||
|
It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Prefix - version detection
|
||||||
|
***************************************/
|
||||||
|
#define ZSTDv01_magicNumber 0xFD2FB51E /* Big Endian version */
|
||||||
|
#define ZSTDv01_magicNumberLE 0x1EB52FFD /* Little Endian version */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZSTD_V01_H_28739879432 */
|
||||||
3519
C/zstd/zstd_v02.c
Normal file
3519
C/zstd/zstd_v02.c
Normal file
File diff suppressed because it is too large
Load Diff
79
C/zstd/zstd_v02.h
Normal file
79
C/zstd/zstd_v02.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_V02_H_4174539423
|
||||||
|
#define ZSTD_V02_H_4174539423
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Includes
|
||||||
|
***************************************/
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Simple one-step function
|
||||||
|
***************************************/
|
||||||
|
/**
|
||||||
|
ZSTDv02_decompress() : decompress ZSTD frames compliant with v0.2.x format
|
||||||
|
compressedSize : is the exact source size
|
||||||
|
maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.
|
||||||
|
It must be equal or larger than originalSize, otherwise decompression will fail.
|
||||||
|
return : the number of bytes decompressed into destination buffer (originalSize)
|
||||||
|
or an errorCode if it fails (which can be tested using ZSTDv01_isError())
|
||||||
|
*/
|
||||||
|
size_t ZSTDv02_decompress( void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
ZSTDv02_isError() : tells if the result of ZSTDv02_decompress() is an error
|
||||||
|
*/
|
||||||
|
unsigned ZSTDv02_isError(size_t code);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Advanced functions
|
||||||
|
***************************************/
|
||||||
|
typedef struct ZSTDv02_Dctx_s ZSTDv02_Dctx;
|
||||||
|
ZSTDv02_Dctx* ZSTDv02_createDCtx(void);
|
||||||
|
size_t ZSTDv02_freeDCtx(ZSTDv02_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv02_decompressDCtx(void* ctx,
|
||||||
|
void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Streaming functions
|
||||||
|
***************************************/
|
||||||
|
size_t ZSTDv02_resetDCtx(ZSTDv02_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv02_nextSrcSizeToDecompress(ZSTDv02_Dctx* dctx);
|
||||||
|
size_t ZSTDv02_decompressContinue(ZSTDv02_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
|
||||||
|
/**
|
||||||
|
Use above functions alternatively.
|
||||||
|
ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
|
||||||
|
ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.
|
||||||
|
Result is the number of bytes regenerated within 'dst'.
|
||||||
|
It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Prefix - version detection
|
||||||
|
***************************************/
|
||||||
|
#define ZSTDv02_magicNumber 0xFD2FB522 /* v0.2 */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZSTD_V02_H_4174539423 */
|
||||||
3160
C/zstd/zstd_v03.c
Normal file
3160
C/zstd/zstd_v03.c
Normal file
File diff suppressed because it is too large
Load Diff
79
C/zstd/zstd_v03.h
Normal file
79
C/zstd/zstd_v03.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_V03_H_298734209782
|
||||||
|
#define ZSTD_V03_H_298734209782
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Includes
|
||||||
|
***************************************/
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Simple one-step function
|
||||||
|
***************************************/
|
||||||
|
/**
|
||||||
|
ZSTDv03_decompress() : decompress ZSTD frames compliant with v0.3.x format
|
||||||
|
compressedSize : is the exact source size
|
||||||
|
maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.
|
||||||
|
It must be equal or larger than originalSize, otherwise decompression will fail.
|
||||||
|
return : the number of bytes decompressed into destination buffer (originalSize)
|
||||||
|
or an errorCode if it fails (which can be tested using ZSTDv01_isError())
|
||||||
|
*/
|
||||||
|
size_t ZSTDv03_decompress( void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
ZSTDv03_isError() : tells if the result of ZSTDv03_decompress() is an error
|
||||||
|
*/
|
||||||
|
unsigned ZSTDv03_isError(size_t code);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Advanced functions
|
||||||
|
***************************************/
|
||||||
|
typedef struct ZSTDv03_Dctx_s ZSTDv03_Dctx;
|
||||||
|
ZSTDv03_Dctx* ZSTDv03_createDCtx(void);
|
||||||
|
size_t ZSTDv03_freeDCtx(ZSTDv03_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv03_decompressDCtx(void* ctx,
|
||||||
|
void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Streaming functions
|
||||||
|
***************************************/
|
||||||
|
size_t ZSTDv03_resetDCtx(ZSTDv03_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv03_nextSrcSizeToDecompress(ZSTDv03_Dctx* dctx);
|
||||||
|
size_t ZSTDv03_decompressContinue(ZSTDv03_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
|
||||||
|
/**
|
||||||
|
Use above functions alternatively.
|
||||||
|
ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
|
||||||
|
ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.
|
||||||
|
Result is the number of bytes regenerated within 'dst'.
|
||||||
|
It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Prefix - version detection
|
||||||
|
***************************************/
|
||||||
|
#define ZSTDv03_magicNumber 0xFD2FB523 /* v0.3 */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZSTD_V03_H_298734209782 */
|
||||||
3791
C/zstd/zstd_v04.c
Normal file
3791
C/zstd/zstd_v04.c
Normal file
File diff suppressed because it is too large
Load Diff
128
C/zstd/zstd_v04.h
Normal file
128
C/zstd/zstd_v04.h
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZSTD_V04_H_91868324769238
|
||||||
|
#define ZSTD_V04_H_91868324769238
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Includes
|
||||||
|
***************************************/
|
||||||
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Simple one-step function
|
||||||
|
***************************************/
|
||||||
|
/**
|
||||||
|
ZSTDv04_decompress() : decompress ZSTD frames compliant with v0.4.x format
|
||||||
|
compressedSize : is the exact source size
|
||||||
|
maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.
|
||||||
|
It must be equal or larger than originalSize, otherwise decompression will fail.
|
||||||
|
return : the number of bytes decompressed into destination buffer (originalSize)
|
||||||
|
or an errorCode if it fails (which can be tested using ZSTDv01_isError())
|
||||||
|
*/
|
||||||
|
size_t ZSTDv04_decompress( void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
ZSTDv04_isError() : tells if the result of ZSTDv04_decompress() is an error
|
||||||
|
*/
|
||||||
|
unsigned ZSTDv04_isError(size_t code);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Advanced functions
|
||||||
|
***************************************/
|
||||||
|
typedef struct ZSTDv04_Dctx_s ZSTDv04_Dctx;
|
||||||
|
ZSTDv04_Dctx* ZSTDv04_createDCtx(void);
|
||||||
|
size_t ZSTDv04_freeDCtx(ZSTDv04_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv04_decompressDCtx(ZSTDv04_Dctx* dctx,
|
||||||
|
void* dst, size_t maxOriginalSize,
|
||||||
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Direct Streaming
|
||||||
|
***************************************/
|
||||||
|
size_t ZSTDv04_resetDCtx(ZSTDv04_Dctx* dctx);
|
||||||
|
|
||||||
|
size_t ZSTDv04_nextSrcSizeToDecompress(ZSTDv04_Dctx* dctx);
|
||||||
|
size_t ZSTDv04_decompressContinue(ZSTDv04_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
|
||||||
|
/**
|
||||||
|
Use above functions alternatively.
|
||||||
|
ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
|
||||||
|
ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.
|
||||||
|
Result is the number of bytes regenerated within 'dst'.
|
||||||
|
It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Buffered Streaming
|
||||||
|
***************************************/
|
||||||
|
typedef struct ZBUFFv04_DCtx_s ZBUFFv04_DCtx;
|
||||||
|
ZBUFFv04_DCtx* ZBUFFv04_createDCtx(void);
|
||||||
|
size_t ZBUFFv04_freeDCtx(ZBUFFv04_DCtx* dctx);
|
||||||
|
|
||||||
|
size_t ZBUFFv04_decompressInit(ZBUFFv04_DCtx* dctx);
|
||||||
|
size_t ZBUFFv04_decompressWithDictionary(ZBUFFv04_DCtx* dctx, const void* dict, size_t dictSize);
|
||||||
|
|
||||||
|
size_t ZBUFFv04_decompressContinue(ZBUFFv04_DCtx* dctx, void* dst, size_t* maxDstSizePtr, const void* src, size_t* srcSizePtr);
|
||||||
|
|
||||||
|
/** ************************************************
|
||||||
|
* Streaming decompression
|
||||||
|
*
|
||||||
|
* A ZBUFF_DCtx object is required to track streaming operation.
|
||||||
|
* Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
|
||||||
|
* Use ZBUFF_decompressInit() to start a new decompression operation.
|
||||||
|
* ZBUFF_DCtx objects can be reused multiple times.
|
||||||
|
*
|
||||||
|
* Optionally, a reference to a static dictionary can be set, using ZBUFF_decompressWithDictionary()
|
||||||
|
* It must be the same content as the one set during compression phase.
|
||||||
|
* Dictionary content must remain accessible during the decompression process.
|
||||||
|
*
|
||||||
|
* Use ZBUFF_decompressContinue() repetitively to consume your input.
|
||||||
|
* *srcSizePtr and *maxDstSizePtr can be any size.
|
||||||
|
* The function will report how many bytes were read or written by modifying *srcSizePtr and *maxDstSizePtr.
|
||||||
|
* Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
|
||||||
|
* The content of dst will be overwritten (up to *maxDstSizePtr) at each function call, so save its content if it matters or change dst.
|
||||||
|
* @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
|
||||||
|
* or 0 when a frame is completely decoded
|
||||||
|
* or an error code, which can be tested using ZBUFF_isError().
|
||||||
|
*
|
||||||
|
* Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize / ZBUFF_recommendedDOutSize
|
||||||
|
* output : ZBUFF_recommendedDOutSize==128 KB block size is the internal unit, it ensures it's always possible to write a full block when it's decoded.
|
||||||
|
* input : ZBUFF_recommendedDInSize==128Kb+3; just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
|
||||||
|
* **************************************************/
|
||||||
|
unsigned ZBUFFv04_isError(size_t errorCode);
|
||||||
|
const char* ZBUFFv04_getErrorName(size_t errorCode);
|
||||||
|
|
||||||
|
|
||||||
|
/** The below functions provide recommended buffer sizes for Compression or Decompression operations.
|
||||||
|
* These sizes are not compulsory, they just tend to offer better latency */
|
||||||
|
size_t ZBUFFv04_recommendedDInSize(void);
|
||||||
|
size_t ZBUFFv04_recommendedDOutSize(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************************
|
||||||
|
* Prefix - version detection
|
||||||
|
***************************************/
|
||||||
|
#define ZSTDv04_magicNumber 0xFD2FB524 /* v0.4 */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZSTD_V04_H_91868324769238 */
|
||||||
@@ -326,7 +326,7 @@ extern "C" {
|
|||||||
* It avoids reloading the dictionary each time.
|
* It avoids reloading the dictionary each time.
|
||||||
* `preparedDCtx` must have been properly initialized using ZSTDv06_decompressBegin_usingDict().
|
* `preparedDCtx` must have been properly initialized using ZSTDv06_decompressBegin_usingDict().
|
||||||
* Requires 2 contexts : 1 for reference (preparedDCtx), which will not be modified, and 1 to run the decompression operation (dctx) */
|
* Requires 2 contexts : 1 for reference (preparedDCtx), which will not be modified, and 1 to run the decompression operation (dctx) */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompress_usingPreparedDCtx(
|
ZSTDLIBv06_API size_t ZSTDv06_decompress_usingPreparedDCtx(
|
||||||
ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx,
|
ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize);
|
const void* src, size_t srcSize);
|
||||||
@@ -337,7 +337,7 @@ ZSTDLIB_API size_t ZSTDv06_decompress_usingPreparedDCtx(
|
|||||||
static const size_t ZSTDv06_frameHeaderSize_min = 5;
|
static const size_t ZSTDv06_frameHeaderSize_min = 5;
|
||||||
static const size_t ZSTDv06_frameHeaderSize_max = ZSTDv06_FRAMEHEADERSIZE_MAX;
|
static const size_t ZSTDv06_frameHeaderSize_max = ZSTDv06_FRAMEHEADERSIZE_MAX;
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompressBegin(ZSTDv06_DCtx* dctx);
|
ZSTDLIBv06_API size_t ZSTDv06_decompressBegin(ZSTDv06_DCtx* dctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Streaming decompression, direct mode (bufferless)
|
Streaming decompression, direct mode (bufferless)
|
||||||
@@ -396,7 +396,7 @@ ZSTDLIB_API size_t ZSTDv06_decompressBegin(ZSTDv06_DCtx* dctx);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define ZSTDv06_BLOCKSIZE_MAX (128 * 1024) /* define, for static allocation */
|
#define ZSTDv06_BLOCKSIZE_MAX (128 * 1024) /* define, for static allocation */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompressBlock(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv06_API size_t ZSTDv06_decompressBlock(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,23 +14,19 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-*************************************
|
/*====== Dependency ======*/
|
||||||
* Dependencies
|
|
||||||
***************************************/
|
|
||||||
#include <stddef.h> /* size_t */
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
|
||||||
/*-***************************************************************
|
/*====== Export for Windows ======*/
|
||||||
* Export parameters
|
|
||||||
*****************************************************************/
|
|
||||||
/*!
|
/*!
|
||||||
* ZSTDv06_DLL_EXPORT :
|
* ZSTDv06_DLL_EXPORT :
|
||||||
* Enable exporting of functions when building a Windows DLL
|
* Enable exporting of functions when building a Windows DLL
|
||||||
*/
|
*/
|
||||||
#if defined(_WIN32) && defined(ZSTDv06_DLL_EXPORT) && (ZSTDv06_DLL_EXPORT==1)
|
#if defined(_WIN32) && defined(ZSTDv06_DLL_EXPORT) && (ZSTDv06_DLL_EXPORT==1)
|
||||||
# define ZSTDLIB_API __declspec(dllexport)
|
# define ZSTDLIBv06_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
# define ZSTDLIB_API
|
# define ZSTDLIBv06_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -42,18 +38,18 @@ extern "C" {
|
|||||||
`dstCapacity` must be large enough, equal or larger than originalSize.
|
`dstCapacity` must be large enough, equal or larger than originalSize.
|
||||||
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
||||||
or an errorCode if it fails (which can be tested using ZSTDv06_isError()) */
|
or an errorCode if it fails (which can be tested using ZSTDv06_isError()) */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompress( void* dst, size_t dstCapacity,
|
ZSTDLIBv06_API size_t ZSTDv06_decompress( void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t compressedSize);
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
|
|
||||||
/* *************************************
|
/* *************************************
|
||||||
* Helper functions
|
* Helper functions
|
||||||
***************************************/
|
***************************************/
|
||||||
ZSTDLIB_API size_t ZSTDv06_compressBound(size_t srcSize); /*!< maximum compressed size (worst case scenario) */
|
ZSTDLIBv06_API size_t ZSTDv06_compressBound(size_t srcSize); /*!< maximum compressed size (worst case scenario) */
|
||||||
|
|
||||||
/* Error Management */
|
/* Error Management */
|
||||||
ZSTDLIB_API unsigned ZSTDv06_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
ZSTDLIBv06_API unsigned ZSTDv06_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
||||||
ZSTDLIB_API const char* ZSTDv06_getErrorName(size_t code); /*!< provides readable string for an error code */
|
ZSTDLIBv06_API const char* ZSTDv06_getErrorName(size_t code); /*!< provides readable string for an error code */
|
||||||
|
|
||||||
|
|
||||||
/* *************************************
|
/* *************************************
|
||||||
@@ -61,12 +57,12 @@ ZSTDLIB_API const char* ZSTDv06_getErrorName(size_t code); /*!< provides rea
|
|||||||
***************************************/
|
***************************************/
|
||||||
/** Decompression context */
|
/** Decompression context */
|
||||||
typedef struct ZSTDv06_DCtx_s ZSTDv06_DCtx;
|
typedef struct ZSTDv06_DCtx_s ZSTDv06_DCtx;
|
||||||
ZSTDLIB_API ZSTDv06_DCtx* ZSTDv06_createDCtx(void);
|
ZSTDLIBv06_API ZSTDv06_DCtx* ZSTDv06_createDCtx(void);
|
||||||
ZSTDLIB_API size_t ZSTDv06_freeDCtx(ZSTDv06_DCtx* dctx); /*!< @return : errorCode */
|
ZSTDLIBv06_API size_t ZSTDv06_freeDCtx(ZSTDv06_DCtx* dctx); /*!< @return : errorCode */
|
||||||
|
|
||||||
/** ZSTDv06_decompressDCtx() :
|
/** ZSTDv06_decompressDCtx() :
|
||||||
* Same as ZSTDv06_decompress(), but requires an already allocated ZSTDv06_DCtx (see ZSTDv06_createDCtx()) */
|
* Same as ZSTDv06_decompress(), but requires an already allocated ZSTDv06_DCtx (see ZSTDv06_createDCtx()) */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompressDCtx(ZSTDv06_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv06_API size_t ZSTDv06_decompressDCtx(ZSTDv06_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|
||||||
|
|
||||||
/*-***********************
|
/*-***********************
|
||||||
@@ -76,10 +72,10 @@ ZSTDLIB_API size_t ZSTDv06_decompressDCtx(ZSTDv06_DCtx* ctx, void* dst, size_t d
|
|||||||
* Decompression using a pre-defined Dictionary content (see dictBuilder).
|
* Decompression using a pre-defined Dictionary content (see dictBuilder).
|
||||||
* Dictionary must be identical to the one used during compression, otherwise regenerated data will be corrupted.
|
* Dictionary must be identical to the one used during compression, otherwise regenerated data will be corrupted.
|
||||||
* Note : dict can be NULL, in which case, it's equivalent to ZSTDv06_decompressDCtx() */
|
* Note : dict can be NULL, in which case, it's equivalent to ZSTDv06_decompressDCtx() */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompress_usingDict(ZSTDv06_DCtx* dctx,
|
ZSTDLIBv06_API size_t ZSTDv06_decompress_usingDict(ZSTDv06_DCtx* dctx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
const void* dict,size_t dictSize);
|
const void* dict,size_t dictSize);
|
||||||
|
|
||||||
|
|
||||||
/*-************************
|
/*-************************
|
||||||
@@ -88,12 +84,12 @@ ZSTDLIB_API size_t ZSTDv06_decompress_usingDict(ZSTDv06_DCtx* dctx,
|
|||||||
struct ZSTDv06_frameParams_s { unsigned long long frameContentSize; unsigned windowLog; };
|
struct ZSTDv06_frameParams_s { unsigned long long frameContentSize; unsigned windowLog; };
|
||||||
typedef struct ZSTDv06_frameParams_s ZSTDv06_frameParams;
|
typedef struct ZSTDv06_frameParams_s ZSTDv06_frameParams;
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv06_getFrameParams(ZSTDv06_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
ZSTDLIBv06_API size_t ZSTDv06_getFrameParams(ZSTDv06_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, size_t dictSize);
|
ZSTDLIBv06_API size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, size_t dictSize);
|
||||||
ZSTDLIB_API void ZSTDv06_copyDCtx(ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx);
|
ZSTDLIBv06_API void ZSTDv06_copyDCtx(ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv06_nextSrcSizeToDecompress(ZSTDv06_DCtx* dctx);
|
ZSTDLIBv06_API size_t ZSTDv06_nextSrcSizeToDecompress(ZSTDv06_DCtx* dctx);
|
||||||
ZSTDLIB_API size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv06_API size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -102,15 +98,15 @@ ZSTDLIB_API size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, siz
|
|||||||
***************************************/
|
***************************************/
|
||||||
|
|
||||||
typedef struct ZBUFFv06_DCtx_s ZBUFFv06_DCtx;
|
typedef struct ZBUFFv06_DCtx_s ZBUFFv06_DCtx;
|
||||||
ZSTDLIB_API ZBUFFv06_DCtx* ZBUFFv06_createDCtx(void);
|
ZSTDLIBv06_API ZBUFFv06_DCtx* ZBUFFv06_createDCtx(void);
|
||||||
ZSTDLIB_API size_t ZBUFFv06_freeDCtx(ZBUFFv06_DCtx* dctx);
|
ZSTDLIBv06_API size_t ZBUFFv06_freeDCtx(ZBUFFv06_DCtx* dctx);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZBUFFv06_decompressInit(ZBUFFv06_DCtx* dctx);
|
ZSTDLIBv06_API size_t ZBUFFv06_decompressInit(ZBUFFv06_DCtx* dctx);
|
||||||
ZSTDLIB_API size_t ZBUFFv06_decompressInitDictionary(ZBUFFv06_DCtx* dctx, const void* dict, size_t dictSize);
|
ZSTDLIBv06_API size_t ZBUFFv06_decompressInitDictionary(ZBUFFv06_DCtx* dctx, const void* dict, size_t dictSize);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* dctx,
|
ZSTDLIBv06_API size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* dctx,
|
||||||
void* dst, size_t* dstCapacityPtr,
|
void* dst, size_t* dstCapacityPtr,
|
||||||
const void* src, size_t* srcSizePtr);
|
const void* src, size_t* srcSizePtr);
|
||||||
|
|
||||||
/*-***************************************************************************
|
/*-***************************************************************************
|
||||||
* Streaming decompression howto
|
* Streaming decompression howto
|
||||||
@@ -140,13 +136,13 @@ ZSTDLIB_API size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* dctx,
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Tool functions
|
* Tool functions
|
||||||
***************************************/
|
***************************************/
|
||||||
ZSTDLIB_API unsigned ZBUFFv06_isError(size_t errorCode);
|
ZSTDLIBv06_API unsigned ZBUFFv06_isError(size_t errorCode);
|
||||||
ZSTDLIB_API const char* ZBUFFv06_getErrorName(size_t errorCode);
|
ZSTDLIBv06_API const char* ZBUFFv06_getErrorName(size_t errorCode);
|
||||||
|
|
||||||
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
||||||
* These sizes are just hints, they tend to offer better latency */
|
* These sizes are just hints, they tend to offer better latency */
|
||||||
ZSTDLIB_API size_t ZBUFFv06_recommendedDInSize(void);
|
ZSTDLIBv06_API size_t ZBUFFv06_recommendedDInSize(void);
|
||||||
ZSTDLIB_API size_t ZBUFFv06_recommendedDOutSize(void);
|
ZSTDLIBv06_API size_t ZBUFFv06_recommendedDOutSize(void);
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
|
|||||||
@@ -68,27 +68,27 @@ typedef struct { ZSTDv07_allocFunction customAlloc; ZSTDv07_freeFunction customF
|
|||||||
|
|
||||||
/*! ZSTDv07_estimateDCtxSize() :
|
/*! ZSTDv07_estimateDCtxSize() :
|
||||||
* Gives the potential amount of memory allocated to create a ZSTDv07_DCtx */
|
* Gives the potential amount of memory allocated to create a ZSTDv07_DCtx */
|
||||||
ZSTDLIB_API size_t ZSTDv07_estimateDCtxSize(void);
|
ZSTDLIBv07_API size_t ZSTDv07_estimateDCtxSize(void);
|
||||||
|
|
||||||
/*! ZSTDv07_createDCtx_advanced() :
|
/*! ZSTDv07_createDCtx_advanced() :
|
||||||
* Create a ZSTD decompression context using external alloc and free functions */
|
* Create a ZSTD decompression context using external alloc and free functions */
|
||||||
ZSTDLIB_API ZSTDv07_DCtx* ZSTDv07_createDCtx_advanced(ZSTDv07_customMem customMem);
|
ZSTDLIBv07_API ZSTDv07_DCtx* ZSTDv07_createDCtx_advanced(ZSTDv07_customMem customMem);
|
||||||
|
|
||||||
/*! ZSTDv07_sizeofDCtx() :
|
/*! ZSTDv07_sizeofDCtx() :
|
||||||
* Gives the amount of memory used by a given ZSTDv07_DCtx */
|
* Gives the amount of memory used by a given ZSTDv07_DCtx */
|
||||||
ZSTDLIB_API size_t ZSTDv07_sizeofDCtx(const ZSTDv07_DCtx* dctx);
|
ZSTDLIBv07_API size_t ZSTDv07_sizeofDCtx(const ZSTDv07_DCtx* dctx);
|
||||||
|
|
||||||
|
|
||||||
/* ******************************************************************
|
/* ******************************************************************
|
||||||
* Buffer-less streaming functions (synchronous mode)
|
* Buffer-less streaming functions (synchronous mode)
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompressBegin(ZSTDv07_DCtx* dctx);
|
ZSTDLIBv07_API size_t ZSTDv07_decompressBegin(ZSTDv07_DCtx* dctx);
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompressBegin_usingDict(ZSTDv07_DCtx* dctx, const void* dict, size_t dictSize);
|
ZSTDLIBv07_API size_t ZSTDv07_decompressBegin_usingDict(ZSTDv07_DCtx* dctx, const void* dict, size_t dictSize);
|
||||||
ZSTDLIB_API void ZSTDv07_copyDCtx(ZSTDv07_DCtx* dctx, const ZSTDv07_DCtx* preparedDCtx);
|
ZSTDLIBv07_API void ZSTDv07_copyDCtx(ZSTDv07_DCtx* dctx, const ZSTDv07_DCtx* preparedDCtx);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv07_nextSrcSizeToDecompress(ZSTDv07_DCtx* dctx);
|
ZSTDLIBv07_API size_t ZSTDv07_nextSrcSizeToDecompress(ZSTDv07_DCtx* dctx);
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompressContinue(ZSTDv07_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv07_API size_t ZSTDv07_decompressContinue(ZSTDv07_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Buffer-less streaming decompression (synchronous mode)
|
Buffer-less streaming decompression (synchronous mode)
|
||||||
@@ -169,8 +169,8 @@ ZSTDLIB_API size_t ZSTDv07_decompressContinue(ZSTDv07_DCtx* dctx, void* dst, siz
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define ZSTDv07_BLOCKSIZE_ABSOLUTEMAX (128 * 1024) /* define, for static allocation */
|
#define ZSTDv07_BLOCKSIZE_ABSOLUTEMAX (128 * 1024) /* define, for static allocation */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompressBlock(ZSTDv07_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv07_API size_t ZSTDv07_decompressBlock(ZSTDv07_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
ZSTDLIB_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful for uncompressed blocks */
|
ZSTDLIBv07_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful for uncompressed blocks */
|
||||||
|
|
||||||
|
|
||||||
#endif /* ZSTDv07_STATIC_LINKING_ONLY */
|
#endif /* ZSTDv07_STATIC_LINKING_ONLY */
|
||||||
@@ -650,8 +650,8 @@ MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, U32 nbBits)
|
|||||||
if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */
|
if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */
|
||||||
MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD)
|
MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD)
|
||||||
{
|
{
|
||||||
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should not happen => corruption detected */
|
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should not happen => corruption detected */
|
||||||
return BITv07_DStream_overflow;
|
return BITv07_DStream_overflow;
|
||||||
|
|
||||||
if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) {
|
if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) {
|
||||||
bitD->ptr -= bitD->bitsConsumed >> 3;
|
bitD->ptr -= bitD->bitsConsumed >> 3;
|
||||||
@@ -3831,7 +3831,7 @@ size_t ZSTDv07_decompressBlock(ZSTDv07_DCtx* dctx,
|
|||||||
|
|
||||||
/** ZSTDv07_insertBlock() :
|
/** ZSTDv07_insertBlock() :
|
||||||
insert `src` block into `dctx` history. Useful to track uncompressed blocks. */
|
insert `src` block into `dctx` history. Useful to track uncompressed blocks. */
|
||||||
ZSTDLIB_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockStart, size_t blockSize)
|
ZSTDLIBv07_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockStart, size_t blockSize)
|
||||||
{
|
{
|
||||||
ZSTDv07_checkContinuity(dctx, blockStart);
|
ZSTDv07_checkContinuity(dctx, blockStart);
|
||||||
dctx->previousDstEnd = (const char*)blockStart + blockSize;
|
dctx->previousDstEnd = (const char*)blockStart + blockSize;
|
||||||
@@ -4233,7 +4233,7 @@ size_t ZSTDv07_freeDDict(ZSTDv07_DDict* ddict)
|
|||||||
/*! ZSTDv07_decompress_usingDDict() :
|
/*! ZSTDv07_decompress_usingDDict() :
|
||||||
* Decompression using a pre-digested Dictionary
|
* Decompression using a pre-digested Dictionary
|
||||||
* Use dictionary without significant overhead. */
|
* Use dictionary without significant overhead. */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
|
ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
const ZSTDv07_DDict* ddict)
|
const ZSTDv07_DDict* ddict)
|
||||||
@@ -4320,7 +4320,7 @@ struct ZBUFFv07_DCtx_s {
|
|||||||
ZSTDv07_customMem customMem;
|
ZSTDv07_customMem customMem;
|
||||||
}; /* typedef'd to ZBUFFv07_DCtx within "zstd_buffered.h" */
|
}; /* typedef'd to ZBUFFv07_DCtx within "zstd_buffered.h" */
|
||||||
|
|
||||||
ZSTDLIB_API ZBUFFv07_DCtx* ZBUFFv07_createDCtx_advanced(ZSTDv07_customMem customMem);
|
ZSTDLIBv07_API ZBUFFv07_DCtx* ZBUFFv07_createDCtx_advanced(ZSTDv07_customMem customMem);
|
||||||
|
|
||||||
ZBUFFv07_DCtx* ZBUFFv07_createDCtx(void)
|
ZBUFFv07_DCtx* ZBUFFv07_createDCtx(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,13 +24,12 @@ extern "C" {
|
|||||||
* Enable exporting of functions when building a Windows DLL
|
* Enable exporting of functions when building a Windows DLL
|
||||||
*/
|
*/
|
||||||
#if defined(_WIN32) && defined(ZSTDv07_DLL_EXPORT) && (ZSTDv07_DLL_EXPORT==1)
|
#if defined(_WIN32) && defined(ZSTDv07_DLL_EXPORT) && (ZSTDv07_DLL_EXPORT==1)
|
||||||
# define ZSTDLIB_API __declspec(dllexport)
|
# define ZSTDLIBv07_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
# define ZSTDLIB_API
|
# define ZSTDLIBv07_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *************************************
|
/* *************************************
|
||||||
* Simple API
|
* Simple API
|
||||||
***************************************/
|
***************************************/
|
||||||
@@ -46,12 +45,12 @@ unsigned long long ZSTDv07_getDecompressedSize(const void* src, size_t srcSize);
|
|||||||
`dstCapacity` must be equal or larger than originalSize.
|
`dstCapacity` must be equal or larger than originalSize.
|
||||||
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
||||||
or an errorCode if it fails (which can be tested using ZSTDv07_isError()) */
|
or an errorCode if it fails (which can be tested using ZSTDv07_isError()) */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompress( void* dst, size_t dstCapacity,
|
ZSTDLIBv07_API size_t ZSTDv07_decompress( void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t compressedSize);
|
const void* src, size_t compressedSize);
|
||||||
|
|
||||||
/*====== Helper functions ======*/
|
/*====== Helper functions ======*/
|
||||||
ZSTDLIB_API unsigned ZSTDv07_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
ZSTDLIBv07_API unsigned ZSTDv07_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
||||||
ZSTDLIB_API const char* ZSTDv07_getErrorName(size_t code); /*!< provides readable string from an error code */
|
ZSTDLIBv07_API const char* ZSTDv07_getErrorName(size_t code); /*!< provides readable string from an error code */
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
@@ -59,12 +58,12 @@ ZSTDLIB_API const char* ZSTDv07_getErrorName(size_t code); /*!< provides rea
|
|||||||
***************************************/
|
***************************************/
|
||||||
/** Decompression context */
|
/** Decompression context */
|
||||||
typedef struct ZSTDv07_DCtx_s ZSTDv07_DCtx;
|
typedef struct ZSTDv07_DCtx_s ZSTDv07_DCtx;
|
||||||
ZSTDLIB_API ZSTDv07_DCtx* ZSTDv07_createDCtx(void);
|
ZSTDLIBv07_API ZSTDv07_DCtx* ZSTDv07_createDCtx(void);
|
||||||
ZSTDLIB_API size_t ZSTDv07_freeDCtx(ZSTDv07_DCtx* dctx); /*!< @return : errorCode */
|
ZSTDLIBv07_API size_t ZSTDv07_freeDCtx(ZSTDv07_DCtx* dctx); /*!< @return : errorCode */
|
||||||
|
|
||||||
/** ZSTDv07_decompressDCtx() :
|
/** ZSTDv07_decompressDCtx() :
|
||||||
* Same as ZSTDv07_decompress(), requires an allocated ZSTDv07_DCtx (see ZSTDv07_createDCtx()) */
|
* Same as ZSTDv07_decompress(), requires an allocated ZSTDv07_DCtx (see ZSTDv07_createDCtx()) */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompressDCtx(ZSTDv07_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
ZSTDLIBv07_API size_t ZSTDv07_decompressDCtx(ZSTDv07_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
||||||
|
|
||||||
|
|
||||||
/*-************************
|
/*-************************
|
||||||
@@ -74,10 +73,10 @@ ZSTDLIB_API size_t ZSTDv07_decompressDCtx(ZSTDv07_DCtx* ctx, void* dst, size_t d
|
|||||||
* Decompression using a pre-defined Dictionary content (see dictBuilder).
|
* Decompression using a pre-defined Dictionary content (see dictBuilder).
|
||||||
* Dictionary must be identical to the one used during compression.
|
* Dictionary must be identical to the one used during compression.
|
||||||
* Note : This function load the dictionary, resulting in a significant startup time */
|
* Note : This function load the dictionary, resulting in a significant startup time */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompress_usingDict(ZSTDv07_DCtx* dctx,
|
ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDict(ZSTDv07_DCtx* dctx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
const void* dict,size_t dictSize);
|
const void* dict,size_t dictSize);
|
||||||
|
|
||||||
|
|
||||||
/*-**************************
|
/*-**************************
|
||||||
@@ -87,16 +86,16 @@ ZSTDLIB_API size_t ZSTDv07_decompress_usingDict(ZSTDv07_DCtx* dctx,
|
|||||||
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
||||||
* `dict` can be released after creation */
|
* `dict` can be released after creation */
|
||||||
typedef struct ZSTDv07_DDict_s ZSTDv07_DDict;
|
typedef struct ZSTDv07_DDict_s ZSTDv07_DDict;
|
||||||
ZSTDLIB_API ZSTDv07_DDict* ZSTDv07_createDDict(const void* dict, size_t dictSize);
|
ZSTDLIBv07_API ZSTDv07_DDict* ZSTDv07_createDDict(const void* dict, size_t dictSize);
|
||||||
ZSTDLIB_API size_t ZSTDv07_freeDDict(ZSTDv07_DDict* ddict);
|
ZSTDLIBv07_API size_t ZSTDv07_freeDDict(ZSTDv07_DDict* ddict);
|
||||||
|
|
||||||
/*! ZSTDv07_decompress_usingDDict() :
|
/*! ZSTDv07_decompress_usingDDict() :
|
||||||
* Decompression using a pre-digested Dictionary
|
* Decompression using a pre-digested Dictionary
|
||||||
* Faster startup than ZSTDv07_decompress_usingDict(), recommended when same dictionary is used multiple times. */
|
* Faster startup than ZSTDv07_decompress_usingDict(), recommended when same dictionary is used multiple times. */
|
||||||
ZSTDLIB_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
|
ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
|
||||||
void* dst, size_t dstCapacity,
|
void* dst, size_t dstCapacity,
|
||||||
const void* src, size_t srcSize,
|
const void* src, size_t srcSize,
|
||||||
const ZSTDv07_DDict* ddict);
|
const ZSTDv07_DDict* ddict);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long long frameContentSize;
|
unsigned long long frameContentSize;
|
||||||
@@ -105,7 +104,7 @@ typedef struct {
|
|||||||
unsigned checksumFlag;
|
unsigned checksumFlag;
|
||||||
} ZSTDv07_frameParams;
|
} ZSTDv07_frameParams;
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
ZSTDLIBv07_API size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -114,13 +113,13 @@ ZSTDLIB_API size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const
|
|||||||
* Streaming functions
|
* Streaming functions
|
||||||
***************************************/
|
***************************************/
|
||||||
typedef struct ZBUFFv07_DCtx_s ZBUFFv07_DCtx;
|
typedef struct ZBUFFv07_DCtx_s ZBUFFv07_DCtx;
|
||||||
ZSTDLIB_API ZBUFFv07_DCtx* ZBUFFv07_createDCtx(void);
|
ZSTDLIBv07_API ZBUFFv07_DCtx* ZBUFFv07_createDCtx(void);
|
||||||
ZSTDLIB_API size_t ZBUFFv07_freeDCtx(ZBUFFv07_DCtx* dctx);
|
ZSTDLIBv07_API size_t ZBUFFv07_freeDCtx(ZBUFFv07_DCtx* dctx);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZBUFFv07_decompressInit(ZBUFFv07_DCtx* dctx);
|
ZSTDLIBv07_API size_t ZBUFFv07_decompressInit(ZBUFFv07_DCtx* dctx);
|
||||||
ZSTDLIB_API size_t ZBUFFv07_decompressInitDictionary(ZBUFFv07_DCtx* dctx, const void* dict, size_t dictSize);
|
ZSTDLIBv07_API size_t ZBUFFv07_decompressInitDictionary(ZBUFFv07_DCtx* dctx, const void* dict, size_t dictSize);
|
||||||
|
|
||||||
ZSTDLIB_API size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* dctx,
|
ZSTDLIBv07_API size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* dctx,
|
||||||
void* dst, size_t* dstCapacityPtr,
|
void* dst, size_t* dstCapacityPtr,
|
||||||
const void* src, size_t* srcSizePtr);
|
const void* src, size_t* srcSizePtr);
|
||||||
|
|
||||||
@@ -152,13 +151,13 @@ ZSTDLIB_API size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* dctx,
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Tool functions
|
* Tool functions
|
||||||
***************************************/
|
***************************************/
|
||||||
ZSTDLIB_API unsigned ZBUFFv07_isError(size_t errorCode);
|
ZSTDLIBv07_API unsigned ZBUFFv07_isError(size_t errorCode);
|
||||||
ZSTDLIB_API const char* ZBUFFv07_getErrorName(size_t errorCode);
|
ZSTDLIBv07_API const char* ZBUFFv07_getErrorName(size_t errorCode);
|
||||||
|
|
||||||
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
||||||
* These sizes are just hints, they tend to offer better latency */
|
* These sizes are just hints, they tend to offer better latency */
|
||||||
ZSTDLIB_API size_t ZBUFFv07_recommendedDInSize(void);
|
ZSTDLIBv07_API size_t ZBUFFv07_recommendedDInSize(void);
|
||||||
ZSTDLIB_API size_t ZBUFFv07_recommendedDOutSize(void);
|
ZSTDLIBv07_API size_t ZBUFFv07_recommendedDOutSize(void);
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
|
|||||||
@@ -4,61 +4,29 @@
|
|||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "ZstdEncoder.h"
|
#include "ZstdEncoder.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef EXTRACT_ONLY
|
#ifndef EXTRACT_ONLY
|
||||||
struct MyStream {
|
|
||||||
ISequentialInStream *inStream;
|
|
||||||
ISequentialOutStream *outStream;
|
|
||||||
ICompressProgressInfo *progress;
|
|
||||||
UInt64 *processedIn;
|
|
||||||
UInt64 *processedOut;
|
|
||||||
};
|
|
||||||
|
|
||||||
int MyRead(void *arg, ZSTDMT_Buffer * in)
|
|
||||||
{
|
|
||||||
struct MyStream *x = (struct MyStream*)arg;
|
|
||||||
size_t size = static_cast < size_t > (in->size);
|
|
||||||
//_props._level = static_cast < Byte > (prop.ulVal);
|
|
||||||
|
|
||||||
HRESULT res = ReadStream(x->inStream, in->buf, &size);
|
|
||||||
if (res != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*x->processedIn += size;
|
|
||||||
x->progress->SetRatioInfo(x->processedIn, x->processedOut);
|
|
||||||
in->size = static_cast < int > (size);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MyWrite(void *arg, ZSTDMT_Buffer * out)
|
|
||||||
{
|
|
||||||
struct MyStream *x = (struct MyStream*)arg;
|
|
||||||
HRESULT res = WriteStream(x->outStream, out->buf, out->size);
|
|
||||||
if (res != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*x->processedOut += out->size;
|
|
||||||
x->progress->SetRatioInfo(x->processedIn, x->processedOut);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace NCompress {
|
namespace NCompress {
|
||||||
namespace NZSTD {
|
namespace NZSTD {
|
||||||
|
|
||||||
CEncoder::CEncoder():
|
CEncoder::CEncoder():
|
||||||
|
_cstream(NULL),
|
||||||
|
_buffIn(NULL),
|
||||||
|
_buffOut(NULL),
|
||||||
|
_buffInSize(0),
|
||||||
|
_buffOutSize(0),
|
||||||
_processedIn(0),
|
_processedIn(0),
|
||||||
_processedOut(0),
|
_processedOut(0)
|
||||||
_inputSize(0),
|
|
||||||
_numThreads(1)
|
|
||||||
{
|
{
|
||||||
_props.clear();
|
_props.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CEncoder::~CEncoder()
|
CEncoder::~CEncoder()
|
||||||
{
|
{
|
||||||
|
if (_cstream)
|
||||||
|
ZSTD_freeCStream(_cstream);
|
||||||
|
|
||||||
|
MyFree(_buffIn);
|
||||||
|
MyFree(_buffOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID * propIDs, const PROPVARIANT * coderProps, UInt32 numProps)
|
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID * propIDs, const PROPVARIANT * coderProps, UInt32 numProps)
|
||||||
@@ -69,7 +37,6 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID * propIDs, const PROPVARI
|
|||||||
{
|
{
|
||||||
const PROPVARIANT & prop = coderProps[i];
|
const PROPVARIANT & prop = coderProps[i];
|
||||||
PROPID propID = propIDs[i];
|
PROPID propID = propIDs[i];
|
||||||
UInt32 v = (UInt32)prop.ulVal;
|
|
||||||
switch (propID)
|
switch (propID)
|
||||||
{
|
{
|
||||||
case NCoderPropID::kLevel:
|
case NCoderPropID::kLevel:
|
||||||
@@ -85,11 +52,6 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID * propIDs, const PROPVARI
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NCoderPropID::kNumThreads:
|
|
||||||
{
|
|
||||||
SetNumberOfThreads(v);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -112,67 +74,73 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
|
|||||||
ISequentialOutStream *outStream, const UInt64 * /* inSize */ ,
|
ISequentialOutStream *outStream, const UInt64 * /* inSize */ ,
|
||||||
const UInt64 * /* outSize */ , ICompressProgressInfo *progress)
|
const UInt64 * /* outSize */ , ICompressProgressInfo *progress)
|
||||||
{
|
{
|
||||||
ZSTDMT_RdWr_t rdwr;
|
size_t result;
|
||||||
int ret;
|
|
||||||
|
|
||||||
struct MyStream Rd;
|
/* init only once in beginning */
|
||||||
Rd.progress = progress;
|
if (!_cstream) {
|
||||||
Rd.inStream = inStream;
|
|
||||||
Rd.processedIn = &_processedIn;
|
|
||||||
Rd.processedOut = &_processedOut;
|
|
||||||
|
|
||||||
struct MyStream Wr;
|
/* allocate stream */
|
||||||
Wr.progress = progress;
|
_cstream = ZSTD_createCStream();
|
||||||
Wr.outStream = outStream;
|
if (!_cstream)
|
||||||
Wr.processedIn = &_processedIn;
|
return E_OUTOFMEMORY;
|
||||||
Wr.processedOut = &_processedOut;
|
|
||||||
|
|
||||||
/* 1) setup read/write functions */
|
/* allocate buffers */
|
||||||
rdwr.fn_read = ::MyRead;
|
_buffInSize = ZSTD_CStreamInSize();
|
||||||
rdwr.fn_write = ::MyWrite;
|
_buffIn = MyAlloc(_buffInSize);
|
||||||
rdwr.arg_read = (void *)&Rd;
|
if (!_buffIn)
|
||||||
rdwr.arg_write = (void *)&Wr;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
/* 2) create compression context */
|
_buffOutSize = ZSTD_CStreamOutSize();
|
||||||
ZSTDMT_CCtx *ctx = ZSTDMT_createCCtx(_numThreads, _props._level, _inputSize);
|
_buffOut = MyAlloc(_buffOutSize);
|
||||||
if (!ctx)
|
if (!_buffOut)
|
||||||
return S_FALSE;
|
return E_OUTOFMEMORY;
|
||||||
// perror_exit("Allocating ctx failed!");
|
}
|
||||||
|
|
||||||
/* 3) compress */
|
/* init or re-init stream */
|
||||||
ret = ZSTDMT_CompressCCtx(ctx, &rdwr);
|
result = ZSTD_initCStream(_cstream, _props._level);
|
||||||
if (ret == -1)
|
if (ZSTD_isError(result))
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
// perror_exit("ZSTDMT_CompressCCtx() failed!");
|
|
||||||
|
|
||||||
/* 4) free resources */
|
UInt32 read, toRead = static_cast < UInt32 > (_buffInSize);
|
||||||
ZSTDMT_freeCCtx(ctx);
|
for(;;) {
|
||||||
return S_OK;
|
|
||||||
|
/* read input */
|
||||||
|
RINOK(inStream->Read(_buffIn, toRead, &read));
|
||||||
|
size_t InSize = static_cast < size_t > (read);
|
||||||
|
_processedIn += InSize;
|
||||||
|
|
||||||
|
if (InSize == 0) {
|
||||||
|
|
||||||
|
/* @eof */
|
||||||
|
ZSTD_outBuffer output = { _buffOut, _buffOutSize, 0 };
|
||||||
|
result = ZSTD_endStream(_cstream, &output);
|
||||||
|
if (ZSTD_isError(result))
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
if (output.pos) {
|
||||||
|
/* write last compressed bytes and update progress */
|
||||||
|
RINOK(WriteStream(outStream, _buffOut, output.pos));
|
||||||
|
_processedOut += output.pos;
|
||||||
|
RINOK(progress->SetRatioInfo(&_processedIn, &_processedOut));
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* compress input */
|
||||||
|
ZSTD_inBuffer input = { _buffIn, InSize, 0 };
|
||||||
|
while (input.pos < input.size) {
|
||||||
|
ZSTD_outBuffer output = { _buffOut, _buffOutSize, 0 };
|
||||||
|
result = ZSTD_compressStream(_cstream, &output , &input);
|
||||||
|
if (ZSTD_isError(result))
|
||||||
|
return S_FALSE;
|
||||||
|
/* write compressed stream and update progress */
|
||||||
|
RINOK(WriteStream(outStream, _buffOut, output.pos));
|
||||||
|
_processedOut += output.pos;
|
||||||
|
RINOK(progress->SetRatioInfo(&_processedIn, &_processedOut));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
|
|
||||||
{
|
|
||||||
const UInt32 kNumThreadsMax = 128;
|
|
||||||
if (numThreads < 1) numThreads = 1;
|
|
||||||
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
|
|
||||||
_numThreads = numThreads;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT CEncoder::ErrorOut(size_t code)
|
|
||||||
{
|
|
||||||
const char *strError = ZSTD_getErrorName(code);
|
|
||||||
size_t strErrorLen = strlen(strError) + 1;
|
|
||||||
wchar_t *wstrError = (wchar_t *)MyAlloc(sizeof(wchar_t) * strErrorLen);
|
|
||||||
|
|
||||||
if (!wstrError)
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
mbstowcs(wstrError, strError, strErrorLen - 1);
|
|
||||||
MessageBoxW(0, wstrError, L"7-Zip ZStandard", MB_ICONERROR | MB_OK);
|
|
||||||
MyFree(wstrError);
|
|
||||||
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#define ZSTD_STATIC_LINKING_ONLY
|
#define ZSTD_STATIC_LINKING_ONLY
|
||||||
#include "../../../C/Alloc.h"
|
#include "../../../C/Alloc.h"
|
||||||
#include "../../../C/ZStd/zstd.h"
|
#include "../../../C/ZStd/zstd.h"
|
||||||
#include "../../../C/ZStd/zstdmt.h"
|
|
||||||
|
|
||||||
#include "../../Common/Common.h"
|
#include "../../Common/Common.h"
|
||||||
#include "../../Common/MyCom.h"
|
#include "../../Common/MyCom.h"
|
||||||
@@ -40,22 +39,21 @@ class CEncoder:
|
|||||||
{
|
{
|
||||||
CProps _props;
|
CProps _props;
|
||||||
|
|
||||||
|
ZSTD_CStream *_cstream;
|
||||||
|
void *_buffIn;
|
||||||
|
void *_buffOut;
|
||||||
|
size_t _buffInSize;
|
||||||
|
size_t _buffOutSize;
|
||||||
UInt64 _processedIn;
|
UInt64 _processedIn;
|
||||||
UInt64 _processedOut;
|
UInt64 _processedOut;
|
||||||
UInt32 _inputSize;
|
|
||||||
UInt32 _numThreads;
|
|
||||||
|
|
||||||
int MyRead(void *arg, ZSTDMT_Buffer * in);
|
HRESULT CreateCompressor();
|
||||||
int MyWrite(void *arg, ZSTDMT_Buffer * out);
|
|
||||||
|
|
||||||
HRESULT CEncoder::ErrorOut(size_t code);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MY_UNKNOWN_IMP2 (ICompressSetCoderProperties, ICompressWriteCoderProperties)
|
MY_UNKNOWN_IMP2 (ICompressSetCoderProperties, ICompressWriteCoderProperties)
|
||||||
STDMETHOD (Code) (ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
STDMETHOD (Code) (ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
||||||
STDMETHOD (SetCoderProperties) (const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
|
STDMETHOD (SetCoderProperties) (const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
|
||||||
STDMETHOD (WriteCoderProperties) (ISequentialOutStream *outStream);
|
STDMETHOD (WriteCoderProperties) (ISequentialOutStream *outStream);
|
||||||
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads);
|
|
||||||
|
|
||||||
CEncoder();
|
CEncoder();
|
||||||
virtual ~CEncoder();
|
virtual ~CEncoder();
|
||||||
|
|||||||
Reference in New Issue
Block a user