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

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Compress')
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder1.cpp2
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder2.cpp2
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.cpp53
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.h8
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.cpp57
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.h10
-rwxr-xr-xCPP/7zip/Compress/Branch/x86_2.cpp4
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.cpp80
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.h7
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeDecoder.cpp5
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.cpp13
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp8
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp134
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp51
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/makefile1
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/makefile.gcc53
-rwxr-xr-xCPP/7zip/Compress/Lzh/LzhDecoder.cpp10
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDContext.h8
-rwxr-xr-xCPP/7zip/Compress/Quantum/QuantumDecoder.cpp2
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Vm.h2
20 files changed, 333 insertions, 177 deletions
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
index 7f720807..dda3721a 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
@@ -14,7 +14,7 @@ static const UInt32 kHistorySize = 26624;
static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3;
-static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
+// static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits,
UInt32 *table, int tablesize)
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
index a734d1b4..24c101d1 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
@@ -9,7 +9,7 @@ namespace NArj {
namespace NDecoder2 {
static const UInt32 kHistorySize = 26624;
-static const UInt32 kMatchMaxLen = 256;
+// static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3;
STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
index 703d528b..354ed03e 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
@@ -420,7 +420,7 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
#ifdef COMPRESS_BZIP2_MT
-static DWORD WINAPI MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
+static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
CDecoder::CDecoder():
m_States(0)
@@ -434,35 +434,40 @@ CDecoder::~CDecoder()
Free();
}
-bool CDecoder::Create()
+HRes CDecoder::Create()
{
+ RINOK(CanProcessEvent.CreateIfNotCreated());
+ RINOK(CanStartWaitingEvent.CreateIfNotCreated());
+ if (m_States != 0 && m_NumThreadsPrev == NumThreads)
+ return true;
+ Free();
+ MtMode = (NumThreads > 1);
+ m_NumThreadsPrev = NumThreads;
try
{
- if (m_States != 0 && m_NumThreadsPrev == NumThreads)
- return true;
- Free();
- MtMode = (NumThreads > 1);
- m_NumThreadsPrev = NumThreads;
m_States = new CState[NumThreads];
if (m_States == 0)
- return false;
- #ifdef COMPRESS_BZIP2_MT
- for (UInt32 t = 0; t < NumThreads; t++)
+ return E_OUTOFMEMORY;
+ }
+ catch(...) { return E_OUTOFMEMORY; }
+ #ifdef COMPRESS_BZIP2_MT
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CState &ti = m_States[t];
+ ti.Decoder = this;
+ if (MtMode)
{
- CState &ti = m_States[t];
- ti.Decoder = this;
- if (MtMode)
- if (!ti.Thread.Create(MFThread, &ti))
- {
- NumThreads = t;
- Free();
- return false;
- }
+ HRes res = ti.Thread.Create(MFThread, &ti);
+ if (res != S_OK)
+ {
+ NumThreads = t;
+ Free();
+ return res;
+ }
}
- #endif
}
- catch(...) { return false; }
- return true;
+ #endif
+ return S_OK;
}
void CDecoder::Free()
@@ -517,13 +522,13 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
{
#ifdef COMPRESS_BZIP2_MT
Progress = progress;
- if (!Create())
- return E_FAIL;
+ RINOK(Create());
for (UInt32 t = 0; t < NumThreads; t++)
{
CState &s = m_States[t];
if (!s.Alloc())
return E_OUTOFMEMORY;
+ RINOK(s.Create());
s.StreamWasFinishedEvent.Reset();
s.WaitingWasStartedEvent.Reset();
s.CanWriteEvent.Reset();
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.h b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
index f7a1c6bb..d38ababe 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Decoder.h
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
@@ -53,6 +53,12 @@ struct CState
void FinishStream();
void ThreadFunc();
+ HRes Create()
+ {
+ RINOK(StreamWasFinishedEvent.CreateIfNotCreated());
+ RINOK(WaitingWasStartedEvent.CreateIfNotCreated());
+ return CanWriteEvent.CreateIfNotCreated();
+ }
#endif
CState(): Counters(0) {}
@@ -125,7 +131,7 @@ public:
UInt32 BlockSizeMax;
CDecoder();
~CDecoder();
- bool Create();
+ HRes Create();
void Free();
#else
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
index 5e555813..f1e53cd6 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
@@ -26,14 +26,14 @@ const int kMaxHuffmanLenForEncoding = 16; // it must be < kMaxHuffmanLen = 20
static const UInt32 kBufferSize = (1 << 17);
static const int kNumHuffPasses = 4;
-bool CThreadInfo::Create()
+bool CThreadInfo::Alloc()
{
- if (m_BlockSorterIndex != 0)
- return true;
- m_BlockSorterIndex = (UInt32 *)::BigAlloc(BLOCK_SORT_BUF_SIZE(kBlockSizeMax) * sizeof(UInt32));
if (m_BlockSorterIndex == 0)
- return false;
-
+ {
+ m_BlockSorterIndex = (UInt32 *)::BigAlloc(BLOCK_SORT_BUF_SIZE(kBlockSizeMax) * sizeof(UInt32));
+ if (m_BlockSorterIndex == 0)
+ return false;
+ }
if (m_Block == 0)
{
@@ -111,7 +111,7 @@ DWORD CThreadInfo::ThreadFunc()
}
}
-static DWORD WINAPI MFThread(void *threadCoderInfo)
+static THREAD_FUNC_DECL MFThread(void *threadCoderInfo)
{
return ((CThreadInfo *)threadCoderInfo)->ThreadFunc();
}
@@ -135,33 +135,38 @@ CEncoder::~CEncoder()
Free();
}
-bool CEncoder::Create()
+HRes CEncoder::Create()
{
+ RINOK(CanProcessEvent.CreateIfNotCreated());
+ RINOK(CanStartWaitingEvent.CreateIfNotCreated());
+ if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
+ return S_OK;
try
{
- if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
- return true;
Free();
MtMode = (NumThreads > 1);
m_NumThreadsPrev = NumThreads;
ThreadsInfo = new CThreadInfo[NumThreads];
if (ThreadsInfo == 0)
- return false;
- for (UInt32 t = 0; t < NumThreads; t++)
+ return E_OUTOFMEMORY;
+ }
+ catch(...) { return E_OUTOFMEMORY; }
+ for (UInt32 t = 0; t < NumThreads; t++)
+ {
+ CThreadInfo &ti = ThreadsInfo[t];
+ ti.Encoder = this;
+ if (MtMode)
{
- CThreadInfo &ti = ThreadsInfo[t];
- ti.Encoder = this;
- if (MtMode)
- if (!ti.Thread.Create(MFThread, &ti))
- {
- NumThreads = t;
- Free();
- return false;
- }
+ HRes res = ti.Thread.Create(MFThread, &ti);
+ if (res != S_OK)
+ {
+ NumThreads = t;
+ Free();
+ return res;
+ }
}
}
- catch(...) { return false; }
- return true;
+ return S_OK;
}
void CEncoder::Free()
@@ -712,8 +717,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
{
#ifdef COMPRESS_BZIP2_MT
Progress = progress;
- if (!Create())
- return E_FAIL;
+ RINOK(Create());
for (UInt32 t = 0; t < NumThreads; t++)
#endif
{
@@ -729,8 +733,9 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
ti.m_OptimizeNumTables = m_OptimizeNumTables;
- if (!ti.Create())
+ if (!ti.Alloc())
return E_OUTOFMEMORY;
+ RINOK(ti.Create());
}
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.h b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
index c05a0481..eff93bc7 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Encoder.h
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
@@ -130,11 +130,17 @@ public:
UInt64 m_PackSize;
Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
+ HRes Create()
+ {
+ RINOK(StreamWasFinishedEvent.Create());
+ RINOK(WaitingWasStartedEvent.Create());
+ return CanWriteEvent.Create();
+ }
#endif
CThreadInfo(): m_BlockSorterIndex(0), m_Block(0) {}
~CThreadInfo() { Free(); }
- bool Create();
+ bool Alloc();
void Free();
HRESULT EncodeBlock3(UInt32 blockSize);
@@ -189,7 +195,7 @@ public:
void WriteCRC(UInt32 v);
#ifdef COMPRESS_BZIP2_MT
- bool Create();
+ HRes Create();
void Free();
#endif
diff --git a/CPP/7zip/Compress/Branch/x86_2.cpp b/CPP/7zip/Compress/Branch/x86_2.cpp
index 6f3a2f3c..178587b6 100755
--- a/CPP/7zip/Compress/Branch/x86_2.cpp
+++ b/CPP/7zip/Compress/Branch/x86_2.cpp
@@ -8,8 +8,6 @@ extern "C"
#include "../../../../C/Alloc.h"
}
-static const int kBufferSize = 1 << 17;
-
inline bool IsJcc(Byte b0, Byte b1)
{
return (b0 == 0x0F && (b1 & 0xF0) == 0x80);
@@ -17,6 +15,8 @@ inline bool IsJcc(Byte b0, Byte b1)
#ifndef EXTRACT_ONLY
+static const int kBufferSize = 1 << 17;
+
static bool inline Test86MSByte(Byte b)
{
return (b == 0 || b == 0xFF);
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
index a574fa3c..ac68ff35 100755
--- a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
@@ -104,6 +104,8 @@ CCoder::CCoder(bool deflate64Mode):
m_NumPasses(1),
m_NumDivPasses(1),
m_NumFastBytes(32),
+ _fastMode(false),
+ _btMode(true),
m_OnePosMatchesMemory(0),
m_DistanceMemory(0),
m_Created(false),
@@ -157,7 +159,7 @@ HRESULT CCoder::Create()
if (!m_Created)
{
- _lzInWindow.btMode = 1;
+ _lzInWindow.btMode = _btMode ? 1 : 0;
_lzInWindow.numHashBytes = 3;
if (!MatchFinder_Create(&_lzInWindow,
m_Deflate64Mode ? kHistorySize64 : kHistorySize32,
@@ -213,6 +215,15 @@ HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
m_MatchFinderCycles = prop.ulVal;
break;
}
+ case NCoderPropID::kAlgorithm:
+ {
+ if (prop.vt != VT_UI4)
+ return E_INVALIDARG;
+ UInt32 maximize = prop.ulVal;
+ _fastMode = (maximize == 0);
+ _btMode = !_fastMode;
+ break;
+ }
default:
return E_INVALIDARG;
}
@@ -238,7 +249,7 @@ CCoder::~CCoder()
MatchFinder_Free(&_lzInWindow, &g_Alloc);
}
-void CCoder::GetMatches()
+NO_INLINE void CCoder::GetMatches()
{
if (m_IsMultiPass)
{
@@ -252,7 +263,10 @@ void CCoder::GetMatches()
UInt32 distanceTmp[kMatchMaxLen * 2 + 3];
- UInt32 numPairs = Bt3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp);
+ UInt32 numPairs = (_btMode) ?
+ Bt3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp):
+ Hc3Zip_MatchFinder_GetMatches(&_lzInWindow, distanceTmp);
+
*m_MatchDistances = (UInt16)numPairs;
if (numPairs > 0)
@@ -285,7 +299,10 @@ void CCoder::MovePos(UInt32 num)
{
if (!m_SecondPass && num > 0)
{
- Bt3Zip_MatchFinder_Skip(&_lzInWindow, num);
+ if (_btMode)
+ Bt3Zip_MatchFinder_Skip(&_lzInWindow, num);
+ else
+ Hc3Zip_MatchFinder_Skip(&_lzInWindow, num);
m_AdditionalOffset += num;
}
}
@@ -420,6 +437,18 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
}
}
+UInt32 CCoder::GetOptimalFast(UInt32 &backRes)
+{
+ GetMatches();
+ UInt32 numDistancePairs = m_MatchDistances[0];
+ if (numDistancePairs == 0)
+ return 1;
+ UInt32 lenMain = m_MatchDistances[numDistancePairs - 1];
+ backRes = m_MatchDistances[numDistancePairs];
+ MovePos(lenMain - 1);
+ return lenMain;
+}
+
void CTables::InitStructures()
{
UInt32 i;
@@ -489,8 +518,13 @@ NO_INLINE void CCoder::LevelTableDummy(const Byte *levels, int numLevels, UInt32
}
}
+NO_INLINE void CCoder::WriteBits(UInt32 value, int numBits)
+{
+ m_OutStream.WriteBits(value, numBits);
+}
+
#define WRITE_HF2(codes, lens, i) m_OutStream.WriteBits(codes[i], lens[i])
-#define WRITE_HF(i) m_OutStream.WriteBits(codes[i], lens[i])
+#define WRITE_HF(i) WriteBits(codes[i], lens[i])
NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes)
{
@@ -523,17 +557,17 @@ NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const B
count--;
}
WRITE_HF(kTableLevelRepNumber);
- m_OutStream.WriteBits(count - 3, 2);
+ WriteBits(count - 3, 2);
}
else if (count <= 10)
{
WRITE_HF(kTableLevel0Number);
- m_OutStream.WriteBits(count - 3, 3);
+ WriteBits(count - 3, 3);
}
else
{
WRITE_HF(kTableLevel0Number2);
- m_OutStream.WriteBits(count - 11, 7);
+ WriteBits(count - 11, 7);
}
count = 0;
@@ -602,7 +636,11 @@ NO_INLINE void CCoder::TryBlock()
break;
}
UInt32 pos;
- UInt32 len = GetOptimal(pos);
+ UInt32 len;
+ if (_fastMode)
+ len = GetOptimalFast(pos);
+ else
+ len = GetOptimal(pos);
CCodeValue &codeValue = m_Values[m_ValueIndex++];
if (len >= kMatchMinLen)
{
@@ -629,6 +667,8 @@ NO_INLINE void CCoder::TryBlock()
NO_INLINE void CCoder::SetPrices(const CLevels &levels)
{
+ if (_fastMode)
+ return;
UInt32 i;
for(i = 0; i < 256; i++)
{
@@ -709,11 +749,11 @@ void CCoder::WriteStoreBlock(UInt32 blockSize, UInt32 additionalOffset, bool fin
{
UInt32 curBlockSize = (blockSize < (1 << 16)) ? blockSize : (1 << 16) - 1;
blockSize -= curBlockSize;
- m_OutStream.WriteBits((finalBlock && (blockSize == 0) ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
- m_OutStream.WriteBits(NBlockType::kStored, kBlockTypeFieldSize);
+ WriteBits((finalBlock && (blockSize == 0) ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ WriteBits(NBlockType::kStored, kBlockTypeFieldSize);
m_OutStream.FlushByte();
- m_OutStream.WriteBits((UInt16)curBlockSize, kStoredBlockLengthFieldSize);
- m_OutStream.WriteBits((UInt16)~curBlockSize, kStoredBlockLengthFieldSize);
+ WriteBits((UInt16)curBlockSize, kStoredBlockLengthFieldSize);
+ WriteBits((UInt16)~curBlockSize, kStoredBlockLengthFieldSize);
const Byte *data = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow)- additionalOffset;
for(UInt32 i = 0; i < curBlockSize; i++)
m_OutStream.WriteByte(data[i]);
@@ -847,10 +887,10 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock)
WriteStoreBlock(t.BlockSizeRes, m_AdditionalOffset, finalBlock);
else
{
- m_OutStream.WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
+ WriteBits((finalBlock ? NFinalBlockField::kFinalBlock: NFinalBlockField::kNotFinalBlock), kFinalBlockFieldSize);
if (t.StaticMode)
{
- m_OutStream.WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize);
+ WriteBits(NBlockType::kFixedHuffman, kBlockTypeFieldSize);
TryFixedBlock(tableIndex);
int i;
for (i = 0; i < kFixedMainTableSize; i++)
@@ -863,13 +903,13 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock)
{
if (m_NumDivPasses > 1 || m_CheckStatic)
TryDynBlock(tableIndex, 1);
- m_OutStream.WriteBits(NBlockType::kDynamicHuffman, kBlockTypeFieldSize);
- m_OutStream.WriteBits(m_NumLitLenLevels - kNumLitLenCodesMin, kNumLenCodesFieldSize);
- m_OutStream.WriteBits(m_NumDistLevels - kNumDistCodesMin, kNumDistCodesFieldSize);
- m_OutStream.WriteBits(m_NumLevelCodes - kNumLevelCodesMin, kNumLevelCodesFieldSize);
+ WriteBits(NBlockType::kDynamicHuffman, kBlockTypeFieldSize);
+ WriteBits(m_NumLitLenLevels - kNumLitLenCodesMin, kNumLenCodesFieldSize);
+ WriteBits(m_NumDistLevels - kNumDistCodesMin, kNumDistCodesFieldSize);
+ WriteBits(m_NumLevelCodes - kNumLevelCodesMin, kNumLevelCodesFieldSize);
for (UInt32 i = 0; i < m_NumLevelCodes; i++)
- m_OutStream.WriteBits(m_LevelLevels[i], kLevelFieldSize);
+ WriteBits(m_LevelLevels[i], kLevelFieldSize);
Huffman_ReverseBits(levelCodes, levelLens, kLevelTableSize);
LevelTableCode(m_NewLevels.litLenLevels, m_NumLitLenLevels, levelLens, levelCodes);
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.h b/CPP/7zip/Compress/Deflate/DeflateEncoder.h
index 86eede6f..a7b2bb5b 100755
--- a/CPP/7zip/Compress/Deflate/DeflateEncoder.h
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.h
@@ -24,7 +24,7 @@ struct CCodeValue
UInt16 Len;
UInt16 Pos;
void SetAsLiteral() { Len = (1 << 15); }
- bool IsLiteral() const { return ((Len & (1 << 15)) != 0); }
+ bool IsLiteral() const { return (Len >= (1 << 15)); }
};
struct COptimal
@@ -67,6 +67,8 @@ public:
UInt16 *m_MatchDistances;
UInt32 m_NumFastBytes;
+ bool _fastMode;
+ bool _btMode;
UInt16 *m_OnePosMatchesMemory;
UInt16 *m_DistanceMemory;
@@ -123,8 +125,11 @@ public:
void MovePos(UInt32 num);
UInt32 Backward(UInt32 &backRes, UInt32 cur);
UInt32 GetOptimal(UInt32 &backRes);
+ UInt32 GetOptimalFast(UInt32 &backRes);
void LevelTableDummy(const Byte *levels, int numLevels, UInt32 *freqs);
+
+ void WriteBits(UInt32 value, int numBits);
void LevelTableCode(const Byte *levels, int numLevels, const Byte *lens, const UInt32 *codes);
void MakeTables();
diff --git a/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
index 326afc0d..692f7c20 100755
--- a/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
+++ b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
@@ -24,7 +24,7 @@ static const int kNumDistanceLowDirectBitsForSmallDict = 6;
static const int kNumBitsInByte = 8;
-static const int kLevelStructuresNumberFieldSize = kNumBitsInByte;
+// static const int kLevelStructuresNumberFieldSize = kNumBitsInByte;
static const int kLevelStructuresNumberAdditionalValue = 1;
static const int kNumLevelStructureLevelBits = 4;
@@ -51,8 +51,7 @@ static const UInt32 kMatchMinLenWhenLiteralsOff = 2;
static const UInt32 kMatchMinLenMax = MyMax(kMatchMinLenWhenLiteralsOn,
kMatchMinLenWhenLiteralsOff); // 3
-static const UInt32 kMatchMaxLenMax = kMatchMinLenMax +
- (kLengthTableSize - 1) + (1 << kNumAdditionalLengthBits) - 1; // or 2
+// static const UInt32 kMatchMaxLenMax = kMatchMinLenMax + (kLengthTableSize - 1) + (1 << kNumAdditionalLengthBits) - 1; // or 2
enum
{
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
index a57b2a74..c2e2acbe 100755
--- a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
@@ -3,7 +3,18 @@
#include "StdAfx.h"
#include <stdio.h>
+
+#ifdef _WIN32
+#define USE_ALLOCA
+#endif
+
+#ifdef USE_ALLOCA
+#ifdef _WIN32
#include <malloc.h>
+#else
+#include <stdlib.h>
+#endif
+#endif
#include "../../../Common/Defs.h"
#include "../../Common/StreamUtils.h"
@@ -1266,8 +1277,10 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
{
// _needReleaseMFStream = false;
#ifdef COMPRESS_MF_MT
+ #ifdef USE_ALLOCA
alloca(0x300);
#endif
+ #endif
CCoderReleaser coderReleaser(this);
RINOK(SetStreams(inStream, outStream, inSize, outSize));
for (;;)
diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
index dbfa6b59..9cea4cb1 100755
--- a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
+++ b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
@@ -265,6 +265,14 @@ SOURCE=..\..\..\Windows\Defs.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\IntToString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\IntToString.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\MyCom.h
# End Source File
# Begin Source File
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
index e8816184..b0f01099 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
@@ -5,10 +5,28 @@
#include "LzmaBench.h"
#ifndef _WIN32
+#define USE_POSIX_TIME
+#define USE_POSIX_TIME2
+#endif
+
+#ifdef USE_POSIX_TIME
#include <time.h>
+#ifdef USE_POSIX_TIME2
+#include <sys/time.h>
+#endif
+#endif
+
+#ifdef _WIN32
+#define USE_ALLOCA
#endif
+#ifdef USE_ALLOCA
+#ifdef _WIN32
#include <malloc.h>
+#else
+#include <stdlib.h>
+#endif
+#endif
extern "C"
{
@@ -35,12 +53,12 @@ static const UInt32 kAdditionalSize = (1 << 16);
static const UInt32 kCompressedAdditionalSize = (1 << 10);
static const UInt32 kMaxLzmaPropSize = 5;
-class CRandomGenerator
+class CBaseRandomGenerator
{
UInt32 A1;
UInt32 A2;
public:
- CRandomGenerator() { Init(); }
+ CBaseRandomGenerator() { Init(); }
void Init() { A1 = 362436069; A2 = 521288629;}
UInt32 GetRnd()
{
@@ -75,9 +93,9 @@ public:
class CBenchRandomGenerator: public CBenchBuffer
{
- CRandomGenerator *RG;
+ CBaseRandomGenerator *RG;
public:
- void Set(CRandomGenerator *rg) { RG = rg; }
+ void Set(CBaseRandomGenerator *rg) { RG = rg; }
UInt32 GetVal(UInt32 &res, int numBits)
{
UInt32 val = res & (((UInt32)1 << numBits) - 1);
@@ -217,49 +235,64 @@ STDMETHODIMP CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *process
static UInt64 GetTimeCount()
{
- #ifdef _WIN32
+ #ifdef USE_POSIX_TIME
+ #ifdef USE_POSIX_TIME2
+ timeval v;
+ if (gettimeofday(&v, 0) == 0)
+ return (UInt64)(v.tv_sec) * 1000000 + v.tv_usec;
+ return (UInt64)time(NULL) * 1000000;
+ #else
+ return time(NULL);
+ #endif
+ #else
/*
LARGE_INTEGER value;
if (::QueryPerformanceCounter(&value))
return value.QuadPart;
*/
return GetTickCount();
- #else
- return clock();
#endif
}
static UInt64 GetFreq()
{
- #ifdef _WIN32
+ #ifdef USE_POSIX_TIME
+ #ifdef USE_POSIX_TIME2
+ return 1000000;
+ #else
+ return 1;
+ #endif
+ #else
/*
LARGE_INTEGER value;
if (::QueryPerformanceFrequency(&value))
return value.QuadPart;
*/
return 1000;
- #else
- return CLOCKS_PER_SEC;
#endif
}
-UInt64 GetUserTime()
+#ifndef USE_POSIX_TIME
+static inline UInt64 GetTime64(const FILETIME &t) { return ((UInt64)t.dwHighDateTime << 32) | t.dwLowDateTime; }
+#endif
+static UInt64 GetUserTime()
{
- #ifdef _WIN32
- FILETIME creationTime, exitTime, kernelTime, userTime;
- ::GetProcessTimes(::GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime);
- return ((UInt64)userTime.dwHighDateTime << 32) | userTime.dwLowDateTime;
- #else
+ #ifdef USE_POSIX_TIME
return clock();
+ #else
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ if (::GetProcessTimes(::GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime) != 0)
+ return GetTime64(userTime) + GetTime64(kernelTime);
+ return (UInt64)GetTickCount() * 10000;
#endif
}
static UInt64 GetUserFreq()
{
- #ifdef _WIN32
- return 10000000;
- #else
+ #ifdef USE_POSIX_TIME
return CLOCKS_PER_SEC;
+ #else
+ return 10000000;
#endif
}
@@ -435,13 +468,17 @@ struct CEncoderInfo
CBenchProgressInfo *progressInfoSpec[2];
CMyComPtr<ICompressProgressInfo> progressInfo[2];
UInt32 NumIterations;
+ #ifdef USE_ALLOCA
size_t AllocaSize;
+ #endif
struct CDecoderInfo
{
CEncoderInfo *Encoder;
UInt32 DecoderIndex;
+ #ifdef USE_ALLOCA
size_t AllocaSize;
+ #endif
bool CallbackMode;
};
CDecoderInfo decodersInfo[2];
@@ -457,17 +494,19 @@ struct CEncoderInfo
CBenchRandomGenerator rg;
CBenchmarkOutStream *propStreamSpec;
CMyComPtr<ISequentialOutStream> propStream;
- HRESULT Init(UInt32 dictionarySize, UInt32 numThreads, CRandomGenerator *rg);
+ HRESULT Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rg);
HRESULT Encode();
HRESULT Decode(UInt32 decoderIndex);
CEncoderInfo(): outStreamSpec(0), callback(0), propStreamSpec(0) {}
#ifdef BENCH_MT
- static DWORD WINAPI EncodeThreadFunction(void *param)
+ static THREAD_FUNC_DECL EncodeThreadFunction(void *param)
{
CEncoderInfo *encoder = (CEncoderInfo *)param;
+ #ifdef USE_ALLOCA
alloca(encoder->AllocaSize);
+ #endif
HRESULT res = encoder->Encode();
encoder->Results[0] = res;
if (res != S_OK)
@@ -475,38 +514,41 @@ struct CEncoderInfo
return 0;
}
- static DWORD WINAPI DecodeThreadFunction(void *param)
+ static THREAD_FUNC_DECL DecodeThreadFunction(void *param)
{
CDecoderInfo *decoder = (CDecoderInfo *)param;
+ #ifdef USE_ALLOCA
alloca(decoder->AllocaSize);
+ #endif
CEncoderInfo *encoder = decoder->Encoder;
encoder->Results[decoder->DecoderIndex] = encoder->Decode(decoder->DecoderIndex);
return 0;
}
- HRESULT CreateEncoderThread(size_t allocaSize)
+ HRESULT CreateEncoderThread()
{
- AllocaSize = allocaSize;
- if (!thread[0].Create(EncodeThreadFunction, this))
- return ::GetLastError();
- return 0;
+ return thread[0].Create(EncodeThreadFunction, this);
}
- HRESULT CreateDecoderThread(int index, bool callbackMode, size_t allocaSize)
+ HRESULT CreateDecoderThread(int index, bool callbackMode
+ #ifdef USE_ALLOCA
+ , size_t allocaSize
+ #endif
+ )
{
CDecoderInfo &decoder = decodersInfo[index];
decoder.DecoderIndex = index;
decoder.Encoder = this;
+ #ifdef USE_ALLOCA
decoder.AllocaSize = allocaSize;
+ #endif
decoder.CallbackMode = callbackMode;
- if (!thread[index].Create(DecodeThreadFunction, &decoder))
- return ::GetLastError();
- return 0;
+ return thread[index].Create(DecodeThreadFunction, &decoder);
}
#endif
};
-HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CRandomGenerator *rgLoc)
+HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandomGenerator *rgLoc)
{
rg.Set(rgLoc);
kBufferSize = dictionarySize + kAdditionalSize;
@@ -670,7 +712,7 @@ HRESULT LzmaBench(
}
}
- CRandomGenerator rg;
+ CBaseRandomGenerator rg;
rg.Init();
for (i = 0; i < numEncoderThreads; i++)
{
@@ -699,8 +741,10 @@ HRESULT LzmaBench(
#ifdef BENCH_MT
if (numEncoderThreads > 1)
{
- size_t allocaSize = (i * 16 * 21) & 0x7FF;
- RINOK(encoder.CreateEncoderThread(allocaSize))
+ #ifdef USE_ALLOCA
+ encoder.AllocaSize = (i * 16 * 21) & 0x7FF;
+ #endif
+ RINOK(encoder.CreateEncoderThread())
}
else
#endif
@@ -753,7 +797,12 @@ HRESULT LzmaBench(
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{
size_t allocaSize = ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF;
- RINOK(encoder.CreateDecoderThread(j, (i == 0 && j == 0), allocaSize))
+ HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0)
+ #ifdef USE_ALLOCA
+ , allocaSize
+ #endif
+ );
+ RINOK(res);
}
}
else
@@ -842,7 +891,7 @@ struct CCrcInfo
}
};
-static DWORD WINAPI CrcThreadFunction(void *param)
+static THREAD_FUNC_DECL CrcThreadFunction(void *param)
{
CCrcInfo *p = (CCrcInfo *)param;
p->Res = CrcBig(p->Data, p->Size, p->NumCycles, p->Crc);
@@ -876,13 +925,13 @@ static UInt32 CrcCalc1(const Byte *buf, UInt32 size)
return CRC_GET_DIGEST(crc);
}
-static void RandGen(Byte *buf, UInt32 size, CRandomGenerator &RG)
+static void RandGen(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
{
for (UInt32 i = 0; i < size; i++)
buf[i] = (Byte)RG.GetRnd();
}
-static UInt32 RandGenCrc(Byte *buf, UInt32 size, CRandomGenerator &RG)
+static UInt32 RandGenCrc(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
{
RandGen(buf, size, RG);
return CrcCalc1(buf, size);
@@ -903,7 +952,7 @@ bool CrcInternalTest()
UInt32 crc1 = CrcCalc1(buf, kBufferSize0);
if (crc1 != 0x29058C73)
return false;
- CRandomGenerator RG;
+ CBaseRandomGenerator RG;
RandGen(buf + kBufferSize0, kBufferSize1, RG);
for (i = 0; i < kBufferSize0 + kBufferSize1 - kCheckSize; i++)
for (UInt32 j = 0; j < kCheckSize; j++)
@@ -925,7 +974,7 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
return E_OUTOFMEMORY;
Byte *buf = buffer.Buffer;
- CRandomGenerator RG;
+ CBaseRandomGenerator RG;
UInt32 numCycles = ((UInt32)1 << 30) / ((bufferSize >> 2) + 1) + 1;
UInt64 timeVal;
@@ -948,8 +997,7 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
for (i = 0; i < numThreads; i++)
{
CCrcInfo &info = threads.Items[i];
- if (!info.Thread.Create(CrcThreadFunction, &info))
- return ::GetLastError();
+ RINOK(info.Thread.Create(CrcThreadFunction, &info));
threads.NumThreads++;
}
threads.WaitAll();
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
index 669cbf98..fef5a9ad 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
@@ -6,6 +6,7 @@
#include "LzmaBench.h"
#include "LzmaBenchCon.h"
+#include "Common/IntToString.h"
#if defined(BENCH_MT) || defined(_WIN32)
#include "Windows/System.h"
@@ -71,14 +72,24 @@ static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
return value * freq / elTime;
}
+static void PrintNumber(FILE *f, UInt64 value, int size)
+{
+ char s[32];
+ ConvertUInt64ToString(value, s);
+ fprintf(f, " ");
+ for (int len = (int)strlen(s); len < size; len++)
+ fprintf(f, " ");
+ fprintf(f, "%s", s);
+}
+
static void PrintRating(FILE *f, UInt64 rating)
{
- fprintf(f, " %6d", (unsigned int)(rating / 1000000));
+ PrintNumber(f, rating / 1000000, 6);
}
static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
{
- fprintf(f, " %5d", (usage + 5000) / 10000);
+ PrintNumber(f, (usage + 5000) / 10000, 5);
PrintRating(f, rpu);
PrintRating(f, rating);
}
@@ -87,7 +98,7 @@ static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
{
UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
- fprintf(f, "%7d", (unsigned int)(speed / 1024));
+ PrintNumber(f, speed / 1024, 7);
UInt64 usage = GetUsage(info);
UInt64 rpu = GetRatingPerUsage(info, rating);
PrintResults(f, usage, rpu, rating);
@@ -119,7 +130,7 @@ HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
return S_OK;
}
-static const char *kSep = " | ";
+static const char *kSep = " | ";
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
@@ -133,17 +144,19 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
fprintf(f, kSep);
CBenchInfo info2 = info;
- info2.GlobalTime /= info.NumIterations;
- info2.UserTime /= info.NumIterations;
+ info2.UnpackSize *= info2.NumIterations;
+ info2.PackSize *= info2.NumIterations;
+ info2.NumIterations = 1;
PrintResults(f, info2, rating, DecodeRes);
}
return S_OK;
}
-static void PtintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
+static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
{
- fprintf(f, "\nRAM %s %5d MB, # %s %3d", sizeString,
- (unsigned int)(size >> 20), threadsString, (unsigned int)numThreads);
+ fprintf(f, "\nRAM %s ", sizeString);
+ PrintNumber(f, (size >> 20), 5);
+ fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
}
HRESULT LzmaBenchCon(
@@ -157,7 +170,7 @@ HRESULT LzmaBenchCon(
#ifdef BENCH_MT
UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
- PtintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
if (numThreads == (UInt32)-1)
numThreads = numCPUs;
if (numThreads > 1)
@@ -176,24 +189,24 @@ HRESULT LzmaBenchCon(
numThreads = 1;
#endif
- PtintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
+ PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
CBenchCallback callback;
callback.Init();
callback.f = f;
- fprintf(f, "\n\nDict Compressing | Decompressing\n ");
+ fprintf(f, "\n\nDict Compressing | Decompressing\n ");
int j;
for (j = 0; j < 2; j++)
{
- fprintf(f, " Speed Usage R/U Rating");
+ fprintf(f, " Speed Usage R/U Rating");
if (j == 0)
fprintf(f, kSep);
}
- fprintf(f, "\n ");
+ fprintf(f, "\n ");
for (j = 0; j < 2; j++)
{
- fprintf(f, " KB/s %% MIPS MIPS");
+ fprintf(f, " KB/s %% MIPS MIPS");
if (j == 0)
fprintf(f, kSep);
}
@@ -206,7 +219,7 @@ HRESULT LzmaBenchCon(
pow--;
for (; ((UInt32)1 << pow) <= dictionary; pow++)
{
- fprintf(f, "%2d: ", pow);
+ fprintf(f, "%2d:", pow);
callback.dictionarySize = (UInt32)1 << pow;
HRESULT res = LzmaBench(
#ifdef EXTERNAL_LZMA
@@ -245,7 +258,7 @@ HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dic
#ifdef BENCH_MT
UInt64 ramSize = NWindows::NSystem::GetRamSize();
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
- PtintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
if (numThreads == (UInt32)-1)
numThreads = numCPUs;
#else
@@ -280,7 +293,7 @@ HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dic
return E_ABORT;
#endif
RINOK(CrcBench(ti + 1, bufSize, speed));
- fprintf(f, " %5d", (unsigned int)(speed >> 20));
+ PrintNumber(f, (speed >> 20), 5);
speedTotals.Values[ti] += speed;
}
fprintf(f, "\n");
@@ -291,7 +304,7 @@ HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dic
{
fprintf(f, "\nAvg:");
for (UInt32 ti = 0; ti < numThreads; ti++)
- fprintf(f, " %5d", (unsigned int)((speedTotals.Values[ti] / numSteps) >> 20));
+ PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
fprintf(f, "\n");
}
return S_OK;
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile b/CPP/7zip/Compress/LZMA_Alone/makefile
index a41a3c53..b7e6ca0e 100755
--- a/CPP/7zip/Compress/LZMA_Alone/makefile
+++ b/CPP/7zip/Compress/LZMA_Alone/makefile
@@ -52,6 +52,7 @@ LZMA_OPT_OBJS = \
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
+ $O\IntToString.obj \
$O\String.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
index 0c52cdc8..7696021e 100755
--- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
+++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
@@ -10,27 +10,28 @@ OBJS = \
LzmaBench.o \
LzmaBenchCon.o \
LzmaRam.o \
- LzmaRamDecode.o \
- LzmaDecode.o \
- BranchX86.o \
LZMADecoder.o \
LZMAEncoder.o \
- 7zCrc.o \
- MatchFinder.o \
LZOutWindow.o \
RangeCoderBit.o \
InBuffer.o \
OutBuffer.o \
FileStreams.o \
StreamUtils.o \
- Alloc.o \
C_FileIO.o \
CommandLineParser.o \
CRC.o \
+ IntToString.o \
String.o \
StringConvert.o \
StringToInt.o \
Vector.o \
+ 7zCrc.o \
+ Alloc.o \
+ BranchX86.o \
+ MatchFinder.o \
+ LzmaDecode.o \
+ LzmaRamDecode.o \
all: $(PROG)
@@ -50,31 +51,12 @@ LzmaBenchCon.o: LzmaBenchCon.cpp
LzmaRam.o: LzmaRam.cpp
$(CXX) $(CFLAGS) LzmaRam.cpp
-LzmaRamDecode.o: LzmaRamDecode.c
- $(CXX_C) $(CFLAGS) LzmaRamDecode.c
-
-LzmaDecode.o: ../../../../C/Compress/Lzma/LzmaDecode.c
- $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lzma/LzmaDecode.c
-
-BranchX86.o: ../../../../C/Compress/Branch/BranchX86.c
- $(CXX_C) $(CFLAGS) ../../../../C/Compress/Branch/BranchX86.c
-
LZMADecoder.o: ../LZMA/LZMADecoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
-MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c
- $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lz/MatchFinder.c
-
-7zCrc.o: ../../../../C/7zCrc.c
- $(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
-
-Alloc.o: ../../../../Alloc.cpp
- $(CXX) $(CFLAGS) ../../../../Alloc.c
-
-
LZOutWindow.o: ../LZ/LZOutWindow.cpp
$(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
@@ -105,6 +87,9 @@ CRC.o: ../../../Common/CRC.cpp
MyWindows.o: ../../../Common/MyWindows.cpp
$(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
+IntToString.o: ../../../Common/IntToString.cpp
+ $(CXX) $(CFLAGS) ../../../Common/IntToString.cpp
+
String.o: ../../../Common/String.cpp
$(CXX) $(CFLAGS) ../../../Common/String.cpp
@@ -117,6 +102,24 @@ StringToInt.o: ../../../Common/StringToInt.cpp
Vector.o: ../../../Common/Vector.cpp
$(CXX) $(CFLAGS) ../../../Common/Vector.cpp
+7zCrc.o: ../../../../C/7zCrc.c
+ $(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
+
+Alloc.o: ../../../../C/Alloc.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Alloc.c
+
+BranchX86.o: ../../../../C/Compress/Branch/BranchX86.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Branch/BranchX86.c
+
+MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lz/MatchFinder.c
+
+LzmaDecode.o: ../../../../C/Compress/Lzma/LzmaDecode.c
+ $(CXX_C) $(CFLAGS) ../../../../C/Compress/Lzma/LzmaDecode.c
+
+LzmaRamDecode.o: LzmaRamDecode.c
+ $(CXX_C) $(CFLAGS) LzmaRamDecode.c
+
clean:
-$(RM) $(PROG) $(OBJS)
diff --git a/CPP/7zip/Compress/Lzh/LzhDecoder.cpp b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
index 5a661047..36adf657 100755
--- a/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
+++ b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
@@ -186,16 +186,20 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
m_OutWindowStream.PutByte((Byte)c);
pos++;
}
- else
+ else if (c >= kNumCSymbols)
+ return S_FALSE;
+ else
{
// offset = (interface->method == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3;
UInt32 len = c - 256 + kMinMatch;
UInt32 distance = m_PHuffmanDecoder.Decode(&m_InBitStream);
if (distance != 0)
distance = (1 << (distance - 1)) + ReadBits(distance - 1);
- pos += len;
if (distance >= pos)
- throw 1;
+ return S_FALSE;
+ if (pos + len > *outSize)
+ len = (UInt32)(*outSize - pos);
+ pos += len;
m_OutWindowStream.CopyBlock(distance, len);
}
}
diff --git a/CPP/7zip/Compress/PPMD/PPMDContext.h b/CPP/7zip/Compress/PPMD/PPMDContext.h
index a6a8dd60..2e955d32 100755
--- a/CPP/7zip/Compress/PPMD/PPMDContext.h
+++ b/CPP/7zip/Compress/PPMD/PPMDContext.h
@@ -135,14 +135,14 @@ struct CInfo
SEE2Cont[i][k].init(5*i+10);
}
- void StartModelRare(int MaxOrder)
+ void StartModelRare(int maxOrder)
{
int i, k, m ,Step;
EscCount=PrintCount=1;
- if (MaxOrder < 2)
+ if (maxOrder < 2)
{
memset(CharMask,0,sizeof(CharMask));
- OrderFall = this->MaxOrder;
+ OrderFall = MaxOrder;
MinContext = MaxContext;
while (MinContext->Suffix != 0)
{
@@ -154,7 +154,7 @@ struct CInfo
}
else
{
- this->MaxOrder = MaxOrder;
+ MaxOrder = maxOrder;
RestartModelRare();
NS2BSIndx[0] = 2 * 0;
NS2BSIndx[1] = 2 * 1;
diff --git a/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
index 5cf863bb..e870292d 100755
--- a/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
+++ b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
@@ -8,7 +8,7 @@
namespace NCompress {
namespace NQuantum {
-const UInt32 kDictionarySizeMax = (1 << 21);
+// const UInt32 kDictionarySizeMax = (1 << 21);
const int kLenIdNeedInit = -2;
diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.h b/CPP/7zip/Compress/Rar/Rar3Vm.h
index d0a4f82c..cc8bbcd7 100755
--- a/CPP/7zip/Compress/Rar/Rar3Vm.h
+++ b/CPP/7zip/Compress/Rar/Rar3Vm.h
@@ -79,7 +79,7 @@ namespace NGlobalOffset
const UInt32 kBlockPos = 0x20;
const UInt32 kExecCount = 0x2C;
const UInt32 kGlobalMemOutSize = 0x30;
-};
+}
enum ECommand
{