lzma.h   lzma.h 
skipping to change at line 47 skipping to change at line 47
* lc/lp/pb in the middle of encoding, and some other internal improvements . * lc/lp/pb in the middle of encoding, and some other internal improvements .
*/ */
#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) #define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
/** /**
* \brief Match finders * \brief Match finders
* *
* Match finder has major effect on both speed and compression ratio. * Match finder has major effect on both speed and compression ratio.
* Usually hash chains are faster than binary trees. * Usually hash chains are faster than binary trees.
* *
* If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
* choice, because binary trees get much higher compression ratio penalty
* with LZMA_SYNC_FLUSH.
*
* The memory usage formulas are only rough estimates, which are closest to * The memory usage formulas are only rough estimates, which are closest to
* reality when dict_size is a power of two. The formulas are more complex * reality when dict_size is a power of two. The formulas are more complex
* in reality, and can also change a little between liblzma versions. Use * in reality, and can also change a little between liblzma versions. Use
* lzma_raw_encoder_memusage() to get more accurate estimate of memory usag e. * lzma_memusage_encoder() to get more accurate estimate of memory usage.
*/ */
typedef enum { typedef enum {
LZMA_MF_HC3 = 0x03, LZMA_MF_HC3 = 0x03,
/**< /**<
* \brief Hash Chain with 2- and 3-byte hashing * \brief Hash Chain with 2- and 3-byte hashing
* *
* Minimum nice_len: 3 * Minimum nice_len: 3
* *
* Memory usage: * Memory usage:
* - dict_size <= 16 MiB: dict_size * 7.5 * - dict_size <= 16 MiB: dict_size * 7.5
* - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
*/ */
LZMA_MF_HC4 = 0x04, LZMA_MF_HC4 = 0x04,
/**< /**<
* \brief Hash Chain with 2-, 3-, and 4-byte hashing * \brief Hash Chain with 2-, 3-, and 4-byte hashing
* *
* Minimum nice_len: 4 * Minimum nice_len: 4
* *
* Memory usage: * Memory usage: dict_size * 7.5
* - dict_size <= 32 MiB: dict_size * 7.5
* - dict_size > 32 MiB: dict_size * 6.5
*/ */
LZMA_MF_BT2 = 0x12, LZMA_MF_BT2 = 0x12,
/**< /**<
* \brief Binary Tree with 2-byte hashing * \brief Binary Tree with 2-byte hashing
* *
* Minimum nice_len: 2 * Minimum nice_len: 2
* *
* Memory usage: dict_size * 9.5 * Memory usage: dict_size * 9.5
*/ */
skipping to change at line 105 skipping to change at line 99
* - dict_size <= 16 MiB: dict_size * 11.5 * - dict_size <= 16 MiB: dict_size * 11.5
* - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
*/ */
LZMA_MF_BT4 = 0x14 LZMA_MF_BT4 = 0x14
/**< /**<
* \brief Binary Tree with 2-, 3-, and 4-byte hashing * \brief Binary Tree with 2-, 3-, and 4-byte hashing
* *
* Minimum nice_len: 4 * Minimum nice_len: 4
* *
* Memory usage: * Memory usage: dict_size * 11.5
* - dict_size <= 32 MiB: dict_size * 11.5
* - dict_size > 32 MiB: dict_size * 10.5
*/ */
} lzma_match_finder; } lzma_match_finder;
/** /**
* \brief Test if given match finder is supported * \brief Test if given match finder is supported
* *
* Return true if the given match finder is supported by this liblzma build . * Return true if the given match finder is supported by this liblzma build .
* Otherwise false is returned. It is safe to call this with a value that * Otherwise false is returned. It is safe to call this with a value that
* isn't listed in lzma_match_finder enumeration; the return value will be * isn't listed in lzma_match_finder enumeration; the return value will be
* false. * false.
skipping to change at line 174 skipping to change at line 166
*/ */
extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
lzma_nothrow lzma_attr_const; lzma_nothrow lzma_attr_const;
/** /**
* \brief Options specific to the LZMA1 and LZMA2 filters * \brief Options specific to the LZMA1 and LZMA2 filters
* *
* Since LZMA1 and LZMA2 share most of the code, it's simplest to share * 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 * the options structure too. For encoding, all but the reserved variables
* need to be initialized unless specifically mentioned otherwise. * 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 * 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. * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
*/ */
typedef struct { typedef struct {
/** /**
* \brief Dictionary size in bytes * \brief Dictionary size in bytes
* *
* Dictionary size indicates how many bytes of the recently processe d * Dictionary size indicates how many bytes of the recently processe d
* uncompressed data is kept in memory. One method to reduce size of * uncompressed data is kept in memory. One method to reduce size of
skipping to change at line 257 skipping to change at line 248
*/ */
uint32_t preset_dict_size; uint32_t preset_dict_size;
/** /**
* \brief Number of literal context bits * \brief Number of literal context bits
* *
* How many of the highest bits of the previous uncompressed * How many of the highest bits of the previous uncompressed
* eight-bit byte (also known as `literal') are taken into * eight-bit byte (also known as `literal') are taken into
* account when predicting the bits of the next literal. * account when predicting the bits of the next literal.
* *
* E.g. in typical English text, an upper-case letter is * \todo Example
* 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 * There is a limit that applies to literal context bits and literal
* position bits together: lc + lp <= 4. Without this limit the * position bits together: lc + lp <= 4. Without this limit the
* decoding could become very slow, which could have security relate d * decoding could become very slow, which could have security relate d
* results in some cases like email servers doing virus scanning. * results in some cases like email servers doing virus scanning.
* This limit also simplifies the internal implementation in liblzma . * This limit also simplifies the internal implementation in liblzma .
* *
* There may be LZMA1 streams that have lc + lp > 4 (maximum possibl e * There may be LZMA1 streams that have lc + lp > 4 (maximum possibl e
* lc would be 8). It is not possible to decode such streams with * lc would be 8). It is not possible to decode such streams with
* liblzma. * liblzma.
*/ */
uint32_t lc; uint32_t lc;
# define LZMA_LCLP_MIN 0 # define LZMA_LCLP_MIN 0
# define LZMA_LCLP_MAX 4 # define LZMA_LCLP_MAX 4
# define LZMA_LC_DEFAULT 3 # define LZMA_LC_DEFAULT 3
/** /**
* \brief Number of literal position bits * \brief Number of literal position bits
* *
* lp affects what kind of alignment in the uncompressed data is * How many of the lowest bits of the current position (number
* assumed when encoding literals. A literal is a single 8-bit byte. * of bytes from the beginning of the uncompressed data) in the
* See pb below for more information about alignment. * uncompressed data is taken into account when predicting the
* bits of the next literal (a single eight-bit byte).
*
* \todo Example
*/ */
uint32_t lp; uint32_t lp;
# define LZMA_LP_DEFAULT 0 # define LZMA_LP_DEFAULT 0
/** /**
* \brief Number of position bits * \brief Number of position bits
* *
* pb affects what kind of alignment in the uncompressed data is * How many of the lowest bits of the current position in the
* assumed in general. The default means four-byte alignment * uncompressed data is taken into account when estimating
* (2^ pb =2^2=4), which is often a good choice when there's * probabilities of matches. A match is a sequence of bytes for
* no better guess. * which a matching sequence is found from the dictionary and
* * thus can be stored as distance-length pair.
* When the aligment is known, setting pb accordingly may reduce *
* the file size a little. E.g. with text files having one-byte * Example: If most of the matches occur at byte positions of
* alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can * 8 * n + 3, that is, 3, 11, 19, ... set pb to 3, because 2**3 == 8
* 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.
*/ */
uint32_t pb; uint32_t pb;
# define LZMA_PB_MIN 0 # define LZMA_PB_MIN 0
# define LZMA_PB_MAX 4 # define LZMA_PB_MAX 4
# define LZMA_PB_DEFAULT 2 # define LZMA_PB_DEFAULT 2
/** Compression mode */ /** Compression mode */
lzma_mode mode; lzma_mode mode;
/** /**
skipping to change at line 359 skipping to change at line 339
* been checked; or * been checked; or
* - maximum search depth is reached. * - maximum search depth is reached.
* *
* Maximum search depth is needed to prevent the match finder from * Maximum search depth is needed to prevent the match finder from
* wasting too much time in case there are lots of short match * wasting too much time in case there are lots of short match
* candidates. On the other hand, stopping the search before all * candidates. On the other hand, stopping the search before all
* candidates have been checked can reduce compression ratio. * candidates have been checked can reduce compression ratio.
* *
* Setting depth to zero tells liblzma to use an automatic default * Setting depth to zero tells liblzma to use an automatic default
* value, that depends on the selected match finder and nice_len. * 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 * The default is in the range [10, 200] or so (it may vary between
* liblzma versions). * liblzma versions).
* *
* Using a bigger depth value than the default can increase * Using a bigger depth value than the default can increase
* compression ratio in some cases. There is no strict maximum value , * compression ratio in some cases. There is no strict maximum value ,
* but high values (thousands or millions) should be used with care: * but high values (thousands or millions) should be used with care:
* the encoder could remain fast enough with typical input, but * the encoder could remain fast enough with typical input, but
* malicious input could cause the match finder to slow down * malicious input could cause the match finder to slow down
* dramatically, possibly creating a denial of service attack. * dramatically, possibly creating a denial of service attack.
*/ */
uint32_t depth; uint32_t depth;
/* /*
* Reserved space to allow possible future extensions without * Reserved space to allow possible future extensions without
* breaking the ABI. You should not touch these, because the names * breaking the ABI. You should not touch these, because the names
* of these variables may change. These are and will never be used * of these variables may change. These are and will never be used
* with the currently supported options, so it is safe to leave thes e * with the currently supported options, so it is safe to leave thes e
* uninitialized. * uninitialized.
*/ */
void *reserved_ptr1;
void *reserved_ptr2;
uint32_t reserved_int1; uint32_t reserved_int1;
uint32_t reserved_int2; uint32_t reserved_int2;
uint32_t reserved_int3; uint32_t reserved_int3;
uint32_t reserved_int4; uint32_t reserved_int4;
uint32_t reserved_int5; uint32_t reserved_int5;
uint32_t reserved_int6; uint32_t reserved_int6;
uint32_t reserved_int7; uint32_t reserved_int7;
uint32_t reserved_int8; uint32_t reserved_int8;
lzma_reserved_enum reserved_enum1; lzma_reserved_enum reserved_enum1;
lzma_reserved_enum reserved_enum2; lzma_reserved_enum reserved_enum2;
lzma_reserved_enum reserved_enum3; lzma_reserved_enum reserved_enum3;
lzma_reserved_enum reserved_enum4; lzma_reserved_enum reserved_enum4;
void *reserved_ptr1;
void *reserved_ptr2;
} lzma_options_lzma; } lzma_options_lzma;
/** /**
* \brief Set a compression preset to lzma_options_lzma structure * \brief Set a compression preset to lzma_options_lzma structure
* *
* 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
* of the xz command line tool. In addition, it is possible to bitwise-or * of the xz command line tool. In addition, it is possible to bitwise-or
* flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
* The flags are defined in container.h, because the flags are used also * The flags are defined in container.h, because the flags are used also
* with lzma_easy_encoder(). * with lzma_easy_encoder().
* *
* The preset values are subject to changes between liblzma versions. * The preset values are subject to changes between liblzma versions.
* *
* This function is available only if LZMA1 or LZMA2 encoder has been enabl ed * This function is available only if LZMA1 or LZMA2 encoder has been enabl ed
* when building liblzma. * when building liblzma.
*
* \return On success, false is returned. If the preset is not
* supported, true is returned.
*/ */
extern LZMA_API(lzma_bool) lzma_lzma_preset( extern LZMA_API(lzma_bool) lzma_lzma_preset(
lzma_options_lzma *options, uint32_t preset) lzma_nothrow; lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
 End of changes. 12 change blocks. 
44 lines changed or deleted 22 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/