From 5258c012febdfba0ef56ad8ce6f7cb003611c47b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 11 Apr 2015 17:17:52 +0200 Subject: vda: add support for nv12 image formats The hardware always decodes to nv12 so using this image format causes less cpu usage than uyvy (which we are currently using, since Apple examples and other free software use that). The reduction in cpu usage can add up to quite a bit, especially for 4k or high fps video. This needs an accompaning commit in libavcodec. --- video/decode/vda.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'video/decode') diff --git a/video/decode/vda.c b/video/decode/vda.c index 6e54479c98..cc2c7b0795 100644 --- a/video/decode/vda.c +++ b/video/decode/vda.c @@ -31,7 +31,8 @@ static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info, const char *decoder) { hwdec_request_api(info, "vda"); - + if (!info || !info->hwctx) + return HWDEC_ERR_NO_CTX; if (mp_codec_to_av_codec_id(decoder) != AV_CODEC_ID_H264) return HWDEC_ERR_NO_CODEC; return 0; @@ -76,7 +77,14 @@ static void print_vda_error(struct mp_log *log, int lev, char *message, static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h) { av_vda_default_free(ctx->avctx); +#if HAVE_VDA_DEFAULT_INIT2 + AVVDAContext *vdactx = av_vda_alloc_context(); + vdactx->cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + int err = av_vda_default_init2(ctx->avctx, vdactx); +#else int err = av_vda_default_init(ctx->avctx); +#endif + if (err < 0) { print_vda_error(ctx->log, MSGL_ERR, "failed to init VDA decoder", err); return -1; -- cgit v1.2.3