23 #include "config_components.h"
28 #define DECODER_IS_SDR(codec_id) \
29 (((codec_id) == AV_CODEC_ID_FFV1) || \
30 ((codec_id) == AV_CODEC_ID_DPX) || \
31 ((codec_id) == AV_CODEC_ID_PRORES_RAW) || \
32 ((codec_id) == AV_CODEC_ID_PRORES))
34 #if CONFIG_H264_VULKAN_HWACCEL
37 #if CONFIG_HEVC_VULKAN_HWACCEL
40 #if CONFIG_VP9_VULKAN_HWACCEL
43 #if CONFIG_AV1_VULKAN_HWACCEL
46 #if CONFIG_FFV1_VULKAN_HWACCEL
49 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
52 #if CONFIG_PRORES_VULKAN_HWACCEL
55 #if CONFIG_DPX_VULKAN_HWACCEL
60 #if CONFIG_H264_VULKAN_HWACCEL
63 #if CONFIG_HEVC_VULKAN_HWACCEL
66 #if CONFIG_VP9_VULKAN_HWACCEL
69 #if CONFIG_AV1_VULKAN_HWACCEL
72 #if CONFIG_FFV1_VULKAN_HWACCEL
75 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
78 #if CONFIG_PRORES_VULKAN_HWACCEL
81 #if CONFIG_DPX_VULKAN_HWACCEL
89 #if CONFIG_VP9_VULKAN_HWACCEL
90 VkVideoDecodeVP9ProfileInfoKHR vp9_profile;
94 VkVideoDecodeUsageInfoKHR
usage;
110 const VkVideoProfileListInfoKHR *profile_list;
112 VkStructureType profile_struct_type =
115 #if CONFIG_VP9_VULKAN_HWACCEL
119 VK_STRUCTURE_TYPE_MAX_ENUM;
120 if (profile_struct_type == VK_STRUCTURE_TYPE_MAX_ENUM)
124 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
128 for (
int i = 0;
i < profile_list->profileCount;
i++)
130 return &profile_list->pProfiles[
i];
181 vkpic->
view.
ref[
i] = VK_NULL_HANDLE;
182 vkpic->
view.
out[
i] = VK_NULL_HANDLE;
183 vkpic->
view.
dst[
i] = VK_NULL_HANDLE;
207 if (
ctx->common.layered_dpb && alloc_dpb) {
208 vkpic->
view.
ref[0] =
ctx->common.layered_view;
210 }
else if (alloc_dpb) {
221 dpb_hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
228 if (!alloc_dpb || is_current) {
236 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
237 (hwfc->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR));
281 if (!alloc_dpb || is_current) {
299 const uint8_t *
data,
size_t size,
int add_startcode,
300 uint32_t *nb_slices,
const uint32_t **
offsets)
305 static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
306 const size_t startcode_len = add_startcode ?
sizeof(startcode_prefix) : 0;
307 const int nb = nb_slices ? *nb_slices : 0;
313 ctx->caps.minBitstreamBufferSizeAlignment;
314 new_size =
FFALIGN(new_size,
ctx->caps.minBitstreamBufferSizeAlignment);
318 (nb + 1)*
sizeof(slice_off));
328 if (!vkbuf || vkbuf->
size < new_size) {
334 size_t buf_size =
FFMAX(new_size, 1024*1024);
338 buf_size = 2 <<
av_log2(buf_size);
344 void *buf_pnext =
ctx->s.hwfc->create_pnext;
345 if (
ctx->s.hwfc->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
347 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
351 (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
352 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
353 VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
355 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
357 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
375 memcpy(slices + vp->
slices_size, startcode_prefix, startcode_len);
390 VkVideoSessionParametersKHR *empty_session_params)
395 VkVideoDecodeH264SessionParametersCreateInfoKHR h264_params = {
396 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
398 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
399 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
401 StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
402 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
403 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
404 .pStdSequenceHeader = &av1_empty_seq,
406 VkVideoSessionParametersCreateInfoKHR session_params_create = {
407 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
412 .videoSession =
ctx->common.session,
418 ret = vk->CreateVideoSessionParametersKHR(
s->hwctx->act_dev, &session_params_create,
419 s->hwctx->alloc, empty_session_params);
420 if (
ret != VK_SUCCESS) {
421 av_log(avctx,
AV_LOG_ERROR,
"Unable to create empty Vulkan video session parameters: %s!\n",
435 VkVideoBeginCodingInfoKHR decode_start = {
436 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
437 .videoSession =
ctx->common.session,
442 &decode_start.videoSessionParameters);
447 VkVideoCodingControlInfoKHR decode_ctrl = {
448 .sType = VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR,
449 .flags = VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR,
452 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
458 vk->CmdBeginVideoCodingKHR(exec->
buf, &decode_start);
459 vk->CmdControlVideoCodingKHR(exec->
buf, &decode_ctrl);
464 if (decode_start.videoSessionParameters) {
469 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
470 decode_start.videoSessionParameters,
487 VkCommandBuffer cmd_buf;
498 const int layered_dpb =
ctx->common.layered_dpb;
500 VkVideoBeginCodingInfoKHR decode_start = {
501 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
502 .videoSession =
ctx->common.session,
506 .referenceSlotCount = vp->
decode_info.referenceSlotCount,
507 .pReferenceSlots = vp->
decode_info.pReferenceSlots,
510 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
513 VkImageMemoryBarrier2 img_bar[37];
515 size_t data_size =
FFALIGN(vp->slices_size,
516 ctx->caps.minBitstreamBufferSizeAlignment);
521 VkVideoReferenceSlotInfoKHR *cur_vk_ref;
522 cur_vk_ref = (
void *)&decode_start.pReferenceSlots[decode_start.referenceSlotCount];
523 cur_vk_ref[0] = vp->ref_slot;
524 cur_vk_ref[0].slotIndex = -1;
525 decode_start.referenceSlotCount++;
530 if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
531 VkMappedMemoryRange flush_buf = {
532 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
533 .memory = sd_buf->mem,
535 .size =
FFALIGN(vp->slices_size,
536 ctx->s.props.properties.limits.nonCoherentAtomSize),
539 ret = vk->FlushMappedMemoryRanges(
ctx->s.hwctx->act_dev, 1, &flush_buf);
540 if (
ret != VK_SUCCESS) {
547 vp->decode_info.srcBuffer = sd_buf->buf;
548 vp->decode_info.srcBufferOffset = 0;
549 vp->decode_info.srcBufferRange = data_size;
561 vp->slices_buf =
NULL;
569 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
570 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
580 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
581 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
583 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
584 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
585 .srcAccessMask = VK_ACCESS_2_NONE,
586 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
587 .oldLayout = vkf->layout[0],
588 .newLayout = (layered_dpb || vp->dpb_frame) ?
589 VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
590 VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
591 .srcQueueFamilyIndex = vkf->queue_family[0],
592 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
593 .image = vkf->img[0],
594 .subresourceRange = (VkImageSubresourceRange) {
595 .aspectMask = vp->view.aspect[0],
601 &img_bar[nb_img_bar], &nb_img_bar);
606 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
607 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
615 for (
int i = 0;
i < vp->decode_info.referenceSlotCount;
i++) {
621 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
622 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
637 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
638 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
640 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
641 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
642 .srcAccessMask = VK_ACCESS_2_NONE,
643 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR |
644 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
645 .oldLayout = rvkf->
layout[0],
646 .newLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
648 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
649 .image = rvkf->
img[0],
650 .subresourceRange = (VkImageSubresourceRange) {
657 &img_bar[nb_img_bar], &nb_img_bar);
660 }
else if (vp->decode_info.referenceSlotCount ||
661 vp->view.out[0] != vp->view.ref[0]) {
664 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
665 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
671 vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
672 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
673 .dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT,
674 .pImageMemoryBarriers = img_bar,
675 .imageMemoryBarrierCount = nb_img_bar,
679 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
680 vk->CmdDecodeVideoKHR(cmd_buf, &vp->decode_info);
681 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
691 VkSemaphoreWaitInfo
sem_wait = (VkSemaphoreWaitInfo) {
692 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
693 .pSemaphores = &vp->
sem,
735 if (
ctx->sd_ctx_free)
764 if (vk_desc->
queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
767 VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME);
787 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
788 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
789 #
if CONFIG_VP9_VULKAN_HWACCEL
790 VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
792 VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
793 VkVideoCapabilitiesKHR *caps,
794 VkVideoDecodeCapabilitiesKHR *dec_caps,
797 VkVideoDecodeUsageInfoKHR *
usage = &prof->
usage;
799 VkVideoProfileListInfoKHR *profile_list = &prof->
profile_list;
801 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->
h264_profile;
802 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->
h265_profile;
803 #if CONFIG_VP9_VULKAN_HWACCEL
804 VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
806 VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->
av1_profile;
813 dec_caps->pNext = h264_caps;
814 usage->pNext = h264_profile;
815 h264_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;
824 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR :
825 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR;
827 dec_caps->pNext = h265_caps;
828 usage->pNext = h265_profile;
829 h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
830 h265_profile->stdProfileIdc = cur_profile;
831 #if CONFIG_VP9_VULKAN_HWACCEL
833 dec_caps->pNext = vp9_caps;
834 usage->pNext = vp9_profile;
835 vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
836 vp9_profile->stdProfile = cur_profile;
839 dec_caps->pNext = av1_caps;
840 usage->pNext = av1_profile;
841 av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
842 av1_profile->stdProfile = cur_profile;
846 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
847 usage->videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
849 profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
856 profile_list->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;
857 profile_list->profileCount = 1;
858 profile_list->pProfiles =
profile;
861 caps->sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;
862 caps->pNext = dec_caps;
863 dec_caps->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;
866 return vk->GetPhysicalDeviceVideoCapabilitiesKHR(hwctx->
phys_dev,
profile,
876 int max_level, base_profile, cur_profile;
889 VkVideoCapabilitiesKHR *caps = &
ctx->caps;
890 VkVideoDecodeCapabilitiesKHR *dec_caps = &
ctx->dec_caps;
892 VkVideoDecodeH264CapabilitiesKHR h264_caps = {
893 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR,
895 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
896 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
898 #if CONFIG_VP9_VULKAN_HWACCEL
899 VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
900 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
903 VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
904 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
907 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
908 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR,
911 VkVideoFormatPropertiesKHR *ret_info;
912 uint32_t nb_out_fmts = 0;
923 #if CONFIG_VP9_VULKAN_HWACCEL
932 #
if CONFIG_VP9_VULKAN_HWACCEL
939 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR &&
941 avctx->
profile != base_profile) {
943 "again with profile %s\n",
947 cur_profile = base_profile;
951 #
if CONFIG_VP9_VULKAN_HWACCEL
960 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR) {
962 "%s profile \"%s\" not supported!\n",
966 }
else if (
ret == VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR) {
968 "format (%s) not supported!\n",
971 }
else if (
ret == VK_ERROR_FEATURE_NOT_PRESENT ||
972 ret == VK_ERROR_FORMAT_NOT_SUPPORTED) {
974 }
else if (
ret != VK_SUCCESS) {
980 #if CONFIG_VP9_VULKAN_HWACCEL
990 max_level, avctx->
level);
992 caps->minCodedExtent.width, caps->maxCodedExtent.width);
994 caps->minCodedExtent.height, caps->maxCodedExtent.height);
996 caps->pictureAccessGranularity.width);
998 caps->pictureAccessGranularity.height);
1000 caps->minBitstreamBufferOffsetAlignment);
1002 caps->minBitstreamBufferSizeAlignment);
1006 caps->maxActiveReferencePictures);
1008 caps->stdHeaderVersion.extensionName,
1010 av_log(avctx,
AV_LOG_VERBOSE,
" Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n",
1011 CODEC_VER(caps->stdHeaderVersion.specVersion),
1014 dec_caps->flags ?
"" :
1016 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR ?
1017 " reuse_dst_dpb" :
"",
1018 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR ?
1019 " dedicated_dpb" :
"");
1023 caps->flags & VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR ?
1025 caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
1026 " separate_references" :
"");
1029 if (avctx->
coded_width < caps->minCodedExtent.width ||
1031 avctx->
coded_width > caps->maxCodedExtent.width ||
1036 avctx->
level > max_level)
1040 if (!(dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1041 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR))) {
1043 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR nor "
1044 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are set!\n");
1046 }
else if ((dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1047 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) ==
1048 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) &&
1049 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR)) {
1050 av_log(avctx,
AV_LOG_ERROR,
"Cannot initialize Vulkan decoding session, buggy driver: "
1051 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
1052 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
1056 dec->
dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
1058 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
1061 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1063 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1064 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
1065 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1066 VK_IMAGE_USAGE_SAMPLED_BIT;
1070 fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1074 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1076 &nb_out_fmts,
NULL);
1077 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1078 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1080 }
else if (
ret != VK_SUCCESS) {
1086 ret_info =
av_mallocz(
sizeof(*ret_info)*nb_out_fmts);
1090 for (
int i = 0;
i < nb_out_fmts;
i++)
1091 ret_info[
i].sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;
1093 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1095 &nb_out_fmts, ret_info);
1096 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1097 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1100 }
else if (
ret != VK_SUCCESS) {
1109 *vk_fmt = best_vkfmt = VK_FORMAT_UNDEFINED;
1112 av_log(avctx,
AV_LOG_DEBUG,
"Choosing best pixel format for decoding from %i:\n", nb_out_fmts);
1113 for (
int i = 0;
i < nb_out_fmts;
i++) {
1121 if (
tmp == best_format)
1122 best_vkfmt = ret_info[
i].format;
1132 av_log(avctx,
AV_LOG_ERROR,
"No valid/compatible pixel format found for decoding!\n");
1140 *vk_fmt = best_vkfmt;
1154 int err, dedicated_dpb;
1177 prof, &dedicated_dpb);
1189 hwfc->create_pnext = &prof->profile_list;
1191 hwfc->format[0] = VK_FORMAT_UNDEFINED;
1216 hwfc->format[3] = VK_FORMAT_R16_UNORM;
1222 hwfc->format[0] = VK_FORMAT_R16_UNORM;
1223 hwfc->format[1] = VK_FORMAT_R16_UNORM;
1224 hwfc->format[2] = VK_FORMAT_R16_UNORM;
1231 if (hwfc->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
1232 hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
1234 hwfc->usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1235 VK_IMAGE_USAGE_STORAGE_BIT |
1236 VK_IMAGE_USAGE_SAMPLED_BIT;
1241 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR;
1242 if (!dec->dedicated_dpb)
1243 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1245 ctx = dec->shared_ctx;
1248 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1258 VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)
data;
1259 vk->DestroyVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, *par,
1260 ctx->s.hwctx->alloc);
1265 const VkVideoSessionParametersCreateInfoKHR *session_params_create)
1267 VkVideoSessionParametersKHR *par =
av_malloc(
sizeof(*par));
1275 ret = vk->CreateVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, session_params_create,
1276 ctx->s.hwctx->alloc, par);
1277 if (
ret != VK_SUCCESS) {
1278 av_log(logctx,
AV_LOG_ERROR,
"Unable to create Vulkan video session parameters: %s!\n",
1311 const VkVideoProfileInfoKHR *
profile;
1314 VkVideoSessionCreateInfoKHR session_create = {
1315 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1347 session_create.queueFamilyIndex =
ctx->qf->idx;
1348 session_create.maxCodedExtent =
ctx->caps.maxCodedExtent;
1349 session_create.maxDpbSlots =
ctx->caps.maxDpbSlots;
1350 session_create.maxActiveReferencePictures =
ctx->caps.maxActiveReferencePictures;
1351 session_create.pictureFormat =
s->hwfc->format[0];
1352 session_create.referencePictureFormat = session_create.pictureFormat;
1353 session_create.pStdHeaderVersion = &vk_desc->
ext_props;
1354 session_create.pVideoProfile =
profile;
1355 #ifdef VK_KHR_video_maintenance2
1357 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1363 async_depth = 2*
ctx->qf->num;
1370 async_depth, 0, 0, 0,
profile);
1386 if (!
ctx->common.dpb_hwfc_ref) {
1399 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
1404 VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
1405 if (drm_create_pnext) {
1407 dpb_hwfc->
tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
1411 dpb_hwfc->
tiling = VK_IMAGE_TILING_OPTIMAL;
1413 dpb_hwfc->
format[0] =
s->hwfc->format[0];
1414 dpb_hwfc->
usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1416 if (
ctx->common.layered_dpb)
1423 if (
ctx->common.layered_dpb) {
1425 if (!
ctx->common.layered_frame) {
1431 &
ctx->common.layered_view,
1432 &
ctx->common.layered_aspect,
1434 s->hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
1450 const VkPhysicalDeviceDriverProperties *driver_props;
1452 if (driver_props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
1453 driver_props->conformanceVersion.major == 1 &&
1454 driver_props->conformanceVersion.minor == 3 &&
1455 driver_props->conformanceVersion.subminor == 8 &&
1456 driver_props->conformanceVersion.patch < 3)