Lines Matching +full:byte +full:- +full:len
2 * Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
12 * Free Software Foundation. This program is dual-licensed; you may select
26 /*-*************************************
31 ssPtr->log2matchLengthSum = ZSTD_highbit32(ssPtr->matchLengthSum + 1); in ZSTD_setLog2Prices()
32 ssPtr->log2litLengthSum = ZSTD_highbit32(ssPtr->litLengthSum + 1); in ZSTD_setLog2Prices()
33 ssPtr->log2litSum = ZSTD_highbit32(ssPtr->litSum + 1); in ZSTD_setLog2Prices()
34 ssPtr->log2offCodeSum = ZSTD_highbit32(ssPtr->offCodeSum + 1); in ZSTD_setLog2Prices()
35 …ssPtr->factor = 1 + ((ssPtr->litSum >> 5) / ssPtr->litLengthSum) + ((ssPtr->litSum << 1) / (ssPtr-… in ZSTD_setLog2Prices()
38 ZSTD_STATIC void ZSTD_rescaleFreqs(seqStore_t *ssPtr, const BYTE *src, size_t srcSize) in ZSTD_rescaleFreqs()
42 ssPtr->cachedLiterals = NULL; in ZSTD_rescaleFreqs()
43 ssPtr->cachedPrice = ssPtr->cachedLitLength = 0; in ZSTD_rescaleFreqs()
44 ssPtr->staticPrices = 0; in ZSTD_rescaleFreqs()
46 if (ssPtr->litLengthSum == 0) { in ZSTD_rescaleFreqs()
48 ssPtr->staticPrices = 1; in ZSTD_rescaleFreqs()
51 ssPtr->litFreq[u] = 0; in ZSTD_rescaleFreqs()
53 ssPtr->litFreq[src[u]]++; in ZSTD_rescaleFreqs()
55 ssPtr->litSum = 0; in ZSTD_rescaleFreqs()
56 ssPtr->litLengthSum = MaxLL + 1; in ZSTD_rescaleFreqs()
57 ssPtr->matchLengthSum = MaxML + 1; in ZSTD_rescaleFreqs()
58 ssPtr->offCodeSum = (MaxOff + 1); in ZSTD_rescaleFreqs()
59 ssPtr->matchSum = (ZSTD_LITFREQ_ADD << Litbits); in ZSTD_rescaleFreqs()
62 ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u] >> ZSTD_FREQ_DIV); in ZSTD_rescaleFreqs()
63 ssPtr->litSum += ssPtr->litFreq[u]; in ZSTD_rescaleFreqs()
66 ssPtr->litLengthFreq[u] = 1; in ZSTD_rescaleFreqs()
68 ssPtr->matchLengthFreq[u] = 1; in ZSTD_rescaleFreqs()
70 ssPtr->offCodeFreq[u] = 1; in ZSTD_rescaleFreqs()
72 ssPtr->matchLengthSum = 0; in ZSTD_rescaleFreqs()
73 ssPtr->litLengthSum = 0; in ZSTD_rescaleFreqs()
74 ssPtr->offCodeSum = 0; in ZSTD_rescaleFreqs()
75 ssPtr->matchSum = 0; in ZSTD_rescaleFreqs()
76 ssPtr->litSum = 0; in ZSTD_rescaleFreqs()
79 ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u] >> (ZSTD_FREQ_DIV + 1)); in ZSTD_rescaleFreqs()
80 ssPtr->litSum += ssPtr->litFreq[u]; in ZSTD_rescaleFreqs()
83 ssPtr->litLengthFreq[u] = 1 + (ssPtr->litLengthFreq[u] >> (ZSTD_FREQ_DIV + 1)); in ZSTD_rescaleFreqs()
84 ssPtr->litLengthSum += ssPtr->litLengthFreq[u]; in ZSTD_rescaleFreqs()
87 ssPtr->matchLengthFreq[u] = 1 + (ssPtr->matchLengthFreq[u] >> ZSTD_FREQ_DIV); in ZSTD_rescaleFreqs()
88 ssPtr->matchLengthSum += ssPtr->matchLengthFreq[u]; in ZSTD_rescaleFreqs()
89 ssPtr->matchSum += ssPtr->matchLengthFreq[u] * (u + 3); in ZSTD_rescaleFreqs()
91 ssPtr->matchSum *= ZSTD_LITFREQ_ADD; in ZSTD_rescaleFreqs()
93 ssPtr->offCodeFreq[u] = 1 + (ssPtr->offCodeFreq[u] >> ZSTD_FREQ_DIV); in ZSTD_rescaleFreqs()
94 ssPtr->offCodeSum += ssPtr->offCodeFreq[u]; in ZSTD_rescaleFreqs()
101 FORCE_INLINE U32 ZSTD_getLiteralPrice(seqStore_t *ssPtr, U32 litLength, const BYTE *literals) in ZSTD_getLiteralPrice()
105 if (ssPtr->staticPrices) in ZSTD_getLiteralPrice()
109 return ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[0] + 1); in ZSTD_getLiteralPrice()
112 if (ssPtr->cachedLiterals == literals) { in ZSTD_getLiteralPrice()
113 U32 const additional = litLength - ssPtr->cachedLitLength; in ZSTD_getLiteralPrice()
114 const BYTE *literals2 = ssPtr->cachedLiterals + ssPtr->cachedLitLength; in ZSTD_getLiteralPrice()
115 price = ssPtr->cachedPrice + additional * ssPtr->log2litSum; in ZSTD_getLiteralPrice()
117 price -= ZSTD_highbit32(ssPtr->litFreq[literals2[u]] + 1); in ZSTD_getLiteralPrice()
118 ssPtr->cachedPrice = price; in ZSTD_getLiteralPrice()
119 ssPtr->cachedLitLength = litLength; in ZSTD_getLiteralPrice()
121 price = litLength * ssPtr->log2litSum; in ZSTD_getLiteralPrice()
123 price -= ZSTD_highbit32(ssPtr->litFreq[literals[u]] + 1); in ZSTD_getLiteralPrice()
126 ssPtr->cachedLiterals = literals; in ZSTD_getLiteralPrice()
127 ssPtr->cachedPrice = price; in ZSTD_getLiteralPrice()
128 ssPtr->cachedLitLength = litLength; in ZSTD_getLiteralPrice()
134 const BYTE LL_deltaCode = 19; in ZSTD_getLiteralPrice()
135 …const BYTE llCode = (litLength > 63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[li… in ZSTD_getLiteralPrice()
136 …price += LL_bits[llCode] + ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[llCode] +… in ZSTD_getLiteralPrice()
142 FORCE_INLINE U32 ZSTD_getPrice(seqStore_t *seqStorePtr, U32 litLength, const BYTE *literals, U32 of… in ZSTD_getPrice()
146 BYTE const offCode = (BYTE)ZSTD_highbit32(offset + 1); in ZSTD_getPrice()
148 if (seqStorePtr->staticPrices) in ZSTD_getPrice()
151 …price = offCode + seqStorePtr->log2offCodeSum - ZSTD_highbit32(seqStorePtr->offCodeFreq[offCode] +… in ZSTD_getPrice()
153 price += (offCode - 19) * 2; in ZSTD_getPrice()
157 const BYTE ML_deltaCode = 36; in ZSTD_getPrice()
158 …const BYTE mlCode = (matchLength > 127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Co… in ZSTD_getPrice()
159 …price += ML_bits[mlCode] + seqStorePtr->log2matchLengthSum - ZSTD_highbit32(seqStorePtr->matchLeng… in ZSTD_getPrice()
162 return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + seqStorePtr->factor; in ZSTD_getPrice()
165 ZSTD_STATIC void ZSTD_updatePrice(seqStore_t *seqStorePtr, U32 litLength, const BYTE *literals, U32… in ZSTD_updatePrice()
170 seqStorePtr->litSum += litLength * ZSTD_LITFREQ_ADD; in ZSTD_updatePrice()
172 seqStorePtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD; in ZSTD_updatePrice()
176 const BYTE LL_deltaCode = 19; in ZSTD_updatePrice()
177 …const BYTE llCode = (litLength > 63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[li… in ZSTD_updatePrice()
178 seqStorePtr->litLengthFreq[llCode]++; in ZSTD_updatePrice()
179 seqStorePtr->litLengthSum++; in ZSTD_updatePrice()
184 BYTE const offCode = (BYTE)ZSTD_highbit32(offset + 1); in ZSTD_updatePrice()
185 seqStorePtr->offCodeSum++; in ZSTD_updatePrice()
186 seqStorePtr->offCodeFreq[offCode]++; in ZSTD_updatePrice()
191 const BYTE ML_deltaCode = 36; in ZSTD_updatePrice()
192 …const BYTE mlCode = (matchLength > 127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Co… in ZSTD_updatePrice()
193 seqStorePtr->matchLengthFreq[mlCode]++; in ZSTD_updatePrice()
194 seqStorePtr->matchLengthSum++; in ZSTD_updatePrice()
215 U32 ZSTD_insertAndFindFirstIndexHash3(ZSTD_CCtx *zc, const BYTE *ip) in ZSTD_insertAndFindFirstIndexHash3()
217 U32 *const hashTable3 = zc->hashTable3; in ZSTD_insertAndFindFirstIndexHash3()
218 U32 const hashLog3 = zc->hashLog3; in ZSTD_insertAndFindFirstIndexHash3()
219 const BYTE *const base = zc->base; in ZSTD_insertAndFindFirstIndexHash3()
220 U32 idx = zc->nextToUpdate3; in ZSTD_insertAndFindFirstIndexHash3()
221 const U32 target = zc->nextToUpdate3 = (U32)(ip - base); in ZSTD_insertAndFindFirstIndexHash3()
232 /*-*************************************
235 static U32 ZSTD_insertBtAndGetAllMatches(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLi… in ZSTD_insertBtAndGetAllMatches()
238 const BYTE *const base = zc->base; in ZSTD_insertBtAndGetAllMatches()
239 const U32 curr = (U32)(ip - base); in ZSTD_insertBtAndGetAllMatches()
240 const U32 hashLog = zc->params.cParams.hashLog; in ZSTD_insertBtAndGetAllMatches()
242 U32 *const hashTable = zc->hashTable; in ZSTD_insertBtAndGetAllMatches()
244 U32 *const bt = zc->chainTable; in ZSTD_insertBtAndGetAllMatches()
245 const U32 btLog = zc->params.cParams.chainLog - 1; in ZSTD_insertBtAndGetAllMatches()
246 const U32 btMask = (1U << btLog) - 1; in ZSTD_insertBtAndGetAllMatches()
248 const BYTE *const dictBase = zc->dictBase; in ZSTD_insertBtAndGetAllMatches()
249 const U32 dictLimit = zc->dictLimit; in ZSTD_insertBtAndGetAllMatches()
250 const BYTE *const dictEnd = dictBase + dictLimit; in ZSTD_insertBtAndGetAllMatches()
251 const BYTE *const prefixStart = base + dictLimit; in ZSTD_insertBtAndGetAllMatches()
252 const U32 btLow = btMask >= curr ? 0 : curr - btMask; in ZSTD_insertBtAndGetAllMatches()
253 const U32 windowLow = zc->lowLimit; in ZSTD_insertBtAndGetAllMatches()
261 size_t bestLength = minMatchLen - 1; in ZSTD_insertBtAndGetAllMatches()
265 if (matchIndex3 > windowLow && (curr - matchIndex3 < (1 << 18))) { in ZSTD_insertBtAndGetAllMatches()
266 const BYTE *match; in ZSTD_insertBtAndGetAllMatches()
275 …ZSTD_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction… in ZSTD_insertBtAndGetAllMatches()
282 matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex3; in ZSTD_insertBtAndGetAllMatches()
283 matches[mnum].len = (U32)currMl; in ZSTD_insertBtAndGetAllMatches()
295 while (nbCompares-- && (matchIndex > windowLow)) { in ZSTD_insertBtAndGetAllMatches()
298 const BYTE *match; in ZSTD_insertBtAndGetAllMatches()
313 if (matchLength > matchEndIdx - matchIndex) in ZSTD_insertBtAndGetAllMatches()
316 matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex; in ZSTD_insertBtAndGetAllMatches()
317 matches[mnum].len = (U32)matchLength; in ZSTD_insertBtAndGetAllMatches()
351 zc->nextToUpdate = (matchEndIdx > curr + 8) ? matchEndIdx - 8 : curr + 1; in ZSTD_insertBtAndGetAllMatches()
356 static U32 ZSTD_BtGetAllMatches(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLimit, cons… in ZSTD_BtGetAllMatches()
359 if (ip < zc->base + zc->nextToUpdate) in ZSTD_BtGetAllMatches()
366 …const BYTE *ip, const BYTE *const iHighLimit, const U32 maxNbAttempts, const U32 matchLengthSearch, in ZSTD_BtGetAllMatches_selectMLS()
380 static U32 ZSTD_BtGetAllMatches_extDict(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLim… in ZSTD_BtGetAllMatches_extDict()
383 if (ip < zc->base + zc->nextToUpdate) in ZSTD_BtGetAllMatches_extDict()
390 …const BYTE *ip, const BYTE *const iHighLimit, const U32 maxNbAttempts, const U32 matchLengthSearch, in ZSTD_BtGetAllMatches_selectMLS_extDict()
403 /*-*******************************
409 seqStore_t *seqStorePtr = &(ctx->seqStore); in ZSTD_compressBlock_opt_generic()
410 const BYTE *const istart = (const BYTE *)src; in ZSTD_compressBlock_opt_generic()
411 const BYTE *ip = istart; in ZSTD_compressBlock_opt_generic()
412 const BYTE *anchor = istart; in ZSTD_compressBlock_opt_generic()
413 const BYTE *const iend = istart + srcSize; in ZSTD_compressBlock_opt_generic()
414 const BYTE *const ilimit = iend - 8; in ZSTD_compressBlock_opt_generic()
415 const BYTE *const base = ctx->base; in ZSTD_compressBlock_opt_generic()
416 const BYTE *const prefixStart = base + ctx->dictLimit; in ZSTD_compressBlock_opt_generic()
418 const U32 maxSearches = 1U << ctx->params.cParams.searchLog; in ZSTD_compressBlock_opt_generic()
419 const U32 sufficient_len = ctx->params.cParams.targetLength; in ZSTD_compressBlock_opt_generic()
420 const U32 mls = ctx->params.cParams.searchLength; in ZSTD_compressBlock_opt_generic()
421 const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4; in ZSTD_compressBlock_opt_generic()
423 ZSTD_optimal_t *opt = seqStorePtr->priceTable; in ZSTD_compressBlock_opt_generic()
424 ZSTD_match_t *matches = seqStorePtr->matchTable; in ZSTD_compressBlock_opt_generic()
425 const BYTE *inr; in ZSTD_compressBlock_opt_generic()
429 ctx->nextToUpdate3 = ctx->nextToUpdate; in ZSTD_compressBlock_opt_generic()
430 ZSTD_rescaleFreqs(seqStorePtr, (const BYTE *)src, srcSize); in ZSTD_compressBlock_opt_generic()
435 rep[i] = ctx->rep[i]; in ZSTD_compressBlock_opt_generic()
444 litlen = (U32)(ip - anchor); in ZSTD_compressBlock_opt_generic()
450 const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i]; in ZSTD_compressBlock_opt_generic()
451 if ((repCur > 0) && (repCur < (S32)(ip - prefixStart)) && in ZSTD_compressBlock_opt_generic()
452 (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(ip - repCur, minMatch))) { in ZSTD_compressBlock_opt_generic()
453 mlen = (U32)ZSTD_count(ip + minMatch, ip + minMatch - repCur, iend) + minMatch; in ZSTD_compressBlock_opt_generic()
461 best_off = i - (ip == anchor); in ZSTD_compressBlock_opt_generic()
463 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
466 mlen--; in ZSTD_compressBlock_opt_generic()
479 …if (match_num && (matches[match_num - 1].len > sufficient_len || matches[match_num - 1].len >= ZST… in ZSTD_compressBlock_opt_generic()
480 best_mlen = matches[match_num - 1].len; in ZSTD_compressBlock_opt_generic()
481 best_off = matches[match_num - 1].off; in ZSTD_compressBlock_opt_generic()
490 mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen; in ZSTD_compressBlock_opt_generic()
491 best_mlen = matches[u].len; in ZSTD_compressBlock_opt_generic()
493 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
518 if (opt[cur - 1].mlen == 1) { in ZSTD_compressBlock_opt_generic()
519 litlen = opt[cur - 1].litlen + 1; in ZSTD_compressBlock_opt_generic()
521 price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - litlen); in ZSTD_compressBlock_opt_generic()
526 price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - 1); in ZSTD_compressBlock_opt_generic()
540 opt[cur].rep[2] = opt[cur - mlen].rep[1]; in ZSTD_compressBlock_opt_generic()
541 opt[cur].rep[1] = opt[cur - mlen].rep[0]; in ZSTD_compressBlock_opt_generic()
542 opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE_OPT; in ZSTD_compressBlock_opt_generic()
544 opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur - mlen].rep[1] : opt[cur - mlen].rep[2]; in ZSTD_compressBlock_opt_generic()
545 opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur - mlen].rep[0] : opt[cur - mlen].rep[1]; in ZSTD_compressBlock_opt_generic()
547 …t[cur].off == ZSTD_REP_MOVE_OPT) && (mlen != 1)) ? (opt[cur - mlen].rep[0] - 1) : (opt[cur - mlen]… in ZSTD_compressBlock_opt_generic()
554 const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i]; in ZSTD_compressBlock_opt_generic()
555 if ((repCur > 0) && (repCur < (S32)(inr - prefixStart)) && in ZSTD_compressBlock_opt_generic()
556 (ZSTD_readMINMATCH(inr, minMatch) == ZSTD_readMINMATCH(inr - repCur, minMatch))) { in ZSTD_compressBlock_opt_generic()
557 mlen = (U32)ZSTD_count(inr + minMatch, inr + minMatch - repCur, iend) + minMatch; in ZSTD_compressBlock_opt_generic()
566 best_off = i - (opt[cur].mlen != 1); in ZSTD_compressBlock_opt_generic()
574 price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr - litlen, in ZSTD_compressBlock_opt_generic()
575 best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
577 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
580 … price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
585 mlen--; in ZSTD_compressBlock_opt_generic()
593 …if (match_num > 0 && (matches[match_num - 1].len > sufficient_len || cur + matches[match_num - 1].… in ZSTD_compressBlock_opt_generic()
594 best_mlen = matches[match_num - 1].len; in ZSTD_compressBlock_opt_generic()
595 best_off = matches[match_num - 1].off; in ZSTD_compressBlock_opt_generic()
602 mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen; in ZSTD_compressBlock_opt_generic()
603 best_mlen = matches[u].len; in ZSTD_compressBlock_opt_generic()
609 price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip + cur - litlen, in ZSTD_compressBlock_opt_generic()
610 matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
612 … price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_generic()
615 …price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off - 1, mlen - MINMATCH, … in ZSTD_compressBlock_opt_generic()
628 cur = last_pos - best_mlen; in ZSTD_compressBlock_opt_generic()
643 cur -= mlen; in ZSTD_compressBlock_opt_generic()
659 litLength = (U32)(ip - anchor); in ZSTD_compressBlock_opt_generic()
664 rep[0] = offset - ZSTD_REP_MOVE_OPT; in ZSTD_compressBlock_opt_generic()
665 offset--; in ZSTD_compressBlock_opt_generic()
668 best_off = (offset == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : (rep[offset]); in ZSTD_compressBlock_opt_generic()
675 offset--; in ZSTD_compressBlock_opt_generic()
678 ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH); in ZSTD_compressBlock_opt_generic()
679 ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH); in ZSTD_compressBlock_opt_generic()
688 ctx->repToConfirm[i] = rep[i]; in ZSTD_compressBlock_opt_generic()
693 size_t const lastLLSize = iend - anchor; in ZSTD_compressBlock_opt_generic()
694 memcpy(seqStorePtr->lit, anchor, lastLLSize); in ZSTD_compressBlock_opt_generic()
695 seqStorePtr->lit += lastLLSize; in ZSTD_compressBlock_opt_generic()
702 seqStore_t *seqStorePtr = &(ctx->seqStore); in ZSTD_compressBlock_opt_extDict_generic()
703 const BYTE *const istart = (const BYTE *)src; in ZSTD_compressBlock_opt_extDict_generic()
704 const BYTE *ip = istart; in ZSTD_compressBlock_opt_extDict_generic()
705 const BYTE *anchor = istart; in ZSTD_compressBlock_opt_extDict_generic()
706 const BYTE *const iend = istart + srcSize; in ZSTD_compressBlock_opt_extDict_generic()
707 const BYTE *const ilimit = iend - 8; in ZSTD_compressBlock_opt_extDict_generic()
708 const BYTE *const base = ctx->base; in ZSTD_compressBlock_opt_extDict_generic()
709 const U32 lowestIndex = ctx->lowLimit; in ZSTD_compressBlock_opt_extDict_generic()
710 const U32 dictLimit = ctx->dictLimit; in ZSTD_compressBlock_opt_extDict_generic()
711 const BYTE *const prefixStart = base + dictLimit; in ZSTD_compressBlock_opt_extDict_generic()
712 const BYTE *const dictBase = ctx->dictBase; in ZSTD_compressBlock_opt_extDict_generic()
713 const BYTE *const dictEnd = dictBase + dictLimit; in ZSTD_compressBlock_opt_extDict_generic()
715 const U32 maxSearches = 1U << ctx->params.cParams.searchLog; in ZSTD_compressBlock_opt_extDict_generic()
716 const U32 sufficient_len = ctx->params.cParams.targetLength; in ZSTD_compressBlock_opt_extDict_generic()
717 const U32 mls = ctx->params.cParams.searchLength; in ZSTD_compressBlock_opt_extDict_generic()
718 const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4; in ZSTD_compressBlock_opt_extDict_generic()
720 ZSTD_optimal_t *opt = seqStorePtr->priceTable; in ZSTD_compressBlock_opt_extDict_generic()
721 ZSTD_match_t *matches = seqStorePtr->matchTable; in ZSTD_compressBlock_opt_extDict_generic()
722 const BYTE *inr; in ZSTD_compressBlock_opt_extDict_generic()
729 rep[i] = ctx->rep[i]; in ZSTD_compressBlock_opt_extDict_generic()
732 ctx->nextToUpdate3 = ctx->nextToUpdate; in ZSTD_compressBlock_opt_extDict_generic()
733 ZSTD_rescaleFreqs(seqStorePtr, (const BYTE *)src, srcSize); in ZSTD_compressBlock_opt_extDict_generic()
740 U32 curr = (U32)(ip - base); in ZSTD_compressBlock_opt_extDict_generic()
743 opt[0].litlen = (U32)(ip - anchor); in ZSTD_compressBlock_opt_extDict_generic()
749 const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i]; in ZSTD_compressBlock_opt_extDict_generic()
750 const U32 repIndex = (U32)(curr - repCur); in ZSTD_compressBlock_opt_extDict_generic()
751 const BYTE *const repBase = repIndex < dictLimit ? dictBase : base; in ZSTD_compressBlock_opt_extDict_generic()
752 const BYTE *const repMatch = repBase + repIndex; in ZSTD_compressBlock_opt_extDict_generic()
754 … (((U32)((dictLimit - 1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */ in ZSTD_compressBlock_opt_extDict_generic()
757 const BYTE *const repEnd = repIndex < dictLimit ? dictEnd : iend; in ZSTD_compressBlock_opt_extDict_generic()
768 best_off = i - (ip == anchor); in ZSTD_compressBlock_opt_extDict_generic()
771 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
774 mlen--; in ZSTD_compressBlock_opt_extDict_generic()
794 …if (match_num && (matches[match_num - 1].len > sufficient_len || matches[match_num - 1].len >= ZST… in ZSTD_compressBlock_opt_extDict_generic()
795 best_mlen = matches[match_num - 1].len; in ZSTD_compressBlock_opt_extDict_generic()
796 best_off = matches[match_num - 1].off; in ZSTD_compressBlock_opt_extDict_generic()
806 mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen; in ZSTD_compressBlock_opt_extDict_generic()
807 best_mlen = matches[u].len; in ZSTD_compressBlock_opt_extDict_generic()
810 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
826 if (opt[cur - 1].mlen == 1) { in ZSTD_compressBlock_opt_extDict_generic()
827 litlen = opt[cur - 1].litlen + 1; in ZSTD_compressBlock_opt_extDict_generic()
829 price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - litlen); in ZSTD_compressBlock_opt_extDict_generic()
834 price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - 1); in ZSTD_compressBlock_opt_extDict_generic()
848 opt[cur].rep[2] = opt[cur - mlen].rep[1]; in ZSTD_compressBlock_opt_extDict_generic()
849 opt[cur].rep[1] = opt[cur - mlen].rep[0]; in ZSTD_compressBlock_opt_extDict_generic()
850 opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE_OPT; in ZSTD_compressBlock_opt_extDict_generic()
852 opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur - mlen].rep[1] : opt[cur - mlen].rep[2]; in ZSTD_compressBlock_opt_extDict_generic()
853 opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur - mlen].rep[0] : opt[cur - mlen].rep[1]; in ZSTD_compressBlock_opt_extDict_generic()
855 …t[cur].off == ZSTD_REP_MOVE_OPT) && (mlen != 1)) ? (opt[cur - mlen].rep[0] - 1) : (opt[cur - mlen]… in ZSTD_compressBlock_opt_extDict_generic()
862 const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i]; in ZSTD_compressBlock_opt_extDict_generic()
863 const U32 repIndex = (U32)(curr + cur - repCur); in ZSTD_compressBlock_opt_extDict_generic()
864 const BYTE *const repBase = repIndex < dictLimit ? dictBase : base; in ZSTD_compressBlock_opt_extDict_generic()
865 const BYTE *const repMatch = repBase + repIndex; in ZSTD_compressBlock_opt_extDict_generic()
867 … (((U32)((dictLimit - 1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */ in ZSTD_compressBlock_opt_extDict_generic()
870 const BYTE *const repEnd = repIndex < dictLimit ? dictEnd : iend; in ZSTD_compressBlock_opt_extDict_generic()
880 best_off = i - (opt[cur].mlen != 1); in ZSTD_compressBlock_opt_extDict_generic()
888 price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr - litlen, in ZSTD_compressBlock_opt_extDict_generic()
889 best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
891 price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
894 … price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
899 mlen--; in ZSTD_compressBlock_opt_extDict_generic()
907 …if (match_num > 0 && (matches[match_num - 1].len > sufficient_len || cur + matches[match_num - 1].… in ZSTD_compressBlock_opt_extDict_generic()
908 best_mlen = matches[match_num - 1].len; in ZSTD_compressBlock_opt_extDict_generic()
909 best_off = matches[match_num - 1].off; in ZSTD_compressBlock_opt_extDict_generic()
916 mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen; in ZSTD_compressBlock_opt_extDict_generic()
917 best_mlen = matches[u].len; in ZSTD_compressBlock_opt_extDict_generic()
923 price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip + cur - litlen, in ZSTD_compressBlock_opt_extDict_generic()
924 matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
926 … price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra); in ZSTD_compressBlock_opt_extDict_generic()
929 …price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off - 1, mlen - MINMATCH, … in ZSTD_compressBlock_opt_extDict_generic()
942 cur = last_pos - best_mlen; in ZSTD_compressBlock_opt_extDict_generic()
957 cur -= mlen; in ZSTD_compressBlock_opt_extDict_generic()
973 litLength = (U32)(ip - anchor); in ZSTD_compressBlock_opt_extDict_generic()
978 rep[0] = offset - ZSTD_REP_MOVE_OPT; in ZSTD_compressBlock_opt_extDict_generic()
979 offset--; in ZSTD_compressBlock_opt_extDict_generic()
982 best_off = (offset == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : (rep[offset]); in ZSTD_compressBlock_opt_extDict_generic()
990 offset--; in ZSTD_compressBlock_opt_extDict_generic()
993 ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH); in ZSTD_compressBlock_opt_extDict_generic()
994 ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH); in ZSTD_compressBlock_opt_extDict_generic()
1003 ctx->repToConfirm[i] = rep[i]; in ZSTD_compressBlock_opt_extDict_generic()
1008 size_t lastLLSize = iend - anchor; in ZSTD_compressBlock_opt_extDict_generic()
1009 memcpy(seqStorePtr->lit, anchor, lastLLSize); in ZSTD_compressBlock_opt_extDict_generic()
1010 seqStorePtr->lit += lastLLSize; in ZSTD_compressBlock_opt_extDict_generic()