vulkan: decoder: create union for profile usage

As a profile can include a VkVideoDecodeUsageInfoKHR
or VkVideoEncodeUsageInfoKHR, use union to separate the both.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5701>
This commit is contained in:
Stéphane Cerveau 2023-10-30 16:40:47 +01:00 committed by GStreamer Marge Bot
parent 7f14bfe8b8
commit 476c7efcb7
5 changed files with 13 additions and 10 deletions

View file

@ -540,7 +540,7 @@ gst_vulkan_video_profile_from_h264_sps (GstVulkanVideoProfile * profile,
.lumaBitDepth = _get_component_bit_depth (sps->bit_depth_luma_minus8 + 8), .lumaBitDepth = _get_component_bit_depth (sps->bit_depth_luma_minus8 + 8),
.chromaBitDepth = _get_component_bit_depth (sps->bit_depth_chroma_minus8 + 8), .chromaBitDepth = _get_component_bit_depth (sps->bit_depth_chroma_minus8 + 8),
}, },
.usage = { .usage.decode = {
.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR, .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR,
.videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR, .videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR,
.pNext = &profile->codec, .pNext = &profile->codec,

View file

@ -183,8 +183,8 @@ gst_vulkan_decoder_start (GstVulkanDecoder * self,
} }
self->profile = *profile; self->profile = *profile;
self->profile.profile.pNext = &self->profile.usage; self->profile.profile.pNext = &self->profile.usage.decode;
self->profile.usage.pNext = &self->profile.codec; self->profile.usage.decode.pNext = &self->profile.codec;
switch (self->codec) { switch (self->codec) {
case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR: case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR:

View file

@ -224,8 +224,8 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
profile->usage.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR; profile->usage.decode.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
profile->usage.videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR; profile->usage.decode.videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
profile->profile.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR; profile->profile.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
profile->profile.pNext = &profile->usage; profile->profile.pNext = &profile->usage;
@ -245,7 +245,7 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
STD_VIDEO_H264_PROFILE_IDC_INVALID; STD_VIDEO_H264_PROFILE_IDC_INVALID;
profile->codec.h264dec.pictureLayout = profile->codec.h264dec.pictureLayout =
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_KHR; VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_KHR;
profile->usage.pNext = &profile->codec; profile->usage.decode.pNext = &profile->codec;
profile_str = gst_structure_get_string (structure, "profile"); profile_str = gst_structure_get_string (structure, "profile");
for (j = 0; profile_str && j < G_N_ELEMENTS (h264_profile_map); j++) { for (j = 0; profile_str && j < G_N_ELEMENTS (h264_profile_map); j++) {
@ -270,7 +270,7 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
profile->codec.h265dec.sType = video_codecs_map[i].stype; profile->codec.h265dec.sType = video_codecs_map[i].stype;
profile->codec.h265dec.stdProfileIdc = profile->codec.h265dec.stdProfileIdc =
STD_VIDEO_H265_PROFILE_IDC_INVALID; STD_VIDEO_H265_PROFILE_IDC_INVALID;
profile->usage.pNext = &profile->codec; profile->usage.decode.pNext = &profile->codec;
profile_str = gst_structure_get_string (structure, "profile"); profile_str = gst_structure_get_string (structure, "profile");
for (j = 0; profile_str && j < G_N_ELEMENTS (h265_profile_map); j++) { for (j = 0; profile_str && j < G_N_ELEMENTS (h265_profile_map); j++) {
@ -283,7 +283,7 @@ gst_vulkan_video_profile_from_caps (GstVulkanVideoProfile * profile,
break; break;
} }
default: default:
profile->usage.pNext = NULL; profile->usage.decode.pNext = NULL;
break; break;
} }

View file

@ -37,7 +37,10 @@ struct _GstVulkanVideoProfile
/*< private >*/ /*< private >*/
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS #if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
VkVideoProfileInfoKHR profile; VkVideoProfileInfoKHR profile;
VkVideoDecodeUsageInfoKHR usage; union {
VkVideoDecodeUsageInfoKHR decode;
} usage;
union { union {
VkBaseInStructure base; VkBaseInStructure base;
VkVideoDecodeH264ProfileInfoKHR h264dec; VkVideoDecodeH264ProfileInfoKHR h264dec;

View file

@ -226,7 +226,7 @@ GST_START_TEST (test_decoder)
.chromaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR, .chromaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR,
.lumaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR, .lumaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR,
}, },
.usage = { .usage.decode = {
.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR, .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR,
.videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR, .videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR,
.pNext = &profile.codec, .pNext = &profile.codec,