Skip to content

Commit

Permalink
Match default compression level value in compress streams #726
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Oct 26, 2023
1 parent 1e9c6d8 commit 97d8e65
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mz_strm_bzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mz_strm_lzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion mz_strm_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mz_strm_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 97d8e65

Please sign in to comment.