aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/easy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/common/easy.c')
-rw-r--r--src/liblzma/common/easy.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/liblzma/common/easy.c b/src/liblzma/common/easy.c
index 769253f4..441e66c0 100644
--- a/src/liblzma/common/easy.c
+++ b/src/liblzma/common/easy.c
@@ -33,30 +33,16 @@ struct lzma_coder_s {
static bool
-easy_set_filters(lzma_coder *coder, uint32_t level, uint32_t flags)
+easy_set_filters(lzma_coder *coder, uint32_t preset)
{
- // FIXME
- (void)flags;
+ if (lzma_lzma_preset(&coder->opt_lzma, preset))
+ return true;
- bool error = false;
+ coder->filters[0].id = LZMA_FILTER_LZMA2;
+ coder->filters[0].options = &coder->opt_lzma;
+ coder->filters[1].id = LZMA_VLI_UNKNOWN;
- if (level == 0) {
- // TODO FIXME Use Subblock or LZMA2 with no compression.
- error = true;
-
-#ifdef HAVE_ENCODER_LZMA2
- } else if (level <= 9) {
- error = lzma_lzma_preset(&coder->opt_lzma, level);
- coder->filters[0].id = LZMA_FILTER_LZMA2;
- coder->filters[0].options = &coder->opt_lzma;
- coder->filters[1].id = LZMA_VLI_UNKNOWN;
-#endif
-
- } else {
- error = true;
- }
-
- return error;
+ return false;
}
@@ -83,7 +69,7 @@ easy_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
easy_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- uint32_t level, uint32_t flags, lzma_check check)
+ uint32_t preset, lzma_check check)
{
lzma_next_coder_init(easy_encoder_init, next, allocator);
@@ -98,7 +84,7 @@ easy_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->stream_encoder = LZMA_NEXT_CODER_INIT;
}
- if (easy_set_filters(next->coder, level, flags))
+ if (easy_set_filters(next->coder, preset))
return LZMA_OPTIONS_ERROR;
return lzma_stream_encoder_init(&next->coder->stream_encoder,
@@ -107,10 +93,9 @@ easy_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API lzma_ret
-lzma_easy_encoder(lzma_stream *strm,
- uint32_t level, uint32_t flags, lzma_check check)
+lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check)
{
- lzma_next_strm_init(easy_encoder_init, strm, level, flags, check);
+ lzma_next_strm_init(easy_encoder_init, strm, preset, check);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
@@ -122,10 +107,10 @@ lzma_easy_encoder(lzma_stream *strm,
extern LZMA_API uint64_t
-lzma_easy_encoder_memusage(uint32_t level, uint32_t flags)
+lzma_easy_encoder_memusage(uint32_t preset)
{
lzma_coder coder;
- if (easy_set_filters(&coder, level, flags))
+ if (easy_set_filters(&coder, preset))
return UINT32_MAX;
return lzma_memusage_encoder(coder.filters);
@@ -133,10 +118,10 @@ lzma_easy_encoder_memusage(uint32_t level, uint32_t flags)
extern LZMA_API uint64_t
-lzma_easy_decoder_memusage(uint32_t level, uint32_t flags)
+lzma_easy_decoder_memusage(uint32_t preset)
{
lzma_coder coder;
- if (easy_set_filters(&coder, level, flags))
+ if (easy_set_filters(&coder, preset))
return UINT32_MAX;
return lzma_memusage_decoder(coder.filters);