summaryrefslogtreecommitdiffstats
path: root/src/libs/7zip/win/CPP/7zip/Compress
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/7zip/win/CPP/7zip/Compress')
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.cpp176
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.h55
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/BranchMisc.cpp42
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/CodecExports.cpp160
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Compress.pri30
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.cpp21
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.h1
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/DeltaFilter.cpp17
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Lzma2Decoder.cpp4
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.cpp2
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.h2
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.cpp18
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.h8
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.cpp34
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.h4
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/RangeCoder.h30
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/RangeCoderBit.h16
-rw-r--r--src/libs/7zip/win/CPP/7zip/Compress/StdAfx.h2
18 files changed, 236 insertions, 386 deletions
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.cpp
index 684da5abf..9da6b9c28 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.cpp
@@ -15,35 +15,22 @@ inline unsigned GetIndex(Byte b0, Byte b1) { return ((b1 == 0xE8) ? b0 : ((b1 ==
#ifndef EXTRACT_ONLY
-static const int kBufferSize = 1 << 17;
+static const unsigned kBufSize = 1 << 17;
-static bool inline Test86MSByte(Byte b)
-{
- return (b == 0 || b == 0xFF);
-}
+#define NUM_BITS 2
+#define SIGN_BIT (1 << NUM_BITS)
+#define MASK_HIGH (0x100 - (1 << (NUM_BITS + 1)))
-bool CEncoder::Create()
+static const UInt32 kDefaultLimit = (1 << (24 + NUM_BITS));
+
+static bool inline Test86MSByte(Byte b)
{
- if (!_mainStream.Create(1 << 18))
- return false;
- if (!_callStream.Create(1 << 18))
- return false;
- if (!_jumpStream.Create(1 << 18))
- return false;
- if (!_rangeEncoder.Create(1 << 20))
- return false;
- if (_buffer == 0)
- {
- _buffer = (Byte *)MidAlloc(kBufferSize);
- if (_buffer == 0)
- return false;
- }
- return true;
+ return (((b) + SIGN_BIT) & MASK_HIGH) == 0;
}
CEncoder::~CEncoder()
{
- ::MidFree(_buffer);
+ ::MidFree(_buf);
}
HRESULT CEncoder::Flush()
@@ -51,12 +38,10 @@ HRESULT CEncoder::Flush()
RINOK(_mainStream.Flush());
RINOK(_callStream.Flush());
RINOK(_jumpStream.Flush());
- _rangeEncoder.FlushData();
- return _rangeEncoder.FlushStream();
+ _rc.FlushData();
+ return _rc.FlushStream();
}
-const UInt32 kDefaultLimit = (1 << 24);
-
HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
ISequentialOutStream **outStreams, const UInt64 ** /* outSizes */, UInt32 numOutStreams,
ICompressProgressInfo *progress)
@@ -64,32 +49,34 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
if (numInStreams != 1 || numOutStreams != 4)
return E_INVALIDARG;
- if (!Create())
- return E_OUTOFMEMORY;
+ if (!_mainStream.Create(1 << 18)) return E_OUTOFMEMORY;
+ if (!_callStream.Create(1 << 18)) return E_OUTOFMEMORY;
+ if (!_jumpStream.Create(1 << 18)) return E_OUTOFMEMORY;
+ if (!_rc.Create(1 << 20)) return E_OUTOFMEMORY;
+ if (_buf == 0)
+ {
+ _buf = (Byte *)MidAlloc(kBufSize);
+ if (_buf == 0)
+ return E_OUTOFMEMORY;
+ }
bool sizeIsDefined = false;
UInt64 inSize = 0;
- if (inSizes != NULL)
- if (inSizes[0] != NULL)
+ if (inSizes)
+ if (inSizes[0])
{
inSize = *inSizes[0];
if (inSize <= kDefaultLimit)
sizeIsDefined = true;
}
- CCoderReleaser releaser(this);
-
ISequentialInStream *inStream = inStreams[0];
- _mainStream.SetStream(outStreams[0]);
- _mainStream.Init();
- _callStream.SetStream(outStreams[1]);
- _callStream.Init();
- _jumpStream.SetStream(outStreams[2]);
- _jumpStream.Init();
- _rangeEncoder.SetStream(outStreams[3]);
- _rangeEncoder.Init();
- for (int i = 0; i < 256 + 2; i++)
+ _mainStream.SetStream(outStreams[0]); _mainStream.Init();
+ _callStream.SetStream(outStreams[1]); _callStream.Init();
+ _jumpStream.SetStream(outStreams[2]); _jumpStream.Init();
+ _rc.SetStream(outStreams[3]); _rc.Init();
+ for (unsigned i = 0; i < 256 + 2; i++)
_statusEncoder[i].Init();
CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
@@ -99,12 +86,12 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
UInt32 nowPos = 0;
UInt64 nowPos64 = 0;
- UInt32 bufferPos = 0;
+ UInt32 bufPos = 0;
Byte prevByte = 0;
UInt64 subStreamIndex = 0;
- UInt64 subStreamStartPos = 0;
+ UInt64 subStreamStartPos = 0;
UInt64 subStreamEndPos = 0;
for (;;)
@@ -112,23 +99,23 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
UInt32 processedSize = 0;
for (;;)
{
- UInt32 size = kBufferSize - (bufferPos + processedSize);
+ UInt32 size = kBufSize - (bufPos + processedSize);
UInt32 processedSizeLoc;
if (size == 0)
break;
- RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
+ RINOK(inStream->Read(_buf + bufPos + processedSize, size, &processedSizeLoc));
if (processedSizeLoc == 0)
break;
processedSize += processedSizeLoc;
}
- UInt32 endPos = bufferPos + processedSize;
-
+ UInt32 endPos = bufPos + processedSize;
+
if (endPos < 5)
{
// change it
- for (bufferPos = 0; bufferPos < endPos; bufferPos++)
+ for (bufPos = 0; bufPos < endPos; bufPos++)
{
- Byte b = _buffer[bufferPos];
+ Byte b = _buf[bufPos];
_mainStream.WriteByte(b);
UInt32 index;
if (b == 0xE8)
@@ -142,37 +129,37 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
prevByte = b;
continue;
}
- _statusEncoder[index].Encode(&_rangeEncoder, 0);
+ _statusEncoder[index].Encode(&_rc, 0);
prevByte = b;
}
return Flush();
}
- bufferPos = 0;
+ bufPos = 0;
UInt32 limit = endPos - 5;
- while(bufferPos <= limit)
+ while (bufPos <= limit)
{
- Byte b = _buffer[bufferPos];
+ Byte b = _buf[bufPos];
_mainStream.WriteByte(b);
if (!IsJ(prevByte, b))
{
- bufferPos++;
+ bufPos++;
prevByte = b;
continue;
}
- Byte nextByte = _buffer[bufferPos + 4];
+ Byte nextByte = _buf[bufPos + 4];
UInt32 src =
(UInt32(nextByte) << 24) |
- (UInt32(_buffer[bufferPos + 3]) << 16) |
- (UInt32(_buffer[bufferPos + 2]) << 8) |
- (_buffer[bufferPos + 1]);
- UInt32 dest = (nowPos + bufferPos + 5) + src;
+ (UInt32(_buf[bufPos + 3]) << 16) |
+ (UInt32(_buf[bufPos + 2]) << 8) |
+ (_buf[bufPos + 1]);
+ UInt32 dest = (nowPos + bufPos + 5) + src;
// if (Test86MSByte(nextByte))
bool convert;
- if (getSubStreamSize != NULL)
+ if (getSubStreamSize)
{
- UInt64 currentPos = (nowPos64 + bufferPos);
+ UInt64 currentPos = (nowPos64 + bufPos);
while (subStreamEndPos < currentPos)
{
UInt64 subStreamSize;
@@ -214,8 +201,8 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
unsigned index = GetIndex(prevByte, b);
if (convert)
{
- _statusEncoder[index].Encode(&_rangeEncoder, 1);
- bufferPos += 5;
+ _statusEncoder[index].Encode(&_rc, 1);
+ bufPos += 5;
COutBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
for (int i = 24; i >= 0; i -= 8)
s.WriteByte((Byte)(dest >> i));
@@ -223,30 +210,30 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams, const UInt64 **inSiz
}
else
{
- _statusEncoder[index].Encode(&_rangeEncoder, 0);
- bufferPos++;
+ _statusEncoder[index].Encode(&_rc, 0);
+ bufPos++;
prevByte = b;
}
}
- nowPos += bufferPos;
- nowPos64 += bufferPos;
+ nowPos += bufPos;
+ nowPos64 += bufPos;
- if (progress != NULL)
+ if (progress)
{
/*
const UInt64 compressedSize =
_mainStream.GetProcessedSize() +
_callStream.GetProcessedSize() +
_jumpStream.GetProcessedSize() +
- _rangeEncoder.GetProcessedSize();
+ _rc.GetProcessedSize();
*/
RINOK(progress->SetRatioInfo(&nowPos64, NULL));
}
-
+
UInt32 i = 0;
- while(bufferPos < endPos)
- _buffer[i++] = _buffer[bufferPos++];
- bufferPos = i;
+ while (bufPos < endPos)
+ _buf[i++] = _buf[bufPos++];
+ bufPos = i;
}
}
@@ -284,46 +271,39 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams, const UInt64 ** /* i
if (numInStreams != 4 || numOutStreams != 1)
return E_INVALIDARG;
- if (!_mainInStream.Create(_inBufSizes[0]))
- return E_OUTOFMEMORY;
- if (!_callStream.Create(_inBufSizes[1]))
- return E_OUTOFMEMORY;
- if (!_jumpStream.Create(_inBufSizes[2]))
- return E_OUTOFMEMORY;
- if (!_rangeDecoder.Create(_inBufSizes[3]))
- return E_OUTOFMEMORY;
- if (!_outStream.Create(_outBufSize))
- return E_OUTOFMEMORY;
-
- CCoderReleaser releaser(this);
+ if (!_mainStream.Create(_inBufSizes[0])) return E_OUTOFMEMORY;
+ if (!_callStream.Create(_inBufSizes[1])) return E_OUTOFMEMORY;
+ if (!_jumpStream.Create(_inBufSizes[2])) return E_OUTOFMEMORY;
+ if (!_rc.Create(_inBufSizes[3])) return E_OUTOFMEMORY;
+ if (!_outStream.Create(_outBufSize)) return E_OUTOFMEMORY;
- _mainInStream.SetStream(inStreams[0]);
+ _mainStream.SetStream(inStreams[0]);
_callStream.SetStream(inStreams[1]);
_jumpStream.SetStream(inStreams[2]);
- _rangeDecoder.SetStream(inStreams[3]);
+ _rc.SetStream(inStreams[3]);
_outStream.SetStream(outStreams[0]);
- _mainInStream.Init();
+ _mainStream.Init();
_callStream.Init();
_jumpStream.Init();
- _rangeDecoder.Init();
+ _rc.Init();
_outStream.Init();
- for (int i = 0; i < 256 + 2; i++)
+ for (unsigned i = 0; i < 256 + 2; i++)
_statusDecoder[i].Init();
Byte prevByte = 0;
UInt32 processedBytes = 0;
for (;;)
{
- if (processedBytes >= (1 << 20) && progress != NULL)
+ if (processedBytes >= (1 << 20) && progress)
{
/*
const UInt64 compressedSize =
- _mainInStream.GetProcessedSize() +
+ _mainStream.GetProcessedSize() +
_callStream.GetProcessedSize() +
_jumpStream.GetProcessedSize() +
- _rangeDecoder.GetProcessedSize();
+ _rc.GetProcessedSize();
*/
const UInt64 nowPos64 = _outStream.GetProcessedSize();
RINOK(progress->SetRatioInfo(NULL, &nowPos64));
@@ -334,8 +314,8 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams, const UInt64 ** /* i
const UInt32 kBurstSize = (1 << 18);
for (i = 0; i < kBurstSize; i++)
{
- if (!_mainInStream.ReadByte(b))
- return Flush();
+ if (!_mainStream.ReadByte(b))
+ return _outStream.Flush();
_outStream.WriteByte(b);
if (IsJ(prevByte, b))
break;
@@ -345,14 +325,14 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams, const UInt64 ** /* i
if (i == kBurstSize)
continue;
unsigned index = GetIndex(prevByte, b);
- if (_statusDecoder[index].Decode(&_rangeDecoder) == 1)
+ if (_statusDecoder[index].Decode(&_rc) == 1)
{
UInt32 src = 0;
CInBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
- for (int i = 0; i < 4; i++)
+ for (unsigned i = 0; i < 4; i++)
{
Byte b0;
- if(!s.ReadByte(b0))
+ if (!s.ReadByte(b0))
return S_FALSE;
src <<= 8;
src |= ((UInt32)b0);
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.h b/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.h
index 79a713f17..e7bd37951 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Bcj2Coder.h
@@ -12,7 +12,7 @@
namespace NCompress {
namespace NBcj2 {
-const int kNumMoveBits = 5;
+const unsigned kNumMoveBits = 5;
#ifndef EXTRACT_ONLY
@@ -20,32 +20,15 @@ class CEncoder:
public ICompressCoder2,
public CMyUnknownImp
{
- Byte *_buffer;
- bool Create();
+ Byte *_buf;
COutBuffer _mainStream;
COutBuffer _callStream;
COutBuffer _jumpStream;
- NCompress::NRangeCoder::CEncoder _rangeEncoder;
- NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
+ NRangeCoder::CEncoder _rc;
+ NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
HRESULT Flush();
-public:
- void ReleaseStreams()
- {
- _mainStream.ReleaseStream();
- _callStream.ReleaseStream();
- _jumpStream.ReleaseStream();
- _rangeEncoder.ReleaseStream();
- }
-
- class CCoderReleaser
- {
- CEncoder *_coder;
- public:
- CCoderReleaser(CEncoder *coder): _coder(coder) {}
- ~CCoderReleaser() { _coder->ReleaseStreams(); }
- };
public:
MY_UNKNOWN_IMP
@@ -56,7 +39,8 @@ public:
STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
ICompressProgressInfo *progress);
- CEncoder(): _buffer(0) {};
+
+ CEncoder(): _buf(0) {};
~CEncoder();
};
@@ -67,37 +51,19 @@ class CDecoder:
public ICompressSetBufSize,
public CMyUnknownImp
{
- CInBuffer _mainInStream;
+ CInBuffer _mainStream;
CInBuffer _callStream;
CInBuffer _jumpStream;
- NCompress::NRangeCoder::CDecoder _rangeDecoder;
- NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
+ NRangeCoder::CDecoder _rc;
+ NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
COutBuffer _outStream;
UInt32 _inBufSizes[4];
UInt32 _outBufSize;
public:
- void ReleaseStreams()
- {
- _mainInStream.ReleaseStream();
- _callStream.ReleaseStream();
- _jumpStream.ReleaseStream();
- _rangeDecoder.ReleaseStream();
- _outStream.ReleaseStream();
- }
-
- HRESULT Flush() { return _outStream.Flush(); }
- class CCoderReleaser
- {
- CDecoder *_coder;
- public:
- CCoderReleaser(CDecoder *coder): _coder(coder) {}
- ~CCoderReleaser() { _coder->ReleaseStreams(); }
- };
-
-public:
MY_UNKNOWN_IMP1(ICompressSetBufSize);
+
HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
ICompressProgressInfo *progress);
@@ -107,6 +73,7 @@ public:
STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
+
CDecoder();
};
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/BranchMisc.cpp b/src/libs/7zip/win/CPP/7zip/Compress/BranchMisc.cpp
index 423b723ab..239f25138 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/BranchMisc.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/BranchMisc.cpp
@@ -6,32 +6,16 @@
#include "BranchMisc.h"
-UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::ARM_Convert(data, size, _bufferPos, 1); }
-
-UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::ARM_Convert(data, size, _bufferPos, 0); }
-
-UInt32 CBC_ARMT_Encoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 1); }
-
-UInt32 CBC_ARMT_Decoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::ARMT_Convert(data, size, _bufferPos, 0); }
-
-UInt32 CBC_PPC_Encoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::PPC_Convert(data, size, _bufferPos, 1); }
-
-UInt32 CBC_PPC_Decoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::PPC_Convert(data, size, _bufferPos, 0); }
-
-UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 1); }
-
-UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::SPARC_Convert(data, size, _bufferPos, 0); }
-
-UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::IA64_Convert(data, size, _bufferPos, 1); }
-
-UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
- { return (UInt32)::IA64_Convert(data, size, _bufferPos, 0); }
+#define SUB_FILTER_IMP2(name, coderStr, coderNum) \
+ UInt32 CBC_ ## name ## coderStr::SubFilter(Byte *data, UInt32 size) \
+ { return (UInt32)::name ## Convert(data, size, _bufferPos, coderNum); }
+
+#define SUB_FILTER_IMP(name) \
+ SUB_FILTER_IMP2(name, Encoder, 1) \
+ SUB_FILTER_IMP2(name, Decoder, 0) \
+
+SUB_FILTER_IMP(ARM_)
+SUB_FILTER_IMP(ARMT_)
+SUB_FILTER_IMP(PPC_)
+SUB_FILTER_IMP(SPARC_)
+SUB_FILTER_IMP(IA64_)
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/CodecExports.cpp b/src/libs/7zip/win/CPP/7zip/Compress/CodecExports.cpp
deleted file mode 100644
index 4ff1c0fcb..000000000
--- a/src/libs/7zip/win/CPP/7zip/Compress/CodecExports.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-// CodecExports.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/ComTry.h"
-
-#include "../../Windows/PropVariant.h"
-
-#include "../ICoder.h"
-
-#include "../Common/RegisterCodec.h"
-
-extern unsigned int g_NumCodecs;
-extern const CCodecInfo *g_Codecs[];
-
-static const UInt16 kDecodeId = 0x2790;
-
-DEFINE_GUID(CLSID_CCodec,
-0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
-
-static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
-{
- if ((value->bstrVal = ::SysAllocStringByteLen(s, size)) != 0)
- value->vt = VT_BSTR;
- return S_OK;
-}
-
-static inline HRESULT SetPropGUID(const GUID &guid, PROPVARIANT *value)
-{
- return SetPropString((const char *)&guid, sizeof(GUID), value);
-}
-
-static HRESULT SetClassID(CMethodId id, bool encode, PROPVARIANT *value)
-{
- GUID clsId = CLSID_CCodec;
- for (int i = 0; i < sizeof(id); i++, id >>= 8)
- clsId.Data4[i] = (Byte)(id & 0xFF);
- if (encode)
- clsId.Data3++;
- return SetPropGUID(clsId, value);
-}
-
-static HRESULT FindCodecClassId(const GUID *clsID, UInt32 isCoder2, bool isFilter, bool &encode, int &index)
-{
- index = -1;
- if (clsID->Data1 != CLSID_CCodec.Data1 ||
- clsID->Data2 != CLSID_CCodec.Data2 ||
- (clsID->Data3 & ~1) != kDecodeId)
- return S_OK;
- encode = (clsID->Data3 != kDecodeId);
- UInt64 id = 0;
- for (int j = 0; j < 8; j++)
- id |= ((UInt64)clsID->Data4[j]) << (8 * j);
- for (unsigned i = 0; i < g_NumCodecs; i++)
- {
- const CCodecInfo &codec = *g_Codecs[i];
- if (id != codec.Id || encode && !codec.CreateEncoder || !encode && !codec.CreateDecoder)
- continue;
- if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
- codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
- return E_NOINTERFACE;
- index = i;
- return S_OK;
- }
- return S_OK;
-}
-
-STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- bool isCoder = (*iid == IID_ICompressCoder) != 0;
- bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
- bool isFilter = (*iid == IID_ICompressFilter) != 0;
- const CCodecInfo &codec = *g_Codecs[index];
- if (!isFilter && codec.IsFilter || isFilter && !codec.IsFilter ||
- codec.NumInStreams != 1 && !isCoder2 || codec.NumInStreams == 1 && isCoder2)
- return E_NOINTERFACE;
- if (encode)
- {
- if (!codec.CreateEncoder)
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = codec.CreateEncoder();
- }
- else
- {
- if (!codec.CreateDecoder)
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = codec.CreateDecoder();
- }
- if (isCoder)
- ((ICompressCoder *)*outObject)->AddRef();
- else if (isCoder2)
- ((ICompressCoder2 *)*outObject)->AddRef();
- else
- ((ICompressFilter *)*outObject)->AddRef();
- return S_OK;
- COM_TRY_END
-}
-
-STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
-{
- *outObject = 0;
- bool isCoder = (*iid == IID_ICompressCoder) != 0;
- bool isCoder2 = (*iid == IID_ICompressCoder2) != 0;
- bool isFilter = (*iid == IID_ICompressFilter) != 0;
- if (!isCoder && !isCoder2 && !isFilter)
- return E_NOINTERFACE;
- bool encode;
- int codecIndex;
- HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
- if (res != S_OK)
- return res;
- if (codecIndex < 0)
- return CLASS_E_CLASSNOTAVAILABLE;
- return CreateCoder2(encode, codecIndex, iid, outObject);
-}
-
-STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
-{
- ::VariantClear((VARIANTARG *)value);
- const CCodecInfo &codec = *g_Codecs[codecIndex];
- switch(propID)
- {
- case NMethodPropID::kID:
- {
- value->uhVal.QuadPart = (UInt64)codec.Id;
- value->vt = VT_UI8;
- break;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(codec.Name)) != 0)
- value->vt = VT_BSTR;
- break;
- case NMethodPropID::kDecoder:
- if (codec.CreateDecoder)
- return SetClassID(codec.Id, false, value);
- break;
- case NMethodPropID::kEncoder:
- if (codec.CreateEncoder)
- return SetClassID(codec.Id, true, value);
- break;
- case NMethodPropID::kInStreams:
- {
- if (codec.NumInStreams != 1)
- {
- value->vt = VT_UI4;
- value->ulVal = (ULONG)codec.NumInStreams;
- }
- break;
- }
- }
- return S_OK;
-}
-
-STDAPI GetNumberOfMethods(UINT32 *numCodecs)
-{
- *numCodecs = g_NumCodecs;
- return S_OK;
-}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Compress.pri b/src/libs/7zip/win/CPP/7zip/Compress/Compress.pri
new file mode 100644
index 000000000..db923a868
--- /dev/null
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Compress.pri
@@ -0,0 +1,30 @@
+HEADERS += $$7ZIP_BASE/CPP/7zip/Compress/Bcj2Coder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/BcjCoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/BranchCoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/BranchMisc.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/CopyCoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/Lzma2Decoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/Lzma2Encoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/LzmaDecoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/LzmaEncoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/RangeCoder.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/RangeCoderBit.h \
+ $$7ZIP_BASE/CPP/7zip/Compress/StdAfx.h
+
+SOURCES += $$7ZIP_BASE/CPP/7zip/Compress/Bcj2Coder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/Bcj2Register.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/BcjCoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/BcjRegister.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/BranchCoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/BranchMisc.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/BranchRegister.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/ByteSwap.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/CopyCoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/CopyRegister.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/DeltaFilter.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/Lzma2Decoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/Lzma2Encoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/Lzma2Register.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/LzmaDecoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/LzmaEncoder.cpp \
+ $$7ZIP_BASE/CPP/7zip/Compress/LzmaRegister.cpp
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.cpp
index f71692a77..f0863202a 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.cpp
@@ -22,10 +22,10 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
- if (_buffer == 0)
+ if (!_buffer)
{
_buffer = (Byte *)::MidAlloc(kBufferSize);
- if (_buffer == 0)
+ if (!_buffer)
return E_OUTOFMEMORY;
}
@@ -33,9 +33,8 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
for (;;)
{
UInt32 size = kBufferSize;
- if (outSize != 0)
- if (size > *outSize - TotalSize)
- size = (UInt32)(*outSize - TotalSize);
+ if (outSize && size > *outSize - TotalSize)
+ size = (UInt32)(*outSize - TotalSize);
RINOK(inStream->Read(_buffer, size, &size));
if (size == 0)
break;
@@ -44,7 +43,7 @@ STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
RINOK(WriteStream(outStream, _buffer, size));
}
TotalSize += size;
- if (progress != NULL)
+ if (progress)
{
RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
}
@@ -60,8 +59,16 @@ STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
HRESULT CopyStream(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress)
{
- CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = new CCopyCoder;
return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
}
+HRESULT CopyStream_ExactSize(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt64 size, ICompressProgressInfo *progress)
+{
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+ RINOK(copyCoder->Code(inStream, outStream, NULL, &size, progress));
+ return copyCoderSpec->TotalSize == size ? S_OK : E_FAIL;
+}
+
}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.h b/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.h
index c5445ccf8..5e0bb6436 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/CopyCoder.h
@@ -28,6 +28,7 @@ public:
};
HRESULT CopyStream(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress);
+HRESULT CopyStream_ExactSize(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt64 size, ICompressProgressInfo *progress);
}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/DeltaFilter.cpp b/src/libs/7zip/win/CPP/7zip/Compress/DeltaFilter.cpp
index 2e421acf4..d8378a60e 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/DeltaFilter.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/DeltaFilter.cpp
@@ -62,9 +62,22 @@ STDMETHODIMP CDeltaEncoder::SetCoderProperties(const PROPID *propIDs, const PROP
for (UInt32 i = 0; i < numProps; i++)
{
const PROPVARIANT &prop = props[i];
- if (propIDs[i] != NCoderPropID::kDefaultProp || prop.vt != VT_UI4 || prop.ulVal < 1 || prop.ulVal > 256)
+ PROPID propID = propIDs[i];
+ if (propID >= NCoderPropID::kReduceSize)
+ continue;
+ if (prop.vt != VT_UI4)
return E_INVALIDARG;
- delta = prop.ulVal;
+ switch (propID)
+ {
+ case NCoderPropID::kDefaultProp:
+ delta = (UInt32)prop.ulVal;
+ if (delta < 1 || delta > 256)
+ return E_INVALIDARG;
+ break;
+ case NCoderPropID::kNumThreads: break;
+ case NCoderPropID::kLevel: break;
+ default: return E_INVALIDARG;
+ }
}
_delta = delta;
return S_OK;
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Decoder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Decoder.cpp
index 322015e29..b20ae5f5e 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Decoder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Decoder.cpp
@@ -66,7 +66,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
_outSize = *outSize;
Lzma2Dec_Init(&_state);
-
+
_inPos = _inSize = 0;
_inSizeProcessed = _outSizeProcessed = 0;
return S_OK;
@@ -93,7 +93,7 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
const UInt32 kStepSize = ((UInt32)1 << 22);
if (curSize > kStepSize)
curSize = (SizeT)kStepSize;
-
+
ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
if (_outSizeDefined)
{
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.cpp
index 5e4c71bea..f867881c0 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.cpp
@@ -90,5 +90,5 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream
return progressWrap.Res;
return SResToHRESULT(res);
}
-
+
}}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.h b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.h
index f0fb74d33..6a2318076 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/Lzma2Encoder.h
@@ -21,7 +21,7 @@ class CEncoder:
CLzma2EncHandle _encoder;
public:
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties)
-
+
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.cpp
index b7c260bd9..d378ba668 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.cpp
@@ -27,7 +27,8 @@ namespace NLzma {
CDecoder::CDecoder(): _inBuf(0), _propsWereSet(false), _outSizeDefined(false),
_inBufSize(1 << 20),
_outBufSize(1 << 22),
- FinishStream(false)
+ FinishStream(false),
+ NeedMoreInput(false)
{
_inSizeProcessed = 0;
_inPos = _inSize = 0;
@@ -81,6 +82,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
{
_inSizeProcessed = 0;
_inPos = _inSize = 0;
+ NeedMoreInput = false;
SetOutStreamSizeResume(outSize);
return S_OK;
}
@@ -103,7 +105,7 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
SizeT dicPos = _state.dicPos;
SizeT curSize = next - dicPos;
-
+
ELzmaFinishMode finishMode = LZMA_FINISH_ANY;
if (_outSizeDefined)
{
@@ -144,9 +146,21 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
return S_FALSE;
RINOK(res2);
if (stopDecoding)
+ {
+ if (status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ NeedMoreInput = true;
+ if (FinishStream &&
+ status != LZMA_STATUS_FINISHED_WITH_MARK &&
+ status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)
+ return S_FALSE;
return S_OK;
+ }
if (finished)
+ {
+ if (status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ NeedMoreInput = true;
return (status == LZMA_STATUS_FINISHED_WITH_MARK ? S_OK : S_FALSE);
+ }
}
if (progress)
{
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.h b/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.h
index d28a4634b..140c48b9c 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/LzmaDecoder.h
@@ -62,7 +62,7 @@ public:
STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
#ifndef NO_READ_FROM_CODER
-
+
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
@@ -73,10 +73,14 @@ public:
#endif
- bool FinishStream;
+ bool FinishStream; // set it before decoding, if you need to decode full LZMA stream
+
+ bool NeedMoreInput; // it's set by decoder, if it needs more input data to decode stream
CDecoder();
virtual ~CDecoder();
+
+ UInt64 GetOutputProcessedSize() const { return _outSizeProcessed; }
};
}}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.cpp b/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.cpp
index 9bdedaeb6..484d04523 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.cpp
+++ b/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.cpp
@@ -73,6 +73,8 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
return 1;
}
+#define SET_PROP_32(_id_, _dest_) case NCoderPropID::_id_: ep._dest_ = v; break;
+
HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
{
if (propID == NCoderPropID::kMatchFinder)
@@ -81,18 +83,29 @@ HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
return E_INVALIDARG;
return ParseMatchFinder(prop.bstrVal, &ep.btMode, &ep.numHashBytes) ? S_OK : E_INVALIDARG;
}
+ if (propID > NCoderPropID::kReduceSize)
+ return S_OK;
+ if (propID == NCoderPropID::kReduceSize)
+ {
+ if (prop.vt == VT_UI8)
+ ep.reduceSize = prop.uhVal.QuadPart;
+ return S_OK;
+ }
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UInt32 v = prop.ulVal;
switch (propID)
{
- case NCoderPropID::kNumFastBytes: ep.fb = v; break;
- case NCoderPropID::kMatchFinderCycles: ep.mc = v; break;
- case NCoderPropID::kAlgorithm: ep.algo = v; break;
- case NCoderPropID::kDictionarySize: ep.dictSize = v; break;
- case NCoderPropID::kPosStateBits: ep.pb = v; break;
- case NCoderPropID::kLitPosBits: ep.lp = v; break;
- case NCoderPropID::kLitContextBits: ep.lc = v; break;
+ case NCoderPropID::kDefaultProp: if (v > 31) return E_INVALIDARG; ep.dictSize = (UInt32)1 << (unsigned)v; break;
+ SET_PROP_32(kLevel, level)
+ SET_PROP_32(kNumFastBytes, fb)
+ SET_PROP_32(kMatchFinderCycles, mc)
+ SET_PROP_32(kAlgorithm, algo)
+ SET_PROP_32(kDictionarySize, dictSize)
+ SET_PROP_32(kPosStateBits, pb)
+ SET_PROP_32(kLitPosBits, lp)
+ SET_PROP_32(kLitContextBits, lc)
+ SET_PROP_32(kNumThreads, numThreads)
default: return E_INVALIDARG;
}
return S_OK;
@@ -111,9 +124,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
switch (propID)
{
case NCoderPropID::kEndMarker:
- if (prop.vt != VT_BOOL) return E_INVALIDARG; props.writeEndMark = (prop.boolVal == VARIANT_TRUE); break;
- case NCoderPropID::kNumThreads:
- if (prop.vt != VT_UI4) return E_INVALIDARG; props.numThreads = prop.ulVal; break;
+ if (prop.vt != VT_BOOL) return E_INVALIDARG; props.writeEndMark = (prop.boolVal != VARIANT_FALSE); break;
default:
RINOK(SetLzmaProp(propID, prop, props));
}
@@ -137,6 +148,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream
CCompressProgressWrap progressWrap(progress);
SRes res = LzmaEnc_Encode(_encoder, &outWrap.p, &inWrap.p, progress ? &progressWrap.p : NULL, &g_Alloc, &g_BigAlloc);
+ _inputProcessed = inWrap.Processed;
if (res == SZ_ERROR_READ && inWrap.Res != S_OK)
return inWrap.Res;
if (res == SZ_ERROR_WRITE && outWrap.Res != S_OK)
@@ -145,5 +157,5 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream
return progressWrap.Res;
return SResToHRESULT(res);
}
-
+
}}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.h b/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.h
index 904c0002c..7e15a132d 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/LzmaEncoder.h
@@ -19,9 +19,10 @@ class CEncoder:
public CMyUnknownImp
{
CLzmaEncHandle _encoder;
+ UInt64 _inputProcessed;
public:
MY_UNKNOWN_IMP2(ICompressSetCoderProperties, ICompressWriteCoderProperties)
-
+
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
@@ -29,6 +30,7 @@ public:
CEncoder();
virtual ~CEncoder();
+ UInt64 GetInputProcessedSize() const { return _inputProcessed; }
};
}}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/RangeCoder.h b/src/libs/7zip/win/CPP/7zip/Compress/RangeCoder.h
index 1eb2a6d47..1555bd705 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/RangeCoder.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/RangeCoder.h
@@ -1,5 +1,5 @@
// Compress/RangeCoder.h
-// 2009-05-30 : Igor Pavlov : Public domain
+// 2013-01-10 : Igor Pavlov : Public domain
#ifndef __COMPRESS_RANGE_CODER_H
#define __COMPRESS_RANGE_CODER_H
@@ -10,7 +10,7 @@
namespace NCompress {
namespace NRangeCoder {
-const int kNumTopBits = 24;
+const unsigned kNumTopBits = 24;
const UInt32 kTopValue = (1 << kNumTopBits);
class CEncoder
@@ -21,7 +21,7 @@ public:
UInt64 Low;
UInt32 Range;
COutBuffer Stream;
- bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+ bool Create(UInt32 bufSize) { return Stream.Create(bufSize); }
void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
void Init()
@@ -36,14 +36,12 @@ public:
void FlushData()
{
// Low += 1;
- for(int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++)
ShiftLow();
}
HRESULT FlushStream() { return Stream.Flush(); }
- void ReleaseStream() { Stream.ReleaseStream(); }
-
void Encode(UInt32 start, UInt32 size, UInt32 total)
{
Low += start * (Range /= total);
@@ -57,7 +55,7 @@ public:
void ShiftLow()
{
- if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
+ if ((UInt32)Low < (UInt32)0xFF000000 || (unsigned)(Low >> 32) != 0)
{
Byte temp = _cache;
do
@@ -65,13 +63,13 @@ public:
Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
temp = 0xFF;
}
- while(--_cacheSize != 0);
+ while (--_cacheSize != 0);
_cache = (Byte)((UInt32)Low >> 24);
}
_cacheSize++;
Low = (UInt32)Low << 8;
}
-
+
void EncodeDirectBits(UInt32 value, int numBits)
{
for (numBits--; numBits >= 0; numBits--)
@@ -103,7 +101,7 @@ public:
}
}
- UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
+ UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
};
class CDecoder
@@ -112,7 +110,7 @@ public:
CInBuffer Stream;
UInt32 Range;
UInt32 Code;
- bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+ bool Create(UInt32 bufSize) { return Stream.Create(bufSize); }
void Normalize()
{
@@ -122,22 +120,20 @@ public:
Range <<= 8;
}
}
-
+
void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
void Init()
{
Stream.Init();
Code = 0;
Range = 0xFFFFFFFF;
- for(int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++)
Code = (Code << 8) | Stream.ReadByte();
}
- void ReleaseStream() { Stream.ReleaseStream(); }
-
UInt32 GetThreshold(UInt32 total)
{
- return (Code) / ( Range /= total);
+ return (Code) / (Range /= total);
}
void Decode(UInt32 start, UInt32 size)
@@ -197,7 +193,7 @@ public:
return symbol;
}
- UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
+ UInt64 GetProcessedSize() { return Stream.GetProcessedSize(); }
};
}}
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/RangeCoderBit.h b/src/libs/7zip/win/CPP/7zip/Compress/RangeCoderBit.h
index b5a1830d6..0eddd5586 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/RangeCoderBit.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/RangeCoderBit.h
@@ -1,5 +1,5 @@
// Compress/RangeCoderBit.h
-// 2009-05-30 : Igor Pavlov : Public domain
+// 2013-01-10 : Igor Pavlov : Public domain
#ifndef __COMPRESS_RANGE_CODER_BIT_H
#define __COMPRESS_RANGE_CODER_BIT_H
@@ -9,17 +9,17 @@
namespace NCompress {
namespace NRangeCoder {
-const int kNumBitModelTotalBits = 11;
+const unsigned kNumBitModelTotalBits = 11;
const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
-const int kNumMoveReducingBits = 4;
+const unsigned kNumMoveReducingBits = 4;
-const int kNumBitPriceShiftBits = 4;
+const unsigned kNumBitPriceShiftBits = 4;
const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
extern UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
-template <int numMoveBits>
+template <unsigned numMoveBits>
class CBitModel
{
public:
@@ -39,7 +39,7 @@ public:
void Init() { Prob = kBitModelTotal / 2; }
};
-template <int numMoveBits>
+template <unsigned numMoveBits>
class CBitEncoder: public CBitModel<numMoveBits>
{
public:
@@ -69,14 +69,14 @@ public:
}
UInt32 GetPrice(UInt32 symbol) const
{
- return ProbPrices[(this->Prob ^ ((-(int)symbol)) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
+ return ProbPrices[(this->Prob ^ ((-(int)(Int32)symbol)) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
}
UInt32 GetPrice0() const { return ProbPrices[this->Prob >> kNumMoveReducingBits]; }
UInt32 GetPrice1() const { return ProbPrices[(this->Prob ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]; }
};
-template <int numMoveBits>
+template <unsigned numMoveBits>
class CBitDecoder: public CBitModel<numMoveBits>
{
public:
diff --git a/src/libs/7zip/win/CPP/7zip/Compress/StdAfx.h b/src/libs/7zip/win/CPP/7zip/Compress/StdAfx.h
index 99a8aa46d..1cbd7feae 100644
--- a/src/libs/7zip/win/CPP/7zip/Compress/StdAfx.h
+++ b/src/libs/7zip/win/CPP/7zip/Compress/StdAfx.h
@@ -3,6 +3,6 @@
#ifndef __STDAFX_H
#define __STDAFX_H
-#include "../../Common/MyWindows.h"
+#include "../../Common/Common.h"
#endif