• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/contrib/openzfs/module/zstd/lib/

Lines Matching refs:dctx

2319 size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);   /**< decodes RLE and uncompressed */
2320 size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */
2321 size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */
2322 size_t HUF_decompress4X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
2323 size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
2325 size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
2326 size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
2466 size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
2467 size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize);
2469 size_t HUF_decompress1X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
2470 size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
2473 size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
2474 size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
2490 size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
2493 size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
3305 ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
3312 ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
3636 ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value);
3644 ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset);
3889 ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
3944 ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
4058 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
4069 ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
4087 ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
4096 ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
4430 * Limitation 3 : static dctx is incompatible with legacy support.
4709 * but references `dict` content instead of copying it into `dctx`.
4712 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
4719 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
4724 ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
4733 ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
4777 ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
4786 ZSTD_DCtx* dctx,
5118 ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
5119 ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
5120 ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
5122 ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
5123 ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
5126 ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
5128 ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
5167 ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
5168 ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
6736 size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
21765 static size_t HUF_decompress4X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
21771 size_t const hSize = HUF_readDTableX1_wksp (dctx, cSrc, cSrcSize,
21777 return HUF_decompress4X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
21780 size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
21784 return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, 0);
21788 size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
21791 return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
22266 static size_t HUF_decompress4X2_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
22272 size_t hSize = HUF_readDTableX2_wksp(dctx, cSrc, cSrcSize,
22278 return HUF_decompress4X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
22281 size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
22285 return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, /* bmi2 */ 0);
22289 size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
22293 return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
22432 size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
22444 return HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
22448 return HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
22450 return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
22451 HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
22456 size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
22459 return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
22464 size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst,
22477 return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
22481 return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
22483 return algoNb ? HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
22485 HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
22490 size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
22504 return HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc,
22509 return HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
22512 return algoNb ? HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
22514 HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc,
22520 size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
22524 return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
22547 size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
22551 size_t const hSize = HUF_readDTableX1_wksp(dctx, cSrc, cSrcSize, workSpace, wkspSize);
22556 return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
22577 size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
22587 return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
22591 return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
22593 return algoNb ? HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2) :
22594 HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
22809 void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst);
22854 void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
22955 size_t ZSTDv01_freeDCtx(ZSTDv01_Dctx* dctx);
22964 size_t ZSTDv01_resetDCtx(ZSTDv01_Dctx* dctx);
22966 size_t ZSTDv01_nextSrcSizeToDecompress(ZSTDv01_Dctx* dctx);
22967 size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
23053 size_t ZSTDv02_freeDCtx(ZSTDv02_Dctx* dctx);
23062 size_t ZSTDv02_resetDCtx(ZSTDv02_Dctx* dctx);
23064 size_t ZSTDv02_nextSrcSizeToDecompress(ZSTDv02_Dctx* dctx);
23065 size_t ZSTDv02_decompressContinue(ZSTDv02_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
23150 size_t ZSTDv03_freeDCtx(ZSTDv03_Dctx* dctx);
23159 size_t ZSTDv03_resetDCtx(ZSTDv03_Dctx* dctx);
23161 size_t ZSTDv03_nextSrcSizeToDecompress(ZSTDv03_Dctx* dctx);
23162 size_t ZSTDv03_decompressContinue(ZSTDv03_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
23247 size_t ZSTDv04_freeDCtx(ZSTDv04_Dctx* dctx);
23249 size_t ZSTDv04_decompressDCtx(ZSTDv04_Dctx* dctx,
23257 size_t ZSTDv04_resetDCtx(ZSTDv04_Dctx* dctx);
23259 size_t ZSTDv04_nextSrcSizeToDecompress(ZSTDv04_Dctx* dctx);
23260 size_t ZSTDv04_decompressContinue(ZSTDv04_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
23275 size_t ZBUFFv04_freeDCtx(ZBUFFv04_DCtx* dctx);
23277 size_t ZBUFFv04_decompressInit(ZBUFFv04_DCtx* dctx);
23278 size_t ZBUFFv04_decompressWithDictionary(ZBUFFv04_DCtx* dctx, const void* dict, size_t dictSize);
23280 size_t ZBUFFv04_decompressContinue(ZBUFFv04_DCtx* dctx, void* dst, size_t* maxDstSizePtr, const void* src, size_t* srcSizePtr);
23394 size_t ZSTDv05_freeDCtx(ZSTDv05_DCtx* dctx); /*!< @return : errorCode */
23408 size_t ZSTDv05_decompress_usingDict(ZSTDv05_DCtx* dctx,
23424 size_t ZSTDv05_decompressBegin_usingDict(ZSTDv05_DCtx* dctx, const void* dict, size_t dictSize);
23426 size_t ZSTDv05_nextSrcSizeToDecompress(ZSTDv05_DCtx* dctx);
23427 size_t ZSTDv05_decompressContinue(ZSTDv05_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
23435 size_t ZBUFFv05_freeDCtx(ZBUFFv05_DCtx* dctx);
23437 size_t ZBUFFv05_decompressInit(ZBUFFv05_DCtx* dctx);
23438 size_t ZBUFFv05_decompressInitDictionary(ZBUFFv05_DCtx* dctx, const void* dict, size_t dictSize);
23440 size_t ZBUFFv05_decompressContinue(ZBUFFv05_DCtx* dctx,
23571 ZSTDLIBv06_API size_t ZSTDv06_freeDCtx(ZSTDv06_DCtx* dctx); /*!< @return : errorCode */
23585 ZSTDLIBv06_API size_t ZSTDv06_decompress_usingDict(ZSTDv06_DCtx* dctx,
23598 ZSTDLIBv06_API size_t ZSTDv06_decompressBegin_usingDict(ZSTDv06_DCtx* dctx, const void* dict, size_t dictSize);
23599 ZSTDLIBv06_API void ZSTDv06_copyDCtx(ZSTDv06_DCtx* dctx, const ZSTDv06_DCtx* preparedDCtx);
23601 ZSTDLIBv06_API size_t ZSTDv06_nextSrcSizeToDecompress(ZSTDv06_DCtx* dctx);
23602 ZSTDLIBv06_API size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
23612 ZSTDLIBv06_API size_t ZBUFFv06_freeDCtx(ZBUFFv06_DCtx* dctx);
23614 ZSTDLIBv06_API size_t ZBUFFv06_decompressInit(ZBUFFv06_DCtx* dctx);
23615 ZSTDLIBv06_API size_t ZBUFFv06_decompressInitDictionary(ZBUFFv06_DCtx* dctx, const void* dict, size_t dictSize);
23617 ZSTDLIBv06_API size_t ZBUFFv06_decompressContinue(ZBUFFv06_DCtx* dctx,
23749 ZSTDLIBv07_API size_t ZSTDv07_freeDCtx(ZSTDv07_DCtx* dctx); /*!< @return : errorCode */
23763 ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDict(ZSTDv07_DCtx* dctx,
23782 ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
23804 ZSTDLIBv07_API size_t ZBUFFv07_freeDCtx(ZBUFFv07_DCtx* dctx);
23806 ZSTDLIBv07_API size_t ZBUFFv07_decompressInit(ZBUFFv07_DCtx* dctx);
23807 ZSTDLIBv07_API size_t ZBUFFv07_decompressInitDictionary(ZBUFFv07_DCtx* dctx, const void* dict, size_t dictSize);
23809 ZSTDLIBv07_API size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* dctx,
24108 ZBUFFv04_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv04_createDCtx() : (ZBUFFv04_DCtx*)*legacyContext;
24109 if (dctx==NULL) return ERROR(memory_allocation);
24110 ZBUFFv04_decompressInit(dctx);
24111 ZBUFFv04_decompressWithDictionary(dctx, dict, dictSize);
24112 *legacyContext = dctx;
24119 ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext;
24120 if (dctx==NULL) return ERROR(memory_allocation);
24121 ZBUFFv05_decompressInitDictionary(dctx, dict, dictSize);
24122 *legacyContext = dctx;
24129 ZBUFFv06_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv06_createDCtx() : (ZBUFFv06_DCtx*)*legacyContext;
24130 if (dctx==NULL) return ERROR(memory_allocation);
24131 ZBUFFv06_decompressInitDictionary(dctx, dict, dictSize);
24132 *legacyContext = dctx;
24139 ZBUFFv07_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv07_createDCtx() : (ZBUFFv07_DCtx*)*legacyContext;
24140 if (dctx==NULL) return ERROR(memory_allocation);
24141 ZBUFFv07_decompressInitDictionary(dctx, dict, dictSize);
24142 *legacyContext = dctx;
24166 ZBUFFv04_DCtx* dctx = (ZBUFFv04_DCtx*) legacyContext;
24171 size_t const hintSize = ZBUFFv04_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
24180 ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext;
24185 size_t const hintSize = ZBUFFv05_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
24194 ZBUFFv06_DCtx* dctx = (ZBUFFv06_DCtx*) legacyContext;
24199 size_t const hintSize = ZBUFFv06_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
24208 ZBUFFv07_DCtx* dctx = (ZBUFFv07_DCtx*) legacyContext;
24213 size_t const hintSize = ZBUFFv07_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
24258 void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
24261 assert(dctx != NULL);
24263 dctx->dictID = ddict->dictID;
24264 dctx->prefixStart = ddict->dictContent;
24265 dctx->virtualStart = ddict->dictContent;
24266 dctx->dictEnd = (const BYTE*)ddict->dictContent + ddict->dictSize;
24267 dctx->previousDstEnd = dctx->dictEnd;
24269 dctx->dictContentBeginForFuzzing = dctx->prefixStart;
24270 dctx->dictContentEndForFuzzing = dctx->previousDstEnd;
24273 dctx->litEntropy = 1;
24274 dctx->fseEntropy = 1;
24275 dctx->LLTptr = ddict->entropy.LLTable;
24276 dctx->MLTptr = ddict->entropy.MLTable;
24277 dctx->OFTptr = ddict->entropy.OFTable;
24278 dctx->HUFptr = ddict->entropy.hufTable;
24279 dctx->entropy.rep[0] = ddict->entropy.rep[0];
24280 dctx->entropy.rep[1] = ddict->entropy.rep[1];
24281 dctx->entropy.rep[2] = ddict->entropy.rep[2];
24283 dctx->litEntropy = 0;
24284 dctx->fseEntropy = 0;
24556 size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
24584 size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx)
24586 if (dctx==NULL) return 0; /* support sizeof NULL */
24587 return sizeof(*dctx)
24588 + ZSTD_sizeof_DDict(dctx->ddictLocal)
24589 + dctx->inBuffSize + dctx->outBuffSize;
24603 static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
24605 dctx->format = ZSTD_f_zstd1; /* ZSTD_decompressBegin() invokes ZSTD_startingInputLength() with argument dctx->format */
24606 dctx->staticSize = 0;
24607 dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
24608 dctx->ddict = NULL;
24609 dctx->ddictLocal = NULL;
24610 dctx->dictEnd = NULL;
24611 dctx->ddictIsCold = 0;
24612 dctx->dictUses = ZSTD_dont_use;
24613 dctx->inBuff = NULL;
24614 dctx->inBuffSize = 0;
24615 dctx->outBuffSize = 0;
24616 dctx->streamStage = zdss_init;
24617 dctx->legacyContext = NULL;
24618 dctx->previousLegacyVersion = 0;
24619 dctx->noForwardProgress = 0;
24620 dctx->oversizedDuration = 0;
24621 dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
24622 dctx->outBufferMode = ZSTD_obm_buffered;
24624 dctx->dictContentEndForFuzzing = NULL;
24630 ZSTD_DCtx* const dctx = (ZSTD_DCtx*) workspace;
24635 ZSTD_initDCtx_internal(dctx);
24636 dctx->staticSize = workspaceSize;
24637 dctx->inBuff = (char*)(dctx+1);
24638 return dctx;
24645 { ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(*dctx), customMem);
24646 if (!dctx) return NULL;
24647 dctx->customMem = customMem;
24648 ZSTD_initDCtx_internal(dctx);
24649 return dctx;
24659 static void ZSTD_clearDict(ZSTD_DCtx* dctx)
24661 ZSTD_freeDDict(dctx->ddictLocal);
24662 dctx->ddictLocal = NULL;
24663 dctx->ddict = NULL;
24664 dctx->dictUses = ZSTD_dont_use;
24667 size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
24669 if (dctx==NULL) return 0; /* support free on NULL */
24670 RETURN_ERROR_IF(dctx->staticSize, memory_allocation, "not compatible with static DCtx");
24671 { ZSTD_customMem const cMem = dctx->customMem;
24672 ZSTD_clearDict(dctx);
24673 ZSTD_free(dctx->inBuff, cMem);
24674 dctx->inBuff = NULL;
24676 if (dctx->legacyContext)
24677 ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
24679 ZSTD_free(dctx, cMem);
24943 static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t headerSize)
24945 size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
24952 RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
24955 if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0);
25074 * insert `src` block into `dctx` history. Useful to track uncompressed blocks. */
25075 size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize)
25078 ZSTD_checkContinuity(dctx, blockStart);
25079 dctx->previousDstEnd = (const char*)blockStart + blockSize;
25112 * @dctx must be properly initialized
25115 static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
25129 remainingSrcSize < ZSTD_FRAMEHEADERSIZE_MIN(dctx->format)+ZSTD_blockHeaderSize,
25134 ip, ZSTD_FRAMEHEADERSIZE_PREFIX(dctx->format), dctx->format);
25138 FORWARD_IF_ERROR( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) , "");
25156 decodedSize = ZSTD_decompressBlock_internal(dctx, op, oend-op, ip, cBlockSize, /* frame */ 1);
25170 if (dctx->fParams.checksumFlag)
25171 XXH64_update(&dctx->xxhState, op, decodedSize);
25180 if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
25181 RETURN_ERROR_IF((U64)(op-ostart) != dctx->fParams.frameContentSize,
25184 if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
25185 U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
25200 static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
25217 while (srcSize >= ZSTD_startingInputLength(dctx->format)) {
25224 RETURN_ERROR_IF(dctx->staticSize, memory_allocation,
25225 "legacy support is not compatible with static dctx");
25256 FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDDict(dctx, ddict), "");
25260 FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize), "");
25262 ZSTD_checkContinuity(dctx, dst);
25264 { const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity,
25293 size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
25298 return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL);
25302 static ZSTD_DDict const* ZSTD_getDDict(ZSTD_DCtx* dctx)
25304 switch (dctx->dictUses) {
25309 ZSTD_clearDict(dctx);
25312 return dctx->ddict;
25314 dctx->dictUses = ZSTD_dont_use;
25315 return dctx->ddict;
25319 size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
25321 return ZSTD_decompress_usingDDict(dctx, dst, dstCapacity, src, srcSize, ZSTD_getDDict(dctx));
25329 ZSTD_DCtx* const dctx = ZSTD_createDCtx();
25330 RETURN_ERROR_IF(dctx==NULL, memory_allocation, "NULL pointer!");
25331 regenSize = ZSTD_decompressDCtx(dctx, dst, dstCapacity, src, srcSize);
25332 ZSTD_freeDCtx(dctx);
25335 ZSTD_DCtx dctx;
25336 ZSTD_initDCtx_internal(&dctx);
25337 return ZSTD_decompressDCtx(&dctx, dst, dstCapacity, src, srcSize);
25346 size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx) { return dctx->expected; }
25358 static size_t ZSTD_nextSrcSizeToDecompressWithInputSize(ZSTD_DCtx* dctx, size_t inputSize) {
25359 if (!(dctx->stage == ZSTDds_decompressBlock || dctx->stage == ZSTDds_decompressLastBlock))
25360 return dctx->expected;
25361 if (dctx->bType != bt_raw)
25362 return dctx->expected;
25363 return MIN(MAX(inputSize, 1), dctx->expected);
25366 ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
25367 switch(dctx->stage)
25388 static int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; }
25394 size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
25398 RETURN_ERROR_IF(srcSize != ZSTD_nextSrcSizeToDecompressWithInputSize(dctx, srcSize), srcSize_wrong, "not allowed");
25399 if (dstCapacity) ZSTD_checkContinuity(dctx, dst);
25401 switch (dctx->stage)
25405 if (dctx->format == ZSTD_f_zstd1) { /* allows header */
25408 memcpy(dctx->headerBuffer, src, srcSize);
25409 dctx->expected = ZSTD_SKIPPABLEHEADERSIZE - srcSize; /* remaining to load to get full skippable frame header */
25410 dctx->stage = ZSTDds_decodeSkippableHeader;
25413 dctx->headerSize = ZSTD_frameHeaderSize_internal(src, srcSize, dctx->format);
25414 if (ZSTD_isError(dctx->headerSize)) return dctx->headerSize;
25415 memcpy(dctx->headerBuffer, src, srcSize);
25416 dctx->expected = dctx->headerSize - srcSize;
25417 dctx->stage = ZSTDds_decodeFrameHeader;
25422 memcpy(dctx->headerBuffer + (dctx->headerSize - srcSize), src, srcSize);
25423 FORWARD_IF_ERROR(ZSTD_decodeFrameHeader(dctx, dctx->headerBuffer, dctx->headerSize), "");
25424 dctx->expected = ZSTD_blockHeaderSize;
25425 dctx->stage = ZSTDds_decodeBlockHeader;
25432 RETURN_ERROR_IF(cBlockSize > dctx->fParams.blockSizeMax, corruption_detected, "Block Size Exceeds Maximum");
25433 dctx->expected = cBlockSize;
25434 dctx->bType = bp.blockType;
25435 dctx->rleSize = bp.origSize;
25437 dctx->stage = bp.lastBlock ? ZSTDds_decompressLastBlock : ZSTDds_decompressBlock;
25442 if (dctx->fParams.checksumFlag) {
25443 dctx->expected = 4;
25444 dctx->stage = ZSTDds_checkChecksum;
25446 dctx->expected = 0; /* end of frame */
25447 dctx->stage = ZSTDds_getFrameHeaderSize;
25450 dctx->expected = ZSTD_blockHeaderSize; /* jump to next header */
25451 dctx->stage = ZSTDds_decodeBlockHeader;
25460 switch(dctx->bType)
25464 rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1);
25465 dctx->expected = 0; /* Streaming not supported */
25468 assert(srcSize <= dctx->expected);
25472 dctx->expected -= rSize;
25475 rSize = ZSTD_setRleBlock(dst, dstCapacity, *(const BYTE*)src, dctx->rleSize);
25476 dctx->expected = 0; /* Streaming not supported */
25483 RETURN_ERROR_IF(rSize > dctx->fParams.blockSizeMax, corruption_detected, "Decompressed Block Size Exceeds Maximum");
25485 dctx->decodedSize += rSize;
25486 if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize);
25487 dctx->previousDstEnd = (char*)dst + rSize;
25490 if (dctx->expected > 0) {
25494 if (dctx->stage == ZSTDds_decompressLastBlock) { /* end of frame */
25495 DEBUGLOG(4, "ZSTD_decompressContinue: decoded size from frame : %u", (unsigned)dctx->decodedSize);
25497 dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN
25498 && dctx->decodedSize != dctx->fParams.frameContentSize,
25500 if (dctx->fParams.checksumFlag) { /* another round for frame checksum */
25501 dctx->expected = 4;
25502 dctx->stage = ZSTDds_checkChecksum;
25504 dctx->expected = 0; /* ends here */
25505 dctx->stage = ZSTDds_getFrameHeaderSize;
25508 dctx->stage = ZSTDds_decodeBlockHeader;
25509 dctx->expected = ZSTD_blockHeaderSize;
25515 assert(srcSize == 4); /* guaranteed by dctx->expected */
25516 { U32 const h32 = (U32)XXH64_digest(&dctx->xxhState);
25520 dctx->expected = 0;
25521 dctx->stage = ZSTDds_getFrameHeaderSize;
25528 memcpy(dctx->headerBuffer + (ZSTD_SKIPPABLEHEADERSIZE - srcSize), src, srcSize); /* complete skippable header */
25529 dctx->expected = MEM_readLE32(dctx->headerBuffer + ZSTD_FRAMEIDSIZE); /* note : dctx->expected can grow seriously large, beyond local buffer size */
25530 dctx->stage = ZSTDds_skipFrame;
25534 dctx->expected = 0;
25535 dctx->stage = ZSTDds_getFrameHeaderSize;
25545 static size_t ZSTD_refDictContent(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
25547 dctx->dictEnd = dctx->previousDstEnd;
25548 dctx->virtualStart = (const char*)dict - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
25549 dctx->prefixStart = dict;
25550 dctx->previousDstEnd = (const char*)dict + dictSize;
25552 dctx->dictContentBeginForFuzzing = dctx->prefixStart;
25553 dctx->dictContentEndForFuzzing = dctx->previousDstEnd;
25643 static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
25645 if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize);
25648 return ZSTD_refDictContent(dctx, dict, dictSize); /* pure content mode */
25650 dctx->dictID = MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE);
25653 { size_t const eSize = ZSTD_loadDEntropy(&dctx->entropy, dict, dictSize);
25658 dctx->litEntropy = dctx->fseEntropy = 1;
25661 return ZSTD_refDictContent(dctx, dict, dictSize);
25664 size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
25666 assert(dctx != NULL);
25667 dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */
25668 dctx->stage = ZSTDds_getFrameHeaderSize;
25669 dctx->decodedSize = 0;
25670 dctx->previousDstEnd = NULL;
25671 dctx->prefixStart = NULL;
25672 dctx->virtualStart = NULL;
25673 dctx->dictEnd = NULL;
25674 dctx->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
25675 dctx->litEntropy = dctx->fseEntropy = 0;
25676 dctx->dictID = 0;
25677 dctx->bType = bt_reserved;
25678 ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue));
25679 memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue)); /* initial repcodes */
25680 dctx->LLTptr = dctx->entropy.LLTable;
25681 dctx->MLTptr = dctx->entropy.MLTable;
25682 dctx->OFTptr = dctx->entropy.OFTable;
25683 dctx->HUFptr = dctx->entropy.hufTable;
25687 size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
25689 FORWARD_IF_ERROR( ZSTD_decompressBegin(dctx) , "");
25692 ZSTD_isError(ZSTD_decompress_insertDictionary(dctx, dict, dictSize)),
25700 size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
25703 assert(dctx != NULL);
25708 dctx->ddictIsCold = (dctx->dictEnd != dictEnd);
25710 dctx->ddictIsCold ? "~cold~" : "hot!");
25712 FORWARD_IF_ERROR( ZSTD_decompressBegin(dctx) , "");
25714 ZSTD_copyDDictParameters(dctx, ddict);
25755 size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
25761 return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
25798 size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx,
25803 RETURN_ERROR_IF(dctx->streamStage != zdss_init, stage_wrong, "");
25804 ZSTD_clearDict(dctx);
25806 dctx->ddictLocal = ZSTD_createDDict_advanced(dict, dictSize, dictLoadMethod, dictContentType, dctx->customMem);
25807 RETURN_ERROR_IF(dctx->ddictLocal == NULL, memory_allocation, "NULL pointer!");
25808 dctx->ddict = dctx->ddictLocal;
25809 dctx->dictUses = ZSTD_use_indefinitely;
25814 size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
25816 return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto);
25819 size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
25821 return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto);
25824 size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
25826 FORWARD_IF_ERROR(ZSTD_DCtx_loadDictionary_advanced(dctx, prefix, prefixSize, ZSTD_dlm_byRef, dictContentType), "");
25827 dctx->dictUses = ZSTD_use_once;
25831 size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize)
25833 return ZSTD_DCtx_refPrefix_advanced(dctx, prefix, prefixSize, ZSTD_dct_rawContent);
25858 size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
25860 FORWARD_IF_ERROR( ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only) , "");
25861 FORWARD_IF_ERROR( ZSTD_DCtx_refDDict(dctx, ddict) , "");
25862 return ZSTD_startingInputLength(dctx->format);
25868 size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
25870 FORWARD_IF_ERROR(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only), "");
25871 return ZSTD_startingInputLength(dctx->format);
25875 size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
25877 RETURN_ERROR_IF(dctx->streamStage != zdss_init, stage_wrong, "");
25878 ZSTD_clearDict(dctx);
25880 dctx->ddict = ddict;
25881 dctx->dictUses = ZSTD_use_indefinitely;
25889 size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize)
25894 RETURN_ERROR_IF(dctx->streamStage != zdss_init, stage_wrong, "");
25897 dctx->maxWindowSize = maxWindowSize;
25901 size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
25903 return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format);
25945 size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter dParam, int value)
25947 RETURN_ERROR_IF(dctx->streamStage != zdss_init, stage_wrong, "");
25952 dctx->maxWindowSize = ((size_t)1) << value;
25956 dctx->format = (ZSTD_format_e)value;
25960 dctx->outBufferMode = (ZSTD_outBufferMode_e)value;
25967 size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset)
25971 dctx->streamStage = zdss_init;
25972 dctx->noForwardProgress = 0;
25976 RETURN_ERROR_IF(dctx->streamStage != zdss_init, stage_wrong, "");
25977 ZSTD_clearDict(dctx);
25978 dctx->format = ZSTD_f_zstd1;
25979 dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
25985 size_t ZSTD_sizeof_DStream(const ZSTD_DStream* dctx)
25987 return ZSTD_sizeof_DCtx(dctx);
26011 U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; /* note : should be user-selectable, but requires an additional parameter (or a dctx) */
26137 "legacy support is incompatible with static dctx");
26154 "legacy support is incompatible with static dctx");
26380 ZSTD_DCtx* dctx,
26387 size_t const cErr = ZSTD_decompressStream(dctx, &output, &input);
26467 size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
26472 size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
26485 RETURN_ERROR_IF(dctx->litEntropy==0, dictionary_corrupted, "");
26521 if (dctx->ddictIsCold && (litSize > 768 /* heuristic */)) {
26522 PREFETCH_AREA(dctx->HUFptr, sizeof(dctx->entropy.hufTable));
26528 dctx->litBuffer, litSize, istart+lhSize, litCSize,
26529 dctx->HUFptr, dctx->bmi2);
26532 dctx->litBuffer, litSize, istart+lhSize, litCSize,
26533 dctx->HUFptr, dctx->bmi2);
26539 dctx->entropy.hufTable, dctx->litBuffer, litSize,
26540 istart+lhSize, litCSize, dctx->workspace,
26541 sizeof(dctx->workspace));
26544 dctx->entropy.hufTable, dctx->litBuffer, litSize,
26545 istart+lhSize, litCSize, dctx->workspace,
26546 sizeof(dctx->workspace), dctx->bmi2);
26550 dctx->entropy.hufTable, dctx->litBuffer, litSize,
26551 istart+lhSize, litCSize, dctx->workspace,
26552 sizeof(dctx->workspace), dctx->bmi2);
26558 dctx->litPtr = dctx->litBuffer;
26559 dctx->litSize = litSize;
26560 dctx->litEntropy = 1;
26561 if (litEncType==set_compressed) dctx->HUFptr = dctx->entropy.hufTable;
26562 memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
26587 memcpy(dctx->litBuffer, istart+lhSize, litSize);
26588 dctx->litPtr = dctx->litBuffer;
26589 dctx->litSize = litSize;
26590 memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
26594 dctx->litPtr = istart+lhSize;
26595 dctx->litSize = litSize;
26619 memset(dctx->litBuffer, istart[lhSize], litSize + WILDCOPY_OVERLENGTH);
26620 dctx->litPtr = dctx->litBuffer;
26621 dctx->litSize = litSize;
26873 size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
26911 { size_t const llhSize = ZSTD_buildSeqTable(dctx->entropy.LLTable, &dctx->LLTptr,
26915 LL_defaultDTable, dctx->fseEntropy,
26916 dctx->ddictIsCold, nbSeq);
26921 { size_t const ofhSize = ZSTD_buildSeqTable(dctx->entropy.OFTable, &dctx->OFTptr,
26925 OF_defaultDTable, dctx->fseEntropy,
26926 dctx->ddictIsCold, nbSeq);
26931 { size_t const mlhSize = ZSTD_buildSeqTable(dctx->entropy.MLTable, &dctx->MLTptr,
26935 ML_defaultDTable, dctx->fseEntropy,
26936 dctx->ddictIsCold, nbSeq);
27344 static int ZSTD_dictionaryIsActive(ZSTD_DCtx const* dctx, BYTE const* prefixStart, BYTE const* oLitEnd)
27346 size_t const windowSize = dctx->fParams.windowSize;
27348 if (dctx->dictContentEndForFuzzing == NULL) return 0;
27350 if (prefixStart == dctx->dictContentBeginForFuzzing) return 1;
27352 if (dctx->dictEnd != dctx->dictContentEndForFuzzing) return 0;
27360 ZSTD_DCtx const* dctx,
27365 size_t const windowSize = dctx->fParams.windowSize;
27373 if (ZSTD_dictionaryIsActive(dctx, prefixStart, oLitEnd)) {
27374 size_t const dictSize = (size_t)((char const*)dctx->dictContentEndForFuzzing - (char const*)dctx->dictContentBeginForFuzzing);
27388 ZSTD_decompressSequences_body( ZSTD_DCtx* dctx,
27399 const BYTE* litPtr = dctx->litPtr;
27400 const BYTE* const litEnd = litPtr + dctx->litSize;
27401 const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
27402 const BYTE* const vBase = (const BYTE*) (dctx->virtualStart);
27403 const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
27411 dctx->fseEntropy = 1;
27412 { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
27416 ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
27417 ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
27418 ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
27472 if (frame) ZSTD_assertValidSequence(dctx, op, oend, sequence, prefixStart, vBase);
27493 { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
27509 ZSTD_decompressSequences_default(ZSTD_DCtx* dctx,
27515 return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27522 ZSTD_DCtx* dctx,
27533 const BYTE* litPtr = dctx->litPtr;
27534 const BYTE* const litEnd = litPtr + dctx->litSize;
27535 const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
27536 const BYTE* const dictStart = (const BYTE*) (dctx->virtualStart);
27537 const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
27549 dctx->fseEntropy = 1;
27550 { int i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
27559 ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
27560 ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
27561 ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
27576 if (frame) ZSTD_assertValidSequence(dctx, op, oend, sequences[(seqNb-ADVANCED_SEQS) & STORED_SEQS_MASK], prefixStart, dictStart);
27591 if (frame) ZSTD_assertValidSequence(dctx, op, oend, sequences[seqNb&STORED_SEQS_MASK], prefixStart, dictStart);
27598 { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
27614 ZSTD_decompressSequencesLong_default(ZSTD_DCtx* dctx,
27620 return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27631 ZSTD_decompressSequences_bmi2(ZSTD_DCtx* dctx,
27637 return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27643 ZSTD_decompressSequencesLong_bmi2(ZSTD_DCtx* dctx,
27649 return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27656 ZSTD_DCtx* dctx,
27664 ZSTD_decompressSequences(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize,
27671 if (dctx->bmi2) {
27672 return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27675 return ZSTD_decompressSequences_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27687 ZSTD_decompressSequencesLong(ZSTD_DCtx* dctx,
27695 if (dctx->bmi2) {
27696 return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27699 return ZSTD_decompressSequencesLong_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset, frame);
27734 ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
27745 ZSTD_longOffset_e const isLongOffset = (ZSTD_longOffset_e)(MEM_32bits() && (!frame || (dctx->fParams.windowSize > (1ULL << STREAM_ACCUMULATOR_MIN))));
27751 { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
27766 int usePrefetchDecoder = dctx->ddictIsCold;
27769 size_t const seqHSize = ZSTD_decodeSeqHeaders(dctx, &nbSeq, ip, srcSize);
27779 && (!frame || (dctx->fParams.windowSize > (1<<24)))
27781 U32 const shareLongOffsets = ZSTD_getLongOffsetsShare(dctx->OFTptr);
27787 dctx->ddictIsCold = 0;
27794 return ZSTD_decompressSequencesLong(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset, frame);
27799 return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset, frame);
27805 void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst)
27807 if (dst != dctx->previousDstEnd) { /* not contiguous */
27808 dctx->dictEnd = dctx->previousDstEnd;
27809 dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
27810 dctx->prefixStart = dst;
27811 dctx->previousDstEnd = dst;
27816 size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
27821 ZSTD_checkContinuity(dctx, dst);
27822 dSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 0);
27823 dctx->previousDstEnd = (char*)dst + dSize;