1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-09 08:27:18 +00:00

video/filters: simplify libavfilter bridge

Remove the confusing crap that allowed a filter using the libavfilter
bridge to be compiled without libavfilter. Instead, compile the wrappers
only if libavfilter is enabled at compile time.

The only filter which still requires it is vf_stereo3d (unfortunately).
Special-case this one. (The whole filter and how it interacts with lavfi
is pure braindeath anyway.)

(cherry picked from commit 2522bff565)
This commit is contained in:
wm4 2015-02-11 17:32:41 +01:00 committed by Diogo Franco (Kovensky)
parent d4207c64e6
commit 64a45f972c
13 changed files with 61 additions and 71 deletions

View File

@ -99,6 +99,14 @@ SOURCES-$(WAYLAND) += video/out/vo_wayland.c \
video/out/wayland/memfile.c
SOURCES-$(LIBAVFILTER) += video/filter/vf_lavfi.c \
video/filter/vf_delogo.c \
video/filter/vf_gradfun.c \
video/filter/vf_hqdn3d.c \
video/filter/vf_noise.c \
video/filter/vf_pullup.c \
video/filter/vf_rotate.c \
video/filter/vf_unsharp.c \
video/filter/vf_yadif.c \
audio/filter/af_lavfi.c
SOURCES-$(LUA) += player/lua.c
@ -250,25 +258,17 @@ SOURCES = audio/audio.c \
video/filter/vf.c \
video/filter/vf_buffer.c \
video/filter/vf_crop.c \
video/filter/vf_delogo.c \
video/filter/vf_dsize.c \
video/filter/vf_eq.c \
video/filter/vf_expand.c \
video/filter/vf_flip.c \
video/filter/vf_format.c \
video/filter/vf_gradfun.c \
video/filter/vf_hqdn3d.c \
video/filter/vf_mirror.c \
video/filter/vf_noformat.c \
video/filter/vf_noise.c \
video/filter/vf_pullup.c \
video/filter/vf_rotate.c \
video/filter/vf_scale.c \
video/filter/vf_screenshot.c \
video/filter/vf_stereo3d.c \
video/filter/vf_sub.c \
video/filter/vf_unsharp.c \
video/filter/vf_yadif.c \
video/out/bitmap_packer.c \
video/out/aspect.c \
video/out/filter_kernels.c \

View File

@ -77,25 +77,25 @@ static const vf_info_t *const filter_list[] = {
&vf_info_format,
&vf_info_noformat,
&vf_info_flip,
&vf_info_rotate,
&vf_info_mirror,
#if HAVE_LIBAVFILTER
&vf_info_lavfi,
&vf_info_rotate,
&vf_info_noise,
&vf_info_gradfun,
&vf_info_unsharp,
&vf_info_hqdn3d,
&vf_info_pullup,
&vf_info_delogo,
&vf_info_yadif,
#endif
&vf_info_screenshot,
&vf_info_noise,
&vf_info_eq,
&vf_info_gradfun,
&vf_info_unsharp,
&vf_info_hqdn3d,
&vf_info_dsize,
&vf_info_pullup,
&vf_info_delogo,
&vf_info_sub,
&vf_info_yadif,
&vf_info_stereo3d,
&vf_info_buffer,
#if HAVE_DLOPEN

View File

@ -48,7 +48,7 @@ static int vf_open(vf_instance_t *vf){
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'delogo' filter.\n");
return 0;
}

View File

@ -79,7 +79,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'gradfun' filter.\n");
return 0;
}

View File

@ -42,7 +42,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'hqdn3' filter.\n");
return 0;
}

View File

@ -38,6 +38,7 @@
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include "config.h"
#include "common/av_common.h"
#include "common/msg.h"
#include "options/m_option.h"

View File

@ -1,15 +1,11 @@
#ifndef MP_VF_LAVFI_H_
#define MP_VF_LAVFI_H_
#include "config.h"
#include "common/common.h"
#include "vf.h"
struct vf_lw_opts;
#if HAVE_LIBAVFILTER
extern const struct m_sub_options vf_lw_conf;
int vf_lw_set_graph(struct vf_instance *vf, struct vf_lw_opts *lavfi_opts,
@ -21,28 +17,5 @@ void vf_lw_set_reconfig_cb(struct vf_instance *vf,
int (*reconfig)(struct vf_instance *vf,
struct mp_image_params *in,
struct mp_image_params *out));
#else
static inline
int vf_lw_set_graph(struct vf_instance *vf, struct vf_lw_opts *lavfi_opts,
char *filter, char *opts, ...)
{
return -1;
}
static void *vf_lw_old_priv(struct vf_instance *vf)
{
return 0;
}
static void vf_lw_update_graph(struct vf_instance *vf, char *filter, char *opts, ...)
{
}
static void vf_lw_set_reconfig_cb(struct vf_instance *vf,
int (*reconfig)(struct vf_instance *vf,
struct mp_image_params *in,
struct mp_image_params *out))
{
}
#include "options/m_option.h"
static const struct m_sub_options vf_lw_conf = {0};
#endif
#endif

View File

@ -48,7 +48,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'pullup' filter.\n");
return 0;
}

