1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-21 23:23:19 +00:00

af, vf: improvements to libavfilter bridge

Add the "lavfi-" prefix (details see manpage additons).

Tag the filter name as "(lavfi)" in the verbose filter list output.
This commit is contained in:
wm4 2017-05-31 17:42:03 +02:00
parent 1a25f8c9fb
commit cc69650e76
6 changed files with 28 additions and 5 deletions

View File

@ -15,6 +15,9 @@ syntax is:
wrapper, which gives you access to most of libavfilter's filters. This
includes all filters that have been ported from MPlayer to libavfilter.
The ``--vf`` description describes how libavfilter can be used and how to
workaround deprecated mpv filters.
See ``--vf`` group of options for info on how ``--af-defaults``, ``--af-add``,
``--af-pre``, ``--af-del``, ``--af-clr``, and possibly others work.

View File

@ -49,13 +49,14 @@ normal filter parameters.
.. note::
To get a full list of available video filters, see ``--vf=help``.
To get a full list of available video filters, see ``--vf=help`` and
http://ffmpeg.org/ffmpeg-filters.html .
Also, keep in mind that most actual filters are available via the ``lavfi``
wrapper, which gives you access to most of libavfilter's filters. This
includes all filters that have been ported from MPlayer to libavfilter.
Most filters are deprecated in some ways, unless they're only available
Most builtin filters are deprecated in some ways, unless they're only available
in mpv (such as filters which deal with mpv specifics, or which are
implemented in mpv only).
@ -66,6 +67,11 @@ normal filter parameters.
everything accepted by vf_lavfi's ``graph`` option will be accepted by
``--vf``.)
You can also prefix the filter name with ``lavfi-`` to force the wrapper.
This is helpful if the filter name collides with a deprecated mpv builtin
filter. For example ``--vf=lavfi-scale=args`` would use libavfilter's
``scale`` filter over mpv's deprecated builtin one.
Video filters are managed in lists. There are a few commands to manage the
filter list.
@ -92,7 +98,7 @@ With filters that support it, you can access parameters by their name.
Sets a named parameter to the given value. Use on and off or yes and no to
set flag parameters.
Available filters are:
Available mpv-only filters are:
``crop[=w:h:x:y]``
Crops the given part of the image and discards the rest. Useful to remove

View File

@ -163,11 +163,14 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
lavfi_name = name;
lavfi_args = args;
args = NULL;
if (strncmp(lavfi_name, "lavfi-", 6) == 0)
lavfi_name += 6;
}
MP_VERBOSE(s, "Adding filter %s \n", name);
struct af_instance *af = talloc_zero(NULL, struct af_instance);
*af = (struct af_instance) {
.full_name = talloc_strdup(af, name),
.info = desc.p,
.data = talloc_zero(af, struct mp_audio),
.log = mp_log_new(af, s->log, name),
@ -192,6 +195,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
assert(opts->opt->type == &m_option_type_keyvalue_list);
if (m_config_set_option_raw(config, opts, &lavfi_args, 0) < 0)
goto error;
af->full_name = talloc_asprintf(af, "%s (lavfi)", af->full_name);
}
af->priv = config->optstruct;
@ -271,7 +275,7 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
struct af_instance *af = s->first;
while (af) {
char b[128] = {0};
mp_snprintf_cat(b, sizeof(b), " [%s] ", af->info->name);
mp_snprintf_cat(b, sizeof(b), " [%s] ", af->full_name);
if (af->label)
mp_snprintf_cat(b, sizeof(b), "\"%s\" ", af->label);
if (af->data)
@ -518,6 +522,7 @@ struct af_stream *af_new(struct mpv_global *global)
static const struct af_info in = { .name = "in" };
s->first = talloc(s, struct af_instance);
*s->first = (struct af_instance) {
.full_name = "in",
.info = &in,
.log = s->log,
.control = input_control,
@ -529,6 +534,7 @@ struct af_stream *af_new(struct mpv_global *global)
static const struct af_info out = { .name = "out" };
s->last = talloc(s, struct af_instance);
*s->last = (struct af_instance) {
.full_name = "out",
.info = &out,
.log = s->log,
.control = output_control,

View File

@ -52,6 +52,7 @@ struct af_info {
// Linked list of audio filters
struct af_instance {
const struct af_info *info;
char *full_name;
struct mp_log *log;
struct MPOpts *opts;
struct replaygain_data *replaygain_data;

View File

@ -229,7 +229,7 @@ void vf_print_filter_chain(struct vf_chain *c, int msglevel,
for (vf_instance_t *f = c->first; f; f = f->next) {
char b[128] = {0};
mp_snprintf_cat(b, sizeof(b), " [%s] ", f->info->name);
mp_snprintf_cat(b, sizeof(b), " [%s] ", f->full_name);
if (f->label)
mp_snprintf_cat(b, sizeof(b), "\"%s\" ", f->label);
mp_snprintf_cat(b, sizeof(b), "%s", mp_image_params_to_str(&f->fmt_out));
@ -255,9 +255,12 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name,
lavfi_name = name;
lavfi_args = args;
args = NULL;
if (strncmp(lavfi_name, "lavfi-", 6) == 0)
lavfi_name += 6;
}
vf_instance_t *vf = talloc_zero(NULL, struct vf_instance);
*vf = (vf_instance_t) {
.full_name = talloc_strdup(vf, name),
.info = desc.p,
.log = mp_log_new(vf, c->log, name),
.hwdec_devs = c->hwdec_devs,
@ -282,6 +285,7 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name,
assert(opts->opt->type == &m_option_type_keyvalue_list);
if (m_config_set_option_raw(config, opts, &lavfi_args, 0) < 0)
goto error;
vf->full_name = talloc_asprintf(vf, "%s (lavfi)", vf->full_name);
}
vf->priv = config->optstruct;
int retcode = vf->info->open(vf);
@ -792,6 +796,7 @@ struct vf_chain *vf_new(struct mpv_global *global)
static const struct vf_info in = { .name = "in" };
c->first = talloc(c, struct vf_instance);
*c->first = (struct vf_instance) {
.full_name = "in",
.log = c->log,
.info = &in,
.query_format = input_query_format,
@ -799,6 +804,7 @@ struct vf_chain *vf_new(struct mpv_global *global)
static const struct vf_info out = { .name = "out" };
c->last = talloc(c, struct vf_instance);
*c->last = (struct vf_instance) {
.full_name = "out",
.log = c->log,
.info = &out,
.query_format = output_query_format,

View File

@ -46,6 +46,7 @@ typedef struct vf_info {
typedef struct vf_instance {
const vf_info_t *info;
char *full_name;
// Initialize the filter. The filter must set *out to the same image
// params as the images the filter functions will return for the given