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

Function init_profile

libavcodec/vulkan_encode_h264.c:679–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677}
678
679static int init_profile(AVCodecContext *avctx,
680 VkVideoProfileInfoKHR *profile, void *pnext)
681{
682 VkResult ret;
683 VulkanEncodeH264Context *enc = avctx->priv_data;
684 FFVulkanEncodeContext *ctx = &enc->common;
685 FFVulkanContext *s = &ctx->s;
686 FFVulkanFunctions *vk = &ctx->s.vkfn;
687 VkVideoEncodeH264CapabilitiesKHR h264_caps = {
688 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_KHR,
689 };
690 VkVideoEncodeCapabilitiesKHR enc_caps = {
691 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR,
692 .pNext = &h264_caps,
693 };
694 VkVideoCapabilitiesKHR caps = {
695 .sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR,
696 .pNext = &enc_caps,
697 };
698
699 /* In order of preference */
700 int last_supported = AV_PROFILE_UNKNOWN;
701 static const int known_profiles[] = {
702 AV_PROFILE_H264_CONSTRAINED_BASELINE,
703 AV_PROFILE_H264_MAIN,
704 AV_PROFILE_H264_HIGH,
705 AV_PROFILE_H264_HIGH_10,
706 };
707 int nb_profiles = FF_ARRAY_ELEMS(known_profiles);
708
709 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->frames->sw_format);
710 if (!desc)
711 return AVERROR(EINVAL);
712
713 if (desc->comp[0].depth == 8)
714 nb_profiles = 3;
715
716 enc->profile = (VkVideoEncodeH264ProfileInfoKHR) {
717 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_KHR,
718 .pNext = pnext,
719 .stdProfileIdc = ff_vk_h264_profile_to_vk(avctx->profile),
720 };
721 profile->pNext = &enc->profile;
722
723 /* Set level */
724 if (avctx->level == AV_LEVEL_UNKNOWN)
725 avctx->level = enc->common.opts.level;
726
727 /* User has explicitly specified a profile. */
728 if (avctx->profile != AV_PROFILE_UNKNOWN)
729 return 0;
730
731 av_log(avctx, AV_LOG_DEBUG, "Supported profiles:\n");
732 for (int i = 0; i < nb_profiles; i++) {
733 enc->profile.stdProfileIdc = ff_vk_h264_profile_to_vk(known_profiles[i]);
734 ret = vk->GetPhysicalDeviceVideoCapabilitiesKHR(s->hwctx->phys_dev,
735 profile,
736 &caps);

Callers

nothing calls this directly

Calls 4

av_pix_fmt_desc_getFunction · 0.85
ff_vk_h264_profile_to_vkFunction · 0.85
av_logFunction · 0.85
avcodec_profile_nameFunction · 0.85

Tested by

no test coverage detected