mirror of https://github.com/mpv-player/mpv
m_option: optionally allow passing "no" to imgfmt option types
Needed for the following commit. Also, fix that uint32_t type - we always assumed int.
This commit is contained in:
parent
8fb0d2ee27
commit
0aa01ca743
|
@ -2047,6 +2047,8 @@ const m_option_type_t m_option_type_size_box = {
|
||||||
static int parse_imgfmt(struct mp_log *log, const m_option_t *opt,
|
static int parse_imgfmt(struct mp_log *log, const m_option_t *opt,
|
||||||
struct bstr name, struct bstr param, void *dst)
|
struct bstr name, struct bstr param, void *dst)
|
||||||
{
|
{
|
||||||
|
bool accept_no = opt->min < 0;
|
||||||
|
|
||||||
if (param.len == 0)
|
if (param.len == 0)
|
||||||
return M_OPT_MISSING_PARAM;
|
return M_OPT_MISSING_PARAM;
|
||||||
|
|
||||||
|
@ -2055,28 +2057,29 @@ static int parse_imgfmt(struct mp_log *log, const m_option_t *opt,
|
||||||
char **list = mp_imgfmt_name_list();
|
char **list = mp_imgfmt_name_list();
|
||||||
for (int i = 0; list[i]; i++)
|
for (int i = 0; list[i]; i++)
|
||||||
mp_info(log, " %s", list[i]);
|
mp_info(log, " %s", list[i]);
|
||||||
|
if (accept_no)
|
||||||
|
mp_info(log, " no");
|
||||||
mp_info(log, "\n");
|
mp_info(log, "\n");
|
||||||
talloc_free(list);
|
talloc_free(list);
|
||||||
return M_OPT_EXIT;
|
return M_OPT_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int fmt = mp_imgfmt_from_name(param, true);
|
unsigned int fmt = mp_imgfmt_from_name(param, true);
|
||||||
if (!fmt) {
|
if (!fmt && !(accept_no && bstr_equals0(param, "no"))) {
|
||||||
mp_err(log, "Option %.*s: unknown format name: '%.*s'\n",
|
mp_err(log, "Option %.*s: unknown format name: '%.*s'\n",
|
||||||
BSTR_P(name), BSTR_P(param));
|
BSTR_P(name), BSTR_P(param));
|
||||||
return M_OPT_INVALID;
|
return M_OPT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst)
|
if (dst)
|
||||||
*((uint32_t *)dst) = fmt;
|
*((int *)dst) = fmt;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const m_option_type_t m_option_type_imgfmt = {
|
const m_option_type_t m_option_type_imgfmt = {
|
||||||
// Please report any missing colorspaces
|
|
||||||
.name = "Image format",
|
.name = "Image format",
|
||||||
.size = sizeof(uint32_t),
|
.size = sizeof(int),
|
||||||
.parse = parse_imgfmt,
|
.parse = parse_imgfmt,
|
||||||
.copy = copy_opt,
|
.copy = copy_opt,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue