22# define ZSTD_HEAPMODE 1
29#ifndef ZSTD_LEGACY_SUPPORT
30# define ZSTD_LEGACY_SUPPORT 0
39#ifndef ZSTD_MAXWINDOWSIZE_DEFAULT
40# define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + 1)
50#ifndef ZSTD_NO_FORWARD_PROGRESS_MAX
51# define ZSTD_NO_FORWARD_PROGRESS_MAX 16
61#define FSE_STATIC_LINKING_ONLY
63#define HUF_STATIC_LINKING_ONLY
70#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
71# include "../legacy/zstd_legacy.h"
80 if (dctx==
NULL)
return 0;
91 size_t const startingInputLength = ZSTD_FRAMEHEADERSIZE_PREFIX(
format);
94 return startingInputLength;
99 dctx->
format = ZSTD_f_zstd1;
117#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118 dctx->dictContentEndForFuzzing =
NULL;
126 if ((
size_t)workspace & 7)
return NULL;
131 dctx->
inBuff = (
char*)(dctx+1);
137 if (!customMem.customAlloc ^ !customMem.customFree)
return NULL;
140 if (!dctx)
return NULL;
163 if (dctx==
NULL)
return 0;
165 { ZSTD_customMem
const cMem = dctx->
customMem;
169#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
181 size_t const toCopy = (
size_t)((
char*)(&dstDCtx->
inBuff) - (
char*)dstDCtx);
182 memcpy(dstDCtx, srcDCtx, toCopy);
202#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
218 {
BYTE const fhd = ((
const BYTE*)
src)[minInputSize-1];
219 U32 const dictID= fhd & 3;
220 U32 const singleSegment = (fhd >> 5) & 1;
221 U32 const fcsId = fhd >> 6;
222 return minInputSize + !singleSegment
224 + (singleSegment && !fcsId);
249 memset(zfhPtr, 0,
sizeof(*zfhPtr));
250 if (srcSize < minInputSize)
return minInputSize;
253 if ( (
format != ZSTD_f_zstd1_magicless)
257 if (srcSize < ZSTD_SKIPPABLEHEADERSIZE)
258 return ZSTD_SKIPPABLEHEADERSIZE;
259 memset(zfhPtr, 0,
sizeof(*zfhPtr));
261 zfhPtr->frameType = ZSTD_skippableFrame;
269 if (srcSize < fhsize)
return fhsize;
270 zfhPtr->headerSize = (
U32)fhsize;
273 {
BYTE const fhdByte =
ip[minInputSize-1];
274 size_t pos = minInputSize;
275 U32 const dictIDSizeCode = fhdByte&3;
276 U32 const checksumFlag = (fhdByte>>2)&1;
277 U32 const singleSegment = (fhdByte>>5)&1;
278 U32 const fcsID = fhdByte>>6;
283 "reserved bits, must be zero");
285 if (!singleSegment) {
288 RETURN_ERROR_IF(windowLog > ZSTD_WINDOWLOG_MAX, frameParameter_windowTooLarge,
"");
289 windowSize = (1ULL << windowLog);
290 windowSize += (windowSize >> 3) * (wlByte&7);
292 switch(dictIDSizeCode)
296 case 1 : dictID =
ip[
pos];
pos++;
break;
303 case 0 :
if (singleSegment) frameContentSize =
ip[
pos];
break;
308 if (singleSegment) windowSize = frameContentSize;
310 zfhPtr->frameType = ZSTD_frame;
311 zfhPtr->frameContentSize = frameContentSize;
312 zfhPtr->windowSize = windowSize;
314 zfhPtr->dictID = dictID;
315 zfhPtr->checksumFlag = checksumFlag;
339#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
340 if (ZSTD_isLegacy(
src, srcSize)) {
341 unsigned long long const ret = ZSTD_getDecompressedSize_legacy(
src, srcSize);
345 { ZSTD_frameHeader zfh;
348 if (zfh.frameType == ZSTD_skippableFrame) {
351 return zfh.frameContentSize;
357 size_t const skippableHeaderSize = ZSTD_SKIPPABLEHEADERSIZE;
360 RETURN_ERROR_IF(srcSize < ZSTD_SKIPPABLEHEADERSIZE, srcSize_wrong,
"");
364 frameParameter_unsupported,
"");
366 size_t const skippableSize = skippableHeaderSize + sizeU32;
368 return skippableSize;
379 unsigned long long totalDstSize = 0;
389 assert(skippableSize <= srcSize);
392 srcSize -= skippableSize;
409 srcSize -= frameSrcSize;
442#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
447 dictionary_wrong,
"");
458 return frameSizeInfo;
466#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
467 if (ZSTD_isLegacy(
src, srcSize))
468 return ZSTD_findFrameSizeInfoLegacy(
src, srcSize);
471 if ((srcSize >= ZSTD_SKIPPABLEHEADERSIZE)
476 return frameSizeInfo;
479 const BYTE*
const ipstart =
ip;
480 size_t remainingSize = srcSize;
482 ZSTD_frameHeader zfh;
492 ip += zfh.headerSize;
493 remainingSize -= zfh.headerSize;
513 if (zfh.checksumFlag) {
514 if (remainingSize < 4)
521 ? zfh.frameContentSize
522 : nbBlocks * zfh.blockSizeMax;
523 return frameSizeInfo;
546 unsigned long long bound = 0;
548 while (srcSize > 0) {
554 assert(srcSize >= compressedSize);
556 srcSize -= compressedSize;
557 bound += decompressedBound;
571 DEBUGLOG(5,
"ZSTD_insertBlock: %u bytes", (
unsigned)blockSize);
579 const void*
src,
size_t srcSize)
583 if (srcSize == 0)
return 0;
596 if (regenSize == 0)
return 0;
610 void*
dst,
size_t dstCapacity,
611 const void** srcPtr,
size_t *srcSizePtr)
615 BYTE*
const oend = dstCapacity != 0 ? ostart + dstCapacity : ostart;
617 size_t remainingSrcSize = *srcSizePtr;
619 DEBUGLOG(4,
"ZSTD_decompressFrame (srcSize:%i)", (
int)*srcSizePtr);
629 if (
ZSTD_isError(frameHeaderSize))
return frameHeaderSize;
633 ip += frameHeaderSize; remainingSrcSize -= frameHeaderSize;
660 RETURN_ERROR(corruption_detected,
"invalid block type");
664 if (dctx->
fParams.checksumFlag)
666 if (decodedSize != 0)
670 remainingSrcSize -= cBlockSize;
676 corruption_detected,
"");
678 if (dctx->
fParams.checksumFlag) {
685 remainingSrcSize -= 4;
690 *srcSizePtr = remainingSrcSize;
695 void*
dst,
size_t dstCapacity,
696 const void*
src,
size_t srcSize,
697 const void* dict,
size_t dictSize,
700 void*
const dststart =
dst;
701 int moreThan1Frame = 0;
703 DEBUGLOG(5,
"ZSTD_decompressMultiFrame");
713#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
714 if (ZSTD_isLegacy(
src, srcSize)) {
716 size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(
src, srcSize);
719 "legacy support is not compatible with static dctx");
721 decodedSize = ZSTD_decompressLegacy(
dst, dstCapacity,
src, frameSize, dict, dictSize);
724 assert(decodedSize <=- dstCapacity);
726 dstCapacity -= decodedSize;
729 srcSize -= frameSize;
736 DEBUGLOG(4,
"reading magic number %08X (expecting %08X)",
741 assert(skippableSize <= srcSize);
744 srcSize -= skippableSize;
762 && (moreThan1Frame==1),
764 "at least one frame successfully completed, but following "
765 "bytes are garbage: it's more likely to be a srcSize error, "
766 "specifying more bytes than compressed size of frame(s). This "
767 "error message replaces ERROR(prefix_unknown), which would be "
768 "confusing, as the first header is actually correct. Note that "
769 "one could be unlucky, it might be a corruption error instead, "
770 "happening right at the place where we expect zstd magic "
771 "bytes. But this is _much_ less likely than a srcSize field "
782 RETURN_ERROR_IF(srcSize, srcSize_wrong,
"input not entirely consumed");
788 void*
dst,
size_t dstCapacity,
789 const void*
src,
size_t srcSize,
790 const void* dict,
size_t dictSize)
821#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1)
867 return ZSTDnit_frameHeader;
869 return ZSTDnit_blockHeader;
871 return ZSTDnit_block;
873 return ZSTDnit_lastBlock;
875 return ZSTDnit_checksum;
878 return ZSTDnit_skippableFrame;
890 DEBUGLOG(5,
"ZSTD_decompressContinue (srcSize:%u)", (
unsigned)srcSize);
899 if (dctx->
format == ZSTD_f_zstd1) {
903 dctx->
expected = ZSTD_SKIPPABLEHEADERSIZE - srcSize;
926 RETURN_ERROR_IF(cBlockSize > dctx->
fParams.blockSizeMax, corruption_detected,
"Block Size Exceeds Maximum");
936 if (dctx->
fParams.checksumFlag) {
952 DEBUGLOG(5,
"ZSTD_decompressContinue: case ZSTDds_decompressBlock");
957 DEBUGLOG(5,
"ZSTD_decompressContinue: case bt_compressed");
974 RETURN_ERROR(corruption_detected,
"invalid block type");
977 RETURN_ERROR_IF(rSize > dctx->
fParams.blockSizeMax, corruption_detected,
"Decompressed Block Size Exceeds Maximum");
978 DEBUGLOG(5,
"ZSTD_decompressContinue: decoded size from block : %u", (
unsigned)rSize);
989 DEBUGLOG(4,
"ZSTD_decompressContinue: decoded size from frame : %u", (
unsigned)dctx->
decodedSize);
993 corruption_detected,
"");
994 if (dctx->
fParams.checksumFlag) {
1012 DEBUGLOG(4,
"ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", (
unsigned)h32, (
unsigned)check32);
1021 assert(srcSize <= ZSTD_SKIPPABLEHEADERSIZE);
1045#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1046 dctx->dictContentBeginForFuzzing = dctx->
prefixStart;
1057 const void*
const dict,
size_t const dictSize)
1059 const BYTE* dictPtr = (
const BYTE*)dict;
1060 const BYTE*
const dictEnd = dictPtr + dictSize;
1062 RETURN_ERROR_IF(dictSize <= 8, dictionary_corrupted,
"dict is too small");
1069 {
void*
const workspace = &entropy->
LLTable;
1070 size_t const workspaceSize =
sizeof(entropy->
LLTable) +
sizeof(entropy->
OFTable) +
sizeof(entropy->
MLTable);
1071#ifdef HUF_FORCE_DECOMPRESS_X1
1074 dictPtr, dictEnd - dictPtr,
1075 workspace, workspaceSize);
1078 dictPtr, dictEnd - dictPtr,
1079 workspace, workspaceSize);
1085 {
short offcodeNCount[
MaxOff+1];
1086 unsigned offcodeMaxValue =
MaxOff, offcodeLog;
1087 size_t const offcodeHeaderSize =
FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
1092 offcodeNCount, offcodeMaxValue,
1095 dictPtr += offcodeHeaderSize;
1098 {
short matchlengthNCount[
MaxML+1];
1099 unsigned matchlengthMaxValue =
MaxML, matchlengthLog;
1100 size_t const matchlengthHeaderSize =
FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
1105 matchlengthNCount, matchlengthMaxValue,
1108 dictPtr += matchlengthHeaderSize;
1111 {
short litlengthNCount[
MaxLL+1];
1112 unsigned litlengthMaxValue =
MaxLL, litlengthLog;
1113 size_t const litlengthHeaderSize =
FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
1118 litlengthNCount, litlengthMaxValue,
1121 dictPtr += litlengthHeaderSize;
1126 size_t const dictContentSize = (
size_t)(dictEnd - (dictPtr+12));
1127 for (
i=0;
i<3;
i++) {
1130 dictionary_corrupted,
"");
1131 entropy->
rep[
i] = rep;
1134 return dictPtr - (
const BYTE*)dict;
1149 dict = (
const char*)dict + eSize;
1184 if (dict && dictSize)
1187 dictionary_corrupted,
"");
1196 DEBUGLOG(4,
"ZSTD_decompressBegin_usingDDict");
1201 const void*
const dictEnd = dictStart + dictSize;
1219 if (dictSize < 8)
return 0;
1239 ZSTD_frameHeader zfp = { 0, 0, 0, ZSTD_frame, 0, 0, 0 };
1250 void*
dst,
size_t dstCapacity,
1251 const void*
src,
size_t srcSize,
1293 const void* dict,
size_t dictSize,
1294 ZSTD_dictLoadMethod_e dictLoadMethod,
1295 ZSTD_dictContentType_e dictContentType)
1299 if (dict && dictSize != 0) {
1336 DEBUGLOG(4,
"ZSTD_initDStream_usingDict");
1374 dctx->
ddict = ddict;
1413 case ZSTD_d_stableOutBuffer:
1435#define CHECK_DBOUNDS(p,v) { \
1436 RETURN_ERROR_IF(!ZSTD_dParam_withinBounds(p, v), parameter_outOfBound, ""); \
1444 if (
value == 0)
value = ZSTD_WINDOWLOG_LIMIT_DEFAULT;
1452 case ZSTD_d_stableOutBuffer:
1472 dctx->
format = ZSTD_f_zstd1;
1487 unsigned long long const neededRBSize = windowSize + blockSize + (
WILDCOPY_OVERLENGTH * 2);
1488 unsigned long long const neededSize =
MIN(frameContentSize, neededRBSize);
1489 size_t const minRBSize = (
size_t) neededSize;
1491 frameParameter_windowTooLarge,
"");
1498 size_t const inBuffSize = blockSize;
1505 U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX;
1506 ZSTD_frameHeader zfh;
1511 frameParameter_windowTooLarge,
"");
1551 RETURN_ERROR(dstBuffer_wrong,
"ZSTD_obm_stable enabled but output differs!");
1561 void const*
src,
size_t srcSize) {
1568 if (!decodedSize && !isSkipFrame) {
1576 size_t const dstSize = isSkipFrame ? 0 : oend - *
op;
1590 const char*
const src = (
const char*)
input->src;
1593 const char*
ip = istart;
1594 char*
const dst = (
char*)output->
dst;
1595 char*
const ostart = output->
pos != 0 ?
dst + output->
pos :
dst;
1598 U32 someMoreWork = 1;
1600 DEBUGLOG(5,
"ZSTD_decompressStream");
1604 "forbidden. in: pos: %u vs size: %u",
1609 "forbidden. out: pos: %u vs size: %u",
1614 while (someMoreWork) {
1618 DEBUGLOG(5,
"stage zdss_init => transparent reset ");
1627 DEBUGLOG(5,
"stage zdss_loadHeader (srcSize : %u)", (
U32)(iend -
ip));
1628#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
1631 "legacy support is incompatible with static dctx");
1640#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
1641 U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart);
1642 if (legacyVersion) {
1646 DEBUGLOG(5,
"ZSTD_decompressStream: detected legacy version v0.%u", legacyVersion);
1648 "legacy support is incompatible with static dctx");
1651 dict, dictSize),
"");
1661 size_t const toLoad = hSize - zds->
lhSize;
1662 size_t const remainingInput = (
size_t)(iend-
ip);
1664 if (toLoad > remainingInput) {
1665 if (remainingInput > 0) {
1667 zds->
lhSize += remainingInput;
1679 && zds->
fParams.frameType != ZSTD_skippableFrame
1680 && (
U64)(
size_t)(oend-
op) >= zds->
fParams.frameContentSize) {
1682 if (cSize <= (
size_t)(iend-istart)) {
1685 if (
ZSTD_isError(decompressedSize))
return decompressedSize;
1686 DEBUGLOG(4,
"shortcut to single-pass ZSTD_decompress_usingDDict()")
1687 ip = istart + cSize;
1688 op += decompressedSize;
1697 && zds->
fParams.frameType != ZSTD_skippableFrame
1699 && (
U64)(
size_t)(oend-
op) < zds->
fParams.frameContentSize) {
1700 RETURN_ERROR(dstSize_tooSmall,
"ZSTD_obm_stable passed but ZSTD_outBuffer is too small");
1717 DEBUGLOG(4,
"Control max memory usage (%u KB <= max %u KB)",
1722 frameParameter_windowTooLarge,
"");
1725 {
size_t const neededInBuffSize =
MAX(zds->
fParams.blockSizeMax, 4 );
1732 {
int const tooSmall = (zds->
inBuffSize < neededInBuffSize) || (zds->
outBuffSize < neededOutBuffSize);
1735 if (tooSmall || tooLarge) {
1736 size_t const bufferSize = neededInBuffSize + neededOutBuffSize;
1737 DEBUGLOG(4,
"inBuff : from %u to %u",
1739 DEBUGLOG(4,
"outBuff : from %u to %u",
1746 memory_allocation,
"");
1764 DEBUGLOG(5,
"neededInSize = %u", (
U32)neededInSize);
1765 if (neededInSize==0) {
1770 if ((
size_t)(iend-
ip) >= neededInSize) {
1776 if (
ip==iend) { someMoreWork = 0;
break; }
1782 size_t const toLoad = neededInSize - zds->
inPos;
1788 loadedSize =
MIN(toLoad, (
size_t)(iend-
ip));
1791 corruption_detected,
1792 "should never happen");
1796 zds->
inPos += loadedSize;
1797 if (loadedSize < toLoad) { someMoreWork = 0;
break; }
1810 if (flushedSize == toFlushSize) {
1814 DEBUGLOG(5,
"restart filling outBuff from beginning (left:%i, needed:%u)",
1837 if ((
ip==istart) && (
op==ostart)) {
1848 if (!nextSrcSizeHint) {
1868 nextSrcSizeHint -= zds->
inPos;
1869 return nextSrcSizeHint;
1875 void*
dst,
size_t dstCapacity,
size_t* dstPos,
1876 const void*
src,
size_t srcSize,
size_t* srcPos)
1882 *dstPos = output.
pos;
1883 *srcPos =
input.pos;
#define RETURN_ERROR(StatusCode)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void)
MEM_STATIC U16 MEM_readLE16(const void *memPtr)
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSVPtr, unsigned *tableLogPtr, const void *headerBuffer, size_t hbSize)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
size_t HUF_readDTableX1_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workSpace, size_t wkspSize)
#define memcpy(s1, s2, n)
static unsigned(__cdecl *hash_bstr)(bstr_t s)
#define offsetof(TYPE, MEMBER)
const HUF_DTable * HUFptr
ZSTD_dStreamStage streamStage
const ZSTD_seqSymbol * MLTptr
U32 previousLegacyVersion
const void * virtualStart
const ZSTD_seqSymbol * OFTptr
ZSTD_entropyDTables_t entropy
ZSTD_outBuffer expectedOutBuffer
BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]
const void * previousDstEnd
ZSTD_outBufferMode_e outBufferMode
const ZSTD_seqSymbol * LLTptr
ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]
ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]
ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]
HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]
unsigned long long decompressedBound
XXH_PUBLIC_API XXH_errorcode XXH64_update(XXH64_state_t *state_in, const void *input, size_t len)
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t *statePtr, unsigned long long seed)
XXH_PUBLIC_API unsigned long long XXH64_digest(const XXH64_state_t *state_in)
#define ZSTD_CONTENTSIZE_UNKNOWN
#define ZSTD_MAGIC_DICTIONARY
#define ZSTD_MAGIC_SKIPPABLE_MASK
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict *ddict)
struct ZSTD_DCtx_s ZSTD_DCtx
#define ZSTD_CONTENTSIZE_ERROR
@ ZSTD_reset_session_only
@ ZSTD_reset_session_and_parameters
ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict *ddict)
#define ZSTD_BLOCKSIZE_MAX
#define ZSTD_MAGIC_SKIPPABLE_START
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code)
void ZSTD_free(void *ptr, ZSTD_customMem customMem)
void * ZSTD_malloc(size_t size, ZSTD_customMem customMem)
ZSTD_DDict * ZSTD_createDDict_advanced(const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_customMem customMem)
void ZSTD_copyDDictParameters(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
const void * ZSTD_DDict_dictContent(const ZSTD_DDict *ddict)
size_t ZSTD_DDict_dictSize(const ZSTD_DDict *ddict)
size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx *dctx, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
static int ZSTD_DCtx_isOverflow(ZSTD_DStream *zds, size_t const neededInBuffSize, size_t const neededOutBuffSize)
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx)
size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
static ZSTD_frameSizeInfo ZSTD_findFrameSizeInfo(const void *src, size_t srcSize)
static size_t ZSTD_refDictContent(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, const ZSTD_DDict *ddict)
#define CHECK_DBOUNDS(p, v)
size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
ZSTD_DCtx * ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
static ZSTD_frameSizeInfo ZSTD_errorFrameSizeInfo(size_t ret)
ZSTD_DStream * ZSTD_createDStream(void)
size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
size_t ZSTD_freeDStream(ZSTD_DStream *zds)
size_t ZSTD_estimateDStreamSize_fromFrame(const void *src, size_t srcSize)
size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize)
ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx *dctx)
size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
static size_t ZSTD_frameHeaderSize_internal(const void *src, size_t srcSize, ZSTD_format_e format)
size_t ZSTD_decompressBegin(ZSTD_DCtx *dctx)
size_t ZSTD_estimateDCtxSize(void)
static size_t ZSTD_setRleBlock(void *dst, size_t dstCapacity, BYTE b, size_t regenSize)
ZSTD_DStream * ZSTD_createDStream_advanced(ZSTD_customMem customMem)
size_t ZSTD_freeDCtx(ZSTD_DCtx *dctx)
static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
size_t ZSTD_DCtx_reset(ZSTD_DCtx *dctx, ZSTD_ResetDirective reset)
size_t ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize)
unsigned long long ZSTD_getDecompressedSize(const void *src, size_t srcSize)
static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx *dctx, const void *src, size_t headerSize)
static size_t ZSTD_decompressContinueStream(ZSTD_DStream *zds, char **op, char *oend, void const *src, size_t srcSize)
size_t ZSTD_initDStream(ZSTD_DStream *zds)
size_t ZSTD_loadDEntropy(ZSTD_entropyDTables_t *entropy, const void *const dict, size_t const dictSize)
size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx *dctx)
size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize, ZSTD_format_e format)
ZSTD_DStream * ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
static size_t readSkippableFrameSize(void const *src, size_t srcSize)
void ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx)
static int ZSTD_isSkipFrame(ZSTD_DCtx *dctx)
static size_t ZSTD_decompressFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void **srcPtr, size_t *srcSizePtr)
size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
static void ZSTD_DCtx_updateOversizedDuration(ZSTD_DStream *zds, size_t const neededInBuffSize, size_t const neededOutBuffSize)
static size_t ZSTD_checkOutBuffer(ZSTD_DStream const *zds, ZSTD_outBuffer const *output)
unsigned ZSTD_getDictID_fromFrame(const void *src, size_t srcSize)
static size_t ZSTD_copyRawBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
size_t ZSTD_resetDStream(ZSTD_DStream *dctx)
static ZSTD_DDict const * ZSTD_getDDict(ZSTD_DCtx *dctx)
static void ZSTD_clearDict(ZSTD_DCtx *dctx)
size_t ZSTD_DCtx_setFormat(ZSTD_DCtx *dctx, ZSTD_format_e format)
size_t ZSTD_DStreamOutSize(void)
size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
size_t ZSTD_estimateDStreamSize(size_t windowSize)
unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
unsigned ZSTD_getDictID_fromDict(const void *dict, size_t dictSize)
size_t ZSTD_DCtx_refDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
static void ZSTD_initDCtx_internal(ZSTD_DCtx *dctx)
size_t ZSTD_decompress(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
static int ZSTD_DCtx_isOversizedTooLong(ZSTD_DStream *zds)
static int ZSTD_dParam_withinBounds(ZSTD_dParameter dParam, int value)
unsigned long long ZSTD_findDecompressedSize(const void *src, size_t srcSize)
static size_t ZSTD_nextSrcSizeToDecompressWithInputSize(ZSTD_DCtx *dctx, size_t inputSize)
size_t ZSTD_DStreamInSize(void)
size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
size_t ZSTD_initDStream_usingDDict(ZSTD_DStream *dctx, const ZSTD_DDict *ddict)
size_t ZSTD_getFrameHeader(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize)
size_t ZSTD_initDStream_usingDict(ZSTD_DStream *zds, const void *dict, size_t dictSize)
unsigned ZSTD_isFrame(const void *buffer, size_t size)
size_t ZSTD_decompressStream_simpleArgs(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, size_t *dstPos, const void *src, size_t srcSize, size_t *srcPos)
size_t ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSize)
size_t ZSTD_DCtx_setParameter(ZSTD_DCtx *dctx, ZSTD_dParameter dParam, int value)
size_t ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
ZSTD_DCtx * ZSTD_createDCtx(void)
unsigned long long ZSTD_decompressBound(const void *src, size_t srcSize)
size_t ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict)
static size_t ZSTD_startingInputLength(ZSTD_format_e format)
#define ZSTD_NO_FORWARD_PROGRESS_MAX
ZSTD_DCtx * ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx *dctx, size_t maxWindowSize)
size_t ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
#define ZSTD_MAXWINDOWSIZE_DEFAULT
size_t ZSTD_sizeof_DStream(const ZSTD_DStream *dctx)
size_t ZSTD_decompressBlock_internal(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const int frame)
size_t ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr)
void ZSTD_checkContinuity(ZSTD_DCtx *dctx, const void *dst)
void ZSTD_buildFSETable(ZSTD_seqSymbol *dt, const short *normalizedCounter, unsigned maxSymbolValue, const U32 *baseValue, const U32 *nbAdditionalBits, unsigned tableLog)
static const U32 ML_base[MaxML+1]
static const U32 OF_base[MaxOff+1]
static const U32 OF_bits[MaxOff+1]
@ ZSTDds_getFrameHeaderSize
@ ZSTDds_decodeBlockHeader
@ ZSTDds_decompressLastBlock
@ ZSTDds_decodeFrameHeader
@ ZSTDds_decodeSkippableHeader
static const U32 LL_base[MaxLL+1]
@ ZSTD_error_prefix_unknown
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION
#define FORWARD_IF_ERROR(err,...)
static const size_t ZSTD_blockHeaderSize
#define WILDCOPY_OVERLENGTH
#define ZSTD_WINDOWLOG_ABSOLUTEMIN
#define RETURN_ERROR_IF(cond, err,...)
static const U32 ML_bits[MaxML+1]
static const size_t ZSTD_did_fieldSize[4]
MEM_STATIC size_t ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize)
static const size_t ZSTD_fcs_fieldSize[4]
static const U32 repStartValue[ZSTD_REP_NUM]
static const U32 LL_bits[MaxLL+1]
#define ZSTD_STATIC_ASSERT(c)
#define ZSTD_WORKSPACETOOLARGE_FACTOR