DeflateEncoder.cpp (p7zip_15.14.1_src_all) | : | DeflateEncoder.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 333 | skipping to change at line 333 | |||
{ | { | |||
UInt32 len = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentInde x; | UInt32 len = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentInde x; | |||
backRes = m_Optimum[m_OptimumCurrentIndex].BackPrev; | backRes = m_Optimum[m_OptimumCurrentIndex].BackPrev; | |||
m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev; | m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev; | |||
return len; | return len; | |||
} | } | |||
m_OptimumCurrentIndex = m_OptimumEndIndex = 0; | m_OptimumCurrentIndex = m_OptimumEndIndex = 0; | |||
GetMatches(); | GetMatches(); | |||
UInt32 numDistancePairs = m_MatchDistances[0]; | UInt32 lenEnd; | |||
if (numDistancePairs == 0) | { | |||
return 1; | const UInt32 numDistancePairs = m_MatchDistances[0]; | |||
if (numDistancePairs == 0) | ||||
return 1; | ||||
const UInt16 *matchDistances = m_MatchDistances + 1; | ||||
lenEnd = matchDistances[numDistancePairs - 2]; | ||||
const UInt16 *matchDistances = m_MatchDistances + 1; | if (lenEnd > m_NumFastBytes) | |||
UInt32 lenMain = matchDistances[numDistancePairs - 2]; | { | |||
backRes = matchDistances[numDistancePairs - 1]; | ||||
MovePos(lenEnd - 1); | ||||
return lenEnd; | ||||
} | ||||
if (lenMain > m_NumFastBytes) | m_Optimum[1].Price = m_LiteralPrices[*(Inline_MatchFinder_GetPointerToCurren | |||
{ | tPos(&_lzInWindow) - m_AdditionalOffset)]; | |||
backRes = matchDistances[numDistancePairs - 1]; | m_Optimum[1].PosPrev = 0; | |||
MovePos(lenMain - 1); | ||||
return lenMain; | ||||
} | ||||
m_Optimum[1].Price = m_LiteralPrices[*(Inline_MatchFinder_GetPointerToCurrentP | ||||
os(&_lzInWindow) - m_AdditionalOffset)]; | ||||
m_Optimum[1].PosPrev = 0; | ||||
m_Optimum[2].Price = kIfinityPrice; | m_Optimum[2].Price = kIfinityPrice; | |||
m_Optimum[2].PosPrev = 1; | m_Optimum[2].PosPrev = 1; | |||
UInt32 offs = 0; | UInt32 offs = 0; | |||
for (UInt32 i = kMatchMinLen; i <= lenMain; i++) | ||||
{ | for (UInt32 i = kMatchMinLen; i <= lenEnd; i++) | |||
UInt32 distance = matchDistances[offs + 1]; | { | |||
m_Optimum[i].PosPrev = 0; | UInt32 distance = matchDistances[offs + 1]; | |||
m_Optimum[i].BackPrev = (UInt16)distance; | m_Optimum[i].PosPrev = 0; | |||
m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot( | m_Optimum[i].BackPrev = (UInt16)distance; | |||
distance)]; | m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlo | |||
if (i == matchDistances[offs]) | t(distance)]; | |||
offs += 2; | if (i == matchDistances[offs]) | |||
offs += 2; | ||||
} | ||||
} | } | |||
UInt32 cur = 0; | UInt32 cur = 0; | |||
UInt32 lenEnd = lenMain; | ||||
for (;;) | for (;;) | |||
{ | { | |||
++cur; | ++cur; | |||
if (cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit) | if (cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit) | |||
return Backward(backRes, cur); | return Backward(backRes, cur); | |||
GetMatches(); | GetMatches(); | |||
matchDistances = m_MatchDistances + 1; | const UInt16 *matchDistances = m_MatchDistances + 1; | |||
const UInt32 numDistancePairs = m_MatchDistances[0]; | ||||
UInt32 numDistancePairs = m_MatchDistances[0]; | ||||
UInt32 newLen = 0; | UInt32 newLen = 0; | |||
if (numDistancePairs != 0) | if (numDistancePairs != 0) | |||
{ | { | |||
newLen = matchDistances[numDistancePairs - 2]; | newLen = matchDistances[numDistancePairs - 2]; | |||
if (newLen > m_NumFastBytes) | if (newLen > m_NumFastBytes) | |||
{ | { | |||
UInt32 len = Backward(backRes, cur); | UInt32 len = Backward(backRes, cur); | |||
m_Optimum[cur].BackPrev = matchDistances[numDistancePairs - 1]; | m_Optimum[cur].BackPrev = matchDistances[numDistancePairs - 1]; | |||
m_OptimumEndIndex = cur + newLen; | m_OptimumEndIndex = cur + newLen; | |||
m_Optimum[cur].PosPrev = (UInt16)m_OptimumEndIndex; | m_Optimum[cur].PosPrev = (UInt16)m_OptimumEndIndex; | |||
MovePos(newLen - 1); | MovePos(newLen - 1); | |||
return len; | return len; | |||
} | } | |||
} | } | |||
UInt32 curPrice = m_Optimum[cur].Price; | UInt32 curPrice = m_Optimum[cur].Price; | |||
UInt32 curAnd1Price = curPrice + m_LiteralPrices[*(Inline_MatchFinder_GetPoi | ||||
nterToCurrentPos(&_lzInWindow) + cur - m_AdditionalOffset)]; | ||||
COptimal &optimum = m_Optimum[cur + 1]; | ||||
if (curAnd1Price < optimum.Price) | ||||
{ | { | |||
optimum.Price = curAnd1Price; | const UInt32 curAnd1Price = curPrice + m_LiteralPrices[*(Inline_MatchFinde | |||
optimum.PosPrev = (UInt16)cur; | r_GetPointerToCurrentPos(&_lzInWindow) + cur - m_AdditionalOffset)]; | |||
COptimal &optimum = m_Optimum[cur + 1]; | ||||
if (curAnd1Price < optimum.Price) | ||||
{ | ||||
optimum.Price = curAnd1Price; | ||||
optimum.PosPrev = (UInt16)cur; | ||||
} | ||||
} | } | |||
if (numDistancePairs == 0) | if (numDistancePairs == 0) | |||
continue; | continue; | |||
while (lenEnd < cur + newLen) | while (lenEnd < cur + newLen) | |||
m_Optimum[++lenEnd].Price = kIfinityPrice; | m_Optimum[++lenEnd].Price = kIfinityPrice; | |||
offs = 0; | UInt32 offs = 0; | |||
UInt32 distance = matchDistances[offs + 1]; | UInt32 distance = matchDistances[offs + 1]; | |||
curPrice += m_PosPrices[GetPosSlot(distance)]; | curPrice += m_PosPrices[GetPosSlot(distance)]; | |||
for (UInt32 lenTest = kMatchMinLen; ; lenTest++) | for (UInt32 lenTest = kMatchMinLen; ; lenTest++) | |||
{ | { | |||
UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen]; | UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen]; | |||
COptimal &optimum = m_Optimum[cur + lenTest]; | COptimal &optimum = m_Optimum[cur + lenTest]; | |||
if (curAndLenPrice < optimum.Price) | if (curAndLenPrice < optimum.Price) | |||
{ | { | |||
optimum.Price = curAndLenPrice; | optimum.Price = curAndLenPrice; | |||
optimum.PosPrev = (UInt16)cur; | optimum.PosPrev = (UInt16)cur; | |||
End of changes. 10 change blocks. | ||||
37 lines changed or deleted | 42 lines changed or added |