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));
259 const uint8_t *
data,
size_t size,
int add_startcode,
260 uint32_t *nb_slices,
const uint32_t **
offsets)
265 static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
266 const size_t startcode_len = add_startcode ?
sizeof(startcode_prefix) : 0;
267 const int nb = nb_slices ? *nb_slices : 0;
273 ctx->caps.minBitstreamBufferSizeAlignment;
274 new_size =
FFALIGN(new_size,
ctx->caps.minBitstreamBufferSizeAlignment);
278 (nb + 1)*
sizeof(slice_off));
288 if (!vkbuf || vkbuf->
size < new_size) {
294 size_t buf_size =
FFMAX(new_size, 1024*1024);
298 buf_size = 2 <<
av_log2(buf_size);
304 void *buf_pnext =
ctx->s.hwfc->create_pnext;
305 if (
ctx->s.hwfc->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
307 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
311 (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
312 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
313 VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
315 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
317 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0x0));
335 memcpy(slices + vp->
slices_size, startcode_prefix, startcode_len);
350 VkVideoSessionParametersKHR *empty_session_params)
355 VkVideoDecodeH264SessionParametersCreateInfoKHR h264_params = {
356 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
358 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
359 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
361 StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
362 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
363 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
364 .pStdSequenceHeader = &av1_empty_seq,
366 VkVideoSessionParametersCreateInfoKHR session_params_create = {
367 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
372 .videoSession =
ctx->common.session,
378 ret = vk->CreateVideoSessionParametersKHR(
s->hwctx->act_dev, &session_params_create,
379 s->hwctx->alloc, empty_session_params);
380 if (
ret != VK_SUCCESS) {
381 av_log(avctx,
AV_LOG_ERROR,
"Unable to create empty Vulkan video session parameters: %s!\n",
395 VkVideoBeginCodingInfoKHR decode_start = {
396 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
397 .videoSession =
ctx->common.session,
402 &decode_start.videoSessionParameters);
407 VkVideoCodingControlInfoKHR decode_ctrl = {
408 .sType = VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR,
409 .flags = VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR,
412 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
418 vk->CmdBeginVideoCodingKHR(exec->
buf, &decode_start);
419 vk->CmdControlVideoCodingKHR(exec->
buf, &decode_ctrl);
424 if (decode_start.videoSessionParameters) {
429 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
430 decode_start.videoSessionParameters,
447 VkCommandBuffer cmd_buf;
458 const int layered_dpb =
ctx->common.layered_dpb;
460 VkVideoBeginCodingInfoKHR decode_start = {
461 .sType = VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR,
462 .videoSession =
ctx->common.session,
466 .referenceSlotCount = vp->
decode_info.referenceSlotCount,
467 .pReferenceSlots = vp->
decode_info.pReferenceSlots,
470 .sType = VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR,
473 VkImageMemoryBarrier2 img_bar[37];
475 size_t data_size =
FFALIGN(vp->slices_size,
476 ctx->caps.minBitstreamBufferSizeAlignment);
481 VkVideoReferenceSlotInfoKHR *cur_vk_ref;
482 cur_vk_ref = (
void *)&decode_start.pReferenceSlots[decode_start.referenceSlotCount];
483 cur_vk_ref[0] = vp->ref_slot;
484 cur_vk_ref[0].slotIndex = -1;
485 decode_start.referenceSlotCount++;
490 if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
491 VkMappedMemoryRange flush_buf = {
492 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
493 .memory = sd_buf->mem,
495 .size =
FFALIGN(vp->slices_size,
496 ctx->s.props.properties.limits.nonCoherentAtomSize),
499 ret = vk->FlushMappedMemoryRanges(
ctx->s.hwctx->act_dev, 1, &flush_buf);
500 if (
ret != VK_SUCCESS) {
507 vp->decode_info.srcBuffer = sd_buf->buf;
508 vp->decode_info.srcBufferOffset = 0;
509 vp->decode_info.srcBufferRange = data_size;
521 vp->slices_buf =
NULL;
529 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
530 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
540 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
541 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
543 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
544 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
545 .srcAccessMask = VK_ACCESS_2_NONE,
546 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
547 .oldLayout = vkf->layout[0],
548 .newLayout = (layered_dpb || vp->dpb_frame) ?
549 VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
550 VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
551 .srcQueueFamilyIndex = vkf->queue_family[0],
552 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
553 .image = vkf->img[0],
554 .subresourceRange = (VkImageSubresourceRange) {
555 .aspectMask = vp->view.aspect[0],
561 &img_bar[nb_img_bar], &nb_img_bar);
566 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
567 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
575 for (
int i = 0;
i < vp->decode_info.referenceSlotCount;
i++) {
581 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
582 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
597 img_bar[nb_img_bar] = (VkImageMemoryBarrier2) {
598 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2,
600 .srcStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
601 .dstStageMask = VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
602 .srcAccessMask = VK_ACCESS_2_NONE,
603 .dstAccessMask = VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR |
604 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR,
605 .oldLayout = rvkf->
layout[0],
606 .newLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR,
608 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
609 .image = rvkf->
img[0],
610 .subresourceRange = (VkImageSubresourceRange) {
617 &img_bar[nb_img_bar], &nb_img_bar);
620 }
else if (vp->decode_info.referenceSlotCount ||
621 vp->view.out[0] != vp->view.ref[0]) {
624 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
625 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR);
631 vk->CmdPipelineBarrier2(cmd_buf, &(VkDependencyInfo) {
632 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
633 .dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT,
634 .pImageMemoryBarriers = img_bar,
635 .imageMemoryBarrierCount = nb_img_bar,
639 vk->CmdBeginVideoCodingKHR(cmd_buf, &decode_start);
640 vk->CmdDecodeVideoKHR(cmd_buf, &vp->decode_info);
641 vk->CmdEndVideoCodingKHR(cmd_buf, &
decode_end);
651 VkSemaphoreWaitInfo
sem_wait = (VkSemaphoreWaitInfo) {
652 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
653 .pSemaphores = &vp->
sem,
695 if (
ctx->sd_ctx_free)
724 if (vk_desc->
queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
727 VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME);
747 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
748 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
749 #
if CONFIG_VP9_VULKAN_HWACCEL
750 VkVideoDecodeVP9CapabilitiesKHR *vp9_caps,
752 VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
753 VkVideoCapabilitiesKHR *caps,
754 VkVideoDecodeCapabilitiesKHR *dec_caps,
757 VkVideoDecodeUsageInfoKHR *
usage = &prof->
usage;
759 VkVideoProfileListInfoKHR *profile_list = &prof->
profile_list;
761 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->
h264_profile;
762 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->
h265_profile;
763 #if CONFIG_VP9_VULKAN_HWACCEL
764 VkVideoDecodeVP9ProfileInfoKHR *vp9_profile = &prof->vp9_profile;
766 VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->
av1_profile;
773 dec_caps->pNext = h264_caps;
774 usage->pNext = h264_profile;
775 h264_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;
784 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR :
785 VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR;
787 dec_caps->pNext = h265_caps;
788 usage->pNext = h265_profile;
789 h265_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;
790 h265_profile->stdProfileIdc = cur_profile;
791 #if CONFIG_VP9_VULKAN_HWACCEL
793 dec_caps->pNext = vp9_caps;
794 usage->pNext = vp9_profile;
795 vp9_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;
796 vp9_profile->stdProfile = cur_profile;
799 dec_caps->pNext = av1_caps;
800 usage->pNext = av1_profile;
801 av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
802 av1_profile->stdProfile = cur_profile;
806 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
807 usage->videoUsageHints = VK_VIDEO_DECODE_USAGE_DEFAULT_KHR;
809 profile->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;
816 profile_list->sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;
817 profile_list->profileCount = 1;
818 profile_list->pProfiles =
profile;
821 caps->sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;
822 caps->pNext = dec_caps;
823 dec_caps->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;
826 return vk->GetPhysicalDeviceVideoCapabilitiesKHR(hwctx->
phys_dev,
profile,
836 int max_level, base_profile, cur_profile;
849 VkVideoCapabilitiesKHR *caps = &
ctx->caps;
850 VkVideoDecodeCapabilitiesKHR *dec_caps = &
ctx->dec_caps;
852 VkVideoDecodeH264CapabilitiesKHR h264_caps = {
853 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR,
855 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
856 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
858 #if CONFIG_VP9_VULKAN_HWACCEL
859 VkVideoDecodeVP9CapabilitiesKHR vp9_caps = {
860 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR,
863 VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
864 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
867 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
868 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR,
871 VkVideoFormatPropertiesKHR *ret_info;
872 uint32_t nb_out_fmts = 0;
883 #if CONFIG_VP9_VULKAN_HWACCEL
892 #
if CONFIG_VP9_VULKAN_HWACCEL
899 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR &&
901 avctx->
profile != base_profile) {
903 "again with profile %s\n",
907 cur_profile = base_profile;
911 #
if CONFIG_VP9_VULKAN_HWACCEL
920 if (
ret == VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR) {
922 "%s profile \"%s\" not supported!\n",
926 }
else if (
ret == VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR) {
928 "format (%s) not supported!\n",
931 }
else if (
ret == VK_ERROR_FEATURE_NOT_PRESENT ||
932 ret == VK_ERROR_FORMAT_NOT_SUPPORTED) {
934 }
else if (
ret != VK_SUCCESS) {
940 #if CONFIG_VP9_VULKAN_HWACCEL
950 max_level, avctx->
level);
952 caps->minCodedExtent.width, caps->maxCodedExtent.width);
954 caps->minCodedExtent.height, caps->maxCodedExtent.height);
956 caps->pictureAccessGranularity.width);
958 caps->pictureAccessGranularity.height);
960 caps->minBitstreamBufferOffsetAlignment);
962 caps->minBitstreamBufferSizeAlignment);
966 caps->maxActiveReferencePictures);
968 caps->stdHeaderVersion.extensionName,
970 av_log(avctx,
AV_LOG_VERBOSE,
" Codec header version: %i.%i.%i (driver), %i.%i.%i (compiled)\n",
971 CODEC_VER(caps->stdHeaderVersion.specVersion),
974 dec_caps->flags ?
"" :
976 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR ?
977 " reuse_dst_dpb" :
"",
978 dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR ?
979 " dedicated_dpb" :
"");
983 caps->flags & VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR ?
985 caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR ?
986 " separate_references" :
"");
989 if (avctx->
coded_width < caps->minCodedExtent.width ||
996 avctx->
level > max_level)
1000 if (!(dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1001 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR))) {
1003 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR nor "
1004 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are set!\n");
1006 }
else if ((dec_caps->flags & (VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR |
1007 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) ==
1008 VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) &&
1009 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR)) {
1010 av_log(avctx,
AV_LOG_ERROR,
"Cannot initialize Vulkan decoding session, buggy driver: "
1011 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
1012 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
1016 dec->
dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
1018 !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
1021 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1023 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
1024 VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR |
1025 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1026 VK_IMAGE_USAGE_SAMPLED_BIT;
1030 fmt_info.imageUsage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1034 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1036 &nb_out_fmts,
NULL);
1037 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1038 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1040 }
else if (
ret != VK_SUCCESS) {
1046 ret_info =
av_mallocz(
sizeof(*ret_info)*nb_out_fmts);
1050 for (
int i = 0;
i < nb_out_fmts;
i++)
1051 ret_info[
i].sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;
1053 ret = vk->GetPhysicalDeviceVideoFormatPropertiesKHR(hwctx->
phys_dev,
1055 &nb_out_fmts, ret_info);
1056 if (
ret == VK_ERROR_FORMAT_NOT_SUPPORTED ||
1057 (!nb_out_fmts &&
ret == VK_SUCCESS)) {
1060 }
else if (
ret != VK_SUCCESS) {
1069 *vk_fmt = best_vkfmt = VK_FORMAT_UNDEFINED;
1072 av_log(avctx,
AV_LOG_DEBUG,
"Choosing best pixel format for decoding from %i:\n", nb_out_fmts);
1073 for (
int i = 0;
i < nb_out_fmts;
i++) {
1081 if (
tmp == best_format)
1082 best_vkfmt = ret_info[
i].format;
1092 av_log(avctx,
AV_LOG_ERROR,
"No valid/compatible pixel format found for decoding!\n");
1100 *vk_fmt = best_vkfmt;
1114 int err, dedicated_dpb;
1137 prof, &dedicated_dpb);
1149 hwfc->create_pnext = &prof->profile_list;
1151 hwfc->format[0] = VK_FORMAT_UNDEFINED;
1176 hwfc->format[3] = VK_FORMAT_R16_UNORM;
1182 hwfc->format[0] = VK_FORMAT_R16_UNORM;
1183 hwfc->format[1] = VK_FORMAT_R16_UNORM;
1184 hwfc->format[2] = VK_FORMAT_R16_UNORM;
1191 if (hwfc->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
1192 hwfc->tiling = VK_IMAGE_TILING_OPTIMAL;
1194 hwfc->usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1195 VK_IMAGE_USAGE_STORAGE_BIT |
1196 VK_IMAGE_USAGE_SAMPLED_BIT;
1201 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR;
1202 if (!dec->dedicated_dpb)
1203 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1205 ctx = dec->shared_ctx;
1208 hwfc->usage |= VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR;
1218 VkVideoSessionParametersKHR *par = (VkVideoSessionParametersKHR *)
data;
1219 vk->DestroyVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, *par,
1220 ctx->s.hwctx->alloc);
1225 const VkVideoSessionParametersCreateInfoKHR *session_params_create)
1227 VkVideoSessionParametersKHR *par =
av_malloc(
sizeof(*par));
1235 ret = vk->CreateVideoSessionParametersKHR(
ctx->s.hwctx->act_dev, session_params_create,
1236 ctx->s.hwctx->alloc, par);
1237 if (
ret != VK_SUCCESS) {
1238 av_log(logctx,
AV_LOG_ERROR,
"Unable to create Vulkan video session parameters: %s!\n",
1271 const VkVideoProfileInfoKHR *
profile;
1274 VkVideoSessionCreateInfoKHR session_create = {
1275 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1307 session_create.queueFamilyIndex =
ctx->qf->idx;
1308 session_create.maxCodedExtent =
ctx->caps.maxCodedExtent;
1309 session_create.maxDpbSlots =
ctx->caps.maxDpbSlots;
1310 session_create.maxActiveReferencePictures =
ctx->caps.maxActiveReferencePictures;
1311 session_create.pictureFormat =
s->hwfc->format[0];
1312 session_create.referencePictureFormat = session_create.pictureFormat;
1313 session_create.pStdHeaderVersion = &vk_desc->
ext_props;
1314 session_create.pVideoProfile =
profile;
1315 #ifdef VK_KHR_video_maintenance2
1317 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1323 async_depth = 2*
ctx->qf->num;
1330 async_depth, 0, 0, 0,
profile);
1346 if (!
ctx->common.dpb_hwfc_ref) {
1359 VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR);
1364 VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
1365 if (drm_create_pnext) {
1367 dpb_hwfc->
tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
1371 dpb_hwfc->
tiling = VK_IMAGE_TILING_OPTIMAL;
1373 dpb_hwfc->
format[0] =
s->hwfc->format[0];
1374 dpb_hwfc->
usage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
1376 if (
ctx->common.layered_dpb)
1383 if (
ctx->common.layered_dpb) {
1385 if (!
ctx->common.layered_frame) {
1391 &
ctx->common.layered_view,
1392 &
ctx->common.layered_aspect,
1394 s->hwfc->format[0], VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR);
1410 const VkPhysicalDeviceDriverProperties *driver_props;
1412 if (driver_props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
1413 driver_props->conformanceVersion.major == 1 &&
1414 driver_props->conformanceVersion.minor == 3 &&
1415 driver_props->conformanceVersion.subminor == 8 &&
1416 driver_props->conformanceVersion.patch < 3)