View File

@ -66,8 +66,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
return 1;
return 0;
}
#define OPT_BASE_STRUCT struct vf_priv_s

View File

@ -510,6 +510,8 @@ static bool handle_auto_in(struct vf_instance *vf)
return true;
}
#if HAVE_LIBAVFILTER
static int lavfi_reconfig(struct vf_instance *vf,
struct mp_image_params *in,
struct mp_image_params *out)
@ -528,6 +530,32 @@ static int lavfi_reconfig(struct vf_instance *vf,
return 0;
}
static void lavfi_init(vf_instance_t *vf)
{
if (vf->priv->in.fmt == STEREO_AUTO &&
vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "null") >= 0)
{
vf_lw_set_reconfig_cb(vf, lavfi_reconfig);
return;
}
if (vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "%s:%s",
rev_map_name(vf->priv->in.fmt),
rev_map_name(vf->priv->out.fmt)) >= 0)
return;
}
#else
const struct m_sub_options vf_lw_conf = {0};
static void lavfi_init(vf_instance_t *vf)
{
// doing nothing will make it use the internal implementation
}
#endif
static int vf_open(vf_instance_t *vf)
{
vf->config = config;
@ -541,18 +569,7 @@ static int vf_open(vf_instance_t *vf)
if (vf->priv->in.fmt == STEREO_AUTO)
vf->priv->auto_in = 1;
if (vf->priv->in.fmt == STEREO_AUTO &&
vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "null") >= 0)
{
vf_lw_set_reconfig_cb(vf, lavfi_reconfig);
return 1;
}
if (vf_lw_set_graph(vf, vf->priv->lw_opts, "stereo3d", "%s:%s",
rev_map_name(vf->priv->in.fmt),
rev_map_name(vf->priv->out.fmt)) >= 0)
return 1;
lavfi_init(vf);
return 1;
}

View File

@ -55,7 +55,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'unsharp' filter.\n");
return 0;
}

View File

@ -52,7 +52,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
MP_FATAL(vf, "Requires libavfilter.\n");
MP_FATAL(vf, "This version of libavfilter has no 'yadif' filter.\n");
return 0;
}

View File

@ -297,30 +297,30 @@ def build(ctx):
( "video/filter/vf.c" ),
( "video/filter/vf_buffer.c" ),
( "video/filter/vf_crop.c" ),
( "video/filter/vf_delogo.c" ),
( "video/filter/vf_delogo.c", "libavfilter"),
( "video/filter/vf_dlopen.c", "dlopen" ),
( "video/filter/vf_dsize.c" ),
( "video/filter/vf_eq.c" ),
( "video/filter/vf_expand.c" ),
( "video/filter/vf_flip.c" ),
( "video/filter/vf_format.c" ),
( "video/filter/vf_gradfun.c" ),
( "video/filter/vf_hqdn3d.c" ),
( "video/filter/vf_gradfun.c", "libavfilter"),
( "video/filter/vf_hqdn3d.c", "libavfilter"),
( "video/filter/vf_lavfi.c", "libavfilter"),
( "video/filter/vf_mirror.c" ),
( "video/filter/vf_noformat.c" ),
( "video/filter/vf_noise.c" ),
( "video/filter/vf_pullup.c" ),
( "video/filter/vf_rotate.c" ),
( "video/filter/vf_noise.c", "libavfilter"),
( "video/filter/vf_pullup.c", "libavfilter"),
( "video/filter/vf_rotate.c", "libavfilter"),
( "video/filter/vf_scale.c" ),
( "video/filter/vf_screenshot.c" ),
( "video/filter/vf_stereo3d.c" ),
( "video/filter/vf_sub.c" ),
( "video/filter/vf_unsharp.c" ),
( "video/filter/vf_unsharp.c", "libavfilter"),
( "video/filter/vf_vapoursynth.c", "vapoursynth-core" ),
( "video/filter/vf_vavpp.c", "vaapi-vpp"),
( "video/filter/vf_vdpaupp.c", "vdpau" ),
( "video/filter/vf_yadif.c" ),
( "video/filter/vf_yadif.c", "libavfilter"),
( "video/out/aspect.c" ),
( "video/out/bitmap_packer.c" ),
( "video/out/cocoa/video_view.m", "cocoa" ),