4.30 beta

This commit is contained in:
Igor Pavlov
2005-11-18 00:00:00 +00:00
committed by Kornel Lesiński
parent bcd1db2f5a
commit e18587ba51
214 changed files with 5385 additions and 2712 deletions

View File

@@ -18,9 +18,10 @@ static NArchive::N7z::CMethodID k_Copy = { { 0x0 }, 1 };
#include "../../Compress/Copy/CopyCoder.h"
#endif
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
#ifdef COMPRESS_LZMA
#include "../../Compress/LZMA/LZMAEncoder.h"
static NArchive::N7z::CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
#endif
#ifdef COMPRESS_PPMD
@@ -114,7 +115,7 @@ static void ConvertBindInfoToFolderItemInfo(const NCoderMixer2::CBindInfo &bindI
folder.PackStreams.Add(bindInfo.InStreams[i]);
}
HRESULT CEncoder::CreateMixerCoder()
HRESULT CEncoder::CreateMixerCoder(const UInt64 *inSizeForReduce)
{
_mixerCoderSpec = new NCoderMixer2::CCoderMixer2MT;
_mixerCoder = _mixerCoderSpec;
@@ -203,6 +204,30 @@ HRESULT CEncoder::CreateMixerCoder()
return E_FAIL;
#endif
}
bool tryReduce = false;
UInt32 reducedDictionarySize = 1 << 10;
if (inSizeForReduce != 0 && methodFull.MethodID == k_LZMA)
{
while (true)
{
const UInt32 step = (reducedDictionarySize >> 1);
if (reducedDictionarySize >= *inSizeForReduce)
{
tryReduce = true;
break;
}
reducedDictionarySize += step;
if (reducedDictionarySize >= *inSizeForReduce)
{
tryReduce = true;
break;
}
if (reducedDictionarySize >= ((UInt32)11 << 30))
break;
reducedDictionarySize += step;
}
}
if (methodFull.CoderProperties.Size() > 0)
{
@@ -215,7 +240,10 @@ HRESULT CEncoder::CreateMixerCoder()
{
const CProperty &property = methodFull.CoderProperties[i];
propIDs.Add(property.PropID);
values[i] = property.Value;
NWindows::NCOM::CPropVariant value = property.Value;
if (tryReduce && property.PropID == NCoderPropID::kDictionarySize && value.vt == VT_UI4 && reducedDictionarySize < value.ulVal)
value.ulVal = reducedDictionarySize;
values[i] = value;
}
CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
if (methodFull.IsSimpleCoder())
@@ -308,7 +336,7 @@ HRESULT CEncoder::CreateMixerCoder()
}
HRESULT CEncoder::Encode(ISequentialInStream *inStream,
const UInt64 *inStreamSize,
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem,
ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes,
@@ -316,7 +344,7 @@ HRESULT CEncoder::Encode(ISequentialInStream *inStream,
{
if (_mixerCoderSpec == NULL)
{
RINOK(CreateMixerCoder());
RINOK(CreateMixerCoder(inSizeForReduce));
}
_mixerCoderSpec->ReInit();
// _mixerCoderSpec->SetCoderInfo(0, NULL, NULL, progress);

View File

@@ -38,13 +38,13 @@ class CEncoder
NCoderMixer2::CBindReverseConverter *_bindReverseConverter;
CRecordVector<CMethodID> _decompressionMethods;
HRESULT CreateMixerCoder();
HRESULT CreateMixerCoder(const UInt64 *inSizeForReduce);
public:
CEncoder(const CCompressionMethodMode &options);
~CEncoder();
HRESULT Encode(ISequentialInStream *inStream,
const UInt64 *inStreamSize,
const UInt64 *inStreamSize, const UInt64 *inSizeForReduce,
CFolder &folderItem,
ISequentialOutStream *outStream,
CRecordVector<UInt64> &packSizes,

View File

@@ -81,7 +81,7 @@ const wchar_t *kDefaultMethodName = kLZMAMethodName;
static const wchar_t *kMatchFinderForHeaders = L"BT2";
static const UInt32 kDictionaryForHeaders = 1 << 20;
static const UInt32 kNumFastBytesForHeaders = 254;
static const UInt32 kNumFastBytesForHeaders = 273;
static bool IsLZMAMethod(const UString &methodName)
{ return (methodName.CompareNoCase(kLZMAMethodName) == 0); }

View File

@@ -576,8 +576,8 @@ HRESULT COutArchive::EncodeStream(CEncoder &encoder, const Byte *data, size_t da
CFolder folderItem;
folderItem.UnPackCRCDefined = true;
folderItem.UnPackCRC = CCRC::CalculateDigest(data, dataSize);
RINOK(encoder.Encode(stream, NULL, folderItem, SeqStream,
packSizes, NULL));
UInt64 dataSize64 = dataSize;
RINOK(encoder.Encode(stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL));
folders.Add(folderItem);
return S_OK;
}

View File

@@ -566,11 +566,21 @@ static HRESULT Update2(
UInt64 complexity = 0;
for(i = 0; i < folderRefs.Size(); i++)
complexity += database->GetFolderFullPackSize(folderRefs[i]);
UInt64 inSizeForReduce = 0;
for(i = 0; i < updateItems.Size(); i++)
{
const CUpdateItem &updateItem = updateItems[i];
if (updateItem.NewData)
{
complexity += updateItem.Size;
if (numSolidFiles == 1)
{
if (updateItem.Size > inSizeForReduce)
inSizeForReduce = updateItem.Size;
}
else
inSizeForReduce += updateItem.Size;
}
}
RINOK(updateCallback->SetTotal(complexity));
complexity = 0;
@@ -636,6 +646,10 @@ static HRESULT Update2(
SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
updateItems, groups);
const UInt32 kMinReduceSize = (1 << 16);
if (inSizeForReduce < kMinReduceSize)
inSizeForReduce = kMinReduceSize;
for (int groupIndex = 0; groupIndex < groups.Size(); groupIndex++)
{
const CSolidGroup &group = groups[groupIndex];
@@ -708,7 +722,7 @@ static HRESULT Update2(
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
RINOK(encoder.Encode(solidInStream, NULL, folderItem,
RINOK(encoder.Encode(solidInStream, NULL, &inSizeForReduce, folderItem,
archive.SeqStream, newDatabase.PackSizes, compressProgress));
// for()
// newDatabase.PackCRCsDefined.Add(false);

View File

@@ -4,6 +4,9 @@
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h"
#ifdef _WIN32
#include "../../../Common/Alloc.h"
#endif
#include "../../ICoder.h"
@@ -18,12 +21,32 @@ DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
#endif
HINSTANCE g_hInstance;
#ifndef _UNICODE
bool g_IsNT = false;
static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
#endif
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
#ifdef _WIN32
SetLargePageSize();
#endif
}
return TRUE;
}