diff mbox series

[FFmpeg-devel] avcodec/dxva2: don't call GetDesc on a NULL ID3D11VideoDecoderOutputView

Message ID 20220323121621.7615-1-robux4@ycbcr.xyz
State New
Headers show
Series [FFmpeg-devel] avcodec/dxva2: don't call GetDesc on a NULL ID3D11VideoDecoderOutputView | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Steve Lhomme March 23, 2022, 12:16 p.m. UTC
We should return 0 and assert there's something wrong. This is how it's done
with the other DXVA variants.

It fixes bad reference usage in http://www.gbbsoft.pl/!download/!/Film1.mp4
It's using a frame that doesn't have any data[] fields set (yet?).

Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
---
 libavcodec/dxva2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 568d686f39..043497b74f 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -777,7 +777,7 @@  unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
 #if CONFIG_D3D11VA
     if (avctx->pix_fmt == AV_PIX_FMT_D3D11)
         return (intptr_t)frame->data[1];
-    if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
+    if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && surface) {
         D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
         ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, &viewDesc);
         return viewDesc.Texture2D.ArraySlice;