Skip to content

Commit

Permalink
capabilities: Report placeholder text for codec options
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiatka committed Sep 20, 2024
1 parent 64ee8a2 commit 2798cfb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") << "\"}";
Expand Down
1 change: 1 addition & 0 deletions src/video_compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ typedef std::shared_ptr<video_frame> (*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
Expand Down
9 changes: 5 additions & 4 deletions src/video_compress/cineform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/video_compress/cmpto_j2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <t>", ":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 <t>", ":pool_size=", false, TOSTRING(DEFAULT_POOL_SIZE)},
{"Use MCT", "mct", "use MCT", ":mct", true, ""},
};

static void usage() {
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/video_compress/gpujpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 });
}

Expand Down
8 changes: 5 additions & 3 deletions src/video_compress/libavcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2798cfb

Please sign in to comment.