summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-02-09 06:10:42 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-02-14 11:01:12 -0800
commit74a8fd37025e6dc5804bcb9992a1b8097a1e62f8 (patch)
tree007e7f6a9b5d972724e0d341fff0f49f40cf9dfd
parente1e052a58eb3c3cb201e9d4ef24e7fe7bfd46687 (diff)
downloadmpv-74a8fd37025e6dc5804bcb9992a1b8097a1e62f8.tar.bz2
mpv-74a8fd37025e6dc5804bcb9992a1b8097a1e62f8.tar.xz
dxva2: streamline number of surface calculation
use hwdec_get_max_refs and put the "4 base work surfaces" into ADDITIONAL_SURFACES macro.
-rw-r--r--video/decode/dxva2.c11
1 files 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));