OLD | NEW |
(Empty) | |
| 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 // |
| 3 /// \file lzma_encoder_presets.c |
| 4 /// \brief Encoder presets |
| 5 // |
| 6 // Author: Lasse Collin |
| 7 // |
| 8 // This file has been put into the public domain. |
| 9 // You can do whatever you want with this file. |
| 10 // |
| 11 /////////////////////////////////////////////////////////////////////////////// |
| 12 |
| 13 #include "common.h" |
| 14 |
| 15 |
| 16 extern LZMA_API(lzma_bool) |
| 17 lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) |
| 18 { |
| 19 const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK; |
| 20 const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK; |
| 21 const uint32_t supported_flags = LZMA_PRESET_EXTREME; |
| 22 |
| 23 if (level > 9 || (flags & ~supported_flags)) |
| 24 return true; |
| 25 |
| 26 const uint32_t dict_shift = level <= 1 ? 16 : level + 17; |
| 27 options->dict_size = UINT32_C(1) << dict_shift; |
| 28 |
| 29 options->preset_dict = NULL; |
| 30 options->preset_dict_size = 0; |
| 31 |
| 32 options->lc = LZMA_LC_DEFAULT; |
| 33 options->lp = LZMA_LP_DEFAULT; |
| 34 options->pb = LZMA_PB_DEFAULT; |
| 35 |
| 36 options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL; |
| 37 |
| 38 options->nice_len = level == 0 ? 8 : level <= 5 ? 32 : 64; |
| 39 options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4 |
| 40 : LZMA_MF_BT4; |
| 41 options->depth = 0; |
| 42 |
| 43 if (flags & LZMA_PRESET_EXTREME) { |
| 44 options->lc = 4; // FIXME? |
| 45 options->mode = LZMA_MODE_NORMAL; |
| 46 options->mf = LZMA_MF_BT4; |
| 47 options->nice_len = 273; |
| 48 options->depth = 512; |
| 49 } |
| 50 |
| 51 return false; |
| 52 } |
OLD | NEW |