vf_lavfi: silence stupid deprecation warning

libavfilter changed the way a format list is passed to vf_format. Now
you have to separate formats with "|" instead of ":". If you use "|",
it prints an annoying message on every reinit:

    [format @ 0x8bbaaa0]This syntax is deprecated. Use '|' to separate the list items.

...and it will probably stop working without warning at some point in
the future.

We need some very annoying ifdeffery to detect this case, because
libavfilter version numbers are just plain incompatible between Libav
and ffmpeg. There is no other way to detect this.

(Sometimes I wonder whether ffmpeg and especially Libav actually like
causing unnecessary pain for their users, and intentionally break stuff
in the most annoying way possible. Sigh...)
This commit is contained in:
wm4 2013-04-26 12:17:43 +02:00
parent 3765cfcf57
commit 3ffeeee411
1 changed files with 12 additions and 2 deletions

View File

@ -45,6 +45,8 @@
#include "video/fmt-conversion.h"
#include "vf.h"
#define IS_LIBAV_FORK (LIBAVFILTER_VERSION_MICRO < 100)
struct vf_priv_s {
AVFilterGraph *graph;
AVFilterContext *in;
@ -72,7 +74,7 @@ static void destroy_graph(struct vf_instance *vf)
// FFmpeg and Libav have slightly different APIs, just enough to cause us
// unnecessary pain. <Expletive deleted.>
#if LIBAVFILTER_VERSION_MICRO < 100
#if IS_LIBAV_FORK
#define graph_parse(graph, filters, inputs, outputs, log_ctx) \
avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx)
#else
@ -80,6 +82,14 @@ static void destroy_graph(struct vf_instance *vf)
avfilter_graph_parse(graph, filters, &(inputs), &(outputs), log_ctx)
#endif
// ":" is deprecated, but "|" doesn't work in earlier versions.
#if (IS_LIBAV_FORK && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3, 7, 0)) || \
(!IS_LIBAV_FORK && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3, 50, 100))
#define FMTSEP "|"
#else
#define FMTSEP ":"
#endif
static AVRational par_from_sar_dar(int width, int height,
int d_width, int d_height)
{
@ -133,7 +143,7 @@ static bool recreate_graph(struct vf_instance *vf, int width, int height,
if (vf_next_query_format(vf, n)) {
const char *name = av_get_pix_fmt_name(imgfmt2pixfmt(n));
if (name) {
const char *s = fmtstr[0] ? ":" : "";
const char *s = fmtstr[0] ? FMTSEP : "";
fmtstr = talloc_asprintf_append_buffer(fmtstr, "%s%s", s, name);
}
}