Package Kit: Scale compression levels to the method's levels.

Zlib has (for now?) 1-9 as its compression levels, but Zstd has
1-22, so we need to scale and round based on *_COMPRESSION_LEVEL_BEST.
This commit is contained in:
Augustin Cavalier 2021-10-26 16:51:09 -04:00
parent a89813083e
commit 4acd233580

View File

@ -310,7 +310,8 @@ WriterImplBase::InitHeapReader(size_t headerSize)
compressionAlgorithm = CompressionAlgorithmOwner::Create(
new(std::nothrow) BZlibCompressionAlgorithm,
new(std::nothrow) BZlibCompressionParameters(
fParameters.CompressionLevel()));
(fParameters.CompressionLevel() / float(B_HPKG_COMPRESSION_LEVEL_BEST))
* B_ZLIB_COMPRESSION_BEST));
compressionAlgorithmReference.SetTo(compressionAlgorithm, true);
decompressionAlgorithm = DecompressionAlgorithmOwner::Create(
@ -331,7 +332,8 @@ WriterImplBase::InitHeapReader(size_t headerSize)
compressionAlgorithm = CompressionAlgorithmOwner::Create(
new(std::nothrow) BZstdCompressionAlgorithm,
new(std::nothrow) BZstdCompressionParameters(
fParameters.CompressionLevel()));
(fParameters.CompressionLevel() / float(B_HPKG_COMPRESSION_LEVEL_BEST))
* B_ZSTD_COMPRESSION_BEST));
compressionAlgorithmReference.SetTo(compressionAlgorithm, true);
decompressionAlgorithm = DecompressionAlgorithmOwner::Create(