Rizin
unix-like reverse engineering framework and cli tools
lzma_options_lzma Struct Reference

Options specific to the LZMA1 and LZMA2 filters. More...

#include <lzma12.h>

Public Attributes

uint32_t dict_size
 Dictionary size in bytes. More...
 
const uint8_tpreset_dict
 Pointer to an initial dictionary. More...
 
uint32_t preset_dict_size
 Size of the preset dictionary. More...
 
uint32_t lc
 Number of literal context bits. More...
 
uint32_t lp
 Number of literal position bits. More...
 
uint32_t pb
 Number of position bits. More...
 
lzma_mode mode
 
uint32_t nice_len
 Nice length of a match. More...
 
lzma_match_finder mf
 
uint32_t depth
 Maximum search depth in the match finder. More...
 
uint32_t reserved_int1
 
uint32_t reserved_int2
 
uint32_t reserved_int3
 
uint32_t reserved_int4
 
uint32_t reserved_int5
 
uint32_t reserved_int6
 
uint32_t reserved_int7
 
uint32_t reserved_int8
 
lzma_reserved_enum reserved_enum1
 
lzma_reserved_enum reserved_enum2
 
lzma_reserved_enum reserved_enum3
 
lzma_reserved_enum reserved_enum4
 
void * reserved_ptr1
 
void * reserved_ptr2
 

Detailed Description

Options specific to the LZMA1 and LZMA2 filters.

Since LZMA1 and LZMA2 share most of the code, it's simplest to share the options structure too. For encoding, all but the reserved variables need to be initialized unless specifically mentioned otherwise. lzma_lzma_preset() can be used to get a good starting point.

For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.

Definition at line 185 of file lzma12.h.

Member Data Documentation

◆ depth

uint32_t lzma_options_lzma::depth

Maximum search depth in the match finder.

For every input byte, match finder searches through the hash chain or binary tree in a loop, each iteration going one step deeper in the chain or tree. The searching stops if

  • a match of at least nice_len bytes long is found;
  • all match candidates from the hash chain or binary tree have been checked; or
  • maximum search depth is reached.

Maximum search depth is needed to prevent the match finder from wasting too much time in case there are lots of short match candidates. On the other hand, stopping the search before all candidates have been checked can reduce compression ratio.

Setting depth to zero tells liblzma to use an automatic default value, that depends on the selected match finder and nice_len. The default is in the range [4, 200] or so (it may vary between liblzma versions).

Using a bigger depth value than the default can increase compression ratio in some cases. There is no strict maximum value, but high values (thousands or millions) should be used with care: the encoder could remain fast enough with typical input, but malicious input could cause the match finder to slow down dramatically, possibly creating a denial of service attack.

Definition at line 375 of file lzma12.h.

Referenced by message_filters_to_str(), and set_lzma().

◆ dict_size

uint32_t lzma_options_lzma::dict_size

Dictionary size in bytes.

Dictionary size indicates how many bytes of the recently processed uncompressed data is kept in memory. One method to reduce size of the uncompressed data is to store distance-length pairs, which indicate what data to repeat from the dictionary buffer. Thus, the bigger the dictionary, the better the compression ratio usually is.

Maximum size of the dictionary depends on multiple things:

  • Memory usage limit
  • Available address space (not a problem on 64-bit systems)
  • Selected match finder (encoder only)

Currently the maximum dictionary size for encoding is 1.5 GiB (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit systems for certain match finder implementation reasons. In the future, there may be match finders that support bigger dictionaries.

Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. UINT32_MAX), so increasing the maximum dictionary size of the encoder won't cause problems for old decoders.

Because extremely small dictionaries sizes would have unneeded overhead in the decoder, the minimum dictionary size is 4096 bytes.

Note
When decoding, too big dictionary does no other harm than wasting memory.

Definition at line 217 of file lzma12.h.

Referenced by alone_decode(), block_encode_uncompressed(), coder_init(), lzma_alone_decoder_init(), lzma_lzma2_block_size(), lzma_lzma2_props_encode(), lzma_lzma_decoder_memusage_nocheck(), lzma_lzma_props_decode(), lzmainfo(), main(), message_filters_to_str(), and set_lzma().

◆ lc

uint32_t lzma_options_lzma::lc

Number of literal context bits.

How many of the highest bits of the previous uncompressed eight-bit byte (also known as ‘literal’) are taken into account when predicting the bits of the next literal.

E.g. in typical English text, an upper-case letter is often followed by a lower-case letter, and a lower-case letter is usually followed by another lower-case letter. In the US-ASCII character set, the highest three bits are 010 for upper-case letters and 011 for lower-case letters. When lc is at least 3, the literal coding can take advantage of this property in the uncompressed data.

There is a limit that applies to literal context bits and literal position bits together: lc + lp <= 4. Without this limit the decoding could become very slow, which could have security related results in some cases like email servers doing virus scanning. This limit also simplifies the internal implementation in liblzma.

There may be LZMA1 streams that have lc + lp > 4 (maximum possible lc would be 8). It is not possible to decode such streams with liblzma.

Definition at line 281 of file lzma12.h.

Referenced by lzma2_encoder_options_update(), lzmainfo(), message_filters_to_str(), and set_lzma().

◆ lp

uint32_t lzma_options_lzma::lp

Number of literal position bits.

lp affects what kind of alignment in the uncompressed data is assumed when encoding literals. A literal is a single 8-bit byte. See pb below for more information about alignment.

