diff options
author | Karl Berry <karl@freefriends.org> | 2011-04-03 23:53:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-04-03 23:53:28 +0000 |
commit | 1e665e264ead3dedcf83afc950c43a6764a79884 (patch) | |
tree | f2de017feac2b53a9fc3c15b31d9dba1541a7837 /Build/source/extra/xz/src/liblzma | |
parent | 7566b1e9fc57db87642f5e344164e5bbfe209b50 (diff) |
xz 5.0.2, from http://tukaani.org/xz/xz-5.0.2.tar.xz
git-svn-id: svn://tug.org/texlive/trunk@21944 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/extra/xz/src/liblzma')
28 files changed, 217 insertions, 157 deletions
diff --git a/Build/source/extra/xz/src/liblzma/Makefile.am b/Build/source/extra/xz/src/liblzma/Makefile.am index f6c572b2885..813dc406760 100644 --- a/Build/source/extra/xz/src/liblzma/Makefile.am +++ b/Build/source/extra/xz/src/liblzma/Makefile.am @@ -24,7 +24,7 @@ liblzma_la_CPPFLAGS = \ -I$(top_srcdir)/src/liblzma/simple \ -I$(top_srcdir)/src/common \ -DTUKLIB_SYMBOL_PREFIX=lzma_ -liblzma_la_LDFLAGS = -no-undefined -version-info 0:0:0 +liblzma_la_LDFLAGS = -no-undefined -version-info 5:2:0 include $(srcdir)/common/Makefile.inc include $(srcdir)/check/Makefile.inc diff --git a/Build/source/extra/xz/src/liblzma/Makefile.in b/Build/source/extra/xz/src/liblzma/Makefile.in index 4179c1b5467..7a9e268c452 100644 --- a/Build/source/extra/xz/src/liblzma/Makefile.in +++ b/Build/source/extra/xz/src/liblzma/Makefile.in @@ -192,6 +192,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/tuklib_common.m4 \ $(top_srcdir)/m4/tuklib_cpucores.m4 \ $(top_srcdir)/m4/tuklib_integer.m4 \ + $(top_srcdir)/m4/tuklib_mbstr.m4 \ $(top_srcdir)/m4/tuklib_physmem.m4 \ $(top_srcdir)/m4/tuklib_progname.m4 \ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac @@ -450,8 +451,6 @@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ -DYNAMIC_CPPFLAGS = @DYNAMIC_CPPFLAGS@ -DYNAMIC_LDFLAGS = @DYNAMIC_LDFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -484,6 +483,7 @@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ @@ -513,8 +513,6 @@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ -STATIC_CPPFLAGS = @STATIC_CPPFLAGS@ -STATIC_LDFLAGS = @STATIC_LDFLAGS@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -524,6 +522,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ @@ -610,7 +609,7 @@ liblzma_la_CPPFLAGS = \ -I$(top_srcdir)/src/common \ -DTUKLIB_SYMBOL_PREFIX=lzma_ -liblzma_la_LDFLAGS = -no-undefined -version-info 0:0:0 \ +liblzma_la_LDFLAGS = -no-undefined -version-info 5:2:0 \ $(am__append_38) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = liblzma.pc diff --git a/Build/source/extra/xz/src/liblzma/api/Makefile.in b/Build/source/extra/xz/src/liblzma/api/Makefile.in index 186506cd876..82c8eb0b1ae 100644 --- a/Build/source/extra/xz/src/liblzma/api/Makefile.in +++ b/Build/source/extra/xz/src/liblzma/api/Makefile.in @@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/tuklib_common.m4 \ $(top_srcdir)/m4/tuklib_cpucores.m4 \ $(top_srcdir)/m4/tuklib_integer.m4 \ + $(top_srcdir)/m4/tuklib_mbstr.m4 \ $(top_srcdir)/m4/tuklib_physmem.m4 \ $(top_srcdir)/m4/tuklib_progname.m4 \ $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac @@ -110,8 +111,6 @@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ -DYNAMIC_CPPFLAGS = @DYNAMIC_CPPFLAGS@ -DYNAMIC_LDFLAGS = @DYNAMIC_LDFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -144,6 +143,7 @@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ @@ -173,8 +173,6 @@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ -STATIC_CPPFLAGS = @STATIC_CPPFLAGS@ -STATIC_LDFLAGS = @STATIC_LDFLAGS@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -184,6 +182,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ diff --git a/Build/source/extra/xz/src/liblzma/api/lzma.h b/Build/source/extra/xz/src/liblzma/api/lzma.h index fb593a35a07..fb874c3e137 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma.h @@ -60,8 +60,8 @@ * * Some could argue that liblzma API should provide all the required types, * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was - * seen unnecessary mess, since most systems already provide all the necessary - * types and macros in the standard headers. + * seen as an unnecessary mess, since most systems already provide all the + * necessary types and macros in the standard headers. * * Note that liblzma API still has lzma_bool, because using stdbool.h would * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/base.h b/Build/source/extra/xz/src/liblzma/api/lzma/base.h index 993626a4cdf..43dde8d60f3 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/base.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/base.h @@ -281,21 +281,21 @@ typedef enum { * Using LZMA_SYNC_FLUSH very often can dramatically reduce * the compression ratio. With some filters (for example, * LZMA2), fine-tuning the compression options may help - * mitigate this problem significantly. + * mitigate this problem significantly (for example, + * match finder with LZMA2). * * Decoders don't support LZMA_SYNC_FLUSH. */ LZMA_FULL_FLUSH = 2, /**< - * \brief Make all the input available at output + * \brief Finish encoding of the current Block * - * Finish encoding of the current Block. All the input - * data going to the current Block must have been given - * to the encoder (the last bytes can still be pending in - * next_in). Call lzma_code() with LZMA_FULL_FLUSH until - * it returns LZMA_STREAM_END. Then continue normally with - * LZMA_RUN or finish the Stream with LZMA_FINISH. + * All the input data going to the current Block must have + * been given to the encoder (the last bytes can still be + * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH + * until it returns LZMA_STREAM_END. Then continue normally + * with LZMA_RUN or finish the Stream with LZMA_FINISH. * * This action is currently supported only by Stream encoder * and easy encoder (which uses Stream encoder). If there is @@ -306,12 +306,12 @@ typedef enum { /**< * \brief Finish the coding operation * - * Finishes the coding operation. All the input data must - * have been given to the encoder (the last bytes can still - * be pending in next_in). Call lzma_code() with LZMA_FINISH - * until it returns LZMA_STREAM_END. Once LZMA_FINISH has - * been used, the amount of input must no longer be changed - * by the application. + * All the input data must have been given to the encoder + * (the last bytes can still be pending in next_in). + * Call lzma_code() with LZMA_FINISH until it returns + * LZMA_STREAM_END. Once LZMA_FINISH has been used, + * the amount of input must no longer be changed by + * the application. * * When decoding, using LZMA_FINISH is optional unless the * LZMA_CONCATENATED flag was used when the decoder was @@ -478,8 +478,12 @@ typedef struct { */ void *reserved_ptr1; void *reserved_ptr2; + void *reserved_ptr3; + void *reserved_ptr4; uint64_t reserved_int1; uint64_t reserved_int2; + size_t reserved_int3; + size_t reserved_int4; lzma_reserved_enum reserved_enum1; lzma_reserved_enum reserved_enum2; @@ -506,7 +510,8 @@ typedef struct { */ #define LZMA_STREAM_INIT \ { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ - NULL, NULL, 0, 0, LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } + NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ + LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } /** @@ -554,11 +559,11 @@ extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; * this may give misleading information if decoding .xz Streams that have * multiple Blocks, because each Block can have different memory requirements. * - * \return Rough estimate of how much memory is currently allocated - * for the filter decoders. If no filter chain is currently - * allocated, some non-zero value is still returned, which is - * less than or equal to what any filter chain would indicate - * as its memory requirement. + * \return How much memory is currently allocated for the filter + * decoders. If no filter chain is currently allocated, + * some non-zero value is still returned, which is less than + * or equal to what any filter chain would indicate as its + * memory requirement. * * If this function isn't supported by *strm or some other error * occurs, zero is returned. diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/bcj.h b/Build/source/extra/xz/src/liblzma/api/lzma/bcj.h index 82e4a440b21..8e37538ad4a 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/bcj.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/bcj.h @@ -31,7 +31,7 @@ #define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) /**< - * Filter for IA64 (Itanium) binaries. + * Filter for IA-64 (Itanium) binaries. */ #define LZMA_FILTER_ARM LZMA_VLI_C(0x07) @@ -41,7 +41,7 @@ #define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) /**< - * Filter for ARMThumb binaries. + * Filter for ARM-Thumb binaries. */ #define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/block.h b/Build/source/extra/xz/src/liblzma/api/lzma/block.h index 8e681ed2811..3019bf916fe 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/block.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/block.h @@ -318,8 +318,8 @@ extern LZMA_API(lzma_ret) lzma_block_header_encode( * The size of the Block Header must have already been decoded with * lzma_block_header_size_decode() macro and stored to block->header_size. * - * block->filters must have been allocated, but not necessarily initialized. - * Possible existing filter options are _not_ freed. + * block->filters must have been allocated, but they don't need to be + * initialized (possible existing filter options are not freed). * * \param block Destination for Block options. * \param allocator lzma_allocator for custom allocator functions. diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/container.h b/Build/source/extra/xz/src/liblzma/api/lzma/container.h index 0d907650fc4..83e70b44f22 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/container.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/container.h @@ -55,13 +55,13 @@ * * This flag doesn't affect the memory usage requirements of the decoder (at * least not significantly). The memory usage of the encoder may be increased - * a little but only at the lowest preset levels (0-2). + * a little but only at the lowest preset levels (0-3). */ #define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) /** - * \brief Calculate rough memory usage of easy encoder + * \brief Calculate approximate memory usage of easy encoder * * This function is a wrapper for lzma_raw_encoder_memusage(). * @@ -72,7 +72,7 @@ extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) /** - * \brief Calculate rough decoder memory usage of a preset + * \brief Calculate approximate decoder memory usage of a preset * * This function is a wrapper for lzma_raw_decoder_memusage(). * @@ -93,16 +93,19 @@ extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) * \param preset Compression preset to use. A preset consist of level * number and zero or more flags. Usually flags aren't * used, so preset is simply a number [0, 9] which match - * the options -0 .. -9 of the xz command line tool. + * the options -0 ... -9 of the xz command line tool. * Additional flags can be be set using bitwise-or with * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. * \param check Integrity check type to use. See check.h for available - * checks. If you are unsure, use LZMA_CHECK_CRC32. + * checks. The xz command line tool defaults to + * LZMA_CHECK_CRC64, which is a good choice if you are + * unsure. LZMA_CHECK_CRC32 is good too as long as the + * uncompressed file is not many gigabytes. * * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to * encode your data. * - LZMA_MEM_ERROR: Memory allocation failed. - * - LZMA_OPTIONS_ERROR: The given compression level is not + * - LZMA_OPTIONS_ERROR: The given compression preset is not * supported by this build of liblzma. * - LZMA_UNSUPPORTED_CHECK: The given check type is not * supported by this liblzma build. @@ -310,7 +313,8 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * \brief Initialize .xz Stream decoder * * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Rough memory usage limit as bytes + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. * \param flags Bitwise-or of zero or more of the decoder flags: * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED @@ -318,6 +322,7 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * \return - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_OPTIONS_ERROR: Unsupported flags + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_stream_decoder( lzma_stream *strm, uint64_t memlimit, uint32_t flags) @@ -332,12 +337,14 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder( * of the input file has been detected. * * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Rough memory usage limit as bytes + * \param memlimit Memory usage limit as bytes. Use UINT64_MAX + * to effectively disable the limiter. * \param flags Bitwise-or of flags, or zero for no flags. * * \return - LZMA_OK: Initialization was successful. * - LZMA_MEM_ERROR: Cannot allocate memory. * - LZMA_OPTIONS_ERROR: Unsupported flags + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_auto_decoder( lzma_stream *strm, uint64_t memlimit, uint32_t flags) @@ -353,6 +360,7 @@ extern LZMA_API(lzma_ret) lzma_auto_decoder( * * \return - LZMA_OK * - LZMA_MEM_ERROR + * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_alone_decoder( lzma_stream *strm, uint64_t memlimit) @@ -379,7 +387,7 @@ extern LZMA_API(lzma_ret) lzma_alone_decoder( * won't be read is in[in_size]. * \param out Beginning of the output buffer * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. + * *out_pos is updated only if decoding succeeds. * \param out_size Size of the out buffer; the first byte into * which no data is written to is out[out_size]. * diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/filter.h b/Build/source/extra/xz/src/liblzma/api/lzma/filter.h index 038a93398c6..efd036f7f04 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/filter.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/filter.h @@ -1,6 +1,6 @@ /** * \file lzma/filter.h - * \brief Common filter related types + * \brief Common filter related types and functions */ /* @@ -59,11 +59,6 @@ typedef struct { * If the filter doesn't need options, set this to NULL. If id is * set to LZMA_VLI_UNKNOWN, options is ignored, and thus * doesn't need be initialized. - * - * Some filters support changing the options in the middle of - * the encoding process. These filters store the pointer of the - * options structure and communicate with the application via - * modifications of the options structure. */ void *options; @@ -126,15 +121,16 @@ extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src, /** - * \brief Calculate rough memory requirements for raw encoder + * \brief Calculate approximate memory requirements for raw encoder * - * Because the calculation is rough, this function can be used to calculate - * the memory requirements for Block and Stream encoders too. + * This function can be used to calculate the memory requirements for + * Block and Stream encoders too because Block and Stream encoders don't + * need significantly more memory than raw encoder. * * \param filters Array of filters terminated with * .id == LZMA_VLI_UNKNOWN. * - * \return Rough number of bytes of memory required for the given + * \return Number of bytes of memory required for the given * filter chain when encoding. */ extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) @@ -142,15 +138,16 @@ extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) /** - * \brief Calculate rough memory requirements for raw decoder + * \brief Calculate approximate memory requirements for raw decoder * - * Because the calculation is rough, this function can be used to calculate - * the memory requirements for Block and Stream decoders too. + * This function can be used to calculate the memory requirements for + * Block and Stream decoders too because Block and Stream decoders don't + * need significantly more memory than raw decoder. * * \param filters Array of filters terminated with * .id == LZMA_VLI_UNKNOWN. * - * \return Rough number of bytes of memory required for the given + * \return Number of bytes of memory required for the given * filter chain when decoding. */ extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) @@ -251,7 +248,8 @@ extern LZMA_API(lzma_ret) lzma_filters_update( * * \note There is no function to calculate how big output buffer * would surely be big enough. (lzma_stream_buffer_bound() - * works only for lzma_stream_buffer_encode().) + * works only for lzma_stream_buffer_encode(); raw encoder + * won't necessarily meet that bound.) */ extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( const lzma_filter *filters, lzma_allocator *allocator, @@ -323,9 +321,10 @@ extern LZMA_API(lzma_ret) lzma_properties_size( * succeeds but using the same options to initialize the encoder * will fail. * - * \note It is OK to skip calling this function if - * lzma_properties_size() indicated that the size - * of the Filter Properties field is zero. + * \note If lzma_properties_size() indicated that the size + * of the Filter Properties field is zero, calling + * lzma_properties_encode() is not required, but it + * won't do any harm either. */ extern LZMA_API(lzma_ret) lzma_properties_encode( const lzma_filter *filter, uint8_t *props) lzma_nothrow; @@ -364,11 +363,11 @@ extern LZMA_API(lzma_ret) lzma_properties_decode( * memory to hold the encoded Filter Flags. * * \param size Pointer to integer to hold the calculated size - * \param filters Filter ID and associated options whose encoded + * \param filter Filter ID and associated options whose encoded * size is to be calculated * * \return - LZMA_OK: *size set successfully. Note that this doesn't - * guarantee that filters->options is valid, thus + * guarantee that filter->options is valid, thus * lzma_filter_flags_encode() may still fail. * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. * - LZMA_PROG_ERROR: Invalid options @@ -377,7 +376,7 @@ extern LZMA_API(lzma_ret) lzma_properties_decode( * you need to loop over every lzma_filter entry. */ extern LZMA_API(lzma_ret) lzma_filter_flags_size( - uint32_t *size, const lzma_filter *filters) + uint32_t *size, const lzma_filter *filter) lzma_nothrow lzma_attr_warn_unused_result; @@ -387,7 +386,7 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_size( * In contrast to some functions, this doesn't allocate the needed buffer. * This is due to how this function is used internally by liblzma. * - * \param filters Filter ID and options to be encoded + * \param filter Filter ID and options to be encoded * \param out Beginning of the output buffer * \param out_pos out[*out_pos] is the next write position. This * is updated by the encoder. @@ -399,7 +398,7 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_size( * buffer space (you should have checked it with * lzma_filter_flags_size()). */ -extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filters, +extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow lzma_attr_warn_unused_result; @@ -407,8 +406,8 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filters, /** * \brief Decode Filter Flags from given buffer * - * The decoded result is stored into *filters. filters->options is - * initialized but the old value is NOT free()d. + * The decoded result is stored into *filter. The old value of + * filter->options is not free()d. * * \return - LZMA_OK * - LZMA_OPTIONS_ERROR @@ -416,6 +415,6 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filters, * - LZMA_PROG_ERROR */ extern LZMA_API(lzma_ret) lzma_filter_flags_decode( - lzma_filter *filters, lzma_allocator *allocator, + lzma_filter *filter, lzma_allocator *allocator, const uint8_t *in, size_t *in_pos, size_t in_size) lzma_nothrow lzma_attr_warn_unused_result; diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/hardware.h b/Build/source/extra/xz/src/liblzma/api/lzma/hardware.h index f44cb602ff9..e7dd03c3e8d 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/hardware.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/hardware.h @@ -39,8 +39,7 @@ * * This function may be useful when determining a reasonable memory * usage limit for decompressing or how much memory it is OK to use - * for compressing. For example, the default limit used by the xz - * command line tool is 40 % of RAM. + * for compressing. * * \return On success, the total amount of physical memory in bytes * is returned. If the amount of RAM cannot be determined, diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/index.h b/Build/source/extra/xz/src/liblzma/api/lzma/index.h index 5ea12e359e5..16bacc287df 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/index.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/index.h @@ -136,6 +136,13 @@ typedef struct { * * This offset is relative to the beginning of the lzma_index * (i.e. usually the beginning of the .xz file). + * + * When doing random-access reading, it is possible that + * the target offset is not exactly at Block boundary. One + * will need to compare the target offset against + * uncompressed_file_offset or uncompressed_stream_offset, + * and possibly decode and throw away some amount of data + * before reaching the target offset. */ lzma_vli uncompressed_file_offset; @@ -166,14 +173,8 @@ typedef struct { * \brief Uncompressed size of this Block * * You should pass this to the Block decoder if you will - * decode this Block. - * - * When doing random-access reading, it is possible that - * the target offset is not exactly at Block boundary. One - * will need to compare the target offset against - * uncompressed_file_offset or uncompressed_stream_offset, - * and possibly decode and throw away some amount of data - * before reaching the target offset. + * decode this Block. It will allow the Block decoder to + * validate the uncompressed size. */ lzma_vli uncompressed_size; @@ -181,7 +182,8 @@ typedef struct { * \brief Unpadded size of this Block * * You should pass this to the Block decoder if you will - * decode this Block. + * decode this Block. It will allow the Block decoder to + * validate the unpadded size. */ lzma_vli unpadded_size; @@ -583,7 +585,9 @@ extern LZMA_API(lzma_index *) lzma_index_dup( * \param strm Pointer to properly prepared lzma_stream * \param i Pointer to lzma_index which should be encoded. * - * The only valid action value for lzma_code() is LZMA_RUN. + * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. + * It is enough to use only one of them (you can choose freely; use LZMA_RUN + * to support liblzma versions older than 5.0.0). * * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR @@ -608,7 +612,9 @@ extern LZMA_API(lzma_ret) lzma_index_encoder( * \param memlimit How much memory the resulting lzma_index is * allowed to require. * - * The only valid action value for lzma_code() is LZMA_RUN. + * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. + * It is enough to use only one of them (you can choose freely; use LZMA_RUN + * to support liblzma versions older than 5.0.0). * * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/index_hash.h b/Build/source/extra/xz/src/liblzma/api/lzma/index_hash.h index 94726e7beea..fa2e048d552 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/index_hash.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/index_hash.h @@ -1,6 +1,6 @@ /** * \file lzma/index_hash.h - * \brief Validates Index by using a hash function + * \brief Validate Index by using a hash function * * Hashing makes it possible to use constant amount of memory to validate * Index of arbitrary size. diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/lzma.h b/Build/source/extra/xz/src/liblzma/api/lzma/lzma.h index c17736d7eaa..3f8e095f70e 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/lzma.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/lzma.h @@ -46,10 +46,14 @@ * Match finder has major effect on both speed and compression ratio. * 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 * 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 - * lzma_memusage_encoder() to get more accurate estimate of memory usage. + * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. */ typedef enum { LZMA_MF_HC3 = 0x03, @@ -69,7 +73,9 @@ typedef enum { * * Minimum nice_len: 4 * - * Memory usage: dict_size * 7.5 + * Memory usage: + * - dict_size <= 32 MiB: dict_size * 7.5 + * - dict_size > 32 MiB: dict_size * 6.5 */ LZMA_MF_BT2 = 0x12, @@ -98,7 +104,9 @@ typedef enum { * * Minimum nice_len: 4 * - * Memory usage: dict_size * 11.5 + * Memory usage: + * - dict_size <= 32 MiB: dict_size * 11.5 + * - dict_size > 32 MiB: dict_size * 10.5 */ } lzma_match_finder; @@ -169,6 +177,7 @@ extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) * 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. @@ -251,7 +260,13 @@ typedef struct { * eight-bit byte (also known as `literal') are taken into * account when predicting the bits of the next literal. * - * \todo Example + * 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 @@ -271,12 +286,9 @@ typedef struct { /** * \brief Number of literal position bits * - * How many of the lowest bits of the current position (number - * of bytes from the beginning of the uncompressed data) in the - * uncompressed data is taken into account when predicting the - * bits of the next literal (a single eight-bit byte). - * - * \todo Example + * 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. */ uint32_t lp; # define LZMA_LP_DEFAULT 0 @@ -284,14 +296,22 @@ typedef struct { /** * \brief Number of position bits * - * How many of the lowest bits of the current position in the - * uncompressed data is taken into account when estimating - * probabilities of matches. A match is a sequence of bytes for - * which a matching sequence is found from the dictionary and - * thus can be stored as distance-length pair. + * 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 aligment 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. * - * Example: If most of the matches occur at byte positions of - * 8 * n + 3, that is, 3, 11, 19, ... set pb to 3, because 2**3 == 8. + * 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; # define LZMA_PB_MIN 0 @@ -342,7 +362,7 @@ typedef struct { * * 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 [10, 200] or so (it may vary between + * 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 @@ -361,8 +381,6 @@ typedef struct { * with the currently supported options, so it is safe to leave these * uninitialized. */ - void *reserved_ptr1; - void *reserved_ptr2; uint32_t reserved_int1; uint32_t reserved_int2; uint32_t reserved_int3; @@ -375,6 +393,8 @@ typedef struct { lzma_reserved_enum reserved_enum2; lzma_reserved_enum reserved_enum3; lzma_reserved_enum reserved_enum4; + void *reserved_ptr1; + void *reserved_ptr2; } lzma_options_lzma; @@ -392,6 +412,9 @@ typedef struct { * * This function is available only if LZMA1 or LZMA2 encoder has been enabled * 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( lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/stream_flags.h b/Build/source/extra/xz/src/liblzma/api/lzma/stream_flags.h index d255bdda15f..bbdd408263e 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/stream_flags.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/stream_flags.h @@ -91,8 +91,6 @@ typedef struct { lzma_reserved_enum reserved_enum2; lzma_reserved_enum reserved_enum3; lzma_reserved_enum reserved_enum4; - lzma_reserved_enum reserved_enum5; - lzma_reserved_enum reserved_enum6; lzma_bool reserved_bool1; lzma_bool reserved_bool2; lzma_bool reserved_bool3; @@ -103,8 +101,6 @@ typedef struct { lzma_bool reserved_bool8; uint32_t reserved_int1; uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; } lzma_stream_flags; @@ -148,7 +144,7 @@ extern LZMA_API(lzma_ret) lzma_stream_footer_encode( /** * \brief Decode Stream Header * - * \param options Stream Header options to be encoded. + * \param options Target for the decoded Stream Header options. * \param in Beginning of the input buffer of * LZMA_STREAM_HEADER_SIZE bytes. * @@ -183,7 +179,7 @@ extern LZMA_API(lzma_ret) lzma_stream_header_decode( /** * \brief Decode Stream Footer * - * \param options Stream Header options to be encoded. + * \param options Target for the decoded Stream Header options. * \param in Beginning of the input buffer of * LZMA_STREAM_HEADER_SIZE bytes. * diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/version.h b/Build/source/extra/xz/src/liblzma/api/lzma/version.h index 0f7c2d3737d..4959f6e8dbe 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/version.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/version.h @@ -20,10 +20,10 @@ /* * Version number split into components */ -#define LZMA_VERSION_MAJOR 4 -#define LZMA_VERSION_MINOR 999 -#define LZMA_VERSION_PATCH 9 -#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_BETA +#define LZMA_VERSION_MAJOR 5 +#define LZMA_VERSION_MINOR 0 +#define LZMA_VERSION_PATCH 2 +#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #ifndef LZMA_VERSION_COMMIT # define LZMA_VERSION_COMMIT "" diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/vli.h b/Build/source/extra/xz/src/liblzma/api/lzma/vli.h index 57e3d3882b5..9ad13f2e2fc 100644 --- a/Build/source/extra/xz/src/liblzma/api/lzma/vli.h +++ b/Build/source/extra/xz/src/liblzma/api/lzma/vli.h @@ -29,7 +29,7 @@ /** - * \brief Maximum supported value of variable-length integer + * \brief Maximum supported value of a variable-length integer */ #define LZMA_VLI_MAX (UINT64_MAX / 2) @@ -39,11 +39,10 @@ #define LZMA_VLI_UNKNOWN UINT64_MAX /** - * \brief Maximum supported length of variable length integers + * \brief Maximum supported encoded length of variable length integers */ #define LZMA_VLI_BYTES_MAX 9 - /** * \brief VLI constant suffix */ @@ -53,19 +52,19 @@ /** * \brief Variable-length integer type * - * This will always be unsigned integer. Valid VLI values are in the range - * [0, LZMA_VLI_MAX]. Unknown value is indicated with LZMA_VLI_UNKNOWN, - * which is the maximum value of the underlaying integer type. + * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is + * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the + * underlaying integer type. * - * In future, even if lzma_vli is defined to be something other than uint64_t, - * it is guaranteed that 2 * LZMA_VLI_MAX will not overflow lzma_vli. - * This simplifies integer overflow detection. + * lzma_vli will be uint64_t for the foreseeable future. If a bigger size + * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will + * not overflow lzma_vli. This simplifies integer overflow detection. */ typedef uint64_t lzma_vli; /** - * \brief Simple macro to validate variable-length integer + * \brief Validate a variable-length integer * * This is useful to test that application has given acceptable values * for example in the uncompressed_size and compressed_size variables. @@ -88,9 +87,9 @@ typedef uint64_t lzma_vli; * * \param vli Integer to be encoded * \param vli_pos How many VLI-encoded bytes have already been written - * out. When starting to encode a new integer, *vli_pos - * must be set to zero. To use single-call encoding, - * set vli_pos to NULL. + * out. When starting to encode a new integer in + * multi-call mode, *vli_pos must be set to zero. + * To use single-call encoding, set vli_pos to NULL. * \param out Beginning of the output buffer * \param out_pos The next byte will be written to out[*out_pos]. * \param out_size Size of the out buffer; the first byte into @@ -126,9 +125,9 @@ extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, * initialize it to zero when *vli_pos == 0, so * application isn't required to initialize *vli. * \param vli_pos How many bytes have already been decoded. When - * starting to decode a new integer, *vli_pos must - * be initialized to zero. To use single-call decoding, - * set this to NULL. + * starting to decode a new integer in multi-call + * mode, *vli_pos must be initialized to zero. To + * use single-call decoding, set vli_pos to NULL. * \param in Beginning of the input buffer * \param in_pos The next byte will be read from in[*in_pos]. * \param in_size Size of the input buffer; the first byte that diff --git a/Build/source/extra/xz/src/liblzma/common/common.c b/Build/source/extra/xz/src/liblzma/common/common.c index 07b1d4763f6..0408e15328b 100644 --- a/Build/source/extra/xz/src/liblzma/common/common.c +++ b/Build/source/extra/xz/src/liblzma/common/common.c @@ -182,6 +182,20 @@ lzma_code(lzma_stream *strm, lzma_action action) || !strm->internal->supported_actions[action]) return LZMA_PROG_ERROR; + // Check if unsupported members have been set to non-zero or non-NULL, + // which would indicate that some new feature is wanted. + if (strm->reserved_ptr1 != NULL + || strm->reserved_ptr2 != NULL + || strm->reserved_ptr3 != NULL + || strm->reserved_ptr4 != NULL + || strm->reserved_int1 != 0 + || strm->reserved_int2 != 0 + || strm->reserved_int3 != 0 + || strm->reserved_int4 != 0 + || strm->reserved_enum1 != LZMA_RESERVED_ENUM + || strm->reserved_enum2 != LZMA_RESERVED_ENUM) + return LZMA_OPTIONS_ERROR; + switch (strm->internal->sequence) { case ISEQ_RUN: switch (action) { diff --git a/Build/source/extra/xz/src/liblzma/common/common.h b/Build/source/extra/xz/src/liblzma/common/common.h index 3a85168f13b..b819432371d 100644 --- a/Build/source/extra/xz/src/liblzma/common/common.h +++ b/Build/source/extra/xz/src/liblzma/common/common.h @@ -205,7 +205,7 @@ struct lzma_internal_s { /// Allocates memory extern void *lzma_alloc(size_t size, lzma_allocator *allocator) - lzma_attribute((malloc)); + lzma_attribute((malloc)) lzma_attr_alloc_size(1); /// Frees memory extern void lzma_free(void *ptr, lzma_allocator *allocator); diff --git a/Build/source/extra/xz/src/liblzma/common/filter_encoder.c b/Build/source/extra/xz/src/liblzma/common/filter_encoder.c index 436d2cc6e42..635d8122347 100644 --- a/Build/source/extra/xz/src/liblzma/common/filter_encoder.c +++ b/Build/source/extra/xz/src/liblzma/common/filter_encoder.c @@ -226,6 +226,7 @@ lzma_raw_encoder_memusage(const lzma_filter *filters) } +/* extern LZMA_API(lzma_vli) lzma_chunk_size(const lzma_filter *filters) { @@ -247,6 +248,7 @@ lzma_chunk_size(const lzma_filter *filters) return max; } +*/ extern LZMA_API(lzma_ret) diff --git a/Build/source/extra/xz/src/liblzma/common/filter_encoder.h b/Build/source/extra/xz/src/liblzma/common/filter_encoder.h index a978932def7..5bc137f6458 100644 --- a/Build/source/extra/xz/src/liblzma/common/filter_encoder.h +++ b/Build/source/extra/xz/src/liblzma/common/filter_encoder.h @@ -16,8 +16,8 @@ #include "common.h" -// FIXME !!! Public API -extern lzma_vli lzma_chunk_size(const lzma_filter *filters); +// FIXME: Might become a part of the public API once finished. +// extern lzma_vli lzma_chunk_size(const lzma_filter *filters); extern lzma_ret lzma_raw_encoder_init( diff --git a/Build/source/extra/xz/src/liblzma/common/index.c b/Build/source/extra/xz/src/liblzma/common/index.c index 3941e28ba72..ddb9d364362 100644 --- a/Build/source/extra/xz/src/liblzma/common/index.c +++ b/Build/source/extra/xz/src/liblzma/common/index.c @@ -18,7 +18,7 @@ /// /// This should be big enough to avoid making lots of tiny allocations /// but small enough to avoid too much unused memory at once. -#define INDEX_GROUP_SIZE 500 +#define INDEX_GROUP_SIZE 512 /// \brief How many Records can be allocated at once at maximum diff --git a/Build/source/extra/xz/src/liblzma/common/index_decoder.c b/Build/source/extra/xz/src/liblzma/common/index_decoder.c index 86a22971b06..a6bc650e046 100644 --- a/Build/source/extra/xz/src/liblzma/common/index_decoder.c +++ b/Build/source/extra/xz/src/liblzma/common/index_decoder.c @@ -291,6 +291,7 @@ lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit) lzma_next_strm_init(index_decoder_init, strm, i, memlimit); strm->internal->supported_actions[LZMA_RUN] = true; + strm->internal->supported_actions[LZMA_FINISH] = true; return LZMA_OK; } diff --git a/Build/source/extra/xz/src/liblzma/common/index_encoder.c b/Build/source/extra/xz/src/liblzma/common/index_encoder.c index 706f1fd7990..c10d7afa06b 100644 --- a/Build/source/extra/xz/src/liblzma/common/index_encoder.c +++ b/Build/source/extra/xz/src/liblzma/common/index_encoder.c @@ -209,6 +209,7 @@ lzma_index_encoder(lzma_stream *strm, const lzma_index *i) lzma_next_strm_init(lzma_index_encoder_init, strm, i); strm->internal->supported_actions[LZMA_RUN] = true; + strm->internal->supported_actions[LZMA_FINISH] = true; return LZMA_OK; } diff --git a/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c b/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c index 9e980a2c71d..273f577b69b 100644 --- a/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c +++ b/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c @@ -349,9 +349,10 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator, // Maximum number of match finder cycles mf->depth = lz_options->depth; if (mf->depth == 0) { - mf->depth = 16 + (mf->nice_len / 2); - if (!is_bt) - mf->depth /= 2; + if (is_bt) + mf->depth = 16 + mf->nice_len / 2; + else + mf->depth = 4 + mf->nice_len / 4; } return false; diff --git a/Build/source/extra/xz/src/liblzma/lzma/lzma2_decoder.c b/Build/source/extra/xz/src/liblzma/lzma/lzma2_decoder.c index b4c2f2d5ba7..3e42575d5b8 100644 --- a/Build/source/extra/xz/src/liblzma/lzma/lzma2_decoder.c +++ b/Build/source/extra/xz/src/liblzma/lzma/lzma2_decoder.c @@ -67,6 +67,10 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, const uint32_t control = in[*in_pos]; ++*in_pos; + // End marker + if (control == 0x00) + return LZMA_STREAM_END; + if (control >= 0xE0 || control == 1) { // Dictionary reset implies that next LZMA chunk has // to set new properties. @@ -104,10 +108,6 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, &coder->options); } } else { - // End marker - if (control == 0x00) - return LZMA_STREAM_END; - // Invalid control values if (control > 2) return LZMA_DATA_ERROR; @@ -191,7 +191,6 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, case SEQ_COPY: { // Copy from input to the dictionary as is. - // FIXME Can copy too much? dict_write(dict, in, in_pos, in_size, &coder->compressed_size); if (coder->compressed_size != 0) return LZMA_OK; diff --git a/Build/source/extra/xz/src/liblzma/lzma/lzma_decoder.c b/Build/source/extra/xz/src/liblzma/lzma/lzma_decoder.c index 4329e019927..9979bb4261b 100644 --- a/Build/source/extra/xz/src/liblzma/lzma/lzma_decoder.c +++ b/Build/source/extra/xz/src/liblzma/lzma/lzma_decoder.c @@ -656,7 +656,8 @@ lzma_decode(lzma_coder *restrict coder, lzma_dict *restrict dictptr, } case SEQ_EOPM: - // TODO Comment + // LZMA1 stream with + // end-of-payload marker. rc_normalize(SEQ_EOPM); ret = LZMA_STREAM_END; goto out; @@ -856,7 +857,6 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt) // NOTE: We assume that lc/lp/pb are valid since they were // successfully decoded with lzma_lzma_decode_properties(). - // FIXME? // Calculate pos_mask. We don't need pos_bits as is for anything. coder->pos_mask = (1U << options->pb) - 1; diff --git a/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder.c b/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder.c index 0fe992d510a..0b9ee9e1507 100644 --- a/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder.c +++ b/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder.c @@ -334,7 +334,7 @@ lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, // With LZMA2 we need to take care that compressed size of // a chunk doesn't get too big. - // TODO + // FIXME? Check if this could be improved. if (limit != UINT32_MAX && (mf->read_pos - mf->read_ahead >= limit || *out_pos + rc_pending(&coder->rc) diff --git a/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder_presets.c b/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder_presets.c index c4c9c146f55..21e427a8d02 100644 --- a/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder_presets.c +++ b/Build/source/extra/xz/src/liblzma/lzma/lzma_encoder_presets.c @@ -23,9 +23,6 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) if (level > 9 || (flags & ~supported_flags)) return true; - const uint32_t dict_shift = level <= 1 ? 16 : level + 17; - options->dict_size = UINT32_C(1) << dict_shift; - options->preset_dict = NULL; options->preset_dict_size = 0; @@ -33,19 +30,31 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) options->lp = LZMA_LP_DEFAULT; options->pb = LZMA_PB_DEFAULT; - options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL; + options->dict_size = UINT32_C(1) << (uint8_t []){ + 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level]; - options->nice_len = level == 0 ? 8 : level <= 5 ? 32 : 64; - options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4 - : LZMA_MF_BT4; - options->depth = 0; + if (level <= 3) { + options->mode = LZMA_MODE_FAST; + options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4; + options->nice_len = level <= 1 ? 128 : 273; + options->depth = (uint8_t []){ 4, 8, 24, 48 }[level]; + } else { + options->mode = LZMA_MODE_NORMAL; + options->mf = LZMA_MF_BT4; + options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64; + options->depth = 0; + } if (flags & LZMA_PRESET_EXTREME) { - options->lc = 4; // FIXME? options->mode = LZMA_MODE_NORMAL; options->mf = LZMA_MF_BT4; - options->nice_len = 273; - options->depth = 512; + if (level == 3 || level == 5) { + options->nice_len = 192; + options->depth = 0; + } else { + options->nice_len = 273; + options->depth = 512; + } } return false; |