dxva2: streamline number of surface calculation

use hwdec_get_max_refs and put the "4 base work surfaces" into
ADDITIONAL_SURFACES macro.
This commit is contained in:
Kevin Mitchell 2016-02-09 06:10:42 -08:00
parent e1e052a58e
commit 74a8fd3702
1 changed files with 2 additions and 9 deletions

View File

@ -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));