mirror of https://github.com/mpv-player/mpv
options: allow using [ ] for quoting in sub-options
This is an attempt to make quoting of sub-option values less awkward, even if it works only with some shells. This is needed mainly for vf_lavfi. Also update the vf_lavfi manpage section.
This commit is contained in:
parent
ca08ce77a9
commit
28a971e26f
|
@ -383,14 +383,21 @@ lavfi=graph[:sws_flags]
|
|||
|
||||
*EXAMPLE*:
|
||||
|
||||
``'--vf=lavfi="gradfun=20:30"'``
|
||||
gradfun filter with non-sensical parameters. The ``'`` quotes are
|
||||
for the shell. Otherwise, the shell would remove the ``"`` quotes.
|
||||
``-vf lavfi=[gradfun=20:30,vflip]``
|
||||
gradfun filter with nonsense parameters, followed by a vflip
|
||||
filter. (This demonstrates how libavfilter takes a graph and not
|
||||
just a single filter.) The filter graph string is quoted with
|
||||
``[`` and ``]``. This requires no additional quoting or escaping
|
||||
with some shells (like bash), while others (like zsh) require
|
||||
additional ``"`` quotes around the option string.
|
||||
|
||||
``'--vf=lavfi="gradfun=20:30,vflip"'``
|
||||
same as before, but uses quoting that should be safe with all
|
||||
shells. The outer ``'`` quotes make sure that the shell doesn't
|
||||
remove the ``"`` quotes needed by mpv.
|
||||
|
||||
``'--vf=lavfi=graph="gradfun=radius=30:strength=20,vflip"'``
|
||||
same as before, but uses named parameters. Also a vflip filter is
|
||||
appended, demonstrating how libavfilter actually takes a graph
|
||||
description and not a single filter.
|
||||
same as before, but uses named parameters for everything.
|
||||
|
||||
<sws_flags>
|
||||
If libavfilter inserts filters for pixel format conversion, this
|
||||
|
|
|
@ -1167,6 +1167,13 @@ static int read_subparam(bstr optname, bstr *str, bstr *out_subparam)
|
|||
return M_OPT_INVALID;
|
||||
}
|
||||
p = bstr_cut(p, 1);
|
||||
} else if (bstr_eatstart0(&p, "[")) {
|
||||
if (!bstr_split_tok(p, "]", &subparam, &p)) {
|
||||
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||
"Terminating ']' missing for '%.*s'\n",
|
||||
BSTR_P(optname));
|
||||
return M_OPT_INVALID;
|
||||
}
|
||||
} else if (bstr_eatstart0(&p, "%")) {
|
||||
int optlen = bstrtoll(p, &p, 0);
|
||||
if (!bstr_startswith0(p, "%") || (optlen > p.len - 1)) {
|
||||
|
@ -1180,7 +1187,7 @@ static int read_subparam(bstr optname, bstr *str, bstr *out_subparam)
|
|||
} else {
|
||||
// Skip until the next character that could possibly be a meta
|
||||
// character in option parsing.
|
||||
int optlen = bstrcspn(p, ":=,\\%\"'");
|
||||
int optlen = bstrcspn(p, ":=,\\%\"'[]");
|
||||
subparam = bstr_splice(p, 0, optlen);
|
||||
p = bstr_cut(p, optlen);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue