summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-07 14:19:11 +0100
committerwm4 <wm4@nowhere>2019-12-07 14:19:11 +0100
commit855a4779ae64a53d04a7d8fcdc274bd8f2155831 (patch)
tree6591561f3b7e3933227608a712ccde4227a3622d /filters
parentd90d5ee1a0914239ee3048fe567fed14adbe1127 (diff)
downloadmpv-855a4779ae64a53d04a7d8fcdc274bd8f2155831.tar.bz2
mpv-855a4779ae64a53d04a7d8fcdc274bd8f2155831.tar.xz
filters: move prefix check from f_lavfi.c to user_filters.c
It's user_filters.c which allows the "lavfi-" prefix to distinguish libavfilter filters from mpv builtin filters. f_lavfi.c is a layer below, and strictly passes anything it gets to libavfilter. So the correct place for this is in user_filters.c, which also has the code for stripping the prefix in the normal filter instantiation code.
Diffstat (limited to 'filters')
-rw-r--r--filters/f_lavfi.c4
-rw-r--r--filters/user_filters.c12
2 files changed, 10 insertions, 6 deletions
diff --git a/filters/f_lavfi.c b/filters/f_lavfi.c
index f4f68ba0af..23af326c9b 100644
--- a/filters/f_lavfi.c
+++ b/filters/f_lavfi.c
@@ -943,10 +943,6 @@ static bool is_usable(const AVFilter *filter, int media_type)
bool mp_lavfi_is_usable(const char *name, int media_type)
{
- // Skip the lavfi- prefix, if present.
- if (strncmp(name, "lavfi-", 6) == 0)
- name += 6;
-
const AVFilter *f = avfilter_get_by_name(name);
return f && is_usable(f, media_type);
}
diff --git a/filters/user_filters.c b/filters/user_filters.c
index 69017b7b5a..7fb164490e 100644
--- a/filters/user_filters.c
+++ b/filters/user_filters.c
@@ -20,6 +20,14 @@ static bool get_desc_from(const struct mp_user_filter_entry **list, int num,
return true;
}
+static bool check_unknown_entry(const char *name, int media_type)
+{
+ // Generic lavfi bridge: skip the lavfi- prefix, if present.
+ if (strncmp(name, "lavfi-", 6) == 0)
+ name += 6;
+ return mp_lavfi_is_usable(name, media_type);
+}
+
// --af option
const struct mp_user_filter_entry *af_list[] = {
@@ -50,7 +58,7 @@ static void print_af_lavfi_help(struct mp_log *log, const char *name)
static bool check_af_lavfi(const char *name)
{
- return mp_lavfi_is_usable(name, AVMEDIA_TYPE_AUDIO);
+ return check_unknown_entry(name, AVMEDIA_TYPE_AUDIO);
}
const struct m_obj_list af_obj_list = {
@@ -107,7 +115,7 @@ static void print_vf_lavfi_help(struct mp_log *log, const char *name)
static bool check_vf_lavfi(const char *name)
{
- return mp_lavfi_is_usable(name, AVMEDIA_TYPE_VIDEO);
+ return check_unknown_entry(name, AVMEDIA_TYPE_VIDEO);
}
const struct m_obj_list vf_obj_list = {