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

Function get_plane_buf

libavutil/hwcontext_vulkan.c:4345–4382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4343}
4344
4345static int get_plane_buf(AVHWFramesContext *hwfc, AVBufferRef **dst,
4346 AVFrame *swf, VkBufferImageCopy *region, int upload)
4347{
4348 int err;
4349 uint32_t p_w, p_h;
4350 VulkanFramesPriv *fp = hwfc->hwctx;
4351 VulkanDevicePriv *p = hwfc->device_ctx->hwctx;
4352 const int planes = av_pix_fmt_count_planes(swf->format);
4353 VkBufferUsageFlags buf_usage = upload ? VK_BUFFER_USAGE_TRANSFER_SRC_BIT :
4354 VK_BUFFER_USAGE_TRANSFER_DST_BIT;
4355
4356 size_t buf_offset = 0;
4357 for (int i = 0; i < planes; i++) {
4358 get_plane_wh(&p_w, &p_h, swf->format, swf->width, swf->height, i);
4359
4360 region[i] = (VkBufferImageCopy) {
4361 .bufferOffset = buf_offset,
4362 .bufferRowLength = FFALIGN(swf->linesize[i],
4363 p->props.properties.limits.optimalBufferCopyRowPitchAlignment),
4364 .bufferImageHeight = p_h,
4365 .imageSubresource.layerCount = 1,
4366 .imageExtent = (VkExtent3D){ p_w, p_h, 1 },
4367 /* Rest of the fields adjusted/filled in later */
4368 };
4369
4370 buf_offset += FFALIGN(p_h*region[i].bufferRowLength,
4371 p->props.properties.limits.optimalBufferCopyOffsetAlignment);
4372 }
4373
4374 err = ff_vk_get_pooled_buffer(&p->vkctx, &fp->tmp, dst, buf_usage,
4375 NULL, buf_offset,
4376 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
4377 p->vkctx.host_cached_flag);
4378 if (err < 0)
4379 return err;
4380
4381 return 0;
4382}
4383
4384static int host_map_frame(AVHWFramesContext *hwfc, AVBufferRef **dst, int *nb_bufs,
4385 AVFrame *swf, VkBufferImageCopy *region, int upload)

Callers 1

vulkan_transfer_frameFunction · 0.85

Calls 3

av_pix_fmt_count_planesFunction · 0.85
get_plane_whFunction · 0.85
ff_vk_get_pooled_bufferFunction · 0.85

Tested by

no test coverage detected