Match default compression level value in compress streams #726

This commit is contained in:
Nathan Moinvaziri 2023-10-26 11:51:43 -07:00
parent 1e9c6d8361
commit 97d8e65dc8
4 changed files with 7 additions and 4 deletions

View file

@ -326,7 +326,7 @@ int32_t mz_stream_bzip_set_prop_int64(void *stream, int32_t prop, int64_t value)
mz_stream_bzip *bzip = (mz_stream_bzip *)stream;
switch (prop) {
case MZ_STREAM_PROP_COMPRESS_LEVEL:
if (value < 0)
if (value == MZ_COMPRESS_LEVEL_DEFAULT)
bzip->level = 6;
else
bzip->level = (int16_t)value;

View file

@ -415,7 +415,7 @@ int32_t mz_stream_lzma_set_prop_int64(void *stream, int32_t prop, int64_t value)
mz_stream_lzma *lzma = (mz_stream_lzma *)stream;
switch (prop) {
case MZ_STREAM_PROP_COMPRESS_LEVEL:
if (value < 0 || value > 9)
if (value == MZ_COMPRESS_LEVEL_DEFAULT)
lzma->preset = LZMA_PRESET_DEFAULT;
else
lzma->preset = (uint32_t)value;

View file

@ -347,7 +347,10 @@ int32_t mz_stream_zlib_set_prop_int64(void *stream, int32_t prop, int64_t value)
mz_stream_zlib *zlib = (mz_stream_zlib *)stream;
switch (prop) {
case MZ_STREAM_PROP_COMPRESS_LEVEL:
zlib->level = (int16_t)value;
if (value == MZ_COMPRESS_LEVEL_DEFAULT)
zlib->level = Z_DEFAULT_COMPRESSION;
else
zlib->level = (int16_t)value;
break;
case MZ_STREAM_PROP_TOTAL_IN_MAX:
zlib->max_total_in = value;

View file

@ -312,7 +312,7 @@ int32_t mz_stream_zstd_set_prop_int64(void *stream, int32_t prop, int64_t value)
mz_stream_zstd *zstd = (mz_stream_zstd *)stream;
switch (prop) {
case MZ_STREAM_PROP_COMPRESS_LEVEL:
if (value < 0)
if (value == MZ_COMPRESS_LEVEL_DEFAULT)
zstd->preset = ZSTD_CLEVEL_DEFAULT;
else
zstd->preset = (int16_t)value;