1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file lzma_encoder_presets.c
4 /// \brief Encoder presets
6 // Author: Lasse Collin
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
16 extern LZMA_API(lzma_bool
)
17 lzma_lzma_preset(lzma_options_lzma
*options
, uint32_t preset
)
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
;
23 if (level
> 9 || (flags
& ~supported_flags
))
26 options
->preset_dict
= NULL
;
27 options
->preset_dict_size
= 0;
29 options
->lc
= LZMA_LC_DEFAULT
;
30 options
->lp
= LZMA_LP_DEFAULT
;
31 options
->pb
= LZMA_PB_DEFAULT
;
33 options
->dict_size
= UINT32_C(1) << (uint8_t []){
34 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level
];
37 options
->mode
= LZMA_MODE_FAST
;
38 options
->mf
= level
== 0 ? LZMA_MF_HC3
: LZMA_MF_HC4
;
39 options
->nice_len
= level
<= 1 ? 128 : 273;
40 options
->depth
= (uint8_t []){ 4, 8, 24, 48 }[level
];
42 options
->mode
= LZMA_MODE_NORMAL
;
43 options
->mf
= LZMA_MF_BT4
;
44 options
->nice_len
= level
== 4 ? 16 : level
== 5 ? 32 : 64;
48 if (flags
& LZMA_PRESET_EXTREME
) {
49 options
->mode
= LZMA_MODE_NORMAL
;
50 options
->mf
= LZMA_MF_BT4
;
51 if (level
== 3 || level
== 5) {
52 options
->nice_len
= 192;
55 options
->nice_len
= 273;