summaryrefslogtreecommitdiffstats
path: root/filters/user_filters.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-25 19:07:55 +0100
committerwm4 <wm4@nowhere>2019-11-25 20:29:42 +0100
commit37ac43847eddc42f51e348a81c73bb1b42481ad0 (patch)
tree292c59e0b816bf3a18e4ab0530a7c5b536b7fb25 /filters/user_filters.c
parent13afc2150beeb1117e9c1724b2910e41ee4cc28b (diff)
downloadmpv-37ac43847eddc42f51e348a81c73bb1b42481ad0.tar.bz2
mpv-37ac43847eddc42f51e348a81c73bb1b42481ad0.tar.xz
options: pre-check filter names when using vf/af libavfilter bridge
Until now, using a filter not in mpv's builtin filter list would assume it's a libavfilter filter. If it wasn't, the option value was still accepted, but creating the filter simply failed. But since this happens after option parsing, so the result is confusing. Improve this slightly by checking filter names. This will reject truly unknown filters at option parsing time. Unfortunately, this still does not check filter arguments. This would be much more complex, because you'd have to create a dummy filter graph and allocate the filter. Maybe another time.
Diffstat (limited to 'filters/user_filters.c')
-rw-r--r--filters/user_filters.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/filters/user_filters.c b/filters/user_filters.c
index 1a4cf3b122..5ca5b43090 100644
--- a/filters/user_filters.c
+++ b/filters/user_filters.c
@@ -48,11 +48,17 @@ static void print_af_lavfi_help(struct mp_log *log, const char *name)
print_lavfi_help(log, name, AVMEDIA_TYPE_AUDIO);
}
+static bool check_af_lavfi(const char *name)
+{
+ return mp_lavfi_is_usable(name, AVMEDIA_TYPE_AUDIO);
+}
+
const struct m_obj_list af_obj_list = {
.get_desc = get_af_desc,
.description = "audio filters",
.allow_disable_entries = true,
.allow_unknown_entries = true,
+ .check_unknown_entry = check_af_lavfi,
.print_help_list = print_af_help_list,
.print_unknown_entry_help = print_af_lavfi_help,
};
@@ -96,11 +102,17 @@ static void print_vf_lavfi_help(struct mp_log *log, const char *name)
print_lavfi_help(log, name, AVMEDIA_TYPE_VIDEO);
}
+static bool check_vf_lavfi(const char *name)
+{
+ return mp_lavfi_is_usable(name, AVMEDIA_TYPE_VIDEO);
+}
+
const struct m_obj_list vf_obj_list = {
.get_desc = get_vf_desc,
.description = "video filters",
.allow_disable_entries = true,
.allow_unknown_entries = true,
+ .check_unknown_entry = check_vf_lavfi,
.print_help_list = print_vf_help_list,
.print_unknown_entry_help = print_vf_lavfi_help,
};