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], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
227 if (!alloc_dpb || is_current) {
235 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
236 (hwfc->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR));
280 if (!alloc_dpb || is_current) {
298 const uint8_t *
data,
size_t size,
int add_startcode,
299 uint32_t *nb_slices,
const uint32_t **
offsets)
304 static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
305 const size_t startcode_len = add_startcode ?
sizeof(startcode_prefix) : 0;
306 const int nb = nb_slices ? *nb_slices : 0;
312 ctx->caps.minBitstreamBufferSizeAlignment;
313 new_size =
FFALIGN(new_size,
ctx->caps.minBitstreamBufferSizeAlignment);
317 (nb + 1)*
sizeof(slice_off));
327 if (!vkbuf || vkbuf->
size < new_size) {
333 size_t buf_size =
FFMAX(new_size, 1024*1024);
337 buf_size = 2 <<
av_log2(buf_size);
343 void *buf_pnext =
ctx->s.hwfc->create_pnext;
344 if (
ctx->s.hwfc->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
346 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
350 (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
351 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
352 VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
354 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
356 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
374 memcpy(slices + vp->
slices_size, startcode_prefix, startcode_len);
389 VkVideoSessionParametersKHR *empty_session_params)
394 VkVideoDecodeH264SessionParametersCreateInfoKHR h264_params = {
395 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
397 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
398 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
400 StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
401 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
402 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
403 .pStdSequenceHeader = &av1_empty_seq,
405 VkVideoSessionParametersCreateInfoKHR session_params_create = {
406 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
411 .videoSession =
ctx->common.session,
417 ret = vk->CreateVideoSessionParametersKHR(
s->hwctx->act_dev, &session_params_create,
418 s->hwctx->alloc, empty_session_params);
419 if (
ret != VK_SUCCESS) {
420 av_log(avctx,
AV_LOG_ERROR,
"Unable to create empty Vulkan video session parameters: %s!\n",
434 VkVideoBeginCodingInfoKHR decode_start = {
435 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
436 .videoSession =
ctx->common.session,
441 &decode_start.videoSessionParameters);
446 VkVideoCodingControlInfoKHR decode_ctrl = {
447 .sType = VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR,
448 .flags = VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR,
451 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
457 vk->CmdBeginVideoCodingKHR(exec->
buf, &decode_start);
458 vk->CmdControlVideoCodingKHR(exec->
buf, &decode_ctrl);
463 if (decode_start.videoSessionParameters) {
468 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
469 decode_start.videoSessionParameters,
486 VkCommandBuffer cmd_buf;
497 const int layered_dpb =
ctx->common.layered_dpb;
499 VkVideoBeginCodingInfoKHR decode_start = {
500 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
501 .videoSession =
ctx->common.session,
505 .referenceSlotCount = vp->
decode_info.referenceSlotCount,
506 .pReferenceSlots = vp->
decode_info.pReferenceSlots,
509 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
512 VkImageMemoryBarrier2 img_bar[37];
514 size_t data_size =
FFALIGN(vp->slices_size,
515 ctx->caps.minBitstreamBufferSizeAlignment);
520 VkVideoReferenceSlotInfoKHR *cur_vk_ref;
521 cur_vk_ref = (
void *)&decode_start.pReferenceSlots[decode_start.referenceSlotCount];
522 cur_vk_ref[0] = vp->ref_slot;
523 cur_vk_ref[0].slotIndex = -1;
524 decode_start.referenceSlotCount++;
529 if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
530 VkMappedMemoryRange flush_buf = {
531 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
532 .memory = sd_buf->mem,
534 .size =
FFALIGN(vp->slices_size,
535 ctx->s.props.properties.limits.nonCoherentAtomSize),
538 ret = vk->FlushMappedMemoryRanges(
ctx->s.hwctx->act_dev, 1, &flush_buf);
539 if (
ret != VK_SUCCESS) {
546 vp->decode_info.srcBuffer = sd_buf->buf;
547 vp->decode_info.srcBufferOffset = 0;
548 vp->decode_info.srcBufferRange = data_size;
560 vp->slices_buf =
NULL;
568 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
569 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
579 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
580 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
582 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
583 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
584 .srcAccessMask = VK_ACCESS_2_NONE,
585 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
586 .oldLayout = vkf->layout[0],
587 .newLayout = (layered_dpb || vp->dpb_frame) ?
588 VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
589 VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
590 .srcQueueFamilyIndex = vkf->queue_family[0],
591 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
592 .image = vkf->img[0],
593 .subresourceRange = (VkImageSubresourceRange) {
594 .aspectMask = vp->view.aspect[0],
600 &img_bar[nb_img_bar], &nb_img_bar);
605 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
606 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
614 for (
int i = 0;
i < vp->decode_info.referenceSlotCount;
i++) {
620 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
621 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
636 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
637 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
639 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
640 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
641 .srcAccessMask = VK_ACCESS_2_NONE,
642 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR |
643 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
644 .oldLayout = rvkf->
layout[0],
645 .newLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
647 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
648 .image = rvkf->
img[0],
649 .subresourceRange = (VkImageSubresourceRange) {
656 &img_bar[nb_img_bar], &nb_img_bar);
659 }
else if (vp->decode_info.referenceSlotCount ||
660 vp->view.out[0] != vp->view.ref[0]) {
663 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
664 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
670 vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
671 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
672 .dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT,
673 .pImageMemoryBarriers = img_bar,
674 .imageMemoryBarrierCount = nb_img_bar,
678 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
679 vk->CmdDecodeVideoKHR(cmd_buf, &vp->decode_info);
680 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
690 VkSemaphoreWaitInfo
sem_wait = (VkSemaphoreWaitInfo) {
691 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
692 .pSemaphores = &vp->
sem,
734 if (
ctx->sd_ctx_free)
763 if (vk_desc->
queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
766 VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME);
786 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
787 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
788 #
if CONFIG_VP9_VULKAN_HWACCEL
789 VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
791 VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
792 VkVideoCapabilitiesKHR *caps,
793 VkVideoDecodeCapabilitiesKHR *dec_caps,
796 VkVideoDecodeUsageInfoKHR *
usage = &prof->
usage;
798 VkVideoProfileListInfoKHR *profile_list = &prof->
profile_list;
800 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->
h264_profile;
801 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->
h265_profile;
802 #if CONFIG_VP9_VULKAN_HWACCEL
803 VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
805 VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->
av1_profile;
812 dec_caps->pNext = h264_caps;
813 usage->pNext = h264_profile;
814 h264_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;
823 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR :
824 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR;
826 dec_caps->pNext = h265_caps;
827 usage->pNext = h265_profile;
828 h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
829 h265_profile->stdProfileIdc = cur_profile;
830 #if CONFIG_VP9_VULKAN_HWACCEL
832 dec_caps->pNext = vp9_caps;
833 usage->pNext = vp9_profile;
834 vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
835 vp9_profile->stdProfile = cur_profile;
838 dec_caps->pNext = av1_caps;
839 usage->pNext = av1_profile;
840 av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
841 av1_profile->stdProfile = cur_profile;
845 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
846 usage->videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
848 profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
855 profile_list->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;
856 profile_list->profileCount = 1;
857 profile_list->pProfiles =
profile;
860 caps->sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;
861 caps->pNext = dec_caps;
862 dec_caps->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;
865 return vk->GetPhysicalDeviceVideoCapabilitiesKHR(hwctx->
phys_dev,
profile,
875 int max_level, base_profile, cur_profile;
888 VkVideoCapabilitiesKHR *caps = &
ctx->caps;
889 VkVideoDecodeCapabilitiesKHR *dec_caps = &
ctx->dec_caps;
891 VkVideoDecodeH264CapabilitiesKHR h264_caps = {
892 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR,
894 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
895 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
897 #if CONFIG_VP9_VULKAN_HWACCEL
898 VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
899 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
902 VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
903 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
906 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
907 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR,
910 VkVideoFormatPropertiesKHR *ret_info;
911 uint32_t nb_out_fmts = 0;
922 #if CONFIG_VP9_VULKAN_HWACCEL
931 #
if CONFIG_VP9_VULKAN_HWACCEL
938 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR &&
940 avctx->
profile != base_profile) {
942 "again with profile %s\n",
946 cur_profile = base_profile;
950 #
if CONFIG_VP9_VULKAN_HWACCEL
959 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR) {
961 "%s profile \"%s\" not supported!\n",
965 }
else if (
ret == VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR) {
967 "format (%s) not supported!\n",
970 }
else if (
ret == VK_ERROR_FEATURE_NOT_PRESENT ||
971 ret == VK_ERROR_FORMAT_NOT_SUPPORTED) {
973 }
else if (
ret != VK_SUCCESS) {
979 #if CONFIG_VP9_VULKAN_HWACCEL
989 max_level, avctx->
level);
991 caps->minCodedExtent.width, caps->maxCodedExtent.width);
993 caps->minCodedExtent.height, caps->maxCodedExtent.height);
995 caps->pictureAccessGranularity.width);
997 caps->pictureAccessGranularity.height);
999 caps->minBitstreamBufferOffsetAlignment);
1001 caps->minBitstreamBufferSizeAlignment);
1005 caps->maxActiveReferencePictures);
1007 caps->stdHeaderVersion.extensionName,
1009 av_log(avctx,
AV_LOG_VERBOSE,
" Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n",
1010 CODEC_VER(caps->stdHeaderVersion.specVersion),
1013 dec_caps->flags ?
"" :
1015 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR ?
1016 " reuse_dst_dpb" :
"",
1017 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR ?
1018 " dedicated_dpb" :
"");
1022 caps->flags & VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR ?
1024 caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
1025 " separate_references" :
"");
1028 if (avctx->
coded_width < caps->minCodedExtent.width ||
1030 avctx->
coded_width > caps->maxCodedExtent.width ||
1035 avctx->
level > max_level)
1039 if (!(dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1040 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR))) {
1042 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR nor "
1043 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are set!\n");
1045 }
else if ((dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1046 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) ==
1047 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) &&
1048 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR)) {
1049 av_log(avctx,
AV_LOG_ERROR,
"Cannot initialize Vulkan decoding session, buggy driver: "
1050 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
1051 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
1055 dec->
dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
1057 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
1060 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1062 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1063 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
1064 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1065 VK_IMAGE_USAGE_SAMPLED_BIT;
1069 fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1073 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1075 &nb_out_fmts,
NULL);
1076 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1077 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1079 }
else if (
ret != VK_SUCCESS) {
1085 ret_info =
av_mallocz(
sizeof(*ret_info)*nb_out_fmts);
1089 for (
int i = 0;
i < nb_out_fmts;
i++)
1090 ret_info[
i].sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;
1092 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1094 &nb_out_fmts, ret_info);
1095 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1096 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1099 }
else if (
ret != VK_SUCCESS) {
1108 *vk_fmt = best_vkfmt = VK_FORMAT_UNDEFINED;
1111 av_log(avctx,
AV_LOG_DEBUG,
"Choosing best pixel format for decoding from %i:\n", nb_out_fmts);
1112 for (
int i = 0;
i < nb_out_fmts;
i++) {
1120 if (
tmp == best_format)
1121 best_vkfmt = ret_info[
i].format;
1131 av_log(avctx,
AV_LOG_ERROR,
"No valid/compatible pixel format found for decoding!\n");
1139 *vk_fmt = best_vkfmt;
1153 int err, dedicated_dpb;
1176 prof, &dedicated_dpb);
1188 hwfc->create_pnext = &prof->profile_list;
1190 hwfc->format[0] = VK_FORMAT_UNDEFINED;
1215 hwfc->format[3] = VK_FORMAT_R16_UNORM;
1221 hwfc->format[0] = VK_FORMAT_R16_UNORM;
1222 hwfc->format[1] = VK_FORMAT_R16_UNORM;
1223 hwfc->format[2] = VK_FORMAT_R16_UNORM;
1230 if (hwfc->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
1231 hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
1233 hwfc->usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1234 VK_IMAGE_USAGE_STORAGE_BIT |
1235 VK_IMAGE_USAGE_SAMPLED_BIT;
1240 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR;
1241 if (!dec->dedicated_dpb)
1242 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1244 ctx = dec->shared_ctx;
1247 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1257 VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)
data;
1258 vk->DestroyVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, *par,
1259 ctx->s.hwctx->alloc);
1264 const VkVideoSessionParametersCreateInfoKHR *session_params_create)
1266 VkVideoSessionParametersKHR *par =
av_malloc(
sizeof(*par));
1274 ret = vk->CreateVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, session_params_create,
1275 ctx->s.hwctx->alloc, par);
1276 if (
ret != VK_SUCCESS) {
1277 av_log(logctx,
AV_LOG_ERROR,
"Unable to create Vulkan video session parameters: %s!\n",
1310 const VkVideoProfileInfoKHR *
profile;
1313 VkVideoSessionCreateInfoKHR session_create = {
1314 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1346 session_create.queueFamilyIndex =
ctx->qf->idx;
1347 session_create.maxCodedExtent =
ctx->caps.maxCodedExtent;
1348 session_create.maxDpbSlots =
ctx->caps.maxDpbSlots;
1349 session_create.maxActiveReferencePictures =
ctx->caps.maxActiveReferencePictures;
1350 session_create.pictureFormat =
s->hwfc->format[0];
1351 session_create.referencePictureFormat = session_create.pictureFormat;
1352 session_create.pStdHeaderVersion = &vk_desc->
ext_props;
1353 session_create.pVideoProfile =
profile;
1354 #ifdef VK_KHR_video_maintenance2
1356 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1362 async_depth = 2*
ctx->qf->num;
1369 async_depth, 0, 0, 0,
profile);
1385 if (!
ctx->common.dpb_hwfc_ref) {
1398 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
1403 VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
1404 if (drm_create_pnext) {
1406 dpb_hwfc->
tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
1410 dpb_hwfc->
tiling = VK_IMAGE_TILING_OPTIMAL;
1412 dpb_hwfc->
format[0] =
s->hwfc->format[0];
1413 dpb_hwfc->
usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1415 if (
ctx->common.layered_dpb)
1422 if (
ctx->common.layered_dpb) {
1424 if (!
ctx->common.layered_frame) {
1430 &
ctx->common.layered_view,
1431 &
ctx->common.layered_aspect,
1433 s->hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
1449 const VkPhysicalDeviceDriverProperties *driver_props;
1451 if (driver_props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
1452 driver_props->conformanceVersion.major == 1 &&
1453 driver_props->conformanceVersion.minor == 3 &&
1454 driver_props->conformanceVersion.subminor == 8 &&
1455 driver_props->conformanceVersion.patch < 3)