22 #include "config_components.h"
27 #define DECODER_IS_SDR(codec_id) \
28 (((codec_id) == AV_CODEC_ID_FFV1) || \
29 ((codec_id) == AV_CODEC_ID_DPX) || \
30 ((codec_id) == AV_CODEC_ID_PRORES_RAW) || \
31 ((codec_id) == AV_CODEC_ID_PRORES))
33 #if CONFIG_H264_VULKAN_HWACCEL
36 #if CONFIG_HEVC_VULKAN_HWACCEL
39 #if CONFIG_VP9_VULKAN_HWACCEL
42 #if CONFIG_AV1_VULKAN_HWACCEL
45 #if CONFIG_FFV1_VULKAN_HWACCEL
48 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
51 #if CONFIG_PRORES_VULKAN_HWACCEL
54 #if CONFIG_DPX_VULKAN_HWACCEL
59 #if CONFIG_H264_VULKAN_HWACCEL
62 #if CONFIG_HEVC_VULKAN_HWACCEL
65 #if CONFIG_VP9_VULKAN_HWACCEL
68 #if CONFIG_AV1_VULKAN_HWACCEL
71 #if CONFIG_FFV1_VULKAN_HWACCEL
74 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
77 #if CONFIG_PRORES_VULKAN_HWACCEL
80 #if CONFIG_DPX_VULKAN_HWACCEL
88 #if CONFIG_VP9_VULKAN_HWACCEL
89 VkVideoDecodeVP9ProfileInfoKHR vp9_profile;
93 VkVideoDecodeUsageInfoKHR
usage;
109 const VkVideoProfileListInfoKHR *profile_list;
111 VkStructureType profile_struct_type =
114 #if CONFIG_VP9_VULKAN_HWACCEL
118 VK_STRUCTURE_TYPE_MAX_ENUM;
119 if (profile_struct_type == VK_STRUCTURE_TYPE_MAX_ENUM)
123 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
127 for (
int i = 0;
i < profile_list->profileCount;
i++)
129 return &profile_list->pProfiles[
i];
180 vkpic->
view.
ref[
i] = VK_NULL_HANDLE;
181 vkpic->
view.
out[
i] = VK_NULL_HANDLE;
182 vkpic->
view.
dst[
i] = VK_NULL_HANDLE;
206 if (
ctx->common.layered_dpb && alloc_dpb) {
207 vkpic->
view.
ref[0] =
ctx->common.layered_view;
209 }
else if (alloc_dpb) {
220 dpb_hwfc->format[0], !is_current);
227 if (!alloc_dpb || is_current) {
234 hwfc->format[0], !is_current);
277 if (!alloc_dpb || is_current) {
295 const uint8_t *
data,
size_t size,
int add_startcode,
296 uint32_t *nb_slices,
const uint32_t **
offsets)
301 static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
302 const size_t startcode_len = add_startcode ?
sizeof(startcode_prefix) : 0;
303 const int nb = nb_slices ? *nb_slices : 0;
309 ctx->caps.minBitstreamBufferSizeAlignment;
310 new_size =
FFALIGN(new_size,
ctx->caps.minBitstreamBufferSizeAlignment);
314 (nb + 1)*
sizeof(slice_off));
324 if (!vkbuf || vkbuf->
size < new_size) {
330 size_t buf_size =
FFMAX(new_size, 1024*1024);
334 buf_size = 2 <<
av_log2(buf_size);
338 (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
339 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
340 VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
341 ctx->s.hwfc->create_pnext, buf_size,
342 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
344 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
362 memcpy(slices + vp->
slices_size, startcode_prefix, startcode_len);
381 VkVideoBeginCodingInfoKHR decode_start = {
382 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
383 .videoSession =
ctx->common.session,
384 .videoSessionParameters =
ctx->empty_session_params,
386 VkVideoCodingControlInfoKHR decode_ctrl = {
387 .sType = VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR,
388 .
flags = VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR,
391 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
394 VkCommandBuffer cmd_buf;
405 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
406 vk->CmdControlVideoCodingKHR(cmd_buf, &decode_ctrl);
407 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
417 VkCommandBuffer cmd_buf;
428 const int layered_dpb =
ctx->common.layered_dpb;
430 VkVideoBeginCodingInfoKHR decode_start = {
431 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
432 .videoSession =
ctx->common.session,
436 .referenceSlotCount = vp->
decode_info.referenceSlotCount,
437 .pReferenceSlots = vp->
decode_info.pReferenceSlots,
440 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
443 VkImageMemoryBarrier2 img_bar[37];
445 size_t data_size =
FFALIGN(vp->slices_size,
446 ctx->caps.minBitstreamBufferSizeAlignment);
451 VkVideoReferenceSlotInfoKHR *cur_vk_ref;
452 cur_vk_ref = (
void *)&decode_start.pReferenceSlots[decode_start.referenceSlotCount];
453 cur_vk_ref[0] = vp->ref_slot;
454 cur_vk_ref[0].slotIndex = -1;
455 decode_start.referenceSlotCount++;
460 if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
461 VkMappedMemoryRange flush_buf = {
462 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
463 .memory = sd_buf->mem,
465 .size =
FFALIGN(vp->slices_size,
466 ctx->s.props.properties.limits.nonCoherentAtomSize),
469 ret = vk->FlushMappedMemoryRanges(
ctx->s.hwctx->act_dev, 1, &flush_buf);
470 if (
ret != VK_SUCCESS) {
477 vp->decode_info.srcBuffer = sd_buf->buf;
478 vp->decode_info.srcBufferOffset = 0;
479 vp->decode_info.srcBufferRange = data_size;
491 vp->slices_buf =
NULL;
499 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
500 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
510 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
511 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
513 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
514 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
515 .srcAccessMask = VK_ACCESS_2_NONE,
516 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
517 .oldLayout = vkf->layout[0],
518 .newLayout = (layered_dpb || vp->dpb_frame) ?
519 VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
520 VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
521 .srcQueueFamilyIndex = vkf->queue_family[0],
522 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
523 .image = vkf->img[0],
524 .subresourceRange = (VkImageSubresourceRange) {
525 .aspectMask = vp->view.aspect[0],
531 &img_bar[nb_img_bar], &nb_img_bar);
536 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
537 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
545 for (
int i = 0;
i < vp->decode_info.referenceSlotCount;
i++) {
551 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
552 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
567 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
568 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
570 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
571 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
572 .srcAccessMask = VK_ACCESS_2_NONE,
573 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR |
574 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
575 .oldLayout = rvkf->
layout[0],
576 .newLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
578 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
579 .image = rvkf->
img[0],
580 .subresourceRange = (VkImageSubresourceRange) {
587 &img_bar[nb_img_bar], &nb_img_bar);
590 }
else if (vp->decode_info.referenceSlotCount ||
591 vp->view.out[0] != vp->view.ref[0]) {
594 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
595 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
601 vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
602 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
603 .dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT,
604 .pImageMemoryBarriers = img_bar,
605 .imageMemoryBarrierCount = nb_img_bar,
609 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
610 vk->CmdDecodeVideoKHR(cmd_buf, &vp->decode_info);
611 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
621 VkSemaphoreWaitInfo
sem_wait = (VkSemaphoreWaitInfo) {
622 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
623 .pSemaphores = &vp->
sem,
663 if (
ctx->empty_session_params)
664 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
665 ctx->empty_session_params,
672 if (
ctx->sd_ctx_free)
701 if (vk_desc->
queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
704 VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME);
724 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
725 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
726 #
if CONFIG_VP9_VULKAN_HWACCEL
727 VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
729 VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
730 VkVideoCapabilitiesKHR *caps,
731 VkVideoDecodeCapabilitiesKHR *dec_caps,
734 VkVideoDecodeUsageInfoKHR *
usage = &prof->
usage;
736 VkVideoProfileListInfoKHR *profile_list = &prof->
profile_list;
738 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->
h264_profile;
739 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->
h265_profile;
740 #if CONFIG_VP9_VULKAN_HWACCEL
741 VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
743 VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->
av1_profile;
750 dec_caps->pNext = h264_caps;
751 usage->pNext = h264_profile;
752 h264_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;
761 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR :
762 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR;
764 dec_caps->pNext = h265_caps;
765 usage->pNext = h265_profile;
766 h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
767 h265_profile->stdProfileIdc = cur_profile;
768 #if CONFIG_VP9_VULKAN_HWACCEL
770 dec_caps->pNext = vp9_caps;
771 usage->pNext = vp9_profile;
772 vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
773 vp9_profile->stdProfile = cur_profile;
776 dec_caps->pNext = av1_caps;
777 usage->pNext = av1_profile;
778 av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
779 av1_profile->stdProfile = cur_profile;
783 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
784 usage->videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
786 profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
793 profile_list->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;
794 profile_list->profileCount = 1;
795 profile_list->pProfiles =
profile;
798 caps->sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;
799 caps->pNext = dec_caps;
800 dec_caps->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;
803 return vk->GetPhysicalDeviceVideoCapabilitiesKHR(hwctx->
phys_dev,
profile,
813 int max_level, base_profile, cur_profile;
826 VkVideoCapabilitiesKHR *caps = &
ctx->caps;
827 VkVideoDecodeCapabilitiesKHR *dec_caps = &
ctx->dec_caps;
829 VkVideoDecodeH264CapabilitiesKHR h264_caps = {
830 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR,
832 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
833 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
835 #if CONFIG_VP9_VULKAN_HWACCEL
836 VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
837 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
840 VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
841 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
844 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
845 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR,
848 VkVideoFormatPropertiesKHR *ret_info;
849 uint32_t nb_out_fmts = 0;
860 #if CONFIG_VP9_VULKAN_HWACCEL
869 #
if CONFIG_VP9_VULKAN_HWACCEL
876 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR &&
878 avctx->
profile != base_profile) {
880 "again with profile %s\n",
884 cur_profile = base_profile;
888 #
if CONFIG_VP9_VULKAN_HWACCEL
897 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR) {
899 "%s profile \"%s\" not supported!\n",
903 }
else if (
ret == VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR) {
905 "format (%s) not supported!\n",
908 }
else if (
ret == VK_ERROR_FEATURE_NOT_PRESENT ||
909 ret == VK_ERROR_FORMAT_NOT_SUPPORTED) {
911 }
else if (
ret != VK_SUCCESS) {
917 #if CONFIG_VP9_VULKAN_HWACCEL
927 max_level, avctx->
level);
929 caps->minCodedExtent.width, caps->maxCodedExtent.width);
931 caps->minCodedExtent.height, caps->maxCodedExtent.height);
933 caps->pictureAccessGranularity.width);
935 caps->pictureAccessGranularity.height);
937 caps->minBitstreamBufferOffsetAlignment);
939 caps->minBitstreamBufferSizeAlignment);
943 caps->maxActiveReferencePictures);
945 caps->stdHeaderVersion.extensionName,
947 av_log(avctx,
AV_LOG_VERBOSE,
" Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n",
948 CODEC_VER(caps->stdHeaderVersion.specVersion),
951 dec_caps->flags ?
"" :
953 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR ?
954 " reuse_dst_dpb" :
"",
955 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR ?
956 " dedicated_dpb" :
"");
960 caps->flags & VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR ?
962 caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
963 " separate_references" :
"");
966 if (avctx->
coded_width < caps->minCodedExtent.width ||
973 avctx->
level > max_level)
977 if (!(dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
978 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR))) {
980 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR nor "
981 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are set!\n");
983 }
else if ((dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
984 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) ==
985 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) &&
986 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR)) {
987 av_log(avctx,
AV_LOG_ERROR,
"Cannot initialize Vulkan decoding session, buggy driver: "
988 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
989 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
993 dec->
dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
995 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
998 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1000 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1001 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
1002 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1003 VK_IMAGE_USAGE_SAMPLED_BIT;
1007 fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1011 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1013 &nb_out_fmts,
NULL);
1014 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1015 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1017 }
else if (
ret != VK_SUCCESS) {
1023 ret_info =
av_mallocz(
sizeof(*ret_info)*nb_out_fmts);
1027 for (
int i = 0;
i < nb_out_fmts;
i++)
1028 ret_info[
i].sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;
1030 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1032 &nb_out_fmts, ret_info);
1033 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1034 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1037 }
else if (
ret != VK_SUCCESS) {
1046 *vk_fmt = best_vkfmt = VK_FORMAT_UNDEFINED;
1049 av_log(avctx,
AV_LOG_DEBUG,
"Choosing best pixel format for decoding from %i:\n", nb_out_fmts);
1050 for (
int i = 0;
i < nb_out_fmts;
i++) {
1058 if (
tmp == best_format)
1059 best_vkfmt = ret_info[
i].format;
1069 av_log(avctx,
AV_LOG_ERROR,
"No valid/compatible pixel format found for decoding!\n");
1077 *vk_fmt = best_vkfmt;
1091 VkFormat vkfmt = VK_FORMAT_UNDEFINED;
1092 int err, dedicated_dpb;
1111 prof, &dedicated_dpb);
1120 hwfc->create_pnext = &prof->profile_list;
1154 hwfc->format[0] = vkfmt;
1155 hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
1156 hwfc->usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1157 VK_IMAGE_USAGE_STORAGE_BIT |
1158 VK_IMAGE_USAGE_SAMPLED_BIT;
1163 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR;
1164 if (!dec->dedicated_dpb)
1165 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1167 ctx = dec->shared_ctx;
1170 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1180 VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)
data;
1181 vk->DestroyVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, *par,
1182 ctx->s.hwctx->alloc);
1187 const VkVideoSessionParametersCreateInfoKHR *session_params_create)
1189 VkVideoSessionParametersKHR *par =
av_malloc(
sizeof(*par));
1197 ret = vk->CreateVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, session_params_create,
1198 ctx->s.hwctx->alloc, par);
1199 if (
ret != VK_SUCCESS) {
1200 av_log(logctx,
AV_LOG_ERROR,
"Unable to create Vulkan video session parameters: %s!\n",
1233 VkVideoDecodeH264SessionParametersCreateInfoKHR h264_params = {
1234 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
1236 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
1237 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
1239 StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
1240 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
1241 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
1242 .pStdSequenceHeader = &av1_empty_seq,
1244 VkVideoSessionParametersCreateInfoKHR session_params_create = {
1245 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
1250 .videoSession =
ctx->common.session,
1256 ret = vk->CreateVideoSessionParametersKHR(
s->hwctx->act_dev, &session_params_create,
1257 s->hwctx->alloc, &
ctx->empty_session_params);
1258 if (
ret != VK_SUCCESS) {
1259 av_log(avctx,
AV_LOG_ERROR,
"Unable to create empty Vulkan video session parameters: %s!\n",
1274 const VkVideoProfileInfoKHR *
profile;
1276 const VkPhysicalDeviceDriverProperties *driver_props;
1278 VkVideoSessionCreateInfoKHR session_create = {
1279 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1311 session_create.queueFamilyIndex =
ctx->qf->idx;
1312 session_create.maxCodedExtent =
ctx->caps.maxCodedExtent;
1313 session_create.maxDpbSlots =
ctx->caps.maxDpbSlots;
1314 session_create.maxActiveReferencePictures =
ctx->caps.maxActiveReferencePictures;
1315 session_create.pictureFormat =
s->hwfc->format[0];
1316 session_create.referencePictureFormat = session_create.pictureFormat;
1317 session_create.pStdHeaderVersion = &vk_desc->
ext_props;
1318 session_create.pVideoProfile =
profile;
1319 #ifdef VK_KHR_video_maintenance2
1321 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1327 async_depth = 2*
ctx->qf->num;
1334 async_depth, 0, 0, 0,
profile);
1350 if (!
ctx->common.dpb_hwfc_ref) {
1363 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
1364 dpb_hwfc->
format[0] =
s->hwfc->format[0];
1365 dpb_hwfc->
tiling = VK_IMAGE_TILING_OPTIMAL;
1366 dpb_hwfc->
usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1367 VK_IMAGE_USAGE_SAMPLED_BIT;
1369 if (
ctx->common.layered_dpb)
1376 if (
ctx->common.layered_dpb) {
1378 if (!
ctx->common.layered_frame) {
1384 &
ctx->common.layered_view,
1385 &
ctx->common.layered_aspect,
1387 s->hwfc->format[0], 1);
1406 if (driver_props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
1407 driver_props->conformanceVersion.major == 1 &&
1408 driver_props->conformanceVersion.minor == 3 &&
1409 driver_props->conformanceVersion.subminor == 8 &&
1410 driver_props->conformanceVersion.patch < 3)