mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 22:11:38 -06:00
4.34 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
02516d3fce
commit
0f60a4933b
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
@@ -70,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BZIP2_EXPORTS" /D "COMPRESS_MT" /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"
|
||||
@@ -216,6 +216,14 @@ SOURCE=..\Common\DummyOutStream.cpp
|
||||
|
||||
SOURCE=..\Common\DummyOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ParseProperties.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Engine"
|
||||
|
||||
|
||||
@@ -191,6 +191,16 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
{
|
||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||
decoder.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
|
||||
if (setCoderMt)
|
||||
{
|
||||
RINOK(setCoderMt->SetNumberOfThreads(_numThreads));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CDummyOutStream *outStreamSpec = new CDummyOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include "../IArchive.h"
|
||||
#include "BZip2Item.h"
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
#include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
@@ -20,8 +24,21 @@ class CHandler:
|
||||
NArchive::NBZip2::CItem _item;
|
||||
UInt64 _streamStartPosition;
|
||||
|
||||
UInt32 _level;
|
||||
UInt32 _dicSize;
|
||||
UInt32 _numPasses;
|
||||
void InitMethodProperties() { _numPasses = 1; }
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 _numThreads;
|
||||
#endif
|
||||
void InitMethodProperties()
|
||||
{
|
||||
_level = 5;
|
||||
_dicSize =
|
||||
_numPasses = 0xFFFFFFFF;
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP3(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// BZip2/OutHandler.cpp
|
||||
// BZip2HandlerOut.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
@@ -7,13 +7,23 @@
|
||||
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
|
||||
#include "../../Compress/Copy/CopyCoder.h"
|
||||
|
||||
#include "../Common/ParseProperties.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
static const UInt32 kNumPassesX1 = 1;
|
||||
static const UInt32 kNumPassesX7 = 2;
|
||||
static const UInt32 kNumPassesX9 = 7;
|
||||
|
||||
static const UInt32 kDicSizeX1 = 100000;
|
||||
static const UInt32 kDicSizeX3 = 500000;
|
||||
static const UInt32 kDicSizeX5 = 900000;
|
||||
|
||||
namespace NArchive {
|
||||
namespace NBZip2 {
|
||||
|
||||
@@ -69,7 +79,24 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
return E_INVALIDARG;
|
||||
size = propVariant.uhVal.QuadPart;
|
||||
}
|
||||
return UpdateArchive(size, outStream, 0, _numPasses, updateCallback);
|
||||
|
||||
UInt32 dicSize = _dicSize;
|
||||
if (dicSize == 0xFFFFFFFF)
|
||||
dicSize = (_level >= 5 ? kDicSizeX5 :
|
||||
(_level >= 3 ? kDicSizeX3 :
|
||||
kDicSizeX1));
|
||||
|
||||
UInt32 numPasses = _numPasses;
|
||||
if (numPasses == 0xFFFFFFFF)
|
||||
numPasses = (_level >= 9 ? kNumPassesX9 :
|
||||
(_level >= 7 ? kNumPassesX7 :
|
||||
kNumPassesX1));
|
||||
|
||||
return UpdateArchive(size, outStream, 0, dicSize, numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
_numThreads,
|
||||
#endif
|
||||
updateCallback);
|
||||
}
|
||||
if (indexInArchive != 0)
|
||||
return E_INVALIDARG;
|
||||
@@ -80,6 +107,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
|
||||
{
|
||||
InitMethodProperties();
|
||||
#ifdef COMPRESS_MT
|
||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
||||
_numThreads = numProcessors;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < numProperties; i++)
|
||||
{
|
||||
UString name = UString(names[i]);
|
||||
@@ -87,68 +119,34 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
|
||||
if (name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
const PROPVARIANT &value = values[i];
|
||||
const PROPVARIANT &prop = values[i];
|
||||
|
||||
if (name[0] == 'X')
|
||||
{
|
||||
name.Delete(0);
|
||||
UInt32 level = 9;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
level = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
level = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
if (level < 7)
|
||||
_numPasses = 1;
|
||||
else if (level < 9)
|
||||
_numPasses = 2;
|
||||
else
|
||||
_numPasses = 7;
|
||||
RINOK(ParsePropValue(name.Mid(1), prop, level));
|
||||
_level = level;
|
||||
continue;
|
||||
}
|
||||
else if (name.Left(4) == L"PASS")
|
||||
if (name[0] == 'D')
|
||||
{
|
||||
name.Delete(0, 4);
|
||||
UInt32 numPasses = 1;
|
||||
if (value.vt == VT_UI4)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
numPasses = value.ulVal;
|
||||
}
|
||||
else if (value.vt == VT_EMPTY)
|
||||
{
|
||||
if(!name.IsEmpty())
|
||||
{
|
||||
const wchar_t *start = name;
|
||||
const wchar_t *end;
|
||||
UInt64 v = ConvertStringToUInt64(start, &end);
|
||||
if (end - start != name.Length())
|
||||
return E_INVALIDARG;
|
||||
numPasses = (UInt32)v;
|
||||
}
|
||||
}
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (numPasses < 1 || numPasses > 10)
|
||||
return E_INVALIDARG;
|
||||
_numPasses = numPasses;
|
||||
UInt32 dicSize = kDicSizeX5;
|
||||
RINOK(ParsePropDictionaryValue(name.Mid(1), prop, dicSize));
|
||||
_dicSize = dicSize;
|
||||
continue;
|
||||
}
|
||||
if (name.Left(4) == L"PASS")
|
||||
{
|
||||
UInt32 num = kNumPassesX9;
|
||||
RINOK(ParsePropValue(name.Mid(4), prop, num));
|
||||
_numPasses = num;
|
||||
continue;
|
||||
}
|
||||
if (name.Left(2) == L"MT")
|
||||
{
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace NBZip2 {
|
||||
HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 dictionary,
|
||||
UInt32 numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 numThreads,
|
||||
#endif
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
RINOK(updateCallback->SetTotal(unpackSize));
|
||||
@@ -53,21 +57,23 @@ HRESULT UpdateArchive(UInt64 unpackSize,
|
||||
encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
|
||||
if (setCoderProperties)
|
||||
{
|
||||
/*
|
||||
NWindows::NCOM::CPropVariant properties[2] =
|
||||
NWindows::NCOM::CPropVariant properties[] =
|
||||
{
|
||||
dictionary, numPasses
|
||||
dictionary,
|
||||
numPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, numThreads
|
||||
#endif
|
||||
};
|
||||
PROPID propIDs[2] =
|
||||
PROPID propIDs[] =
|
||||
{
|
||||
NCoderPropID::kDictionarySize,
|
||||
NCoderPropID::kNumPasses,
|
||||
NCoderPropID::kNumPasses
|
||||
#ifdef COMPRESS_MT
|
||||
, NCoderPropID::kNumThreads
|
||||
#endif
|
||||
};
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, 2));
|
||||
*/
|
||||
NWindows::NCOM::CPropVariant property = numPasses;
|
||||
PROPID propID = NCoderPropID::kNumPasses;
|
||||
RINOK(setCoderProperties->SetCoderProperties(&propID, &property, 1));
|
||||
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, sizeof(propIDs) / sizeof(propIDs[0])));
|
||||
}
|
||||
|
||||
RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
|
||||
|
||||
@@ -12,7 +12,11 @@ HRESULT UpdateArchive(
|
||||
UInt64 unpackSize,
|
||||
ISequentialOutStream *outStream,
|
||||
int indexInClient,
|
||||
UInt32 dictionary,
|
||||
UInt32 numPasses,
|
||||
#ifdef COMPRESS_MT
|
||||
UInt32 numThreads,
|
||||
#endif
|
||||
IArchiveUpdateCallback *updateCallback);
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = bz2.dll
|
||||
DEF_FILE = ../Archive.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
|
||||
LIBS = $(LIBS) oleaut32.lib user32.lib
|
||||
|
||||
BZ2_OBJS = \
|
||||
@@ -27,6 +27,7 @@ WIN_OBJS = \
|
||||
AR_COMMON_OBJS = \
|
||||
$O\CodecsPath.obj \
|
||||
$O\DummyOutStream.obj \
|
||||
$O\ParseProperties.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
|
||||
Reference in New Issue
Block a user