diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.c index 47e372377e..d31e06be0e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.c @@ -323,3 +323,45 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile, #endif return TRUE; } + +/** + * gst_vulkan_video_profile_is_valid: (skip) + * @profile: the output profile + * @codec: VkVideoCodecOperationFlagBitsKHR described by @profile + * + * Returns: %TRUE if @profile is correct and matches with @codec + * + * Since: 1.24 + */ +gboolean +gst_vulkan_video_profile_is_valid (GstVulkanVideoProfile * profile, guint codec) +{ +#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS + int i; + VkVideoCodecOperationFlagBitsKHR op = codec; + VkStructureType stype = VK_STRUCTURE_TYPE_MAX_ENUM; + + if (op == VK_VIDEO_CODEC_OPERATION_NONE_KHR) + return FALSE; + + if (profile->profile.videoCodecOperation != op) + return FALSE; + + for (i = 0; i < G_N_ELEMENTS (video_codecs_map); i++) { + if (op == video_codecs_map[i].codec) { + stype = video_codecs_map[i].stype; + break; + } + } + + if (stype == VK_STRUCTURE_TYPE_MAX_ENUM) + return FALSE; + + if (profile->codec.base.sType != stype) + return FALSE; + + return TRUE; + +#endif + return FALSE; +} diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.h b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.h index 1bee84f34a..ade31e3769 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkvideoutils.h @@ -21,7 +21,7 @@ #pragma once #include -#include +#include G_BEGIN_DECLS @@ -39,6 +39,7 @@ struct _GstVulkanVideoProfile VkVideoProfileInfoKHR profile; VkVideoDecodeUsageInfoKHR usage; union { + VkBaseInStructure base; VkVideoDecodeH264ProfileInfoKHR h264; VkVideoDecodeH265ProfileInfoKHR h265; } codec; @@ -51,5 +52,8 @@ GstCaps * gst_vulkan_video_profile_to_caps (const GstVulkan GST_VULKAN_API gboolean gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile, GstCaps * caps); +GST_VULKAN_API +gboolean gst_vulkan_video_profile_is_valid (GstVulkanVideoProfile * profile, + guint codec); G_END_DECLS