1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

vulkan_decode: add ifdefs around VP9 definitions and privatize profile struct

The struct is not referenced anywhere else.
This commit is contained in:
Lynne
2025-08-08 21:15:56 +09:00
committed by James Almer
parent f7a5128109
commit eb9e000584
2 changed files with 31 additions and 10 deletions

View File

@@ -68,6 +68,19 @@ static const FFVulkanDecodeDescriptor *dec_descs[] = {
#endif
};
typedef struct FFVulkanDecodeProfileData {
VkVideoDecodeH264ProfileInfoKHR h264_profile;
VkVideoDecodeH265ProfileInfoKHR h265_profile;
#if CONFIG_VP9_VULKAN_HWACCEL
VkVideoDecodeVP9ProfileInfoKHR vp9_profile;
#endif
VkVideoDecodeAV1ProfileInfoKHR av1_profile;
VkVideoDecodeUsageInfoKHR usage;
VkVideoProfileInfoKHR profile;
VkVideoProfileListInfoKHR profile_list;
} FFVulkanDecodeProfileData;
static const FFVulkanDecodeDescriptor *get_codecdesc(enum AVCodecID codec_id)
{
for (size_t i = 0; i < FF_ARRAY_ELEMS(dec_descs); i++)
@@ -84,7 +97,9 @@ static const VkVideoProfileInfoKHR *get_video_profile(FFVulkanDecodeShared *ctx,
VkStructureType profile_struct_type =
codec_id == AV_CODEC_ID_H264 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR :
codec_id == AV_CODEC_ID_HEVC ? VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR :
#if CONFIG_VP9_VULKAN_HWACCEL
codec_id == AV_CODEC_ID_VP9 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR :
#endif
codec_id == AV_CODEC_ID_AV1 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR :
VK_STRUCTURE_TYPE_MAX_ENUM;
if (profile_struct_type == VK_STRUCTURE_TYPE_MAX_ENUM)
@@ -694,7 +709,9 @@ static VkResult vulkan_setup_profile(AVCodecContext *avctx,
const FFVulkanDecodeDescriptor *vk_desc,
VkVideoDecodeH264CapabilitiesKHR *h264_caps,
VkVideoDecodeH265CapabilitiesKHR *h265_caps,
#if CONFIG_VP9_VULKAN_HWACCEL
VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
#endif
VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
VkVideoCapabilitiesKHR *caps,
VkVideoDecodeCapabilitiesKHR *dec_caps,
@@ -706,7 +723,9 @@ static VkResult vulkan_setup_profile(AVCodecContext *avctx,
VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->h264_profile;
VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->h265_profile;
#if CONFIG_VP9_VULKAN_HWACCEL
VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
#endif
VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->av1_profile;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
@@ -732,11 +751,13 @@ static VkResult vulkan_setup_profile(AVCodecContext *avctx,
usage->pNext = h265_profile;
h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
h265_profile->stdProfileIdc = cur_profile;
#if CONFIG_VP9_VULKAN_HWACCEL
} else if (avctx->codec_id == AV_CODEC_ID_VP9) {
dec_caps->pNext = vp9_caps;
usage->pNext = vp9_profile;
vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
vp9_profile->stdProfile = cur_profile;
#endif
} else if (avctx->codec_id == AV_CODEC_ID_AV1) {
dec_caps->pNext = av1_caps;
usage->pNext = av1_profile;
@@ -797,9 +818,11 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
VkVideoDecodeH265CapabilitiesKHR h265_caps = {
.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
};
#if CONFIG_VP9_VULKAN_HWACCEL
VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
};
#endif
VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
};
@@ -820,14 +843,18 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
cur_profile = avctx->profile;
base_profile = avctx->codec_id == AV_CODEC_ID_H264 ? AV_PROFILE_H264_CONSTRAINED_BASELINE :
avctx->codec_id == AV_CODEC_ID_H265 ? AV_PROFILE_HEVC_MAIN :
#if CONFIG_VP9_VULKAN_HWACCEL
avctx->codec_id == AV_CODEC_ID_VP9 ? STD_VIDEO_VP9_PROFILE_0 :
#endif
avctx->codec_id == AV_CODEC_ID_AV1 ? STD_VIDEO_AV1_PROFILE_MAIN :
0;
ret = vulkan_setup_profile(avctx, prof, hwctx, vk, vk_desc,
&h264_caps,
&h265_caps,
#if CONFIG_VP9_VULKAN_HWACCEL
&vp9_caps,
#endif
&av1_caps,
caps,
dec_caps,
@@ -844,7 +871,9 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
ret = vulkan_setup_profile(avctx, prof, hwctx, vk, vk_desc,
&h264_caps,
&h265_caps,
#if CONFIG_VP9_VULKAN_HWACCEL
&vp9_caps,
#endif
&av1_caps,
caps,
dec_caps,
@@ -871,7 +900,9 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
max_level = avctx->codec_id == AV_CODEC_ID_H264 ? ff_vk_h264_level_to_av(h264_caps.maxLevelIdc) :
avctx->codec_id == AV_CODEC_ID_H265 ? ff_vk_h265_level_to_av(h265_caps.maxLevelIdc) :
#if CONFIG_VP9_VULKAN_HWACCEL
avctx->codec_id == AV_CODEC_ID_VP9 ? vp9_caps.maxLevel :
#endif
avctx->codec_id == AV_CODEC_ID_AV1 ? av1_caps.maxLevel :
0;

View File

@@ -35,16 +35,6 @@ typedef struct FFVulkanDecodeDescriptor {
VkExtensionProperties ext_props;
} FFVulkanDecodeDescriptor;
typedef struct FFVulkanDecodeProfileData {
VkVideoDecodeH264ProfileInfoKHR h264_profile;
VkVideoDecodeH265ProfileInfoKHR h265_profile;
VkVideoDecodeVP9ProfileInfoKHR vp9_profile;
VkVideoDecodeAV1ProfileInfoKHR av1_profile;
VkVideoDecodeUsageInfoKHR usage;
VkVideoProfileInfoKHR profile;
VkVideoProfileListInfoKHR profile_list;
} FFVulkanDecodeProfileData;
typedef struct FFVulkanDecodeShared {
FFVulkanContext s;
FFVkVideoCommon common;