2007-12-08 22:42:33 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
/// \file lzma_encoder_presets.c
|
|
|
|
/// \brief Encoder presets
|
|
|
|
//
|
|
|
|
// Copyright (C) 2007 Lasse Collin
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
/*
|
2008-08-28 19:53:15 +00:00
|
|
|
#define pow2(e) (UINT32_C(1) << (e))
|
|
|
|
|
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
static const lzma_options_lzma presets[9] = {
|
2008-08-28 19:53:15 +00:00
|
|
|
// dict lc lp pb mode fb mf mfc
|
|
|
|
{ pow2(16), NULL, 0, 3, 0, 2, false, LZMA_MODE_FAST, 64, LZMA_MF_HC3, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(20), NULL, 0, 3, 0, 0, false, LZMA_MODE_FAST, 64, LZMA_MF_HC4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(19), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 64, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(20), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 64, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(21), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 128, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(22), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 128, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(23), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 128, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(24), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 273, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
|
|
|
{ pow2(25), NULL, 0, 3, 0, 0, false, LZMA_MODE_NORMAL, 273, LZMA_MF_BT4, 0, 0, 0, 0, 0, NULL, NULL },
|
2007-12-08 22:42:33 +00:00
|
|
|
};
|
2008-08-28 19:53:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern LZMA_API lzma_bool
|
2008-09-27 16:09:21 +00:00
|
|
|
lzma_lzma_preset(lzma_options_lzma *options, uint32_t level)
|
2008-08-28 19:53:15 +00:00
|
|
|
{
|
2008-09-27 16:09:21 +00:00
|
|
|
if (level >= ARRAY_SIZE(presetes))
|
|
|
|
return true;
|
2008-08-28 19:53:15 +00:00
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
*options = presets[level];
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*/
|
2008-08-28 19:53:15 +00:00
|
|
|
|
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
extern LZMA_API lzma_bool
|
|
|
|
lzma_lzma_preset(lzma_options_lzma *options, uint32_t level)
|
|
|
|
{
|
2008-10-07 06:40:31 +00:00
|
|
|
if (level == 0 || level > 9)
|
2008-09-27 16:09:21 +00:00
|
|
|
return true;
|
|
|
|
|
2008-10-07 06:40:31 +00:00
|
|
|
--level;
|
2008-09-27 16:09:21 +00:00
|
|
|
memzero(options, sizeof(*options));
|
2008-08-28 19:53:15 +00:00
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
static const uint8_t shift[9] = { 16, 20, 19, 20, 21, 22, 23, 24, 25 };
|
|
|
|
options->dict_size = UINT32_C(1) << shift[level];
|
2008-08-28 19:53:15 +00:00
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
options->preset_dict = NULL;
|
|
|
|
options->preset_dict_size = 0;
|
2008-08-28 19:53:15 +00:00
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
options->lc = LZMA_LC_DEFAULT;
|
|
|
|
options->lp = LZMA_LP_DEFAULT;
|
|
|
|
options->pb = LZMA_PB_DEFAULT;
|
2008-08-28 19:53:15 +00:00
|
|
|
|
2008-09-27 16:09:21 +00:00
|
|
|
options->persistent = false;
|
|
|
|
options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL;
|
|
|
|
|
|
|
|
options->nice_len = level <= 5 ? 32 : 64;
|
|
|
|
options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4
|
|
|
|
: LZMA_MF_BT4;
|
|
|
|
options->depth = 0;
|
|
|
|
|
|
|
|
return false;
|
2008-08-28 19:53:15 +00:00
|
|
|
}
|