Definition at line 293 of file lzma12.h.

Referenced by lzma2_encoder_options_update(), lzmainfo(), message_filters_to_str(), and set_lzma().

◆ mf

lzma_match_finder lzma_options_lzma::mf

Match finder ID

Definition at line 345 of file lzma12.h.

Referenced by message_filters_to_str(), and set_lzma().

◆ mode

lzma_mode lzma_options_lzma::mode

Compression mode

Definition at line 322 of file lzma12.h.

Referenced by message_filters_to_str(), test_group_name.GroupTest::run(), and set_lzma().

◆ nice_len

uint32_t lzma_options_lzma::nice_len

Nice length of a match.

This determines how many bytes the encoder compares from the match candidates when looking for the best match. Once a match of at least nice_len bytes long is found, the encoder stops looking for better candidates and encodes the match. (Naturally, if the found match is actually longer than nice_len, the actual length is encoded; it's not truncated to nice_len.)

Bigger values usually increase the compression ratio and compression time. For most files, 32 to 128 is a good value, which gives very good compression ratio at good speed.

The exact minimum value depends on the match finder. The maximum is 273, which is the maximum length of a match that LZMA1 and LZMA2 can encode.

Definition at line 342 of file lzma12.h.

Referenced by message_filters_to_str(), and set_lzma().

◆ pb

uint32_t lzma_options_lzma::pb

Number of position bits.

pb affects what kind of alignment in the uncompressed data is assumed in general. The default means four-byte alignment (2^ pb =2^2=4), which is often a good choice when there's no better guess.

When the alignment is known, setting pb accordingly may reduce the file size a little. E.g. with text files having one-byte alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can improve compression slightly. For UTF-16 text, pb=1 is a good choice. If the alignment is an odd number like 3 bytes, pb=0 might be the best choice.

Even though the assumed alignment can be adjusted with pb and lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. It might be worth taking into account when designing file formats that are likely to be often compressed with LZMA1 or LZMA2.

Definition at line 316 of file lzma12.h.

Referenced by lzma2_encoder_options_update(), lzmainfo(), message_filters_to_str(), and set_lzma().

◆ preset_dict

const uint8_t* lzma_options_lzma::preset_dict

Pointer to an initial dictionary.

It is possible to initialize the LZ77 history window using a preset dictionary. It is useful when compressing many similar, relatively small chunks of data independently from each other. The preset dictionary should contain typical strings that occur in the files being compressed. The most probable strings should be near the end of the preset dictionary.

This feature should be used only in special situations. For now, it works correctly only with raw encoding and decoding. Currently none of the container formats supported by liblzma allow preset dictionary when decoding, thus if you create a .xz or .lzma file with preset dictionary, it cannot be decoded with the regular decoder functions. In the future, the .xz format will likely get support for preset dictionary though.

Definition at line 240 of file lzma12.h.

Referenced by lzma2_encoder_init(), lzma_alone_decoder_init(), and lzma_lzma_props_decode().

◆ preset_dict_size

uint32_t lzma_options_lzma::preset_dict_size

Size of the preset dictionary.

Specifies the size of the preset dictionary. If the size is bigger than dict_size, only the last dict_size bytes are processed.

This variable is read only when preset_dict is not NULL. If preset_dict is not NULL but preset_dict_size is zero, no preset dictionary is used (identical to only setting preset_dict to NULL).

Definition at line 254 of file lzma12.h.

Referenced by lzma2_encoder_init(), lzma_alone_decoder_init(), and lzma_lzma_props_decode().

◆ reserved_enum1

lzma_reserved_enum lzma_options_lzma::reserved_enum1

Definition at line 392 of file lzma12.h.

◆ reserved_enum2

lzma_reserved_enum lzma_options_lzma::reserved_enum2

Definition at line 393 of file lzma12.h.

◆ reserved_enum3

lzma_reserved_enum lzma_options_lzma::reserved_enum3

Definition at line 394 of file lzma12.h.

◆ reserved_enum4

lzma_reserved_enum lzma_options_lzma::reserved_enum4

Definition at line 395 of file lzma12.h.

◆ reserved_int1

uint32_t lzma_options_lzma::reserved_int1

Definition at line 384 of file lzma12.h.

◆ reserved_int2

uint32_t lzma_options_lzma::reserved_int2

Definition at line 385 of file lzma12.h.

◆ reserved_int3

uint32_t lzma_options_lzma::reserved_int3

Definition at line 386 of file lzma12.h.

◆ reserved_int4

uint32_t lzma_options_lzma::reserved_int4

Definition at line 387 of file lzma12.h.

◆ reserved_int5

uint32_t lzma_options_lzma::reserved_int5

Definition at line 388 of file lzma12.h.

◆ reserved_int6

uint32_t lzma_options_lzma::reserved_int6

Definition at line 389 of file lzma12.h.

◆ reserved_int7

uint32_t lzma_options_lzma::reserved_int7

Definition at line 390 of file lzma12.h.

◆ reserved_int8

uint32_t lzma_options_lzma::reserved_int8

Definition at line 391 of file lzma12.h.

◆ reserved_ptr1

void* lzma_options_lzma::reserved_ptr1

Definition at line 396 of file lzma12.h.

◆ reserved_ptr2

void* lzma_options_lzma::reserved_ptr2

Definition at line 397 of file lzma12.h.


The documentation for this struct was generated from the following file: