options: enable handling --no-hwdec as --hwdec=no

Reusing M_OPT_ALLOW_NO has the side-effect of applying to --ab-loop-[ab],
which makes sense.
This commit is contained in:
sfan5 2024-09-29 15:19:52 +02:00
parent ce0452fa0d
commit c11239be8c
3 changed files with 7 additions and 2 deletions

View File

@ -662,10 +662,13 @@ static struct m_config_option *m_config_mogrify_cli_opt(struct m_config *config,
bstr no_name = *name;
if (!co && bstr_eatstart0(&no_name, "no-")) {
co = m_config_get_co(config, no_name);
if (!co)
return NULL;
// Not all choice types have this value - if they don't, then parsing
// them will simply result in an error. Good enough.
if (!co || !(co->opt->type->flags & M_OPT_TYPE_CHOICE))
if (!(co->opt->type->flags & M_OPT_TYPE_CHOICE) &&
!(co->opt->flags & M_OPT_ALLOW_NO))
return NULL;
*name = no_name;

View File

@ -468,6 +468,8 @@ char *format_file_size(int64_t size);
#define M_OPT_DEFAULT_NAN (1 << 26)
// type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected)
// and
// parsing: "--no-opt" is parsed as "--opt=no"
#define M_OPT_ALLOW_NO (1 << 27)
// type channels: disallow "auto" (still accept ""), limit list to at most 1 item.

View File

@ -124,7 +124,7 @@ const struct m_sub_options vd_lavc_conf = {
{"vd-apply-cropping", OPT_BOOL(apply_cropping)},
{"hwdec", OPT_STRINGLIST(hwdec_api),
.help = hwdec_opt_help,
.flags = M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC},
.flags = M_OPT_OPTIONAL_PARAM | M_OPT_ALLOW_NO | UPDATE_HWDEC},
{"hwdec-codecs", OPT_STRING(hwdec_codecs)},
{"hwdec-image-format", OPT_IMAGEFORMAT(hwdec_image_format)},
{"hwdec-extra-frames", OPT_INT(hwdec_extra_frames), M_RANGE(0, 256)},