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_APV) || \
32 ((codec_id) == AV_CODEC_ID_PRORES_RAW) || \
33 ((codec_id) == AV_CODEC_ID_PRORES))
35 #if CONFIG_H264_VULKAN_HWACCEL
38 #if CONFIG_HEVC_VULKAN_HWACCEL
41 #if CONFIG_VP9_VULKAN_HWACCEL
44 #if CONFIG_AV1_VULKAN_HWACCEL
47 #if CONFIG_FFV1_VULKAN_HWACCEL
50 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
53 #if CONFIG_PRORES_VULKAN_HWACCEL
56 #if CONFIG_DPX_VULKAN_HWACCEL
59 #if CONFIG_APV_VULKAN_HWACCEL
64 #if CONFIG_H264_VULKAN_HWACCEL
67 #if CONFIG_HEVC_VULKAN_HWACCEL
70 #if CONFIG_VP9_VULKAN_HWACCEL
73 #if CONFIG_AV1_VULKAN_HWACCEL
76 #if CONFIG_FFV1_VULKAN_HWACCEL
79 #if CONFIG_PRORES_RAW_VULKAN_HWACCEL
82 #if CONFIG_PRORES_VULKAN_HWACCEL
85 #if CONFIG_DPX_VULKAN_HWACCEL
88 #if CONFIG_APV_VULKAN_HWACCEL
96 #if CONFIG_VP9_VULKAN_HWACCEL
97 VkVideoDecodeVP9ProfileInfoKHR vp9_profile;
117 const VkVideoProfileListInfoKHR *profile_list;
119 VkStructureType profile_struct_type =
122 #if CONFIG_VP9_VULKAN_HWACCEL
126 VK_STRUCTURE_TYPE_MAX_ENUM;
127 if (profile_struct_type == VK_STRUCTURE_TYPE_MAX_ENUM)
131 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
135 for (
int i = 0;
i < profile_list->profileCount;
i++)
137 return &profile_list->pProfiles[
i];
188 vkpic->
view.
ref[
i] = VK_NULL_HANDLE;
189 vkpic->
view.
out[
i] = VK_NULL_HANDLE;
190 vkpic->
view.
dst[
i] = VK_NULL_HANDLE;
214 if (
ctx->common.layered_dpb && alloc_dpb) {
215 vkpic->
view.
ref[0] =
ctx->common.layered_view;
217 }
else if (alloc_dpb) {
228 dpb_hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
235 if (!alloc_dpb || is_current) {
243 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
244 (hwfc->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR));
288 if (!alloc_dpb || is_current) {
306 const uint8_t *
data,
size_t size,
int add_startcode,
307 uint32_t *nb_slices,
const uint32_t **
offsets)
312 static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
313 const size_t startcode_len = add_startcode ?
sizeof(startcode_prefix) : 0;
314 const int nb = nb_slices ? *nb_slices : 0;
320 ctx->caps.minBitstreamBufferSizeAlignment;
321 new_size =
FFALIGN(new_size,
ctx->caps.minBitstreamBufferSizeAlignment);
325 (nb + 1)*
sizeof(slice_off));
335 if (!vkbuf || vkbuf->
size < new_size) {
341 size_t buf_size =
FFMAX(new_size, 1024*1024);
345 buf_size = 2 <<
av_log2(buf_size);
351 void *buf_pnext =
ctx->s.hwfc->create_pnext;
352 if (
ctx->s.hwfc->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
354 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
358 (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
359 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
360 VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
362 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
364 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
382 memcpy(slices + vp->
slices_size, startcode_prefix, startcode_len);
397 VkVideoSessionParametersKHR *empty_session_params)
402 VkVideoDecodeH264SessionParametersCreateInfoKHR h264_params = {
403 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
405 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
406 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
408 StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
409 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
410 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
411 .pStdSequenceHeader = &av1_empty_seq,
413 VkVideoSessionParametersCreateInfoKHR session_params_create = {
414 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
419 .videoSession =
ctx->common.session,
425 ret = vk->CreateVideoSessionParametersKHR(
s->hwctx->act_dev, &session_params_create,
426 s->hwctx->alloc, empty_session_params);
427 if (
ret != VK_SUCCESS) {
428 av_log(avctx,
AV_LOG_ERROR,
"Unable to create empty Vulkan video session parameters: %s!\n",
442 VkVideoBeginCodingInfoKHR decode_start = {
443 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
444 .videoSession =
ctx->common.session,
449 &decode_start.videoSessionParameters);
454 VkVideoCodingControlInfoKHR decode_ctrl = {
455 .sType = VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR,
456 .flags = VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR,
459 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
465 vk->CmdBeginVideoCodingKHR(exec->
buf, &decode_start);
466 vk->CmdControlVideoCodingKHR(exec->
buf, &decode_ctrl);
471 if (decode_start.videoSessionParameters) {
476 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
477 decode_start.videoSessionParameters,
494 VkCommandBuffer cmd_buf;
505 const int layered_dpb =
ctx->common.layered_dpb;
507 VkVideoBeginCodingInfoKHR decode_start = {
508 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
509 .videoSession =
ctx->common.session,
513 .referenceSlotCount = vp->
decode_info.referenceSlotCount,
514 .pReferenceSlots = vp->
decode_info.pReferenceSlots,
517 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
520 VkImageMemoryBarrier2 img_bar[37];
522 size_t data_size =
FFALIGN(vp->slices_size,
523 ctx->caps.minBitstreamBufferSizeAlignment);
528 VkVideoReferenceSlotInfoKHR *cur_vk_ref;
529 cur_vk_ref = (
void *)&decode_start.pReferenceSlots[decode_start.referenceSlotCount];
530 cur_vk_ref[0] = vp->ref_slot;
531 cur_vk_ref[0].slotIndex = -1;
532 decode_start.referenceSlotCount++;
537 if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
538 VkMappedMemoryRange flush_buf = {
539 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
540 .memory = sd_buf->mem,
542 .size =
FFALIGN(vp->slices_size,
543 ctx->s.props.properties.limits.nonCoherentAtomSize),
546 ret = vk->FlushMappedMemoryRanges(
ctx->s.hwctx->act_dev, 1, &flush_buf);
547 if (
ret != VK_SUCCESS) {
554 vp->decode_info.srcBuffer = sd_buf->buf;
555 vp->decode_info.srcBufferOffset = 0;
556 vp->decode_info.srcBufferRange = data_size;
568 vp->slices_buf =
NULL;
576 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
577 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
587 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
588 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
590 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
591 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
592 .srcAccessMask = VK_ACCESS_2_NONE,
593 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
594 .oldLayout = vkf->layout[0],
595 .newLayout = (layered_dpb || vp->dpb_frame) ?
596 VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
597 VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
598 .srcQueueFamilyIndex = vkf->queue_family[0],
599 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
600 .image = vkf->img[0],
601 .subresourceRange = (VkImageSubresourceRange) {
602 .aspectMask = vp->view.aspect[0],
608 &img_bar[nb_img_bar], &nb_img_bar);
613 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
614 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
622 for (
int i = 0;
i < vp->decode_info.referenceSlotCount;
i++) {
628 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
629 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
644 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
645 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
647 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
648 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
649 .srcAccessMask = VK_ACCESS_2_NONE,
650 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR |
651 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
652 .oldLayout = rvkf->
layout[0],
653 .newLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
655 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
656 .image = rvkf->
img[0],
657 .subresourceRange = (VkImageSubresourceRange) {
664 &img_bar[nb_img_bar], &nb_img_bar);
667 }
else if (vp->decode_info.referenceSlotCount ||
668 vp->view.out[0] != vp->view.ref[0]) {
671 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
672 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
678 vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
679 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
680 .dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT,
681 .pImageMemoryBarriers = img_bar,
682 .imageMemoryBarrierCount = nb_img_bar,
686 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
687 vk->CmdDecodeVideoKHR(cmd_buf, &vp->decode_info);
688 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
698 VkSemaphoreWaitInfo
sem_wait = (VkSemaphoreWaitInfo) {
699 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
700 .pSemaphores = &vp->
sem,
742 if (
ctx->sd_ctx_free)
771 if (vk_desc->
queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
774 VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME);
794 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
795 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
796 #
if CONFIG_VP9_VULKAN_HWACCEL
797 VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
799 VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
800 VkVideoCapabilitiesKHR *caps,
801 VkVideoDecodeCapabilitiesKHR *dec_caps,
804 VkVideoDecodeUsageInfoKHR *
usage = &prof->
usage;
806 VkVideoProfileListInfoKHR *profile_list = &prof->
profile_list;
808 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->
h264_profile;
809 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->
h265_profile;
810 #if CONFIG_VP9_VULKAN_HWACCEL
811 VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
813 VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->
av1_profile;
820 dec_caps->pNext = h264_caps;
821 usage->pNext = h264_profile;
822 h264_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;
831 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR :
832 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR;
834 dec_caps->pNext = h265_caps;
835 usage->pNext = h265_profile;
836 h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
837 h265_profile->stdProfileIdc = cur_profile;
838 #if CONFIG_VP9_VULKAN_HWACCEL
840 dec_caps->pNext = vp9_caps;
841 usage->pNext = vp9_profile;
842 vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
843 vp9_profile->stdProfile = cur_profile;
846 dec_caps->pNext = av1_caps;
847 usage->pNext = av1_profile;
848 av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
849 av1_profile->stdProfile = cur_profile;
853 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
854 usage->videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
856 profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
863 profile_list->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;
864 profile_list->profileCount = 1;
865 profile_list->pProfiles =
profile;
868 caps->sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;
869 caps->pNext = dec_caps;
870 dec_caps->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;
873 return vk->GetPhysicalDeviceVideoCapabilitiesKHR(hwctx->
phys_dev,
profile,
883 int max_level, base_profile, cur_profile;
896 VkVideoCapabilitiesKHR *caps = &
ctx->caps;
897 VkVideoDecodeCapabilitiesKHR *dec_caps = &
ctx->dec_caps;
899 VkVideoDecodeH264CapabilitiesKHR h264_caps = {
900 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR,
902 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
903 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
905 #if CONFIG_VP9_VULKAN_HWACCEL
906 VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
907 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
910 VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
911 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
914 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
915 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR,
918 VkVideoFormatPropertiesKHR *ret_info;
919 uint32_t nb_out_fmts = 0;
930 #if CONFIG_VP9_VULKAN_HWACCEL
939 #
if CONFIG_VP9_VULKAN_HWACCEL
946 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR &&
948 avctx->
profile != base_profile) {
950 "again with profile %s\n",
954 cur_profile = base_profile;
958 #
if CONFIG_VP9_VULKAN_HWACCEL
967 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR) {
969 "%s profile \"%s\" not supported!\n",
973 }
else if (
ret == VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR) {
975 "format (%s) not supported!\n",
978 }
else if (
ret == VK_ERROR_FEATURE_NOT_PRESENT ||
979 ret == VK_ERROR_FORMAT_NOT_SUPPORTED) {
981 }
else if (
ret != VK_SUCCESS) {
987 #if CONFIG_VP9_VULKAN_HWACCEL
997 max_level, avctx->
level);
999 caps->minCodedExtent.width, caps->maxCodedExtent.width);
1001 caps->minCodedExtent.height, caps->maxCodedExtent.height);
1003 caps->pictureAccessGranularity.width);
1005 caps->pictureAccessGranularity.height);
1007 caps->minBitstreamBufferOffsetAlignment);
1009 caps->minBitstreamBufferSizeAlignment);
1013 caps->maxActiveReferencePictures);
1015 caps->stdHeaderVersion.extensionName,
1017 av_log(avctx,
AV_LOG_VERBOSE,
" Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n",
1018 CODEC_VER(caps->stdHeaderVersion.specVersion),
1021 dec_caps->flags ?
"" :
1023 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR ?
1024 " reuse_dst_dpb" :
"",
1025 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR ?
1026 " dedicated_dpb" :
"");
1030 caps->flags & VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR ?
1032 caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
1033 " separate_references" :
"");
1036 if (avctx->
coded_width < caps->minCodedExtent.width ||
1038 avctx->
coded_width > caps->maxCodedExtent.width ||
1043 avctx->
level > max_level)
1047 if (!(dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1048 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR))) {
1050 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR nor "
1051 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are set!\n");
1053 }
else if ((dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1054 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) ==
1055 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) &&
1056 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR)) {
1057 av_log(avctx,
AV_LOG_ERROR,
"Cannot initialize Vulkan decoding session, buggy driver: "
1058 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
1059 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
1063 dec->
dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
1065 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
1068 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1070 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1071 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
1072 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1073 VK_IMAGE_USAGE_SAMPLED_BIT;
1077 fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1081 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1083 &nb_out_fmts,
NULL);
1084 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1085 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1087 }
else if (
ret != VK_SUCCESS) {
1093 ret_info =
av_mallocz(
sizeof(*ret_info)*nb_out_fmts);
1097 for (
int i = 0;
i < nb_out_fmts;
i++)
1098 ret_info[
i].sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;
1100 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1102 &nb_out_fmts, ret_info);
1103 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1104 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1107 }
else if (
ret != VK_SUCCESS) {
1116 *vk_fmt = best_vkfmt = VK_FORMAT_UNDEFINED;
1119 av_log(avctx,
AV_LOG_DEBUG,
"Choosing best pixel format for decoding from %i:\n", nb_out_fmts);
1120 for (
int i = 0;
i < nb_out_fmts;
i++) {
1128 if (
tmp == best_format)
1129 best_vkfmt = ret_info[
i].format;
1139 av_log(avctx,
AV_LOG_ERROR,
"No valid/compatible pixel format found for decoding!\n");
1147 *vk_fmt = best_vkfmt;
1161 int err, dedicated_dpb;
1184 prof, &dedicated_dpb);
1196 hwfc->create_pnext = &prof->profile_list;
1198 hwfc->format[0] = VK_FORMAT_UNDEFINED;
1223 hwfc->format[3] = VK_FORMAT_R16_UNORM;
1229 hwfc->format[0] = VK_FORMAT_R16_UNORM;
1230 hwfc->format[1] = VK_FORMAT_R16_UNORM;
1231 hwfc->format[2] = VK_FORMAT_R16_UNORM;
1238 if (hwfc->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
1239 hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
1241 hwfc->usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1242 VK_IMAGE_USAGE_STORAGE_BIT |
1243 VK_IMAGE_USAGE_SAMPLED_BIT;
1248 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR;
1249 if (!dec->dedicated_dpb)
1250 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1252 ctx = dec->shared_ctx;
1255 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1265 VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)
data;
1266 vk->DestroyVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, *par,
1267 ctx->s.hwctx->alloc);
1272 const VkVideoSessionParametersCreateInfoKHR *session_params_create)
1274 VkVideoSessionParametersKHR *par =
av_malloc(
sizeof(*par));
1282 ret = vk->CreateVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, session_params_create,
1283 ctx->s.hwctx->alloc, par);
1284 if (
ret != VK_SUCCESS) {
1285 av_log(logctx,
AV_LOG_ERROR,
"Unable to create Vulkan video session parameters: %s!\n",
1318 const VkVideoProfileInfoKHR *
profile;
1321 VkVideoSessionCreateInfoKHR session_create = {
1322 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1354 session_create.queueFamilyIndex =
ctx->qf->idx;
1355 session_create.maxCodedExtent =
ctx->caps.maxCodedExtent;
1356 session_create.maxDpbSlots =
ctx->caps.maxDpbSlots;
1357 session_create.maxActiveReferencePictures =
ctx->caps.maxActiveReferencePictures;
1358 session_create.pictureFormat =
s->hwfc->format[0];
1359 session_create.referencePictureFormat = session_create.pictureFormat;
1360 session_create.pStdHeaderVersion = &vk_desc->
ext_props;
1361 session_create.pVideoProfile =
profile;
1362 #ifdef VK_KHR_video_maintenance2
1364 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1370 async_depth = 2*
ctx->qf->num;
1377 async_depth, 0, 0, 0,
profile);
1393 if (!
ctx->common.dpb_hwfc_ref) {
1406 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
1411 VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
1412 if (drm_create_pnext) {
1414 dpb_hwfc->
tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
1418 dpb_hwfc->
tiling = VK_IMAGE_TILING_OPTIMAL;
1420 dpb_hwfc->
format[0] =
s->hwfc->format[0];
1421 dpb_hwfc->
usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1423 if (
ctx->common.layered_dpb)
1430 if (
ctx->common.layered_dpb) {
1432 if (!
ctx->common.layered_frame) {
1438 &
ctx->common.layered_view,
1439 &
ctx->common.layered_aspect,
1441 s->hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
1457 const VkPhysicalDeviceDriverProperties *driver_props;
1459 if (driver_props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
1460 driver_props->conformanceVersion.major == 1 &&
1461 driver_props->conformanceVersion.minor == 3 &&
1462 driver_props->conformanceVersion.subminor == 8 &&
1463 driver_props->conformanceVersion.patch < 3)