From 2798cfb5f8d82c5a93bb479d997143e57393541d Mon Sep 17 00:00:00 2001 From: Martin Piatka Date: Fri, 20 Sep 2024 15:31:22 +0200 Subject: [PATCH] capabilities: Report placeholder text for codec options --- src/host.cpp | 1 + src/video_compress.h | 1 + src/video_compress/cineform.cpp | 9 +++++---- src/video_compress/cmpto_j2k.cpp | 15 ++++++++------- src/video_compress/gpujpeg.cpp | 15 ++++++++------- src/video_compress/libavcodec.cpp | 8 +++++--- 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index 3dd46719a..bc3639322 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -709,6 +709,7 @@ static void probe_compress(std::string const & name, const void *mod) noexcept { cout << "{" "\"display_name\":" << std::quoted(opt.display_name) << ", " "\"display_desc\":" << std::quoted(opt.display_desc) << ", " + "\"placeholder_text\":" << std::quoted(opt.placeholder_text) << ", " "\"key\":" << std::quoted(opt.key) << ", " "\"opt_str\":" << std::quoted(opt.opt_str) << ", " "\"is_boolean\":\"" << (opt.is_boolean ? "t" : "f") << "\"}"; diff --git a/src/video_compress.h b/src/video_compress.h index 08ae836b8..8506b908a 100644 --- a/src/video_compress.h +++ b/src/video_compress.h @@ -172,6 +172,7 @@ typedef std::shared_ptr (*compress_tile_async_pop_t)(struct module struct module_option{ std::string display_name; //Name displayed to user std::string display_desc; //Description displayed to user + std::string placeholder_text; //Displayed placeholder text if opt is a line edit /* internal name of option, options that are used in the same way should * have the same key (e.g. both bitrate for libavcodec and quality for jpeg diff --git a/src/video_compress/cineform.cpp b/src/video_compress/cineform.cpp index 140ec4a97..82bca520c 100644 --- a/src/video_compress/cineform.cpp +++ b/src/video_compress/cineform.cpp @@ -125,10 +125,11 @@ struct { const char *key; const char *description; const char *opt_str; + const char *placeholder; } usage_opts[] = { - {"Quality", "quality", "specifies encode quality, range 1-6 (default: 4)", ":quality="}, - {"Threads", "num_threads", "specifies number of threads for encoding (default: " TOSTRING(DEFAULT_THREAD_COUNT) ")", ":num_threads="}, - {"Pool size", "pool_size", "specifies the size of encoding pool (default: " TOSTRING(DEFAULT_POOL_SIZE) ")", ":pool_size="}, + {"Quality", "quality", "specifies encode quality, range 1-6 (default: 4)", ":quality=", "4"}, + {"Threads", "num_threads", "specifies number of threads for encoding (default: " TOSTRING(DEFAULT_THREAD_COUNT) ")", ":num_threads=", ""}, + {"Pool size", "pool_size", "specifies the size of encoding pool (default: " TOSTRING(DEFAULT_POOL_SIZE) ")", ":pool_size=", ""}, }; static void usage() { @@ -516,7 +517,7 @@ static compress_module_info get_cineform_module_info(){ for(const auto& opt : usage_opts){ module_info.opts.emplace_back(module_option{opt.label, - opt.description, opt.key, opt.opt_str, false}); + opt.description, opt.placeholder, opt.key, opt.opt_str, false}); } codec codec_info; diff --git a/src/video_compress/cmpto_j2k.cpp b/src/video_compress/cmpto_j2k.cpp index 2578a51b1..2d6a14221 100644 --- a/src/video_compress/cmpto_j2k.cpp +++ b/src/video_compress/cmpto_j2k.cpp @@ -455,13 +455,14 @@ struct { const char *description; const char *opt_str; const bool is_boolean; + const char *placeholder; } usage_opts[] = { - {"Bitrate", "quality", "Target bitrate", ":rate=", false}, - {"Quality", "quant_coeff", "Quality in range [0-1], default: " TOSTRING(DEFAULT_QUALITY), ":quality=", false}, - {"Mem limit", "mem_limit", "CUDA device memory limit (in bytes), default: " TOSTRING(DEFAULT_MEM_LIMIT), ":mem_limit=", false}, - {"Tile limit", "tile_limit", "Number of tiles encoded at moment (less to reduce latency, more to increase performance, 0 means infinity), default: " TOSTRING(DEFAULT_TILE_LIMIT), ":tile_limit=", false}, - {"Pool size", "pool_size", "Total number of tiles encoder can hold at moment (same meaning as above), default: " TOSTRING(DEFAULT_POOL_SIZE) ", should be greater than ", ":pool_size=", false}, - {"Use MCT", "mct", "use MCT", ":mct", true}, + {"Bitrate", "quality", "Target bitrate", ":rate=", false, "70M"}, + {"Quality", "quant_coeff", "Quality in range [0-1], default: " TOSTRING(DEFAULT_QUALITY), ":quality=", false, TOSTRING(DEFAULT_QUALITY)}, + {"Mem limit", "mem_limit", "CUDA device memory limit (in bytes), default: " TOSTRING(DEFAULT_MEM_LIMIT), ":mem_limit=", false, TOSTRING(DEFAULT_MEM_LIMIT)}, + {"Tile limit", "tile_limit", "Number of tiles encoded at moment (less to reduce latency, more to increase performance, 0 means infinity), default: " TOSTRING(DEFAULT_TILE_LIMIT), ":tile_limit=", false, TOSTRING(DEFAULT_TILE_LIMIT)}, + {"Pool size", "pool_size", "Total number of tiles encoder can hold at moment (same meaning as above), default: " TOSTRING(DEFAULT_POOL_SIZE) ", should be greater than ", ":pool_size=", false, TOSTRING(DEFAULT_POOL_SIZE)}, + {"Use MCT", "mct", "use MCT", ":mct", true, ""}, }; static void usage() { @@ -719,7 +720,7 @@ static compress_module_info get_cmpto_j2k_module_info(){ for(const auto& opt : usage_opts){ module_info.opts.emplace_back(module_option{opt.label, - opt.description, opt.key, opt.opt_str, opt.is_boolean}); + opt.description, opt.placeholder, opt.key, opt.opt_str, opt.is_boolean}); } codec codec_info; diff --git a/src/video_compress/gpujpeg.cpp b/src/video_compress/gpujpeg.cpp index 2db889dbb..70d4f92f4 100644 --- a/src/video_compress/gpujpeg.cpp +++ b/src/video_compress/gpujpeg.cpp @@ -469,31 +469,32 @@ static const struct { const char *description; const char *opt_str; bool is_boolean; + const char *placeholder; } usage_opts[] = { {"Quality", "quality", "quality", - "\t\tJPEG quality coefficient [0..100] - more is better\n", ":q=", false}, + "\t\tJPEG quality coefficient [0..100] - more is better\n", ":q=", false, "80"}, {"Restart interval", "restart_interval", "restart_interval", "\t\tInterval between independently entropy encoded block of MCUs,\n" "\t\t0 to disable. Using large intervals or disable (0) slightly\n" "\t\treduces bandwidth at the expense of worse parallelization (if\n" "\t\treset intervals disabled, Huffman encoding is run on CPU). Leave\n" "\t\tuntouched if unsure.\n", - ":restart=", false}, + ":restart=", false, ""}, {"Interleaved", "interleaved", "interleaved", "\t\tForce interleaved encoding (default for YCbCr input formats).\n" "\t\tNon-interleaved has slightly better performance for RGB at the\n" "\t\texpense of worse compatibility. Therefore this option may be\n" "\t\tenabled safely.\n", - ":interleaved", true}, + ":interleaved", true, ""}, {"Color space", "color_space", "RGB|Y601|Y601full|Y709", "\t\tforce internal JPEG color space (otherwise source color space is kept).\n", - ":", false}, + ":", false, "Y601"}, {"Subsampling", "subsampling", "sub", "\t\tUse specified JPEG subsampling (444, 422 or 420).\n", - ":sub=", false}, + ":sub=", false, "422"}, {"Alpha", "alpha", "alpha", "\t\tCompress (keep) alpha channel of RGBA.\n", - ":alpha", true}, + ":alpha", true, ""}, }; struct module * gpujpeg_compress_init(struct module *parent, const char *opts) @@ -725,7 +726,7 @@ static compress_module_info get_gpujpeg_module_info(){ desc.erase(std::remove(desc.begin(), desc.end(), '\t'), desc.end()); std::replace(desc.begin(), desc.end(), '\n', ' '); module_info.opts.emplace_back( - module_option{ opt.label, std::move(desc), opt.key, + module_option{ opt.label, std::move(desc), opt.placeholder, opt.key, opt.opt_str, opt.is_boolean }); } diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index eff669615..97677fdaa 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -634,16 +634,18 @@ parse_fmt(struct state_video_compress_libav *s, char *fmt) noexcept(false) static compress_module_info get_libavcodec_module_info(){ compress_module_info module_info; module_info.name = "libavcodec"; - module_info.opts.emplace_back(module_option{"Bitrate", "Bitrate", "quality", ":bitrate=", false}); - module_info.opts.emplace_back(module_option{"Crf", "specifies CRF factor (only for libx264/libx265)", "crf", ":crf=", false}); + module_info.opts.emplace_back(module_option{"Bitrate", "Bitrate", "25M", "quality", ":bitrate=", false}); + module_info.opts.emplace_back(module_option{"Crf", "specifies CRF factor (only for libx264/libx265)", "23", "crf", ":crf=", false}); module_info.opts.emplace_back(module_option{"Disable intra refresh", - "Do not use Periodic Intra Refresh (H.264/H.265)", + "Do not use Periodic Intra Refresh (H.264/H.265)", "", "disable_intra_refresh", ":disable_intra_refresh", true}); module_info.opts.emplace_back(module_option{"Subsampling", "may be one of 444, 422, or 420, default 420 for progresive, 422 for interlaced", + "422", "subsampling", ":subsampling=", false}); module_info.opts.emplace_back(module_option{"Lavc opt", "arbitrary option to be passed directly to libavcodec (eg. preset=veryfast), eventual colons must be backslash-escaped (eg. for x264opts)", + "", "lavc_opt", ":", false}); for (const auto& param : codec_params) {