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
This commit is contained in:
Stefan Reinauer
2010-04-27 06:56:47 +00:00
committed by Stefan Reinauer
parent 0e1e8065e3
commit 14e2277962
1022 changed files with 9209 additions and 9210 deletions

View File

@@ -38,7 +38,7 @@ public:
bool Create(UInt32 bufferSize);
void Free();
void SetStream(ISequentialInStream *stream);
void Init();
void ReleaseStream() { _stream.Release(); }

View File

@@ -43,9 +43,9 @@ void COutBuffer::Init()
}
UInt64 COutBuffer::GetProcessedSize() const
{
{
UInt64 res = _processedSize + _pos - _streamPos;
if (_streamPos > _pos)
if (_streamPos > _pos)
res += _bufferSize;
return res;
}

View File

@@ -36,7 +36,7 @@ public:
COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}
~COutBuffer() { Free(); }
bool Create(UInt32 bufferSize);
void Free();

View File

@@ -6,4 +6,4 @@
#include "../../Common/MyWindows.h"
#include "../../Common/NewHandler.h"
#endif
#endif

View File

@@ -11,7 +11,7 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32
*processedSize = 0;
while(size != 0)
{
UInt32 processedSizeLoc;
UInt32 processedSizeLoc;
HRESULT res = stream->Read(data, size, &processedSizeLoc);
if (processedSize != 0)
*processedSize += processedSizeLoc;
@@ -30,7 +30,7 @@ HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size,
*processedSize = 0;
while(size != 0)
{
UInt32 processedSizeLoc;
UInt32 processedSizeLoc;
HRESULT res = stream->Write(data, size, &processedSizeLoc);
if (processedSize != 0)
*processedSize += processedSizeLoc;

View File

@@ -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);

View File

@@ -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
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -3,4 +3,4 @@
#ifndef __STDAFX_H
#define __STDAFX_H
#endif
#endif

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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; \

View File

@@ -1,21 +1,21 @@
/*
LzmaDecode.c
LZMA Decoder (optimized for Speed version)
LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10)
http://www.7-zip.org/
LZMA SDK is licensed under two licenses:
1) GNU Lesser General Public License (GNU LGPL)
2) Common Public License (CPL)
It means that you can select one of these two licenses and
It means that you can select one of these two licenses and
follow rules of that license.
SPECIAL EXCEPTION:
Igor Pavlov, as the author of this Code, expressly permits you to
statically or dynamically link your Code (or bind by name) to the
interfaces of this file without subjecting your linked Code to the
terms of the CPL or GNU LGPL. Any modifications or additions
Igor Pavlov, as the author of this Code, expressly permits you to
statically or dynamically link your Code (or bind by name) to the
interfaces of this file without subjecting your linked Code to the
terms of the CPL or GNU LGPL. Any modifications or additions
to this file, however, are subject to the LGPL or CPL terms.
*/
@@ -50,7 +50,7 @@
#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
#endif
#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
@@ -61,9 +61,9 @@
#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
{ UpdateBit0(p); mi <<= 1; A0; } else \
{ UpdateBit1(p); mi = (mi + mi) + 1; A1; }
#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
{ UpdateBit1(p); mi = (mi + mi) + 1; A1; }
#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
{ int i = numLevels; res = 1; \
@@ -86,7 +86,7 @@
#define LenLow (LenChoice2 + 1)
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
#define kNumStates 12
@@ -172,7 +172,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
int lc = vs->Properties.lc;
#ifdef _LZMA_OUT_READ
UInt32 Range = vs->Range;
UInt32 Code = vs->Code;
#ifdef _LZMA_IN_CB
@@ -214,7 +214,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
UInt32 i;
for (i = 0; i < numProbs; i++)
p[i] = kBitModelTotal >> 1;
p[i] = kBitModelTotal >> 1;
rep0 = rep1 = rep2 = rep3 = 1;
state = 0;
globalPos = 0;
@@ -265,7 +265,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
for (i = 0; i < numProbs; i++)
p[i] = kBitModelTotal >> 1;
}
#ifdef _LZMA_IN_CB
RC_INIT;
#else
@@ -279,7 +279,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
CProb *prob;
UInt32 bound;
int posState = (int)(
(nowPos
(nowPos
#ifdef _LZMA_OUT_READ
+ globalPos
#endif
@@ -291,9 +291,9 @@ int LzmaDecode(CLzmaDecoderState *vs,
{
int symbol = 1;
UpdateBit0(prob)
prob = p + Literal + (LZMA_LIT_SIZE *
prob = p + Literal + (LZMA_LIT_SIZE *
(((
(nowPos
(nowPos
#ifdef _LZMA_OUT_READ
+ globalPos
#endif
@@ -342,7 +342,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
else if (state < 10) state -= 3;
else state -= 6;
}
else
else
{
UpdateBit1(prob);
prob = p + IsRep + state;
@@ -369,14 +369,14 @@ int LzmaDecode(CLzmaDecoderState *vs,
UInt32 pos;
#endif
UpdateBit0(prob);
#ifdef _LZMA_OUT_READ
if (distanceLimit == 0)
#else
if (nowPos == 0)
#endif
return LZMA_RESULT_DATA_ERROR;
state = state < kNumLitStates ? 9 : 11;
#ifdef _LZMA_OUT_READ
pos = dictionaryPos - rep0;
@@ -412,7 +412,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
UpdateBit0(prob);
distance = rep1;
}
else
else
{
UpdateBit1(prob);
prob = p + IsRepG2 + state;
@@ -473,7 +473,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
int posSlot;
state += kNumLitStates;
prob = p + PosSlot +
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
kNumPosSlotBits);
RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
if (posSlot >= kStartPosModelIndex)
@@ -528,7 +528,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
len += kMatchMinLen;
#ifdef _LZMA_OUT_READ
if (rep0 > distanceLimit)
if (rep0 > distanceLimit)
#else
if (rep0 > nowPos)
#endif

View File

@@ -1,4 +1,4 @@
/*
/*
LzmaDecode.h
LZMA Decoder interface
@@ -8,14 +8,14 @@
LZMA SDK is licensed under two licenses:
1) GNU Lesser General Public License (GNU LGPL)
2) Common Public License (CPL)
It means that you can select one of these two licenses and
It means that you can select one of these two licenses and
follow rules of that license.
SPECIAL EXCEPTION:
Igor Pavlov, as the author of this code, expressly permits you to
statically or dynamically link your code (or bind by name) to the
interfaces of this file without subjecting your linked code to the
terms of the CPL or GNU LGPL. Any modifications or additions
Igor Pavlov, as the author of this code, expressly permits you to
statically or dynamically link your code (or bind by name) to the
interfaces of this file without subjecting your linked code to the
terms of the CPL or GNU LGPL. Any modifications or additions
to this file, however, are subject to the LGPL or CPL terms.
*/
@@ -29,7 +29,7 @@
/* Use read function for output data */
/* #define _LZMA_PROB32 */
/* It can increase speed on some 32-bit CPUs,
/* It can increase speed on some 32-bit CPUs,
but memory usage will be doubled in that case */
/* #define _LZMA_LOC_OPT */

View File

@@ -19,8 +19,8 @@ CODER_INTERFACE(ICompressProgressInfo, 0x04)
CODER_INTERFACE(ICompressCoder, 0x05)
{
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize,
ISequentialOutStream *outStream,
const UInt64 *inSize,
const UInt64 *outSize,
ICompressProgressInfo *progress) PURE;
};
@@ -28,9 +28,9 @@ CODER_INTERFACE(ICompressCoder, 0x05)
CODER_INTERFACE(ICompressCoder2, 0x18)
{
STDMETHOD(Code)(ISequentialInStream **inStreams,
const UInt64 **inSizes,
const UInt64 **inSizes,
UInt32 numInStreams,
ISequentialOutStream **outStreams,
ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress) PURE;
@@ -49,7 +49,7 @@ namespace NCoderPropID
kNumFastBytes = 0x450,
kMatchFinder,
kMatchFinderCycles,
kNumPasses = 0x460,
kNumPasses = 0x460,
kAlgorithm = 0x470,
kMultiThread = 0x480,
kNumThreads,
@@ -59,7 +59,7 @@ namespace NCoderPropID
CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
{
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties) PURE;
};
@@ -124,7 +124,7 @@ CODER_INTERFACE(ICompressFilter, 0x40)
// Filter return outSize (UInt32)
// if (outSize <= size): Filter have converted outSize bytes
// if (outSize > size): Filter have not converted anything.
// and it needs at least outSize bytes to convert one block
// and it needs at least outSize bytes to convert one block
// (it's for crypto block algorithms).
};

View File

@@ -21,7 +21,7 @@ STREAM_INTERFACE(ISequentialInStream, 0x01)
/*
Out: if size != 0, return_value = S_OK and (*processedSize == 0),
then there are no more bytes in stream.
if (size > 0) && there are bytes in stream,
if (size > 0) && there are bytes in stream,
this function must read at least 1 byte.
This function is allowed to read less than number of remaining bytes in stream.
You must call Read function in loop, if you need exact amount of data

View File

@@ -35,7 +35,7 @@ void MyFree(void *address) throw()
if (address != 0)
fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
#endif
::free(address);
}
@@ -62,7 +62,7 @@ void MidFree(void *address) throw()
::VirtualFree(address, 0, MEM_RELEASE);
}
static SIZE_T g_LargePageSize =
static SIZE_T g_LargePageSize =
#ifdef _WIN64
(1 << 21);
#else
@@ -92,10 +92,10 @@ void *BigAlloc(size_t size) throw()
#ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
#endif
if (size >= (1 << 18))
{
void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
MEM_COMMIT, PAGE_READWRITE);
if (res != 0)
return res;
@@ -109,7 +109,7 @@ void BigFree(void *address) throw()
if (address != 0)
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
#endif
if (address == 0)
return;
::VirtualFree(address, 0, MEM_RELEASE);

View File

@@ -14,9 +14,9 @@ void CCRC::InitTable()
{
UInt32 r = i;
for (int j = 0; j < 8; j++)
if (r & 1)
if (r & 1)
r = (r >> 1) ^ kCRCPoly;
else
else
r >>= 1;
CCRC::Table[i] = r;
}

View File

@@ -20,7 +20,7 @@ public:
void UpdateUInt32(UInt32 v);
void UpdateUInt64(UInt64 v);
void Update(const void *data, size_t size);
UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
static UInt32 CalculateDigest(const void *data, size_t size)
{
CCRC crc;

View File

@@ -26,11 +26,11 @@ public:
// T& operator*() const { return *_p; }
T** operator&() { return &_p; }
T* operator->() const { return _p; }
T* operator=(T* p)
{
T* operator=(T* p)
{
if (p != 0)
p->AddRef();
if (_p)
if (_p)
_p->Release();
_p = p;
return p;
@@ -114,8 +114,8 @@ public:
unsigned int Length() const { return ::SysStringLen(m_str); }
operator BSTR() const { return m_str; }
BSTR* operator&() { return &m_str; }
BSTR MyCopy() const
{
BSTR MyCopy() const
{
int byteLen = ::SysStringByteLen(m_str);
BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
memmove(res, m_str, byteLen);
@@ -147,7 +147,7 @@ public:
};
#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
(REFGUID iid, void **outObject) {
(REFGUID iid, void **outObject) {
#define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \
{ *outObject = (void *)(i *)this; AddRef(); return S_OK; }

View File

@@ -23,7 +23,7 @@ typedef struct {
#ifdef __cplusplus
inline bool operator==(REFGUID g1, REFGUID g2)
{
{
for (int i = 0; i < (int)sizeof(g1); i++)
if (((const unsigned char *)&g1)[i] != ((const unsigned char *)&g2)[i])
return false;

View File

@@ -9,7 +9,7 @@
#if (_WIN32_WCE > 300)
#include <basetyps.h>
#else
#define MIDL_INTERFACE(x) struct
#define MIDL_INTERFACE(x) struct
#endif
#else
#include <basetyps.h>
@@ -17,8 +17,8 @@
#include <unknwn.h>
#else
#else
#include "MyWindows.h"
#endif
#endif

View File

@@ -85,9 +85,9 @@ typedef LONG SCODE;
#define E_INVALIDARG ((HRESULT)0x80070057L)
#ifdef _MSC_VER
#define STDMETHODCALLTYPE __stdcall
#define STDMETHODCALLTYPE __stdcall
#else
#define STDMETHODCALLTYPE
#define STDMETHODCALLTYPE
#endif
#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
@@ -97,7 +97,7 @@ typedef LONG SCODE;
#define PURE = 0
#define MIDL_INTERFACE(x) struct
#define MIDL_INTERFACE(x) struct
struct IUnknown
{
@@ -113,7 +113,7 @@ typedef IUnknown *LPUNKNOWN;
#define VARIANT_FALSE ((VARIANT_BOOL)0)
enum VARENUM
{
{
VT_EMPTY = 0,
VT_NULL = 1,
VT_I2 = 2,
@@ -153,7 +153,7 @@ typedef struct tagPROPVARIANT
PROPVAR_PAD1 wReserved1;
PROPVAR_PAD2 wReserved2;
PROPVAR_PAD3 wReserved3;
union
union
{
CHAR cVal;
UCHAR bVal;
@@ -191,7 +191,7 @@ MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
#define CP_OEMCP 1
typedef enum tagSTREAM_SEEK
{
{
STREAM_SEEK_SET = 0,
STREAM_SEEK_CUR = 1,
STREAM_SEEK_END = 2

View File

@@ -6,11 +6,11 @@
class CNewException {};
#ifdef _WIN32
void
void
#ifdef _MSC_VER
__cdecl
__cdecl
#endif
operator delete(void *p) throw();
#endif
#endif
#endif
#endif

View File

@@ -6,4 +6,4 @@
// #include "MyWindows.h"
#include "NewHandler.h"
#endif
#endif

View File

@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an