4.46 beta

This commit is contained in:
Igor Pavlov
2007-05-25 00:00:00 +00:00
committed by Kornel Lesiński
parent a145bfc7cf
commit c574fc0f4b
191 changed files with 1318 additions and 854 deletions

View File

@@ -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

View File

@@ -13,6 +13,7 @@ struct CCompressionMethodMode
{
CRecordVector<Byte> MethodSequence;
// bool MaximizeRatio;
UInt32 Algo;
UInt32 NumPasses;
UInt32 NumFastBytes;
bool NumMatchFinderCyclesDefined;

View File

@@ -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;

View File

@@ -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 =

View File

@@ -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;
}

View File

@@ -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());

View File

@@ -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;
}