memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */
}
-#if 0
-/* deprecated */
-static void ZSTD_refDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
-{
- ZSTD_decompressBegin(dstDCtx); /* init */
- if (srcDCtx) { /* support refDCtx on NULL */
- dstDCtx->dictEnd = srcDCtx->dictEnd;
- dstDCtx->vBase = srcDCtx->vBase;
- dstDCtx->base = srcDCtx->base;
- dstDCtx->previousDstEnd = srcDCtx->previousDstEnd;
- dstDCtx->dictID = srcDCtx->dictID;
- dstDCtx->litEntropy = srcDCtx->litEntropy;
- dstDCtx->fseEntropy = srcDCtx->fseEntropy;
- dstDCtx->LLTptr = srcDCtx->entropy.LLTable;
- dstDCtx->MLTptr = srcDCtx->entropy.MLTable;
- dstDCtx->OFTptr = srcDCtx->entropy.OFTable;
- dstDCtx->HUFptr = srcDCtx->entropy.hufTable;
- dstDCtx->entropy.rep[0] = srcDCtx->entropy.rep[0];
- dstDCtx->entropy.rep[1] = srcDCtx->entropy.rep[1];
- dstDCtx->entropy.rep[2] = srcDCtx->entropy.rep[2];
- }
-}
-#endif
-
static void ZSTD_refDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict);
/*! ZSTD_getcBlockSize() :
* Provides the size of compressed block from block header `src` */
-size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
+size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr)
{
if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong);
{ U32 const cBlockHeader = MEM_readLE24(src);
}
-static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
{
if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall);
memcpy(dst, src, srcSize);
}
-static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity, const void* src, size_t srcSize, size_t regenSize)
+static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ size_t regenSize)
{
if (srcSize != 1) return ERROR(srcSize_wrong);
if (regenSize > dstCapacity) return ERROR(dstSize_tooSmall);
U32 alignedBy4;
} FSE_decode_t4;
+/* Default FSE distribution table for Literal Lengths */
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 } },
+ /* base, symbol, bits */
+ { { 0, 0, 4 } }, { { 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 */
+/* Default FSE distribution table for Match Lengths */
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 } },
+ /* base, symbol, bits */
+ { { 0, 0, 6 } }, { { 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 */
+/* Default FSE distribution table for Offset Codes */
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 } },
+ /* base, symbol, bits */
+ { { 0, 0, 5 } }, { { 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() :
}
-
-
static seq_t ZSTD_decodeSequence(seqState_t* seqState)
{
seq_t seq;
/* copy Match */
if (sequence.offset > (size_t)(oLitEnd - base)) {
- /* offset beyond prefix */
+ /* offset beyond prefix -> go into extDict */
if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
match = dictEnd + (match - base);
if (match + sequence.matchLength <= dictEnd) {