diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2010-03-24 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:02 +0300 |
commit | 76b173af78d09dea806d3ed35c0f67a09b496357 (patch) | |
tree | 6262e759ddaeb55c7adb2eab98349daf6ea0b61e /CPP | |
parent | 993daef9cbed7febf494217f07e40e0a26b3bc06 (diff) |
9.129.12
Diffstat (limited to 'CPP')
-rwxr-xr-x | CPP/7zip/Archive/PeHandler.cpp | 3 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipAddCommon.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Zip/ZipHandlerOut.cpp | 39 | ||||
-rwxr-xr-x | CPP/7zip/Compress/PpmdZip.cpp | 2 | ||||
-rwxr-xr-x | CPP/7zip/MyVersion.h | 8 | ||||
-rwxr-xr-x | CPP/7zip/UI/GUI/CompressDialog.cpp | 83 |
6 files changed, 75 insertions, 64 deletions
diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index c791d6d7..97c374d0 100755 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp @@ -450,6 +450,7 @@ struct CResItem bool IsIcon() const { return Type == 3; } bool IsString() const { return Type == 6; } bool IsRcData() const { return Type == 10; } + bool IsRcDataOrUnknown() const { return IsRcData() || Type > 64; } }; struct CStringItem @@ -1410,7 +1411,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) { mixItem.ResourceIndex = j; mixItem.StringIndex = -1; - if (item.IsRcData()) + if (item.IsRcDataOrUnknown()) { if (item.Size >= mainSize) { diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp index 7fed3cab..3451e3f1 100755 --- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp @@ -244,14 +244,14 @@ HRESULT CAddCommon::Compress( _compressEncoder = encoder; NWindows::NCOM::CPropVariant props[] = { - // _options.Algo, + _options.Algo, _options.MemSize, _options.Order }; PROPID propIDs[] = { - // NCoderPropID::kAlgorithm, + NCoderPropID::kAlgorithm, NCoderPropID::kUsedMemorySize, NCoderPropID::kOrder }; diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp index b190dd2f..fa7a4480 100755 --- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp @@ -51,18 +51,6 @@ static const UInt32 kLzmaDicSizeX5 = 1 << 24; static const UInt32 kLzmaDicSizeX7 = 1 << 25; static const UInt32 kLzmaDicSizeX9 = 1 << 26; -static const UInt32 kPpmdMemSizeX1 = (1 << 20); -static const UInt32 kPpmdMemSizeX3 = (1 << 22); -static const UInt32 kPpmdMemSizeX5 = (1 << 24); -static const UInt32 kPpmdMemSizeX7 = (1 << 26); -static const UInt32 kPpmdMemSizeX9 = (1 << 27); - -static const UInt32 kPpmdOrderX1 = 4; -static const UInt32 kPpmdOrderX3 = 6; -static const UInt32 kPpmdOrderX5 = 8; -static const UInt32 kPpmdOrderX7 = 10; -static const UInt32 kPpmdOrderX9 = 16; - static const UInt32 kBZip2NumPassesX1 = 1; static const UInt32 kBZip2NumPassesX7 = 2; static const UInt32 kBZip2NumPassesX9 = 7; @@ -362,23 +350,18 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt } if (mainMethod == NFileHeader::NCompressionMethod::kPPMd) { + int level2 = level; + if (level2 < 1) level2 = 1; + if (level2 > 9) level2 = 9; + if (options.MemSize == 0xFFFFFFFF) - options.MemSize = - (level >= 9 ? kPpmdMemSizeX9 : - (level >= 7 ? kPpmdMemSizeX7 : - (level >= 5 ? kPpmdMemSizeX5 : - (level >= 3 ? kPpmdMemSizeX3 : - kPpmdMemSizeX1)))); + options.MemSize = (1 << (19 + (level2 > 8 ? 8 : level2))); if (options.Order == 0xFFFFFFFF) - options.Order = - (level >= 9 ? kPpmdOrderX9 : - (level >= 7 ? kPpmdOrderX7 : - (level >= 5 ? kPpmdOrderX5 : - (level >= 3 ? kPpmdOrderX3 : - kPpmdOrderX1)))); - - options.Algo = 0; + options.Order = 3 + level2; + + if (options.Algo == 0xFFFFFFFF) + options.Algo = (level2 >= 7 ? 1 : 0); } return Update( @@ -482,13 +465,13 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v } else if (name.Left(3) == L"MEM") { - UInt32 memSize = kPpmdMemSizeX5; + UInt32 memSize = 1 << 24; RINOK(ParsePropDictionaryValue(name.Mid(3), prop, memSize)); m_MemSize = memSize; } else if (name[0] == L'O') { - UInt32 order = kPpmdOrderX5; + UInt32 order = 8; RINOK(ParsePropValue(name.Mid(1), prop, order)); m_Order = order; } diff --git a/CPP/7zip/Compress/PpmdZip.cpp b/CPP/7zip/Compress/PpmdZip.cpp index f576909f..e83d979c 100755 --- a/CPP/7zip/Compress/PpmdZip.cpp +++ b/CPP/7zip/Compress/PpmdZip.cpp @@ -1,5 +1,5 @@ // PpmdZip.cpp -// 2010-03-11 : Igor Pavlov : Public domain +// 2010-03-24 : Igor Pavlov : Public domain #include "StdAfx.h" diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index 6b6a3476..14f1c971 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 9 -#define MY_VER_MINOR 11 +#define MY_VER_MINOR 12 #define MY_VER_BUILD 0 -#define MY_VERSION "9.11 beta" -#define MY_7ZIP_VERSION "7-Zip 9.11 beta" -#define MY_DATE "2010-03-15" +#define MY_VERSION "9.12 beta" +#define MY_7ZIP_VERSION "7-Zip 9.12 beta" +#define MY_DATE "2010-03-24" #define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp index bafaf371..75a1f9ed 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.cpp +++ b/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -114,7 +114,8 @@ enum EMethodID kPPMd, kBZip2, kDeflate, - kDeflate64 + kDeflate64, + kPPMdZip, }; static const LPCWSTR kMethodsNames[] = @@ -125,7 +126,8 @@ static const LPCWSTR kMethodsNames[] = L"PPMd", L"BZip2", L"Deflate", - L"Deflate64" + L"Deflate64", + L"PPMd" }; static const EMethodID g_7zMethods[] = @@ -149,7 +151,8 @@ static EMethodID g_ZipMethods[] = kDeflate, kDeflate64, kBZip2, - kLZMA + kLZMA, + kPPMdZip }; static EMethodID g_GZipMethods[] = @@ -849,6 +852,7 @@ void CCompressDialog::SetMethod(int keepMethodId) continue; const LPCWSTR method = kMethodsNames[methodID]; int itemIndex = (int)m_Method.AddString(GetSystemString(method)); + m_Method.SetItemData(itemIndex, methodID); if (keepMethodId == methodID) { m_Method.SetCurSel(itemIndex); @@ -897,21 +901,16 @@ void CCompressDialog::SetEncryptionMethod() int CCompressDialog::GetMethodID() { - UString methodName; - m_Method.GetText(methodName); - for (int i = 0; i < MY_SIZE_OF_ARRAY(kMethodsNames); i++) - if (methodName.CompareNoCase(kMethodsNames[i]) == 0) - return i; - return -1; + if (m_Method.GetCount() <= 0) + return -1; + return (int)(UInt32)m_Method.GetItemData(m_Method.GetCurSel()); } UString CCompressDialog::GetMethodSpec() { if (m_Method.GetCount() <= 1) return UString(); - UString result; - m_Method.GetText(result); - return result; + return kMethodsNames[GetMethodID()]; } UString CCompressDialog::GetEncryptionMethodSpec() @@ -964,7 +963,7 @@ void CCompressDialog::SetDictionary() m_Dictionary.ResetContent(); const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); - UInt32 defaultDictionary = UInt32(-1); + UInt32 defaultDictionary = (UInt32)-1; if (index >= 0) { const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; @@ -982,7 +981,7 @@ void CCompressDialog::SetDictionary() case kLZMA2: { static const UInt32 kMinDicSize = (1 << 16); - if (defaultDictionary == UInt32(-1)) + if (defaultDictionary == (UInt32)-1) { if (level >= 9) defaultDictionary = (1 << 26); else if (level >= 7) defaultDictionary = (1 << 25); @@ -1011,7 +1010,7 @@ void CCompressDialog::SetDictionary() UInt64 decomprSize; UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize); if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize) - m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); } // SetNearestSelectComboBox(m_Dictionary, defaultDictionary); @@ -1019,7 +1018,7 @@ void CCompressDialog::SetDictionary() } case kPPMd: { - if (defaultDictionary == UInt32(-1)) + if (defaultDictionary == (UInt32)-1) { if (level >= 9) defaultDictionary = (192 << 20); else if (level >= 7) defaultDictionary = ( 64 << 20); @@ -1039,7 +1038,7 @@ void CCompressDialog::SetDictionary() UInt64 decomprSize; UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize); if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0) - m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); } SetNearestSelectComboBox(m_Dictionary, defaultDictionary); break; @@ -1058,8 +1057,7 @@ void CCompressDialog::SetDictionary() } case kBZip2: { - // UInt32 defaultDictionary; - if (defaultDictionary == UInt32(-1)) + if (defaultDictionary == (UInt32)-1) { if (level >= 5) defaultDictionary = (900 << 10); @@ -1073,10 +1071,26 @@ void CCompressDialog::SetDictionary() UInt32 dictionary = (i * 100) << 10; AddDictionarySize(dictionary); if (dictionary <= defaultDictionary || m_Dictionary.GetCount() == 0) - m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); } break; } + case kPPMdZip: + { + if (defaultDictionary == (UInt32)-1) + defaultDictionary = (1 << (19 + (level > 8 ? 8 : level))); + for (int i = 20; i <= 28; i++) + { + UInt32 dictionary = (1 << i); + AddDictionarySize(dictionary); + UInt64 decomprSize; + UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize); + if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0) + m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1); + } + SetNearestSelectComboBox(m_Dictionary, defaultDictionary); + break; + } } } @@ -1109,7 +1123,7 @@ void CCompressDialog::SetOrder() m_Order.ResetContent(); const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); - UInt32 defaultOrder = UInt32(-1); + UInt32 defaultOrder = (UInt32)-1; if (index >= 0) { const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; @@ -1125,7 +1139,7 @@ void CCompressDialog::SetOrder() case kLZMA: case kLZMA2: { - if (defaultOrder == UInt32(-1)) + if (defaultOrder == (UInt32)-1) defaultOrder = (level >= 7) ? 64 : 32; for (int i = 3; i <= 8; i++) for (int j = 0; j < 2; j++) @@ -1140,7 +1154,7 @@ void CCompressDialog::SetOrder() } case kPPMd: { - if (defaultOrder == UInt32(-1)) + if (defaultOrder == (UInt32)-1) { if (level >= 9) defaultOrder = 32; @@ -1168,7 +1182,7 @@ void CCompressDialog::SetOrder() case kDeflate: case kDeflate64: { - if (defaultOrder == UInt32(-1)) + if (defaultOrder == (UInt32)-1) { if (level >= 9) defaultOrder = 128; @@ -1193,6 +1207,15 @@ void CCompressDialog::SetOrder() { break; } + case kPPMdZip: + { + if (defaultOrder == (UInt32)-1) + defaultOrder = level + 3; + for (int i = 2; i <= 16; i++) + AddOrder(i); + SetNearestSelectComboBox(m_Order, defaultOrder); + break; + } } } @@ -1221,7 +1244,7 @@ void CCompressDialog::SetSolidBlockSize() return; UInt32 dictionary = GetDictionarySpec(); - if (dictionary == UInt32(-1)) + if (dictionary == (UInt32)-1) dictionary = 1; UInt32 defaultBlockSize = (UInt32)-1; @@ -1299,7 +1322,6 @@ void CCompressDialog::SetNumThreads() SetNearestSelectComboBox(m_NumThreads, defaultValue); } - UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory) { decompressMemory = UInt64(Int64(-1)); @@ -1377,7 +1399,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemo case kDeflate64: { UInt32 order = GetOrder(); - if (order == UInt32(-1)) + if (order == (UInt32)-1) order = 32; if (level >= 7) size += (1 << 20); @@ -1391,8 +1413,13 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemo UInt64 memForOneThread = (10 << 20); return size + memForOneThread * numThreads; } + case kPPMdZip: + { + decompressMemory = dictionary + (2 << 20); + return size + (UInt64)decompressMemory * numThreads; + } } - return UInt64(Int64(-1)); + return (UInt64)(Int64)-1; } UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory) |