aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lzma/lzma_encoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-01-27 18:36:05 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-01-27 18:36:05 +0200
commitf76e39cf930f888d460b443d18f977ebedea8b2a (patch)
tree314f531dc9953c5b87a5268d53373e6646598323 /src/liblzma/lzma/lzma_encoder.c
parentRegenerate the CRC tables without trailing blanks. (diff)
downloadxz-f76e39cf930f888d460b443d18f977ebedea8b2a.tar.xz
Added initial support for preset dictionary for raw LZMA1
and LZMA2. It is not supported by the .xz format or the xz command line tool yet.
Diffstat (limited to 'src/liblzma/lzma/lzma_encoder.c')
-rw-r--r--src/liblzma/lzma/lzma_encoder.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c
index 79bb8f9b..cf7637d2 100644
--- a/src/liblzma/lzma/lzma_encoder.c
+++ b/src/liblzma/lzma/lzma_encoder.c
@@ -274,6 +274,8 @@ encode_symbol(lzma_coder *coder, lzma_mf *mf,
static bool
encode_init(lzma_coder *coder, lzma_mf *mf)
{
+ assert(mf_position(mf) == 0);
+
if (mf->read_pos == mf->read_limit) {
if (mf->action == LZMA_RUN)
return false; // We cannot do anything.
@@ -594,7 +596,12 @@ lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
return LZMA_OPTIONS_ERROR;
}
- coder->is_initialized = false;
+ // We don't need to write the first byte as literal if there is
+ // a non-empty preset dictionary. encode_init() wouldn't even work
+ // if there is a non-empty preset dictionary, because encode_init()
+ // assumes that position is zero and previous byte is also zero.
+ coder->is_initialized = options->preset_dict != NULL
+ && options->preset_dict_size > 0;
coder->is_flushed = false;
set_lz_options(lz_options, options);