mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Use LZMA1EXT feature in lzma_microlzma_decoder().
Here too this avoids the slightly ugly method to set the uncompressed size. Also moved the setting of dict_size to the struct initializer.
This commit is contained in:
parent
e310e8b6a4
commit
cee8320646
1 changed files with 8 additions and 7 deletions
|
@ -80,10 +80,17 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
return LZMA_OK;
|
return LZMA_OK;
|
||||||
|
|
||||||
lzma_options_lzma options = {
|
lzma_options_lzma options = {
|
||||||
|
.dict_size = coder->dict_size,
|
||||||
.preset_dict = NULL,
|
.preset_dict = NULL,
|
||||||
.preset_dict_size = 0,
|
.preset_dict_size = 0,
|
||||||
|
.ext_flags = 0, // EOPM not allowed when size is known
|
||||||
|
.ext_size_low = UINT32_MAX, // Unknown size by default
|
||||||
|
.ext_size_high = UINT32_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (coder->uncomp_size_is_exact)
|
||||||
|
lzma_set_ext_size(options, coder->uncomp_size);
|
||||||
|
|
||||||
// The properties are stored as bitwise-negation
|
// The properties are stored as bitwise-negation
|
||||||
// of the typical encoding.
|
// of the typical encoding.
|
||||||
if (lzma_lzma_lclppb_decode(&options, ~in[*in_pos]))
|
if (lzma_lzma_lclppb_decode(&options, ~in[*in_pos]))
|
||||||
|
@ -92,10 +99,9 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
++*in_pos;
|
++*in_pos;
|
||||||
|
|
||||||
// Initialize the decoder.
|
// Initialize the decoder.
|
||||||
options.dict_size = coder->dict_size;
|
|
||||||
lzma_filter_info filters[2] = {
|
lzma_filter_info filters[2] = {
|
||||||
{
|
{
|
||||||
.id = LZMA_FILTER_LZMA1,
|
.id = LZMA_FILTER_LZMA1EXT,
|
||||||
.init = &lzma_lzma_decoder_init,
|
.init = &lzma_lzma_decoder_init,
|
||||||
.options = &options,
|
.options = &options,
|
||||||
}, {
|
}, {
|
||||||
|
@ -106,11 +112,6 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
return_if_error(lzma_next_filter_init(&coder->lzma,
|
return_if_error(lzma_next_filter_init(&coder->lzma,
|
||||||
allocator, filters));
|
allocator, filters));
|
||||||
|
|
||||||
// Use a hack to set the uncompressed size.
|
|
||||||
if (coder->uncomp_size_is_exact)
|
|
||||||
lzma_lz_decoder_uncompressed(coder->lzma.coder,
|
|
||||||
coder->uncomp_size, false);
|
|
||||||
|
|
||||||
// Pass one dummy 0x00 byte to the LZMA decoder since that
|
// Pass one dummy 0x00 byte to the LZMA decoder since that
|
||||||
// is what it expects the first byte to be.
|
// is what it expects the first byte to be.
|
||||||
const uint8_t dummy_in = 0;
|
const uint8_t dummy_in = 0;
|
||||||
|
|
Loading…
Reference in a new issue