The slice index expected by D3D11VA is the one from the texture not from the
array or texture/slices.

In VLC the slices we provide the decoder don't start from 0 and thus pictures
appear in bogus order. With possible crashes and corruptions when using an
invalid index.
---
 libavcodec/dxva2.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 9157094..c8982dc 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -43,7 +43,16 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext 
*avctx,
 
     for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++)
         if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface)
+#if CONFIG_D3D11VA
+        {
+            ID3D11VideoDecoderOutputView *pOut = DXVA_CONTEXT_SURFACE(avctx, 
ctx, i);
+            D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
+            ID3D11VideoDecoderOutputView_GetDesc( pOut, &viewDesc );
+            return viewDesc.Texture2D.ArraySlice;
+        }
+#elif CONFIG_DXVA2
             return i;
+#endif
 
     assert(0);
     return 0;
-- 
2.8.2

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to