summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c')
-rw-r--r--MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c
index 5128fc9518..8765cbebfc 100644
--- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c
+++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c
@@ -75,7 +75,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
p->streamEndWasReached = 1;
return;
}
-
+
for (;;)
{
Byte *dest = p->buffer + (p->streamPos - p->pos);
@@ -182,24 +182,24 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
ISzAllocPtr alloc)
{
UInt32 sizeReserv;
-
+
if (historySize > kMaxHistorySize)
{
MatchFinder_Free(p, alloc);
return 0;
}
-
+
sizeReserv = historySize >> 1;
if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;
else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;
-
+
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
-
+
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
-
+
if (LzInWindow_Create(p, sizeReserv, alloc))
{
UInt32 newCyclicBufferSize = historySize + 1;
@@ -245,7 +245,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
p->historySize = historySize;
p->hashSizeSum = hs;
p->cyclicBufferSize = newCyclicBufferSize;
-
+
numSons = newCyclicBufferSize;
if (p->btMode)
numSons <<= 1;
@@ -253,11 +253,11 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
if (p->hash && p->numRefs == newSize)
return 1;
-
+
MatchFinder_FreeThisClassMemory(p, alloc);
p->numRefs = newSize;
p->hash = AllocRefs(newSize, alloc);
-
+
if (p->hash)
{
p->son = p->hash + p->hashSizeSum;
@@ -274,11 +274,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
{
UInt32 limit = kMaxValForNormalize - p->pos;
UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
-
+
if (limit2 < limit)
limit = limit2;
limit2 = p->streamPos - p->pos;
-
+
if (limit2 <= p->keepSizeAfter)
{
if (limit2 > 0)
@@ -286,10 +286,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
}
else
limit2 -= p->keepSizeAfter;
-
+
if (limit2 < limit)
limit = limit2;
-
+
{
UInt32 lenLimit = p->streamPos - p->pos;
if (lenLimit > p->matchMaxLen)
@@ -328,10 +328,10 @@ void MatchFinder_Init_3(CMatchFinder *p, int readData)
p->streamPos = p->cyclicBufferSize;
p->result = SZ_OK;
p->streamEndWasReached = 0;
-
+
if (readData)
MatchFinder_ReadBlock(p);
-
+
MatchFinder_SetLimits(p);
}
@@ -343,7 +343,7 @@ void MatchFinder_Init(CMatchFinder *p)
MatchFinder_Init_3(p, True);
}
-
+
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
@@ -586,7 +586,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
d2 = pos - hash[h2];
curMatch = (hash + kFix3HashSize)[hv];
-
+
hash[h2] = pos;
(hash + kFix3HashSize)[hv] = pos;
@@ -605,7 +605,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET;
}
}
-
+
GET_MATCHES_FOOTER(offset, maxLen)
}
@@ -631,14 +631,14 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
maxLen = 0;
offset = 0;
-
+
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
{
distances[0] = maxLen = 2;
distances[1] = d2 - 1;
offset = 2;
}
-
+
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
{
maxLen = 3;
@@ -646,7 +646,7 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset += 2;
d2 = d3;
}
-
+
if (offset != 0)
{
UPDATE_maxLen
@@ -657,10 +657,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET;
}
}
-
+
if (maxLen < 3)
maxLen = 3;
-
+
GET_MATCHES_FOOTER(offset, maxLen)
}
@@ -712,7 +712,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset = 2;
d2 = d3;
}
-
+
if (d2 != d4 && d4 < p->cyclicBufferSize
&& *(cur - d4) == *cur
&& *(cur - d4 + 3) == *(cur + 3))
@@ -722,7 +722,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset += 2;
d2 = d4;
}
-
+
if (offset != 0)
{
UPDATE_maxLen
@@ -736,7 +736,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (maxLen < 4)
maxLen = 4;
-
+
GET_MATCHES_FOOTER(offset, maxLen)
}
*/
@@ -751,10 +751,10 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
hash = p->hash;
pos = p->pos;
-
+
d2 = pos - hash[ h2];
d3 = pos - (hash + kFix3HashSize)[h3];
-
+
curMatch = (hash + kFix4HashSize)[hv];
hash[ h2] = pos;
@@ -770,7 +770,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
distances[1] = d2 - 1;
offset = 2;
}
-
+
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
{
maxLen = 3;
@@ -778,7 +778,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset += 2;
d2 = d3;
}
-
+
if (offset != 0)
{
UPDATE_maxLen
@@ -789,7 +789,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET;
}
}
-
+
if (maxLen < 3)
maxLen = 3;
@@ -809,7 +809,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
hash = p->hash;
pos = p->pos;
-
+
d2 = pos - hash[ h2];
d3 = pos - (hash + kFix3HashSize)[h3];
d4 = pos - (hash + kFix4HashSize)[h4];
@@ -846,7 +846,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset = 2;
d2 = d3;
}
-
+
if (d2 != d4 && d4 < p->cyclicBufferSize
&& *(cur - d4) == *cur
&& *(cur - d4 + 3) == *(cur + 3))
@@ -856,7 +856,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
offset += 2;
d2 = d4;
}
-
+
if (offset != 0)
{
UPDATE_maxLen
@@ -867,7 +867,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET;
}
}
-
+
if (maxLen < 4)
maxLen = 4;