diff mbox series

[FFmpeg-devel,2/3] avcodec/vulkan_decode: check specVersion to avoid using incompatible implementations

Message ID 20230823200600.1480-2-kasper93@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avcodec/vulkan_decode: fix struct type for h265_profile | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Kacper Michajłow Aug. 23, 2023, 8:05 p.m. UTC
Fixes:
VUID-VkVideoSessionCreateInfoKHR-pStdHeaderVersion-07190
VUID-VkVideoSessionCreateInfoKHR-pStdHeaderVersion-07191

As a bonus avoids crashing AMD video driver on Windows, which currently
doesn't advertise support.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
 libavcodec/vulkan_decode.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 04350578f9..7607edf52e 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -881,6 +881,11 @@  static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
            caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
                " separate_references" : "");
 
+    if (dec_ext[avctx->codec_id]->specVersion > caps->stdHeaderVersion.specVersion ||
+        strncmp(caps->stdHeaderVersion.extensionName,
+                dec_ext[avctx->codec_id]->extensionName, VK_MAX_EXTENSION_NAME_SIZE))
+        return AVERROR(EINVAL);
+
     /* Check if decoding is possible with the given parameters */
     if (avctx->width  < caps->minCodedExtent.width   ||
         avctx->height < caps->minCodedExtent.height  ||