16 const void*
const end,
19 const ZSTD_compressionParameters*
const cParams = &ms->
cParams;
21 U32 const hBits = cParams->hashLog;
22 U32 const mls = cParams->minMatch;
26 const U32 fastHashFillStep = 3;
31 for ( ;
ip + fastHashFillStep < iend + 2;
ip += fastHashFillStep) {
38 for (
p = 1;
p < fastHashFillStep; ++
p) {
40 if (hashTable[
hash] == 0) {
49 void const*
src,
size_t srcSize,
52 const ZSTD_compressionParameters*
const cParams = &ms->
cParams;
54 U32 const hlog = cParams->hashLog;
56 size_t const stepSize = cParams->targetLength + !(cParams->targetLength) + 1;
60 const BYTE* ip0 = istart;
62 const BYTE* anchor = istart;
63 const U32 endIndex = (
U32)((
size_t)(istart -
base) + srcSize);
65 const BYTE*
const prefixStart =
base + prefixStartIndex;
66 const BYTE*
const iend = istart + srcSize;
68 U32 offset_1=rep[0], offset_2=rep[1];
72 DEBUGLOG(5,
"ZSTD_compressBlock_fast_generic");
73 ip0 += (ip0 == prefixStart);
78 if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
79 if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
83#ifdef __INTEL_COMPILER
90 while (ip1 < ilimit) {
92 BYTE const* ip2 = ip0 + 2;
99 U32 const matchIndex0 = hashTable[h0];
100 U32 const matchIndex1 = hashTable[h1];
101 BYTE const* repMatch = ip2 - offset_1;
102 const BYTE* match0 =
base + matchIndex0;
103 const BYTE* match1 =
base + matchIndex1;
106#if defined(__aarch64__)
110 hashTable[h0] = current0;
111 hashTable[h1] = current1;
116 mLength = (ip2[-1] == repMatch[-1]) ? 1 : 0;
118 match0 = repMatch - mLength;
123 if ((matchIndex0 > prefixStartIndex) &&
MEM_read32(match0) == val0) {
127 if ((matchIndex1 > prefixStartIndex) &&
MEM_read32(match1) == val1) {
142 offset_1 = (
U32)(ip0-match0);
146 while (((ip0>anchor) & (match0>prefixStart))
147 && (ip0[-1] == match0[-1])) { ip0--; match0--; mLength++; }
151 mLength +=
ZSTD_count(ip0+mLength, match0+mLength, iend);
166 size_t const rLength =
ZSTD_count(ip0+4, ip0+4-offset_2, iend) + 4;
167 {
U32 const tmpOff = offset_2; offset_2 = offset_1; offset_1 = tmpOff; }
178 rep[0] = offset_1 ? offset_1 : offsetSaved;
179 rep[1] = offset_2 ? offset_2 : offsetSaved;
182 return (
size_t)(iend - anchor);
188 void const*
src,
size_t srcSize)
209 void const*
src,
size_t srcSize,
U32 const mls)
211 const ZSTD_compressionParameters*
const cParams = &ms->
cParams;
213 U32 const hlog = cParams->hashLog;
215 U32 const stepSize = cParams->targetLength + !(cParams->targetLength);
219 const BYTE* anchor = istart;
221 const BYTE*
const prefixStart =
base + prefixStartIndex;
222 const BYTE*
const iend = istart + srcSize;
224 U32 offset_1=rep[0], offset_2=rep[1];
228 const ZSTD_compressionParameters*
const dictCParams = &dms->
cParams ;
232 const BYTE*
const dictStart = dictBase + dictStartIndex;
234 const U32 dictIndexDelta = prefixStartIndex - (
U32)(dictEnd - dictBase);
235 const U32 dictAndPrefixLength = (
U32)(
ip - prefixStart + dictEnd - dictStart);
236 const U32 dictHLog = dictCParams->hashLog;
240 const U32 maxDistance = 1U << cParams->windowLog;
241 const U32 endIndex = (
U32)((
size_t)(
ip -
base) + srcSize);
242 assert(endIndex - prefixStartIndex <= maxDistance);
247 assert(prefixStartIndex >= (
U32)(dictEnd - dictBase));
250 DEBUGLOG(5,
"ZSTD_compressBlock_fast_dictMatchState_generic");
251 ip += (dictAndPrefixLength == 0);
254 assert(offset_1 <= dictAndPrefixLength);
255 assert(offset_2 <= dictAndPrefixLength);
258 while (
ip < ilimit) {
262 U32 const matchIndex = hashTable[
h];
265 const BYTE* repMatch = (repIndex < prefixStartIndex) ?
266 dictBase + (repIndex - dictIndexDelta) :
270 if ( ((
U32)((prefixStartIndex-1) - repIndex) >= 3)
272 const BYTE*
const repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
276 }
else if ( (matchIndex <= prefixStartIndex) ) {
278 U32 const dictMatchIndex = dictHashTable[dictHash];
279 const BYTE* dictMatch = dictBase + dictMatchIndex;
280 if (dictMatchIndex <= dictStartIndex ||
289 while (((
ip>anchor) & (dictMatch>dictStart))
290 && (
ip[-1] == dictMatch[-1])) {
291 ip--; dictMatch--; mLength++;
306 while (((
ip>anchor) & (
match>prefixStart))
324 while (
ip <= ilimit) {
326 U32 const repIndex2 = current2 - offset_2;
327 const BYTE* repMatch2 = repIndex2 < prefixStartIndex ?
328 dictBase - dictIndexDelta + repIndex2 :
330 if ( ((
U32)((prefixStartIndex-1) - (
U32)repIndex2) >= 3 )
332 const BYTE*
const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
334 U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset;
347 rep[0] = offset_1 ? offset_1 : offsetSaved;
348 rep[1] = offset_2 ? offset_2 : offsetSaved;
351 return (
size_t)(iend - anchor);
356 void const*
src,
size_t srcSize)
377 void const*
src,
size_t srcSize,
U32 const mls)
379 const ZSTD_compressionParameters*
const cParams = &ms->
cParams;
381 U32 const hlog = cParams->hashLog;
383 U32 const stepSize = cParams->targetLength + !(cParams->targetLength);
388 const BYTE* anchor = istart;
389 const U32 endIndex = (
U32)((
size_t)(istart -
base) + srcSize);
391 const U32 dictStartIndex = lowLimit;
392 const BYTE*
const dictStart = dictBase + dictStartIndex;
394 const U32 prefixStartIndex = dictLimit < lowLimit ? lowLimit : dictLimit;
395 const BYTE*
const prefixStart =
base + prefixStartIndex;
396 const BYTE*
const dictEnd = dictBase + prefixStartIndex;
397 const BYTE*
const iend = istart + srcSize;
398 const BYTE*
const ilimit = iend - 8;
399 U32 offset_1=rep[0], offset_2=rep[1];
401 DEBUGLOG(5,
"ZSTD_compressBlock_fast_extDict_generic (offset_1=%u)", offset_1);
404 if (prefixStartIndex == dictStartIndex)
408 while (
ip < ilimit) {
410 const U32 matchIndex = hashTable[
h];
411 const BYTE*
const matchBase = matchIndex < prefixStartIndex ? dictBase :
base;
412 const BYTE*
match = matchBase + matchIndex;
415 const BYTE*
const repBase = repIndex < prefixStartIndex ? dictBase :
base;
416 const BYTE*
const repMatch = repBase + repIndex;
421 if ( (((
U32)((prefixStartIndex-1) - repIndex) >= 3) & (repIndex > dictStartIndex))
423 const BYTE*
const repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
430 if ( (matchIndex < dictStartIndex) ||
436 {
const BYTE*
const matchEnd = matchIndex < prefixStartIndex ? dictEnd : iend;
437 const BYTE*
const lowMatchPtr = matchIndex < prefixStartIndex ? dictStart : prefixStart;
441 offset_2 = offset_1; offset_1 =
offset;
452 while (
ip <= ilimit) {
454 U32 const repIndex2 = current2 - offset_2;
455 const BYTE*
const repMatch2 = repIndex2 < prefixStartIndex ? dictBase + repIndex2 :
base + repIndex2;
456 if ( (((
U32)((prefixStartIndex-1) - repIndex2) >= 3) & (repIndex2 > dictStartIndex))
458 const BYTE*
const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
460 {
U32 const tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; }
475 return (
size_t)(iend - anchor);
481 void const*
src,
size_t srcSize)
void mls(int argc, const char *argv[])
MEM_STATIC U32 MEM_read32(const void *memPtr)
GLfloat GLfloat GLfloat GLfloat h
struct task_struct * current
ZSTD_compressionParameters cParams
const ZSTD_matchState_t * dictMatchState
#define FORCE_INLINE_TEMPLATE
MEM_STATIC size_t ZSTD_count_2segments(const BYTE *ip, const BYTE *match, const BYTE *iEnd, const BYTE *mEnd, const BYTE *iStart)
MEM_STATIC size_t ZSTD_hashPtr(const void *p, U32 hBits, U32 mls)
MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_matchState_t *ms, U32 current, unsigned windowLog)
MEM_STATIC U32 ZSTD_getLowestMatchIndex(const ZSTD_matchState_t *ms, U32 current, unsigned windowLog)
MEM_STATIC size_t ZSTD_count(const BYTE *pIn, const BYTE *pMatch, const BYTE *const pInLimit)
HINT_INLINE UNUSED_ATTR void ZSTD_storeSeq(seqStore_t *seqStorePtr, size_t litLength, const BYTE *literals, const BYTE *litLimit, U32 offCode, size_t mlBase)
ZSTD_dictTableLoadMethod_e
size_t ZSTD_compressBlock_fast_dictMatchState(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
FORCE_INLINE_TEMPLATE size_t ZSTD_compressBlock_fast_dictMatchState_generic(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize, U32 const mls)
size_t ZSTD_compressBlock_fast(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)
FORCE_INLINE_TEMPLATE size_t ZSTD_compressBlock_fast_generic(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize, U32 const mls)
static size_t ZSTD_compressBlock_fast_extDict_generic(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize, U32 const mls)
void ZSTD_fillHashTable(ZSTD_matchState_t *ms, const void *const end, ZSTD_dictTableLoadMethod_e dtlm)
size_t ZSTD_compressBlock_fast_extDict(ZSTD_matchState_t *ms, seqStore_t *seqStore, U32 rep[ZSTD_REP_NUM], void const *src, size_t srcSize)