From 8a74638dc743007f6d5d6bb3a672167fce353480 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 23 Apr 2014 01:17:28 +0200 Subject: video: add a "hwdec" property to enable or disable hw decoding at runtime --- video/decode/lavc.h | 1 + video/decode/vd.h | 1 + video/decode/vd_lavc.c | 9 +++++++++ 3 files changed, 11 insertions(+) (limited to 'video') diff --git a/video/decode/lavc.h b/video/decode/lavc.h index 16d3251725..d67292c4fd 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -26,6 +26,7 @@ typedef struct lavc_ctx { AVCodecContext *avctx; AVFrame *pic; struct vd_lavc_hwdec *hwdec; + int selected_hwdec; enum AVPixelFormat pix_fmt; int best_csp; enum AVDiscard skip_frame; diff --git a/video/decode/vd.h b/video/decode/vd.h index 35c2739aa8..28ace3cc04 100644 --- a/video/decode/vd.h +++ b/video/decode/vd.h @@ -45,6 +45,7 @@ enum vd_ctrl { VDCTRL_RESET = 1, // reset decode state after seeking VDCTRL_QUERY_UNSEEN_FRAMES, // current decoder lag VDCTRL_FORCE_HWDEC_FALLBACK, // force software decoding fallback + VDCTRL_GET_HWDEC, }; #endif /* MPLAYER_VD_H */ diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 4935913d73..57b391a6a2 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -225,6 +225,8 @@ static int init(struct dec_video *vd, const char *decoder) ctx->log = vd->log; ctx->opts = vd->opts; + ctx->selected_hwdec = vd->opts->hwdec_api; + if (bstr_endswith0(bstr0(decoder), "_vdpau")) { MP_WARN(vd, "VDPAU decoder '%s' was requested. " "This way of enabling hardware\ndecoding is not supported " @@ -646,6 +648,13 @@ static int control(struct dec_video *vd, int cmd, void *arg) delay += avctx->thread_count - 1; *(int *)arg = delay; return CONTROL_TRUE; + case VDCTRL_GET_HWDEC: { + int hwdec = ctx->selected_hwdec; + if (!ctx->software_fallback_decoder) + hwdec = 0; + *(int *)arg = hwdec; + return CONTROL_TRUE; + } case VDCTRL_FORCE_HWDEC_FALLBACK: return force_fallback(vd); } -- cgit v1.2.3