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

Function create_frame

libavutil/hwcontext_vulkan.c:2703–2810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2701}
2702
2703static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
2704 VkImageTiling tiling, VkImageUsageFlagBits usage,
2705 VkImageCreateFlags flags, int nb_layers,
2706 void *create_pnext)
2707{
2708 int err;
2709 VkResult ret;
2710 AVVulkanFramesContext *hwfc_vk = hwfc->hwctx;
2711 AVHWDeviceContext *ctx = hwfc->device_ctx;
2712 VulkanDevicePriv *p = ctx->hwctx;
2713 AVVulkanDeviceContext *hwctx = &p->p;
2714 FFVulkanFunctions *vk = &p->vkctx.vkfn;
2715 AVVkFrame *f;
2716
2717 VkSemaphoreTypeCreateInfo sem_type_info = {
2718 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
2719 .semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE,
2720 .initialValue = 0,
2721 };
2722 VkSemaphoreCreateInfo sem_spawn = {
2723 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
2724 .pNext = &sem_type_info,
2725 };
2726
2727 VkExportSemaphoreCreateInfo ext_sem_info_opaque = {
2728 .sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO,
2729#ifdef _WIN32
2730 .handleTypes = IsWindows8OrGreater()
2731 ? VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT
2732 : VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT,
2733#else
2734 .handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT,
2735#endif
2736 };
2737
2738 /* Check if exporting is supported before chaining any structs */
2739 if (p->ext_sem_props_opaque.externalSemaphoreFeatures & VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT) {
2740 if (p->vkctx.extensions & (FF_VK_EXT_EXTERNAL_WIN32_SEM | FF_VK_EXT_EXTERNAL_FD_SEM))
2741 ff_vk_link_struct(&sem_type_info, &ext_sem_info_opaque);
2742 }
2743
2744 f = av_vk_frame_alloc();
2745 if (!f) {
2746 av_log(ctx, AV_LOG_ERROR, "Unable to allocate memory for AVVkFrame!\n");
2747 return AVERROR(ENOMEM);
2748 }
2749
2750 // TODO: check width and height for alignment in case of multiplanar (must be mod-2 if subsampled)
2751
2752 /* Create the images */
2753 for (int i = 0; (hwfc_vk->format[i] != VK_FORMAT_UNDEFINED); i++) {
2754 VkImageCreateInfo create_info = {
2755 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
2756 .pNext = create_pnext,
2757 .imageType = VK_IMAGE_TYPE_2D,
2758 .format = hwfc_vk->format[i],
2759 .extent.depth = 1,
2760 .mipLevels = 1,

Callers 2

vulkan_pool_allocFunction · 0.70
vulkan_frames_initFunction · 0.70

Calls 6

ff_vk_link_structFunction · 0.85
av_logFunction · 0.85
get_plane_whFunction · 0.85
ff_vk_ret2strFunction · 0.85
vulkan_frame_freeFunction · 0.85
av_vk_frame_allocFunction · 0.70

Tested by

no test coverage detected