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.
This commit is contained in:
wm4 2019-12-07 14:19:11 +01:00
parent d90d5ee1a0
commit 855a4779ae
2 changed files with 10 additions and 6 deletions

View File

@ -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);
}

View File

@ -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 = {