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

Function init_profile

libavcodec/vulkan_encode_av1.c:588–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588static int init_profile(AVCodecContext *avctx,
589 VkVideoProfileInfoKHR *profile, void *pnext)
590{
591 VkResult ret;
592 VulkanEncodeAV1Context *enc = avctx->priv_data;
593 FFVulkanEncodeContext *ctx = &enc->common;
594 FFVulkanContext *s = &ctx->s;
595 FFVulkanFunctions *vk = &ctx->s.vkfn;
596 FFHWBaseEncodeContext *base_ctx = &ctx->base;
597
598 VkVideoEncodeAV1CapabilitiesKHR av1_caps = {
599 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_CAPABILITIES_KHR,
600 };
601 VkVideoEncodeCapabilitiesKHR enc_caps = {
602 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR,
603 .pNext = &av1_caps,
604 };
605 VkVideoCapabilitiesKHR caps = {
606 .sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR,
607 .pNext = &enc_caps,
608 };
609
610 /* In order of preference */
611 int last_supported = AV_PROFILE_UNKNOWN;
612 static const int known_profiles[] = {
613 AV_PROFILE_AV1_MAIN,
614 AV_PROFILE_AV1_HIGH,
615 AV_PROFILE_AV1_PROFESSIONAL,
616 };
617 int nb_profiles = FF_ARRAY_ELEMS(known_profiles);
618
619 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->frames->sw_format);
620 if (!desc)
621 return AVERROR(EINVAL);
622
623 if (s->frames->sw_format == AV_PIX_FMT_NV12 ||
624 s->frames->sw_format == AV_PIX_FMT_P010)
625 nb_profiles = 1;
626
627 enc->profile = (VkVideoEncodeAV1ProfileInfoKHR) {
628 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_PROFILE_INFO_KHR,
629 .pNext = pnext,
630 .stdProfile = ff_vk_av1_profile_to_vk(avctx->profile),
631 };
632 profile->pNext = &enc->profile;
633
634 /* Set level */
635 if (avctx->level == AV_LEVEL_UNKNOWN) {
636 const AV1LevelDescriptor *level;
637 float framerate = 0.0;
638
639 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
640 framerate = av_q2d(avctx->framerate);
641
642 level = ff_av1_guess_level(avctx->bit_rate, enc->seq_tier,
643 base_ctx->surface_width, base_ctx->surface_height,
644 enc->tile_rows * enc->tile_cols,
645 enc->tile_cols, framerate);

Callers

nothing calls this directly

Calls 7

av_pix_fmt_desc_getFunction · 0.85
ff_vk_av1_profile_to_vkFunction · 0.85
av_q2dFunction · 0.85
ff_av1_guess_levelFunction · 0.85
av_logFunction · 0.85
ff_vk_av1_level_to_vkFunction · 0.85
avcodec_profile_nameFunction · 0.85

Tested by

no test coverage detected