mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 08:07:12 -06:00
4.46 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
a145bfc7cf
commit
c574fc0f4b
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../../../Windows/PropVariant.h"
|
||||
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
@@ -157,7 +157,7 @@ HRESULT CDecoder::Decode(
|
||||
_mixerCoderCommon = _mixerCoderSTSpec;
|
||||
#endif
|
||||
}
|
||||
_mixerCoderCommon->SetBindInfo(bindInfo);
|
||||
RINOK(_mixerCoderCommon->SetBindInfo(bindInfo));
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ HRESULT CEncoder::CreateMixerCoder(
|
||||
{
|
||||
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
|
||||
_mixerCoder = _mixerCoderSpec;
|
||||
_mixerCoderSpec->SetBindInfo(_bindInfo);
|
||||
RINOK(_mixerCoderSpec->SetBindInfo(_bindInfo));
|
||||
for (int i = 0; i < _options.Methods.Size(); i++)
|
||||
{
|
||||
const CMethodFull &methodFull = _options.Methods[i];
|
||||
|
||||
@@ -143,10 +143,12 @@ static inline UString GetHex2(Byte value)
|
||||
|
||||
static const UInt64 k_AES = 0x06F10701;
|
||||
|
||||
#ifndef _SFX
|
||||
static inline UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CHandler::IsEncrypted(UInt32 index2) const
|
||||
{
|
||||
@@ -393,11 +395,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static const wchar_t *kExt = L"7z";
|
||||
static const wchar_t *kAfterPart = L".7z";
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
class CVolumeName
|
||||
{
|
||||
bool _first;
|
||||
|
||||
@@ -85,8 +85,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
#ifdef _7Z_VOL
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,9 @@ static const UInt32 kPpmdOrderX5 = 6;
|
||||
static const UInt32 kPpmdOrderX7 = 16;
|
||||
static const UInt32 kPpmdOrderX9 = 32;
|
||||
|
||||
static const UInt32 kDeflateAlgoX1 = 0;
|
||||
static const UInt32 kDeflateAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kDeflateFastBytesX1 = 32;
|
||||
static const UInt32 kDeflateFastBytesX7 = 64;
|
||||
static const UInt32 kDeflateFastBytesX9 = 128;
|
||||
@@ -323,7 +326,11 @@ HRESULT CHandler::SetCompressionMethod(
|
||||
(level >= 9 ? kDeflatePassesX9 :
|
||||
(level >= 7 ? kDeflatePassesX7 :
|
||||
kDeflatePassesX1));
|
||||
UInt32 algo =
|
||||
(level >= 5 ? kDeflateAlgoX5 :
|
||||
kDeflateAlgoX1);
|
||||
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
|
||||
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
|
||||
}
|
||||
|
||||
@@ -1238,7 +1238,7 @@ HRESULT CInArchive::ReadDatabase(
|
||||
UInt64 nextHeaderSize;
|
||||
UInt32 nextHeaderCRC;
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
UInt32 temp;
|
||||
UInt32 temp = 0;
|
||||
RINOK(SafeReadDirectUInt32(crcFromArchive, temp));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderOffset, crc));
|
||||
RINOK(SafeReadDirectUInt64(nextHeaderSize, crc));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../../../Common/Buffer.h"
|
||||
#include "../../../Common/String.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "7zHeader.h"
|
||||
|
||||
namespace NArchive {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
|
||||
enum // PropID
|
||||
enum
|
||||
{
|
||||
kpidPackedSize0 = kpidUserDefined,
|
||||
kpidPackedSize1,
|
||||
kpidPackedSize2,
|
||||
kpidPackedSize3,
|
||||
kpidPackedSize4,
|
||||
kpidPackedSize4
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -350,7 +350,6 @@ static bool IsExeFile(const UString &ext)
|
||||
return false;
|
||||
}
|
||||
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
static const UInt64 k_LZMA = 0x030101;
|
||||
static const UInt64 k_BCJ = 0x03030103;
|
||||
static const UInt64 k_BCJ2 = 0x0303011B;
|
||||
@@ -843,6 +842,8 @@ static HRESULT Update2(
|
||||
|
||||
#ifdef _7Z_VOL
|
||||
|
||||
static const UInt64 k_Copy = 0x0;
|
||||
|
||||
static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
|
||||
{
|
||||
CCoderInfo coder;
|
||||
|
||||
@@ -35,7 +35,7 @@ struct CUpdateItem
|
||||
bool IsLastAccessTimeDefined;
|
||||
bool AttributesAreDefined;
|
||||
|
||||
const bool HasStream() const
|
||||
bool HasStream() const
|
||||
{ return !IsDirectory && !IsAnti && Size != 0; }
|
||||
CUpdateItem():
|
||||
IsAnti(false),
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace NFileHeader
|
||||
kCompressed1c = 3,
|
||||
kCompressed2 = 4,
|
||||
kNoDataNoCRC = 8,
|
||||
kNoData = 9,
|
||||
kNoData = 9
|
||||
};
|
||||
}
|
||||
namespace NFileType
|
||||
@@ -62,7 +62,7 @@ namespace NFileHeader
|
||||
k7BitText = 1,
|
||||
kDirectory = 3,
|
||||
kVolumeLablel = 4,
|
||||
kChapterLabel = 5,
|
||||
kChapterLabel = 5
|
||||
};
|
||||
}
|
||||
namespace NFlags
|
||||
|
||||
@@ -46,8 +46,7 @@ class CHandler:
|
||||
}
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
|
||||
@@ -54,8 +54,6 @@ STATPROPSTG kProperties[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
{
|
||||
L"None",
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
{
|
||||
kUnexpectedEndOfArchive = 0,
|
||||
kIncorrectArchive,
|
||||
kUnsupported,
|
||||
kUnsupported
|
||||
} Cause;
|
||||
CInArchiveException(CCauseType cause) : Cause(cause) {}
|
||||
};
|
||||
|
||||
@@ -55,8 +55,6 @@ STATPROPSTG kProperties[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int kNumProperties = sizeof(kProperties) / sizeof(kProperties[0]);
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value)
|
||||
{
|
||||
value->vt = VT_EMPTY;
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -158,7 +158,7 @@ struct CCoderInfo
|
||||
class CCoderMixer2
|
||||
{
|
||||
public:
|
||||
virtual void SetBindInfo(const CBindInfo &bindInfo) = 0;
|
||||
virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) = 0;
|
||||
virtual void ReInit() = 0;
|
||||
virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0;
|
||||
};
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace NCoderMixer2 {
|
||||
|
||||
CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
|
||||
ExitEvent(NULL),
|
||||
CompressEvent(NULL),
|
||||
CompressionCompletedEvent(NULL),
|
||||
CCoderInfo(numInStreams, numOutStreams)
|
||||
{
|
||||
InStreams.Reserve(NumInStreams);
|
||||
@@ -22,20 +20,6 @@ CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams):
|
||||
OutStreamPointers.Reserve(NumOutStreams);
|
||||
}
|
||||
|
||||
void CThreadCoderInfo::CreateEvents()
|
||||
{
|
||||
CompressEvent = new CAutoResetEvent(false);
|
||||
CompressionCompletedEvent = new CAutoResetEvent(false);
|
||||
}
|
||||
|
||||
CThreadCoderInfo::~CThreadCoderInfo()
|
||||
{
|
||||
if (CompressEvent != NULL)
|
||||
delete CompressEvent;
|
||||
if (CompressionCompletedEvent != NULL)
|
||||
delete CompressionCompletedEvent;
|
||||
}
|
||||
|
||||
class CCoderInfoFlusher2
|
||||
{
|
||||
CThreadCoderInfo *m_CoderInfo;
|
||||
@@ -48,13 +32,13 @@ public:
|
||||
m_CoderInfo->InStreams[i].Release();
|
||||
for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++)
|
||||
m_CoderInfo->OutStreams[i].Release();
|
||||
m_CoderInfo->CompressionCompletedEvent->Set();
|
||||
m_CoderInfo->CompressionCompletedEvent.Set();
|
||||
}
|
||||
};
|
||||
|
||||
bool CThreadCoderInfo::WaitAndCode()
|
||||
{
|
||||
HANDLE events[2] = { ExitEvent, *CompressEvent };
|
||||
HANDLE events[2] = { ExitEvent, CompressEvent };
|
||||
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
|
||||
if (waitResult == WAIT_OBJECT_0 + 0)
|
||||
return false;
|
||||
@@ -123,7 +107,7 @@ void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes,
|
||||
SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
|
||||
}
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -135,7 +119,7 @@ static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
//////////////////////////////////////
|
||||
// CCoderMixer2MT
|
||||
|
||||
static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL MainCoderThread(void *threadCoderInfo)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -146,7 +130,9 @@ static DWORD WINAPI MainCoderThread(void *threadCoderInfo)
|
||||
|
||||
CCoderMixer2MT::CCoderMixer2MT()
|
||||
{
|
||||
if (!_mainThread.Create(MainCoderThread, this))
|
||||
if (CreateEvents() != S_OK)
|
||||
throw 271824;
|
||||
if (_mainThread.Create(MainCoderThread, this) != S_OK)
|
||||
throw 271825;
|
||||
}
|
||||
|
||||
@@ -161,15 +147,16 @@ CCoderMixer2MT::~CCoderMixer2MT()
|
||||
}
|
||||
}
|
||||
|
||||
void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
{
|
||||
_bindInfo = bindInfo;
|
||||
_streamBinders.Clear();
|
||||
for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
|
||||
{
|
||||
_streamBinders.Add(CStreamBinder());
|
||||
_streamBinders.Back().CreateEvents();
|
||||
RINOK(_streamBinders.Back().CreateEvents());
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CCoderMixer2MT::AddCoderCommon()
|
||||
@@ -180,13 +167,13 @@ void CCoderMixer2MT::AddCoderCommon()
|
||||
CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams,
|
||||
CoderStreamsInfo.NumOutStreams);
|
||||
_coderInfoVector.Add(threadCoderInfo);
|
||||
_coderInfoVector.Back().CreateEvents();
|
||||
_coderInfoVector.Back().ExitEvent = _exitEvent;
|
||||
_compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent);
|
||||
CThreadCoderInfo *tci = &_coderInfoVector.Back();
|
||||
tci->CreateEvents();
|
||||
tci->ExitEvent = _exitEvent;
|
||||
|
||||
NWindows::CThread newThread;
|
||||
_threads.Add(newThread);
|
||||
if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back()))
|
||||
if (_threads.Back().Create(CoderThread, tci) != S_OK)
|
||||
throw 271824;
|
||||
}
|
||||
|
||||
@@ -282,13 +269,13 @@ bool CCoderMixer2MT::MyCode()
|
||||
if (waitResult == WAIT_OBJECT_0 + 0)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressEvent->Set();
|
||||
/* DWORD result = */ ::WaitForMultipleObjects(_compressingCompletedEvents.Size(),
|
||||
&_compressingCompletedEvents.Front(), TRUE, INFINITE);
|
||||
|
||||
_compressingFinishedEvent.Set();
|
||||
int i;
|
||||
for(i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressEvent.Set();
|
||||
for (i = 0; i < _coderInfoVector.Size(); i++)
|
||||
_coderInfoVector[i].CompressionCompletedEvent.Lock();
|
||||
|
||||
_compressingFinishedEvent.Set();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -311,6 +298,7 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
|
||||
|
||||
CCrossThreadProgress *progressSpec = new CCrossThreadProgress;
|
||||
CMyComPtr<ICompressProgressInfo> crossProgress = progressSpec;
|
||||
RINOK(progressSpec->Create());
|
||||
progressSpec->Init();
|
||||
_coderInfoVector[_progressCoderIndex].Progress = crossProgress;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace NCoderMixer2 {
|
||||
|
||||
struct CThreadCoderInfo: public CCoderInfo
|
||||
{
|
||||
NWindows::NSynchronization::CAutoResetEvent *CompressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressEvent;
|
||||
HANDLE ExitEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
|
||||
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
|
||||
CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
|
||||
@@ -35,9 +35,12 @@ struct CThreadCoderInfo: public CCoderInfo
|
||||
CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams);
|
||||
void SetCoderInfo(const UInt64 **inSizes,
|
||||
const UInt64 **outSizes, ICompressProgressInfo *progress);
|
||||
~CThreadCoderInfo();
|
||||
bool WaitAndCode();
|
||||
void CreateEvents();
|
||||
HRes CreateEvents()
|
||||
{
|
||||
RINOK(CompressEvent.CreateIfNotCreated());
|
||||
return CompressionCompletedEvent.CreateIfNotCreated();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -105,14 +108,20 @@ private:
|
||||
NWindows::CThread _mainThread;
|
||||
|
||||
NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent;
|
||||
CRecordVector<HANDLE> _compressingCompletedEvents;
|
||||
NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent;
|
||||
|
||||
NWindows::NSynchronization::CManualResetEvent _exitEvent;
|
||||
UInt32 _progressCoderIndex;
|
||||
|
||||
HRes CreateEvents()
|
||||
{
|
||||
RINOK(_startCompressingEvent.CreateIfNotCreated());
|
||||
RINOK(_compressingFinishedEvent.CreateIfNotCreated());
|
||||
return _exitEvent.CreateIfNotCreated();
|
||||
}
|
||||
|
||||
public:
|
||||
void SetBindInfo(const CBindInfo &bindInfo);
|
||||
HRESULT SetBindInfo(const CBindInfo &bindInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ CCoderMixer2ST::CCoderMixer2ST() {}
|
||||
|
||||
CCoderMixer2ST::~CCoderMixer2ST(){ }
|
||||
|
||||
void CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
|
||||
HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
|
||||
{
|
||||
_bindInfo = bindInfo;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CCoderMixer2ST::AddCoderCommon(bool isMain)
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
CObjectVector<CSTCoderInfo> _coders;
|
||||
int _mainCoderIndex;
|
||||
public:
|
||||
void SetBindInfo(const CBindInfo &bindInfo);
|
||||
HRESULT SetBindInfo(const CBindInfo &bindInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ public:
|
||||
HRESULT Result;
|
||||
NWindows::NSynchronization::CAutoResetEvent ProgressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent WaitEvent;
|
||||
|
||||
HRes Create()
|
||||
{
|
||||
RINOK(ProgressEvent.CreateIfNotCreated());
|
||||
return WaitEvent.CreateIfNotCreated();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
ProgressEvent.Reset();
|
||||
|
||||
@@ -16,7 +16,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -16,7 +16,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -19,6 +19,7 @@ extern "C"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
#ifndef _UNICODE
|
||||
#ifdef _WIN32
|
||||
bool g_IsNT = false;
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
@@ -29,6 +30,7 @@ static bool IsItWindowsNT()
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
@@ -37,8 +39,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
#ifndef _UNICODE
|
||||
#ifdef _WIN32
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
|
||||
SetLargePageSize();
|
||||
#endif
|
||||
|
||||
@@ -23,8 +23,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
@@ -79,7 +78,8 @@ private:
|
||||
void InitMethodProperties()
|
||||
{
|
||||
m_Method.NumMatchFinderCyclesDefined = false;
|
||||
m_Level = m_Method.NumPasses = m_Method.NumFastBytes = m_Method.NumMatchFinderCycles = 0xFFFFFFFF;
|
||||
m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
|
||||
m_Method.NumMatchFinderCycles = m_Method.Algo = 0xFFFFFFFF;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NGZip {
|
||||
|
||||
static const UInt32 kAlgoX1 = 0;
|
||||
static const UInt32 kAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kNumPassesX1 = 1;
|
||||
static const UInt32 kNumPassesX7 = 3;
|
||||
static const UInt32 kNumPassesX9 = 10;
|
||||
@@ -137,6 +140,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
if (m_Method.Algo == 0xFFFFFFFF)
|
||||
m_Method.Algo =
|
||||
(level >= 5 ? kAlgoX5 :
|
||||
kAlgoX1);
|
||||
|
||||
return UpdateArchive(
|
||||
EXTERNAL_CODECS_VARS
|
||||
@@ -193,6 +200,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
m_Method.NumMatchFinderCycles = num;
|
||||
m_Method.NumMatchFinderCyclesDefined = true;
|
||||
}
|
||||
else if (name.Left(1) == L"A")
|
||||
{
|
||||
UInt32 num = kAlgoX5;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, num));
|
||||
m_Method.Algo = num;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ HRESULT CInArchive::ReadBytes(ISequentialInStream *inStream, void *data, UInt32
|
||||
|
||||
HRESULT CInArchive::ReadByte(ISequentialInStream *inStream, Byte &value, UInt32 &crc)
|
||||
{
|
||||
HRESULT res = ReadBytes(inStream, &value, 1);
|
||||
RINOK(ReadBytes(inStream, &value, 1));
|
||||
crc = CRC_UPDATE_BYTE(crc, value);
|
||||
return res;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CInArchive::ReadUInt16(ISequentialInStream *inStream, UInt16 &value, UInt32 &crc)
|
||||
|
||||
@@ -83,12 +83,14 @@ HRESULT UpdateArchive(
|
||||
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
compressionMethod.Algo,
|
||||
compressionMethod.NumPasses,
|
||||
compressionMethod.NumFastBytes,
|
||||
compressionMethod.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kAlgorithm,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
|
||||
@@ -17,6 +17,7 @@ struct CCompressionMethodMode
|
||||
{
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
UInt32 Algo;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
UInt32 NumMatchFinderCycles;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace NArchive
|
||||
{
|
||||
kExtract = 0,
|
||||
kTest,
|
||||
kSkip,
|
||||
kSkip
|
||||
};
|
||||
}
|
||||
namespace NOperationResult
|
||||
@@ -58,7 +58,7 @@ namespace NArchive
|
||||
kOK = 0,
|
||||
kUnSupportedMethod,
|
||||
kDataError,
|
||||
kCRCError,
|
||||
kCRCError
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace NArchive
|
||||
enum
|
||||
{
|
||||
kOK = 0,
|
||||
kError,
|
||||
kError
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Tar/Handler.h
|
||||
// Iso/Handler.h
|
||||
|
||||
#ifndef __ISO_HANDLER_H
|
||||
#define __ISO_HANDLER_H
|
||||
|
||||
@@ -15,7 +15,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -27,8 +27,7 @@ class CHandler:
|
||||
bool GetCompressedSize(int index, UInt32 &size);
|
||||
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
@@ -23,7 +23,9 @@ public:
|
||||
SignatureInitializer() { kSignature[0]--; };
|
||||
} g_SignatureInitializer;
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static const char *kCrLf = "\x0D\x0A";
|
||||
#endif
|
||||
|
||||
UInt32 GetUInt32FromMemLE(const Byte *p)
|
||||
{
|
||||
@@ -245,6 +247,7 @@ enum
|
||||
EW_LOCKWINDOW
|
||||
};
|
||||
|
||||
#ifdef NSIS_SCRIPT
|
||||
static CCommandPair kCommandPairs[] =
|
||||
{
|
||||
{ 0, "Invalid" },
|
||||
@@ -324,6 +327,7 @@ static CCommandPair kCommandPairs[] =
|
||||
{ 6, "LockWindow" }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static const char *kShellStrings[] =
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "../../Common/FilterCoder.h"
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
#include "../../Crypto/Rar20/Rar20Cipher.h"
|
||||
|
||||
@@ -18,7 +18,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
@@ -17,8 +17,6 @@ extern "C"
|
||||
namespace NArchive {
|
||||
namespace NRar {
|
||||
|
||||
static const char kEndOfString = '\0';
|
||||
|
||||
void CInArchive::ThrowExceptionWithCode(
|
||||
CInArchiveException::CCauseType cause)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
kUnexpectedEndOfArchive = 0,
|
||||
kArchiveHeaderCRCError,
|
||||
kFileHeaderCRCError,
|
||||
kIncorrectArchive,
|
||||
kIncorrectArchive
|
||||
}
|
||||
Cause;
|
||||
CInArchiveException(CCauseType cause) : Cause(cause) {}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IInArchiveGetStream)
|
||||
MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -14,7 +14,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
|
||||
STDMETHOD(Open)(IInStream *stream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
|
||||
@@ -166,12 +166,14 @@ HRESULT CAddCommon::Compress(
|
||||
{
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
_options.Algo,
|
||||
_options.NumPasses,
|
||||
_options.NumFastBytes,
|
||||
_options.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kAlgorithm,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumFastBytes,
|
||||
NCoderPropID::kMatchFinderCycles
|
||||
|
||||
@@ -13,6 +13,7 @@ struct CCompressionMethodMode
|
||||
{
|
||||
CRecordVector<Byte> MethodSequence;
|
||||
// bool MaximizeRatio;
|
||||
UInt32 Algo;
|
||||
UInt32 NumPasses;
|
||||
UInt32 NumFastBytes;
|
||||
bool NumMatchFinderCyclesDefined;
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
static const CMethodId kMethodId_Store = 0;
|
||||
// static const CMethodId kMethodId_Store = 0;
|
||||
static const CMethodId kMethodId_ZipBase = 0x040100;
|
||||
static const CMethodId kMethodId_BZip2 = 0x040202;
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_QUERYINTERFACE_BEGIN
|
||||
MY_QUERYINTERFACE_ENTRY(IInArchive)
|
||||
MY_QUERYINTERFACE_BEGIN2(IInArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(IOutArchive)
|
||||
MY_QUERYINTERFACE_ENTRY(ISetProperties)
|
||||
QUERY_ENTRY_ISetCompressCodecsInfo
|
||||
@@ -73,6 +72,7 @@ private:
|
||||
int m_Level;
|
||||
int m_MainMethod;
|
||||
UInt32 m_DicSize;
|
||||
UInt32 m_Algo;
|
||||
UInt32 m_NumPasses;
|
||||
UInt32 m_NumFastBytes;
|
||||
UInt32 m_NumMatchFinderCycles;
|
||||
@@ -91,6 +91,7 @@ private:
|
||||
{
|
||||
m_Level = -1;
|
||||
m_MainMethod = -1;
|
||||
m_Algo =
|
||||
m_DicSize =
|
||||
m_NumPasses =
|
||||
m_NumFastBytes =
|
||||
|
||||
@@ -24,6 +24,9 @@ using namespace NTime;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
static const UInt32 kDeflateAlgoX1 = 0;
|
||||
static const UInt32 kDeflateAlgoX5 = 1;
|
||||
|
||||
static const UInt32 kDeflateNumPassesX1 = 1;
|
||||
static const UInt32 kDeflateNumPassesX7 = 3;
|
||||
static const UInt32 kDeflateNumPassesX9 = 10;
|
||||
@@ -238,6 +241,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.NumFastBytes = m_NumFastBytes;
|
||||
options.NumMatchFinderCycles = m_NumMatchFinderCycles;
|
||||
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
|
||||
options.Algo = m_Algo;
|
||||
#ifdef COMPRESS_MT
|
||||
options.NumThreads = _numThreads;
|
||||
#endif
|
||||
@@ -251,6 +255,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
|
||||
(level >= 7 ? kNumFastBytesX7 :
|
||||
kNumFastBytesX1));
|
||||
if (options.Algo == 0xFFFFFFFF)
|
||||
options.Algo =
|
||||
(level >= 5 ? kDeflateAlgoX5 :
|
||||
kDeflateAlgoX1);
|
||||
}
|
||||
if (isBZip2)
|
||||
{
|
||||
@@ -386,6 +394,12 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
|
||||
#endif
|
||||
}
|
||||
else if (name.Left(1) == L"A")
|
||||
{
|
||||
UInt32 num = kDeflateAlgoX5;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, num));
|
||||
m_Algo = num;
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ bool CLocalItem::IsImplodeLiteralsOn() const
|
||||
return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
|
||||
}
|
||||
|
||||
static const char *kUnknownAttributes = "Unknown file attributes";
|
||||
|
||||
bool CLocalItem::IsDirectory() const
|
||||
{
|
||||
return NItemName::HasTailSlash(Name, GetCodePage());
|
||||
|
||||
@@ -30,16 +30,6 @@ using namespace NSynchronization;
|
||||
namespace NArchive {
|
||||
namespace NZip {
|
||||
|
||||
class CCriticalSectionLock2
|
||||
{
|
||||
CCriticalSection *_object;
|
||||
void Unlock() { if (_object != 0) _object->Leave(); }
|
||||
public:
|
||||
CCriticalSectionLock2(): _object(0) {}
|
||||
void Set(CCriticalSection &object) { _object = &object; _object->Enter(); }
|
||||
~CCriticalSectionLock2() { Unlock(); }
|
||||
};
|
||||
|
||||
static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
|
||||
static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
|
||||
|
||||
@@ -135,7 +125,7 @@ static void SetItemInfoFromCompressingResult(const CCompressingResult &compressi
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo);
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo);
|
||||
|
||||
struct CThreadInfo
|
||||
{
|
||||
@@ -145,8 +135,8 @@ struct CThreadInfo
|
||||
#endif
|
||||
|
||||
NWindows::CThread Thread;
|
||||
CAutoResetEvent *CompressEvent;
|
||||
CAutoResetEvent *CompressionCompletedEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressEvent;
|
||||
NWindows::NSynchronization::CAutoResetEvent CompressionCompletedEvent;
|
||||
bool ExitThread;
|
||||
|
||||
CMtCompressProgress *ProgressSpec;
|
||||
@@ -164,21 +154,18 @@ struct CThreadInfo
|
||||
UInt32 UpdateIndex;
|
||||
|
||||
CThreadInfo(const CCompressionMethodMode &options):
|
||||
CompressEvent(NULL),
|
||||
CompressionCompletedEvent(NULL),
|
||||
ExitThread(false),
|
||||
ProgressSpec(0),
|
||||
OutStreamSpec(0),
|
||||
Coder(options)
|
||||
{}
|
||||
|
||||
void CreateEvents()
|
||||
HRESULT CreateEvents()
|
||||
{
|
||||
CompressEvent = new CAutoResetEvent(false);
|
||||
CompressionCompletedEvent = new CAutoResetEvent(false);
|
||||
RINOK(CompressEvent.CreateIfNotCreated());
|
||||
return CompressionCompletedEvent.CreateIfNotCreated();
|
||||
}
|
||||
bool CreateThread() { return Thread.Create(CoderThread, this); }
|
||||
~CThreadInfo();
|
||||
HRes CreateThread() { return Thread.Create(CoderThread, this); }
|
||||
|
||||
void WaitAndCode();
|
||||
void StopWaitClose()
|
||||
@@ -186,27 +173,19 @@ struct CThreadInfo
|
||||
ExitThread = true;
|
||||
if (OutStreamSpec != 0)
|
||||
OutStreamSpec->StopWriting(E_ABORT);
|
||||
if (CompressEvent != NULL)
|
||||
CompressEvent->Set();
|
||||
if (CompressEvent.IsCreated())
|
||||
CompressEvent.Set();
|
||||
Thread.Wait();
|
||||
Thread.Close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CThreadInfo::~CThreadInfo()
|
||||
{
|
||||
if (CompressEvent != NULL)
|
||||
delete CompressEvent;
|
||||
if (CompressionCompletedEvent != NULL)
|
||||
delete CompressionCompletedEvent;
|
||||
}
|
||||
|
||||
void CThreadInfo::WaitAndCode()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
CompressEvent->Lock();
|
||||
CompressEvent.Lock();
|
||||
if (ExitThread)
|
||||
return;
|
||||
Result = Coder.Compress(
|
||||
@@ -216,11 +195,11 @@ void CThreadInfo::WaitAndCode()
|
||||
InStream, OutStream, Progress, CompressingResult);
|
||||
if (Result == S_OK && Progress)
|
||||
Result = Progress->SetRatioInfo(&CompressingResult.UnpackSize, &CompressingResult.PackSize);
|
||||
CompressionCompletedEvent->Set();
|
||||
CompressionCompletedEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
|
||||
{
|
||||
((CThreadInfo *)threadCoderInfo)->WaitAndCode();
|
||||
return 0;
|
||||
@@ -518,8 +497,7 @@ static HRESULT Update2(
|
||||
CRecordVector<int> threadIndices; // list threads in order of updateItems
|
||||
|
||||
{
|
||||
if (!memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)))
|
||||
return E_OUTOFMEMORY;
|
||||
RINOK(memManager.AllocateSpaceAlways((size_t)numThreads * (kMemPerThread / kBlockSize)));
|
||||
for(i = 0; i < updateItems.Size(); i++)
|
||||
refs.Refs.Add(CMemBlocks2());
|
||||
|
||||
@@ -534,15 +512,15 @@ static HRESULT Update2(
|
||||
threadInfo._codecsInfo = codecsInfo;
|
||||
threadInfo._externalCodecs = externalCodecs;
|
||||
#endif
|
||||
threadInfo.CreateEvents();
|
||||
RINOK(threadInfo.CreateEvents());
|
||||
threadInfo.OutStreamSpec = new COutMemStream(&memManager);
|
||||
RINOK(threadInfo.OutStreamSpec->CreateEvents());
|
||||
threadInfo.OutStream = threadInfo.OutStreamSpec;
|
||||
threadInfo.IsFree = true;
|
||||
threadInfo.ProgressSpec = new CMtCompressProgress();
|
||||
threadInfo.Progress = threadInfo.ProgressSpec;
|
||||
threadInfo.ProgressSpec->Init(&mtCompressProgressMixer, (int)i);
|
||||
if (!threadInfo.CreateThread())
|
||||
return ::GetLastError();
|
||||
RINOK(threadInfo.CreateThread());
|
||||
}
|
||||
}
|
||||
int mtItemIndex = 0;
|
||||
@@ -601,10 +579,10 @@ static HRESULT Update2(
|
||||
|
||||
threadInfo.OutStreamSpec->Init();
|
||||
threadInfo.ProgressSpec->Reinit();
|
||||
threadInfo.CompressEvent->Set();
|
||||
threadInfo.CompressEvent.Set();
|
||||
threadInfo.UpdateIndex = mtItemIndex - 1;
|
||||
|
||||
compressingCompletedEvents.Add(*threadInfo.CompressionCompletedEvent);
|
||||
compressingCompletedEvents.Add(threadInfo.CompressionCompletedEvent);
|
||||
threadIndices.Add(i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ CRYPTO_HASH_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_BRANCH_OBJS = \
|
||||
$O\BranchARM.obj \
|
||||
|
||||
@@ -95,7 +95,8 @@ LZMA_OPT_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\7zCrc.obj
|
||||
$O\7zCrc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_BRANCH_OBJS = \
|
||||
$O\BranchARM.obj \
|
||||
|
||||
@@ -236,6 +236,10 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
|
||||
|
||||
SOURCE=..\..\..\Windows\Synchronization.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Thread.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Compress"
|
||||
|
||||
@@ -785,14 +789,6 @@ SOURCE=..\..\Compress\Quantum\QuantumDecoder.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzh\Lzh1Decoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzh\Lzh1Decoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\Lzh\LzhDecoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -2346,5 +2342,61 @@ SOURCE=..\..\IPassword.h
|
||||
SOURCE=..\..\IProgress.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Arj\arj.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\BZip2\bz2.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Cab\cab.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Cpio\cpio.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Deb\deb.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\GZip\gz.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Iso\Iso.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Lzh\lzh.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Rar\rar.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\RPM\rpm.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Split\Split.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Tar\tar.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Z\Z.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Zip\zip.ico
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -123,9 +123,7 @@ static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
|
||||
// static const bool kTestExtractRecursedDefault = true;
|
||||
// static const bool kAddRecursedDefault = false;
|
||||
|
||||
static const int kMaxCmdLineSize = 1000;
|
||||
static const wchar_t *kUniversalWildcard = L"*";
|
||||
// static const int kMinNonSwitchWords = 1;
|
||||
static const int kCommandIndex = 0;
|
||||
|
||||
static const char *kHelpString =
|
||||
@@ -416,13 +414,19 @@ int Main2(
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt64 numErrors = 0;
|
||||
HRESULT result = ListArchives(
|
||||
codecs,
|
||||
v1, v2,
|
||||
wildcardCensorHead,
|
||||
true, false,
|
||||
passwordEnabled,
|
||||
password);
|
||||
password, numErrors);
|
||||
if (numErrors > 0)
|
||||
{
|
||||
g_StdOut << endl << "Errors: " << numErrors;
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ LINK32=link.exe
|
||||
# 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 /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -125,14 +125,6 @@ SOURCE=..\..\Archive\Common\CoderMixer2MT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CoderMixer2ST.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CoderMixer2ST.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\CrossThreadProgress.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -801,6 +793,15 @@ SOURCE=..\..\..\..\C\Alloc.c
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.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
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ CRYPTO_HASH_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_BRANCH_OBJS = \
|
||||
$O\BranchX86.obj \
|
||||
|
||||
@@ -40,7 +40,7 @@ struct CThreadExtracting
|
||||
ExtractCallbackSpec->ProgressDialog.MyClose();
|
||||
return 0;
|
||||
}
|
||||
static DWORD WINAPI MyThreadFunction(void *param)
|
||||
static THREAD_FUNC_DECL MyThreadFunction(void *param)
|
||||
{
|
||||
return ((CThreadExtracting *)param)->Process();
|
||||
}
|
||||
@@ -115,9 +115,8 @@ HRESULT ExtractArchive(
|
||||
|
||||
if (showProgress)
|
||||
{
|
||||
CThread thread;
|
||||
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter))
|
||||
throw 271824;
|
||||
NWindows::CThread thread;
|
||||
RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
|
||||
|
||||
UString title;
|
||||
#ifdef LANG
|
||||
|
||||
@@ -710,6 +710,15 @@ SOURCE=..\..\..\..\C\Alloc.c
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.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
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ LZMA_OPT_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_BRANCH_OBJS = \
|
||||
$O\BranchX86.obj \
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Archive/IArchive.h"
|
||||
#include "../../UI/Common/Extract.h"
|
||||
#include "../../UI/Common/ExitCode.h"
|
||||
#include "../../UI/Explorer/MyMessages.h"
|
||||
#include "../../UI/GUI/ExtractGUI.h"
|
||||
|
||||
@@ -31,13 +32,11 @@ static inline bool IsItWindowsNT()
|
||||
}
|
||||
#endif
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */)
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
static const wchar_t *kMemoryExceptionMessage = L"ERROR: Can't allocate required memory!";
|
||||
static const wchar_t *kUnknownExceptionMessage = L"ERROR: Unknown Error!";
|
||||
|
||||
int APIENTRY WinMain2()
|
||||
{
|
||||
UString password;
|
||||
bool assumeYes = false;
|
||||
bool outputFolderDefined = false;
|
||||
@@ -116,9 +115,38 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
|
||||
outputFolderDefined ? outputFolder :
|
||||
fullPath.Left(fileNamePartStartIndex));
|
||||
*/
|
||||
if (result == S_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (result == E_ABORT)
|
||||
return NExitCode::kUserBreak;
|
||||
if (result == S_FALSE)
|
||||
MyMessageBox(L"Archive is not supported");
|
||||
else if (result != S_OK && result != E_ABORT)
|
||||
MyMessageBox(L"Error in archive");
|
||||
else
|
||||
ShowErrorMessage(0, result);
|
||||
return 0;
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */)
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
#ifndef _UNICODE
|
||||
g_IsNT = IsItWindowsNT();
|
||||
#endif
|
||||
try
|
||||
{
|
||||
return WinMain2();
|
||||
}
|
||||
catch(const CNewException &)
|
||||
{
|
||||
MyMessageBox(kMemoryExceptionMessage);
|
||||
return (NExitCode::kMemoryError);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
MyMessageBox(kUnknownExceptionMessage);
|
||||
return NExitCode::kFatalError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_SFXWIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "NO_READ_FROM_CODER" /D "_SFX" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_SFXWIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "NO_READ_FROM_CODER" /D "_SFX" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
@@ -712,6 +712,14 @@ SOURCE=..\..\..\Common\IntToString.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\String.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -881,6 +889,15 @@ SOURCE=..\..\..\..\C\Alloc.c
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.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
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ CRYPTO_HASH_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
C_BRANCH_OBJS = \
|
||||
$O\BranchX86.obj \
|
||||
|
||||
@@ -25,7 +25,7 @@ bool CInFileStream::Open(LPCTSTR fileName)
|
||||
return File.Open(fileName);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool CInFileStream::Open(LPCWSTR fileName)
|
||||
{
|
||||
@@ -34,9 +34,23 @@ bool CInFileStream::Open(LPCWSTR fileName)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool CInFileStream::OpenShared(LPCTSTR fileName, bool shareForWrite)
|
||||
{
|
||||
return File.OpenShared(fileName, shareForWrite);
|
||||
}
|
||||
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool CInFileStream::OpenShared(LPCWSTR fileName, bool shareForWrite)
|
||||
{
|
||||
return File.OpenShared(fileName, shareForWrite);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
|
||||
UInt32 realProcessedSize;
|
||||
bool result = File.ReadPart(data, size, realProcessedSize);
|
||||
@@ -98,7 +112,7 @@ STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
|
||||
if(seekOrigin >= 3)
|
||||
return STG_E_INVALIDFUNCTION;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
|
||||
UInt64 realNewPosition;
|
||||
bool result = File.Seek(offset, seekOrigin, realNewPosition);
|
||||
@@ -132,7 +146,7 @@ bool COutFileStream::Create(LPCTSTR fileName, bool createAlways)
|
||||
return File.Create(fileName, createAlways);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool COutFileStream::Create(LPCWSTR fileName, bool createAlways)
|
||||
{
|
||||
@@ -143,7 +157,7 @@ bool COutFileStream::Create(LPCWSTR fileName, bool createAlways)
|
||||
|
||||
STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
|
||||
UInt32 realProcessedSize;
|
||||
bool result = File.WritePart(data, size, realProcessedSize);
|
||||
@@ -170,7 +184,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin,
|
||||
{
|
||||
if(seekOrigin >= 3)
|
||||
return STG_E_INVALIDFUNCTION;
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
|
||||
UInt64 realNewPosition;
|
||||
bool result = File.Seek(offset, seekOrigin, realNewPosition);
|
||||
@@ -192,7 +206,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin,
|
||||
|
||||
STDMETHODIMP COutFileStream::SetSize(Int64 newSize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
UInt64 currentPos;
|
||||
if(!File.Seek(0, FILE_CURRENT, currentPos))
|
||||
return E_FAIL;
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
#define __FILESTREAMS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define USE_WIN_FILE
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIN_FILE
|
||||
#include "../../Windows/FileIO.h"
|
||||
#else
|
||||
#include "../../Common/C_FileIO.h"
|
||||
@@ -18,7 +22,7 @@ class CInFileStream:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
NWindows::NFile::NIO::CInFile File;
|
||||
#else
|
||||
NC::NFile::NIO::CInFile File;
|
||||
@@ -27,12 +31,19 @@ public:
|
||||
virtual ~CInFileStream() {}
|
||||
|
||||
bool Open(LPCTSTR fileName);
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool Open(LPCWSTR fileName);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool OpenShared(LPCTSTR fileName, bool shareForWrite);
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool OpenShared(LPCWSTR fileName, bool shareForWrite);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
@@ -62,14 +73,14 @@ class COutFileStream:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
NWindows::NFile::NIO::COutFile File;
|
||||
#else
|
||||
NC::NFile::NIO::COutFile File;
|
||||
#endif
|
||||
virtual ~COutFileStream() {}
|
||||
bool Create(LPCTSTR fileName, bool createAlways);
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WIN_FILE
|
||||
#ifndef _UNICODE
|
||||
bool Create(LPCWSTR fileName, bool createAlways);
|
||||
#endif
|
||||
|
||||
@@ -108,13 +108,13 @@ HRESULT CInMemStreamMt::Read()
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD WINAPI CoderThread(void *threadCoderInfo)
|
||||
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
|
||||
{
|
||||
((CInMemStreamMt *)threadCoderInfo)->ReadResult = ((CInMemStreamMt *)threadCoderInfo)->Read();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CInMemStreamMt::StartReadThread()
|
||||
HRes CInMemStreamMt::StartReadThread()
|
||||
{
|
||||
// _stopReading = false;
|
||||
NWindows::CThread Thread;
|
||||
|
||||
@@ -82,11 +82,12 @@ class CResourceListMt: public CResourceList
|
||||
public:
|
||||
NWindows::NSynchronization::CSemaphore Semaphore;
|
||||
|
||||
bool AllocateList(int numItems)
|
||||
HRes AllocateList(int numItems)
|
||||
{
|
||||
if (!CResourceList::AllocateList(numItems))
|
||||
return false;
|
||||
return Semaphore.Create((LONG)numItems, (LONG)numItems);
|
||||
Semaphore.Close();
|
||||
return Semaphore.Create(numItems, numItems);
|
||||
}
|
||||
|
||||
int AllocateItem()
|
||||
@@ -118,15 +119,15 @@ public:
|
||||
CIntQueueMt(): _numItems(0), _head(0), _cur(0) {}
|
||||
NWindows::NSynchronization::CSemaphore Semaphore;
|
||||
|
||||
bool AllocateList(int numItems)
|
||||
HRes AllocateList(int numItems)
|
||||
{
|
||||
FreeList();
|
||||
if (numItems == 0)
|
||||
return true;
|
||||
return S_OK;
|
||||
if (!CIntListCheck::AllocateList(numItems))
|
||||
return false;
|
||||
return E_OUTOFMEMORY;
|
||||
_numItems = numItems;
|
||||
return Semaphore.Create((LONG)0, (LONG)numItems);
|
||||
return Semaphore.Create(0, numItems);
|
||||
}
|
||||
|
||||
void FreeList()
|
||||
@@ -142,10 +143,8 @@ public:
|
||||
_data[_head++] = value;
|
||||
if (_head == _numItems)
|
||||
_head = 0;
|
||||
LONG previousCount;
|
||||
Semaphore.Release(1, &previousCount);
|
||||
Semaphore.Release();
|
||||
// printf("\nRelease prev = %d\n", previousCount);
|
||||
|
||||
}
|
||||
|
||||
int GetItem()
|
||||
@@ -253,7 +252,7 @@ public:
|
||||
// to stop reading you must implement
|
||||
// returning Error in IInMemStreamMtCallback::AllocateBlock
|
||||
// and then you must free at least one substream
|
||||
bool StartReadThread();
|
||||
HRes StartReadThread();
|
||||
|
||||
void Free();
|
||||
|
||||
|
||||
@@ -8,22 +8,4 @@
|
||||
namespace NStream {
|
||||
namespace NLSBF {
|
||||
|
||||
void CEncoder::WriteBits(UInt32 value, int numBits)
|
||||
{
|
||||
while(numBits > 0)
|
||||
{
|
||||
if (numBits < m_BitPos)
|
||||
{
|
||||
m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
|
||||
m_BitPos -= numBits;
|
||||
return;
|
||||
}
|
||||
numBits -= m_BitPos;
|
||||
m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
|
||||
value >>= m_BitPos;
|
||||
m_BitPos = 8;
|
||||
m_CurByte = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -38,7 +38,23 @@ public:
|
||||
m_CurByte = 0;
|
||||
}
|
||||
|
||||
void WriteBits(UInt32 value, int numBits);
|
||||
void WriteBits(UInt32 value, int numBits)
|
||||
{
|
||||
while(numBits > 0)
|
||||
{
|
||||
if (numBits < m_BitPos)
|
||||
{
|
||||
m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
|
||||
m_BitPos -= numBits;
|
||||
return;
|
||||
}
|
||||
numBits -= m_BitPos;
|
||||
m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
|
||||
value >>= m_BitPos;
|
||||
m_BitPos = 8;
|
||||
m_CurByte = 0;
|
||||
}
|
||||
}
|
||||
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
|
||||
UInt64 GetProcessedSize() const {
|
||||
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
|
||||
|
||||
@@ -51,26 +51,27 @@ void CMemBlockManager::FreeBlock(void *p)
|
||||
}
|
||||
|
||||
|
||||
bool CMemBlockManagerMt::AllocateSpace(size_t numBlocks, size_t numNoLockBlocks)
|
||||
HRes CMemBlockManagerMt::AllocateSpace(size_t numBlocks, size_t numNoLockBlocks)
|
||||
{
|
||||
if (numNoLockBlocks > numBlocks)
|
||||
return false;
|
||||
return E_INVALIDARG;
|
||||
if (!CMemBlockManager::AllocateSpace(numBlocks))
|
||||
return false;
|
||||
return E_OUTOFMEMORY;
|
||||
size_t numLockBlocks = numBlocks - numNoLockBlocks;
|
||||
Semaphore.Close();
|
||||
return Semaphore.Create((LONG)numLockBlocks, (LONG)numLockBlocks);
|
||||
}
|
||||
|
||||
bool CMemBlockManagerMt::AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks)
|
||||
HRes CMemBlockManagerMt::AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks)
|
||||
{
|
||||
if (numNoLockBlocks > desiredNumberOfBlocks)
|
||||
return false;
|
||||
return E_INVALIDARG;
|
||||
for (;;)
|
||||
{
|
||||
if (AllocateSpace(desiredNumberOfBlocks, numNoLockBlocks))
|
||||
return true;
|
||||
if (AllocateSpace(desiredNumberOfBlocks, numNoLockBlocks) == 0)
|
||||
return 0;
|
||||
if (desiredNumberOfBlocks == numNoLockBlocks)
|
||||
return false;
|
||||
return E_OUTOFMEMORY;
|
||||
desiredNumberOfBlocks = numNoLockBlocks + ((desiredNumberOfBlocks - numNoLockBlocks) >> 1);
|
||||
}
|
||||
}
|
||||
@@ -152,16 +153,17 @@ void CMemLockBlocks::Free(CMemBlockManagerMt *memManager)
|
||||
TotalSize = 0;
|
||||
}
|
||||
|
||||
bool CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
|
||||
HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
|
||||
{
|
||||
if (LockMode)
|
||||
{
|
||||
if (Blocks.Size() > 0)
|
||||
if (!memManager->ReleaseLockedBlocks(Blocks.Size()))
|
||||
return false;
|
||||
{
|
||||
RINOK(memManager->ReleaseLockedBlocks(Blocks.Size()));
|
||||
}
|
||||
LockMode = false;
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMemLockBlocks::Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager)
|
||||
|
||||
@@ -41,12 +41,12 @@ public:
|
||||
CMemBlockManagerMt(size_t blockSize = (1 << 20)): CMemBlockManager(blockSize) {}
|
||||
~CMemBlockManagerMt() { FreeSpace(); }
|
||||
|
||||
bool AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0);
|
||||
bool AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
|
||||
HRes AllocateSpace(size_t numBlocks, size_t numNoLockBlocks = 0);
|
||||
HRes AllocateSpaceAlways(size_t desiredNumberOfBlocks, size_t numNoLockBlocks = 0);
|
||||
void FreeSpace();
|
||||
void *AllocateBlock();
|
||||
void FreeBlock(void *p, bool lockMode = true);
|
||||
bool ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
|
||||
HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ struct CMemLockBlocks: public CMemBlocks
|
||||
CMemLockBlocks(): LockMode(true) {};
|
||||
void Free(CMemBlockManagerMt *memManager);
|
||||
void FreeBlock(int index, CMemBlockManagerMt *memManager);
|
||||
bool SwitchToNoLockMode(CMemBlockManagerMt *memManager);
|
||||
HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
|
||||
void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// MethodID.cpp
|
||||
// MethodId.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "MethodID.h"
|
||||
#include "MethodId.h"
|
||||
#include "../../Common/String.h"
|
||||
|
||||
static inline wchar_t GetHex(Byte value)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// MethodID.h
|
||||
// MethodId.h
|
||||
|
||||
#ifndef __7Z_METHOD_ID_H
|
||||
#define __7Z_METHOD_ID_H
|
||||
|
||||
@@ -30,6 +30,12 @@ class COutMemStream:
|
||||
|
||||
public:
|
||||
|
||||
HRes CreateEvents()
|
||||
{
|
||||
RINOK(StopWritingEvent.CreateIfNotCreated());
|
||||
return WriteToRealStreamEvent.CreateIfNotCreated();
|
||||
}
|
||||
|
||||
void SetOutStream(IOutStream *outStream)
|
||||
{
|
||||
OutStream = outStream;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __REGISTERCODEC_H
|
||||
#define __REGISTERCODEC_H
|
||||
|
||||
#include "../Common/MethodID.h"
|
||||
#include "../Common/MethodId.h"
|
||||
|
||||
typedef void * (*CreateCodecP)();
|
||||
struct CCodecInfo
|
||||
|
||||
@@ -51,31 +51,20 @@ STDMETHODIMP CSequentialOutStreamForBinder::Write(const void *data, UInt32 size,
|
||||
// CStreamBinder
|
||||
// (_thereAreBytesToReadEvent && _bufferSize == 0) means that stream is finished.
|
||||
|
||||
void CStreamBinder::CreateEvents()
|
||||
HRes CStreamBinder::CreateEvents()
|
||||
{
|
||||
_allBytesAreWritenEvent = new CManualResetEvent(true);
|
||||
_thereAreBytesToReadEvent = new CManualResetEvent(false);
|
||||
_readStreamIsClosedEvent = new CManualResetEvent(false);
|
||||
RINOK(_allBytesAreWritenEvent.Create(true));
|
||||
RINOK(_thereAreBytesToReadEvent.Create());
|
||||
return _readStreamIsClosedEvent.Create();
|
||||
}
|
||||
|
||||
void CStreamBinder::ReInit()
|
||||
{
|
||||
_thereAreBytesToReadEvent->Reset();
|
||||
_readStreamIsClosedEvent->Reset();
|
||||
_thereAreBytesToReadEvent.Reset();
|
||||
_readStreamIsClosedEvent.Reset();
|
||||
ProcessedSize = 0;
|
||||
}
|
||||
|
||||
CStreamBinder::~CStreamBinder()
|
||||
{
|
||||
if (_allBytesAreWritenEvent != NULL)
|
||||
delete _allBytesAreWritenEvent;
|
||||
if (_thereAreBytesToReadEvent != NULL)
|
||||
delete _thereAreBytesToReadEvent;
|
||||
if (_readStreamIsClosedEvent != NULL)
|
||||
delete _readStreamIsClosedEvent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
|
||||
@@ -103,8 +92,7 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
UInt32 sizeToRead = size;
|
||||
if (size > 0)
|
||||
{
|
||||
if(!_thereAreBytesToReadEvent->Lock())
|
||||
return E_FAIL;
|
||||
RINOK(_thereAreBytesToReadEvent.Lock());
|
||||
sizeToRead = MyMin(_bufferSize, size);
|
||||
if (_bufferSize > 0)
|
||||
{
|
||||
@@ -113,8 +101,8 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
_bufferSize -= sizeToRead;
|
||||
if (_bufferSize == 0)
|
||||
{
|
||||
_thereAreBytesToReadEvent->Reset();
|
||||
_allBytesAreWritenEvent->Set();
|
||||
_thereAreBytesToReadEvent.Reset();
|
||||
_allBytesAreWritenEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +114,7 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
|
||||
void CStreamBinder::CloseRead()
|
||||
{
|
||||
_readStreamIsClosedEvent->Set();
|
||||
_readStreamIsClosedEvent.Set();
|
||||
}
|
||||
|
||||
HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
@@ -135,12 +123,12 @@ HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSiz
|
||||
{
|
||||
_buffer = data;
|
||||
_bufferSize = size;
|
||||
_allBytesAreWritenEvent->Reset();
|
||||
_thereAreBytesToReadEvent->Set();
|
||||
_allBytesAreWritenEvent.Reset();
|
||||
_thereAreBytesToReadEvent.Set();
|
||||
|
||||
HANDLE events[2];
|
||||
events[0] = *_allBytesAreWritenEvent;
|
||||
events[1] = *_readStreamIsClosedEvent;
|
||||
events[0] = _allBytesAreWritenEvent;
|
||||
events[1] = _readStreamIsClosedEvent;
|
||||
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
|
||||
if (waitResult != WAIT_OBJECT_0 + 0)
|
||||
{
|
||||
@@ -158,5 +146,5 @@ HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSiz
|
||||
void CStreamBinder::CloseWrite()
|
||||
{
|
||||
// _bufferSize must be = 0
|
||||
_thereAreBytesToReadEvent->Set();
|
||||
_thereAreBytesToReadEvent.Set();
|
||||
}
|
||||
|
||||
@@ -8,21 +8,16 @@
|
||||
|
||||
class CStreamBinder
|
||||
{
|
||||
NWindows::NSynchronization::CManualResetEvent *_allBytesAreWritenEvent;
|
||||
NWindows::NSynchronization::CManualResetEvent *_thereAreBytesToReadEvent;
|
||||
NWindows::NSynchronization::CManualResetEvent *_readStreamIsClosedEvent;
|
||||
NWindows::NSynchronization::CManualResetEvent _allBytesAreWritenEvent;
|
||||
NWindows::NSynchronization::CManualResetEvent _thereAreBytesToReadEvent;
|
||||
NWindows::NSynchronization::CManualResetEvent _readStreamIsClosedEvent;
|
||||
UInt32 _bufferSize;
|
||||
const void *_buffer;
|
||||
public:
|
||||
// bool ReadingWasClosed;
|
||||
UInt64 ProcessedSize;
|
||||
CStreamBinder():
|
||||
_allBytesAreWritenEvent(NULL),
|
||||
_thereAreBytesToReadEvent(NULL),
|
||||
_readStreamIsClosedEvent(NULL)
|
||||
{}
|
||||
~CStreamBinder();
|
||||
void CreateEvents();
|
||||
CStreamBinder() {}
|
||||
HRes CreateEvents();
|
||||
|
||||
void CreateStreams(ISequentialInStream **inStream,
|
||||
ISequentialOutStream **outStream);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
CState &ti = m_States[t];
|
||||
ti.Decoder = this;
|
||||
if (MtMode)
|
||||
if (!ti.Thread.Create(MFThread, &ti))
|
||||
{
|
||||
NumThreads = t;
|
||||
Free();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
catch(...) { return false; }
|
||||
return true;
|
||||
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)
|
||||
{
|
||||
HRes res = ti.Thread.Create(MFThread, &ti);
|
||||
if (res != S_OK)
|
||||
{
|
||||
NumThreads = t;
|
||||
Free();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
#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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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 (;;)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,10 +5,28 @@
|
||||
#include "LzmaBench.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <time.h>
|
||||
#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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace NCompress {
|
||||
namespace NQuantum {
|
||||
|
||||
const UInt32 kDictionarySizeMax = (1 << 21);
|
||||
// const UInt32 kDictionarySizeMax = (1 << 21);
|
||||
|
||||
const int kLenIdNeedInit = -2;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace NGlobalOffset
|
||||
const UInt32 kBlockPos = 0x20;
|
||||
const UInt32 kExecCount = 0x2C;
|
||||
const UInt32 kGlobalMemOutSize = 0x30;
|
||||
};
|
||||
}
|
||||
|
||||
enum ECommand
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
namespace NCrypto {
|
||||
namespace NRar20 {
|
||||
|
||||
static const int kBufferSize = 1 << 17;
|
||||
|
||||
STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
|
||||
{
|
||||
_coder.SetPassword(data, size);
|
||||
@@ -34,43 +32,4 @@ STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
UInt64 nowPos = 0;
|
||||
UInt32 bufferPos = 0;
|
||||
UInt32 processedSize;
|
||||
for (;;)
|
||||
{
|
||||
UInt32 size = kBufferSize - bufferPos;
|
||||
RINOK(inStream->Read(_buffer + bufferPos, size, &processedSize));
|
||||
|
||||
UInt32 anEndPos = bufferPos + processedSize;
|
||||
for (;bufferPos + 16 <= anEndPos; bufferPos += 16)
|
||||
_coder.DecryptBlock(_buffer + bufferPos);
|
||||
|
||||
if (bufferPos == 0)
|
||||
return S_OK;
|
||||
|
||||
if (outSize != NULL && nowPos + bufferPos > *outSize)
|
||||
bufferPos = UInt32(*outSize - nowPos);
|
||||
|
||||
RINOK(outStream->Write(_buffer, bufferPos, &processedSize));
|
||||
if (bufferPos != processedSize)
|
||||
return E_FAIL;
|
||||
|
||||
nowPos += processedSize;
|
||||
if (outSize != NULL && nowPos == *outSize)
|
||||
return S_OK;
|
||||
|
||||
int i = 0;
|
||||
while(bufferPos < anEndPos)
|
||||
_buffer[i++] = _buffer[bufferPos++];
|
||||
bufferPos = i;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "RarAES.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "../Hash/Sha1.h"
|
||||
#include "../AES/MyAES.h"
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user