• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching refs:p

17 static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)  in LzInWindow_Free()  argument
19 if (!p->directInput) in LzInWindow_Free()
21 alloc->Free(alloc, p->bufferBase); in LzInWindow_Free()
22 p->bufferBase = 0; in LzInWindow_Free()
28 static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) in LzInWindow_Create() argument
30 UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; in LzInWindow_Create()
31 if (p->directInput) in LzInWindow_Create()
33 p->blockSize = blockSize; in LzInWindow_Create()
36 if (p->bufferBase == 0 || p->blockSize != blockSize) in LzInWindow_Create()
38 LzInWindow_Free(p, alloc); in LzInWindow_Create()
39 p->blockSize = blockSize; in LzInWindow_Create()
40 p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize); in LzInWindow_Create()
42 return (p->bufferBase != 0); in LzInWindow_Create()
45 Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } in MatchFinder_GetPointerToCurrentPos() argument
46 Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; } in MatchFinder_GetIndexByte() argument
48 UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } in MatchFinder_GetNumAvailableBytes() argument
50 void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) in MatchFinder_ReduceOffsets() argument
52 p->posLimit -= subValue; in MatchFinder_ReduceOffsets()
53 p->pos -= subValue; in MatchFinder_ReduceOffsets()
54 p->streamPos -= subValue; in MatchFinder_ReduceOffsets()
57 static void MatchFinder_ReadBlock(CMatchFinder *p) in MatchFinder_ReadBlock() argument
59 if (p->streamEndWasReached || p->result != SZ_OK) in MatchFinder_ReadBlock()
61 if (p->directInput) in MatchFinder_ReadBlock()
63 UInt32 curSize = 0xFFFFFFFF - p->streamPos; in MatchFinder_ReadBlock()
64 if (curSize > p->directInputRem) in MatchFinder_ReadBlock()
65 curSize = (UInt32)p->directInputRem; in MatchFinder_ReadBlock()
66 p->directInputRem -= curSize; in MatchFinder_ReadBlock()
67 p->streamPos += curSize; in MatchFinder_ReadBlock()
68 if (p->directInputRem == 0) in MatchFinder_ReadBlock()
69 p->streamEndWasReached = 1; in MatchFinder_ReadBlock()
74 Byte *dest = p->buffer + (p->streamPos - p->pos); in MatchFinder_ReadBlock()
75 size_t size = (p->bufferBase + p->blockSize - dest); in MatchFinder_ReadBlock()
78 p->result = p->stream->Read(p->stream, dest, &size); in MatchFinder_ReadBlock()
79 if (p->result != SZ_OK) in MatchFinder_ReadBlock()
83 p->streamEndWasReached = 1; in MatchFinder_ReadBlock()
86 p->streamPos += (UInt32)size; in MatchFinder_ReadBlock()
87 if (p->streamPos - p->pos > p->keepSizeAfter) in MatchFinder_ReadBlock()
92 void MatchFinder_MoveBlock(CMatchFinder *p) in MatchFinder_MoveBlock() argument
94 memmove(p->bufferBase, in MatchFinder_MoveBlock()
95 p->buffer - p->keepSizeBefore, in MatchFinder_MoveBlock()
96 (size_t)(p->streamPos - p->pos + p->keepSizeBefore)); in MatchFinder_MoveBlock()
97 p->buffer = p->bufferBase + p->keepSizeBefore; in MatchFinder_MoveBlock()
100 int MatchFinder_NeedMove(CMatchFinder *p) in MatchFinder_NeedMove() argument
102 if (p->directInput) in MatchFinder_NeedMove()
105 return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); in MatchFinder_NeedMove()
108 void MatchFinder_ReadIfRequired(CMatchFinder *p) in MatchFinder_ReadIfRequired() argument
110 if (p->streamEndWasReached) in MatchFinder_ReadIfRequired()
112 if (p->keepSizeAfter >= p->streamPos - p->pos) in MatchFinder_ReadIfRequired()
113 MatchFinder_ReadBlock(p); in MatchFinder_ReadIfRequired()
116 static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) in MatchFinder_CheckAndMoveAndRead() argument
118 if (MatchFinder_NeedMove(p)) in MatchFinder_CheckAndMoveAndRead()
119 MatchFinder_MoveBlock(p); in MatchFinder_CheckAndMoveAndRead()
120 MatchFinder_ReadBlock(p); in MatchFinder_CheckAndMoveAndRead()
123 static void MatchFinder_SetDefaultSettings(CMatchFinder *p) in MatchFinder_SetDefaultSettings() argument
125 p->cutValue = 32; in MatchFinder_SetDefaultSettings()
126 p->btMode = 1; in MatchFinder_SetDefaultSettings()
127 p->numHashBytes = 4; in MatchFinder_SetDefaultSettings()
128 p->bigHash = 0; in MatchFinder_SetDefaultSettings()
133 void MatchFinder_Construct(CMatchFinder *p) in MatchFinder_Construct() argument
136 p->bufferBase = 0; in MatchFinder_Construct()
137 p->directInput = 0; in MatchFinder_Construct()
138 p->hash = 0; in MatchFinder_Construct()
139 MatchFinder_SetDefaultSettings(p); in MatchFinder_Construct()
147 p->crc[i] = r; in MatchFinder_Construct()
151 static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) in MatchFinder_FreeThisClassMemory() argument
153 alloc->Free(alloc, p->hash); in MatchFinder_FreeThisClassMemory()
154 p->hash = 0; in MatchFinder_FreeThisClassMemory()
157 void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc) in MatchFinder_Free() argument
159 MatchFinder_FreeThisClassMemory(p, alloc); in MatchFinder_Free()
160 LzInWindow_Free(p, alloc); in MatchFinder_Free()
171 int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, in MatchFinder_Create() argument
178 MatchFinder_Free(p, alloc); in MatchFinder_Create()
186 p->keepSizeBefore = historySize + keepAddBufferBefore + 1; in MatchFinder_Create()
187 p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; in MatchFinder_Create()
189 if (LzInWindow_Create(p, sizeReserv, alloc)) in MatchFinder_Create()
193 p->matchMaxLen = matchMaxLen; in MatchFinder_Create()
195 p->fixedHashSize = 0; in MatchFinder_Create()
196 if (p->numHashBytes == 2) in MatchFinder_Create()
209 if (p->numHashBytes == 3) in MatchFinder_Create()
215 p->hashMask = hs; in MatchFinder_Create()
217 if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; in MatchFinder_Create()
218 if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; in MatchFinder_Create()
219 if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; in MatchFinder_Create()
220 hs += p->fixedHashSize; in MatchFinder_Create()
224 UInt32 prevSize = p->hashSizeSum + p->numSons; in MatchFinder_Create()
226 p->historySize = historySize; in MatchFinder_Create()
227 p->hashSizeSum = hs; in MatchFinder_Create()
228 p->cyclicBufferSize = newCyclicBufferSize; in MatchFinder_Create()
229 p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize); in MatchFinder_Create()
230 newSize = p->hashSizeSum + p->numSons; in MatchFinder_Create()
231 if (p->hash != 0 && prevSize == newSize) in MatchFinder_Create()
233 MatchFinder_FreeThisClassMemory(p, alloc); in MatchFinder_Create()
234 p->hash = AllocRefs(newSize, alloc); in MatchFinder_Create()
235 if (p->hash != 0) in MatchFinder_Create()
237 p->son = p->hash + p->hashSizeSum; in MatchFinder_Create()
242 MatchFinder_Free(p, alloc); in MatchFinder_Create()
246 static void MatchFinder_SetLimits(CMatchFinder *p) in MatchFinder_SetLimits() argument
248 UInt32 limit = kMaxValForNormalize - p->pos; in MatchFinder_SetLimits()
249 UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; in MatchFinder_SetLimits()
252 limit2 = p->streamPos - p->pos; in MatchFinder_SetLimits()
253 if (limit2 <= p->keepSizeAfter) in MatchFinder_SetLimits()
259 limit2 -= p->keepSizeAfter; in MatchFinder_SetLimits()
263 UInt32 lenLimit = p->streamPos - p->pos; in MatchFinder_SetLimits()
264 if (lenLimit > p->matchMaxLen) in MatchFinder_SetLimits()
265 lenLimit = p->matchMaxLen; in MatchFinder_SetLimits()
266 p->lenLimit = lenLimit; in MatchFinder_SetLimits()
268 p->posLimit = p->pos + limit; in MatchFinder_SetLimits()
271 void MatchFinder_Init(CMatchFinder *p) in MatchFinder_Init() argument
274 for (i = 0; i < p->hashSizeSum; i++) in MatchFinder_Init()
275 p->hash[i] = kEmptyHashValue; in MatchFinder_Init()
276 p->cyclicBufferPos = 0; in MatchFinder_Init()
277 p->buffer = p->bufferBase; in MatchFinder_Init()
278 p->pos = p->streamPos = p->cyclicBufferSize; in MatchFinder_Init()
279 p->result = SZ_OK; in MatchFinder_Init()
280 p->streamEndWasReached = 0; in MatchFinder_Init()
281 MatchFinder_ReadBlock(p); in MatchFinder_Init()
282 MatchFinder_SetLimits(p); in MatchFinder_Init()
285 static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) in MatchFinder_GetSubValue() argument
287 return (p->pos - p->historySize - 1) & kNormalizeMask; in MatchFinder_GetSubValue()
304 static void MatchFinder_Normalize(CMatchFinder *p) in MatchFinder_Normalize() argument
306 UInt32 subValue = MatchFinder_GetSubValue(p); in MatchFinder_Normalize()
307 MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons); in MatchFinder_Normalize()
308 MatchFinder_ReduceOffsets(p, subValue); in MatchFinder_Normalize()
311 static void MatchFinder_CheckLimits(CMatchFinder *p) in MatchFinder_CheckLimits() argument
313 if (p->pos == kMaxValForNormalize) in MatchFinder_CheckLimits()
314 MatchFinder_Normalize(p); in MatchFinder_CheckLimits()
315 if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) in MatchFinder_CheckLimits()
316 MatchFinder_CheckAndMoveAndRead(p); in MatchFinder_CheckLimits()
317 if (p->cyclicBufferPos == p->cyclicBufferSize) in MatchFinder_CheckLimits()
318 p->cyclicBufferPos = 0; in MatchFinder_CheckLimits()
319 MatchFinder_SetLimits(p); in MatchFinder_CheckLimits()
459 ++p->cyclicBufferPos; \
460 p->buffer++; \
461 if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
465 static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } in MatchFinder_MovePos() argument
469 lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
470 cur = p->buffer;
475 #define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue argument
478 offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
482 SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
484 static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt2_MatchFinder_GetMatches() argument
489 curMatch = p->hash[hashValue]; in Bt2_MatchFinder_GetMatches()
490 p->hash[hashValue] = p->pos; in Bt2_MatchFinder_GetMatches()
495 UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt3Zip_MatchFinder_GetMatches() argument
500 curMatch = p->hash[hashValue]; in Bt3Zip_MatchFinder_GetMatches()
501 p->hash[hashValue] = p->pos; in Bt3Zip_MatchFinder_GetMatches()
506 static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt3_MatchFinder_GetMatches() argument
513 delta2 = p->pos - p->hash[hash2Value]; in Bt3_MatchFinder_GetMatches()
514 curMatch = p->hash[kFix3HashSize + hashValue]; in Bt3_MatchFinder_GetMatches()
516 p->hash[hash2Value] = in Bt3_MatchFinder_GetMatches()
517 p->hash[kFix3HashSize + hashValue] = p->pos; in Bt3_MatchFinder_GetMatches()
522 if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) in Bt3_MatchFinder_GetMatches()
532 SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); in Bt3_MatchFinder_GetMatches()
539 static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Bt4_MatchFinder_GetMatches() argument
546 delta2 = p->pos - p->hash[ hash2Value]; in Bt4_MatchFinder_GetMatches()
547 delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; in Bt4_MatchFinder_GetMatches()
548 curMatch = p->hash[kFix4HashSize + hashValue]; in Bt4_MatchFinder_GetMatches()
550 p->hash[ hash2Value] = in Bt4_MatchFinder_GetMatches()
551 p->hash[kFix3HashSize + hash3Value] = in Bt4_MatchFinder_GetMatches()
552 p->hash[kFix4HashSize + hashValue] = p->pos; in Bt4_MatchFinder_GetMatches()
556 if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) in Bt4_MatchFinder_GetMatches()
562 if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) in Bt4_MatchFinder_GetMatches()
577 SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); in Bt4_MatchFinder_GetMatches()
586 static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Hc4_MatchFinder_GetMatches() argument
593 delta2 = p->pos - p->hash[ hash2Value]; in Hc4_MatchFinder_GetMatches()
594 delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; in Hc4_MatchFinder_GetMatches()
595 curMatch = p->hash[kFix4HashSize + hashValue]; in Hc4_MatchFinder_GetMatches()
597 p->hash[ hash2Value] = in Hc4_MatchFinder_GetMatches()
598 p->hash[kFix3HashSize + hash3Value] = in Hc4_MatchFinder_GetMatches()
599 p->hash[kFix4HashSize + hashValue] = p->pos; in Hc4_MatchFinder_GetMatches()
603 if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) in Hc4_MatchFinder_GetMatches()
609 if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) in Hc4_MatchFinder_GetMatches()
624 p->son[p->cyclicBufferPos] = curMatch; in Hc4_MatchFinder_GetMatches()
630 offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), in Hc4_MatchFinder_GetMatches()
635 UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) in Hc3Zip_MatchFinder_GetMatches() argument
640 curMatch = p->hash[hashValue]; in Hc3Zip_MatchFinder_GetMatches()
641 p->hash[hashValue] = p->pos; in Hc3Zip_MatchFinder_GetMatches()
642 offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), in Hc3Zip_MatchFinder_GetMatches()
647 static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt2_MatchFinder_Skip() argument
653 curMatch = p->hash[hashValue]; in Bt2_MatchFinder_Skip()
654 p->hash[hashValue] = p->pos; in Bt2_MatchFinder_Skip()
660 void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt3Zip_MatchFinder_Skip() argument
666 curMatch = p->hash[hashValue]; in Bt3Zip_MatchFinder_Skip()
667 p->hash[hashValue] = p->pos; in Bt3Zip_MatchFinder_Skip()
673 static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt3_MatchFinder_Skip() argument
680 curMatch = p->hash[kFix3HashSize + hashValue]; in Bt3_MatchFinder_Skip()
681 p->hash[hash2Value] = in Bt3_MatchFinder_Skip()
682 p->hash[kFix3HashSize + hashValue] = p->pos; in Bt3_MatchFinder_Skip()
688 static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Bt4_MatchFinder_Skip() argument
695 curMatch = p->hash[kFix4HashSize + hashValue]; in Bt4_MatchFinder_Skip()
696 p->hash[ hash2Value] = in Bt4_MatchFinder_Skip()
697 p->hash[kFix3HashSize + hash3Value] = p->pos; in Bt4_MatchFinder_Skip()
698 p->hash[kFix4HashSize + hashValue] = p->pos; in Bt4_MatchFinder_Skip()
704 static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Hc4_MatchFinder_Skip() argument
711 curMatch = p->hash[kFix4HashSize + hashValue]; in Hc4_MatchFinder_Skip()
712 p->hash[ hash2Value] = in Hc4_MatchFinder_Skip()
713 p->hash[kFix3HashSize + hash3Value] = in Hc4_MatchFinder_Skip()
714 p->hash[kFix4HashSize + hashValue] = p->pos; in Hc4_MatchFinder_Skip()
715 p->son[p->cyclicBufferPos] = curMatch; in Hc4_MatchFinder_Skip()
721 void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) in Hc3Zip_MatchFinder_Skip() argument
727 curMatch = p->hash[hashValue]; in Hc3Zip_MatchFinder_Skip()
728 p->hash[hashValue] = p->pos; in Hc3Zip_MatchFinder_Skip()
729 p->son[p->cyclicBufferPos] = curMatch; in Hc3Zip_MatchFinder_Skip()
735 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) in MatchFinder_CreateVTable() argument
741 if (!p->btMode) in MatchFinder_CreateVTable()
746 else if (p->numHashBytes == 2) in MatchFinder_CreateVTable()
751 else if (p->numHashBytes == 3) in MatchFinder_CreateVTable()