| 592 | } |
| 593 | |
| 594 | static 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, |
nothing calls this directly
no test coverage detected