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

Function vulkan_transfer_frame

libavutil/hwcontext_vulkan.c:4560–4719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4558}
4559
4560static int vulkan_transfer_frame(AVHWFramesContext *hwfc,
4561 AVFrame *swf, AVFrame *hwf,
4562 int upload)
4563{
4564 int err;
4565 VulkanFramesPriv *fp = hwfc->hwctx;
4566 AVVulkanFramesContext *hwctx = &fp->p;
4567 VulkanDevicePriv *p = hwfc->device_ctx->hwctx;
4568 FFVulkanFunctions *vk = &p->vkctx.vkfn;
4569
4570 int host_mapped = 0;
4571
4572 AVVkFrame *hwf_vk = (AVVkFrame *)hwf->data[0];
4573 VkBufferImageCopy region[AV_NUM_DATA_POINTERS]; // always one per plane
4574
4575 const int planes = av_pix_fmt_count_planes(swf->format);
4576 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(swf->format);
4577 const int nb_images = ff_vk_count_images(hwf_vk);
4578
4579 VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS];
4580 int nb_img_bar = 0;
4581
4582 AVBufferRef *bufs[AV_NUM_DATA_POINTERS];
4583 int nb_bufs = 0;
4584
4585 VkCommandBuffer cmd_buf;
4586 FFVkExecContext *exec;
4587
4588 /* Sanity checking */
4589 if ((swf->format != AV_PIX_FMT_NONE && !av_vkfmt_from_pixfmt(swf->format))) {
4590 av_log(hwfc, AV_LOG_ERROR, "Unsupported software frame pixel format!\n");
4591 return AVERROR(EINVAL);
4592 }
4593
4594 if (swf->width > hwfc->width || swf->height > hwfc->height)
4595 return AVERROR(EINVAL);
4596
4597 if (hwctx->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT &&
4598 !(p->dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY))
4599 return vulkan_transfer_host(hwfc, hwf, swf, upload);
4600
4601 for (int i = 0; i < av_pix_fmt_count_planes(swf->format); i++) {
4602 uint32_t p_w, p_h;
4603 get_plane_wh(&p_w, &p_h, swf->format, swf->width, swf->height, i);
4604
4605 /* Buffer region for this plane */
4606 region[i] = (VkBufferImageCopy) {
4607 .bufferOffset = 0,
4608 .bufferRowLength = swf->linesize[i],
4609 .bufferImageHeight = p_h,
4610 .imageSubresource.layerCount = 1,
4611 .imageExtent = (VkExtent3D){ p_w, p_h, 1 },
4612 /* Rest of the fields adjusted/filled in later */
4613 };
4614 }
4615
4616 /* Setup buffers first */
4617 if (p->vkctx.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY && !p->avoid_host_import) {

Callers 2

vulkan_transfer_data_toFunction · 0.85

Calls 15

av_pix_fmt_count_planesFunction · 0.85
av_pix_fmt_desc_getFunction · 0.85
ff_vk_count_imagesFunction · 0.85
av_logFunction · 0.85
vulkan_transfer_hostFunction · 0.85
get_plane_whFunction · 0.85
host_map_frameFunction · 0.85
get_plane_bufFunction · 0.85
copy_buffer_dataFunction · 0.85
ff_vk_exec_getFunction · 0.85
ff_vk_exec_startFunction · 0.85
ff_vk_exec_add_dep_frameFunction · 0.85

Tested by

no test coverage detected