mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 10:07:02 -06:00
9.09 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
2fed872194
commit
1fbaf0aac5
@@ -246,15 +246,9 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *ou
|
||||
if (!m_InBitStream.Create(1 << 20))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
int size1 = sizeof(c_table) / sizeof(c_table[0]);
|
||||
for (int i = 0; i < size1; i++)
|
||||
{
|
||||
if (i % 100 == 0)
|
||||
c_table[i] = 0;
|
||||
|
||||
// check it
|
||||
for (int i = 0; i < CTABLESIZE; i++)
|
||||
c_table[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
UInt64 pos = 0;
|
||||
m_OutWindowStream.SetStream(outStream);
|
||||
|
||||
@@ -420,7 +420,7 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
|
||||
|
||||
CDecoder::CDecoder()
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
m_States = 0;
|
||||
m_NumThreadsPrev = 0;
|
||||
NumThreads = 1;
|
||||
@@ -428,7 +428,7 @@ CDecoder::CDecoder()
|
||||
_needInStreamInit = true;
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
@@ -521,8 +521,8 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
|
||||
|
||||
HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
Progress = progress;
|
||||
#ifndef _7ZIP_ST
|
||||
RINOK(Create());
|
||||
for (UInt32 t = 0; t < NumThreads; t++)
|
||||
{
|
||||
@@ -556,7 +556,7 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
|
||||
UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
|
||||
|
||||
CombinedCrc.Init();
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
if (MtMode)
|
||||
{
|
||||
NextBlockIndex = 0;
|
||||
@@ -662,7 +662,7 @@ HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompr
|
||||
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
|
||||
STDMETHODIMP CDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../../Common/MyCom.h"
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../Windows/Synchronization.h"
|
||||
#include "../../Windows/Thread.h"
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@ struct CState
|
||||
{
|
||||
UInt32 *Counters;
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
CDecoder *Decoder;
|
||||
NWindows::CThread Thread;
|
||||
@@ -59,7 +59,7 @@ struct CState
|
||||
|
||||
class CDecoder :
|
||||
public ICompressCoder,
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
public ICompressSetCoderMt,
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
@@ -104,9 +104,9 @@ private:
|
||||
|
||||
public:
|
||||
CBZip2CombinedCrc CombinedCrc;
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
ICompressProgressInfo *Progress;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
CState *m_States;
|
||||
UInt32 m_NumThreadsPrev;
|
||||
|
||||
@@ -145,8 +145,8 @@ public:
|
||||
m_OutStream.ReleaseStream();
|
||||
}
|
||||
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
|
||||
#ifndef _7ZIP_ST
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetCoderMt)
|
||||
#endif
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
HRESULT CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress);
|
||||
UInt64 GetInputProcessedSize() const { return m_InStream.GetProcessedSize(); }
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ void CThreadInfo::Free()
|
||||
m_Block = 0;
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
static THREAD_FUNC_DECL MFThread(void *threadCoderInfo)
|
||||
{
|
||||
@@ -127,14 +127,14 @@ CEncoder::CEncoder():
|
||||
m_OptimizeNumTables(false),
|
||||
m_BlockSizeMult(kBlockSizeMultMax)
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
ThreadsInfo = 0;
|
||||
m_NumThreadsPrev = 0;
|
||||
NumThreads = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
CEncoder::~CEncoder()
|
||||
{
|
||||
Free();
|
||||
@@ -680,7 +680,7 @@ HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
|
||||
|
||||
EncodeBlock2(m_Block, blockSize, Encoder->NumPasses);
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
if (Encoder->MtMode)
|
||||
Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
|
||||
#endif
|
||||
@@ -688,7 +688,7 @@ HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
|
||||
Encoder->CombinedCrc.Update(m_CRCs[i]);
|
||||
Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
|
||||
HRESULT res = S_OK;
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
if (Encoder->MtMode)
|
||||
{
|
||||
UInt32 blockIndex = m_BlockIndex + 1;
|
||||
@@ -719,13 +719,13 @@ void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
|
||||
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
Progress = progress;
|
||||
RINOK(Create());
|
||||
for (UInt32 t = 0; t < NumThreads; t++)
|
||||
#endif
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
CThreadInfo &ti = ThreadsInfo[t];
|
||||
if (MtMode)
|
||||
{
|
||||
@@ -760,7 +760,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
|
||||
CFlusher flusher(this);
|
||||
|
||||
CombinedCrc.Init();
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
NextBlockIndex = 0;
|
||||
StreamWasFinished = false;
|
||||
CloseThreads = false;
|
||||
@@ -772,7 +772,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
|
||||
WriteByte(kArSig2);
|
||||
WriteByte((Byte)(kArSig3 + m_BlockSizeMult));
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
if (MtMode)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
|
||||
for (;;)
|
||||
{
|
||||
CThreadInfo &ti =
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
ThreadsInfo[0];
|
||||
#else
|
||||
ThreadsInfo;
|
||||
@@ -866,7 +866,7 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *p
|
||||
}
|
||||
case NCoderPropID::kNumThreads:
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
if (prop.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
NumThreads = prop.ulVal;
|
||||
@@ -882,7 +882,7 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *p
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
|
||||
{
|
||||
NumThreads = numThreads;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../../Common/Defs.h"
|
||||
#include "../../Common/MyCom.h"
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../Windows/Synchronization.h"
|
||||
#include "../../Windows/Thread.h"
|
||||
#endif
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
public:
|
||||
bool m_OptimizeNumTables;
|
||||
CEncoder *Encoder;
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
NWindows::CThread Thread;
|
||||
|
||||
NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
class CEncoder :
|
||||
public ICompressCoder,
|
||||
public ICompressSetCoderProperties,
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
public ICompressSetCoderMt,
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
UInt32 NumPasses;
|
||||
CBZip2CombinedCrc CombinedCrc;
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
CThreadInfo *ThreadsInfo;
|
||||
NWindows::NSynchronization::CManualResetEvent CanProcessEvent;
|
||||
NWindows::NSynchronization::CCriticalSection CS;
|
||||
@@ -192,14 +192,14 @@ public:
|
||||
void WriteBit(bool v);
|
||||
void WriteCrc(UInt32 v);
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
HRESULT Create();
|
||||
void Free();
|
||||
#endif
|
||||
|
||||
public:
|
||||
CEncoder();
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
~CEncoder();
|
||||
#endif
|
||||
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressSetCoderProperties)
|
||||
#else
|
||||
MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
|
||||
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
#ifndef _7ZIP_ST
|
||||
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
namespace NBitl {
|
||||
|
||||
const int kNumBigValueBits = 8 * 4;
|
||||
|
||||
const int kNumValueBytes = 3;
|
||||
const int kNumValueBits = 8 * kNumValueBytes;
|
||||
const unsigned kNumBigValueBits = 8 * 4;
|
||||
const unsigned kNumValueBytes = 3;
|
||||
const unsigned kNumValueBits = 8 * kNumValueBytes;
|
||||
|
||||
const UInt32 kMask = (1 << kNumValueBits) - 1;
|
||||
|
||||
@@ -20,7 +19,7 @@ template<class TInByte>
|
||||
class CBaseDecoder
|
||||
{
|
||||
protected:
|
||||
int m_BitPos;
|
||||
unsigned m_BitPos;
|
||||
UInt32 m_Value;
|
||||
TInByte m_Stream;
|
||||
public:
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 ReadBits(int numBits)
|
||||
UInt32 ReadBits(unsigned numBits)
|
||||
{
|
||||
Normalize();
|
||||
UInt32 res = m_Value & ((1 << numBits) - 1);
|
||||
@@ -95,19 +94,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 GetValue(int numBits)
|
||||
UInt32 GetValue(unsigned numBits)
|
||||
{
|
||||
Normalize();
|
||||
return ((this->m_Value >> (8 - this->m_BitPos)) & kMask) >> (kNumValueBits - numBits);
|
||||
}
|
||||
|
||||
void MovePos(int numBits)
|
||||
void MovePos(unsigned numBits)
|
||||
{
|
||||
this->m_BitPos += numBits;
|
||||
m_NormalValue >>= numBits;
|
||||
}
|
||||
|
||||
UInt32 ReadBits(int numBits)
|
||||
UInt32 ReadBits(unsigned numBits)
|
||||
{
|
||||
Normalize();
|
||||
UInt32 res = m_NormalValue & ((1 << numBits) - 1);
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
class CBitlEncoder
|
||||
{
|
||||
COutBuffer m_Stream;
|
||||
int m_BitPos;
|
||||
unsigned m_BitPos;
|
||||
Byte m_CurByte;
|
||||
public:
|
||||
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
|
||||
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); }
|
||||
void ReleaseStream() { m_Stream.ReleaseStream(); }
|
||||
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
|
||||
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
|
||||
void Init()
|
||||
{
|
||||
m_Stream.Init();
|
||||
@@ -25,18 +27,16 @@ public:
|
||||
FlushByte();
|
||||
return m_Stream.Flush();
|
||||
}
|
||||
|
||||
void FlushByte()
|
||||
{
|
||||
if(m_BitPos < 8)
|
||||
if (m_BitPos < 8)
|
||||
m_Stream.WriteByte(m_CurByte);
|
||||
m_BitPos = 8;
|
||||
m_CurByte = 0;
|
||||
}
|
||||
|
||||
void WriteBits(UInt32 value, int numBits)
|
||||
void WriteBits(UInt32 value, unsigned numBits)
|
||||
{
|
||||
while(numBits > 0)
|
||||
while (numBits > 0)
|
||||
{
|
||||
if (numBits < m_BitPos)
|
||||
{
|
||||
@@ -51,9 +51,6 @@ public:
|
||||
m_CurByte = 0;
|
||||
}
|
||||
}
|
||||
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
|
||||
UInt64 GetProcessedSize() const {
|
||||
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
|
||||
void WriteByte(Byte b) { m_Stream.WriteByte(b);}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
|
||||
namespace NBitm {
|
||||
|
||||
const int kNumBigValueBits = 8 * 4;
|
||||
const int kNumValueBytes = 3;
|
||||
const int kNumValueBits = 8 * kNumValueBytes;
|
||||
const unsigned kNumBigValueBits = 8 * 4;
|
||||
const unsigned kNumValueBytes = 3;
|
||||
const unsigned kNumValueBits = 8 * kNumValueBytes;
|
||||
|
||||
const UInt32 kMask = (1 << kNumValueBits) - 1;
|
||||
|
||||
template<class TInByte>
|
||||
class CDecoder
|
||||
{
|
||||
UInt32 m_BitPos;
|
||||
unsigned m_BitPos;
|
||||
UInt32 m_Value;
|
||||
public:
|
||||
TInByte m_Stream;
|
||||
@@ -39,19 +39,19 @@ public:
|
||||
m_Value = (m_Value << 8) | m_Stream.ReadByte();
|
||||
}
|
||||
|
||||
UInt32 GetValue(UInt32 numBits) const
|
||||
UInt32 GetValue(unsigned numBits) const
|
||||
{
|
||||
// return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
|
||||
return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
|
||||
}
|
||||
|
||||
void MovePos(UInt32 numBits)
|
||||
void MovePos(unsigned numBits)
|
||||
{
|
||||
m_BitPos += numBits;
|
||||
Normalize();
|
||||
}
|
||||
|
||||
UInt32 ReadBits(UInt32 numBits)
|
||||
UInt32 ReadBits(unsigned numBits)
|
||||
{
|
||||
UInt32 res = GetValue(numBits);
|
||||
MovePos(numBits);
|
||||
|
||||
@@ -9,12 +9,13 @@ template<class TOutByte>
|
||||
class CBitmEncoder
|
||||
{
|
||||
TOutByte m_Stream;
|
||||
int m_BitPos;
|
||||
unsigned m_BitPos;
|
||||
Byte m_CurByte;
|
||||
public:
|
||||
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
|
||||
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream);}
|
||||
void ReleaseStream() { m_Stream.ReleaseStream(); }
|
||||
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
|
||||
void Init()
|
||||
{
|
||||
m_Stream.Init();
|
||||
@@ -23,14 +24,13 @@ public:
|
||||
}
|
||||
HRESULT Flush()
|
||||
{
|
||||
if(m_BitPos < 8)
|
||||
if (m_BitPos < 8)
|
||||
WriteBits(0, m_BitPos);
|
||||
return m_Stream.Flush();
|
||||
}
|
||||
|
||||
void WriteBits(UInt32 value, int numBits)
|
||||
void WriteBits(UInt32 value, unsigned numBits)
|
||||
{
|
||||
while(numBits > 0)
|
||||
while (numBits > 0)
|
||||
{
|
||||
if (numBits < m_BitPos)
|
||||
{
|
||||
@@ -45,8 +45,6 @@ public:
|
||||
m_CurByte = 0;
|
||||
}
|
||||
}
|
||||
UInt64 GetProcessedSize() const {
|
||||
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,13 @@ void RegisterCodec(const CCodecInfo *codecInfo)
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE
|
||||
#else
|
||||
HINSTANCE
|
||||
#endif
|
||||
, DWORD /* dwReason */, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="AloneLZMA" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=AloneLZMA - Win32 DebugU
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "AloneLZMA.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "AloneLZMA.mak" CFG="AloneLZMA - Win32 DebugU"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "AloneLZMA - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "AloneLZMA - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "AloneLZMA - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "AloneLZMA - Win32 DebugU" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "AloneLZMA - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /FAcs /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "AloneLZMA - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "AloneLZMA - Win32 ReleaseU"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "ReleaseU"
|
||||
# PROP BASE Intermediate_Dir "ReleaseU"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "ReleaseU"
|
||||
# PROP Intermediate_Dir "ReleaseU"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\7za2.exe" /opt:NOWIN98
|
||||
# SUBTRACT BASE LINK32 /pdb:none
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "AloneLZMA - Win32 DebugU"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "DebugU"
|
||||
# PROP BASE Intermediate_Dir "DebugU"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "DebugU"
|
||||
# PROP Intermediate_Dir "DebugU"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za2.exe" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "AloneLZMA - Win32 Release"
|
||||
# Name "AloneLZMA - Win32 Debug"
|
||||
# Name "AloneLZMA - Win32 ReleaseU"
|
||||
# Name "AloneLZMA - Win32 DebugU"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "LZMA"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LzmaDecoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LzmaDecoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LzmaEncoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LzmaEncoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Thread.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CommandLineParser.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CommandLineParser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\..\..\Common\MyString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyVector.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyVector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Types.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CWrappers.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\OutBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "LzmaUtil"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Bra.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Bra86.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzFind.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzFind.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzFindMt.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzFindMt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzHash.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma86.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma86Dec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Lzma86Enc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaDec.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaDec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaEnc.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\LzmaEnc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Types.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\ICoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaAlone.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBench.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBench.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBenchCon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LzmaBenchCon.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "AloneLZMA"=.\AloneLZMA.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
// LzmaAlone.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/MyInitGuid.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if (defined(_WIN32) || defined(OS2) || defined(MSDOS)) && !defined(UNDER_CE)
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY)
|
||||
#else
|
||||
#define MY_SET_BINARY_MODE(file)
|
||||
#endif
|
||||
|
||||
#include "../../../Common/CommandLineParser.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
#include "../../../Windows/NtCheck.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../LzmaDecoder.h"
|
||||
#include "../LzmaEncoder.h"
|
||||
|
||||
#include "LzmaBenchCon.h"
|
||||
|
||||
#ifdef COMPRESS_MF_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
#include "../../../../C/7zVersion.h"
|
||||
#include "../../../../C/Alloc.h"
|
||||
#include "../../../../C/Lzma86.h"
|
||||
|
||||
using namespace NCommandLineParser;
|
||||
|
||||
static const char *kCantAllocate = "Can not allocate memory";
|
||||
static const char *kReadError = "Read error";
|
||||
static const char *kWriteError = "Write error";
|
||||
|
||||
namespace NKey {
|
||||
enum Enum
|
||||
{
|
||||
kHelp1 = 0,
|
||||
kHelp2,
|
||||
kAlgo,
|
||||
kDict,
|
||||
kFb,
|
||||
kMc,
|
||||
kLc,
|
||||
kLp,
|
||||
kPb,
|
||||
kMatchFinder,
|
||||
kMultiThread,
|
||||
kEOS,
|
||||
kStdIn,
|
||||
kStdOut,
|
||||
kFilter86
|
||||
};
|
||||
}
|
||||
|
||||
static const CSwitchForm kSwitchForms[] =
|
||||
{
|
||||
{ L"?", NSwitchType::kSimple, false },
|
||||
{ L"H", NSwitchType::kSimple, false },
|
||||
{ L"A", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"D", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"FB", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"MC", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"LC", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
|
||||
{ L"MT", NSwitchType::kUnLimitedPostString, false, 0 },
|
||||
{ L"EOS", NSwitchType::kSimple, false },
|
||||
{ L"SI", NSwitchType::kSimple, false },
|
||||
{ L"SO", NSwitchType::kSimple, false },
|
||||
{ L"F86", NSwitchType::kPostChar, false, 0, 0, L"+" }
|
||||
};
|
||||
|
||||
static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
|
||||
|
||||
static void PrintMessage(const char *s)
|
||||
{
|
||||
fprintf(stderr, s);
|
||||
}
|
||||
|
||||
static void PrintHelp()
|
||||
{
|
||||
PrintMessage("\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n"
|
||||
" e: encode file\n"
|
||||
" d: decode file\n"
|
||||
" b: Benchmark\n"
|
||||
"<Switches>\n"
|
||||
" -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
|
||||
" -d{N}: set dictionary size - [12, 30], default: 23 (8MB)\n"
|
||||
" -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
|
||||
" -mc{N}: set number of cycles for match finder\n"
|
||||
" -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
|
||||
" -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
|
||||
" -pb{N}: set number of pos bits - [0, 4], default: 2\n"
|
||||
" -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
|
||||
" -mt{N}: set number of CPU threads\n"
|
||||
" -eos: write End Of Stream marker\n"
|
||||
" -si: read data from stdin\n"
|
||||
" -so: write data to stdout\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void PrintHelpAndExit(const char *s)
|
||||
{
|
||||
fprintf(stderr, "\nError: %s\n\n", s);
|
||||
PrintHelp();
|
||||
throw -1;
|
||||
}
|
||||
|
||||
static void IncorrectCommand()
|
||||
{
|
||||
PrintHelpAndExit("Incorrect command");
|
||||
}
|
||||
|
||||
static void WriteArgumentsToStringList(int numArgs, const char *args[], UStringVector &strings)
|
||||
{
|
||||
for (int i = 1; i < numArgs; i++)
|
||||
strings.Add(MultiByteToUnicodeString(args[i]));
|
||||
}
|
||||
|
||||
static bool GetNumber(const wchar_t *s, UInt32 &value)
|
||||
{
|
||||
value = 0;
|
||||
if (MyStringLen(s) == 0)
|
||||
return false;
|
||||
const wchar_t *end;
|
||||
UInt64 res = ConvertStringToUInt64(s, &end);
|
||||
if (*end != L'\0')
|
||||
return false;
|
||||
if (res > 0xFFFFFFFF)
|
||||
return false;
|
||||
value = UInt32(res);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ParseUInt32(const CParser &parser, int index, UInt32 &res)
|
||||
{
|
||||
if (parser[index].ThereIs)
|
||||
if (!GetNumber(parser[index].PostStrings[0], res))
|
||||
IncorrectCommand();
|
||||
}
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION PrintMessage("Unsupported Windows version"); return 1;
|
||||
|
||||
int main2(int numArgs, const char *args[])
|
||||
{
|
||||
NT_CHECK
|
||||
|
||||
PrintMessage("\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n");
|
||||
|
||||
if (numArgs == 1)
|
||||
{
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4);
|
||||
if (unsupportedTypes)
|
||||
{
|
||||
PrintMessage("Unsupported base types. Edit Common/Types.h and recompile");
|
||||
return 1;
|
||||
}
|
||||
|
||||
UStringVector commandStrings;
|
||||
WriteArgumentsToStringList(numArgs, args, commandStrings);
|
||||
CParser parser(kNumSwitches);
|
||||
try
|
||||
{
|
||||
parser.ParseStrings(kSwitchForms, commandStrings);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
IncorrectCommand();
|
||||
}
|
||||
|
||||
if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
|
||||
{
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
|
||||
int paramIndex = 0;
|
||||
if (paramIndex >= nonSwitchStrings.Size())
|
||||
IncorrectCommand();
|
||||
const UString &command = nonSwitchStrings[paramIndex++];
|
||||
|
||||
bool dictDefined = false;
|
||||
UInt32 dict = (UInt32)-1;
|
||||
if(parser[NKey::kDict].ThereIs)
|
||||
{
|
||||
UInt32 dicLog;
|
||||
if (!GetNumber(parser[NKey::kDict].PostStrings[0], dicLog))
|
||||
IncorrectCommand();
|
||||
dict = 1 << dicLog;
|
||||
dictDefined = true;
|
||||
}
|
||||
UString mf = L"BT4";
|
||||
if (parser[NKey::kMatchFinder].ThereIs)
|
||||
mf = parser[NKey::kMatchFinder].PostStrings[0];
|
||||
|
||||
UInt32 numThreads = (UInt32)-1;
|
||||
|
||||
#ifdef COMPRESS_MF_MT
|
||||
if (parser[NKey::kMultiThread].ThereIs)
|
||||
{
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
const UString &s = parser[NKey::kMultiThread].PostStrings[0];
|
||||
if (s.IsEmpty())
|
||||
numThreads = numCPUs;
|
||||
else
|
||||
if (!GetNumber(s, numThreads))
|
||||
IncorrectCommand();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (command.CompareNoCase(L"b") == 0)
|
||||
{
|
||||
const UInt32 kNumDefaultItereations = 1;
|
||||
UInt32 numIterations = kNumDefaultItereations;
|
||||
{
|
||||
if (paramIndex < nonSwitchStrings.Size())
|
||||
if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
|
||||
numIterations = kNumDefaultItereations;
|
||||
}
|
||||
return LzmaBenchCon(stderr, numIterations, numThreads, dict);
|
||||
}
|
||||
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = 1;
|
||||
|
||||
bool encodeMode = false;
|
||||
if (command.CompareNoCase(L"e") == 0)
|
||||
encodeMode = true;
|
||||
else if (command.CompareNoCase(L"d") == 0)
|
||||
encodeMode = false;
|
||||
else
|
||||
IncorrectCommand();
|
||||
|
||||
bool stdInMode = parser[NKey::kStdIn].ThereIs;
|
||||
bool stdOutMode = parser[NKey::kStdOut].ThereIs;
|
||||
|
||||
CMyComPtr<ISequentialInStream> inStream;
|
||||
CInFileStream *inStreamSpec = 0;
|
||||
if (stdInMode)
|
||||
{
|
||||
inStream = new CStdInFileStream;
|
||||
MY_SET_BINARY_MODE(stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paramIndex >= nonSwitchStrings.Size())
|
||||
IncorrectCommand();
|
||||
const UString &inputName = nonSwitchStrings[paramIndex++];
|
||||
inStreamSpec = new CInFileStream;
|
||||
inStream = inStreamSpec;
|
||||
if (!inStreamSpec->Open(GetSystemString(inputName)))
|
||||
{
|
||||
fprintf(stderr, "\nError: can not open input file %s\n",
|
||||
(const char *)GetOemString(inputName));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
CMyComPtr<ISequentialOutStream> outStream;
|
||||
COutFileStream *outStreamSpec = NULL;
|
||||
if (stdOutMode)
|
||||
{
|
||||
outStream = new CStdOutFileStream;
|
||||
MY_SET_BINARY_MODE(stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paramIndex >= nonSwitchStrings.Size())
|
||||
IncorrectCommand();
|
||||
const UString &outputName = nonSwitchStrings[paramIndex++];
|
||||
outStreamSpec = new COutFileStream;
|
||||
outStream = outStreamSpec;
|
||||
if (!outStreamSpec->Create(GetSystemString(outputName), true))
|
||||
{
|
||||
fprintf(stderr, "\nError: can not open output file %s\n",
|
||||
(const char *)GetOemString(outputName));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (parser[NKey::kFilter86].ThereIs)
|
||||
{
|
||||
// -f86 switch is for x86 filtered mode: BCJ + LZMA.
|
||||
if (parser[NKey::kEOS].ThereIs || stdInMode)
|
||||
throw "Can not use stdin in this mode";
|
||||
UInt64 fileSize;
|
||||
inStreamSpec->File.GetLength(fileSize);
|
||||
if (fileSize > 0xF0000000)
|
||||
throw "File is too big";
|
||||
size_t inSize = (size_t)fileSize;
|
||||
Byte *inBuffer = 0;
|
||||
if (inSize != 0)
|
||||
{
|
||||
inBuffer = (Byte *)MyAlloc((size_t)inSize);
|
||||
if (inBuffer == 0)
|
||||
throw kCantAllocate;
|
||||
}
|
||||
|
||||
if (ReadStream_FAIL(inStream, inBuffer, inSize) != S_OK)
|
||||
throw "Can not read";
|
||||
|
||||
Byte *outBuffer = 0;
|
||||
size_t outSize;
|
||||
if (encodeMode)
|
||||
{
|
||||
// we allocate 105% of original size for output buffer
|
||||
outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
|
||||
if (outSize != 0)
|
||||
{
|
||||
outBuffer = (Byte *)MyAlloc((size_t)outSize);
|
||||
if (outBuffer == 0)
|
||||
throw kCantAllocate;
|
||||
}
|
||||
if (!dictDefined)
|
||||
dict = 1 << 23;
|
||||
int res = Lzma86_Encode(outBuffer, &outSize, inBuffer, inSize,
|
||||
5, dict, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO);
|
||||
if (res != 0)
|
||||
{
|
||||
fprintf(stderr, "\nEncoder error = %d\n", (int)res);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt64 outSize64;
|
||||
if (Lzma86_GetUnpackSize(inBuffer, inSize, &outSize64) != 0)
|
||||
throw "data error";
|
||||
outSize = (size_t)outSize64;
|
||||
if (outSize != outSize64)
|
||||
throw "too big";
|
||||
if (outSize != 0)
|
||||
{
|
||||
outBuffer = (Byte *)MyAlloc(outSize);
|
||||
if (outBuffer == 0)
|
||||
throw kCantAllocate;
|
||||
}
|
||||
int res = Lzma86_Decode(outBuffer, &outSize, inBuffer, &inSize);
|
||||
if (inSize != (size_t)fileSize)
|
||||
throw "incorrect processed size";
|
||||
if (res != 0)
|
||||
throw "LzmaDecoder error";
|
||||
}
|
||||
if (WriteStream(outStream, outBuffer, outSize) != S_OK)
|
||||
throw kWriteError;
|
||||
MyFree(outBuffer);
|
||||
MyFree(inBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
UInt64 fileSize;
|
||||
if (encodeMode)
|
||||
{
|
||||
NCompress::NLzma::CEncoder *encoderSpec = new NCompress::NLzma::CEncoder;
|
||||
CMyComPtr<ICompressCoder> encoder = encoderSpec;
|
||||
|
||||
if (!dictDefined)
|
||||
dict = 1 << 23;
|
||||
|
||||
UInt32 pb = 2;
|
||||
UInt32 lc = 3; // = 0; for 32-bit data
|
||||
UInt32 lp = 0; // = 2; for 32-bit data
|
||||
UInt32 algo = 1;
|
||||
UInt32 fb = 128;
|
||||
UInt32 mc = 16 + fb / 2;
|
||||
bool mcDefined = false;
|
||||
|
||||
bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
|
||||
|
||||
ParseUInt32(parser, NKey::kAlgo, algo);
|
||||
ParseUInt32(parser, NKey::kFb, fb);
|
||||
ParseUInt32(parser, NKey::kLc, lc);
|
||||
ParseUInt32(parser, NKey::kLp, lp);
|
||||
ParseUInt32(parser, NKey::kPb, pb);
|
||||
|
||||
mcDefined = parser[NKey::kMc].ThereIs;
|
||||
if (mcDefined)
|
||||
if (!GetNumber(parser[NKey::kMc].PostStrings[0], mc))
|
||||
IncorrectCommand();
|
||||
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kDictionarySize,
|
||||
NCoderPropID::kPosStateBits,
|
||||
NCoderPropID::kLitContextBits,
|
||||
NCoderPropID::kLitPosBits,
|
||||
NCoderPropID::kAlgorithm,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinder,
|
||||
NCoderPropID::kEndMarker,
|
||||
NCoderPropID::kNumThreads,
|
||||
NCoderPropID::kMatchFinderCycles,
|
||||
};
|
||||
const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
|
||||
|
||||
PROPVARIANT props[kNumPropsMax];
|
||||
for (int p = 0; p < 6; p++)
|
||||
props[p].vt = VT_UI4;
|
||||
|
||||
props[0].ulVal = (UInt32)dict;
|
||||
props[1].ulVal = (UInt32)pb;
|
||||
props[2].ulVal = (UInt32)lc;
|
||||
props[3].ulVal = (UInt32)lp;
|
||||
props[4].ulVal = (UInt32)algo;
|
||||
props[5].ulVal = (UInt32)fb;
|
||||
|
||||
props[6].vt = VT_BSTR;
|
||||
props[6].bstrVal = (BSTR)(const wchar_t *)mf;
|
||||
|
||||
props[7].vt = VT_BOOL;
|
||||
props[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
|
||||
props[8].vt = VT_UI4;
|
||||
props[8].ulVal = (UInt32)numThreads;
|
||||
|
||||
// it must be last in property list
|
||||
props[9].vt = VT_UI4;
|
||||
props[9].ulVal = (UInt32)mc;
|
||||
|
||||
int numProps = kNumPropsMax;
|
||||
if (!mcDefined)
|
||||
numProps--;
|
||||
|
||||
if (encoderSpec->SetCoderProperties(propIDs, props, numProps) != S_OK)
|
||||
IncorrectCommand();
|
||||
encoderSpec->WriteCoderProperties(outStream);
|
||||
|
||||
if (eos || stdInMode)
|
||||
fileSize = (UInt64)(Int64)-1;
|
||||
else
|
||||
inStreamSpec->File.GetLength(fileSize);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Byte b = Byte(fileSize >> (8 * i));
|
||||
if (outStream->Write(&b, 1, 0) != S_OK)
|
||||
{
|
||||
PrintMessage(kWriteError);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
|
||||
if (result == E_OUTOFMEMORY)
|
||||
{
|
||||
PrintMessage("\nError: Can not allocate memory\n");
|
||||
return 1;
|
||||
}
|
||||
else if (result != S_OK)
|
||||
{
|
||||
fprintf(stderr, "\nEncoder error = %X\n", (unsigned int)result);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NCompress::NLzma::CDecoder *decoderSpec = new NCompress::NLzma::CDecoder;
|
||||
CMyComPtr<ICompressCoder> decoder = decoderSpec;
|
||||
decoderSpec->FinishStream = true;
|
||||
const UInt32 kPropertiesSize = 5;
|
||||
Byte header[kPropertiesSize + 8];
|
||||
if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK)
|
||||
{
|
||||
PrintMessage(kReadError);
|
||||
return 1;
|
||||
}
|
||||
if (decoderSpec->SetDecoderProperties2(header, kPropertiesSize) != S_OK)
|
||||
{
|
||||
PrintMessage("SetDecoderProperties error");
|
||||
return 1;
|
||||
}
|
||||
fileSize = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
fileSize |= ((UInt64)header[kPropertiesSize + i]) << (8 * i);
|
||||
|
||||
if (decoder->Code(inStream, outStream, 0, (fileSize == (UInt64)(Int64)-1) ? 0 : &fileSize, 0) != S_OK)
|
||||
{
|
||||
PrintMessage("Decoder error");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (outStreamSpec != NULL)
|
||||
{
|
||||
if (outStreamSpec->Close() != S_OK)
|
||||
{
|
||||
PrintMessage("File closing error");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
try { return main2(numArgs, args); }
|
||||
catch(const char *s)
|
||||
{
|
||||
fprintf(stderr, "\nError: %s\n", s);
|
||||
return 1;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
PrintMessage("\nError\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
||||
// LzmaBench.h
|
||||
|
||||
#ifndef __LZMABENCH_H
|
||||
#define __LZMABENCH_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../../Common/Types.h"
|
||||
#ifdef EXTERNAL_LZMA
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
#endif
|
||||
|
||||
struct CBenchInfo
|
||||
{
|
||||
UInt64 GlobalTime;
|
||||
UInt64 GlobalFreq;
|
||||
UInt64 UserTime;
|
||||
UInt64 UserFreq;
|
||||
UInt64 UnpackSize;
|
||||
UInt64 PackSize;
|
||||
UInt32 NumIterations;
|
||||
CBenchInfo(): NumIterations(0) {}
|
||||
};
|
||||
|
||||
struct IBenchCallback
|
||||
{
|
||||
virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
|
||||
virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
|
||||
};
|
||||
|
||||
UInt64 GetUsage(const CBenchInfo &benchOnfo);
|
||||
UInt64 GetRatingPerUsage(const CBenchInfo &info, UInt64 rating);
|
||||
UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size);
|
||||
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
|
||||
|
||||
HRESULT LzmaBench(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
|
||||
|
||||
const int kBenchMinDicLogSize = 18;
|
||||
|
||||
UInt64 GetBenchMemoryUsage(UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
bool CrcInternalTest();
|
||||
HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed);
|
||||
|
||||
#endif
|
||||
@@ -1,311 +0,0 @@
|
||||
// LzmaBenchCon.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "LzmaBench.h"
|
||||
#include "LzmaBenchCon.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
|
||||
#if defined(BENCH_MT) || defined(_WIN32)
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
#ifdef BREAK_HANDLER
|
||||
#include "../../UI/Console/ConsoleClose.h"
|
||||
#endif
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
struct CTotalBenchRes
|
||||
{
|
||||
UInt64 NumIterations;
|
||||
UInt64 Rating;
|
||||
UInt64 Usage;
|
||||
UInt64 RPU;
|
||||
void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
|
||||
void Normalize()
|
||||
{
|
||||
if (NumIterations == 0)
|
||||
return;
|
||||
Rating /= NumIterations;
|
||||
Usage /= NumIterations;
|
||||
RPU /= NumIterations;
|
||||
NumIterations = 1;
|
||||
}
|
||||
void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
|
||||
{
|
||||
Rating = (r1.Rating + r2.Rating) / 2;
|
||||
Usage = (r1.Usage + r2.Usage) / 2;
|
||||
RPU = (r1.RPU + r2.RPU) / 2;
|
||||
NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
|
||||
}
|
||||
};
|
||||
|
||||
struct CBenchCallback: public IBenchCallback
|
||||
{
|
||||
CTotalBenchRes EncodeRes;
|
||||
CTotalBenchRes DecodeRes;
|
||||
FILE *f;
|
||||
void Init() { EncodeRes.Init(); DecodeRes.Init(); }
|
||||
void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
|
||||
UInt32 dictionarySize;
|
||||
HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
|
||||
HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
|
||||
};
|
||||
|
||||
static void NormalizeVals(UInt64 &v1, UInt64 &v2)
|
||||
{
|
||||
while (v1 > 1000000)
|
||||
{
|
||||
v1 >>= 1;
|
||||
v2 >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
|
||||
{
|
||||
UInt64 elTime = elapsedTime;
|
||||
NormalizeVals(freq, elTime);
|
||||
if (elTime == 0)
|
||||
elTime = 1;
|
||||
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)
|
||||
{
|
||||
PrintNumber(f, rating / 1000000, 6);
|
||||
}
|
||||
|
||||
static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
|
||||
{
|
||||
PrintNumber(f, (usage + 5000) / 10000, 5);
|
||||
PrintRating(f, rpu);
|
||||
PrintRating(f, rating);
|
||||
}
|
||||
|
||||
|
||||
static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
|
||||
{
|
||||
UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
|
||||
PrintNumber(f, speed / 1024, 7);
|
||||
UInt64 usage = GetUsage(info);
|
||||
UInt64 rpu = GetRatingPerUsage(info, rating);
|
||||
PrintResults(f, usage, rpu, rating);
|
||||
res.NumIterations++;
|
||||
res.RPU += rpu;
|
||||
res.Rating += rating;
|
||||
res.Usage += usage;
|
||||
}
|
||||
|
||||
static void PrintTotals(FILE *f, const CTotalBenchRes &res)
|
||||
{
|
||||
fprintf(f, " ");
|
||||
PrintResults(f, res.Usage, res.RPU, res.Rating);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
|
||||
PrintResults(f, info, rating, EncodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char *kSep = " | ";
|
||||
|
||||
|
||||
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
|
||||
fprintf(f, kSep);
|
||||
CBenchInfo info2 = info;
|
||||
info2.UnpackSize *= info2.NumIterations;
|
||||
info2.PackSize *= info2.NumIterations;
|
||||
info2.NumIterations = 1;
|
||||
PrintResults(f, info2, rating, DecodeRes);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
|
||||
{
|
||||
fprintf(f, "\nRAM %s ", sizeString);
|
||||
PrintNumber(f, (size >> 20), 5);
|
||||
fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
|
||||
}
|
||||
|
||||
HRESULT LzmaBenchCon(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
#ifdef BENCH_MT
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
if (numThreads > 1)
|
||||
numThreads &= ~1;
|
||||
if (dictionary == (UInt32)-1)
|
||||
{
|
||||
int dicSizeLog;
|
||||
for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
|
||||
if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
|
||||
break;
|
||||
dictionary = (1 << dicSizeLog);
|
||||
}
|
||||
#else
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 22);
|
||||
numThreads = 1;
|
||||
#endif
|
||||
|
||||
PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
|
||||
|
||||
CBenchCallback callback;
|
||||
callback.Init();
|
||||
callback.f = f;
|
||||
|
||||
fprintf(f, "\n\nDict Compressing | Decompressing\n ");
|
||||
int j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " Speed Usage R/U Rating");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
}
|
||||
fprintf(f, "\n ");
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " KB/s %% MIPS MIPS");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
const int kStartDicLog = 22;
|
||||
int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
|
||||
while (((UInt32)1 << pow) > dictionary)
|
||||
pow--;
|
||||
for (; ((UInt32)1 << pow) <= dictionary; pow++)
|
||||
{
|
||||
fprintf(f, "%2d:", pow);
|
||||
callback.dictionarySize = (UInt32)1 << pow;
|
||||
HRESULT res = LzmaBench(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
codecs,
|
||||
#endif
|
||||
numThreads, callback.dictionarySize, &callback);
|
||||
fprintf(f, "\n");
|
||||
RINOK(res);
|
||||
}
|
||||
}
|
||||
callback.Normalize();
|
||||
fprintf(f, "----------------------------------------------------------------\nAvr:");
|
||||
PrintTotals(f, callback.EncodeRes);
|
||||
fprintf(f, " ");
|
||||
PrintTotals(f, callback.DecodeRes);
|
||||
fprintf(f, "\nTot:");
|
||||
CTotalBenchRes midRes;
|
||||
midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
|
||||
PrintTotals(f, midRes);
|
||||
fprintf(f, "\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct CTempValues
|
||||
{
|
||||
UInt64 *Values;
|
||||
CTempValues(UInt32 num) { Values = new UInt64[num]; }
|
||||
~CTempValues() { delete []Values; }
|
||||
};
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
|
||||
#ifdef BENCH_MT
|
||||
UInt64 ramSize = NWindows::NSystem::GetRamSize();
|
||||
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
|
||||
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
|
||||
if (numThreads == (UInt32)-1)
|
||||
numThreads = numCPUs;
|
||||
#else
|
||||
numThreads = 1;
|
||||
#endif
|
||||
if (dictionary == (UInt32)-1)
|
||||
dictionary = (1 << 24);
|
||||
|
||||
CTempValues speedTotals(numThreads);
|
||||
fprintf(f, "\n\nSize");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
fprintf(f, " %5d", ti + 1);
|
||||
speedTotals.Values[ti] = 0;
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
|
||||
UInt64 numSteps = 0;
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
{
|
||||
for (int pow = 10; pow < 32; pow++)
|
||||
{
|
||||
UInt32 bufSize = (UInt32)1 << pow;
|
||||
if (bufSize > dictionary)
|
||||
break;
|
||||
fprintf(f, "%2d: ", pow);
|
||||
UInt64 speed;
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
{
|
||||
#ifdef BREAK_HANDLER
|
||||
if (NConsoleClose::TestBreakSignal())
|
||||
return E_ABORT;
|
||||
#endif
|
||||
RINOK(CrcBench(ti + 1, bufSize, speed));
|
||||
PrintNumber(f, (speed >> 20), 5);
|
||||
speedTotals.Values[ti] += speed;
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
numSteps++;
|
||||
}
|
||||
}
|
||||
if (numSteps != 0)
|
||||
{
|
||||
fprintf(f, "\nAvg:");
|
||||
for (UInt32 ti = 0; ti < numThreads; ti++)
|
||||
PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// LzmaBenchCon.h
|
||||
|
||||
#ifndef __LZMABENCHCON_H
|
||||
#define __LZMABENCHCON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../../Common/Types.h"
|
||||
#ifdef EXTERNAL_LZMA
|
||||
#include "../../UI/Common/LoadCodecs.h"
|
||||
#endif
|
||||
HRESULT LzmaBenchCon(
|
||||
#ifdef EXTERNAL_LZMA
|
||||
CCodecs *codecs,
|
||||
#endif
|
||||
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
@@ -1,8 +0,0 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#endif
|
||||
@@ -1,75 +0,0 @@
|
||||
PROG = lzma.exe
|
||||
MY_CONSOLE = 1
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DCOMPRESS_MF_MT \
|
||||
-DBENCH_MT \
|
||||
|
||||
LZMA_OBJS = \
|
||||
$O\LzmaAlone.obj \
|
||||
$O\LzmaBench.obj \
|
||||
$O\LzmaBenchCon.obj \
|
||||
|
||||
LZMA_OPT_OBJS = \
|
||||
$O\LzmaDecoder.obj \
|
||||
$O\LzmaEncoder.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\CommandLineParser.obj \
|
||||
$O\CRC.obj \
|
||||
$O\IntToString.obj \
|
||||
$O\MyString.obj \
|
||||
$O\StringConvert.obj \
|
||||
$O\StringToInt.obj \
|
||||
$O\MyVector.obj
|
||||
|
||||
WIN_OBJS = \
|
||||
$O\System.obj
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\CWrappers.obj \
|
||||
$O\InBuffer.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\7zCrc.obj \
|
||||
$O\Alloc.obj \
|
||||
$O\Bra86.obj \
|
||||
$O\LzFind.obj \
|
||||
$O\LzFindMt.obj \
|
||||
$O\Lzma86Dec.obj \
|
||||
$O\Lzma86Enc.obj \
|
||||
$O\LzmaDec.obj \
|
||||
$O\LzmaEnc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(LZMA_OBJS) \
|
||||
$(LZMA_OPT_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(WIN_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(C_OBJS) \
|
||||
$O\FileStreams.obj \
|
||||
$O\FileIO.obj \
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
|
||||
$(LZMA_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(LZMA_OPT_OBJS): ../$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(WIN_OBJS): ../../../Windows/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$O\FileStreams.obj: ../../Common/FileStreams.cpp
|
||||
$(COMPL)
|
||||
$O\FileIO.obj: ../../../Windows/FileIO.cpp
|
||||
$(COMPL)
|
||||
$(C_OBJS): ../../../../C/$(*B).c
|
||||
$(COMPL_O2)
|
||||
@@ -1,139 +0,0 @@
|
||||
PROG = lzma
|
||||
CXX = g++ -O2 -Wall
|
||||
CXX_C = gcc -O2 -Wall
|
||||
LIB = -lm
|
||||
RM = rm -f
|
||||
CFLAGS = -c
|
||||
|
||||
ifdef SystemDrive
|
||||
IS_MINGW = 1
|
||||
endif
|
||||
|
||||
ifdef IS_MINGW
|
||||
FILE_IO =FileIO
|
||||
FILE_IO_2 =Windows/$(FILE_IO)
|
||||
LIB2 = -luuid
|
||||
else
|
||||
FILE_IO =C_FileIO
|
||||
FILE_IO_2 =Common/$(FILE_IO)
|
||||
endif
|
||||
|
||||
OBJS = \
|
||||
LzmaAlone.o \
|
||||
LzmaBench.o \
|
||||
LzmaBenchCon.o \
|
||||
LzmaDecoder.o \
|
||||
LzmaEncoder.o \
|
||||
CWrappers.o \
|
||||
InBuffer.o \
|
||||
OutBuffer.o \
|
||||
FileStreams.o \
|
||||
StreamUtils.o \
|
||||
$(FILE_IO).o \
|
||||
CommandLineParser.o \
|
||||
CRC.o \
|
||||
IntToString.o \
|
||||
MyString.o \
|
||||
StringConvert.o \
|
||||
StringToInt.o \
|
||||
MyVector.o \
|
||||
7zCrc.o \
|
||||
Alloc.o \
|
||||
Bra86.o \
|
||||
LzFind.o \
|
||||
LzmaDec.o \
|
||||
LzmaEnc.o \
|
||||
Lzma86Dec.o \
|
||||
Lzma86Enc.o \
|
||||
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
$(PROG): $(OBJS)
|
||||
$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2)
|
||||
|
||||
LzmaAlone.o: LzmaAlone.cpp
|
||||
$(CXX) $(CFLAGS) LzmaAlone.cpp
|
||||
|
||||
LzmaBench.o: LzmaBench.cpp
|
||||
$(CXX) $(CFLAGS) LzmaBench.cpp
|
||||
|
||||
LzmaBenchCon.o: LzmaBenchCon.cpp
|
||||
$(CXX) $(CFLAGS) LzmaBenchCon.cpp
|
||||
|
||||
LzmaDecoder.o: ../LzmaDecoder.cpp
|
||||
$(CXX) $(CFLAGS) ../LzmaDecoder.cpp
|
||||
|
||||
LzmaEncoder.o: ../LzmaEncoder.cpp
|
||||
$(CXX) $(CFLAGS) ../LzmaEncoder.cpp
|
||||
|
||||
CWrappers.o: ../../Common/CWrappers.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/CWrappers.cpp
|
||||
|
||||
InBuffer.o: ../../Common/InBuffer.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
|
||||
|
||||
OutBuffer.o: ../../Common/OutBuffer.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
|
||||
|
||||
FileStreams.o: ../../Common/FileStreams.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
|
||||
|
||||
StreamUtils.o: ../../Common/StreamUtils.cpp
|
||||
$(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
|
||||
|
||||
$(FILE_IO).o: ../../../$(FILE_IO_2).cpp
|
||||
$(CXX) $(CFLAGS) ../../../$(FILE_IO_2).cpp
|
||||
|
||||
|
||||
CommandLineParser.o: ../../../Common/CommandLineParser.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
|
||||
|
||||
CRC.o: ../../../Common/CRC.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/CRC.cpp
|
||||
|
||||
MyWindows.o: ../../../Common/MyWindows.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
|
||||
|
||||
IntToString.o: ../../../Common/IntToString.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/IntToString.cpp
|
||||
|
||||
MyString.o: ../../../Common/MyString.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/MyString.cpp
|
||||
|
||||
StringConvert.o: ../../../Common/StringConvert.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
|
||||
|
||||
StringToInt.o: ../../../Common/StringToInt.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
|
||||
|
||||
MyVector.o: ../../../Common/MyVector.cpp
|
||||
$(CXX) $(CFLAGS) ../../../Common/MyVector.cpp
|
||||
|
||||
7zCrc.o: ../../../../C/7zCrc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
|
||||
|
||||
Alloc.o: ../../../../C/Alloc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/Alloc.c
|
||||
|
||||
Bra86.o: ../../../../C/Bra86.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/Bra86.c
|
||||
|
||||
LzFind.o: ../../../../C/LzFind.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/LzFind.c
|
||||
|
||||
LzmaDec.o: ../../../../C/LzmaDec.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/LzmaDec.c
|
||||
|
||||
LzmaEnc.o: ../../../../C/LzmaEnc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/LzmaEnc.c
|
||||
|
||||
Lzma86Dec.o: ../../../../C/Lzma86Dec.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/Lzma86Dec.c
|
||||
|
||||
Lzma86Enc.o: ../../../../C/Lzma86Enc.c
|
||||
$(CXX_C) $(CFLAGS) ../../../../C/Lzma86Enc.c
|
||||
|
||||
clean:
|
||||
-$(RM) $(PROG) $(OBJS)
|
||||
|
||||
@@ -37,7 +37,7 @@ class CDecoder:
|
||||
void SetOutStreamSizeResume(const UInt64 *outSize);
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
|
||||
#ifndef NO_READ_FROM_CODER
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace NCompress {
|
||||
namespace NLzx {
|
||||
|
||||
const int kNumHuffmanBits = 16;
|
||||
const unsigned kNumHuffmanBits = 16;
|
||||
const UInt32 kNumRepDistances = 3;
|
||||
|
||||
const UInt32 kNumLenSlots = 8;
|
||||
@@ -14,7 +14,7 @@ const UInt32 kMatchMinLen = 2;
|
||||
const UInt32 kNumLenSymbols = 249;
|
||||
const UInt32 kMatchMaxLen = kMatchMinLen + (kNumLenSlots - 1) + kNumLenSymbols - 1;
|
||||
|
||||
const int kNumAlignBits = 3;
|
||||
const unsigned kNumAlignBits = 3;
|
||||
const UInt32 kAlignTableSize = 1 << kNumAlignBits;
|
||||
|
||||
const UInt32 kNumPosSlots = 50;
|
||||
@@ -24,36 +24,36 @@ const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
|
||||
const UInt32 kLevelTableSize = 20;
|
||||
const UInt32 kMaxTableSize = kMainTableSize;
|
||||
|
||||
const int kNumBlockTypeBits = 3;
|
||||
const int kBlockTypeVerbatim = 1;
|
||||
const int kBlockTypeAligned = 2;
|
||||
const int kBlockTypeUncompressed = 3;
|
||||
const unsigned kNumBlockTypeBits = 3;
|
||||
const unsigned kBlockTypeVerbatim = 1;
|
||||
const unsigned kBlockTypeAligned = 2;
|
||||
const unsigned kBlockTypeUncompressed = 3;
|
||||
|
||||
const int kUncompressedBlockSizeNumBits = 24;
|
||||
const unsigned kUncompressedBlockSizeNumBits = 24;
|
||||
|
||||
const int kNumBitsForPreTreeLevel = 4;
|
||||
const unsigned kNumBitsForPreTreeLevel = 4;
|
||||
|
||||
const int kLevelSymbolZeros = 17;
|
||||
const int kLevelSymbolZerosBig = 18;
|
||||
const int kLevelSymbolSame = 19;
|
||||
const unsigned kLevelSymbolZeros = 17;
|
||||
const unsigned kLevelSymbolZerosBig = 18;
|
||||
const unsigned kLevelSymbolSame = 19;
|
||||
|
||||
const int kLevelSymbolZerosStartValue = 4;
|
||||
const int kLevelSymbolZerosNumBits = 4;
|
||||
const unsigned kLevelSymbolZerosStartValue = 4;
|
||||
const unsigned kLevelSymbolZerosNumBits = 4;
|
||||
|
||||
const int kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
|
||||
const unsigned kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
|
||||
(1 << kLevelSymbolZerosNumBits);
|
||||
const int kLevelSymbolZerosBigNumBits = 5;
|
||||
const unsigned kLevelSymbolZerosBigNumBits = 5;
|
||||
|
||||
const int kLevelSymbolSameNumBits = 1;
|
||||
const int kLevelSymbolSameStartValue = 4;
|
||||
const unsigned kLevelSymbolSameNumBits = 1;
|
||||
const unsigned kLevelSymbolSameStartValue = 4;
|
||||
|
||||
const int kNumBitsForAlignLevel = 3;
|
||||
const unsigned kNumBitsForAlignLevel = 3;
|
||||
|
||||
const int kNumDictionaryBitsMin = 15;
|
||||
const int kNumDictionaryBitsMax = 21;
|
||||
const unsigned kNumDictionaryBitsMin = 15;
|
||||
const unsigned kNumDictionaryBitsMax = 21;
|
||||
const UInt32 kDictionarySizeMax = (1 << kNumDictionaryBitsMax);
|
||||
|
||||
const int kNumLinearPosSlotBits = 17;
|
||||
const unsigned kNumLinearPosSlotBits = 17;
|
||||
const UInt32 kNumPowerPosSlots = 0x26;
|
||||
|
||||
}}
|
||||
|
||||
@@ -33,7 +33,7 @@ STDMETHODIMP CDecoder::Flush()
|
||||
return m_x86ConvertOutStreamSpec->Flush();
|
||||
}
|
||||
|
||||
UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
|
||||
UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InBitStream.ReadBits(numBits); }
|
||||
|
||||
#define RIF(x) { if (!(x)) return false; }
|
||||
|
||||
@@ -44,7 +44,7 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
|
||||
for (i = 0; i < kLevelTableSize; i++)
|
||||
levelLevels[i] = (Byte)ReadBits(kNumBitsForPreTreeLevel);
|
||||
RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
|
||||
int num = 0;
|
||||
unsigned num = 0;
|
||||
Byte symbol = 0;
|
||||
for (i = 0; i < numSymbols;)
|
||||
{
|
||||
@@ -58,12 +58,12 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
|
||||
UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
|
||||
if (number == kLevelSymbolZeros)
|
||||
{
|
||||
num = kLevelSymbolZerosStartValue + (int)ReadBits(kLevelSymbolZerosNumBits);
|
||||
num = kLevelSymbolZerosStartValue + (unsigned)ReadBits(kLevelSymbolZerosNumBits);
|
||||
symbol = 0;
|
||||
}
|
||||
else if (number == kLevelSymbolZerosBig)
|
||||
{
|
||||
num = kLevelSymbolZerosBigStartValue + (int)ReadBits(kLevelSymbolZerosBigNumBits);
|
||||
num = kLevelSymbolZerosBigStartValue + (unsigned)ReadBits(kLevelSymbolZerosBigNumBits);
|
||||
symbol = 0;
|
||||
}
|
||||
else if (number == kLevelSymbolSame || number <= kNumHuffmanBits)
|
||||
@@ -72,7 +72,7 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
|
||||
num = 1;
|
||||
else
|
||||
{
|
||||
num = kLevelSymbolSameStartValue + (int)ReadBits(kLevelSymbolSameNumBits);
|
||||
num = kLevelSymbolSameStartValue + (unsigned)ReadBits(kLevelSymbolSameNumBits);
|
||||
number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
|
||||
if (number > kNumHuffmanBits)
|
||||
return false;
|
||||
@@ -93,7 +93,7 @@ bool CDecoder::ReadTables(void)
|
||||
m_InBitStream.DirectReadByte();
|
||||
m_InBitStream.Normalize();
|
||||
|
||||
int blockType = (int)ReadBits(kNumBlockTypeBits);
|
||||
unsigned blockType = (unsigned)ReadBits(kNumBlockTypeBits);
|
||||
if (blockType > kBlockTypeUncompressed)
|
||||
return false;
|
||||
if (_wimMode)
|
||||
@@ -114,10 +114,10 @@ bool CDecoder::ReadTables(void)
|
||||
if (!m_InBitStream.ReadUInt32(m_RepDistances[0]))
|
||||
return false;
|
||||
m_RepDistances[0]--;
|
||||
for (int i = 1; i < kNumRepDistances; i++)
|
||||
for (unsigned i = 1; i < kNumRepDistances; i++)
|
||||
{
|
||||
UInt32 rep = 0;
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (unsigned j = 0; j < 4; j++)
|
||||
rep |= (UInt32)m_InBitStream.DirectReadByte() << (8 * j);
|
||||
m_RepDistances[i] = rep - 1;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ bool CDecoder::ReadTables(void)
|
||||
m_AlignIsUsed = (blockType == kBlockTypeAligned);
|
||||
if (m_AlignIsUsed)
|
||||
{
|
||||
for(int i = 0; i < kAlignTableSize; i++)
|
||||
for (unsigned i = 0; i < kAlignTableSize; i++)
|
||||
newLevels[i] = (Byte)ReadBits(kNumBitsForAlignLevel);
|
||||
RIF(m_AlignDecoder.SetCodeLengths(newLevels));
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
|
||||
void CDecoder::ClearPrevLevels()
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i = 0; i < kMainTableSize; i++)
|
||||
m_LastMainLevels[i] = 0;
|
||||
for (i = 0; i < kNumLenSymbols; i++)
|
||||
@@ -193,19 +193,19 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
}
|
||||
m_x86ConvertOutStreamSpec->Init(translationMode, i86TranslationSize);
|
||||
|
||||
for(int i = 0 ; i < kNumRepDistances; i++)
|
||||
for (unsigned i = 0 ; i < kNumRepDistances; i++)
|
||||
m_RepDistances[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while(_remainLen > 0 && curSize > 0)
|
||||
while (_remainLen > 0 && curSize > 0)
|
||||
{
|
||||
m_OutWindowStream.PutByte(m_OutWindowStream.GetByte(m_RepDistances[0]));
|
||||
_remainLen--;
|
||||
curSize--;
|
||||
}
|
||||
|
||||
while(curSize > 0)
|
||||
while (curSize > 0)
|
||||
{
|
||||
if (m_UnCompressedBlockSize == 0)
|
||||
if (!ReadTables())
|
||||
@@ -215,13 +215,13 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
m_UnCompressedBlockSize -= next;
|
||||
if (m_IsUncompressedBlock)
|
||||
{
|
||||
while(next > 0)
|
||||
while (next > 0)
|
||||
{
|
||||
m_OutWindowStream.PutByte(m_InBitStream.DirectReadByte());
|
||||
next--;
|
||||
}
|
||||
}
|
||||
else while(next > 0)
|
||||
else while (next > 0)
|
||||
{
|
||||
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
|
||||
if (number < 256)
|
||||
@@ -254,10 +254,10 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
else
|
||||
{
|
||||
UInt32 distance;
|
||||
int numDirectBits;
|
||||
unsigned numDirectBits;
|
||||
if (posSlot < kNumPowerPosSlots)
|
||||
{
|
||||
numDirectBits = (int)(posSlot >> 1) - 1;
|
||||
numDirectBits = (unsigned)(posSlot >> 1) - 1;
|
||||
distance = ((2 | (posSlot & 1)) << numDirectBits);
|
||||
}
|
||||
else
|
||||
@@ -365,7 +365,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::SetParams(int numDictBits)
|
||||
HRESULT CDecoder::SetParams(unsigned numDictBits)
|
||||
{
|
||||
if (numDictBits < kNumDictionaryBitsMin || numDictBits > kNumDictionaryBitsMax)
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace NLzx {
|
||||
|
||||
namespace NBitStream {
|
||||
|
||||
const int kNumBigValueBits = 8 * 4;
|
||||
const int kNumValueBits = 17;
|
||||
const unsigned kNumBigValueBits = 8 * 4;
|
||||
const unsigned kNumValueBits = 17;
|
||||
const UInt32 kBitDecoderValueMask = (1 << kNumValueBits) - 1;
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
CInBuffer m_Stream;
|
||||
UInt32 m_Value;
|
||||
int m_BitPos;
|
||||
unsigned m_BitPos;
|
||||
public:
|
||||
CDecoder() {}
|
||||
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
|
||||
@@ -39,14 +39,13 @@ public:
|
||||
m_BitPos = kNumBigValueBits;
|
||||
}
|
||||
|
||||
UInt64 GetProcessedSize() const
|
||||
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
|
||||
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
|
||||
|
||||
int GetBitPosition() const { return m_BitPos & 0xF; }
|
||||
unsigned GetBitPosition() const { return m_BitPos & 0xF; }
|
||||
|
||||
void Normalize()
|
||||
{
|
||||
for (;m_BitPos >= 16; m_BitPos -= 16)
|
||||
for (; m_BitPos >= 16; m_BitPos -= 16)
|
||||
{
|
||||
Byte b0 = m_Stream.ReadByte();
|
||||
Byte b1 = m_Stream.ReadByte();
|
||||
@@ -55,29 +54,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 GetValue(int numBits) const
|
||||
UInt32 GetValue(unsigned numBits) const
|
||||
{
|
||||
return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
|
||||
(kNumValueBits - numBits);
|
||||
return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >> (kNumValueBits - numBits);
|
||||
}
|
||||
|
||||
void MovePos(UInt32 numBits)
|
||||
void MovePos(unsigned numBits)
|
||||
{
|
||||
m_BitPos += (int)numBits;
|
||||
m_BitPos += numBits;
|
||||
Normalize();
|
||||
}
|
||||
|
||||
UInt32 ReadBits(int numBits)
|
||||
UInt32 ReadBits(unsigned numBits)
|
||||
{
|
||||
UInt32 res = GetValue(numBits);
|
||||
MovePos(numBits);
|
||||
return res;
|
||||
}
|
||||
|
||||
UInt32 ReadBitsBig(int numBits)
|
||||
UInt32 ReadBitsBig(unsigned numBits)
|
||||
{
|
||||
int numBits0 = numBits / 2;
|
||||
int numBits1 = numBits - numBits0;
|
||||
unsigned numBits0 = numBits / 2;
|
||||
unsigned numBits1 = numBits - numBits0;
|
||||
UInt32 res = ReadBits(numBits0) << numBits1;
|
||||
return res + ReadBits(numBits1);
|
||||
}
|
||||
@@ -128,7 +126,7 @@ class CDecoder :
|
||||
|
||||
bool _wimMode;
|
||||
|
||||
UInt32 ReadBits(int numBits);
|
||||
UInt32 ReadBits(unsigned numBits);
|
||||
bool ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols);
|
||||
bool ReadTables();
|
||||
void ClearPrevLevels();
|
||||
@@ -152,7 +150,7 @@ public:
|
||||
STDMETHOD(ReleaseInStream)();
|
||||
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
|
||||
|
||||
HRESULT SetParams(int numDictBits);
|
||||
HRESULT SetParams(unsigned numDictBits);
|
||||
void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
|
||||
};
|
||||
|
||||
|
||||
@@ -9,19 +9,23 @@
|
||||
namespace NCompress {
|
||||
namespace NQuantum {
|
||||
|
||||
// const UInt32 kDictionarySizeMax = (1 << 21);
|
||||
static const int kLenIdNeedInit = -2;
|
||||
|
||||
const int kLenIdNeedInit = -2;
|
||||
static const unsigned kNumLenSymbols = 27;
|
||||
static const unsigned kMatchMinLen = 3;
|
||||
static const unsigned kNumSimplePosSlots = 4;
|
||||
static const unsigned kNumSimpleLenSlots = 6;
|
||||
|
||||
void CDecoder::Init()
|
||||
{
|
||||
m_Selector.Init(kNumSelectors);
|
||||
for (unsigned int i = 0; i < kNumLitSelectors; i++)
|
||||
unsigned i;
|
||||
for (i = 0; i < kNumLitSelectors; i++)
|
||||
m_Literals[i].Init(kNumLitSymbols);
|
||||
unsigned int numItems = _numDictBits << 1;
|
||||
m_PosSlot[0].Init(MyMin(numItems, kNumLen3PosSymbolsMax));
|
||||
m_PosSlot[1].Init(MyMin(numItems, kNumLen4PosSymbolsMax));
|
||||
m_PosSlot[2].Init(MyMin(numItems, kNumLen5PosSymbolsMax));
|
||||
unsigned numItems = (_numDictBits == 0 ? 1 : (_numDictBits << 1));
|
||||
const unsigned kNumPosSymbolsMax[kNumMatchSelectors] = { 24, 36, 42 };
|
||||
for (i = 0; i < kNumMatchSelectors; i++)
|
||||
m_PosSlot[i].Init(MyMin(numItems, kNumPosSymbolsMax[i]));
|
||||
m_LenSlot.Init(kNumLenSymbols);
|
||||
}
|
||||
|
||||
@@ -31,7 +35,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
{
|
||||
if (!_keepHistory)
|
||||
{
|
||||
if (!_outWindowStream.Create(_dictionarySize))
|
||||
if (!_outWindowStream.Create((UInt32)1 << _numDictBits))
|
||||
return E_OUTOFMEMORY;
|
||||
Init();
|
||||
}
|
||||
@@ -43,7 +47,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
if (curSize == 0)
|
||||
return S_OK;
|
||||
|
||||
while(_remainLen > 0 && curSize > 0)
|
||||
while (_remainLen > 0 && curSize > 0)
|
||||
{
|
||||
_remainLen--;
|
||||
Byte b = _outWindowStream.GetByte(_rep0);
|
||||
@@ -51,12 +55,12 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
curSize--;
|
||||
}
|
||||
|
||||
while(curSize > 0)
|
||||
while (curSize > 0)
|
||||
{
|
||||
if (_rangeDecoder.Stream.WasFinished())
|
||||
return S_FALSE;
|
||||
|
||||
unsigned int selector = m_Selector.Decode(&_rangeDecoder);
|
||||
unsigned selector = m_Selector.Decode(&_rangeDecoder);
|
||||
if (selector < kNumLitSelectors)
|
||||
{
|
||||
Byte b = (Byte)((selector << (8 - kNumLitSelectorBits)) + m_Literals[selector].Decode(&_rangeDecoder));
|
||||
@@ -66,10 +70,10 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
else
|
||||
{
|
||||
selector -= kNumLitSelectors;
|
||||
unsigned int len = selector + kMatchMinLen;
|
||||
unsigned len = selector + kMatchMinLen;
|
||||
if (selector == 2)
|
||||
{
|
||||
unsigned int lenSlot = m_LenSlot.Decode(&_rangeDecoder);;
|
||||
unsigned lenSlot = m_LenSlot.Decode(&_rangeDecoder);
|
||||
if (lenSlot >= kNumSimpleLenSlots)
|
||||
{
|
||||
lenSlot -= 2;
|
||||
@@ -81,15 +85,15 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
else
|
||||
len += lenSlot;
|
||||
}
|
||||
UInt32 rep0 = m_PosSlot[selector].Decode(&_rangeDecoder);;
|
||||
UInt32 rep0 = m_PosSlot[selector].Decode(&_rangeDecoder);
|
||||
if (rep0 >= kNumSimplePosSlots)
|
||||
{
|
||||
int numDirectBits = (int)((rep0 >> 1) - 1);
|
||||
rep0 = ((2 | (rep0 & 1)) << numDirectBits) + _rangeDecoder.Stream.ReadBits(numDirectBits);
|
||||
}
|
||||
unsigned int locLen = len;
|
||||
unsigned locLen = len;
|
||||
if (len > curSize)
|
||||
locLen = (unsigned int)curSize;
|
||||
locLen = (unsigned)curSize;
|
||||
if (!_outWindowStream.CopyBlock(rep0, locLen))
|
||||
return S_FALSE;
|
||||
curSize -= locLen;
|
||||
|
||||
@@ -16,30 +16,30 @@ namespace NQuantum {
|
||||
|
||||
class CStreamBitDecoder
|
||||
{
|
||||
UInt32 m_Value;
|
||||
CInBuffer m_Stream;
|
||||
UInt32 Value;
|
||||
CInBuffer Stream;
|
||||
public:
|
||||
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
|
||||
void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
|
||||
void ReleaseStream() { m_Stream.ReleaseStream();}
|
||||
bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
|
||||
void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
|
||||
void ReleaseStream() { Stream.ReleaseStream(); }
|
||||
|
||||
void Finish() { m_Value = 0x10000; }
|
||||
void Finish() { Value = 0x10000; }
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_Stream.Init();
|
||||
m_Value = 0x10000;
|
||||
Stream.Init();
|
||||
Value = 0x10000;
|
||||
}
|
||||
|
||||
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize(); }
|
||||
bool WasFinished() const { return m_Stream.WasFinished(); };
|
||||
UInt64 GetProcessedSize() const { return Stream.GetProcessedSize(); }
|
||||
bool WasFinished() const { return Stream.WasFinished(); }
|
||||
|
||||
UInt32 ReadBit()
|
||||
{
|
||||
if (m_Value >= 0x10000)
|
||||
m_Value = 0x100 | m_Stream.ReadByte();
|
||||
UInt32 res = (m_Value >> 7) & 1;
|
||||
m_Value <<= 1;
|
||||
if (Value >= 0x10000)
|
||||
Value = 0x100 | Stream.ReadByte();
|
||||
UInt32 res = (Value >> 7) & 1;
|
||||
Value <<= 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -48,26 +48,17 @@ public:
|
||||
UInt32 res = 0;
|
||||
do
|
||||
res = (res << 1) | ReadBit();
|
||||
while(--numBits != 0);
|
||||
while (--numBits != 0);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
const int kNumLitSelectorBits = 2;
|
||||
const unsigned int kNumLitSelectors = (1 << kNumLitSelectorBits);
|
||||
const unsigned int kNumLitSymbols = 1 << (8 - kNumLitSelectorBits);
|
||||
const unsigned int kNumMatchSelectors = 3;
|
||||
const unsigned int kNumSelectors = kNumLitSelectors + kNumMatchSelectors;
|
||||
const unsigned int kNumLen3PosSymbolsMax = 24;
|
||||
const unsigned int kNumLen4PosSymbolsMax = 36;
|
||||
const unsigned int kNumLen5PosSymbolsMax = 42;
|
||||
const unsigned int kNumLenSymbols = 27;
|
||||
|
||||
const unsigned int kNumSymbolsMax = kNumLitSymbols; // 64
|
||||
|
||||
const unsigned int kMatchMinLen = 3;
|
||||
const unsigned int kNumSimplePosSlots = 4;
|
||||
const unsigned int kNumSimpleLenSlots = 6;
|
||||
const unsigned kNumLitSelectorBits = 2;
|
||||
const unsigned kNumLitSelectors = (1 << kNumLitSelectorBits);
|
||||
const unsigned kNumLitSymbols = 1 << (8 - kNumLitSelectorBits);
|
||||
const unsigned kNumMatchSelectors = 3;
|
||||
const unsigned kNumSelectors = kNumLitSelectors + kNumMatchSelectors;
|
||||
const unsigned kNumSymbolsMax = kNumLitSymbols; // 64
|
||||
|
||||
namespace NRangeCoder {
|
||||
|
||||
@@ -135,16 +126,16 @@ const UInt16 kReorderCount = 50;
|
||||
|
||||
class CModelDecoder
|
||||
{
|
||||
unsigned int NumItems;
|
||||
unsigned int ReorderCount;
|
||||
unsigned NumItems;
|
||||
unsigned ReorderCount;
|
||||
UInt16 Freqs[kNumSymbolsMax + 1];
|
||||
Byte Values[kNumSymbolsMax];
|
||||
public:
|
||||
void Init(unsigned int numItems)
|
||||
void Init(unsigned numItems)
|
||||
{
|
||||
NumItems = numItems;
|
||||
ReorderCount = kReorderCountStart;
|
||||
for(unsigned int i = 0; i < numItems; i++)
|
||||
for (unsigned i = 0; i < numItems; i++)
|
||||
{
|
||||
Freqs[i] = (UInt16)(numItems - i);
|
||||
Values[i] = (Byte)i;
|
||||
@@ -152,26 +143,26 @@ public:
|
||||
Freqs[numItems] = 0;
|
||||
}
|
||||
|
||||
unsigned int Decode(CDecoder *rangeDecoder)
|
||||
unsigned Decode(CDecoder *rangeDecoder)
|
||||
{
|
||||
UInt32 threshold = rangeDecoder->GetThreshold(Freqs[0]);
|
||||
unsigned int i;
|
||||
unsigned i;
|
||||
for (i = 1; Freqs[i] > threshold; i++);
|
||||
rangeDecoder->Decode(Freqs[i], Freqs[i - 1], Freqs[0]);
|
||||
unsigned int res = Values[--i];
|
||||
unsigned res = Values[--i];
|
||||
do
|
||||
Freqs[i] += kUpdateStep;
|
||||
while(i-- != 0);
|
||||
while (i-- != 0);
|
||||
|
||||
if (Freqs[0] > kFreqSumMax)
|
||||
{
|
||||
if (--ReorderCount == 0)
|
||||
{
|
||||
ReorderCount = kReorderCount;
|
||||
for(i = 0; i < NumItems; i++)
|
||||
for (i = 0; i < NumItems; i++)
|
||||
Freqs[i] = (UInt16)(((Freqs[i] - Freqs[i + 1]) + 1) >> 1);
|
||||
for(i = 0; i < NumItems - 1; i++)
|
||||
for(unsigned int j = i + 1; j < NumItems; j++)
|
||||
for (i = 0; i < NumItems - 1; i++)
|
||||
for (unsigned j = i + 1; j < NumItems; j++)
|
||||
if (Freqs[i] < Freqs[j])
|
||||
{
|
||||
UInt16 tmpFreq = Freqs[i];
|
||||
@@ -183,7 +174,7 @@ public:
|
||||
}
|
||||
do
|
||||
Freqs[i] = (UInt16)(Freqs[i] + Freqs[i + 1]);
|
||||
while(i-- != 0);
|
||||
while (i-- != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,11 +185,11 @@ public:
|
||||
if (Freqs[i] <= Freqs[i + 1])
|
||||
Freqs[i] = (UInt16)(Freqs[i + 1] + 1);
|
||||
}
|
||||
while(i-- != 0);
|
||||
while (i-- != 0);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -212,23 +203,17 @@ class CDecoder:
|
||||
CLzOutWindow _outWindowStream;
|
||||
NRangeCoder::CDecoder _rangeDecoder;
|
||||
|
||||
///////////////////
|
||||
// State
|
||||
UInt64 _outSize;
|
||||
// UInt64 _nowPos64;
|
||||
int _remainLen; // -1 means end of stream. // -2 means need Init
|
||||
UInt32 _rep0;
|
||||
|
||||
int _numDictBits;
|
||||
UInt32 _dictionarySize;
|
||||
bool _keepHistory;
|
||||
|
||||
NRangeCoder::CModelDecoder m_Selector;
|
||||
NRangeCoder::CModelDecoder m_Literals[kNumLitSelectors];
|
||||
NRangeCoder::CModelDecoder m_PosSlot[kNumMatchSelectors];
|
||||
NRangeCoder::CModelDecoder m_LenSlot;
|
||||
|
||||
bool _keepHistory;
|
||||
|
||||
void Init();
|
||||
HRESULT CodeSpec(UInt32 size);
|
||||
public:
|
||||
@@ -268,16 +253,8 @@ public:
|
||||
STDMETHOD(ReleaseInStream)();
|
||||
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
|
||||
|
||||
void SetParams(int numDictBits)
|
||||
{
|
||||
_numDictBits = numDictBits;
|
||||
_dictionarySize = (UInt32)1 << numDictBits;
|
||||
}
|
||||
void SetKeepHistory(bool keepHistory)
|
||||
{
|
||||
_keepHistory = keepHistory;
|
||||
}
|
||||
|
||||
void SetParams(int numDictBits) { _numDictBits = numDictBits; }
|
||||
void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
|
||||
CDecoder(): _keepHistory(false) {}
|
||||
virtual ~CDecoder() {}
|
||||
};
|
||||
|
||||
@@ -42,6 +42,8 @@ UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits);
|
||||
|
||||
HRESULT CDecoder::CopyBlock(UInt32 distance, UInt32 len)
|
||||
{
|
||||
if (len == 0)
|
||||
return S_FALSE;
|
||||
m_UnpackSize -= len;
|
||||
return m_OutWindowStream.CopyBlock(distance, len) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
@@ -256,6 +256,8 @@ bool CDecoder::DecodeLz(Int32 pos)
|
||||
else if (number == kRepBothNumber)
|
||||
{
|
||||
length = m_LastLength;
|
||||
if (length == 0)
|
||||
return false;
|
||||
distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
|
||||
}
|
||||
else if (number < kLen2Number)
|
||||
|
||||
@@ -623,8 +623,7 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
|
||||
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
|
||||
if (number < 256)
|
||||
{
|
||||
PutByte(Byte(number));
|
||||
|
||||
PutByte((Byte)number);
|
||||
continue;
|
||||
}
|
||||
else if (number == kSymbolReadTable)
|
||||
@@ -640,6 +639,8 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
|
||||
}
|
||||
else if (number == 258)
|
||||
{
|
||||
if (length == 0)
|
||||
return S_FALSE;
|
||||
}
|
||||
else if (number < kSymbolRep + 4)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user