summaryrefslogtreecommitdiffstats
path: root/common/av_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-27 15:55:53 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-29 02:21:32 +0300
commit2a28712b44b0b462a33ee6e91c98e8e19549fede (patch)
tree7ad0c7b8ac366096e77c9fd60d60ce2d6b06a8a2 /common/av_common.c
parentfff5fda74b4fd151b2fa488f34a55a3c7dda9990 (diff)
downloadmpv-2a28712b44b0b462a33ee6e91c98e8e19549fede.tar.bz2
mpv-2a28712b44b0b462a33ee6e91c98e8e19549fede.tar.xz
f_lavfi: support setting common filter options like "threads"
AVFilterContext instances support some additional AVOptions over the actual filter. This includes useful options like "threads". We didn't support setting those for the "direct" wrapper (--vf=yadif:threads=1 failed). Change this. It requires setting options on the AVFilterContext directly, except the code for positional parameters still needs to access the actual filter's AVOptions.
Diffstat (limited to 'common/av_common.c')
-rw-r--r--common/av_common.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/av_common.c b/common/av_common.c
index 2c959ffe4f..3ea1ceb872 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -313,7 +313,7 @@ void mp_avdict_print_unset(struct mp_log *log, int msgl, AVDictionary *dict)
// to the name of the n-th parameter.
static void resolve_positional_arg(void *avobj, char **name)
{
- if (!*name || (*name)[0] != '@')
+ if (!*name || (*name)[0] != '@' || !avobj)
return;
char *end = NULL;
@@ -345,11 +345,18 @@ static void resolve_positional_arg(void *avobj, char **name)
// Returns: >=0 success, <0 failed to set an option
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv)
{
+ return mp_set_avopts_pos(log, avobj, avobj, kv);
+}
+
+// Like mp_set_avopts(), but the posargs argument is used to resolve positional
+// arguments. If posargs==NULL, positional args are disabled.
+int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv)
+{
int success = 0;
for (int n = 0; kv && kv[n * 2]; n++) {
char *k = kv[n * 2 + 0];
char *v = kv[n * 2 + 1];
- resolve_positional_arg(avobj, &k);
+ resolve_positional_arg(posargs, &k);
int r = av_opt_set(avobj, k, v, AV_OPT_SEARCH_CHILDREN);
if (r == AVERROR_OPTION_NOT_FOUND) {
mp_err(log, "AVOption '%s' not found.\n", k);