From de567a8c5dcd0910a8c762d75bf11b9c9683396c Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 16 Feb 2015 21:13:51 -0600 Subject: [PATCH] Various cleanups --- README | 17 ++++++----------- doc/man1/wimlib-imagex-capture.1 | 11 +++++------ include/wimlib.h | 4 ++-- include/wimlib/header.h | 4 ++-- include/wimlib/lzx_common.h | 2 +- include/wimlib/wim.h | 2 +- src/lzx_common.c | 3 +-- src/lzx_compress.c | 16 +++++++--------- src/solid.c | 4 ++-- 9 files changed, 27 insertions(+), 36 deletions(-) diff --git a/README b/README index e54be618..f69e07ee 100644 --- a/README +++ b/README @@ -65,17 +65,12 @@ commands and their syntax. For additional documentation: COMPRESSION RATIO wimlib (and wimlib-imagex) can create XPRESS, LZX, or LZMS compressed WIM files. -wimlib includes its own compression codecs and does not use the compression API -available on some versions of Windows. - -I have gradually been improving the compression codecs in wimlib. For all three -codecs, they now usually outperform and outcompress the equivalent Microsoft -implementations. Although results will vary depending on the data being -compressed, in the table below I present the results for a common use case: -compressing an x86 Windows PE image. Each row displays the compression type, -the size of the resulting WIM file in bytes, and how many seconds it took to -create the file. When applicable, the results with the equivalent Microsoft -implementation in WIMGAPI is included. +wimlib's compression codecs usually outperform and outcompress their Microsoft +equivalents. Although results will vary depending on the data being compressed, +the table below shows results for a common use case: creating an x86 Windows PE +image ("boot.wim"). Each row shows the compression type, the size of the +resulting WIM file in bytes, and the time it took to create the file. When +possible, the results with the Microsoft equivalent are included. ============================================================================= | Compression || wimlib (v1.8.0) | WIMGAPI (Windows 8.1) | diff --git a/doc/man1/wimlib-imagex-capture.1 b/doc/man1/wimlib-imagex-capture.1 index 98ff26b1..767991ab 100644 --- a/doc/man1/wimlib-imagex-capture.1 +++ b/doc/man1/wimlib-imagex-capture.1 @@ -246,8 +246,8 @@ Compatibility-wise, the first version of Microsoft's WIMGAPI to support solid WIM files was released with Windows 8, and the first version of DISM to do so was released with Windows 8.1. .IP "" -If you want to create an "ESD" file, then use this option. An (unencrypted) -"ESD" file is a solid WIM file. +If you want to create an "ESD file", then use this option. An (unencrypted) +"ESD file" is a solid WIM file. .IP "" By default, this option has an effect equivalent to DISM's option \fB/compress:recovery\fR. The options for wimlib-imagex are different because @@ -258,14 +258,13 @@ compression, as these are two different things. Like \fB--chunk-size\fR, but set the chunk size used in solid resources. The default, assuming LZMS compression, is 64MiB (67108864); this requires about 640MiB of memory per thread. This option only has an effect when \fB--solid\fR -is also specified. For maximum compatibility with the Microsoft implementation, -do not use this option. +is also specified. Note: Microsoft's implementation is not compatible with LZMS +chunk sizes larger than 64MiB. .TP \fB--solid-compress\fR=\fITYPE\fR[:\fILEVEL\fR] Like \fB--compress\fR, but set the compression type used in solid resources. The default is LZMS compression. This option only has an effect when -\fB--solid\fR is also specified. For maximum compatibility with the Microsoft -implementation, do not use this option. +\fB--solid\fR is also specified. .TP \fB--threads\fR=\fINUM_THREADS\fR Number of threads to use for compressing data. Default: autodetect (number of diff --git a/include/wimlib.h b/include/wimlib.h index 70b1781f..9b629d66 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -2218,7 +2218,7 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800 /** - * When writing streams in the resulting WIM file, combine multiple streams into + * When writing streams to the resulting WIM file, combine multiple streams into * a single compressed resource instead of compressing them independently. This * is also known as creating a "solid archive". This tends to produce a better * compression ratio at the cost of much slower random access. @@ -2240,7 +2240,7 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour * the WIM's main compression type and chunk size; you can have a WIM that * nominally uses LZX compression and 32768 byte chunks but actually contains * LZMS-compressed solid resources, for example. However, if including solid - * blocks, I suggest that you set the WIM's main compression type to LZMS as + * resources, I suggest that you set the WIM's main compression type to LZMS as * well, either by creating the WIM with * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS). diff --git a/include/wimlib/header.h b/include/wimlib/header.h index 35eb72c7..6c522fa2 100644 --- a/include/wimlib/header.h +++ b/include/wimlib/header.h @@ -19,8 +19,8 @@ /* Version number used for WIMs that allow multiple streams combined into one * resource ("solid resources", marked by WIM_RESHDR_FLAG_SOLID) and also a new * compression format (LZMS). This version is new as of Windows 8 WIMGAPI. - * Although it is used by Windows 8 web downloader, it is not yet properly - * documented by Microsoft. */ + * Although it is used by Windows 8 web downloader, it is not yet documented by + * Microsoft. */ #define WIM_VERSION_SOLID 0xe00 /* Note: there is another WIM version from Vista pre-releases, but it is not diff --git a/include/wimlib/lzx_common.h b/include/wimlib/lzx_common.h index 78c92ec1..ed9d0bbe 100644 --- a/include/wimlib/lzx_common.h +++ b/include/wimlib/lzx_common.h @@ -21,7 +21,7 @@ extern const u32 lzx_offset_slot_base[LZX_MAX_OFFSET_SLOTS + 1]; -extern const u8 lzx_extra_offset_bits[LZX_MAX_OFFSET_SLOTS + 1]; +extern const u8 lzx_extra_offset_bits[LZX_MAX_OFFSET_SLOTS]; /* * Return the offset slot for the specified match offset. diff --git a/include/wimlib/wim.h b/include/wimlib/wim.h index 544ce180..5bc20a6b 100644 --- a/include/wimlib/wim.h +++ b/include/wimlib/wim.h @@ -94,7 +94,7 @@ struct WIMStruct { * decompressor can be used for all data --- and that decompressor will * be cached here. However, if we do encounter any data with a * different compression type or chunk size (this is possible in solid - * blocks), then this cached decompressor will be replaced with a new + * resources), then this cached decompressor will be replaced with a new * one. */ struct wimlib_decompressor *decompressor; diff --git a/src/lzx_common.c b/src/lzx_common.c index 3cc6981b..1baeebe7 100644 --- a/src/lzx_common.c +++ b/src/lzx_common.c @@ -57,7 +57,7 @@ const u32 lzx_offset_slot_base[LZX_MAX_OFFSET_SLOTS + 1] = { /* Mapping: offset slot => how many extra bits must be read and added to the * corresponding offset slot base to decode the match offset. */ -const u8 lzx_extra_offset_bits[LZX_MAX_OFFSET_SLOTS + 1] = { +const u8 lzx_extra_offset_bits[LZX_MAX_OFFSET_SLOTS] = { 0 , 0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 , 6 , @@ -68,7 +68,6 @@ const u8 lzx_extra_offset_bits[LZX_MAX_OFFSET_SLOTS + 1] = { 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17 }; /* Round the specified buffer size up to the next valid LZX window size, and diff --git a/src/lzx_compress.c b/src/lzx_compress.c index 1506b884..28a2656f 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -105,7 +105,7 @@ /* * LZX_BIT_COST is a scaling factor that represents the cost to output one bit. - * THis makes it possible to consider fractional bit costs. + * This makes it possible to consider fractional bit costs. * * Note: this is only useful as a statistical trick for when the true costs are * unknown. In reality, each token in LZX requires a whole number of bits to @@ -128,7 +128,7 @@ /* * LZX_HASH2_ORDER is the log base 2 of the number of entries in the hash table * for finding length 2 matches. This can be as high as 16 (in which case the - * hash function is trivial), but using a smaller hash table actually speeds up + * hash function is trivial), but using a smaller hash table speeds up * compression due to reduced cache pressure. */ #define LZX_HASH2_ORDER 12 @@ -1624,13 +1624,11 @@ lzx_compress_near_optimal(struct lzx_compressor *c, max_len = in_end - in_next; nice_len = min(max_len, nice_len); - /* This extra check is needed to ensure that - * reading the next 3 bytes when looking for a - * length 2 match is valid. In addition, we - * cannot allow ourselves to find a length 2 - * match of the very last two bytes with the - * very first two bytes, since such a match has - * an offset too large to be represented. */ + /* This extra check is needed to ensure that we + * never output a length 2 match of the very + * last two bytes with the very first two bytes, + * since such a match has an offset too large to + * be represented. */ if (unlikely(max_len < 3)) { in_next++; cache_ptr->length = 0; diff --git a/src/solid.c b/src/solid.c index 94901d0f..01f22a5b 100644 --- a/src/solid.c +++ b/src/solid.c @@ -227,7 +227,7 @@ sort_stream_list_for_solid_compression(struct list_head *stream_list) ret = for_image(wims[i], WIMLIB_ALL_IMAGES, image_fill_in_solid_sort_names); if (ret) - goto out_free_lookup_table; + goto out; deselect_current_wim_image(wims[i]); } @@ -236,9 +236,9 @@ sort_stream_list_for_solid_compression(struct list_head *stream_list) write_streams_list), cmp_streams_by_solid_sort_name); +out: list_for_each_entry(lte, stream_list, write_streams_list) FREE(lte->solid_sort_name); -out_free_lookup_table: FREE(lookup_table.table); return ret; } -- 2.43.0