jpayne@69: /* SPDX-License-Identifier: 0BSD */ jpayne@69: jpayne@69: /** jpayne@69: * \file lzma/lzma12.h jpayne@69: * \brief LZMA1 and LZMA2 filters jpayne@69: * \note Never include this file directly. Use instead. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Author: Lasse Collin jpayne@69: */ jpayne@69: jpayne@69: #ifndef LZMA_H_INTERNAL jpayne@69: # error Never include this file directly. Use instead. jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief LZMA1 Filter ID (for raw encoder/decoder only, not in .xz) jpayne@69: * jpayne@69: * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils, jpayne@69: * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from jpayne@69: * accidentally using LZMA when they actually want LZMA2. jpayne@69: */ jpayne@69: #define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001) jpayne@69: jpayne@69: /** jpayne@69: * \brief LZMA1 Filter ID with extended options (for raw encoder/decoder) jpayne@69: * jpayne@69: * This is like LZMA_FILTER_LZMA1 but with this ID a few extra options jpayne@69: * are supported in the lzma_options_lzma structure: jpayne@69: * jpayne@69: * - A flag to tell the encoder if the end of payload marker (EOPM) alias jpayne@69: * end of stream (EOS) marker must be written at the end of the stream. jpayne@69: * In contrast, LZMA_FILTER_LZMA1 always writes the end marker. jpayne@69: * jpayne@69: * - Decoder needs to be told the uncompressed size of the stream jpayne@69: * or that it is unknown (using the special value UINT64_MAX). jpayne@69: * If the size is known, a flag can be set to allow the presence of jpayne@69: * the end marker anyway. In contrast, LZMA_FILTER_LZMA1 always jpayne@69: * behaves as if the uncompressed size was unknown. jpayne@69: * jpayne@69: * This allows handling file formats where LZMA1 streams are used but where jpayne@69: * the end marker isn't allowed or where it might not (always) be present. jpayne@69: * This extended LZMA1 functionality is provided as a Filter ID for raw jpayne@69: * encoder and decoder instead of adding new encoder and decoder initialization jpayne@69: * functions because this way it is possible to also use extra filters, jpayne@69: * for example, LZMA_FILTER_X86 in a filter chain with LZMA_FILTER_LZMA1EXT, jpayne@69: * which might be needed to handle some file formats. jpayne@69: */ jpayne@69: #define LZMA_FILTER_LZMA1EXT LZMA_VLI_C(0x4000000000000002) jpayne@69: jpayne@69: /** jpayne@69: * \brief LZMA2 Filter ID jpayne@69: * jpayne@69: * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds jpayne@69: * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion jpayne@69: * when trying to compress incompressible data), possibility to change jpayne@69: * lc/lp/pb in the middle of encoding, and some other internal improvements. jpayne@69: */ jpayne@69: #define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Match finders jpayne@69: * jpayne@69: * Match finder has major effect on both speed and compression ratio. jpayne@69: * Usually hash chains are faster than binary trees. jpayne@69: * jpayne@69: * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better jpayne@69: * choice, because binary trees get much higher compression ratio penalty jpayne@69: * with LZMA_SYNC_FLUSH. jpayne@69: * jpayne@69: * The memory usage formulas are only rough estimates, which are closest to jpayne@69: * reality when dict_size is a power of two. The formulas are more complex jpayne@69: * in reality, and can also change a little between liblzma versions. Use jpayne@69: * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. jpayne@69: */ jpayne@69: typedef enum { jpayne@69: LZMA_MF_HC3 = 0x03, jpayne@69: /**< jpayne@69: * \brief Hash Chain with 2- and 3-byte hashing jpayne@69: * jpayne@69: * Minimum nice_len: 3 jpayne@69: * jpayne@69: * Memory usage: jpayne@69: * - dict_size <= 16 MiB: dict_size * 7.5 jpayne@69: * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB jpayne@69: */ jpayne@69: jpayne@69: LZMA_MF_HC4 = 0x04, jpayne@69: /**< jpayne@69: * \brief Hash Chain with 2-, 3-, and 4-byte hashing jpayne@69: * jpayne@69: * Minimum nice_len: 4 jpayne@69: * jpayne@69: * Memory usage: jpayne@69: * - dict_size <= 32 MiB: dict_size * 7.5 jpayne@69: * - dict_size > 32 MiB: dict_size * 6.5 jpayne@69: */ jpayne@69: jpayne@69: LZMA_MF_BT2 = 0x12, jpayne@69: /**< jpayne@69: * \brief Binary Tree with 2-byte hashing jpayne@69: * jpayne@69: * Minimum nice_len: 2 jpayne@69: * jpayne@69: * Memory usage: dict_size * 9.5 jpayne@69: */ jpayne@69: jpayne@69: LZMA_MF_BT3 = 0x13, jpayne@69: /**< jpayne@69: * \brief Binary Tree with 2- and 3-byte hashing jpayne@69: * jpayne@69: * Minimum nice_len: 3 jpayne@69: * jpayne@69: * Memory usage: jpayne@69: * - dict_size <= 16 MiB: dict_size * 11.5 jpayne@69: * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB jpayne@69: */ jpayne@69: jpayne@69: LZMA_MF_BT4 = 0x14 jpayne@69: /**< jpayne@69: * \brief Binary Tree with 2-, 3-, and 4-byte hashing jpayne@69: * jpayne@69: * Minimum nice_len: 4 jpayne@69: * jpayne@69: * Memory usage: jpayne@69: * - dict_size <= 32 MiB: dict_size * 11.5 jpayne@69: * - dict_size > 32 MiB: dict_size * 10.5 jpayne@69: */ jpayne@69: } lzma_match_finder; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Test if given match finder is supported jpayne@69: * jpayne@69: * It is safe to call this with a value that isn't listed in jpayne@69: * lzma_match_finder enumeration; the return value will be false. jpayne@69: * jpayne@69: * There is no way to list which match finders are available in this jpayne@69: * particular liblzma version and build. It would be useless, because jpayne@69: * a new match finder, which the application developer wasn't aware, jpayne@69: * could require giving additional options to the encoder that the older jpayne@69: * match finders don't need. jpayne@69: * jpayne@69: * \param match_finder Match finder ID jpayne@69: * jpayne@69: * \return lzma_bool: jpayne@69: * - true if the match finder is supported by this liblzma build. jpayne@69: * - false otherwise. jpayne@69: */ jpayne@69: extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) jpayne@69: lzma_nothrow lzma_attr_const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Compression modes jpayne@69: * jpayne@69: * This selects the function used to analyze the data produced by the match jpayne@69: * finder. jpayne@69: */ jpayne@69: typedef enum { jpayne@69: LZMA_MODE_FAST = 1, jpayne@69: /**< jpayne@69: * \brief Fast compression jpayne@69: * jpayne@69: * Fast mode is usually at its best when combined with jpayne@69: * a hash chain match finder. jpayne@69: */ jpayne@69: jpayne@69: LZMA_MODE_NORMAL = 2 jpayne@69: /**< jpayne@69: * \brief Normal compression jpayne@69: * jpayne@69: * This is usually notably slower than fast mode. Use this jpayne@69: * together with binary tree match finders to expose the jpayne@69: * full potential of the LZMA1 or LZMA2 encoder. jpayne@69: */ jpayne@69: } lzma_mode; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Test if given compression mode is supported jpayne@69: * jpayne@69: * It is safe to call this with a value that isn't listed in lzma_mode jpayne@69: * enumeration; the return value will be false. jpayne@69: * jpayne@69: * There is no way to list which modes are available in this particular jpayne@69: * liblzma version and build. It would be useless, because a new compression jpayne@69: * mode, which the application developer wasn't aware, could require giving jpayne@69: * additional options to the encoder that the older modes don't need. jpayne@69: * jpayne@69: * \param mode Mode ID. jpayne@69: * jpayne@69: * \return lzma_bool: jpayne@69: * - true if the compression mode is supported by this liblzma jpayne@69: * build. jpayne@69: * - false otherwise. jpayne@69: */ jpayne@69: extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) jpayne@69: lzma_nothrow lzma_attr_const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Options specific to the LZMA1 and LZMA2 filters jpayne@69: * jpayne@69: * Since LZMA1 and LZMA2 share most of the code, it's simplest to share jpayne@69: * the options structure too. For encoding, all but the reserved variables jpayne@69: * need to be initialized unless specifically mentioned otherwise. jpayne@69: * lzma_lzma_preset() can be used to get a good starting point. jpayne@69: * jpayne@69: * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and jpayne@69: * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb. jpayne@69: */ jpayne@69: typedef struct { jpayne@69: /** jpayne@69: * \brief Dictionary size in bytes jpayne@69: * jpayne@69: * Dictionary size indicates how many bytes of the recently processed jpayne@69: * uncompressed data is kept in memory. One method to reduce size of jpayne@69: * the uncompressed data is to store distance-length pairs, which jpayne@69: * indicate what data to repeat from the dictionary buffer. Thus, jpayne@69: * the bigger the dictionary, the better the compression ratio jpayne@69: * usually is. jpayne@69: * jpayne@69: * Maximum size of the dictionary depends on multiple things: jpayne@69: * - Memory usage limit jpayne@69: * - Available address space (not a problem on 64-bit systems) jpayne@69: * - Selected match finder (encoder only) jpayne@69: * jpayne@69: * Currently the maximum dictionary size for encoding is 1.5 GiB jpayne@69: * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit jpayne@69: * systems for certain match finder implementation reasons. In the jpayne@69: * future, there may be match finders that support bigger jpayne@69: * dictionaries. jpayne@69: * jpayne@69: * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. jpayne@69: * UINT32_MAX), so increasing the maximum dictionary size of the jpayne@69: * encoder won't cause problems for old decoders. jpayne@69: * jpayne@69: * Because extremely small dictionaries sizes would have unneeded jpayne@69: * overhead in the decoder, the minimum dictionary size is 4096 bytes. jpayne@69: * jpayne@69: * \note When decoding, too big dictionary does no other harm jpayne@69: * than wasting memory. jpayne@69: */ jpayne@69: uint32_t dict_size; jpayne@69: # define LZMA_DICT_SIZE_MIN UINT32_C(4096) jpayne@69: # define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23) jpayne@69: jpayne@69: /** jpayne@69: * \brief Pointer to an initial dictionary jpayne@69: * jpayne@69: * It is possible to initialize the LZ77 history window using jpayne@69: * a preset dictionary. It is useful when compressing many jpayne@69: * similar, relatively small chunks of data independently from jpayne@69: * each other. The preset dictionary should contain typical jpayne@69: * strings that occur in the files being compressed. The most jpayne@69: * probable strings should be near the end of the preset dictionary. jpayne@69: * jpayne@69: * This feature should be used only in special situations. For jpayne@69: * now, it works correctly only with raw encoding and decoding. jpayne@69: * Currently none of the container formats supported by jpayne@69: * liblzma allow preset dictionary when decoding, thus if jpayne@69: * you create a .xz or .lzma file with preset dictionary, it jpayne@69: * cannot be decoded with the regular decoder functions. In the jpayne@69: * future, the .xz format will likely get support for preset jpayne@69: * dictionary though. jpayne@69: */ jpayne@69: const uint8_t *preset_dict; jpayne@69: jpayne@69: /** jpayne@69: * \brief Size of the preset dictionary jpayne@69: * jpayne@69: * Specifies the size of the preset dictionary. If the size is jpayne@69: * bigger than dict_size, only the last dict_size bytes are jpayne@69: * processed. jpayne@69: * jpayne@69: * This variable is read only when preset_dict is not NULL. jpayne@69: * If preset_dict is not NULL but preset_dict_size is zero, jpayne@69: * no preset dictionary is used (identical to only setting jpayne@69: * preset_dict to NULL). jpayne@69: */ jpayne@69: uint32_t preset_dict_size; jpayne@69: jpayne@69: /** jpayne@69: * \brief Number of literal context bits jpayne@69: * jpayne@69: * How many of the highest bits of the previous uncompressed jpayne@69: * eight-bit byte (also known as 'literal') are taken into jpayne@69: * account when predicting the bits of the next literal. jpayne@69: * jpayne@69: * E.g. in typical English text, an upper-case letter is jpayne@69: * often followed by a lower-case letter, and a lower-case jpayne@69: * letter is usually followed by another lower-case letter. jpayne@69: * In the US-ASCII character set, the highest three bits are 010 jpayne@69: * for upper-case letters and 011 for lower-case letters. jpayne@69: * When lc is at least 3, the literal coding can take advantage of jpayne@69: * this property in the uncompressed data. jpayne@69: * jpayne@69: * There is a limit that applies to literal context bits and literal jpayne@69: * position bits together: lc + lp <= 4. Without this limit the jpayne@69: * decoding could become very slow, which could have security related jpayne@69: * results in some cases like email servers doing virus scanning. jpayne@69: * This limit also simplifies the internal implementation in liblzma. jpayne@69: * jpayne@69: * There may be LZMA1 streams that have lc + lp > 4 (maximum possible jpayne@69: * lc would be 8). It is not possible to decode such streams with jpayne@69: * liblzma. jpayne@69: */ jpayne@69: uint32_t lc; jpayne@69: # define LZMA_LCLP_MIN 0 jpayne@69: # define LZMA_LCLP_MAX 4 jpayne@69: # define LZMA_LC_DEFAULT 3 jpayne@69: jpayne@69: /** jpayne@69: * \brief Number of literal position bits jpayne@69: * jpayne@69: * lp affects what kind of alignment in the uncompressed data is jpayne@69: * assumed when encoding literals. A literal is a single 8-bit byte. jpayne@69: * See pb below for more information about alignment. jpayne@69: */ jpayne@69: uint32_t lp; jpayne@69: # define LZMA_LP_DEFAULT 0 jpayne@69: jpayne@69: /** jpayne@69: * \brief Number of position bits jpayne@69: * jpayne@69: * pb affects what kind of alignment in the uncompressed data is jpayne@69: * assumed in general. The default means four-byte alignment jpayne@69: * (2^ pb =2^2=4), which is often a good choice when there's jpayne@69: * no better guess. jpayne@69: * jpayne@69: * When the alignment is known, setting pb accordingly may reduce jpayne@69: * the file size a little. E.g. with text files having one-byte jpayne@69: * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can jpayne@69: * improve compression slightly. For UTF-16 text, pb=1 is a good jpayne@69: * choice. If the alignment is an odd number like 3 bytes, pb=0 jpayne@69: * might be the best choice. jpayne@69: * jpayne@69: * Even though the assumed alignment can be adjusted with pb and jpayne@69: * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. jpayne@69: * It might be worth taking into account when designing file formats jpayne@69: * that are likely to be often compressed with LZMA1 or LZMA2. jpayne@69: */ jpayne@69: uint32_t pb; jpayne@69: # define LZMA_PB_MIN 0 jpayne@69: # define LZMA_PB_MAX 4 jpayne@69: # define LZMA_PB_DEFAULT 2 jpayne@69: jpayne@69: /** Compression mode */ jpayne@69: lzma_mode mode; jpayne@69: jpayne@69: /** jpayne@69: * \brief Nice length of a match jpayne@69: * jpayne@69: * This determines how many bytes the encoder compares from the match jpayne@69: * candidates when looking for the best match. Once a match of at jpayne@69: * least nice_len bytes long is found, the encoder stops looking for jpayne@69: * better candidates and encodes the match. (Naturally, if the found jpayne@69: * match is actually longer than nice_len, the actual length is jpayne@69: * encoded; it's not truncated to nice_len.) jpayne@69: * jpayne@69: * Bigger values usually increase the compression ratio and jpayne@69: * compression time. For most files, 32 to 128 is a good value, jpayne@69: * which gives very good compression ratio at good speed. jpayne@69: * jpayne@69: * The exact minimum value depends on the match finder. The maximum jpayne@69: * is 273, which is the maximum length of a match that LZMA1 and jpayne@69: * LZMA2 can encode. jpayne@69: */ jpayne@69: uint32_t nice_len; jpayne@69: jpayne@69: /** Match finder ID */ jpayne@69: lzma_match_finder mf; jpayne@69: jpayne@69: /** jpayne@69: * \brief Maximum search depth in the match finder jpayne@69: * jpayne@69: * For every input byte, match finder searches through the hash chain jpayne@69: * or binary tree in a loop, each iteration going one step deeper in jpayne@69: * the chain or tree. The searching stops if jpayne@69: * - a match of at least nice_len bytes long is found; jpayne@69: * - all match candidates from the hash chain or binary tree have jpayne@69: * been checked; or jpayne@69: * - maximum search depth is reached. jpayne@69: * jpayne@69: * Maximum search depth is needed to prevent the match finder from jpayne@69: * wasting too much time in case there are lots of short match jpayne@69: * candidates. On the other hand, stopping the search before all jpayne@69: * candidates have been checked can reduce compression ratio. jpayne@69: * jpayne@69: * Setting depth to zero tells liblzma to use an automatic default jpayne@69: * value, that depends on the selected match finder and nice_len. jpayne@69: * The default is in the range [4, 200] or so (it may vary between jpayne@69: * liblzma versions). jpayne@69: * jpayne@69: * Using a bigger depth value than the default can increase jpayne@69: * compression ratio in some cases. There is no strict maximum value, jpayne@69: * but high values (thousands or millions) should be used with care: jpayne@69: * the encoder could remain fast enough with typical input, but jpayne@69: * malicious input could cause the match finder to slow down jpayne@69: * dramatically, possibly creating a denial of service attack. jpayne@69: */ jpayne@69: uint32_t depth; jpayne@69: jpayne@69: /** jpayne@69: * \brief For LZMA_FILTER_LZMA1EXT: Extended flags jpayne@69: * jpayne@69: * This is used only with LZMA_FILTER_LZMA1EXT. jpayne@69: * jpayne@69: * Currently only one flag is supported, LZMA_LZMA1EXT_ALLOW_EOPM: jpayne@69: * jpayne@69: * - Encoder: If the flag is set, then end marker is written just jpayne@69: * like it is with LZMA_FILTER_LZMA1. Without this flag the jpayne@69: * end marker isn't written and the application has to store jpayne@69: * the uncompressed size somewhere outside the compressed stream. jpayne@69: * To decompress streams without the end marker, the application jpayne@69: * has to set the correct uncompressed size in ext_size_low and jpayne@69: * ext_size_high. jpayne@69: * jpayne@69: * - Decoder: If the uncompressed size in ext_size_low and jpayne@69: * ext_size_high is set to the special value UINT64_MAX jpayne@69: * (indicating unknown uncompressed size) then this flag is jpayne@69: * ignored and the end marker must always be present, that is, jpayne@69: * the behavior is identical to LZMA_FILTER_LZMA1. jpayne@69: * jpayne@69: * Otherwise, if this flag isn't set, then the input stream jpayne@69: * must not have the end marker; if the end marker is detected jpayne@69: * then it will result in LZMA_DATA_ERROR. This is useful when jpayne@69: * it is known that the stream must not have the end marker and jpayne@69: * strict validation is wanted. jpayne@69: * jpayne@69: * If this flag is set, then it is autodetected if the end marker jpayne@69: * is present after the specified number of uncompressed bytes jpayne@69: * has been decompressed (ext_size_low and ext_size_high). The jpayne@69: * end marker isn't allowed in any other position. This behavior jpayne@69: * is useful when uncompressed size is known but the end marker jpayne@69: * may or may not be present. This is the case, for example, jpayne@69: * in .7z files (valid .7z files that have the end marker in jpayne@69: * LZMA1 streams are rare but they do exist). jpayne@69: */ jpayne@69: uint32_t ext_flags; jpayne@69: # define LZMA_LZMA1EXT_ALLOW_EOPM UINT32_C(0x01) jpayne@69: jpayne@69: /** jpayne@69: * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (low bits) jpayne@69: * jpayne@69: * The 64-bit uncompressed size is needed for decompression with jpayne@69: * LZMA_FILTER_LZMA1EXT. The size is ignored by the encoder. jpayne@69: * jpayne@69: * The special value UINT64_MAX indicates that the uncompressed size jpayne@69: * is unknown and that the end of payload marker (also known as jpayne@69: * end of stream marker) must be present to indicate the end of jpayne@69: * the LZMA1 stream. Any other value indicates the expected jpayne@69: * uncompressed size of the LZMA1 stream. (If LZMA1 was used together jpayne@69: * with filters that change the size of the data then the uncompressed jpayne@69: * size of the LZMA1 stream could be different than the final jpayne@69: * uncompressed size of the filtered stream.) jpayne@69: * jpayne@69: * ext_size_low holds the least significant 32 bits of the jpayne@69: * uncompressed size. The most significant 32 bits must be set jpayne@69: * in ext_size_high. The macro lzma_set_ext_size(opt_lzma, u64size) jpayne@69: * can be used to set these members. jpayne@69: * jpayne@69: * The 64-bit uncompressed size is split into two uint32_t variables jpayne@69: * because there were no reserved uint64_t members and using the jpayne@69: * same options structure for LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA1EXT, jpayne@69: * and LZMA_FILTER_LZMA2 was otherwise more convenient than having jpayne@69: * a new options structure for LZMA_FILTER_LZMA1EXT. (Replacing two jpayne@69: * uint32_t members with one uint64_t changes the ABI on some systems jpayne@69: * as the alignment of this struct can increase from 4 bytes to 8.) jpayne@69: */ jpayne@69: uint32_t ext_size_low; jpayne@69: jpayne@69: /** jpayne@69: * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (high bits) jpayne@69: * jpayne@69: * This holds the most significant 32 bits of the uncompressed size. jpayne@69: */ jpayne@69: uint32_t ext_size_high; jpayne@69: jpayne@69: /* jpayne@69: * Reserved space to allow possible future extensions without jpayne@69: * breaking the ABI. You should not touch these, because the names jpayne@69: * of these variables may change. These are and will never be used jpayne@69: * with the currently supported options, so it is safe to leave these jpayne@69: * uninitialized. jpayne@69: */ jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: uint32_t reserved_int4; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: uint32_t reserved_int5; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: uint32_t reserved_int6; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: uint32_t reserved_int7; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: uint32_t reserved_int8; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: lzma_reserved_enum reserved_enum1; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: lzma_reserved_enum reserved_enum2; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: lzma_reserved_enum reserved_enum3; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: lzma_reserved_enum reserved_enum4; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: void *reserved_ptr1; jpayne@69: jpayne@69: /** \private Reserved member. */ jpayne@69: void *reserved_ptr2; jpayne@69: jpayne@69: } lzma_options_lzma; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Macro to set the 64-bit uncompressed size in ext_size_* jpayne@69: * jpayne@69: * This might be convenient when decoding using LZMA_FILTER_LZMA1EXT. jpayne@69: * This isn't used with LZMA_FILTER_LZMA1 or LZMA_FILTER_LZMA2. jpayne@69: */ jpayne@69: #define lzma_set_ext_size(opt_lzma2, u64size) \ jpayne@69: do { \ jpayne@69: (opt_lzma2).ext_size_low = (uint32_t)(u64size); \ jpayne@69: (opt_lzma2).ext_size_high = (uint32_t)((uint64_t)(u64size) >> 32); \ jpayne@69: } while (0) jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * \brief Set a compression preset to lzma_options_lzma structure jpayne@69: * jpayne@69: * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 jpayne@69: * of the xz command line tool. In addition, it is possible to bitwise-or jpayne@69: * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. jpayne@69: * The flags are defined in container.h, because the flags are used also jpayne@69: * with lzma_easy_encoder(). jpayne@69: * jpayne@69: * The preset levels are subject to changes between liblzma versions. jpayne@69: * jpayne@69: * This function is available only if LZMA1 or LZMA2 encoder has been enabled jpayne@69: * when building liblzma. jpayne@69: * jpayne@69: * If features (like certain match finders) have been disabled at build time, jpayne@69: * then the function may return success (false) even though the resulting jpayne@69: * LZMA1/LZMA2 options may not be usable for encoder initialization jpayne@69: * (LZMA_OPTIONS_ERROR). jpayne@69: * jpayne@69: * \param[out] options Pointer to LZMA1 or LZMA2 options to be filled jpayne@69: * \param preset Preset level bitwse-ORed with preset flags jpayne@69: * jpayne@69: * \return lzma_bool: jpayne@69: * - true if the preset is not supported (failure). jpayne@69: * - false otherwise (success). jpayne@69: */ jpayne@69: extern LZMA_API(lzma_bool) lzma_lzma_preset( jpayne@69: lzma_options_lzma *options, uint32_t preset) lzma_nothrow;