1
mirror of https://github.com/mpv-player/mpv synced 2024-10-02 16:25:33 +02:00
mpv/filters/f_lavfi.h
wm4 37ac43847e 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.
2019-11-25 20:29:42 +01:00

40 lines
1.9 KiB
C

#pragma once
#include "frame.h"
// A wrapped libavfilter filter or filter graph.
// (to free this, free the filter itself, mp_lavfi.f)
struct mp_lavfi {
// This mirrors the libavfilter pads according to the user specification.
struct mp_filter *f;
};
// Create a filter with the given libavfilter graph string. The graph must
// have labels on all unconnected pads; these are exposed as pins.
// type: if not 0, require all pads to have a compatible media type (or error)
// bidir: if true, require exactly 2 pads, 1 input, 1 output (mp_lavfi.f will
// have the input as pin 0, and the output as pin 1)
// graph_opts: options for the filter graph, see mp_set_avopts() (NULL is OK)
// graph: a libavfilter graph specification
struct mp_lavfi *mp_lavfi_create_graph(struct mp_filter *parent,
enum mp_frame_type type, bool bidir,
char **graph_opts, const char *graph);
// Unlike mp_lavfi_create_graph(), this creates a single filter, using explicit
// options, and without involving the libavfilter graph parser. Instead of
// a graph, it takes a filter name, and a key-value list of filter options
// (which are applied with mp_set_avopts()).
struct mp_lavfi *mp_lavfi_create_filter(struct mp_filter *parent,
enum mp_frame_type type, bool bidir,
char **graph_opts,
const char *filter, char **filter_opts);
// Print libavfilter list for --vf/--af
void print_lavfi_help_list(struct mp_log *log, int media_type);
// Print libavfilter help for the given filter
void print_lavfi_help(struct mp_log *log, const char *name, int media_type);
// Return whether the given filter exists and has the required media_type in/outs.
bool mp_lavfi_is_usable(const char *name, int media_type);