X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=programs%2Fimagex.c;h=679032569bae68a04feeaa0cb538f120520b42f8;hp=f23f043897d42dd7b90da85d4a527a3857db518d;hb=21debdc578194ba5fec47f363e12a15f77b2c5b2;hpb=2254a0fc3f1d7af1151ee83f3458f44339b5028b diff --git a/programs/imagex.c b/programs/imagex.c index f23f0438..67903256 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -284,6 +284,7 @@ static const struct option optimize_options[] = { {T("no-check"), no_argument, NULL, IMAGEX_NOCHECK_OPTION}, {T("recompress"), no_argument, NULL, IMAGEX_RECOMPRESS_OPTION}, {T("compress-slow"), no_argument, NULL, IMAGEX_COMPRESS_SLOW_OPTION}, + {T("recompress-slow"), no_argument, NULL, IMAGEX_COMPRESS_SLOW_OPTION}, {T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION}, {T("pipable"), no_argument, NULL, IMAGEX_PIPABLE_OPTION}, {T("not-pipable"), no_argument, NULL, IMAGEX_NOT_PIPABLE_OPTION}, @@ -418,6 +419,29 @@ get_compression_type(const tchar *optarg) } } +static void +set_compress_slow(void) +{ + static const struct wimlib_lzx_params slow_params = { + .size_of_this = sizeof(struct wimlib_lzx_params), + .algorithm = WIMLIB_LZX_ALGORITHM_SLOW, + .alg_params = { + .slow = { + .use_len2_matches = 1, + .num_fast_bytes = 96, + .num_optim_passes = 4, + .max_search_depth = 100, + .max_matches_per_pos = 10, + .main_nostat_cost = 15, + .len_nostat_cost = 15, + .aligned_nostat_cost = 7, + }, + }, + }; + if (wimlib_lzx_set_default_params(&slow_params)) + imagex_error(T("Couldn't set slow compression parameters.!")); +} + struct string_set { const tchar **strings; unsigned num_strings; @@ -1642,7 +1666,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) int add_image_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE | WIMLIB_ADD_IMAGE_FLAG_WINCONFIG; int write_flags = 0; - int compression_type = WIMLIB_COMPRESSION_TYPE_LZX; + int compression_type = WIMLIB_COMPRESSION_TYPE_INVALID; const tchar *wimfile; int wim_fd; const tchar *name; @@ -1698,7 +1722,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) goto out_err; break; case IMAGEX_COMPRESS_SLOW_OPTION: - write_flags |= WIMLIB_WRITE_FLAG_COMPRESS_SLOW; + set_compress_slow(); break; case IMAGEX_FLAGS_OPTION: flags_element = optarg; @@ -1784,6 +1808,18 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) source = argv[0]; wimfile = argv[1]; + /* Set default compression type. */ + if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) { + struct wimlib_lzx_params params; + memset(¶ms, 0, sizeof(params)); + params.size_of_this = sizeof(params); + params.algorithm = WIMLIB_LZX_ALGORITHM_FAST; + params.use_defaults = 1; + + wimlib_lzx_set_default_params(¶ms); + compression_type = WIMLIB_COMPRESSION_TYPE_LZX; + } + if (!tstrcmp(wimfile, T("-"))) { /* Writing captured WIM to standard output. */ #if 0 @@ -3224,7 +3260,8 @@ imagex_optimize(int argc, tchar **argv, int cmd) write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS; break; case IMAGEX_COMPRESS_SLOW_OPTION: - write_flags |= WIMLIB_WRITE_FLAG_COMPRESS_SLOW; + write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS; + set_compress_slow(); break; case IMAGEX_THREADS_OPTION: num_threads = parse_num_threads(optarg); @@ -3640,11 +3677,11 @@ static const tchar *usage_strings[] = { T( " %"TS" (DIRECTORY | NTFS_VOLUME) WIMFILE\n" " [IMAGE_NAME [IMAGE_DESCRIPTION]] [--boot]\n" -" [--check] [--nocheck] [--compress-slow]\n" -" [--flags EDITION_ID] [--verbose] [--dereference]\n" -" [--config=FILE] [--threads=NUM_THREADS] [--source-list]\n" -" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n" -" [--unix-data] [--pipable] [--update-of=[WIMFILE:]IMAGE]\n" +" [--check] [--nocheck] [--flags EDITION_ID] [--verbose]\n" +" [--dereference] [--config=FILE] [--threads=NUM_THREADS]\n" +" [--source-list] [--no-acls] [--strict-acls] [--rpfix]\n" +" [--norpfix] [--unix-data] [--pipable]\n" +" [--update-of=[WIMFILE:]IMAGE]\n" ), [CMD_APPLY] = T( @@ -3658,7 +3695,7 @@ T( T( " %"TS" (DIRECTORY | NTFS_VOLUME) WIMFILE\n" " [IMAGE_NAME [IMAGE_DESCRIPTION]] [--boot]\n" -" [--check] [--nocheck] [--compress=TYPE] [--compress-slow]\n" +" [--check] [--nocheck] [--compress=TYPE]\n" " [--flags EDITION_ID] [--verbose] [--dereference]\n" " [--config=FILE] [--threads=NUM_THREADS] [--source-list]\n" " [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n" @@ -3717,8 +3754,8 @@ T( [CMD_OPTIMIZE] = T( " %"TS" WIMFILE [--check] [--nocheck] [--recompress]\n" -" [--compress-slow] [--threads=NUM_THREADS]\n" -" [--pipable] [--not-pipable]\n" +" [--recompress-slow] [--threads=NUM_THREADS] [--pipable]\n" +" [--not-pipable]\n" ), [CMD_SPLIT] = T(