Skip to content

Commit 62bfad5

Browse files
authoredSep 11, 2023
Merge pull request #352 from sebres/patch-1
Amend for brotli (de)compress (-mmt1), update README.md
2 parents eeae03e + 09a6777 commit 62bfad5

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed
 

‎CPP/7zip/Archive/ArchiveExports.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "../Common/RegisterArc.h"
1212

13-
static const unsigned kNumArcsMax = 64;
13+
static const unsigned kNumArcsMax = 72;
1414
static unsigned g_NumArcs = 0;
1515
static unsigned g_DefaultArcIndex = 0;
1616
static const CArcInfo *g_Arcs[kNumArcsMax];

‎CPP/7zip/Archive/BrotliHandler.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
173173

174174
NCompress::NBROTLI::CDecoder *decoderSpec = new NCompress::NBROTLI::CDecoder;
175175
decoderSpec->SetNumberOfThreads(0); /* .br - single threaded processing (without header/mt-frames) */
176+
if (_props._numThreads_WasForced) {
177+
decoderSpec->SetNumberOfThreads(_props._numThreads); // translate to decoder (important for -mmt>=2 to use brotli-mt)
178+
}
176179
CMyComPtr<ICompressCoder> decoder = decoderSpec;
177180
decoderSpec->SetInStream(_seqStream);
178181

‎CPP/7zip/Compress/BrotliDecoder.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
100100
const UInt32 kNumThreadsMax = BROTLIMT_THREAD_MAX;
101101
if (numThreads < 0) numThreads = 0;
102102
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
103+
// if single-threaded, retain artificial number set in BrotliHandler (always prefer .br format):
104+
if (_numThreads == 0 && numThreads == 1) {
105+
numThreads = 0;
106+
}
103107
_numThreads = numThreads;
104108
return S_OK;
105109
}

‎CPP/7zip/Compress/BrotliEncoder.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
156156
const UInt32 kNumThreadsMax = BROTLIMT_THREAD_MAX;
157157
if (numThreads < 0) numThreads = 0;
158158
if (numThreads > kNumThreadsMax) numThreads = kNumThreadsMax;
159+
// if single-threaded, retain artificial number set in BrotliHandler (always prefer .br format):
160+
if (_numThreads == 0 && numThreads == 1) {
161+
numThreads = 0;
162+
}
159163
_numThreads = numThreads;
160164
return S_OK;
161165
}

‎CPP/7zip/UI/Common/LoadCodecs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static bool ReadPathFromRegistry(HKEY baseKey, LPCWSTR value, FString &path)
122122
#endif // EXTERNAL_CODECS
123123

124124

125-
static const unsigned kNumArcsMax = 64;
125+
static const unsigned kNumArcsMax = 72;
126126
static unsigned g_NumArcs = 0;
127127
static const CArcInfo *g_Arcs[kNumArcsMax];
128128

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ Hashers:
114114
### Usage and features of the full installation
115115

116116
- compression and decompression for [Brotli], [Lizard], [LZ4], [LZ5] and [Zstandard] within the [7-Zip] container format
117-
- compression and decompression of [Lizard] (`.liz`), [LZ4] (`.lz4`), [LZ5] (`.lz5`) and [Zstandard] (`.zst`) files
117+
- compression and decompression of [Brotli] (`.br`), [Lizard] (`.liz`), [LZ4] (`.lz4`), [LZ5] (`.lz5`) and [Zstandard] (`.zst`) files
118118
- handling of ZIP files with [Zstandard] compression
119119
- included [lzip] decompression support, patch from: https://download.savannah.gnu.org/releases/lzip/7zip/
120120
- explorer context menu: _"Add to xy.7z"_ will use all parameters of the last "Add to Archive" compression dialog (this includes: method, level, dictionary, blocksize, threads and paramters input box)
121121
- squashfs files with LZ4 or Zstandard compression can be handled
122122
- several history settings aren't stored by default, look [here](https://sourceforge.net/p/sevenzip/discussion/45797/thread/dc2ac53d/?limit=25) for some info about that, you can restore original 7-Zip behavior via `tools->options->settings`
123-
- these hashes can be calculated: CRC32, CRC64, MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512, XXH32, XXH64, BLAKE2sp, BLAKE3 (lowercase or uppercase)
123+
- these hashes can be calculated: CRC32, CRC64, MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512, SHA3-256, SHA3-384, SHA3-512, XXH32, XXH64, BLAKE2sp, BLAKE3 (lowercase or uppercase)
124124

125125
```
126126
7z a archiv.7z -m0=zstd -mx0 Zstandard Fastest Mode, without BCJ preprocessor

0 commit comments

Comments
 (0)
Please sign in to comment.