aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/easy.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-02-17 10:43:00 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-02-17 10:43:00 +0200
commit489a3dbaa0465f04400804e956a1cfbbee3654a2 (patch)
tree9456c3fde0e0fdae8e006799338f41dd34508487 /src/liblzma/common/easy.c
parentMake physmem.h work on old Windows versions. (diff)
downloadxz-489a3dbaa0465f04400804e956a1cfbbee3654a2.tar.xz
Added lzma_easy_buffer_encode(). Splitted easy.c into small
pieces to avoid unneeded dependencies making statically linked applications bigger than needed.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/easy_encoder.c (renamed from src/liblzma/common/easy.c)53
1 files changed, 6 insertions, 47 deletions
diff --git a/src/liblzma/common/easy.c b/src/liblzma/common/easy_encoder.c
index 8147a5b5..4a6709c6 100644
--- a/src/liblzma/common/easy.c
+++ b/src/liblzma/common/easy_encoder.c
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
//
-/// \file easy.c
-/// \brief Easy Stream encoder initialization
+/// \file easy_encoder.c
+/// \brief Easy .xz Stream encoder initialization
//
// Copyright (C) 2008 Lasse Collin
//
@@ -17,35 +17,16 @@
//
///////////////////////////////////////////////////////////////////////////////
+#include "easy_preset.h"
#include "stream_encoder.h"
struct lzma_coder_s {
lzma_next_coder stream_encoder;
-
- /// Options for LZMA2
- lzma_options_lzma opt_lzma;
-
- /// We need to keep the filters array available in case
- /// LZMA_FULL_FLUSH is used.
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
+ lzma_options_easy opt_easy;
};
-static bool
-easy_set_filters(lzma_coder *coder, uint32_t preset)
-{
- if (lzma_lzma_preset(&coder->opt_lzma, preset))
- return true;
-
- coder->filters[0].id = LZMA_FILTER_LZMA2;
- coder->filters[0].options = &coder->opt_lzma;
- coder->filters[1].id = LZMA_VLI_UNKNOWN;
-
- return false;
-}
-
-
static lzma_ret
easy_encode(lzma_coder *coder, lzma_allocator *allocator,
const uint8_t *restrict in, size_t *restrict in_pos,
@@ -84,11 +65,11 @@ easy_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->stream_encoder = LZMA_NEXT_CODER_INIT;
}
- if (easy_set_filters(next->coder, preset))
+ if (lzma_easy_preset(&next->coder->opt_easy, preset))
return LZMA_OPTIONS_ERROR;
return lzma_stream_encoder_init(&next->coder->stream_encoder,
- allocator, next->coder->filters, check);
+ allocator, next->coder->opt_easy.filters, check);
}
@@ -104,25 +85,3 @@ lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check)
return LZMA_OK;
}
-
-
-extern LZMA_API(uint64_t)
-lzma_easy_encoder_memusage(uint32_t preset)
-{
- lzma_coder coder;
- if (easy_set_filters(&coder, preset))
- return UINT32_MAX;
-
- return lzma_raw_encoder_memusage(coder.filters);
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_easy_decoder_memusage(uint32_t preset)
-{
- lzma_coder coder;
- if (easy_set_filters(&coder, preset))
- return UINT32_MAX;
-
- return lzma_raw_decoder_memusage(coder.filters);
-}