diff options
author | wm4 <wm4@nowhere> | 2016-07-05 21:10:26 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-07-05 21:10:26 +0200 |
commit | d72bcc8041f1a5cc5ea92a9579aa2b07fd8b3b59 (patch) | |
tree | 3839d81a2319f6a6cf88b8d35df08fea9d5214d6 /player/command.c | |
parent | 329a7147d003f70a017ad6560a1b671b66ae2b62 (diff) | |
download | mpv-d72bcc8041f1a5cc5ea92a9579aa2b07fd8b3b59.tar.bz2 mpv-d72bcc8041f1a5cc5ea92a9579aa2b07fd8b3b59.tar.xz |
player: rewrite deinterlace filter auto-insertion
Instead of using the "vf" command code (which changes filters at runtime
on user input), use the general filter-insertion code. The latter was
added later, and is more suitable for automatically inserted filters.
The old code failed in particular when using watch-later saving, which
stored the filter list in the resume config file. If a user changed the
hardware decoding mode via command line, the stored filter chain was out
of date and could cause failure due to not working with hardware or
software decoding mode. Storing the deinterlace filter in the filter
list was unavoidable, because it was part of the user state. (The new
code only edits the actually instantiated filters.)
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/player/command.c b/player/command.c index 85f453e0ef..425f040ff2 100644 --- a/player/command.c +++ b/player/command.c @@ -2258,88 +2258,6 @@ static int mp_property_detected_hwdec(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } -#define VF_DEINTERLACE_LABEL "deinterlace" - -static bool probe_deint_filter(struct MPContext *mpctx, const char *filt) -{ - char filter[80]; - // add a label so that removing the filter is easier - snprintf(filter, sizeof(filter), "@%s:%s", VF_DEINTERLACE_LABEL, filt); - return edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "pre", filter) >= 0; -} - -static bool check_output_format(struct MPContext *mpctx, int imgfmt) -{ - struct vo_chain *vo_c = mpctx->vo_chain; - if (!vo_c) - return false; - return vo_c->vf->allowed_output_formats[imgfmt - IMGFMT_START]; -} - -static int probe_deint_filters(struct MPContext *mpctx) -{ - if (check_output_format(mpctx, IMGFMT_VDPAU)) { - char filter[80] = "vdpaupp:deint=yes"; - int pref = 0; - vo_control(mpctx->video_out, VOCTRL_GET_PREF_DEINT, &pref); - pref = pref < 0 ? -pref : pref; - if (pref > 0 && pref <= 4) { - const char *types[] = - {"", "first-field", "bob", "temporal", "temporal-spatial"}; - mp_snprintf_cat(filter, sizeof(filter), ":deint-mode=%s", - types[pref]); - } - - probe_deint_filter(mpctx, filter); - return 0; - } - if (check_output_format(mpctx, IMGFMT_VAAPI) && - probe_deint_filter(mpctx, "vavpp")) - return 0; - if ((check_output_format(mpctx, IMGFMT_D3D11VA) || - check_output_format(mpctx, IMGFMT_D3D11NV12)) && - probe_deint_filter(mpctx, "d3d11vpp")) - return 0; - if (probe_deint_filter(mpctx, "yadif")) - return 0; - return -1; -} - -static int get_deinterlacing(struct MPContext *mpctx) -{ - struct vo_chain *vo_c = mpctx->vo_chain; - int enabled = 0; - if (video_vf_vo_control(vo_c, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK) - enabled = -1; - if (enabled < 0) { - // vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE - if (vf_find_by_label(vo_c->vf, VF_DEINTERLACE_LABEL)) - enabled = 1; - } - return enabled; -} - -void remove_deint_filter(struct MPContext *mpctx) -{ - edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL); -} - -void set_deinterlacing(struct MPContext *mpctx, bool enable) -{ - struct vo_chain *vo_c = mpctx->vo_chain; - if (vf_find_by_label(vo_c->vf, VF_DEINTERLACE_LABEL)) { - if (!enable) - remove_deint_filter(mpctx); - } else { - if ((get_deinterlacing(mpctx) > 0) != enable) { - int arg = enable; - if (video_vf_vo_control(vo_c, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK) - probe_deint_filters(mpctx); - } - } - mpctx->opts->deinterlace = get_deinterlacing(mpctx) > 0; -} - static int mp_property_deinterlace(void *ctx, struct m_property *prop, int action, void *arg) { |