diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2010-09-03 15:13:12 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2010-09-03 15:13:12 +0300 |
commit | b4b1cbcb53624ab832f8b3189c74450dc7ea29b6 (patch) | |
tree | 35a7438ac266d7f967f3032048153b254eac1592 | |
parent | liblzma: Adjust default depth calculation for HC3 and HC4. (diff) | |
download | xz-b4b1cbcb53624ab832f8b3189c74450dc7ea29b6.tar.xz |
Tweak the compression presets -0 .. -5.
"Extreme" mode might need some further tweaking still.
Docs were not updated yet.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lzma/lzma_encoder_presets.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/liblzma/lzma/lzma_encoder_presets.c b/src/liblzma/lzma/lzma_encoder_presets.c index c4c9c146..2aa8fd03 100644 --- a/src/liblzma/lzma/lzma_encoder_presets.c +++ b/src/liblzma/lzma/lzma_encoder_presets.c @@ -23,9 +23,6 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) if (level > 9 || (flags & ~supported_flags)) return true; - const uint32_t dict_shift = level <= 1 ? 16 : level + 17; - options->dict_size = UINT32_C(1) << dict_shift; - options->preset_dict = NULL; options->preset_dict_size = 0; @@ -33,19 +30,31 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) options->lp = LZMA_LP_DEFAULT; options->pb = LZMA_PB_DEFAULT; - options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL; + options->dict_size = UINT32_C(1) << (uint8_t []){ + 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level]; - options->nice_len = level == 0 ? 8 : level <= 5 ? 32 : 64; - options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4 - : LZMA_MF_BT4; - options->depth = 0; + if (level <= 3) { + options->mode = LZMA_MODE_FAST; + options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4; + options->nice_len = level <= 1 ? 128 : 273; + options->depth = (uint8_t []){ 4, 8, 24, 48 }[level]; + } else { + options->mode = LZMA_MODE_NORMAL; + options->mf = LZMA_MF_BT4; + options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64; + options->depth = 0; + } if (flags & LZMA_PRESET_EXTREME) { options->lc = 4; // FIXME? options->mode = LZMA_MODE_NORMAL; options->mf = LZMA_MF_BT4; - options->nice_len = 273; - options->depth = 512; + if (level == 3 || level == 5) { + options->nice_len = 192; + } else { + options->nice_len = 273; + options->depth = 512; + } } return false; |