aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lzma/lzma_encoder_presets.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-27 19:27:49 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-27 19:27:49 +0200
commite33194e79d8f5ce07cb4aca909b324ae75098f7e (patch)
tree6a1db024ccdbe49ea8d03dacf9ab0ebcedaa6688 /src/liblzma/lzma/lzma_encoder_presets.c
parentUpdated Makefile.am that was missing from the previous commit. (diff)
downloadxz-e33194e79d8f5ce07cb4aca909b324ae75098f7e.tar.xz
Bunch of liblzma tweaks, including some API changes.
The API and ABI should now be very close to stable, although the code behind it isn't yet.
Diffstat (limited to '')
-rw-r--r--src/liblzma/lzma/lzma_encoder_presets.c53
1 files changed, 16 insertions, 37 deletions
diff --git a/src/liblzma/lzma/lzma_encoder_presets.c b/src/liblzma/lzma/lzma_encoder_presets.c
index b48e0698..31928d61 100644
--- a/src/liblzma/lzma/lzma_encoder_presets.c
+++ b/src/liblzma/lzma/lzma_encoder_presets.c
@@ -20,47 +20,18 @@
#include "common.h"
-/*
-#define pow2(e) (UINT32_C(1) << (e))
-
-
-static const lzma_options_lzma presets[9] = {
-// 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 },
-};
-
-
extern LZMA_API lzma_bool
-lzma_lzma_preset(lzma_options_lzma *options, uint32_t level)
+lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
{
- if (level >= ARRAY_SIZE(presetes))
- return true;
+ const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;
+ const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;
+ const uint32_t supported_flags = LZMA_PRESET_EXTREME;
- *options = presets[level];
- return false;
-}
-*/
-
-
-extern LZMA_API lzma_bool
-lzma_lzma_preset(lzma_options_lzma *options, uint32_t level)
-{
- if (level == 0 || level > 9)
+ if (level > 9 || (flags & ~supported_flags))
return true;
- --level;
- memzero(options, sizeof(*options));
-
- static const uint8_t shift[9] = { 16, 20, 19, 20, 21, 22, 23, 24, 25 };
- options->dict_size = UINT32_C(1) << shift[level];
+ 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;
@@ -72,10 +43,18 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t level)
options->persistent = false;
options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL;
- options->nice_len = level <= 5 ? 32 : 64;
+ 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 (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;
+ }
+
return false;
}