d3d11va: Use the proper decoding slice index

The decoding buffer index expected by D3D11VA is the one from the
ID3D11Texture2D not the one from the ID3D11VideoDecoderOutputView array
in AVD3D11VAContext.

Otherwise, when providing decoder slices that do not start from 0,
pictures appear in bogus order. For an invalid index crashes and
image corruption can occur.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
Steve Lhomme 2016-10-05 12:52:00 +02:00 committed by Diego Biurrun
parent 715f139c9b
commit be630b1e08
3 changed files with 11 additions and 5 deletions

View File

@ -42,8 +42,17 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
unsigned i; unsigned i;
for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++)
if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface) #if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) {
D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], &viewDesc);
return viewDesc.Texture2D.ArraySlice;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface)
return i; return i;
#endif
assert(0); assert(0);
return 0; return 0;

View File

@ -69,7 +69,6 @@ typedef union {
#if CONFIG_D3D11VA && CONFIG_DXVA2 #if CONFIG_D3D11VA && CONFIG_DXVA2
#define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround) #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround)
#define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count) #define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i])
#define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder) #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder)
#define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id)) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? &ctx->d3d11va.report_id : &ctx->dxva2.report_id))
#define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg) #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg)
@ -79,7 +78,6 @@ typedef union {
#elif CONFIG_DXVA2 #elif CONFIG_DXVA2
#define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
#define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count)
#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->dxva2.surface[i])
#define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder) #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->dxva2.decoder)
#define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id)) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->dxva2.report_id))
#define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg) #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->dxva2.cfg)
@ -89,7 +87,6 @@ typedef union {
#elif CONFIG_D3D11VA #elif CONFIG_D3D11VA
#define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
#define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count)
#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->d3d11va.surface[i])
#define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder) #define DXVA_CONTEXT_DECODER(avctx, ctx) (ctx->d3d11va.decoder)
#define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id)) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(&ctx->d3d11va.report_id))
#define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg) #define DXVA_CONTEXT_CFG(avctx, ctx) (ctx->d3d11va.cfg)

View File

@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 27 #define LIBAVCODEC_VERSION_MINOR 27
#define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_MICRO 2
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \