From 74a8fd37025e6dc5804bcb9992a1b8097a1e62f8 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Tue, 9 Feb 2016 06:10:42 -0800 Subject: [PATCH] dxva2: streamline number of surface calculation use hwdec_get_max_refs and put the "4 base work surfaces" into ADDITIONAL_SURFACES macro. --- video/decode/dxva2.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c index 952727d8d4..a81fc54005 100644 --- a/video/decode/dxva2.c +++ b/video/decode/dxva2.c @@ -40,7 +40,7 @@ #include "video/hwdec.h" #include "video/d3d.h" -#define ADDTIONAL_SURFACES HWDEC_DELAY_QUEUE_COUNT +#define ADDITIONAL_SURFACES (4 + HWDEC_DELAY_QUEUE_COUNT) // A minor evil. #ifndef FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO @@ -575,14 +575,7 @@ static int dxva2_create_decoder(struct lavc_ctx *s, int w, int h, else surface_alignment = 16; - /* 4 base work surfaces */ - ctx->num_surfaces = 4 + ADDTIONAL_SURFACES; - - /* add surfaces based on number of possible refs */ - if (codec_id == AV_CODEC_ID_H264 || codec_id == AV_CODEC_ID_HEVC) - ctx->num_surfaces += 16; - else - ctx->num_surfaces += 2; + ctx->num_surfaces = hwdec_get_max_refs(s) + ADDITIONAL_SURFACES; ctx->surfaces = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surfaces)); ctx->surface_infos = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surface_infos));