15#ifndef ZSTD_COMPRESS_H
16#define ZSTD_COMPRESS_H
21#include "../common/zstd_internal.h"
23#ifdef ZSTD_MULTITHREAD
26#include "../common/bits.h"
28#if defined (__cplusplus)
35#define kSearchStrength 8
36#define HASH_READ_SIZE 8
37#define ZSTD_DUBT_UNSORTED_MARK 1
62 ZSTD_dictContentType_e dictContentType;
75 FSE_repeat offcode_repeatMode;
76 FSE_repeat matchlength_repeatMode;
77 FSE_repeat litlength_repeatMode;
109 size_t fseTablesSize;
110 size_t lastCountSize;
125 const ZSTD_CCtx_params* cctxParams,
127 void* workspace,
size_t wkspSize);
147 size_t posInSequence;
171#define ZSTD_OPT_SIZE (ZSTD_OPT_NUM+3)
175 unsigned* litLengthFreq;
176 unsigned* matchLengthFreq;
177 unsigned* offCodeFreq;
186 U32 litLengthSumBasePrice;
187 U32 matchLengthSumBasePrice;
191 ZSTD_paramSwitch_e literalCompressionMode;
202 BYTE const* dictBase;
205 U32 nbOverflowCorrections;
211#define ZSTD_WINDOW_START_INDEX 2
215#define ZSTD_ROW_HASH_CACHE_SIZE 8
280#define LDM_BATCH_SIZE 64
292 ZSTD_paramSwitch_e enableLdm;
301 int collectSequences;
302 ZSTD_Sequence* seqStart;
377#define COMPRESS_SEQUENCES_WORKSPACE_SIZE (sizeof(unsigned) * (MaxSeq + 2))
378#define ENTROPY_WORKSPACE_SIZE (HUF_WORKSPACE_SIZE + COMPRESS_SEQUENCES_WORKSPACE_SIZE)
394#define ZSTD_MAX_NB_BLOCK_SPLITS 196
464#ifdef ZSTD_MULTITHREAD
470 ZSTD_TraceCtx traceCtx;
513 void const* src,
size_t srcSize);
519 static const BYTE LL_Code[64] = { 0, 1, 2, 3, 4, 5, 6, 7,
520 8, 9, 10, 11, 12, 13, 14, 15,
521 16, 16, 17, 17, 18, 18, 19, 19,
522 20, 20, 20, 20, 21, 21, 21, 21,
523 22, 22, 22, 22, 22, 22, 22, 22,
524 23, 23, 23, 23, 23, 23, 23, 23,
525 24, 24, 24, 24, 24, 24, 24, 24,
526 24, 24, 24, 24, 24, 24, 24, 24 };
527 static const U32 LL_deltaCode = 19;
528 return (litLength > 63) ?
ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
536 static const BYTE ML_Code[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
537 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
538 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37,
539 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39,
540 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
541 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
542 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
543 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 };
544 static const U32 ML_deltaCode = 36;
566 U32 const cBlockHeader24 = lastBlock + (((
U32)
bt_raw)<<1) + (
U32)(srcSize << 3);
567 DEBUGLOG(5,
"ZSTD_noCompressBlock (srcSize=%zu, dstCapacity=%zu)", srcSize, dstCapacity);
569 dstSize_tooSmall,
"dst buf too small for uncompressed block");
572 return ZSTD_blockHeaderSize + srcSize;
579 U32 const cBlockHeader = lastBlock + (((
U32)
bt_rle)<<1) + (
U32)(srcSize << 3);
596 return (srcSize >> minlog) + 2;
601 switch (cctxParams->literalCompressionMode) {
604 case ZSTD_ps_disable:
610 return (cctxParams->cParams.strategy ==
ZSTD_fast) && (cctxParams->cParams.targetLength > 0);
620ZSTD_safecopyLiterals(
BYTE* op,
BYTE const* ip,
BYTE const*
const iend,
BYTE const* ilimit_w)
623 if (ip <= ilimit_w) {
628 while (ip < iend) *op++ = *ip++;
632#define REPCODE1_TO_OFFBASE REPCODE_TO_OFFBASE(1)
633#define REPCODE2_TO_OFFBASE REPCODE_TO_OFFBASE(2)
634#define REPCODE3_TO_OFFBASE REPCODE_TO_OFFBASE(3)
635#define REPCODE_TO_OFFBASE(r) (assert((r)>=1), assert((r)<=ZSTD_REP_NUM), (r))
636#define OFFSET_TO_OFFBASE(o) (assert((o)>0), o + ZSTD_REP_NUM)
637#define OFFBASE_IS_OFFSET(o) ((o) > ZSTD_REP_NUM)
638#define OFFBASE_IS_REPCODE(o) ( 1 <= (o) && (o) <= ZSTD_REP_NUM)
639#define OFFBASE_TO_OFFSET(o) (assert(OFFBASE_IS_OFFSET(o)), (o) - ZSTD_REP_NUM)
640#define OFFBASE_TO_REPCODE(o) (assert(OFFBASE_IS_REPCODE(o)), (o))
650 size_t litLength,
const BYTE* literals,
const BYTE* litLimit,
655 BYTE const*
const litEnd = literals + litLength;
656#if defined(DEBUGLEVEL) && (DEBUGLEVEL >= 6)
657 static const BYTE* g_start = NULL;
658 if (g_start==NULL) g_start = (
const BYTE*)literals;
659 {
U32 const pos = (
U32)((
const BYTE*)literals - g_start);
660 DEBUGLOG(6,
"Cpos%7u :%3u literals, match%4u bytes at offBase%7u",
661 pos, (
U32)litLength, (
U32)matchLength, (
U32)offBase);
667 assert(seqStorePtr->
lit + litLength <= seqStorePtr->litStart + seqStorePtr->
maxNbLit);
668 assert(literals + litLength <= litLimit);
669 if (litEnd <= litLimit_w) {
674 ZSTD_copy16(seqStorePtr->
lit, literals);
675 if (litLength > 16) {
679 ZSTD_safecopyLiterals(seqStorePtr->
lit, literals, litEnd, litLimit_w);
681 seqStorePtr->
lit += litLength;
684 if (litLength>0xFFFF) {
696 {
size_t const mlBase = matchLength -
MINMATCH;
722 U32 const currentOffset = (repCode==
ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
723 rep[2] = (repCode >= 2) ? rep[1] : rep[2];
725 rep[0] = currentOffset;
751 const BYTE*
const pStart = pIn;
752 const BYTE*
const pInLoopLimit = pInLimit - (
sizeof(size_t)-1);
754 if (pIn < pInLoopLimit) {
757 pIn+=
sizeof(size_t); pMatch+=
sizeof(size_t);
758 while (pIn < pInLoopLimit) {
760 if (!diff) { pIn+=
sizeof(size_t); pMatch+=
sizeof(size_t);
continue; }
762 return (
size_t)(pIn - pStart);
766 if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
767 return (
size_t)(pIn - pStart);
778 const BYTE*
const vEnd =
MIN( ip + (mEnd - match), iEnd);
779 size_t const matchLength =
ZSTD_count(ip, match, vEnd);
780 if (match + matchLength != mEnd)
return matchLength;
781 DEBUGLOG(7,
"ZSTD_count_2segments: found a 2-parts match (current length==%zu)", matchLength);
782 DEBUGLOG(7,
"distance from match beginning to end dictionary = %zi", mEnd - match);
783 DEBUGLOG(7,
"distance from current pos to end buffer = %zi", iEnd - ip);
784 DEBUGLOG(7,
"next byte : ip==%02X, istart==%02X", ip[matchLength], *iStart);
785 DEBUGLOG(7,
"final match length = %zu", matchLength +
ZSTD_count(ip+matchLength, iStart, iEnd));
786 return matchLength +
ZSTD_count(ip+matchLength, iStart, iEnd);
793static const U32 prime3bytes = 506832829U;
794static U32 ZSTD_hash3(
U32 u,
U32 h,
U32 s) {
assert(h <= 32);
return (((u << (32-24)) * prime3bytes) ^ s) >> (32-h) ; }
798static const U32 prime4bytes = 2654435761U;
799static U32 ZSTD_hash4(
U32 u,
U32 h,
U32 s) {
assert(h <= 32);
return ((u * prime4bytes) ^ s) >> (32-h) ; }
800static size_t ZSTD_hash4Ptr(
const void* ptr,
U32 h) {
return ZSTD_hash4(
MEM_readLE32(ptr), h, 0); }
801static size_t ZSTD_hash4PtrS(
const void* ptr,
U32 h,
U32 s) {
return ZSTD_hash4(
MEM_readLE32(ptr), h, s); }
803static const U64 prime5bytes = 889523592379ULL;
804static size_t ZSTD_hash5(
U64 u,
U32 h,
U64 s) {
assert(h <= 64);
return (
size_t)((((u << (64-40)) * prime5bytes) ^ s) >> (64-h)) ; }
805static size_t ZSTD_hash5Ptr(
const void* p,
U32 h) {
return ZSTD_hash5(
MEM_readLE64(p), h, 0); }
806static size_t ZSTD_hash5PtrS(
const void* p,
U32 h,
U64 s) {
return ZSTD_hash5(
MEM_readLE64(p), h, s); }
808static const U64 prime6bytes = 227718039650203ULL;
809static size_t ZSTD_hash6(
U64 u,
U32 h,
U64 s) {
assert(h <= 64);
return (
size_t)((((u << (64-48)) * prime6bytes) ^ s) >> (64-h)) ; }
810static size_t ZSTD_hash6Ptr(
const void* p,
U32 h) {
return ZSTD_hash6(
MEM_readLE64(p), h, 0); }
811static size_t ZSTD_hash6PtrS(
const void* p,
U32 h,
U64 s) {
return ZSTD_hash6(
MEM_readLE64(p), h, s); }
813static const U64 prime7bytes = 58295818150454627ULL;
814static size_t ZSTD_hash7(
U64 u,
U32 h,
U64 s) {
assert(h <= 64);
return (
size_t)((((u << (64-56)) * prime7bytes) ^ s) >> (64-h)) ; }
815static size_t ZSTD_hash7Ptr(
const void* p,
U32 h) {
return ZSTD_hash7(
MEM_readLE64(p), h, 0); }
816static size_t ZSTD_hash7PtrS(
const void* p,
U32 h,
U64 s) {
return ZSTD_hash7(
MEM_readLE64(p), h, s); }
818static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL;
819static size_t ZSTD_hash8(
U64 u,
U32 h,
U64 s) {
assert(h <= 64);
return (
size_t)((((u) * prime8bytes) ^ s) >> (64-h)) ; }
820static size_t ZSTD_hash8Ptr(
const void* p,
U32 h) {
return ZSTD_hash8(
MEM_readLE64(p), h, 0); }
821static size_t ZSTD_hash8PtrS(
const void* p,
U32 h,
U64 s) {
return ZSTD_hash8(
MEM_readLE64(p), h, s); }
834 case 4:
return ZSTD_hash4Ptr(p, hBits);
835 case 5:
return ZSTD_hash5Ptr(p, hBits);
836 case 6:
return ZSTD_hash6Ptr(p, hBits);
837 case 7:
return ZSTD_hash7Ptr(p, hBits);
838 case 8:
return ZSTD_hash8Ptr(p, hBits);
851 case 4:
return ZSTD_hash4PtrS(p, hBits, (
U32)hashSalt);
852 case 5:
return ZSTD_hash5PtrS(p, hBits, hashSalt);
853 case 6:
return ZSTD_hash6PtrS(p, hBits, hashSalt);
854 case 7:
return ZSTD_hash7PtrS(p, hBits, hashSalt);
855 case 8:
return ZSTD_hash8PtrS(p, hBits, hashSalt);
863static U64 ZSTD_ipow(
U64 base,
U64 exponent)
874#define ZSTD_ROLL_HASH_CHAR_OFFSET 10
879static U64 ZSTD_rollingHash_append(
U64 hash,
void const* buf,
size_t size)
881 BYTE const* istart = (
BYTE const*)buf;
883 for (pos = 0; pos <
size; ++pos) {
895 return ZSTD_rollingHash_append(0, buf,
size);
904 return ZSTD_ipow(prime8bytes, length - 1);
921#if (ZSTD_WINDOWLOG_MAX_64 > 31)
922# error "ZSTD_WINDOWLOG_MAX is too large : would overflow ZSTD_CURRENT_MAX"
925#define ZSTD_CURRENT_MAX ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
927#define ZSTD_CHUNKSIZE_MAX \
937 size_t const endT = (size_t)(
window->nextSrc -
window->base);
978#ifndef ZSTD_WINDOW_OVERFLOW_CORRECT_FREQUENTLY
979# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
980# define ZSTD_WINDOW_OVERFLOW_CORRECT_FREQUENTLY 1
982# define ZSTD_WINDOW_OVERFLOW_CORRECT_FREQUENTLY 0
997 U32 const cycleSize = 1u << cycleLog;
999 U32 const minIndexToOverflowCorrect = cycleSize
1000 +
MAX(maxDist, cycleSize)
1008 U32 const adjustment =
window.nbOverflowCorrections + 1;
1009 U32 const adjustedIndex =
MAX(minIndexToOverflowCorrect * adjustment,
1010 minIndexToOverflowCorrect);
1011 U32 const indexLargeEnough = curr > adjustedIndex;
1016 U32 const dictionaryInvalidated = curr > maxDist + loadedDictEnd;
1018 return indexLargeEnough && dictionaryInvalidated;
1054 U32 maxDist,
void const* src)
1075 U32 const cycleSize = 1u << cycleLog;
1076 U32 const cycleMask = cycleSize - 1;
1078 U32 const currentCycle =
curr & cycleMask;
1083 U32 const newCurrent = currentCycle
1084 + currentCycleCorrection
1085 +
MAX(maxDist, cycleSize);
1086 U32 const correction =
curr - newCurrent;
1091 assert((maxDist & (maxDist - 1)) == 0);
1092 assert((curr & cycleMask) == (newCurrent & cycleMask));
1093 assert(curr > newCurrent);
1096 assert(correction > 1<<28);
1099 window->base += correction;
1100 window->dictBase += correction;
1104 window->lowLimit -= correction;
1109 window->dictLimit -= correction;
1113 assert(newCurrent >= maxDist);
1119 ++
window->nbOverflowCorrections;
1121 DEBUGLOG(4,
"Correction of 0x%x bytes to lowLimit=0x%x", correction,
1151 const void* blockEnd,
1153 U32* loadedDictEndPtr,
1157 U32 const loadedDictEnd = (loadedDictEndPtr != NULL) ? *loadedDictEndPtr : 0;
1158 DEBUGLOG(5,
"ZSTD_window_enforceMaxDist: blockEndIdx=%u, maxDist=%u, loadedDictEnd=%u",
1159 (
unsigned)blockEndIdx, (
unsigned)maxDist, (
unsigned)loadedDictEnd);
1174 if (blockEndIdx > maxDist + loadedDictEnd) {
1175 U32 const newLowLimit = blockEndIdx - maxDist;
1176 if (
window->lowLimit < newLowLimit)
window->lowLimit = newLowLimit;
1178 DEBUGLOG(5,
"Update dictLimit to match lowLimit, from %u to %u",
1179 (
unsigned)
window->dictLimit, (
unsigned)
window->lowLimit);
1183 if (loadedDictEndPtr) *loadedDictEndPtr = 0;
1184 if (dictMatchStatePtr) *dictMatchStatePtr = NULL;
1196 const void* blockEnd,
1198 U32* loadedDictEndPtr,
1201 assert(loadedDictEndPtr != NULL);
1202 assert(dictMatchStatePtr != NULL);
1204 U32 const loadedDictEnd = *loadedDictEndPtr;
1205 DEBUGLOG(5,
"ZSTD_checkDictValidity: blockEndIdx=%u, maxDist=%u, loadedDictEnd=%u",
1206 (
unsigned)blockEndIdx, (
unsigned)maxDist, (
unsigned)loadedDictEnd);
1207 assert(blockEndIdx >= loadedDictEnd);
1209 if (blockEndIdx > loadedDictEnd + maxDist || loadedDictEnd !=
window->dictLimit) {
1219 DEBUGLOG(6,
"invalidating dictionary for current block (distance > windowSize)");
1220 *loadedDictEndPtr = 0;
1221 *dictMatchStatePtr = NULL;
1223 if (*loadedDictEndPtr != 0) {
1224 DEBUGLOG(6,
"dictionary considered valid for current block");
1236 window->nbOverflowCorrections = 0;
1249 void const* src,
size_t srcSize,
1250 int forceNonContiguous)
1252 BYTE const*
const ip = (
BYTE const*)src;
1260 if (src !=
window->nextSrc || forceNonContiguous) {
1262 size_t const distanceFromBase = (size_t)(
window->nextSrc -
window->base);
1263 DEBUGLOG(5,
"Non contiguous blocks, new segment starts at %u",
window->dictLimit);
1265 assert(distanceFromBase == (
size_t)(
U32)distanceFromBase);
1266 window->dictLimit = (
U32)distanceFromBase;
1268 window->base = ip - distanceFromBase;
1273 window->nextSrc = ip + srcSize;
1275 if ( (ip+srcSize >
window->dictBase +
window->lowLimit)
1277 ptrdiff_t
const highInputIdx = (ip + srcSize) -
window->dictBase;
1278 U32 const lowLimitMax = (highInputIdx > (ptrdiff_t)
window->dictLimit) ?
window->dictLimit : (
U32)highInputIdx;
1279 window->lowLimit = lowLimitMax;
1280 DEBUGLOG(5,
"Overlapping extDict and input : new lowLimit = %u",
window->lowLimit);
1290 U32 const maxDistance = 1U << windowLog;
1292 U32 const withinWindow = (
curr - lowestValid > maxDistance) ?
curr - maxDistance : lowestValid;
1298 U32 const matchLowest = isDictionary ? lowestValid : withinWindow;
1307 U32 const maxDistance = 1U << windowLog;
1309 U32 const withinWindow = (
curr - lowestValid > maxDistance) ?
curr - maxDistance : lowestValid;
1314 U32 const matchLowest = isDictionary ? lowestValid : withinWindow;
1325 U32 const fp_accuracy = 8;
1326 U32 const fp_multiplier = (1 << fp_accuracy);
1327 U32 const newStat = rawStat + 1;
1329 U32 const BWeight = hb * fp_multiplier;
1330 U32 const FWeight = (newStat << fp_accuracy) >> hb;
1332 assert(hb + fp_accuracy < 31);
1333 return (
double)
weight / fp_multiplier;
1341 for (u=0, sum=0; u<=
max; u++) sum +=
table[u];
1342 DEBUGLOG(2,
"total nb elts: %u", sum);
1343 for (u=0; u<=
max; u++) {
1345 u,
table[u], ZSTD_fWeight(sum) - ZSTD_fWeight(
table[u]) );
1368#define ZSTD_SHORT_CACHE_TAG_BITS 8
1369#define ZSTD_SHORT_CACHE_TAG_MASK ((1u << ZSTD_SHORT_CACHE_TAG_BITS) - 1)
1385 return tag1 == tag2;
1388#if defined (__cplusplus)
1403 const void*
const dict,
size_t dictSize);
1426 const void* dict,
size_t dictSize,
1428 const ZSTD_CCtx_params* params,
unsigned long long pledgedSrcSize);
1439 const void* dict,
size_t dictSize,
1440 ZSTD_dictContentType_e dictContentType,
1443 const ZSTD_CCtx_params* params,
1444 unsigned long long pledgedSrcSize);
1449 void* dst,
size_t dstCapacity,
1450 const void* src,
size_t srcSize,
1451 const void* dict,
size_t dictSize,
1452 const ZSTD_CCtx_params* params);
1490 const ZSTD_Sequence*
const inSeqs,
size_t inSeqsSize,
1491 const void* src,
size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
1507 const ZSTD_Sequence*
const inSeqs,
size_t inSeqsSize,
1508 const void* src,
size_t blockSize, ZSTD_paramSwitch_e externalRepSearch);
1512 return params->extSeqProdFunc != NULL;
1524 void* dst,
size_t dstCapacity,
1525 const void* src,
size_t srcSize);
1528 void* dst,
size_t dstCapacity,
1529 const void* src,
size_t srcSize);
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
MEM_STATIC unsigned ZSTD_highbit32(U32 val)
#define FORCE_INLINE_ATTR
#define ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
#define assert(condition)
#define RETURN_ERROR_IF(cond, err,...)
struct XXH64_state_s XXH64_state_t
The opaque state struct for the XXH64 streaming API.
#define HUF_CTABLE_SIZE_ST(maxSymbolValue)
MEM_STATIC U32 MEM_read32(const void *memPtr)
MEM_STATIC U16 MEM_read16(const void *memPtr)
MEM_STATIC size_t MEM_readST(const void *memPtr)
MEM_STATIC unsigned MEM_64bits(void)
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
uint32_t size(sys::state const &state)
ZSTD_paramSwitch_e literalCompressionMode
ZSTD_frameParameters fParams
ZSTD_paramSwitch_e useRowMatchFinder
ZSTD_paramSwitch_e searchForExternalRepcodes
int enableMatchFinderFallback
ZSTD_compressionParameters cParams
int deterministicRefPrefix
ZSTD_sequenceFormat_e blockDelimiters
ZSTD_bufferMode_e inBufferMode
int enableDedicatedDictSearch
ZSTD_bufferMode_e outBufferMode
ZSTD_paramSwitch_e useBlockSplitter
ZSTD_dictAttachPref_e attachDictPref
ZSTD_sequenceProducer_F extSeqProdFunc
ZSTD_paramSwitch_e prefetchCDictTables
ZSTD_buffered_policy_e bufferedPolicy
ZSTD_blockSplitCtx blockSplitCtx
ZSTD_CCtx_params appliedParams
ZSTD_prefixDict prefixDict
SeqCollector seqCollector
ZSTD_CCtx_params simpleApiParams
size_t expectedOutBufferSize
ZSTD_compressionStage_e stage
ZSTD_CCtx_params requestedParams
rawSeqStore_t externSeqStore
unsigned long long pledgedSrcSizePlusOne
ZSTD_blockState_t blockState
ZSTD_cStreamStage streamStage
unsigned long long consumedSrcSize
ZSTD_Sequence * extSeqBuf
size_t stableIn_notConsumed
unsigned long long producedCSize
ZSTD_inBuffer expectedInBuffer
size_t outBuffFlushedSize
size_t outBuffContentSize
const rawSeqStore_t * ldmSeqStore
ZSTD_compressionParameters cParams
const ZSTD_matchState_t * dictMatchState
U32 hashCache[ZSTD_ROW_HASH_CACHE_SIZE]
ZSTD_dictContentType_e dictContentType
ZSTD_longLengthType_e longLengthType
ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
size_t ZSTD_compress_advanced_internal(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, const ZSTD_CCtx_params *params)
MEM_STATIC size_t ZSTD_minGain(size_t srcSize, ZSTD_strategy strat)
MEM_STATIC U32 ZSTD_MLcode(U32 mlBase)
ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramSwitch_e rowMatchfinderMode, ZSTD_dictMode_e dictMode)
size_t ZSTD_copySequencesToSeqStoreNoBlockDelim(ZSTD_CCtx *cctx, ZSTD_sequencePosition *seqPos, const ZSTD_Sequence *const inSeqs, size_t inSeqsSize, const void *src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch)
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms)
MEM_STATIC U32 ZSTD_window_needOverflowCorrection(ZSTD_window_t const window, U32 cycleLog, U32 maxDist, U32 loadedDictEnd, void const *src, void const *srcEnd)
void ZSTD_CCtx_trace(ZSTD_CCtx *cctx, size_t extraCSize)
MEM_STATIC void ZSTD_window_clear(ZSTD_window_t *window)
#define ZSTD_SHORT_CACHE_TAG_BITS
size_t ZSTD_compressEnd_public(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
MEM_STATIC U64 ZSTD_rollingHash_compute(void const *buf, size_t size)
#define OFFBASE_TO_OFFSET(o)
MEM_STATIC U64 ZSTD_rollingHash_rotate(U64 hash, BYTE toRemove, BYTE toAdd, U64 primePower)
ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(const ZSTD_CCtx_params *CCtxParams, U64 srcSizeHint, size_t dictSize, ZSTD_cParamMode_e mode)
size_t ZSTD_compressBlock_deprecated(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
MEM_STATIC int ZSTD_literalsCompressionIsDisabled(const ZSTD_CCtx_params *cctxParams)
MEM_STATIC size_t ZSTD_noCompressBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize, U32 lastBlock)
MEM_STATIC size_t ZSTD_count_2segments(const BYTE *ip, const BYTE *match, const BYTE *iEnd, const BYTE *mEnd, const BYTE *iStart)
MEM_STATIC U64 ZSTD_rollingHash_primePower(U32 length)
MEM_STATIC void ZSTD_writeTaggedIndex(U32 *const hashTable, size_t hashAndTag, U32 index)
MEM_STATIC U32 ZSTD_window_isEmpty(ZSTD_window_t const window)
#define ZSTD_SHORT_CACHE_TAG_MASK
size_t ZSTD_loadCEntropy(ZSTD_compressedBlockState_t *bs, void *workspace, const void *const dict, size_t dictSize)
MEM_STATIC int ZSTD_comparePackedTags(size_t packedTag1, size_t packedTag2)
MEM_STATIC void ZSTD_updateRep(U32 rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
struct repcodes_s repcodes_t
MEM_STATIC U32 ZSTD_LLcode(U32 litLength)
#define ZSTD_MAX_NB_BLOCK_SPLITS
void ZSTD_resetSeqStore(seqStore_t *ssPtr)
#define ZSTD_WINDOW_START_INDEX
MEM_STATIC ZSTD_ALLOW_POINTER_OVERFLOW_ATTR U32 ZSTD_window_update(ZSTD_window_t *window, void const *src, size_t srcSize, int forceNonContiguous)
MEM_STATIC void ZSTD_window_init(ZSTD_window_t *window)
size_t ZSTD_copySequencesToSeqStoreExplicitBlockDelim(ZSTD_CCtx *cctx, ZSTD_sequencePosition *seqPos, const ZSTD_Sequence *const inSeqs, size_t inSeqsSize, const void *src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch)
MEM_STATIC FORCE_INLINE_ATTR size_t ZSTD_hashPtr(const void *p, U32 hBits, U32 mls)
MEM_STATIC ZSTD_ALLOW_POINTER_OVERFLOW_ATTR U32 ZSTD_window_correctOverflow(ZSTD_window_t *window, U32 cycleLog, U32 maxDist, void const *src)
MEM_STATIC size_t ZSTD_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *const pInLimit)
size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictContentType_e dictContentType, ZSTD_dictTableLoadMethod_e dtlm, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, unsigned long long pledgedSrcSize)
struct ZSTD_prefixDict_s ZSTD_prefixDict
size_t ZSTD_initCStream_internal(ZSTD_CStream *zcs, const void *dict, size_t dictSize, const ZSTD_CDict *cdict, const ZSTD_CCtx_params *params, unsigned long long pledgedSrcSize)
size_t(* ZSTD_blockCompressor)(ZSTD_matchState_t *bs, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
HINT_INLINE UNUSED_ATTR void ZSTD_storeSeq(seqStore_t *seqStorePtr, size_t litLength, const BYTE *literals, const BYTE *litLimit, U32 offBase, size_t matchLength)
MEM_STATIC U32 ZSTD_getLowestMatchIndex(const ZSTD_matchState_t *ms, U32 curr, unsigned windowLog)
MEM_STATIC U32 ZSTD_window_canOverflowCorrect(ZSTD_window_t const window, U32 cycleLog, U32 maxDist, U32 loadedDictEnd, void const *src)
MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_matchState_t *ms, U32 curr, unsigned windowLog)
MEM_STATIC size_t ZSTD_rleCompressBlock(void *dst, size_t dstCapacity, BYTE src, size_t srcSize, U32 lastBlock)
size_t ZSTD_compressBegin_usingCDict_deprecated(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
#define ZSTD_WINDOW_OVERFLOW_CORRECT_FREQUENTLY
MEM_STATIC void ZSTD_checkDictValidity(const ZSTD_window_t *window, const void *blockEnd, U32 maxDist, U32 *loadedDictEndPtr, const ZSTD_matchState_t **dictMatchStatePtr)
void ZSTD_referenceExternalSequences(ZSTD_CCtx *cctx, rawSeq *seq, size_t nbSeq)
size_t ZSTD_buildBlockEntropyStats(const seqStore_t *seqStorePtr, const ZSTD_entropyCTables_t *prevEntropy, ZSTD_entropyCTables_t *nextEntropy, const ZSTD_CCtx_params *cctxParams, ZSTD_entropyCTablesMetadata_t *entropyMetadata, void *workspace, size_t wkspSize)
MEM_STATIC size_t ZSTD_hash3Ptr(const void *ptr, U32 h)
MEM_STATIC FORCE_INLINE_ATTR size_t ZSTD_hashPtrSalted(const void *p, U32 hBits, U32 mls, const U64 hashSalt)
MEM_STATIC void ZSTD_window_enforceMaxDist(ZSTD_window_t *window, const void *blockEnd, U32 maxDist, U32 *loadedDictEndPtr, const ZSTD_matchState_t **dictMatchStatePtr)
U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)
#define OFFBASE_IS_OFFSET(o)
ZSTD_dictTableLoadMethod_e
size_t ZSTD_writeLastEmptyBlock(void *dst, size_t dstCapacity)
MEM_STATIC size_t ZSTD_hash3PtrS(const void *ptr, U32 h, U32 s)
void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t *bs)
#define OFFBASE_TO_REPCODE(o)
#define ZSTD_DUBT_UNSORTED_MARK
MEM_STATIC repcodes_t ZSTD_newRep(U32 const rep[ZSTD_REP_NUM], U32 const offBase, U32 const ll0)
MEM_STATIC int ZSTD_hasExtSeqProd(const ZSTD_CCtx_params *params)
size_t ZSTD_compressContinue_public(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
#define ZSTD_ROLL_HASH_CHAR_OFFSET
ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict *cdict)
@ ZSTD_dedicatedDictSearch
#define ZSTD_ROW_HASH_CACHE_SIZE
#define ZSTD_memcpy(d, s, l)
#define ZSTD_memset(p, v, l)
#define ZSTD_MAX_HUF_HEADER_SIZE
#define WILDCOPY_OVERLENGTH
MEM_STATIC FORCE_INLINE_ATTR void ZSTD_wildcopy(void *dst, const void *src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
#define ZSTD_STATIC_ASSERT(c)
#define ZSTD_MAX_FSE_HEADERS_SIZE