Lines Matching +full:- +full:p

1 /* LzFind.c -- Match finder for LZ algorithms
2 2018-07-08 : Igor Pavlov : Public domain */
14 #define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))
19 static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc) in LzInWindow_Free() argument
21 if (!p->directInput) in LzInWindow_Free()
23 ISzAlloc_Free(alloc, p->bufferBase); in LzInWindow_Free()
24 p->bufferBase = NULL; in LzInWindow_Free()
30 static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc) in LzInWindow_Create() argument
32 UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; in LzInWindow_Create()
33 if (p->directInput) in LzInWindow_Create()
35 p->blockSize = blockSize; in LzInWindow_Create()
38 if (!p->bufferBase || p->blockSize != blockSize) in LzInWindow_Create()
40 LzInWindow_Free(p, alloc); in LzInWindow_Create()
41 p->blockSize = blockSize; in LzInWindow_Create()
42 p->bufferBase = (Byte *)ISzAlloc_Alloc(alloc, (size_t)blockSize); in LzInWindow_Create()
44 return (p->bufferBase != NULL); in LzInWindow_Create()
47 Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } in MatchFinder_GetPointerToCurrentPos() argument
49 UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } in MatchFinder_GetNumAvailableBytes() argument
51 void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) in MatchFinder_ReduceOffsets() argument
53 p->posLimit -= subValue; in MatchFinder_ReduceOffsets()
54 p->pos -= subValue; in MatchFinder_ReduceOffsets()
55 p->streamPos -= subValue; in MatchFinder_ReduceOffsets()
58 static void MatchFinder_ReadBlock(CMatchFinder *p) in MatchFinder_ReadBlock() argument
60 if (p->streamEndWasReached || p->result != SZ_OK) in MatchFinder_ReadBlock()
63 /* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */ in MatchFinder_ReadBlock()
65 if (p->directInput) in MatchFinder_ReadBlock()
67 UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos); in MatchFinder_ReadBlock()
68 if (curSize > p->directInputRem) in MatchFinder_ReadBlock()
69 curSize = (UInt32)p->directInputRem; in MatchFinder_ReadBlock()
70 p->directInputRem -= curSize; in MatchFinder_ReadBlock()
71 p->streamPos += curSize; in MatchFinder_ReadBlock()
72 if (p->directInputRem == 0) in MatchFinder_ReadBlock()
73 p->streamEndWasReached = 1; in MatchFinder_ReadBlock()
79 Byte *dest = p->buffer + (p->streamPos - p->pos); in MatchFinder_ReadBlock()
80 size_t size = (p->bufferBase + p->blockSize - dest); in MatchFinder_ReadBlock()
84 p->result = ISeqInStream_Read(p->stream, dest, &size); in MatchFinder_ReadBlock()
85 if (p->result != SZ_OK) in MatchFinder_ReadBlock()
89 p->streamEndWasReached = 1; in MatchFinder_ReadBlock()
92 p->streamPos += (UInt32)size; in MatchFinder_ReadBlock()
93 if (p->streamPos - p->pos > p->keepSizeAfter) in MatchFinder_ReadBlock()
98 void MatchFinder_MoveBlock(CMatchFinder *p) in MatchFinder_MoveBlock() argument
100 memmove(p->bufferBase, in MatchFinder_MoveBlock()
101 p->buffer - p->keepSizeBefore, in MatchFinder_MoveBlock()
102 (size_t)(p->streamPos - p->pos) + p->keepSizeBefore); in MatchFinder_MoveBlock()
103 p->buffer = p->bufferBase + p->keepSizeBefore; in MatchFinder_MoveBlock()
106 int MatchFinder_NeedMove(CMatchFinder *p) in MatchFinder_NeedMove() argument
108 if (p->directInput) in MatchFinder_NeedMove()
110 /* if (p->streamEndWasReached) return 0; */ in MatchFinder_NeedMove()
111 return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); in MatchFinder_NeedMove()
114 void MatchFinder_ReadIfRequired(CMatchFinder *p) in MatchFinder_ReadIfRequired() argument
116 if (p->streamEndWasReached) in MatchFinder_ReadIfRequired()
118 if (p->keepSizeAfter >= p->streamPos - p->pos) in MatchFinder_ReadIfRequired()
119 MatchFinder_ReadBlock(p); in MatchFinder_ReadIfRequired()
122 static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) in MatchFinder_CheckAndMoveAndRead() argument
124 if (MatchFinder_NeedMove(p)) in MatchFinder_CheckAndMoveAndRead()
125 MatchFinder_MoveBlock(p); in MatchFinder_CheckAndMoveAndRead()
126 MatchFinder_ReadBlock(p); in MatchFinder_CheckAndMoveAndRead()
129 static void MatchFinder_SetDefaultSettings(CMatchFinder *p) in MatchFinder_SetDefaultSettings() argument
131 p->cutValue = 32; in MatchFinder_SetDefaultSettings()
132 p->btMode = 1; in MatchFinder_SetDefaultSettings()
133 p->numHashBytes = 4; in MatchFinder_SetDefaultSettings()
134 p->bigHash = 0; in MatchFinder_SetDefaultSettings()
139 void MatchFinder_Construct(CMatchFinder *p) in MatchFinder_Construct() argument
142 p->bufferBase = NULL; in MatchFinder_Construct()
143 p->directInput = 0; in MatchFinder_Construct()
144 p->hash = NULL; in MatchFinder_Construct()
145 p->expectedDataSize = (UInt64)(Int64)-1; in MatchFinder_Construct()
146 MatchFinder_SetDefaultSettings(p); in MatchFinder_Construct()
153 r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); in MatchFinder_Construct()
154 p->crc[i] = r; in MatchFinder_Construct()
158 static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc) in MatchFinder_FreeThisClassMemory() argument
160 ISzAlloc_Free(alloc, p->hash); in MatchFinder_FreeThisClassMemory()
161 p->hash = NULL; in MatchFinder_FreeThisClassMemory()
164 void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc) in MatchFinder_Free() argument
166 MatchFinder_FreeThisClassMemory(p, alloc); in MatchFinder_Free()
167 LzInWindow_Free(p, alloc); in MatchFinder_Free()
178 int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, in MatchFinder_Create() argument
186 MatchFinder_Free(p, alloc); in MatchFinder_Create()
196 p->keepSizeBefore = historySize + keepAddBufferBefore + 1; in MatchFinder_Create()
197 p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; in MatchFinder_Create()
201 if (LzInWindow_Create(p, sizeReserv, alloc)) in MatchFinder_Create()
205 p->matchMaxLen = matchMaxLen; in MatchFinder_Create()
207 p->fixedHashSize = 0; in MatchFinder_Create()
208 if (p->numHashBytes == 2) in MatchFinder_Create()
209 hs = (1 << 16) - 1; in MatchFinder_Create()
213 if (hs > p->expectedDataSize) in MatchFinder_Create()
214 hs = (UInt32)p->expectedDataSize; in MatchFinder_Create()
216 hs--; in MatchFinder_Create()
225 if (p->numHashBytes == 3) in MatchFinder_Create()
226 hs = (1 << 24) - 1; in MatchFinder_Create()
229 /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */ in MatchFinder_Create()
232 p->hashMask = hs; in MatchFinder_Create()
234 if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; in MatchFinder_Create()
235 if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; in MatchFinder_Create()
236 if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; in MatchFinder_Create()
237 hs += p->fixedHashSize; in MatchFinder_Create()
243 p->historySize = historySize; in MatchFinder_Create()
244 p->hashSizeSum = hs; in MatchFinder_Create()
245 p->cyclicBufferSize = newCyclicBufferSize; in MatchFinder_Create()
248 if (p->btMode) in MatchFinder_Create()
252 if (p->hash && p->numRefs == newSize) in MatchFinder_Create()
255 MatchFinder_FreeThisClassMemory(p, alloc); in MatchFinder_Create()
256 p->numRefs = newSize; in MatchFinder_Create()
257 p->hash = AllocRefs(newSize, alloc); in MatchFinder_Create()
259 if (p->hash) in MatchFinder_Create()
261 p->son = p->hash + p->hashSizeSum; in MatchFinder_Create()
267 MatchFinder_Free(p, alloc); in MatchFinder_Create()
271 static void MatchFinder_SetLimits(CMatchFinder *p) in MatchFinder_SetLimits() argument
273 UInt32 limit = kMaxValForNormalize - p->pos; in MatchFinder_SetLimits()
274 UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; in MatchFinder_SetLimits()
278 limit2 = p->streamPos - p->pos; in MatchFinder_SetLimits()
280 if (limit2 <= p->keepSizeAfter) in MatchFinder_SetLimits()
286 limit2 -= p->keepSizeAfter; in MatchFinder_SetLimits()
292 UInt32 lenLimit = p->streamPos - p->pos; in MatchFinder_SetLimits()
293 if (lenLimit > p->matchMaxLen) in MatchFinder_SetLimits()
294 lenLimit = p->matchMaxLen; in MatchFinder_SetLimits()
295 p->lenLimit = lenLimit; in MatchFinder_SetLimits()
297 p->posLimit = p->pos + limit; in MatchFinder_SetLimits()
301 void MatchFinder_Init_LowHash(CMatchFinder *p) in MatchFinder_Init_LowHash() argument
304 CLzRef *items = p->hash; in MatchFinder_Init_LowHash()
305 size_t numItems = p->fixedHashSize; in MatchFinder_Init_LowHash()
311 void MatchFinder_Init_HighHash(CMatchFinder *p) in MatchFinder_Init_HighHash() argument
314 CLzRef *items = p->hash + p->fixedHashSize; in MatchFinder_Init_HighHash()
315 size_t numItems = (size_t)p->hashMask + 1; in MatchFinder_Init_HighHash()
321 void MatchFinder_Init_3(CMatchFinder *p, int readData) in MatchFinder_Init_3() argument
323 p->cyclicBufferPos = 0; in MatchFinder_Init_3()
324 p->buffer = p->bufferBase; in MatchFinder_Init_3()
325 p->pos = in MatchFinder_Init_3()
326 p->streamPos = p->cyclicBufferSize; in MatchFinder_Init_3()
327 p->result = SZ_OK; in MatchFinder_Init_3()
328 p->streamEndWasReached = 0; in MatchFinder_Init_3()
331 MatchFinder_ReadBlock(p); in MatchFinder_Init_3()
333 MatchFinder_SetLimits(p); in MatchFinder_Init_3()
337 void MatchFinder_Init(CMatchFinder *p) in MatchFinder_Init() argument
339 MatchFinder_Init_HighHash(p); in MatchFinder_Init()
340 MatchFinder_Init_LowHash(p); in MatchFinder_Init()
341 MatchFinder_Init_3(p, True); in MatchFinder_Init()
345 static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) in MatchFinder_GetSubValue() argument
347 return (p->pos - p->historySize - 1) & kNormalizeMask; in MatchFinder_GetSubValue()
359 value -= subValue; in MatchFinder_Normalize3()
364 static void MatchFinder_Normalize(CMatchFinder *p) in MatchFinder_Normalize() argument
366 UInt32 subValue = MatchFinder_GetSubValue(p); in MatchFinder_Normalize()
367 MatchFinder_Normalize3(subValue, p->hash, p->numRefs); in MatchFinder_Normalize()
368 MatchFinder_ReduceOffsets(p, subValue); in MatchFinder_Normalize()
373 static void MatchFinder_CheckLimits(CMatchFinder *p) in MatchFinder_CheckLimits() argument
375 if (p->pos == kMaxValForNormalize) in MatchFinder_CheckLimits()
376 MatchFinder_Normalize(p); in MatchFinder_CheckLimits()
377 if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) in MatchFinder_CheckLimits()
378 MatchFinder_CheckAndMoveAndRead(p); in MatchFinder_CheckLimits()
379 if (p->cyclicBufferPos == p->cyclicBufferSize) in MatchFinder_CheckLimits()
380 p->cyclicBufferPos = 0; in MatchFinder_CheckLimits()
381 MatchFinder_SetLimits(p); in MatchFinder_CheckLimits()
397 UInt32 delta = pos - curMatch; in Hc_GetMatchesSpec()
398 if (cutValue-- == 0 || delta >= _cyclicBufferSize) in Hc_GetMatchesSpec()
401 const Byte *pb = cur - delta; in Hc_GetMatchesSpec()
402 … curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; in Hc_GetMatchesSpec()
413 *distances++ = delta - 1; in Hc_GetMatchesSpec()
426 UInt32 delta = pos - curMatch; in Hc_GetMatchesSpec()
431 … curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; in Hc_GetMatchesSpec()
432 diff = (ptrdiff_t)0 - delta; in Hc_GetMatchesSpec()
440 distances[0] = (UInt32)(lim - cur); in Hc_GetMatchesSpec()
441 distances[1] = delta - 1; in Hc_GetMatchesSpec()
446 unsigned len = (unsigned)(c - cur); in Hc_GetMatchesSpec()
451 distances[1] = delta - 1; in Hc_GetMatchesSpec()
458 while (--cutValue); in Hc_GetMatchesSpec()
474 UInt32 delta = pos - curMatch; in GetMatchesSpec1()
475 if (cutValue-- == 0 || delta >= _cyclicBufferSize) in GetMatchesSpec1()
481 …CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBuf… in GetMatchesSpec1()
482 const Byte *pb = cur - delta; in GetMatchesSpec1()
495 *distances++ = delta - 1; in GetMatchesSpec1()
530 UInt32 delta = pos - curMatch; in SkipMatchesSpec()
531 if (cutValue-- == 0 || delta >= _cyclicBufferSize) in SkipMatchesSpec()
537 …CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBuf… in SkipMatchesSpec()
538 const Byte *pb = cur - delta; in SkipMatchesSpec()
573 ++p->cyclicBufferPos; \
574 p->buffer++; \
575 if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
579 static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } in MatchFinder_MovePos() argument
583 lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
584 cur = p->buffer;
589 #define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue argument
592 offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \
593 distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;
596 SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
599 ptrdiff_t diff = (ptrdiff_t)0 - d2; \
603 maxLen = (unsigned)(c - cur); }
605 static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt2_MatchFinder_GetMatches() argument
610 curMatch = p->hash[hv]; in Bt2_MatchFinder_GetMatches()
611 p->hash[hv] = p->pos; in Bt2_MatchFinder_GetMatches()
616 UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt3Zip_MatchFinder_GetMatches() argument
621 curMatch = p->hash[hv]; in Bt3Zip_MatchFinder_GetMatches()
622 p->hash[hv] = p->pos; in Bt3Zip_MatchFinder_GetMatches()
627 static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt3_MatchFinder_GetMatches() argument
636 hash = p->hash; in Bt3_MatchFinder_GetMatches()
637 pos = p->pos; in Bt3_MatchFinder_GetMatches()
639 d2 = pos - hash[h2]; in Bt3_MatchFinder_GetMatches()
649 if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) in Bt3_MatchFinder_GetMatches()
653 distances[1] = d2 - 1; in Bt3_MatchFinder_GetMatches()
657 SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); in Bt3_MatchFinder_GetMatches()
665 static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt4_MatchFinder_GetMatches() argument
674 hash = p->hash; in Bt4_MatchFinder_GetMatches()
675 pos = p->pos; in Bt4_MatchFinder_GetMatches()
677 d2 = pos - hash [h2]; in Bt4_MatchFinder_GetMatches()
678 d3 = pos - (hash + kFix3HashSize)[h3]; in Bt4_MatchFinder_GetMatches()
689 if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) in Bt4_MatchFinder_GetMatches()
693 distances[1] = d2 - 1; in Bt4_MatchFinder_GetMatches()
697 if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) in Bt4_MatchFinder_GetMatches()
700 distances[(size_t)offset + 1] = d3 - 1; in Bt4_MatchFinder_GetMatches()
708 distances[(size_t)offset - 2] = (UInt32)maxLen; in Bt4_MatchFinder_GetMatches()
711 SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); in Bt4_MatchFinder_GetMatches()
723 static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
731 hash = p->hash;
732 pos = p->pos;
734 d2 = pos - hash [h2];
735 d3 = pos - (hash + kFix3HashSize)[h3];
736 d4 = pos - (hash + kFix4HashSize)[h4];
748 if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
751 distances[1] = d2 - 1;
753 if (*(cur - d2 + 2) == cur[2])
755 else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
758 distances[3] = d3 - 1;
763 else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
766 distances[1] = d3 - 1;
771 if (d2 != d4 && d4 < p->cyclicBufferSize
772 && *(cur - d4) == *cur
773 && *(cur - d4 + 3) == *(cur + 3))
776 distances[(size_t)offset + 1] = d4 - 1;
784 distances[(size_t)offset - 2] = maxLen;
787 SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
799 static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Hc4_MatchFinder_GetMatches() argument
808 hash = p->hash; in Hc4_MatchFinder_GetMatches()
809 pos = p->pos; in Hc4_MatchFinder_GetMatches()
811 d2 = pos - hash [h2]; in Hc4_MatchFinder_GetMatches()
812 d3 = pos - (hash + kFix3HashSize)[h3]; in Hc4_MatchFinder_GetMatches()
822 if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) in Hc4_MatchFinder_GetMatches()
826 distances[1] = d2 - 1; in Hc4_MatchFinder_GetMatches()
830 if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) in Hc4_MatchFinder_GetMatches()
833 distances[(size_t)offset + 1] = d3 - 1; in Hc4_MatchFinder_GetMatches()
841 distances[(size_t)offset - 2] = (UInt32)maxLen; in Hc4_MatchFinder_GetMatches()
844 p->son[p->cyclicBufferPos] = curMatch; in Hc4_MatchFinder_GetMatches()
852 offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), in Hc4_MatchFinder_GetMatches()
853 distances + offset, maxLen) - (distances)); in Hc4_MatchFinder_GetMatches()
858 static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
866 hash = p->hash;
867 pos = p->pos;
869 d2 = pos - hash [h2];
870 d3 = pos - (hash + kFix3HashSize)[h3];
871 d4 = pos - (hash + kFix4HashSize)[h4];
883 if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
886 distances[1] = d2 - 1;
888 if (*(cur - d2 + 2) == cur[2])
890 else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
893 distances[3] = d3 - 1;
898 else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
901 distances[1] = d3 - 1;
906 if (d2 != d4 && d4 < p->cyclicBufferSize
907 && *(cur - d4) == *cur
908 && *(cur - d4 + 3) == *(cur + 3))
911 distances[(size_t)offset + 1] = d4 - 1;
919 distances[(size_t)offset - 2] = maxLen;
922 p->son[p->cyclicBufferPos] = curMatch;
930 offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
931 distances + offset, maxLen) - (distances));
936 UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Hc3Zip_MatchFinder_GetMatches() argument
941 curMatch = p->hash[hv]; in Hc3Zip_MatchFinder_GetMatches()
942 p->hash[hv] = p->pos; in Hc3Zip_MatchFinder_GetMatches()
943 offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), in Hc3Zip_MatchFinder_GetMatches()
944 distances, 2) - (distances)); in Hc3Zip_MatchFinder_GetMatches()
948 static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt2_MatchFinder_Skip() argument
954 curMatch = p->hash[hv]; in Bt2_MatchFinder_Skip()
955 p->hash[hv] = p->pos; in Bt2_MatchFinder_Skip()
958 while (--num != 0); in Bt2_MatchFinder_Skip()
961 void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt3Zip_MatchFinder_Skip() argument
967 curMatch = p->hash[hv]; in Bt3Zip_MatchFinder_Skip()
968 p->hash[hv] = p->pos; in Bt3Zip_MatchFinder_Skip()
971 while (--num != 0); in Bt3Zip_MatchFinder_Skip()
974 static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt3_MatchFinder_Skip() argument
982 hash = p->hash; in Bt3_MatchFinder_Skip()
985 (hash + kFix3HashSize)[hv] = p->pos; in Bt3_MatchFinder_Skip()
988 while (--num != 0); in Bt3_MatchFinder_Skip()
991 static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt4_MatchFinder_Skip() argument
999 hash = p->hash; in Bt4_MatchFinder_Skip()
1003 (hash + kFix4HashSize)[hv] = p->pos; in Bt4_MatchFinder_Skip()
1006 while (--num != 0); in Bt4_MatchFinder_Skip()
1010 static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
1018 hash = p->hash;
1023 (hash + kFix5HashSize)[hv] = p->pos;
1026 while (--num != 0);
1030 static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Hc4_MatchFinder_Skip() argument
1038 hash = p->hash; in Hc4_MatchFinder_Skip()
1042 (hash + kFix4HashSize)[hv] = p->pos; in Hc4_MatchFinder_Skip()
1043 p->son[p->cyclicBufferPos] = curMatch; in Hc4_MatchFinder_Skip()
1046 while (--num != 0); in Hc4_MatchFinder_Skip()
1050 static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
1058 hash = p->hash;
1063 (hash + kFix5HashSize)[hv] = p->pos;
1064 p->son[p->cyclicBufferPos] = curMatch;
1067 while (--num != 0);
1071 void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Hc3Zip_MatchFinder_Skip() argument
1077 curMatch = p->hash[hv]; in Hc3Zip_MatchFinder_Skip()
1078 p->hash[hv] = p->pos; in Hc3Zip_MatchFinder_Skip()
1079 p->son[p->cyclicBufferPos] = curMatch; in Hc3Zip_MatchFinder_Skip()
1082 while (--num != 0); in Hc3Zip_MatchFinder_Skip()
1085 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) in MatchFinder_CreateVTable() argument
1087 vTable->Init = (Mf_Init_Func)MatchFinder_Init; in MatchFinder_CreateVTable()
1088 vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; in MatchFinder_CreateVTable()
1089 …vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPo… in MatchFinder_CreateVTable()
1090 if (!p->btMode) in MatchFinder_CreateVTable()
1092 /* if (p->numHashBytes <= 4) */ in MatchFinder_CreateVTable()
1094 vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1095 vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; in MatchFinder_CreateVTable()
1100 vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1101 vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip; in MatchFinder_CreateVTable()
1105 else if (p->numHashBytes == 2) in MatchFinder_CreateVTable()
1107 vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1108 vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; in MatchFinder_CreateVTable()
1110 else if (p->numHashBytes == 3) in MatchFinder_CreateVTable()
1112 vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1113 vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; in MatchFinder_CreateVTable()
1115 else /* if (p->numHashBytes == 4) */ in MatchFinder_CreateVTable()
1117 vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1118 vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; in MatchFinder_CreateVTable()
1123 vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches; in MatchFinder_CreateVTable()
1124 vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip; in MatchFinder_CreateVTable()