lzma_encoder_presets.c revision 207753
1266423Sjfv/////////////////////////////////////////////////////////////////////////////// 2266423Sjfv// 3279033Sjfv/// \file lzma_encoder_presets.c 4266423Sjfv/// \brief Encoder presets 5266423Sjfv// 6266423Sjfv// Author: Lasse Collin 7266423Sjfv// 8266423Sjfv// This file has been put into the public domain. 9266423Sjfv// You can do whatever you want with this file. 10266423Sjfv// 11266423Sjfv/////////////////////////////////////////////////////////////////////////////// 12266423Sjfv 13266423Sjfv#include "common.h" 14266423Sjfv 15266423Sjfv 16266423Sjfvextern LZMA_API(lzma_bool) 17266423Sjfvlzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) 18266423Sjfv{ 19266423Sjfv const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK; 20266423Sjfv const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK; 21266423Sjfv const uint32_t supported_flags = LZMA_PRESET_EXTREME; 22266423Sjfv 23266423Sjfv if (level > 9 || (flags & ~supported_flags)) 24266423Sjfv return true; 25266423Sjfv 26266423Sjfv const uint32_t dict_shift = level <= 1 ? 16 : level + 17; 27266423Sjfv options->dict_size = UINT32_C(1) << dict_shift; 28266423Sjfv 29266423Sjfv options->preset_dict = NULL; 30266423Sjfv options->preset_dict_size = 0; 31266423Sjfv 32266423Sjfv options->lc = LZMA_LC_DEFAULT; 33266423Sjfv options->lp = LZMA_LP_DEFAULT; 34266423Sjfv options->pb = LZMA_PB_DEFAULT; 35266423Sjfv 36266423Sjfv options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL; 37266423Sjfv 38266423Sjfv options->nice_len = level == 0 ? 8 : level <= 5 ? 32 : 64; 39266423Sjfv options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4 40266423Sjfv : LZMA_MF_BT4; 41266423Sjfv options->depth = 0; 42266423Sjfv 43266423Sjfv if (flags & LZMA_PRESET_EXTREME) { 44270346Sjfv options->lc = 4; // FIXME? 45299549Serj options->mode = LZMA_MODE_NORMAL; 46266423Sjfv options->mf = LZMA_MF_BT4; 47266423Sjfv options->nice_len = 273; 48266423Sjfv options->depth = 512; 49266423Sjfv } 50266423Sjfv 51266423Sjfv return false; 52266423Sjfv} 53266423Sjfv