summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-20 15:09:29 +0200
committerwm4 <wm4@nowhere>2013-09-20 15:09:29 +0200
commit0611c43b97fe6225cc90b892379af0fc9ffe8e63 (patch)
treee22acafaca1d509d4928ebcf86884e0f8956cf57 /mpvcore
parent2694b5f3786575b0dde8b29b9fe162c50996c18e (diff)
downloadmpv-0611c43b97fe6225cc90b892379af0fc9ffe8e63.tar.bz2
mpv-0611c43b97fe6225cc90b892379af0fc9ffe8e63.tar.xz
command: use a list of potential deinterlacer filters
Instead of hardcoding a single filter. This might be helpful for modeling the vaapi deinterlacer as a video filter. The idea is that a software deinterlacer would be tried first, and if that fails (because vaapi hardware decoding uses HW surfaces, which a software deinterlacer does not accept), the vaapi filter would be tried.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index a2de363b3d..4217bd97e0 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -68,8 +68,8 @@
#include "mpvcore/mp_core.h"
-static void change_video_filters(MPContext *mpctx, const char *cmd,
- const char *arg);
+static int edit_filters(struct MPContext *mpctx, enum stream_type mediatype,
+ const char *cmd, const char *arg);
static int set_filters(struct MPContext *mpctx, enum stream_type mediatype,
struct m_obj_settings *new_chain);
@@ -1135,11 +1135,26 @@ static int mp_property_fullscreen(m_option_t *prop,
#define VF_DEINTERLACE_LABEL "deinterlace"
+static const char *deint_filters[] = {
#ifdef CONFIG_VF_LAVFI
-#define VF_DEINTERLACE "@" VF_DEINTERLACE_LABEL ":lavfi=yadif"
-#else
-#define VF_DEINTERLACE "@" VF_DEINTERLACE_LABEL ":yadif"
+ "lavfi=yadif",
#endif
+ "yadif",
+ NULL
+};
+
+static int probe_deint_filters(struct MPContext *mpctx, const char *cmd)
+{
+ for (int n = 0; deint_filters[n]; n++) {
+ char filter[80];
+ // add a label so that removing the filter is easier
+ snprintf(filter, sizeof(filter), "@%s:%s", VF_DEINTERLACE_LABEL,
+ deint_filters[n]);
+ if (edit_filters(mpctx, STREAM_VIDEO, cmd, filter) >= 0)
+ return 0;
+ }
+ return -1;
+}
static int get_deinterlacing(struct MPContext *mpctx)
{
@@ -1160,12 +1175,12 @@ static void set_deinterlacing(struct MPContext *mpctx, bool enable)
vf_instance_t *vf = mpctx->sh_video->vfilter;
if (vf_find_by_label(vf, VF_DEINTERLACE_LABEL)) {
if (!enable)
- change_video_filters(mpctx, "del", VF_DEINTERLACE);
+ edit_filters(mpctx, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL);
} else {
if ((get_deinterlacing(mpctx) > 0) != enable) {
int arg = enable;
if (vf->control(vf, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK)
- change_video_filters(mpctx, "add", VF_DEINTERLACE);
+ probe_deint_filters(mpctx, "add");
}
}
mpctx->opts->deinterlace = get_deinterlacing(mpctx) > 0;
@@ -2162,12 +2177,6 @@ static int edit_filters_osd(struct MPContext *mpctx, enum stream_type mediatype,
return r;
}
-static void change_video_filters(MPContext *mpctx, const char *cmd,
- const char *arg)
-{
- edit_filters(mpctx, STREAM_VIDEO, cmd, arg);
-}
-
void run_command(MPContext *mpctx, mp_cmd_t *cmd)
{
struct MPOpts *opts = mpctx->opts;