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

Function copy_buffer_data

libavutil/hwcontext_vulkan.c:4302–4343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4300}
4301
4302static int copy_buffer_data(AVHWFramesContext *hwfc, AVBufferRef *buf,
4303 AVFrame *swf, VkBufferImageCopy *region,
4304 int planes, int upload)
4305{
4306 int err;
4307 VulkanDevicePriv *p = hwfc->device_ctx->hwctx;
4308 FFVkBuffer *vkbuf = (FFVkBuffer *)buf->data;
4309
4310 if (upload) {
4311 for (int i = 0; i < planes; i++)
4312 av_image_copy_plane(vkbuf->mapped_mem + region[i].bufferOffset,
4313 region[i].bufferRowLength,
4314 swf->data[i],
4315 swf->linesize[i],
4316 swf->linesize[i],
4317 region[i].imageExtent.height);
4318
4319 err = ff_vk_flush_buffer(&p->vkctx, vkbuf, 0, VK_WHOLE_SIZE, 1);
4320 if (err != VK_SUCCESS) {
4321 av_log(hwfc, AV_LOG_ERROR, "Failed to flush buffer data: %s\n",
4322 av_err2str(err));
4323 return AVERROR_EXTERNAL;
4324 }
4325 } else {
4326 err = ff_vk_flush_buffer(&p->vkctx, vkbuf, 0, VK_WHOLE_SIZE, 0);
4327 if (err != VK_SUCCESS) {
4328 av_log(hwfc, AV_LOG_ERROR, "Failed to invalidate buffer data: %s\n",
4329 av_err2str(err));
4330 return AVERROR_EXTERNAL;
4331 }
4332
4333 for (int i = 0; i < planes; i++)
4334 av_image_copy_plane(swf->data[i],
4335 swf->linesize[i],
4336 vkbuf->mapped_mem + region[i].bufferOffset,
4337 region[i].bufferRowLength,
4338 swf->linesize[i],
4339 region[i].imageExtent.height);
4340 }
4341
4342 return 0;
4343}
4344
4345static int get_plane_buf(AVHWFramesContext *hwfc, AVBufferRef **dst,
4346 AVFrame *swf, VkBufferImageCopy *region, int upload)

Callers 1

vulkan_transfer_frameFunction · 0.85

Calls 3

av_image_copy_planeFunction · 0.85
ff_vk_flush_bufferFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected