summaryrefslogtreecommitdiffstats
path: root/other-licenses/7zstub/src/7zip/Compress
diff options
context:
space:
mode:
Diffstat (limited to 'other-licenses/7zstub/src/7zip/Compress')
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.cpp18
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.h54
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/BranchTypes.h15
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.c101
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.h13
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/x86.cpp18
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/x86.h19
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.cpp412
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.h133
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.cpp52
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.h31
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.cpp17
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.h56
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/LZMA/LZMA.h82
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.cpp337
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.h251
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoder.h205
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.cpp80
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.h120
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBitTree.h161
-rw-r--r--other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h31
21 files changed, 0 insertions, 2206 deletions
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.cpp b/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.cpp
deleted file mode 100644
index 68e938bde..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// BranchCoder.cpp
-
-#include "StdAfx.h"
-#include "BranchCoder.h"
-
-STDMETHODIMP CBranchConverter::Init()
-{
- _bufferPos = 0;
- SubInit();
- return S_OK;
-}
-
-STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size)
-{
- UInt32 processedSize = SubFilter(data, size);
- _bufferPos += processedSize;
- return processedSize;
-}
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.h b/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.h
deleted file mode 100644
index b64562dfc..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// BranchCoder.h
-
-#ifndef __BRANCH_CODER_H
-#define __BRANCH_CODER_H
-
-#include "Common/MyCom.h"
-#include "Common/Types.h"
-#include "Common/Alloc.h"
-
-#include "../../ICoder.h"
-
-class CBranchConverter:
- public ICompressFilter,
- public CMyUnknownImp
-{
-protected:
- UInt32 _bufferPos;
- virtual void SubInit() {}
- virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
-public:
- MY_UNKNOWN_IMP;
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
-};
-
-#define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); };
-
-#define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); };
-
-#define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
-
-#define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
-
-#define MyClass2b(Name, id, subId, encodingId) \
-DEFINE_GUID(CLSID_CCompressConvert ## Name, \
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00);
-
-#define MyClassA(Name, id, subId) \
-MyClass2b(Name ## _Encoder, id, subId, 0x01) \
-MyClassEncoderA(Name ## _Encoder) \
-MyClass2b(Name ## _Decoder, id, subId, 0x00) \
-MyClassDecoderA(Name ## _Decoder)
-
-#define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \
-MyClass2b(Name ## _Encoder, id, subId, 0x01) \
-MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
-MyClass2b(Name ## _Decoder, id, subId, 0x00) \
-MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchTypes.h b/other-licenses/7zstub/src/7zip/Compress/Branch/BranchTypes.h
deleted file mode 100644
index 730087562..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchTypes.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* BranchTypes.h */
-
-#ifndef __BRANCHTYPES_H
-#define __BRANCHTYPES_H
-
-typedef unsigned char Byte;
-typedef unsigned short UInt16;
-
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef unsigned long UInt32;
-#else
-typedef unsigned int UInt32;
-#endif
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.c b/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.c
deleted file mode 100644
index 2d2c03d2d..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* BranchX86.c */
-
-#include "BranchX86.h"
-
-/*
-static int inline Test86MSByte(Byte b)
-{
- return (b == 0 || b == 0xFF);
-}
-*/
-#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
-
-const int kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
-const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
-
-/*
-void x86_Convert_Init(UInt32 *prevMask, UInt32 *prevPos)
-{
- *prevMask = 0;
- *prevPos = (UInt32)(-5);
-}
-*/
-
-UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos,
- UInt32 *prevMask, UInt32 *prevPos, int encoding)
-{
- UInt32 bufferPos = 0;
- UInt32 limit;
-
- if (endPos < 5)
- return 0;
-
- if (nowPos - *prevPos > 5)
- *prevPos = nowPos - 5;
-
- limit = endPos - 5;
- while(bufferPos <= limit)
- {
- Byte b = buffer[bufferPos];
- UInt32 offset;
- if (b != 0xE8 && b != 0xE9)
- {
- bufferPos++;
- continue;
- }
- offset = (nowPos + bufferPos - *prevPos);
- *prevPos = (nowPos + bufferPos);
- if (offset > 5)
- *prevMask = 0;
- else
- {
- UInt32 i;
- for (i = 0; i < offset; i++)
- {
- *prevMask &= 0x77;
- *prevMask <<= 1;
- }
- }
- b = buffer[bufferPos + 4];
- if (Test86MSByte(b) && kMaskToAllowedStatus[(*prevMask >> 1) & 0x7] &&
- (*prevMask >> 1) < 0x10)
- {
- UInt32 src =
- ((UInt32)(b) << 24) |
- ((UInt32)(buffer[bufferPos + 3]) << 16) |
- ((UInt32)(buffer[bufferPos + 2]) << 8) |
- (buffer[bufferPos + 1]);
-
- UInt32 dest;
- while(1)
- {
- UInt32 index;
- if (encoding)
- dest = (nowPos + bufferPos + 5) + src;
- else
- dest = src - (nowPos + bufferPos + 5);
- if (*prevMask == 0)
- break;
- index = kMaskToBitNumber[*prevMask >> 1];
- b = (Byte)(dest >> (24 - index * 8));
- if (!Test86MSByte(b))
- break;
- src = dest ^ ((1 << (32 - index * 8)) - 1);
- }
- buffer[bufferPos + 4] = (Byte)(~(((dest >> 24) & 1) - 1));
- buffer[bufferPos + 3] = (Byte)(dest >> 16);
- buffer[bufferPos + 2] = (Byte)(dest >> 8);
- buffer[bufferPos + 1] = (Byte)dest;
- bufferPos += 5;
- *prevMask = 0;
- }
- else
- {
- bufferPos++;
- *prevMask |= 1;
- if (Test86MSByte(b))
- *prevMask |= 0x10;
- }
- }
- return bufferPos;
-}
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.h b/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.h
deleted file mode 100644
index ff9c71cbe..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/BranchX86.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* BranchX86.h */
-
-#ifndef __BRANCHX86_H
-#define __BRANCHX86_H
-
-#include "BranchTypes.h"
-
-#define x86_Convert_Init(prevMask, prevPos) { prevMask = 0; prevPos = (UInt32)(-5); }
-
-UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos,
- UInt32 *prevMask, UInt32 *prevPos, int encoding);
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/x86.cpp b/other-licenses/7zstub/src/7zip/Compress/Branch/x86.cpp
deleted file mode 100644
index 929484ad6..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/x86.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// x86.cpp
-
-#include "StdAfx.h"
-#include "x86.h"
-
-#include "Windows/Defs.h"
-
-#include "BranchX86.c"
-
-UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 1);
-}
-
-UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
-{
- return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 0);
-}
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/x86.h b/other-licenses/7zstub/src/7zip/Compress/Branch/x86.h
deleted file mode 100644
index 85882d914..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/x86.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// x86.h
-
-#ifndef __X86_H
-#define __X86_H
-
-#include "BranchCoder.h"
-#include "BranchX86.h"
-
-struct CBranch86
-{
- UInt32 _prevMask;
- UInt32 _prevPos;
- void x86Init() { x86_Convert_Init(_prevMask, _prevPos); }
-};
-
-MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
- virtual void SubInit() { x86Init(); })
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.cpp b/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.cpp
deleted file mode 100644
index fc87bd937..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-// x86_2.cpp
-
-#include "StdAfx.h"
-#include "x86_2.h"
-
-#include "../../../Common/Alloc.h"
-
-static const int kBufferSize = 1 << 17;
-
-inline bool IsJcc(Byte b0, Byte b1)
-{
- return (b0 == 0x0F && (b1 & 0xF0) == 0x80);
-}
-
-#ifndef EXTRACT_ONLY
-
-static bool inline Test86MSByte(Byte b)
-{
- return (b == 0 || b == 0xFF);
-}
-
-bool CBCJ2_x86_Encoder::Create()
-{
- if (!_mainStream.Create(1 << 16))
- return false;
- if (!_callStream.Create(1 << 20))
- return false;
- if (!_jumpStream.Create(1 << 20))
- return false;
- if (!_rangeEncoder.Create(1 << 20))
- return false;
- if (_buffer == 0)
- {
- _buffer = (Byte *)MidAlloc(kBufferSize);
- if (_buffer == 0)
- return false;
- }
- return true;
-}
-
-CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder()
-{
- ::MidFree(_buffer);
-}
-
-HRESULT CBCJ2_x86_Encoder::Flush()
-{
- RINOK(_mainStream.Flush());
- RINOK(_callStream.Flush());
- RINOK(_jumpStream.Flush());
- _rangeEncoder.FlushData();
- return _rangeEncoder.FlushStream();
-}
-
-const UInt32 kDefaultLimit = (1 << 24);
-
-HRESULT CBCJ2_x86_Encoder::CodeReal(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress)
-{
- if (numInStreams != 1 || numOutStreams != 4)
- return E_INVALIDARG;
-
- if (!Create())
- return E_OUTOFMEMORY;
-
- bool sizeIsDefined = false;
- UInt64 inSize;
- if (inSizes != NULL)
- if (inSizes[0] != NULL)
- {
- inSize = *inSizes[0];
- if (inSize <= kDefaultLimit)
- sizeIsDefined = true;
- }
-
- 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; i++)
- _statusE8Encoder[i].Init();
- _statusE9Encoder.Init();
- _statusJccEncoder.Init();
- CCoderReleaser releaser(this);
-
- CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
- {
- inStream->QueryInterface(IID_ICompressGetSubStreamSize, (void **)&getSubStreamSize);
- }
-
- UInt32 nowPos = 0;
- UInt64 nowPos64 = 0;
- UInt32 bufferPos = 0;
-
- Byte prevByte = 0;
-
- UInt64 subStreamIndex = 0;
- UInt64 subStreamStartPos = 0;
- UInt64 subStreamEndPos = 0;
-
- while(true)
- {
- UInt32 processedSize = 0;
- while(true)
- {
- UInt32 size = kBufferSize - (bufferPos + processedSize);
- UInt32 processedSizeLoc;
- if (size == 0)
- break;
- RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
- if (processedSizeLoc == 0)
- break;
- processedSize += processedSizeLoc;
- }
- UInt32 endPos = bufferPos + processedSize;
-
- if (endPos < 5)
- {
- // change it
- for (bufferPos = 0; bufferPos < endPos; bufferPos++)
- {
- Byte b = _buffer[bufferPos];
- _mainStream.WriteByte(b);
- if (b == 0xE8)
- _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 0);
- else if (b == 0xE9)
- _statusE9Encoder.Encode(&_rangeEncoder, 0);
- else if (IsJcc(prevByte, b))
- _statusJccEncoder.Encode(&_rangeEncoder, 0);
- prevByte = b;
- }
- return Flush();
- }
-
- bufferPos = 0;
-
- UInt32 limit = endPos - 5;
- while(bufferPos <= limit)
- {
- Byte b = _buffer[bufferPos];
- _mainStream.WriteByte(b);
- if (b != 0xE8 && b != 0xE9 && !IsJcc(prevByte, b))
- {
- bufferPos++;
- prevByte = b;
- continue;
- }
- Byte nextByte = _buffer[bufferPos + 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;
- // if (Test86MSByte(nextByte))
- bool convert;
- if (getSubStreamSize != NULL)
- {
- UInt64 currentPos = (nowPos64 + bufferPos);
- while (subStreamEndPos < currentPos)
- {
- UInt64 subStreamSize;
- HRESULT result = getSubStreamSize->GetSubStreamSize(subStreamIndex, &subStreamSize);
- if (result == S_OK)
- {
- subStreamStartPos = subStreamEndPos;
- subStreamEndPos += subStreamSize;
- subStreamIndex++;
- }
- else if (result == S_FALSE || result == E_NOTIMPL)
- {
- getSubStreamSize.Release();
- subStreamStartPos = 0;
- subStreamEndPos = subStreamStartPos - 1;
- }
- else
- return result;
- }
- if (getSubStreamSize == NULL)
- {
- if (sizeIsDefined)
- convert = (dest < inSize);
- else
- convert = Test86MSByte(nextByte);
- }
- else if (subStreamEndPos - subStreamStartPos > kDefaultLimit)
- convert = Test86MSByte(nextByte);
- else
- {
- UInt64 dest64 = (currentPos + 5) + Int64(Int32(src));
- convert = (dest64 >= subStreamStartPos && dest64 < subStreamEndPos);
- }
- }
- else if (sizeIsDefined)
- convert = (dest < inSize);
- else
- convert = Test86MSByte(nextByte);
- if (convert)
- {
- if (b == 0xE8)
- _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 1);
- else if (b == 0xE9)
- _statusE9Encoder.Encode(&_rangeEncoder, 1);
- else
- _statusJccEncoder.Encode(&_rangeEncoder, 1);
-
- bufferPos += 5;
- if (b == 0xE8)
- {
- _callStream.WriteByte((Byte)(dest >> 24));
- _callStream.WriteByte((Byte)(dest >> 16));
- _callStream.WriteByte((Byte)(dest >> 8));
- _callStream.WriteByte((Byte)(dest));
- }
- else
- {
- _jumpStream.WriteByte((Byte)(dest >> 24));
- _jumpStream.WriteByte((Byte)(dest >> 16));
- _jumpStream.WriteByte((Byte)(dest >> 8));
- _jumpStream.WriteByte((Byte)(dest));
- }
- prevByte = nextByte;
- }
- else
- {
- if (b == 0xE8)
- _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 0);
- else if (b == 0xE9)
- _statusE9Encoder.Encode(&_rangeEncoder, 0);
- else
- _statusJccEncoder.Encode(&_rangeEncoder, 0);
- bufferPos++;
- prevByte = b;
- }
- }
- nowPos += bufferPos;
- nowPos64 += bufferPos;
-
- if (progress != NULL)
- {
- RINOK(progress->SetRatioInfo(&nowPos64, NULL));
- }
-
- UInt32 i = 0;
- while(bufferPos < endPos)
- _buffer[i++] = _buffer[bufferPos++];
- bufferPos = i;
- }
-}
-
-STDMETHODIMP CBCJ2_x86_Encoder::Code(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress)
-{
- try
- {
- return CodeReal(inStreams, inSizes, numInStreams,
- outStreams, outSizes,numOutStreams, progress);
- }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
-
-#endif
-
-HRESULT CBCJ2_x86_Decoder::CodeReal(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress)
-{
- if (numInStreams != 4 || numOutStreams != 1)
- return E_INVALIDARG;
-
- if (!_mainInStream.Create(1 << 16))
- return E_OUTOFMEMORY;
- if (!_callStream.Create(1 << 20))
- return E_OUTOFMEMORY;
- if (!_jumpStream.Create(1 << 16))
- return E_OUTOFMEMORY;
- if (!_rangeDecoder.Create(1 << 20))
- return E_OUTOFMEMORY;
- if (!_outStream.Create(1 << 16))
- return E_OUTOFMEMORY;
-
- _mainInStream.SetStream(inStreams[0]);
- _callStream.SetStream(inStreams[1]);
- _jumpStream.SetStream(inStreams[2]);
- _rangeDecoder.SetStream(inStreams[3]);
- _outStream.SetStream(outStreams[0]);
-
- _mainInStream.Init();
- _callStream.Init();
- _jumpStream.Init();
- _rangeDecoder.Init();
- _outStream.Init();
-
- for (int i = 0; i < 256; i++)
- _statusE8Decoder[i].Init();
- _statusE9Decoder.Init();
- _statusJccDecoder.Init();
-
- CCoderReleaser releaser(this);
-
- Byte prevByte = 0;
- UInt32 processedBytes = 0;
- while(true)
- {
- if (processedBytes > (1 << 20) && progress != NULL)
- {
- UInt64 nowPos64 = _outStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(NULL, &nowPos64));
- processedBytes = 0;
- }
- processedBytes++;
- Byte b;
- if (!_mainInStream.ReadByte(b))
- return Flush();
- _outStream.WriteByte(b);
- if (b != 0xE8 && b != 0xE9 && !IsJcc(prevByte, b))
- {
- prevByte = b;
- continue;
- }
- bool status;
- if (b == 0xE8)
- status = (_statusE8Decoder[prevByte].Decode(&_rangeDecoder) == 1);
- else if (b == 0xE9)
- status = (_statusE9Decoder.Decode(&_rangeDecoder) == 1);
- else
- status = (_statusJccDecoder.Decode(&_rangeDecoder) == 1);
- if (status)
- {
- UInt32 src;
- if (b == 0xE8)
- {
- Byte b0;
- if(!_callStream.ReadByte(b0))
- return S_FALSE;
- src = ((UInt32)b0) << 24;
- if(!_callStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0) << 16;
- if(!_callStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0) << 8;
- if(!_callStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0);
- }
- else
- {
- Byte b0;
- if(!_jumpStream.ReadByte(b0))
- return S_FALSE;
- src = ((UInt32)b0) << 24;
- if(!_jumpStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0) << 16;
- if(!_jumpStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0) << 8;
- if(!_jumpStream.ReadByte(b0))
- return S_FALSE;
- src |= ((UInt32)b0);
- }
- UInt32 dest = src - (UInt32(_outStream.GetProcessedSize()) + 4) ;
- _outStream.WriteByte((Byte)(dest));
- _outStream.WriteByte((Byte)(dest >> 8));
- _outStream.WriteByte((Byte)(dest >> 16));
- _outStream.WriteByte((Byte)(dest >> 24));
- prevByte = (dest >> 24);
- processedBytes += 4;
- }
- else
- prevByte = b;
- }
-}
-
-STDMETHODIMP CBCJ2_x86_Decoder::Code(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress)
-{
- try
- {
- return CodeReal(inStreams, inSizes, numInStreams,
- outStreams, outSizes,numOutStreams, progress);
- }
- catch(const COutBufferException &e) { return e.ErrorCode; }
- catch(...) { return S_FALSE; }
-}
diff --git a/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.h b/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.h
deleted file mode 100644
index 9e7780c80..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Branch/x86_2.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// x86_2.h
-
-#ifndef __BRANCH_X86_2_H
-#define __BRANCH_X86_2_H
-
-#include "../../../Common/MyCom.h"
-#include "../RangeCoder/RangeCoderBit.h"
-#include "../../ICoder.h"
-
-// {23170F69-40C1-278B-0303-010100000100}
-#define MyClass2_a(Name, id, subId, encodingId) \
-DEFINE_GUID(CLSID_CCompressConvert ## Name, \
-0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00);
-
-#define MyClass_a(Name, id, subId) \
-MyClass2_a(Name ## _Encoder, id, subId, 0x01) \
-MyClass2_a(Name ## _Decoder, id, subId, 0x00)
-
-MyClass_a(BCJ2_x86, 0x01, 0x1B)
-
-const int kNumMoveBits = 5;
-
-#ifndef EXTRACT_ONLY
-
-class CBCJ2_x86_Encoder:
- public ICompressCoder2,
- public CMyUnknownImp
-{
- Byte *_buffer;
-public:
- CBCJ2_x86_Encoder(): _buffer(0) {};
- ~CBCJ2_x86_Encoder();
- bool Create();
-
- COutBuffer _mainStream;
- COutBuffer _callStream;
- COutBuffer _jumpStream;
- NCompress::NRangeCoder::CEncoder _rangeEncoder;
- NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusE8Encoder[256];
- NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusE9Encoder;
- NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusJccEncoder;
-
- HRESULT Flush();
- void ReleaseStreams()
- {
- _mainStream.ReleaseStream();
- _callStream.ReleaseStream();
- _jumpStream.ReleaseStream();
- _rangeEncoder.ReleaseStream();
- }
-
- class CCoderReleaser
- {
- CBCJ2_x86_Encoder *_coder;
- public:
- CCoderReleaser(CBCJ2_x86_Encoder *coder): _coder(coder) {}
- ~CCoderReleaser() { _coder->ReleaseStreams(); }
- };
-
-public:
-
- MY_UNKNOWN_IMP
-
- HRESULT CodeReal(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress);
-};
-
-#endif
-
-class CBCJ2_x86_Decoder:
- public ICompressCoder2,
- public CMyUnknownImp
-{
-public:
- CInBuffer _mainInStream;
- CInBuffer _callStream;
- CInBuffer _jumpStream;
- NCompress::NRangeCoder::CDecoder _rangeDecoder;
- NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusE8Decoder[256];
- NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusE9Decoder;
- NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusJccDecoder;
-
- COutBuffer _outStream;
-
- void ReleaseStreams()
- {
- _mainInStream.ReleaseStream();
- _callStream.ReleaseStream();
- _jumpStream.ReleaseStream();
- _rangeDecoder.ReleaseStream();
- _outStream.ReleaseStream();
- }
-
- HRESULT Flush() { return _outStream.Flush(); }
- class CCoderReleaser
- {
- CBCJ2_x86_Decoder *_coder;
- public:
- CCoderReleaser(CBCJ2_x86_Decoder *coder): _coder(coder) {}
- ~CCoderReleaser() { _coder->ReleaseStreams(); }
- };
-
-public:
- MY_UNKNOWN_IMP
- HRESULT CodeReal(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
- UInt32 numInStreams,
- ISequentialOutStream **outStreams,
- const UInt64 **outSizes,
- UInt32 numOutStreams,
- ICompressProgressInfo *progress);
-};
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.cpp b/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.cpp
deleted file mode 100644
index 9ced21158..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Compress/CopyCoder.cpp
-
-#include "StdAfx.h"
-
-#include "CopyCoder.h"
-#include "../../../Common/Alloc.h"
-#include "../../Common/StreamUtils.h"
-
-namespace NCompress {
-
-static const UInt32 kBufferSize = 1 << 17;
-
-CCopyCoder::~CCopyCoder()
-{
- ::MidFree(_buffer);
-}
-
-STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- if (_buffer == 0)
- {
- _buffer = (Byte *)::MidAlloc(kBufferSize);
- if (_buffer == 0)
- return E_OUTOFMEMORY;
- }
-
- TotalSize = 0;
- while(true)
- {
- UInt32 realProcessedSize;
- UInt32 size = kBufferSize;
- if (outSize != 0)
- if (size > *outSize - TotalSize)
- size = (UInt32)(*outSize - TotalSize);
- RINOK(inStream->Read(_buffer, size, &realProcessedSize));
- if(realProcessedSize == 0)
- break;
- RINOK(WriteStream(outStream, _buffer, realProcessedSize, NULL));
- TotalSize += realProcessedSize;
- if (progress != NULL)
- {
- RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
- }
- }
- return S_OK;
-}
-
-}
-
diff --git a/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.h b/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.h
deleted file mode 100644
index c82e469a4..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/Copy/CopyCoder.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Compress/CopyCoder.h
-
-#ifndef __COMPRESS_COPYCODER_H
-#define __COMPRESS_COPYCODER_H
-
-#include "../../ICoder.h"
-#include "../../../Common/MyCom.h"
-
-namespace NCompress {
-
-class CCopyCoder:
- public ICompressCoder,
- public CMyUnknownImp
-{
- Byte *_buffer;
-public:
- UInt64 TotalSize;
- CCopyCoder(): TotalSize(0) , _buffer(0) {};
- ~CCopyCoder();
-
- MY_UNKNOWN_IMP
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-};
-
-}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.cpp b/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.cpp
deleted file mode 100644
index 329a7db35..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// LZOutWindow.cpp
-
-#include "StdAfx.h"
-
-#include "../../../Common/Alloc.h"
-#include "LZOutWindow.h"
-
-void CLZOutWindow::Init(bool solid)
-{
- if(!solid)
- COutBuffer::Init();
- #ifdef _NO_EXCEPTIONS
- ErrorCode = S_OK;
- #endif
-}
-
-
diff --git a/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.h b/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.h
deleted file mode 100644
index b64cb927f..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// LZOutWindow.h
-
-#ifndef __LZ_OUT_WINDOW_H
-#define __LZ_OUT_WINDOW_H
-
-#include "../../IStream.h"
-#include "../../Common/OutBuffer.h"
-
-#ifndef _NO_EXCEPTIONS
-typedef COutBufferException CLZOutWindowException;
-#endif
-
-class CLZOutWindow: public COutBuffer
-{
-public:
- void Init(bool solid = false);
-
- // distance >= 0, len > 0,
- bool CopyBlock(UInt32 distance, UInt32 len)
- {
- UInt32 pos = _pos - distance - 1;
- if (distance >= _pos)
- {
- if (!_overDict || distance >= _bufferSize)
- return false;
- pos += _bufferSize;
- }
- do
- {
- if (pos == _bufferSize)
- pos = 0;
- _buffer[_pos++] = _buffer[pos++];
- if (_pos == _limitPos)
- FlushWithCheck();
- }
- while(--len != 0);
- return true;
- }
-
- void PutByte(Byte b)
- {
- _buffer[_pos++] = b;
- if (_pos == _limitPos)
- FlushWithCheck();
- }
-
- Byte GetByte(UInt32 distance) const
- {
- UInt32 pos = _pos - distance - 1;
- if (pos >= _bufferSize)
- pos += _bufferSize;
- return _buffer[pos];
- }
-};
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMA.h b/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMA.h
deleted file mode 100644
index d53296ee7..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMA.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// LZMA.h
-
-#ifndef __LZMA_H
-#define __LZMA_H
-
-namespace NCompress {
-namespace NLZMA {
-
-const UInt32 kNumRepDistances = 4;
-
-const int kNumStates = 12;
-
-const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
-const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
-const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
-const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
-
-class CState
-{
-public:
- Byte Index;
- void Init() { Index = 0; }
- void UpdateChar() { Index = kLiteralNextStates[Index]; }
- void UpdateMatch() { Index = kMatchNextStates[Index]; }
- void UpdateRep() { Index = kRepNextStates[Index]; }
- void UpdateShortRep() { Index = kShortRepNextStates[Index]; }
- bool IsCharState() const { return Index < 7; }
-};
-
-const int kNumPosSlotBits = 6;
-const int kDicLogSizeMin = 0;
-const int kDicLogSizeMax = 32;
-const int kDistTableSizeMax = kDicLogSizeMax * 2;
-
-const UInt32 kNumLenToPosStates = 4;
-
-inline UInt32 GetLenToPosState(UInt32 len)
-{
- len -= 2;
- if (len < kNumLenToPosStates)
- return len;
- return kNumLenToPosStates - 1;
-}
-
-namespace NLength {
-
-const int kNumPosStatesBitsMax = 4;
-const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
-
-const int kNumPosStatesBitsEncodingMax = 4;
-const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
-
-const int kNumLowBits = 3;
-const int kNumMidBits = 3;
-const int kNumHighBits = 8;
-const UInt32 kNumLowSymbols = 1 << kNumLowBits;
-const UInt32 kNumMidSymbols = 1 << kNumMidBits;
-const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits);
-
-}
-
-const UInt32 kMatchMinLen = 2;
-const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1;
-
-const int kNumAlignBits = 4;
-const UInt32 kAlignTableSize = 1 << kNumAlignBits;
-const UInt32 kAlignMask = (kAlignTableSize - 1);
-
-const UInt32 kStartPosModelIndex = 4;
-const UInt32 kEndPosModelIndex = 14;
-const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
-
-const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2);
-
-const int kNumLitPosStatesBitsEncodingMax = 4;
-const int kNumLitContextBitsMax = 8;
-
-const int kNumMoveBits = 5;
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.cpp b/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.cpp
deleted file mode 100644
index e5dfb2702..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-// LZMADecoder.cpp
-
-#include "StdAfx.h"
-
-#include "LZMADecoder.h"
-#include "../../../Common/Defs.h"
-
-namespace NCompress {
-namespace NLZMA {
-
-const int kLenIdFinished = -1;
-const int kLenIdNeedInit = -2;
-
-void CDecoder::Init()
-{
- {
- for(int i = 0; i < kNumStates; i++)
- {
- for (UInt32 j = 0; j <= _posStateMask; j++)
- {
- _isMatch[i][j].Init();
- _isRep0Long[i][j].Init();
- }
- _isRep[i].Init();
- _isRepG0[i].Init();
- _isRepG1[i].Init();
- _isRepG2[i].Init();
- }
- }
- {
- for (UInt32 i = 0; i < kNumLenToPosStates; i++)
- _posSlotDecoder[i].Init();
- }
- {
- for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
- _posDecoders[i].Init();
- }
- _posAlignDecoder.Init();
- _lenDecoder.Init(_posStateMask + 1);
- _repMatchLenDecoder.Init(_posStateMask + 1);
- _literalDecoder.Init();
-
- _state.Init();
- _reps[0] = _reps[1] = _reps[2] = _reps[3] = 0;
-}
-
-HRESULT CDecoder::CodeSpec(UInt32 curSize)
-{
- if (_outSizeDefined)
- {
- const UInt64 rem = _outSize - _outWindowStream.GetProcessedSize();
- if (curSize > rem)
- curSize = (UInt32)rem;
- }
-
- if (_remainLen == kLenIdFinished)
- return S_OK;
- if (_remainLen == kLenIdNeedInit)
- {
- _rangeDecoder.Init();
- Init();
- _remainLen = 0;
- }
- if (curSize == 0)
- return S_OK;
-
- UInt32 rep0 = _reps[0];
- UInt32 rep1 = _reps[1];
- UInt32 rep2 = _reps[2];
- UInt32 rep3 = _reps[3];
- CState state = _state;
- Byte previousByte;
-
- while(_remainLen > 0 && curSize > 0)
- {
- previousByte = _outWindowStream.GetByte(rep0);
- _outWindowStream.PutByte(previousByte);
- _remainLen--;
- curSize--;
- }
- UInt64 nowPos64 = _outWindowStream.GetProcessedSize();
- if (nowPos64 == 0)
- previousByte = 0;
- else
- previousByte = _outWindowStream.GetByte(0);
-
- while(curSize > 0)
- {
- {
- #ifdef _NO_EXCEPTIONS
- if (_rangeDecoder.Stream.ErrorCode != S_OK)
- return _rangeDecoder.Stream.ErrorCode;
- #endif
- if (_rangeDecoder.Stream.WasFinished())
- return S_FALSE;
- UInt32 posState = UInt32(nowPos64) & _posStateMask;
- if (_isMatch[state.Index][posState].Decode(&_rangeDecoder) == 0)
- {
- if(!state.IsCharState())
- previousByte = _literalDecoder.DecodeWithMatchByte(&_rangeDecoder,
- (UInt32)nowPos64, previousByte, _outWindowStream.GetByte(rep0));
- else
- previousByte = _literalDecoder.DecodeNormal(&_rangeDecoder,
- (UInt32)nowPos64, previousByte);
- _outWindowStream.PutByte(previousByte);
- state.UpdateChar();
- curSize--;
- nowPos64++;
- }
- else
- {
- UInt32 len;
- if(_isRep[state.Index].Decode(&_rangeDecoder) == 1)
- {
- len = 0;
- if(_isRepG0[state.Index].Decode(&_rangeDecoder) == 0)
- {
- if(_isRep0Long[state.Index][posState].Decode(&_rangeDecoder) == 0)
- {
- state.UpdateShortRep();
- len = 1;
- }
- }
- else
- {
- UInt32 distance;
- if(_isRepG1[state.Index].Decode(&_rangeDecoder) == 0)
- distance = rep1;
- else
- {
- if (_isRepG2[state.Index].Decode(&_rangeDecoder) == 0)
- distance = rep2;
- else
- {
- distance = rep3;
- rep3 = rep2;
- }
- rep2 = rep1;
- }
- rep1 = rep0;
- rep0 = distance;
- }
- if (len == 0)
- {
- len = _repMatchLenDecoder.Decode(&_rangeDecoder, posState) + kMatchMinLen;
- state.UpdateRep();
- }
- }
- else
- {
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
- len = kMatchMinLen + _lenDecoder.Decode(&_rangeDecoder, posState);
- state.UpdateMatch();
- UInt32 posSlot = _posSlotDecoder[GetLenToPosState(len)].Decode(&_rangeDecoder);
- if (posSlot >= kStartPosModelIndex)
- {
- UInt32 numDirectBits = (posSlot >> 1) - 1;
- rep0 = ((2 | (posSlot & 1)) << numDirectBits);
-
- if (posSlot < kEndPosModelIndex)
- rep0 += NRangeCoder::ReverseBitTreeDecode(_posDecoders +
- rep0 - posSlot - 1, &_rangeDecoder, numDirectBits);
- else
- {
- rep0 += (_rangeDecoder.DecodeDirectBits(
- numDirectBits - kNumAlignBits) << kNumAlignBits);
- rep0 += _posAlignDecoder.ReverseDecode(&_rangeDecoder);
- if (rep0 == 0xFFFFFFFF)
- {
- _remainLen = kLenIdFinished;
- return S_OK;
- }
- }
- }
- else
- rep0 = posSlot;
- }
- UInt32 locLen = len;
- if (len > curSize)
- locLen = (UInt32)curSize;
- if (!_outWindowStream.CopyBlock(rep0, locLen))
- return S_FALSE;
- previousByte = _outWindowStream.GetByte(0);
- curSize -= locLen;
- nowPos64 += locLen;
- len -= locLen;
- if (len != 0)
- {
- _remainLen = (Int32)len;
- break;
- }
-
- #ifdef _NO_EXCEPTIONS
- if (_outWindowStream.ErrorCode != S_OK)
- return _outWindowStream.ErrorCode;
- #endif
- }
- }
- }
- if (_rangeDecoder.Stream.WasFinished())
- return S_FALSE;
- _reps[0] = rep0;
- _reps[1] = rep1;
- _reps[2] = rep2;
- _reps[3] = rep3;
- _state = state;
-
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- SetInStream(inStream);
- _outWindowStream.SetStream(outStream);
- SetOutStreamSize(outSize);
- CDecoderFlusher flusher(this);
-
- while (true)
- {
- UInt32 curSize = 1 << 18;
- RINOK(CodeSpec(curSize));
- if (_remainLen == kLenIdFinished)
- break;
- if (progress != NULL)
- {
- UInt64 inSize = _rangeDecoder.GetProcessedSize();
- UInt64 nowPos64 = _outWindowStream.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
- }
- if (_outSizeDefined)
- if (_outWindowStream.GetProcessedSize() >= _outSize)
- break;
- }
- flusher.NeedFlush = false;
- return Flush();
-}
-
-
-#ifdef _NO_EXCEPTIONS
-
-#define LZMA_TRY_BEGIN
-#define LZMA_TRY_END
-
-#else
-
-#define LZMA_TRY_BEGIN try {
-#define LZMA_TRY_END } \
- catch(const CInBufferException &e) { return e.ErrorCode; } \
- catch(const CLZOutWindowException &e) { return e.ErrorCode; } \
- catch(...) { return S_FALSE; }
-
-#endif
-
-
-STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress)
-{
- LZMA_TRY_BEGIN
- return CodeReal(inStream, outStream, inSize, outSize, progress);
- LZMA_TRY_END
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
-{
- if (size < 5)
- return E_INVALIDARG;
- int lc = properties[0] % 9;
- Byte remainder = (Byte)(properties[0] / 9);
- int lp = remainder % 5;
- int pb = remainder / 5;
- if (pb > NLength::kNumPosStatesBitsMax)
- return E_INVALIDARG;
- _posStateMask = (1 << pb) - 1;
- UInt32 dictionarySize = 0;
- for (int i = 0; i < 4; i++)
- dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8);
- if (!_outWindowStream.Create(dictionarySize))
- return E_OUTOFMEMORY;
- if (!_literalDecoder.Create(lp, lc))
- return E_OUTOFMEMORY;
- if (!_rangeDecoder.Create(1 << 20))
- return E_OUTOFMEMORY;
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
-{
- *value = _rangeDecoder.GetProcessedSize();
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
-{
- _rangeDecoder.SetStream(inStream);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::ReleaseInStream()
-{
- _rangeDecoder.ReleaseStream();
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
-{
- if (_outSizeDefined = (outSize != NULL))
- _outSize = *outSize;
- _remainLen = kLenIdNeedInit;
- _outWindowStream.Init();
- return S_OK;
-}
-
-#ifdef _ST_MODE
-
-STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- LZMA_TRY_BEGIN
- if (processedSize)
- *processedSize = 0;
- const UInt64 startPos = _outWindowStream.GetProcessedSize();
- _outWindowStream.SetMemStream((Byte *)data);
- RINOK(CodeSpec(size));
- if (processedSize)
- *processedSize = (UInt32)(_outWindowStream.GetProcessedSize() - startPos);
- return Flush();
- LZMA_TRY_END
-}
-
-#endif
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.h b/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.h
deleted file mode 100644
index d6370e250..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/LZMA/LZMADecoder.h
+++ /dev/null
@@ -1,251 +0,0 @@
-// LZMA/Decoder.h
-
-#ifndef __LZMA_DECODER_H
-#define __LZMA_DECODER_H
-
-#include "../../../Common/MyCom.h"
-#include "../../../Common/Alloc.h"
-#include "../../ICoder.h"
-#include "../LZ/LZOutWindow.h"
-#include "../RangeCoder/RangeCoderBitTree.h"
-
-#include "LZMA.h"
-
-namespace NCompress {
-namespace NLZMA {
-
-typedef NRangeCoder::CBitDecoder<kNumMoveBits> CMyBitDecoder;
-
-class CLiteralDecoder2
-{
- CMyBitDecoder _decoders[0x300];
-public:
- void Init()
- {
- for (int i = 0; i < 0x300; i++)
- _decoders[i].Init();
- }
- Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder)
- {
- UInt32 symbol = 1;
- RC_INIT_VAR
- do
- {
- // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder);
- RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol)
- }
- while (symbol < 0x100);
- RC_FLUSH_VAR
- return (Byte)symbol;
- }
- Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, Byte matchByte)
- {
- UInt32 symbol = 1;
- RC_INIT_VAR
- do
- {
- UInt32 matchBit = (matchByte >> 7) & 1;
- matchByte <<= 1;
- // UInt32 bit = _decoders[1 + matchBit][symbol].Decode(rangeDecoder);
- // symbol = (symbol << 1) | bit;
- UInt32 bit;
- RC_GETBIT2(kNumMoveBits, _decoders[0x100 + (matchBit << 8) + symbol].Prob, symbol,
- bit = 0, bit = 1)
- if (matchBit != bit)
- {
- while (symbol < 0x100)
- {
- // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder);
- RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol)
- }
- break;
- }
- }
- while (symbol < 0x100);
- RC_FLUSH_VAR
- return (Byte)symbol;
- }
-};
-
-class CLiteralDecoder
-{
- CLiteralDecoder2 *_coders;
- int _numPrevBits;
- int _numPosBits;
- UInt32 _posMask;
-public:
- CLiteralDecoder(): _coders(0) {}
- ~CLiteralDecoder() { Free(); }
- void Free()
- {
- MyFree(_coders);
- _coders = 0;
- }
- bool Create(int numPosBits, int numPrevBits)
- {
- if (_coders == 0 || (numPosBits + numPrevBits) !=
- (_numPrevBits + _numPosBits) )
- {
- Free();
- UInt32 numStates = 1 << (numPosBits + numPrevBits);
- _coders = (CLiteralDecoder2 *)MyAlloc(numStates * sizeof(CLiteralDecoder2));
- }
- _numPosBits = numPosBits;
- _posMask = (1 << numPosBits) - 1;
- _numPrevBits = numPrevBits;
- return (_coders != 0);
- }
- void Init()
- {
- UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
- for (UInt32 i = 0; i < numStates; i++)
- _coders[i].Init();
- }
- UInt32 GetState(UInt32 pos, Byte prevByte) const
- { return ((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits)); }
- Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte)
- { return _coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder); }
- Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte, Byte matchByte)
- { return _coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); }
-};
-
-namespace NLength {
-
-class CDecoder
-{
- CMyBitDecoder _choice;
- CMyBitDecoder _choice2;
- NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesMax];
- NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesMax];
- NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumHighBits> _highCoder;
-public:
- void Init(UInt32 numPosStates)
- {
- _choice.Init();
- _choice2.Init();
- for (UInt32 posState = 0; posState < numPosStates; posState++)
- {
- _lowCoder[posState].Init();
- _midCoder[posState].Init();
- }
- _highCoder.Init();
- }
- UInt32 Decode(NRangeCoder::CDecoder *rangeDecoder, UInt32 posState)
- {
- if(_choice.Decode(rangeDecoder) == 0)
- return _lowCoder[posState].Decode(rangeDecoder);
- if(_choice2.Decode(rangeDecoder) == 0)
- return kNumLowSymbols + _midCoder[posState].Decode(rangeDecoder);
- return kNumLowSymbols + kNumMidSymbols + _highCoder.Decode(rangeDecoder);
- }
-};
-
-}
-
-class CDecoder:
- public ICompressCoder,
- public ICompressSetDecoderProperties2,
- public ICompressGetInStreamProcessedSize,
- #ifdef _ST_MODE
- public ICompressSetInStream,
- public ICompressSetOutStreamSize,
- public ISequentialInStream,
- #endif
- public CMyUnknownImp
-{
- CLZOutWindow _outWindowStream;
- NRangeCoder::CDecoder _rangeDecoder;
-
- CMyBitDecoder _isMatch[kNumStates][NLength::kNumPosStatesMax];
- CMyBitDecoder _isRep[kNumStates];
- CMyBitDecoder _isRepG0[kNumStates];
- CMyBitDecoder _isRepG1[kNumStates];
- CMyBitDecoder _isRepG2[kNumStates];
- CMyBitDecoder _isRep0Long[kNumStates][NLength::kNumPosStatesMax];
-
- NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumPosSlotBits> _posSlotDecoder[kNumLenToPosStates];
-
- CMyBitDecoder _posDecoders[kNumFullDistances - kEndPosModelIndex];
- NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumAlignBits> _posAlignDecoder;
-
- NLength::CDecoder _lenDecoder;
- NLength::CDecoder _repMatchLenDecoder;
-
- CLiteralDecoder _literalDecoder;
-
- UInt32 _posStateMask;
-
- ///////////////////
- // State
- UInt32 _reps[4];
- CState _state;
- Int32 _remainLen; // -1 means end of stream. // -2 means need Init
- UInt64 _outSize;
- bool _outSizeDefined;
-
- void Init();
- HRESULT CodeSpec(UInt32 size);
-public:
-
- #ifdef _ST_MODE
- MY_UNKNOWN_IMP5(
- ICompressSetDecoderProperties2,
- ICompressGetInStreamProcessedSize,
- ICompressSetInStream,
- ICompressSetOutStreamSize,
- ISequentialInStream)
- #else
- MY_UNKNOWN_IMP2(
- ICompressSetDecoderProperties2,
- ICompressGetInStreamProcessedSize)
- #endif
-
- void ReleaseStreams()
- {
- _outWindowStream.ReleaseStream();
- ReleaseInStream();
- }
-
- class CDecoderFlusher
- {
- CDecoder *_decoder;
- public:
- bool NeedFlush;
- CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
- ~CDecoderFlusher()
- {
- if (NeedFlush)
- _decoder->Flush();
- _decoder->ReleaseStreams();
- }
- };
-
- HRESULT Flush() { return _outWindowStream.Flush(); }
-
- STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
-
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-
- STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
-
- STDMETHOD(SetInStream)(ISequentialInStream *inStream);
- STDMETHOD(ReleaseInStream)();
- STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
-
- #ifdef _ST_MODE
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- #endif
-
- CDecoder(): _outSizeDefined(false) {}
- virtual ~CDecoder() {}
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoder.h b/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoder.h
deleted file mode 100644
index 9828bc4b9..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoder.h
+++ /dev/null
@@ -1,205 +0,0 @@
-// Compress/RangeCoder/RangeCoder.h
-
-#ifndef __COMPRESS_RANGECODER_H
-#define __COMPRESS_RANGECODER_H
-
-#include "../../Common/InBuffer.h"
-#include "../../Common/OutBuffer.h"
-
-namespace NCompress {
-namespace NRangeCoder {
-
-const int kNumTopBits = 24;
-const UInt32 kTopValue = (1 << kNumTopBits);
-
-class CEncoder
-{
- UInt32 _cacheSize;
- Byte _cache;
-public:
- UInt64 Low;
- UInt32 Range;
- COutBuffer Stream;
- bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
-
- void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
- void Init()
- {
- Stream.Init();
- Low = 0;
- Range = 0xFFFFFFFF;
- _cacheSize = 1;
- _cache = 0;
- }
-
- void FlushData()
- {
- // Low += 1;
- 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);
- Range *= size;
- while (Range < kTopValue)
- {
- Range <<= 8;
- ShiftLow();
- }
- }
-
- void ShiftLow()
- {
- if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
- {
- Byte temp = _cache;
- do
- {
- Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
- temp = 0xFF;
- }
- while(--_cacheSize != 0);
- _cache = (Byte)((UInt32)Low >> 24);
- }
- _cacheSize++;
- Low = (UInt32)Low << 8;
- }
-
- void EncodeDirectBits(UInt32 value, int numTotalBits)
- {
- for (int i = numTotalBits - 1; i >= 0; i--)
- {
- Range >>= 1;
- if (((value >> i) & 1) == 1)
- Low += Range;
- if (Range < kTopValue)
- {
- Range <<= 8;
- ShiftLow();
- }
- }
- }
-
- void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)
- {
- UInt32 newBound = (Range >> numTotalBits) * size0;
- if (symbol == 0)
- Range = newBound;
- else
- {
- Low += newBound;
- Range -= newBound;
- }
- while (Range < kTopValue)
- {
- Range <<= 8;
- ShiftLow();
- }
- }
-
- UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
-};
-
-class CDecoder
-{
-public:
- CInBuffer Stream;
- UInt32 Range;
- UInt32 Code;
- bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
-
- void Normalize()
- {
- while (Range < kTopValue)
- {
- Code = (Code << 8) | Stream.ReadByte();
- Range <<= 8;
- }
- }
-
- void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
- void Init()
- {
- Stream.Init();
- Code = 0;
- Range = 0xFFFFFFFF;
- for(int i = 0; i < 5; i++)
- Code = (Code << 8) | Stream.ReadByte();
- }
-
- void ReleaseStream() { Stream.ReleaseStream(); }
-
- UInt32 GetThreshold(UInt32 total)
- {
- return (Code) / ( Range /= total);
- }
-
- void Decode(UInt32 start, UInt32 size)
- {
- Code -= start * Range;
- Range *= size;
- Normalize();
- }
-
- UInt32 DecodeDirectBits(int numTotalBits)
- {
- UInt32 range = Range;
- UInt32 code = Code;
- UInt32 result = 0;
- for (int i = numTotalBits; i != 0; i--)
- {
- range >>= 1;
- /*
- result <<= 1;
- if (code >= range)
- {
- code -= range;
- result |= 1;
- }
- */
- UInt32 t = (code - range) >> 31;
- code -= range & (t - 1);
- result = (result << 1) | (1 - t);
-
- if (range < kTopValue)
- {
- code = (code << 8) | Stream.ReadByte();
- range <<= 8;
- }
- }
- Range = range;
- Code = code;
- return result;
- }
-
- UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
- {
- UInt32 newBound = (Range >> numTotalBits) * size0;
- UInt32 symbol;
- if (Code < newBound)
- {
- symbol = 0;
- Range = newBound;
- }
- else
- {
- symbol = 1;
- Code -= newBound;
- Range -= newBound;
- }
- Normalize();
- return symbol;
- }
-
- UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.cpp b/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.cpp
deleted file mode 100644
index 8d273c8f9..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// Compress/RangeCoder/RangeCoderBit.cpp
-
-#include "StdAfx.h"
-
-#include "RangeCoderBit.h"
-
-namespace NCompress {
-namespace NRangeCoder {
-
-UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
-static CPriceTables g_PriceTables;
-
-CPriceTables::CPriceTables() { Init(); }
-
-void CPriceTables::Init()
-{
- const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits);
- for(int i = kNumBits - 1; i >= 0; i--)
- {
- UInt32 start = 1 << (kNumBits - i - 1);
- UInt32 end = 1 << (kNumBits - i);
- for (UInt32 j = start; j < end; j++)
- ProbPrices[j] = (i << kNumBitPriceShiftBits) +
- (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1));
- }
-
- /*
- // simplest: bad solution
- for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
- ProbPrices[i] = kBitPrice;
- */
-
- /*
- const double kDummyMultMid = (1.0 / kBitPrice) / 2;
- const double kDummyMultMid = 0;
- // float solution
- double ln2 = log(double(2));
- double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits));
- 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++)
- {
- const int kCyclesBits = 5;
- const UInt32 kCycles = (1 << kCyclesBits);
-
- UInt32 range = UInt32(-1);
- UInt32 bitCount = 0;
- for (UInt32 j = 0; j < kCycles; j++)
- {
- range >>= (kNumBitModelTotalBits - kNumMoveReducingBits);
- range *= i;
- while(range < (1 << 31))
- {
- range <<= 1;
- bitCount++;
- }
- }
- bitCount <<= kNumBitPriceShiftBits;
- range -= (1 << 31);
- for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--)
- {
- range <<= 1;
- if (range > (1 << 31))
- {
- bitCount += (1 << k);
- range -= (1 << 31);
- }
- }
- ProbPrices[i] = (bitCount
- // + (1 << (kCyclesBits - 1))
- ) >> kCyclesBits;
- }
- */
-}
-
-}}
diff --git a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.h b/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.h
deleted file mode 100644
index 64538e687..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// Compress/RangeCoder/RangeCoderBit.h
-
-#ifndef __COMPRESS_RANGECODER_BIT_H
-#define __COMPRESS_RANGECODER_BIT_H
-
-#include "RangeCoder.h"
-
-namespace NCompress {
-namespace NRangeCoder {
-
-const int kNumBitModelTotalBits = 11;
-const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
-
-const int kNumMoveReducingBits = 2;
-
-const int kNumBitPriceShiftBits = 6;
-const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
-
-class CPriceTables
-{
-public:
- static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
- static void Init();
- CPriceTables();
-};
-
-template <int numMoveBits>
-class CBitModel
-{
-public:
- UInt32 Prob;
- void UpdateModel(UInt32 symbol)
- {
- /*
- Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
- Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
- */
- if (symbol == 0)
- Prob += (kBitModelTotal - Prob) >> numMoveBits;
- else
- Prob -= (Prob) >> numMoveBits;
- }
-public:
- void Init() { Prob = kBitModelTotal / 2; }
-};
-
-template <int numMoveBits>
-class CBitEncoder: public CBitModel<numMoveBits>
-{
-public:
- void Encode(CEncoder *encoder, UInt32 symbol)
- {
- /*
- encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
- this->UpdateModel(symbol);
- */
- UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
- if (symbol == 0)
- {
- encoder->Range = newBound;
- this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
- }
- else
- {
- encoder->Low += newBound;
- encoder->Range -= newBound;
- this->Prob -= (this->Prob) >> numMoveBits;
- }
- if (encoder->Range < kTopValue)
- {
- encoder->Range <<= 8;
- encoder->ShiftLow();
- }
- }
- UInt32 GetPrice(UInt32 symbol) const
- {
- return CPriceTables::ProbPrices[
- (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
- }
- UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }
- UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }
-};
-
-
-template <int numMoveBits>
-class CBitDecoder: public CBitModel<numMoveBits>
-{
-public:
- UInt32 Decode(CDecoder *decoder)
- {
- UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
- if (decoder->Code < newBound)
- {
- decoder->Range = newBound;
- this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
- if (decoder->Range < kTopValue)
- {
- decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
- decoder->Range <<= 8;
- }
- return 0;
- }
- else
- {
- decoder->Range -= newBound;
- decoder->Code -= newBound;
- this->Prob -= (this->Prob) >> numMoveBits;
- if (decoder->Range < kTopValue)
- {
- decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
- decoder->Range <<= 8;
- }
- return 1;
- }
- }
-};
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBitTree.h b/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBitTree.h
deleted file mode 100644
index 1fa023f3b..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBitTree.h
+++ /dev/null
@@ -1,161 +0,0 @@
-// Compress/RangeCoder/RangeCoderBitTree.h
-
-#ifndef __COMPRESS_RANGECODER_BIT_TREE_H
-#define __COMPRESS_RANGECODER_BIT_TREE_H
-
-#include "RangeCoderBit.h"
-#include "RangeCoderOpt.h"
-
-namespace NCompress {
-namespace NRangeCoder {
-
-template <int numMoveBits, int NumBitLevels>
-class CBitTreeEncoder
-{
- CBitEncoder<numMoveBits> Models[1 << NumBitLevels];
-public:
- void Init()
- {
- for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
- Models[i].Init();
- }
- void Encode(CEncoder *rangeEncoder, UInt32 symbol)
- {
- UInt32 modelIndex = 1;
- for (int bitIndex = NumBitLevels; bitIndex != 0 ;)
- {
- bitIndex--;
- UInt32 bit = (symbol >> bitIndex) & 1;
- Models[modelIndex].Encode(rangeEncoder, bit);
- modelIndex = (modelIndex << 1) | bit;
- }
- };
- void ReverseEncode(CEncoder *rangeEncoder, UInt32 symbol)
- {
- UInt32 modelIndex = 1;
- for (int i = 0; i < NumBitLevels; i++)
- {
- UInt32 bit = symbol & 1;
- Models[modelIndex].Encode(rangeEncoder, bit);
- modelIndex = (modelIndex << 1) | bit;
- symbol >>= 1;
- }
- }
- UInt32 GetPrice(UInt32 symbol) const
- {
- symbol |= (1 << NumBitLevels);
- UInt32 price = 0;
- while (symbol != 1)
- {
- price += Models[symbol >> 1].GetPrice(symbol & 1);
- symbol >>= 1;
- }
- return price;
- }
- UInt32 ReverseGetPrice(UInt32 symbol) const
- {
- UInt32 price = 0;
- UInt32 modelIndex = 1;
- for (int i = NumBitLevels; i != 0; i--)
- {
- UInt32 bit = symbol & 1;
- symbol >>= 1;
- price += Models[modelIndex].GetPrice(bit);
- modelIndex = (modelIndex << 1) | bit;
- }
- return price;
- }
-};
-
-template <int numMoveBits, int NumBitLevels>
-class CBitTreeDecoder
-{
- CBitDecoder<numMoveBits> Models[1 << NumBitLevels];
-public:
- void Init()
- {
- for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
- Models[i].Init();
- }
- UInt32 Decode(CDecoder *rangeDecoder)
- {
- UInt32 modelIndex = 1;
- RC_INIT_VAR
- for(int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)
- {
- // modelIndex = (modelIndex << 1) + Models[modelIndex].Decode(rangeDecoder);
- RC_GETBIT(numMoveBits, Models[modelIndex].Prob, modelIndex)
- }
- RC_FLUSH_VAR
- return modelIndex - (1 << NumBitLevels);
- };
- UInt32 ReverseDecode(CDecoder *rangeDecoder)
- {
- UInt32 modelIndex = 1;
- UInt32 symbol = 0;
- RC_INIT_VAR
- for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
- {
- // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
- // modelIndex <<= 1;
- // modelIndex += bit;
- // symbol |= (bit << bitIndex);
- RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
- }
- RC_FLUSH_VAR
- return symbol;
- }
-};
-
-template <int numMoveBits>
-void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models,
- CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol)
-{
- UInt32 modelIndex = 1;
- for (int i = 0; i < NumBitLevels; i++)
- {
- UInt32 bit = symbol & 1;
- Models[modelIndex].Encode(rangeEncoder, bit);
- modelIndex = (modelIndex << 1) | bit;
- symbol >>= 1;
- }
-}
-
-template <int numMoveBits>
-UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models,
- UInt32 NumBitLevels, UInt32 symbol)
-{
- UInt32 price = 0;
- UInt32 modelIndex = 1;
- for (int i = NumBitLevels; i != 0; i--)
- {
- UInt32 bit = symbol & 1;
- symbol >>= 1;
- price += Models[modelIndex].GetPrice(bit);
- modelIndex = (modelIndex << 1) | bit;
- }
- return price;
-}
-
-template <int numMoveBits>
-UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models,
- CDecoder *rangeDecoder, int NumBitLevels)
-{
- UInt32 modelIndex = 1;
- UInt32 symbol = 0;
- RC_INIT_VAR
- for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
- {
- // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
- // modelIndex <<= 1;
- // modelIndex += bit;
- // symbol |= (bit << bitIndex);
- RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
- }
- RC_FLUSH_VAR
- return symbol;
-}
-
-}}
-
-#endif
diff --git a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h b/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h
deleted file mode 100644
index 829fc83d7..000000000
--- a/other-licenses/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Compress/RangeCoder/RangeCoderOpt.h
-
-#ifndef __COMPRESS_RANGECODER_OPT_H
-#define __COMPRESS_RANGECODER_OPT_H
-
-#define RC_INIT_VAR \
- UInt32 range = rangeDecoder->Range; \
- UInt32 code = rangeDecoder->Code;
-
-#define RC_FLUSH_VAR \
- rangeDecoder->Range = range; \
- rangeDecoder->Code = code;
-
-#define RC_NORMALIZE \
- if (range < NCompress::NRangeCoder::kTopValue) \
- { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
-
-#define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \
- { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \
- if (code < bound) \
- { A0; range = bound; \
- prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \
- mi <<= 1; } \
- else \
- { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \
- mi = (mi + mi) + 1; }} \
- RC_NORMALIZE
-
-#define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
-
-#endif