From eb8957cea110a9aa652894d8bb897a9b1ff91e0b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Dec 2017 21:05:54 +0100 Subject: vd_lavc: rewrite how --hwdec is handled Change it from explicit metadata about every hwaccel method to trying to get it from libavcodec. As shown by add_all_hwdec_methods(), this is a quite bumpy road, and a bit worse than expected. This will probably cause a bunch of regressions. In particular I didn't check all the strange decoder wrappers, which all cause some sort of special cases each. You're volunteering for beta testing by using this commit. One interesting thing is that we completely get rid of mp_hwdec_ctx in vd_lavc.c, and that HWDEC_* mostly goes away (some filters still use it, and the VO hwdec interops still have a lot of code to set it up, so it's not going away completely for now). --- player/command.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 9017278286..9c0dd31f28 100644 --- a/player/command.c +++ b/player/command.c @@ -2419,24 +2419,22 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop, struct MPOpts *opts = mpctx->opts; if (action == M_PROPERTY_SET) { - int new = *(int *)arg; + char *new = *(char **)arg; - if (opts->hwdec_api == new) + if (strcmp(opts->hwdec_api, new) == 0) return M_PROPERTY_OK; - opts->hwdec_api = new; + talloc_free(opts->hwdec_api); + opts->hwdec_api = talloc_strdup(NULL, new); if (!vd) return M_PROPERTY_OK; - int current = -2; - video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t); - if (current != opts->hwdec_api) { - video_vd_control(vd, VDCTRL_REINIT, NULL); - double last_pts = mpctx->last_vo_pts; - if (last_pts != MP_NOPTS_VALUE) - queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0); - } + video_vd_control(vd, VDCTRL_REINIT, NULL); + double last_pts = mpctx->last_vo_pts; + if (last_pts != MP_NOPTS_VALUE) + queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0); + return M_PROPERTY_OK; } return mp_property_generic_option(mpctx, prop, action, arg); @@ -2452,20 +2450,11 @@ static int mp_property_hwdec_current(void *ctx, struct m_property *prop, if (!vd) return M_PROPERTY_UNAVAILABLE; - switch (action) { - case M_PROPERTY_GET_TYPE: { - // Abuse another hwdec option to resolve the value names - struct m_property dummy = {.name = "hwdec"}; - return mp_property_generic_option(mpctx, &dummy, action, arg); - } - case M_PROPERTY_GET: { - int current = HWDEC_NONE; - video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t); - *(int *)arg = current; - return M_PROPERTY_OK; - } - } - return M_PROPERTY_NOT_IMPLEMENTED; + char *current = NULL; + video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t); + if (!current) + current = "no"; + return m_property_strdup_ro(action, arg, current); } static int mp_property_hwdec_interop(void *ctx, struct m_property *prop, -- cgit v1.2.3