diff options
author | Stefan Reinauer <stepan@coresystems.de> | 2010-04-27 06:56:47 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2010-04-27 06:56:47 +0000 |
commit | 14e22779625de673569c7b950ecc2753fb915b31 (patch) | |
tree | 14a6ed759e116e9e6e9bbd7f499b74b96d6cc072 /util/cbfstool/lzma/C/7zip/Compress | |
parent | 0e1e8065e303030c39c3f2c27e5d32ee58a16c66 (diff) | |
download | coreboot-14e22779625de673569c7b950ecc2753fb915b31.tar.xz |
Since some people disapprove of white space cleanups mixed in regular commits
while others dislike them being extra commits, let's clean them up once and
for all for the existing code. If it's ugly, let it only be ugly once :-)
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5507 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/cbfstool/lzma/C/7zip/Compress')
13 files changed, 139 insertions, 139 deletions
diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTree.h b/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTree.h index b3b3f13a56..243d5a3888 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTree.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTree.h @@ -2,13 +2,13 @@ #include "../LZInWindow.h" #include "../IMatchFinder.h" - + namespace BT_NAMESPACE { typedef UInt32 CIndex; const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1; -class CMatchFinder: +class CMatchFinder: public IMatchFinder, public CLZInWindow, public CMyUnknownImp, @@ -40,7 +40,7 @@ class CMatchFinder: STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes); STDMETHOD_(void, ChangeBufferPos)(); - STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, + STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter); STDMETHOD(GetMatches)(UInt32 *distances); STDMETHOD(Skip)(UInt32 num); diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTreeMain.h b/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTreeMain.h index 7a6f621a06..d47a03de90 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTreeMain.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/BinTree/BinTreeMain.h @@ -25,7 +25,7 @@ namespace BT_NAMESPACE { static const UInt32 kMinMatchCheck = kNumHashBytes; static const UInt32 kStartMaxLen = 1; #else - #ifdef HASH_ZIP + #ifdef HASH_ZIP #define kNumHashDirectBytes 0 static const UInt32 kNumHashBytes = 3; static const UInt32 kHashSize = 1 << 16; @@ -73,11 +73,11 @@ void CMatchFinder::FreeMemory() } CMatchFinder::~CMatchFinder() -{ +{ FreeMemory(); } -STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore, +STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter) { if (historySize > kMaxValForNormalize - 256) @@ -85,15 +85,15 @@ STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore FreeMemory(); return E_INVALIDARG; } - _cutValue = + _cutValue = #ifdef _HASH_CHAIN 8 + (matchMaxLen >> 2); #else 16 + (matchMaxLen >> 1); #endif - UInt32 sizeReserv = (historySize + keepAddBufferBefore + + UInt32 sizeReserv = (historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + 256; - if (CLZInWindow::Create(historySize + keepAddBufferBefore, + if (CLZInWindow::Create(historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, sizeReserv)) { _matchMaxLen = matchMaxLen; @@ -161,8 +161,8 @@ STDMETHODIMP CMatchFinder::Init() } STDMETHODIMP_(void) CMatchFinder::ReleaseStream() -{ - // ReleaseStream(); +{ + // ReleaseStream(); } #ifdef HASH_ARRAY_2 @@ -173,7 +173,7 @@ STDMETHODIMP_(void) CMatchFinder::ReleaseStream() hash2Value = temp & (kHash2Size - 1); \ hash3Value = (temp ^ (UInt32(cur[2]) << 8)) & (kHash3Size - 1); \ hashValue = (temp ^ (UInt32(cur[2]) << 8) ^ (CCRC::Table[cur[3]] << 5)) & _hashMask; } - + #else // no HASH_ARRAY_3 #define HASH_CALC { \ UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \ @@ -181,12 +181,12 @@ STDMETHODIMP_(void) CMatchFinder::ReleaseStream() hashValue = (temp ^ (UInt32(cur[2]) << 8)) & _hashMask; } #endif // HASH_ARRAY_3 #else // no HASH_ARRAY_2 -#ifdef HASH_ZIP +#ifdef HASH_ZIP inline UInt32 Hash(const Byte *pointer) { return ((UInt32(pointer[0]) << 8) ^ CCRC::Table[pointer[1]] ^ pointer[2]) & (kHashSize - 1); } -#else // no HASH_ZIP +#else // no HASH_ZIP inline UInt32 Hash(const Byte *pointer) { return pointer[0] ^ (UInt32(pointer[1]) << 8); @@ -205,7 +205,7 @@ STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances) if(lenLimit < kMinMatchCheck) { distances[0] = 0; - return MovePos(); + return MovePos(); } } @@ -298,17 +298,17 @@ STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances) UInt32 cyclicPos = (delta <= _cyclicBufferPos) ? (_cyclicBufferPos - delta): (_cyclicBufferPos - delta + _cyclicBufferSize); - CIndex *pair = son + + CIndex *pair = son + #ifdef _HASH_CHAIN cyclicPos; #else (cyclicPos << 1); #endif - + // _mm_prefetch((const char *)pair, _MM_HINT_T0); - + const Byte *pb = _buffer + curMatch; - UInt32 len = + UInt32 len = #ifdef _HASH_CHAIN kNumHashDirectBytes; if (pb[maxLen] == cur[maxLen]) @@ -369,7 +369,7 @@ STDMETHODIMP CMatchFinder::Skip(UInt32 num) #ifdef _HASH_CHAIN if (_streamPos - _pos < kNumHashBytes) { - RINOK(MovePos()); + RINOK(MovePos()); continue; } #else @@ -425,18 +425,18 @@ STDMETHODIMP CMatchFinder::Skip(UInt32 num) *ptr0 = *ptr1 = kEmptyHashValue; break; } - + UInt32 delta = _pos - curMatch; UInt32 cyclicPos = (delta <= _cyclicBufferPos) ? (_cyclicBufferPos - delta): (_cyclicBufferPos - delta + _cyclicBufferSize); CIndex *pair = son + (cyclicPos << 1); - + // _mm_prefetch((const char *)pair, _MM_HINT_T0); - + const Byte *pb = _buffer + curMatch; UInt32 len = MyMin(len0, len1); - + if (pb[len] == cur[len]) { while(++len != lenLimit) @@ -479,7 +479,7 @@ void CMatchFinder::Normalize() { UInt32 subValue = _pos - _cyclicBufferSize; CIndex *items = _hash; - UInt32 numItems = (_hashSizeSum + _cyclicBufferSize + UInt32 numItems = (_hashSizeSum + _cyclicBufferSize #ifndef _HASH_CHAIN * 2 #endif @@ -509,7 +509,7 @@ HRESULT CMatchFinder::MovePos() STDMETHODIMP_(Byte) CMatchFinder::GetIndexByte(Int32 index) { return CLZInWindow::GetIndexByte(index); } -STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index, +STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index, UInt32 back, UInt32 limit) { return CLZInWindow::GetMatchLen(index, back, limit); } @@ -527,5 +527,5 @@ STDMETHODIMP_(void) CMatchFinder::ChangeBufferPos() #undef HASH_CALC #undef kNumHashDirectBytes - + } diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/IMatchFinder.h b/util/cbfstool/lzma/C/7zip/Compress/LZ/IMatchFinder.h index 8b8480b2d2..53b9c1ecc5 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/IMatchFinder.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/IMatchFinder.h @@ -15,10 +15,10 @@ struct IInWindowStream: public IUnknown STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes) PURE; STDMETHOD_(void, ChangeBufferPos)() PURE; }; - + struct IMatchFinder: public IInWindowStream { - STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, + STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter) PURE; STDMETHOD(GetMatches)(UInt32 *distances) PURE; STDMETHOD(Skip)(UInt32 num) PURE; diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.cpp b/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.cpp index 0e65c4254b..c4d331e933 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.cpp +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.cpp @@ -62,8 +62,8 @@ void CLZInWindow::ReleaseStream() // _streamPos >= _pos + _keepSizeAfter // _posLimit = _streamPos - _keepSizeAfter; // else -// - +// + HRESULT CLZInWindow::ReadBlock() { if(_streamEndWasReached) @@ -98,7 +98,7 @@ void CLZInWindow::MoveBlock() UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore; // we need one additional byte, since MovePos moves on 1 byte. if (offset > 0) - offset--; + offset--; UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos - offset; memmove(_bufferBase, _bufferBase + offset, numBytes); _buffer -= offset; diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.h b/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.h index 54f2cb7bba..670a570378 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/LZInWindow.h @@ -56,7 +56,7 @@ public: // index + limit have not to exceed _keepSizeAfter; // -2G <= index < 2G UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const - { + { if(_streamEndWasReached) if ((_pos + index) + limit > _streamPos) limit = _streamPos - (_pos + index); diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZ/StdAfx.h b/util/cbfstool/lzma/C/7zip/Compress/LZ/StdAfx.h index 3ff6d8a29f..b637fd4007 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZ/StdAfx.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZ/StdAfx.h @@ -3,4 +3,4 @@ #ifndef __STDAFX_H #define __STDAFX_H -#endif +#endif diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMA.h b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMA.h index 7bc4c438af..e262aa2af2 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMA.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMA.h @@ -27,10 +27,10 @@ public: bool IsCharState() const { return Index < 7; } }; -const int kNumPosSlotBits = 6; -const int kDicLogSizeMin = 0; -const int kDicLogSizeMax = 32; -const int kDistTableSizeMax = kDicLogSizeMax * 2; +const int kNumPosSlotBits = 6; +const int kDicLogSizeMin = 0; +const int kDicLogSizeMax = 32; +const int kDistTableSizeMax = kDicLogSizeMax * 2; const UInt32 kNumLenToPosStates = 4; diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.cpp b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.cpp index 8d8f0a004c..1fff04aac8 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.cpp +++ b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.cpp @@ -47,7 +47,7 @@ namespace NLZMA { const int kDefaultDictionaryLogSize = 22; const UInt32 kNumFastBytesDefault = 0x20; -enum +enum { kBT2, kBT3, @@ -55,7 +55,7 @@ enum kHC4 }; -static const wchar_t *kMatchFinderIDs[] = +static const wchar_t *kMatchFinderIDs[] = { L"BT2", L"BT3", @@ -90,7 +90,7 @@ void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol) { UInt32 context = 1; int i = 8; - do + do { i--; UInt32 bit = (symbol >> i) & 1; @@ -100,12 +100,12 @@ void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol) while(i != 0); } -void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, +void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol) { UInt32 context = 1; int i = 8; - do + do { i--; UInt32 bit = (symbol >> i) & 1; @@ -134,7 +134,7 @@ UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) c int i = 8; if (matchMode) { - do + do { i--; UInt32 matchBit = (matchByte >> i) & 1; @@ -277,7 +277,7 @@ HRESULT CEncoder::Create() } #endif #endif - + #ifdef COMPRESS_MF_HC case kHC4: { @@ -304,7 +304,7 @@ HRESULT CEncoder::Create() } #endif } - + if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits)) return E_OUTOFMEMORY; @@ -342,7 +342,7 @@ static int FindMatchFinder(const wchar_t *s) return -1; } -STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, +STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *properties, UInt32 numProperties) { for (UInt32 i = 0; i < numProperties; i++) @@ -372,7 +372,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, if (prop.vt != VT_UI4) return E_INVALIDARG; UInt32 maximize = prop.ulVal; - _fastMode = (maximize == 0); + _fastMode = (maximize == 0); // _maxMode = (maximize >= 2); break; } @@ -483,7 +483,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, } STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) -{ +{ const UInt32 kPropSize = 5; Byte properties[kPropSize]; properties[0] = (_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits; @@ -587,7 +587,7 @@ UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur) while(cur != 0); backRes = _optimum[0].BackPrev; _optimumCurrentIndex = _optimum[0].PosPrev; - return _optimumCurrentIndex; + return _optimumCurrentIndex; } /* @@ -606,7 +606,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) return S_OK; } _optimumCurrentIndex = _optimumEndIndex = 0; - + UInt32 lenMain, numDistancePairs; if (!_longestMatchWasFound) { @@ -644,7 +644,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) continue; } UInt32 lenTest; - for (lenTest = 2; lenTest < numAvailableBytes && + for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++); repLens[i] = lenTest; if (lenTest > repLens[repMaxIndex]) @@ -660,7 +660,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 *matchDistances = _matchDistances + 1; if(lenMain >= _numFastBytes) { - backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; + backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; lenRes = lenMain; return MovePos(lenMain - 1); } @@ -678,7 +678,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 posState = (position & _posStateMask); - _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() + + _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() + _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte); _optimum[1].MakeAsChar(); @@ -722,7 +722,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) { UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState); COptimal &optimum = _optimum[repLen]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = 0; @@ -746,7 +746,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 distance = matchDistances[offs + 1]; UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState); COptimal &optimum = _optimum[len]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = 0; @@ -847,7 +847,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) curOptimum.State = state; for(UInt32 i = 0; i < kNumRepDistances; i++) curOptimum.Backs[i] = reps[i]; - UInt32 curPrice = curOptimum.Price; + UInt32 curPrice = curOptimum.Price; const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1; const Byte currentByte = *data; const Byte matchByte = data[(size_t)0 - reps[0] - 1]; @@ -861,7 +861,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) COptimal &nextOptimum = _optimum[cur + 1]; bool nextIsChar = false; - if (curAnd1Price < nextOptimum.Price) + if (curAnd1Price < nextOptimum.Price) { nextOptimum.Price = curAnd1Price; nextOptimum.PosPrev = cur; @@ -871,7 +871,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1(); UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1(); - + if(matchByte == currentByte && !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) { @@ -903,7 +903,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 backOffset = reps[0] + 1; UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1); UInt32 temp; - for (temp = 1; temp < limit && + for (temp = 1; temp < limit && data[temp] == data[(size_t)temp - backOffset]; temp++); UInt32 lenTest2 = temp - 1; if (lenTest2 >= 2) @@ -911,7 +911,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) CState state2 = state; state2.UpdateChar(); UInt32 posStateNext = (position + 1) & _posStateMask; - UInt32 nextRepMatchPrice = curAnd1Price + + UInt32 nextRepMatchPrice = curAnd1Price + _isMatch[state2.Index][posStateNext].GetPrice1() + _isRep[state2.Index].GetPrice1(); // for (; lenTest2 >= 2; lenTest2--) @@ -922,7 +922,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice( 0, lenTest2, state2, posStateNext); COptimal &optimum = _optimum[offset]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = cur + 1; @@ -933,8 +933,8 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) } } } - - UInt32 startLen = 2; // speed optimization + + UInt32 startLen = 2; // speed optimization for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++) { // UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it; @@ -943,7 +943,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) data[1] != data[(size_t)1 - backOffset]) continue; UInt32 lenTest; - for (lenTest = 2; lenTest < numAvailableBytes && + for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++); while(lenEnd < cur + lenTest) _optimum[++lenEnd].Price = kIfinityPrice; @@ -953,7 +953,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) { UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState); COptimal &optimum = _optimum[cur + lenTest]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = cur; @@ -963,15 +963,15 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) } while(--lenTest >= 2); lenTest = lenTestTemp; - + if (repIndex == 0) startLen = lenTest + 1; - + // if (_maxMode) { UInt32 lenTest2 = lenTest + 1; UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes); - for (; lenTest2 < limit && + for (; lenTest2 < limit && data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++); lenTest2 -= lenTest + 1; if (lenTest2 >= 2) @@ -979,17 +979,17 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) CState state2 = state; state2.UpdateRep(); UInt32 posStateNext = (position + lenTest) & _posStateMask; - UInt32 curAndLenCharPrice = - price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) + + UInt32 curAndLenCharPrice = + price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) + _isMatch[state2.Index][posStateNext].GetPrice0() + _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice( true, data[(size_t)lenTest - backOffset], data[lenTest]); state2.UpdateChar(); posStateNext = (position + lenTest + 1) & _posStateMask; - UInt32 nextRepMatchPrice = curAndLenCharPrice + + UInt32 nextRepMatchPrice = curAndLenCharPrice + _isMatch[state2.Index][posStateNext].GetPrice1() + _isRep[state2.Index].GetPrice1(); - + // for(; lenTest2 >= 2; lenTest2--) { UInt32 offset = cur + lenTest + 1 + lenTest2; @@ -998,7 +998,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice( 0, lenTest2, state2, posStateNext); COptimal &optimum = _optimum[offset]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = cur + lenTest + 1; @@ -1012,7 +1012,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) } } } - + // for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++) if (newLen > numAvailableBytes) { @@ -1040,11 +1040,11 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) curAndLenPrice += _distancesPrices[lenToPosState][curBack]; else curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask]; - + curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState); - + COptimal &optimum = _optimum[cur + lenTest]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = cur; @@ -1058,7 +1058,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) UInt32 backOffset = curBack + 1; UInt32 lenTest2 = lenTest + 1; UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes); - for (; lenTest2 < limit && + for (; lenTest2 < limit && data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++); lenTest2 -= lenTest + 1; if (lenTest2 >= 2) @@ -1066,16 +1066,16 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) CState state2 = state; state2.UpdateMatch(); UInt32 posStateNext = (position + lenTest) & _posStateMask; - UInt32 curAndLenCharPrice = curAndLenPrice + + UInt32 curAndLenCharPrice = curAndLenPrice + _isMatch[state2.Index][posStateNext].GetPrice0() + - _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice( + _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice( true, data[(size_t)lenTest - backOffset], data[lenTest]); state2.UpdateChar(); posStateNext = (posStateNext + 1) & _posStateMask; - UInt32 nextRepMatchPrice = curAndLenCharPrice + + UInt32 nextRepMatchPrice = curAndLenCharPrice + _isMatch[state2.Index][posStateNext].GetPrice1() + _isRep[state2.Index].GetPrice1(); - + // for(; lenTest2 >= 2; lenTest2--) { UInt32 offset = cur + lenTest + 1 + lenTest2; @@ -1083,7 +1083,7 @@ HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes) _optimum[++lenEnd].Price = kIfinityPrice; UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext); COptimal &optimum = _optimum[offset]; - if (curAndLenPrice < optimum.Price) + if (curAndLenPrice < optimum.Price) { optimum.Price = curAndLenPrice; optimum.PosPrev = cur + lenTest + 1; @@ -1122,7 +1122,7 @@ HRESULT CEncoder::ReadMatchDistances(UInt32 &lenRes, UInt32 &numDistancePairs) { lenRes = _matchDistances[1 + numDistancePairs - 2]; if (lenRes == _numFastBytes) - lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1], + lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1], kMatchMaxLen - lenRes); } _additionalOffset++; @@ -1180,7 +1180,7 @@ HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRe UInt32 *matchDistances = _matchDistances + 1; if(lenMain >= _numFastBytes) { - backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; + backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances; lenRes = lenMain; return MovePos(lenMain - 1); } @@ -1203,7 +1203,7 @@ HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRe if (repLens[repMaxIndex] >= 2) { - if (repLens[repMaxIndex] + 1 >= lenMain || + if (repLens[repMaxIndex] + 1 >= lenMain || repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9)) || repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15))) { @@ -1212,14 +1212,14 @@ HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRe return MovePos(lenRes - 1); } } - + if (lenMain >= 2 && numAvailableBytes > 2) { RINOK(ReadMatchDistances(_longestMatchLength, _numDistancePairs)); if (_longestMatchLength >= 2) { UInt32 newDistance = matchDistances[_numDistancePairs - 1]; - if (_longestMatchLength >= lenMain && newDistance < backMain || + if (_longestMatchLength >= lenMain && newDistance < backMain || _longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance) || _longestMatchLength > lenMain + 1 || _longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain)) @@ -1250,7 +1250,7 @@ HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRe return S_OK; } } - backRes = backMain + kNumRepDistances; + backRes = backMain + kNumRepDistances; lenRes = lenMain; return MovePos(lenMain - 2); } @@ -1269,7 +1269,7 @@ HRESULT CEncoder::Flush(UInt32 nowPos) void CEncoder::WriteEndMarker(UInt32 posState) { - // This function for writing End Mark for stream version of LZMA. + // This function for writing End Mark for stream version of LZMA. // In current version this feature is not used. if (!_writeEndMark) return; @@ -1289,7 +1289,7 @@ void CEncoder::WriteEndMarker(UInt32 posState) } HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress) { @@ -1312,7 +1312,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, } HRESULT CEncoder::SetStreams(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize) { _inStream = inStream; @@ -1320,7 +1320,7 @@ HRESULT CEncoder::SetStreams(ISequentialInStream *inStream, RINOK(Create()); RINOK(SetOutStream(outStream)); RINOK(Init()); - + // CCoderReleaser releaser(this); /* @@ -1455,7 +1455,7 @@ HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished) pos -= kNumRepDistances; UInt32 posSlot = GetPosSlot(pos); _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot); - + if (posSlot >= kStartPosModelIndex) { UInt32 footerBits = ((posSlot >> 1) - 1); @@ -1463,7 +1463,7 @@ HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished) UInt32 posReduced = pos - base; if (posSlot < kEndPosModelIndex) - NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1, + NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1, &_rangeEncoder, footerBits, posReduced); else { @@ -1511,26 +1511,26 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ICompressProgressInfo *progress) { #ifndef _NO_EXCEPTIONS - try - { + try + { #endif - return CodeReal(inStream, outStream, inSize, outSize, progress); + return CodeReal(inStream, outStream, inSize, outSize, progress); #ifndef _NO_EXCEPTIONS } catch(const COutBufferException &e) { return e.ErrorCode; } catch(...) { return E_FAIL; } #endif } - + void CEncoder::FillDistancesPrices() { UInt32 tempPrices[kNumFullDistances]; for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++) - { + { UInt32 posSlot = GetPosSlot(i); UInt32 footerBits = ((posSlot >> 1) - 1); UInt32 base = ((2 | (posSlot & 1)) << footerBits); - tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders + + tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders + base - posSlot - 1, footerBits, i - base); } diff --git a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.h b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.h index f4c2c15131..2a41948495 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.h +++ b/util/cbfstool/lzma/C/7zip/Compress/LZMA/LZMAEncoder.h @@ -39,11 +39,11 @@ struct COptimal bool Prev2; UInt32 PosPrev2; - UInt32 BackPrev2; + UInt32 BackPrev2; - UInt32 Price; + UInt32 Price; UInt32 PosPrev; // posNext; - UInt32 BackPrev; + UInt32 BackPrev; UInt32 Backs[kNumRepDistances]; void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; } void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; } @@ -99,7 +99,7 @@ public: CLiteralEncoder(): _coders(0) {} ~CLiteralEncoder() { Free(); } void Free() - { + { MyFree(_coders); _coders = 0; } @@ -172,7 +172,7 @@ public: } -class CEncoder : +class CEncoder : public ICompressCoder, public ICompressSetOutStream, public ICompressSetCoderProperties, @@ -195,7 +195,7 @@ class CEncoder : CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex]; NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder; - + NLength::CPriceTableEncoder _lenEncoder; NLength::CPriceTableEncoder _repMatchLenEncoder; @@ -206,7 +206,7 @@ class CEncoder : bool _fastMode; // bool _maxMode; UInt32 _numFastBytes; - UInt32 _longestMatchLength; + UInt32 _longestMatchLength; UInt32 _numDistancePairs; UInt32 _additionalOffset; @@ -217,7 +217,7 @@ class CEncoder : bool _longestMatchWasFound; UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; - + UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances]; UInt32 _alignPrices[kAlignTableSize]; @@ -257,7 +257,7 @@ class CEncoder : setMfPasses = 0; _matchFinder.Release(); } - + HRESULT ReadMatchDistances(UInt32 &len, UInt32 &numDistancePairs); HRESULT MovePos(UInt32 num); @@ -266,7 +266,7 @@ class CEncoder : return _isRepG0[state.Index].GetPrice0() + _isRep0Long[state.Index][posState].GetPrice0(); } - + UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const { UInt32 price; @@ -307,7 +307,7 @@ class CEncoder : if (pos < kNumFullDistances) price = _distancesPrices[lenToPosState][pos]; else - price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + + price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + _alignPrices[pos & kAlignMask]; return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState); } @@ -319,7 +319,7 @@ class CEncoder : if (pos < kNumFullDistances) price = _distancesPrices[lenToPosState][pos]; else - price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + + price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] + _alignPrices[pos & kAlignMask]; return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState); } @@ -330,7 +330,7 @@ class CEncoder : void FillDistancesPrices(); void FillAlignPrices(); - + void ReleaseMFStream() { if (_matchFinder && _needReleaseMFStream) @@ -373,9 +373,9 @@ public: ICompressSetCoderProperties, ICompressWriteCoderProperties ) - + HRESULT Init(); - + // ICompressCoder interface HRESULT SetStreams(ISequentialInStream *inStream, ISequentialOutStream *outStream, @@ -383,20 +383,20 @@ public: HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished); HRESULT CodeReal(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); // ICompressCoder interface STDMETHOD(Code)(ISequentialInStream *inStream, - ISequentialOutStream *outStream, + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); // ICompressSetCoderProperties2 - STDMETHOD(SetCoderProperties)(const PROPID *propIDs, + STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *properties, UInt32 numProperties); - + // ICompressWriteCoderProperties STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); diff --git a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoder.h b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoder.h index bbb2ba82d3..d77442be45 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoder.h +++ b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoder.h @@ -34,7 +34,7 @@ public: void FlushData() { - // Low += 1; + // Low += 1; for(int i = 0; i < 5; i++) ShiftLow(); } @@ -56,7 +56,7 @@ public: void ShiftLow() { - if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0) + if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0) { Byte temp = _cache; do @@ -65,12 +65,12 @@ public: temp = 0xFF; } while(--_cacheSize != 0); - _cache = (Byte)((UInt32)Low >> 24); - } - _cacheSize++; - Low = (UInt32)Low << 8; + _cache = (Byte)((UInt32)Low >> 24); + } + _cacheSize++; + Low = (UInt32)Low << 8; } - + void EncodeDirectBits(UInt32 value, int numTotalBits) { for (int i = numTotalBits - 1; i >= 0; i--) @@ -122,7 +122,7 @@ public: Range <<= 8; } } - + void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); } void Init() { @@ -150,7 +150,7 @@ public: UInt32 DecodeDirectBits(int numTotalBits) { UInt32 range = Range; - UInt32 code = Code; + UInt32 code = Code; UInt32 result = 0; for (int i = numTotalBits; i != 0; i--) { @@ -170,7 +170,7 @@ public: if (range < kTopValue) { code = (code << 8) | Stream.ReadByte(); - range <<= 8; + range <<= 8; } } Range = range; diff --git a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp index 8e4c4d3a9e..6c1c78e14e 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp +++ b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp @@ -20,7 +20,7 @@ void CPriceTables::Init() UInt32 start = 1 << (kNumBits - i - 1); UInt32 end = 1 << (kNumBits - i); for (UInt32 j = start; j < end; j++) - ProbPrices[j] = (i << kNumBitPriceShiftBits) + + ProbPrices[j] = (i << kNumBitPriceShiftBits) + (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); } @@ -29,7 +29,7 @@ void CPriceTables::Init() for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) ProbPrices[i] = kBitPrice; */ - + /* const double kDummyMultMid = (1.0 / kBitPrice) / 2; const double kDummyMultMid = 0; @@ -39,7 +39,7 @@ void CPriceTables::Init() for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice); */ - + /* // experimental, slow, solution: for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) @@ -70,7 +70,7 @@ void CPriceTables::Init() range -= (1 << 31); } } - ProbPrices[i] = (bitCount + ProbPrices[i] = (bitCount // + (1 << (kCyclesBits - 1)) ) >> kCyclesBits; } diff --git a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBitTree.h b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBitTree.h index 4f0c78b49d..461e2f049f 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBitTree.h +++ b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderBitTree.h @@ -108,7 +108,7 @@ public: }; template <int numMoveBits> -void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models, +void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models, CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol) { UInt32 modelIndex = 1; @@ -122,7 +122,7 @@ void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models, } template <int numMoveBits> -UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models, +UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models, UInt32 NumBitLevels, UInt32 symbol) { UInt32 price = 0; @@ -138,7 +138,7 @@ UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models, } template <int numMoveBits> -UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models, +UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models, CDecoder *rangeDecoder, int NumBitLevels) { UInt32 modelIndex = 1; diff --git a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderOpt.h b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderOpt.h index 668b9a5b0a..5779277635 100644 --- a/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderOpt.h +++ b/util/cbfstool/lzma/C/7zip/Compress/RangeCoder/RangeCoderOpt.h @@ -5,7 +5,7 @@ #define RC_INIT_VAR \ UInt32 range = rangeDecoder->Range; \ - UInt32 code = rangeDecoder->Code; + UInt32 code = rangeDecoder->Code; #define RC_FLUSH_VAR \ rangeDecoder->Range = range; \ |