Skip to content

Commit

Permalink
Fix lzma compression level #731
Browse files Browse the repository at this point in the history
LZMA_PRESET_EXTREME is not a preset on its own but a flag which must be
used together with a level. The difference between level 9 with and without
the extreme flag also seems negligible, so this commit just passes through
the level and maps -1 and invalid values to the default preset.
  • Loading branch information
gix committed Sep 25, 2023
1 parent 680d6f1 commit 9c96447
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mz_strm_lzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ 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 >= 9)
lzma->preset = LZMA_PRESET_EXTREME;
else
if (value < 0 || value > 9)
lzma->preset = LZMA_PRESET_DEFAULT;
else
lzma->preset = (uint32_t)value;
break;
case MZ_STREAM_PROP_COMPRESS_METHOD:
lzma->method = (int16_t)value;
Expand Down

0 comments on commit 9c96447

Please sign in to comment.