summaryrefslogtreecommitdiffstats
path: root/m_option.c
diff options
context:
space:
mode:
Diffstat (limited to 'm_option.c')
-rw-r--r--m_option.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/m_option.c b/m_option.c
index 18f94dc7a9..086f2c8842 100644
--- a/m_option.c
+++ b/m_option.c
@@ -272,13 +272,20 @@ static int parse_choice(const struct m_option *opt, struct bstr name,
struct bstr param, bool ambiguous_param, void *dst,
void *talloc_ctx)
{
- if (param.len == 0)
- return M_OPT_MISSING_PARAM;
-
- struct m_opt_choice_alternatives *alt;
- for (alt = opt->priv; alt->name; alt++)
- if (!bstrcasecmp0(param, alt->name))
- break;
+ bool allow_empty = opt->flags & M_OPT_IMPLICIT_DEFAULT;
+ int ret;
+
+ struct m_opt_choice_alternatives *alt = opt->priv;
+ if (param.len == 0 || (ambiguous_param && allow_empty)) {
+ if (!allow_empty)
+ return M_OPT_MISSING_PARAM;
+ ret = 0;
+ } else {
+ for ( ; alt->name; alt++)
+ if (!bstrcasecmp0(param, alt->name))
+ break;
+ ret = 1;
+ }
if (!alt->name) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Invalid value for option %.*s: %.*s\n",
@@ -292,7 +299,7 @@ static int parse_choice(const struct m_option *opt, struct bstr name,
if (dst)
*(int *)dst = alt->value;
- return 1;
+ return ret;
}
static char *print_choice(const m_option_t *opt, const void *val)
@@ -988,6 +995,7 @@ static struct {
{"argb", IMGFMT_ARGB},
{"bgra", IMGFMT_BGRA},
{"abgr", IMGFMT_ABGR},
+ {"gbrp", IMGFMT_GBRP},
{"mjpeg", IMGFMT_MJPEG},
{"mjpg", IMGFMT_MJPEG},
{ NULL, 0 }