Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2016-05-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:59 +0300
commitbec3b479dcae1345a466ebe923989b0bd56fd5b6 (patch)
tree048b53858db838682f169140ba9887fdf819ab2e /CPP/7zip/Compress
parent66ac98bb02ac0fadd2a0e3266ea39279984580a3 (diff)
16.0116.01
Diffstat (limited to 'CPP/7zip/Compress')
-rw-r--r--CPP/7zip/Compress/BZip2Encoder.cpp6
-rw-r--r--CPP/7zip/Compress/Bcj2Coder.cpp6
-rw-r--r--CPP/7zip/Compress/Bcj2Coder.h2
-rw-r--r--CPP/7zip/Compress/DeflateEncoder.cpp78
-rw-r--r--CPP/7zip/Compress/LzmsDecoder.cpp13
-rw-r--r--CPP/7zip/Compress/LzxDecoder.h24
-rw-r--r--CPP/7zip/Compress/Rar3Decoder.cpp77
-rw-r--r--CPP/7zip/Compress/Rar5Decoder.cpp6
8 files changed, 112 insertions, 100 deletions
diff --git a/CPP/7zip/Compress/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2Encoder.cpp
index bd985dfe..e2225134 100644
--- a/CPP/7zip/Compress/BZip2Encoder.cpp
+++ b/CPP/7zip/Compress/BZip2Encoder.cpp
@@ -449,7 +449,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
}
while (++i < kGroupSize && mtfPos < mtfArraySize);
- UInt32 bestPrice = 0xFFFFFFFF;
+ UInt32 bestPrice2 = 0xFFFFFFFF;
unsigned t = 0;
do
{
@@ -459,10 +459,10 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
do
price += lens[symbols[j]];
while (++j < i);
- if (price < bestPrice)
+ if (price < bestPrice2)
{
m_Selectors[g] = (Byte)t;
- bestPrice = price;
+ bestPrice2 = price;
}
}
while (++t < numTables);
diff --git a/CPP/7zip/Compress/Bcj2Coder.cpp b/CPP/7zip/Compress/Bcj2Coder.cpp
index fd7ce7ef..96150c5f 100644
--- a/CPP/7zip/Compress/Bcj2Coder.cpp
+++ b/CPP/7zip/Compress/Bcj2Coder.cpp
@@ -514,13 +514,13 @@ HRESULT CDecoder::Code(ISequentialInStream * const *inStreams, const UInt64 * co
STDMETHODIMP CDecoder::SetInStream2(UInt32 streamIndex, ISequentialInStream *inStream)
{
- inStreams[streamIndex] = inStream;
+ _inStreams[streamIndex] = inStream;
return S_OK;
}
STDMETHODIMP CDecoder::ReleaseInStream2(UInt32 streamIndex)
{
- inStreams[streamIndex].Release();
+ _inStreams[streamIndex].Release();
return S_OK;
}
@@ -601,7 +601,7 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
do
{
UInt32 curSize = _bufsCurSizes[dec.state] - (UInt32)totalRead;
- HRESULT res2 = inStreams[dec.state]->Read(_bufs[dec.state] + totalRead, curSize, &curSize);
+ HRESULT res2 = _inStreams[dec.state]->Read(_bufs[dec.state] + totalRead, curSize, &curSize);
_readRes[dec.state] = res2;
if (curSize == 0)
break;
diff --git a/CPP/7zip/Compress/Bcj2Coder.h b/CPP/7zip/Compress/Bcj2Coder.h
index 627e505d..381b9f54 100644
--- a/CPP/7zip/Compress/Bcj2Coder.h
+++ b/CPP/7zip/Compress/Bcj2Coder.h
@@ -72,7 +72,7 @@ class CDecoder:
unsigned _extraReadSizes[BCJ2_NUM_STREAMS];
UInt64 _inStreamsProcessed[BCJ2_NUM_STREAMS];
HRESULT _readRes[BCJ2_NUM_STREAMS];
- CMyComPtr<ISequentialInStream> inStreams[BCJ2_NUM_STREAMS];
+ CMyComPtr<ISequentialInStream> _inStreams[BCJ2_NUM_STREAMS];
bool _finishMode;
bool _outSizeDefined;
diff --git a/CPP/7zip/Compress/DeflateEncoder.cpp b/CPP/7zip/Compress/DeflateEncoder.cpp
index 94d0092b..538e7b5e 100644
--- a/CPP/7zip/Compress/DeflateEncoder.cpp
+++ b/CPP/7zip/Compress/DeflateEncoder.cpp
@@ -331,48 +331,50 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
GetMatches();
- UInt32 numDistancePairs = m_MatchDistances[0];
- if (numDistancePairs == 0)
- return 1;
-
- const UInt16 *matchDistances = m_MatchDistances + 1;
- UInt32 lenMain = matchDistances[numDistancePairs - 2];
-
- if (lenMain > m_NumFastBytes)
+ UInt32 lenEnd;
{
- backRes = matchDistances[numDistancePairs - 1];
- MovePos(lenMain - 1);
- return lenMain;
- }
- m_Optimum[1].Price = m_LiteralPrices[*(Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - m_AdditionalOffset)];
- m_Optimum[1].PosPrev = 0;
-
- m_Optimum[2].Price = kIfinityPrice;
- m_Optimum[2].PosPrev = 1;
-
+ const UInt32 numDistancePairs = m_MatchDistances[0];
+ if (numDistancePairs == 0)
+ return 1;
+ const UInt16 *matchDistances = m_MatchDistances + 1;
+ lenEnd = matchDistances[numDistancePairs - 2];
+
+ if (lenEnd > m_NumFastBytes)
+ {
+ backRes = matchDistances[numDistancePairs - 1];
+ MovePos(lenEnd - 1);
+ return lenEnd;
+ }
- UInt32 offs = 0;
- for (UInt32 i = kMatchMinLen; i <= lenMain; i++)
- {
- UInt32 distance = matchDistances[offs + 1];
- m_Optimum[i].PosPrev = 0;
- m_Optimum[i].BackPrev = (UInt16)distance;
- m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(distance)];
- if (i == matchDistances[offs])
- offs += 2;
+ m_Optimum[1].Price = m_LiteralPrices[*(Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - m_AdditionalOffset)];
+ m_Optimum[1].PosPrev = 0;
+
+ m_Optimum[2].Price = kIfinityPrice;
+ m_Optimum[2].PosPrev = 1;
+
+ UInt32 offs = 0;
+
+ for (UInt32 i = kMatchMinLen; i <= lenEnd; i++)
+ {
+ UInt32 distance = matchDistances[offs + 1];
+ m_Optimum[i].PosPrev = 0;
+ m_Optimum[i].BackPrev = (UInt16)distance;
+ m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(distance)];
+ if (i == matchDistances[offs])
+ offs += 2;
+ }
}
UInt32 cur = 0;
- UInt32 lenEnd = lenMain;
+
for (;;)
{
++cur;
if (cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
return Backward(backRes, cur);
GetMatches();
- matchDistances = m_MatchDistances + 1;
-
- UInt32 numDistancePairs = m_MatchDistances[0];
+ const UInt16 *matchDistances = m_MatchDistances + 1;
+ const UInt32 numDistancePairs = m_MatchDistances[0];
UInt32 newLen = 0;
if (numDistancePairs != 0)
{
@@ -388,18 +390,20 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
}
}
UInt32 curPrice = m_Optimum[cur].Price;
- UInt32 curAnd1Price = curPrice + m_LiteralPrices[*(Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) + cur - m_AdditionalOffset)];
- COptimal &optimum = m_Optimum[cur + 1];
- if (curAnd1Price < optimum.Price)
{
- optimum.Price = curAnd1Price;
- optimum.PosPrev = (UInt16)cur;
+ const UInt32 curAnd1Price = curPrice + m_LiteralPrices[*(Inline_MatchFinder_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)
continue;
while (lenEnd < cur + newLen)
m_Optimum[++lenEnd].Price = kIfinityPrice;
- offs = 0;
+ UInt32 offs = 0;
UInt32 distance = matchDistances[offs + 1];
curPrice += m_PosPrices[GetPosSlot(distance)];
for (UInt32 lenTest = kMatchMinLen; ; lenTest++)
diff --git a/CPP/7zip/Compress/LzmsDecoder.cpp b/CPP/7zip/Compress/LzmsDecoder.cpp
index 1f83b63d..0e823446 100644
--- a/CPP/7zip/Compress/LzmsDecoder.cpp
+++ b/CPP/7zip/Compress/LzmsDecoder.cpp
@@ -267,12 +267,15 @@ HRESULT CDecoder::CodeReal(const Byte *in, size_t inSize, Byte *_win, size_t out
{
{
- unsigned i;
- for (i = 0 ; i < k_NumReps + 1; i++)
- _reps[i] = i + 1;
+ {
+ for (unsigned i = 0 ; i < k_NumReps + 1; i++)
+ _reps[i] = i + 1;
+ }
- for (i = 0 ; i < k_NumReps + 1; i++)
- _deltaReps[i] = i + 1;
+ {
+ for (unsigned i = 0 ; i < k_NumReps + 1; i++)
+ _deltaReps[i] = i + 1;
+ }
mainState = 0;
matchState = 0;
diff --git a/CPP/7zip/Compress/LzxDecoder.h b/CPP/7zip/Compress/LzxDecoder.h
index b06d5948..a5c6f12c 100644
--- a/CPP/7zip/Compress/LzxDecoder.h
+++ b/CPP/7zip/Compress/LzxDecoder.h
@@ -67,19 +67,21 @@ public:
{
if (_bitPos <= 16)
{
- UInt32 val;
- if (_buf >= _bufLim)
- {
- val = 0xFFFF;
- _extraSize += 2;
- }
- else
{
- val = GetUi16(_buf);
- _buf += 2;
+ UInt32 val;
+ if (_buf >= _bufLim)
+ {
+ val = 0xFFFF;
+ _extraSize += 2;
+ }
+ else
+ {
+ val = GetUi16(_buf);
+ _buf += 2;
+ }
+ _value = (_value << 16) | val;
+ _bitPos += 16;
}
- _value = (_value << 16) | val;
- _bitPos += 16;
if (_bitPos <= 16)
{
UInt32 val;
diff --git a/CPP/7zip/Compress/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar3Decoder.cpp
index 832eb112..3bf25132 100644
--- a/CPP/7zip/Compress/Rar3Decoder.cpp
+++ b/CPP/7zip/Compress/Rar3Decoder.cpp
@@ -204,9 +204,9 @@ HRESULT CDecoder::WriteBuf()
{
for (unsigned j = i; j < _tempFilters.Size(); j++)
{
- CTempFilter *filter = _tempFilters[j];
- if (filter && filter->NextWindow)
- filter->NextWindow = false;
+ CTempFilter *filter2 = _tempFilters[j];
+ if (filter2 && filter2->NextWindow)
+ filter2->NextWindow = false;
}
_wrPtr = writtenBorder;
return S_OK; // check it
@@ -270,15 +270,16 @@ bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
filter->ExecCount++;
}
- int numEmptyItems = 0;
- unsigned i;
- for (i = 0; i < _tempFilters.Size(); i++)
+ unsigned numEmptyItems = 0;
{
- _tempFilters[i - numEmptyItems] = _tempFilters[i];
- if (!_tempFilters[i])
- numEmptyItems++;
- if (numEmptyItems > 0)
- _tempFilters[i] = NULL;
+ FOR_VECTOR (i, _tempFilters)
+ {
+ _tempFilters[i - numEmptyItems] = _tempFilters[i];
+ if (!_tempFilters[i])
+ numEmptyItems++;
+ if (numEmptyItems != 0)
+ _tempFilters[i] = NULL;
+ }
}
if (numEmptyItems == 0)
{
@@ -305,7 +306,7 @@ bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
if (firstByte & 0x10)
{
UInt32 initMask = inp.ReadBits(NVm::kNumGpRegs);
- for (int i = 0; i < NVm::kNumGpRegs; i++)
+ for (unsigned i = 0; i < NVm::kNumGpRegs; i++)
if (initMask & (1 << i))
tempFilter->InitR[i] = inp.ReadEncodedUInt32();
}
@@ -321,12 +322,14 @@ bool CDecoder::AddVmCode(UInt32 firstByte, UInt32 codeSize)
isOK = filter->PrepareProgram(_vmCode, vmCodeSize);
}
- Byte *globalData = &tempFilter->GlobalData[0];
- for (i = 0; i < NVm::kNumGpRegs; i++)
- NVm::SetValue32(&globalData[i * 4], tempFilter->InitR[i]);
- NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockSize], tempFilter->BlockSize);
- NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockPos], 0); // It was commented. why?
- NVm::SetValue32(&globalData[NVm::NGlobalOffset::kExecCount], filter->ExecCount);
+ {
+ Byte *globalData = &tempFilter->GlobalData[0];
+ for (unsigned i = 0; i < NVm::kNumGpRegs; i++)
+ NVm::SetValue32(&globalData[i * 4], tempFilter->InitR[i]);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockSize], tempFilter->BlockSize);
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kBlockPos], 0); // It was commented. why?
+ NVm::SetValue32(&globalData[NVm::NGlobalOffset::kExecCount], filter->ExecCount);
+ }
if (firstByte & 8)
{
@@ -497,24 +500,24 @@ HRESULT CDecoder::DecodePPM(Int32 num, bool &keepDecompressing)
{
for (int i = 0; i < 3; i++)
{
- int c = DecodePpmSymbol();
- if (c < 0)
+ int c2 = DecodePpmSymbol();
+ if (c2 < 0)
{
PpmError = true;
return S_FALSE;
}
- distance = (distance << 8) + (Byte)c;
+ distance = (distance << 8) + (Byte)c2;
}
distance++;
length += 28;
}
- int c = DecodePpmSymbol();
- if (c < 0)
+ int c2 = DecodePpmSymbol();
+ if (c2 < 0)
{
PpmError = true;
return S_FALSE;
}
- length += c;
+ length += c2;
if (distance >= _lzSize)
return S_FALSE;
CopyBlock(distance, length);
@@ -733,10 +736,10 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
rep0 = distance;
}
- UInt32 sym = m_LenDecoder.Decode(&m_InBitStream.BitDecoder);
- if (sym >= kLenTableSize)
+ const UInt32 sym2 = m_LenDecoder.Decode(&m_InBitStream.BitDecoder);
+ if (sym2 >= kLenTableSize)
return S_FALSE;
- length = 2 + kLenStart[sym] + m_InBitStream.BitDecoder.ReadBits(kLenDirectBits[sym]);
+ length = 2 + kLenStart[sym2] + m_InBitStream.BitDecoder.ReadBits(kLenDirectBits[sym2]);
}
else
{
@@ -753,12 +756,12 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
{
sym -= 271;
length = kNormalMatchMinLen + (UInt32)kLenStart[sym] + m_InBitStream.BitDecoder.ReadBits(kLenDirectBits[sym]);
- UInt32 sym = m_DistDecoder.Decode(&m_InBitStream.BitDecoder);
- if (sym >= kDistTableSize)
+ const UInt32 sym2 = m_DistDecoder.Decode(&m_InBitStream.BitDecoder);
+ if (sym2 >= kDistTableSize)
return S_FALSE;
- rep0 = kDistStart[sym];
- int numBits = kDistDirectBits[sym];
- if (sym >= (kNumAlignBits * 2) + 2)
+ rep0 = kDistStart[sym2];
+ int numBits = kDistDirectBits[sym2];
+ if (sym2 >= (kNumAlignBits * 2) + 2)
{
if (numBits > kNumAlignBits)
rep0 += (m_InBitStream.BitDecoder.ReadBits(numBits - kNumAlignBits) << kNumAlignBits);
@@ -769,13 +772,13 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
}
else
{
- UInt32 sym = m_AlignDecoder.Decode(&m_InBitStream.BitDecoder);
- if (sym < (1 << kNumAlignBits))
+ const UInt32 sym3 = m_AlignDecoder.Decode(&m_InBitStream.BitDecoder);
+ if (sym3 < (1 << kNumAlignBits))
{
- rep0 += sym;
- PrevAlignBits = sym;
+ rep0 += sym3;
+ PrevAlignBits = sym3;
}
- else if (sym == (1 << kNumAlignBits))
+ else if (sym3 == (1 << kNumAlignBits))
{
PrevAlignCount = kNumAlignReps;
rep0 += PrevAlignBits;
diff --git a/CPP/7zip/Compress/Rar5Decoder.cpp b/CPP/7zip/Compress/Rar5Decoder.cpp
index 627f7ee6..dc8830f8 100644
--- a/CPP/7zip/Compress/Rar5Decoder.cpp
+++ b/CPP/7zip/Compress/Rar5Decoder.cpp
@@ -639,10 +639,10 @@ HRESULT CDecoder::DecodeLZ()
rep0 = dist;
}
- UInt32 sym = m_LenDecoder.Decode(&_bitStream);
- if (sym >= kLenTableSize)
+ const UInt32 sym2 = m_LenDecoder.Decode(&_bitStream);
+ if (sym2 >= kLenTableSize)
break; // return S_FALSE;
- len = SlotToLen(_bitStream, sym);
+ len = SlotToLen(_bitStream, sym2);
}
else
{