MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_profile

Function init_profile

libavcodec/vulkan_encode_h265.c:594–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594static int init_profile(AVCodecContext *avctx,
595 VkVideoProfileInfoKHR *profile, void *pnext)
596{
597 VkResult ret;
598 VulkanEncodeH265Context *enc = avctx->priv_data;
599 FFVulkanEncodeContext *ctx = &enc->common;
600 FFVulkanContext *s = &ctx->s;
601 FFVulkanFunctions *vk = &ctx->s.vkfn;
602 VkVideoEncodeH265CapabilitiesKHR h265_caps = {
603 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_KHR,
604 };
605 VkVideoEncodeCapabilitiesKHR enc_caps = {
606 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR,
607 .pNext = &h265_caps,
608 };
609 VkVideoCapabilitiesKHR caps = {
610 .sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR,
611 .pNext = &enc_caps,
612 };
613
614 /* In order of preference */
615 int last_supported = AV_PROFILE_UNKNOWN;
616 static const int known_profiles[] = {
617 AV_PROFILE_HEVC_MAIN,
618 AV_PROFILE_HEVC_MAIN_10,
619 AV_PROFILE_HEVC_REXT,
620 };
621 int nb_profiles = FF_ARRAY_ELEMS(known_profiles);
622
623 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->frames->sw_format);
624 if (!desc)
625 return AVERROR(EINVAL);
626
627 if (s->frames->sw_format == AV_PIX_FMT_NV12)
628 nb_profiles = 1;
629 else if (s->frames->sw_format == AV_PIX_FMT_P010)
630 nb_profiles = 2;
631
632 enc->profile = (VkVideoEncodeH265ProfileInfoKHR) {
633 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_KHR,
634 .pNext = pnext,
635 .stdProfileIdc = ff_vk_h265_profile_to_vk(avctx->profile),
636 };
637 profile->pNext = &enc->profile;
638
639 /* Set level */
640 if (avctx->level == AV_LEVEL_UNKNOWN)
641 avctx->level = enc->common.opts.level;
642
643 /* User has explicitly specified a profile. */
644 if (avctx->profile != AV_PROFILE_UNKNOWN)
645 return 0;
646
647 av_log(avctx, AV_LOG_DEBUG, "Supported profiles:\n");
648 for (int i = 0; i < nb_profiles; i++) {
649 enc->profile.stdProfileIdc = ff_vk_h265_profile_to_vk(known_profiles[i]);
650 ret = vk->GetPhysicalDeviceVideoCapabilitiesKHR(s->hwctx->phys_dev,
651 profile,

Callers

nothing calls this directly

Calls 4

av_pix_fmt_desc_getFunction · 0.85
ff_vk_h265_profile_to_vkFunction · 0.85
av_logFunction · 0.85
avcodec_profile_nameFunction · 0.85

Tested by

no test coverage detected