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

Function vulkan_encode_prores_submit_frame

libavcodec/proresenc_kostya_vulkan.c:368–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368static int vulkan_encode_prores_submit_frame(AVCodecContext *avctx, FFVkExecContext *exec,
369 AVFrame *frame, int picture_idx)
370{
371 ProresVulkanContext *pv = avctx->priv_data;
372 ProresContext *ctx = &pv->ctx;
373 VulkanEncodeProresFrameData *pd = exec->opaque;
374 FFVulkanContext *vkctx = &pv->vkctx;
375 FFVulkanFunctions *vk = &vkctx->vkfn;
376 int err = 0, nb_img_bar = 0, i, is_chroma;
377 int min_quant = ctx->profile_info->min_quant;
378 int max_quant = ctx->profile_info->max_quant;
379 int subgroup_size = vkctx->subgroup_props.maxSubgroupSize;
380 int estimate_dim_x = ctx->alpha_bits ? subgroup_size : (subgroup_size / 3) * 3;
381 int transfer_slices = vkctx->extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY;
382 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(vkctx->frames->sw_format);
383 VkImageView views[AV_NUM_DATA_POINTERS];
384 VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS];
385 FFVkBuffer *pkt_vk_buf, *slice_data_buf, *slice_score_buf, *frame_size_buf;
386 SliceDataInfo slice_data_info;
387 EncodeSliceInfo encode_info;
388 FFVulkanShader *shd;
389
390 /* Start recording */
391 ff_vk_exec_start(vkctx, exec);
392
393 /* Get a pooled buffer for writing output data */
394 RET(ff_vk_get_pooled_buffer(vkctx, &pv->pkt_buf_pool, &pd->out_data_ref[picture_idx],
395 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
396 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
397 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, NULL,
398 ctx->frame_size_upper_bound + FF_INPUT_BUFFER_MIN_SIZE,
399 transfer_slices ? VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
400 : (VK_MEMORY_PROPERTY_HOST_CACHED_BIT |
401 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
402 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)));
403 pkt_vk_buf = (FFVkBuffer*)pd->out_data_ref[picture_idx]->data;
404 ff_vk_exec_add_dep_buf(vkctx, exec, &pd->out_data_ref[picture_idx], 1, 1);
405
406 /* Allocate buffer for writing slice data */
407 RET(ff_vk_get_pooled_buffer(vkctx, &pv->slice_data_buf_pool, &pd->slice_data_ref[picture_idx],
408 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
409 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, NULL,
410 ctx->slices_per_picture * sizeof(SliceData),
411 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
412 slice_data_buf = (FFVkBuffer*)pd->slice_data_ref[picture_idx]->data;
413 ff_vk_exec_add_dep_buf(vkctx, exec, &pd->slice_data_ref[picture_idx], 1, 1);
414
415 /* Allocate buffer for writing slice scores */
416 RET(ff_vk_get_pooled_buffer(vkctx, &pv->slice_score_buf_pool, &pd->slice_score_ref[picture_idx],
417 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
418 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, NULL,
419 ctx->slices_per_picture * sizeof(SliceScore),
420 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
421 slice_score_buf = (FFVkBuffer*)pd->slice_score_ref[picture_idx]->data;
422 ff_vk_exec_add_dep_buf(vkctx, exec, &pd->slice_score_ref[picture_idx], 1, 1);
423
424 /* Allocate buffer for writing frame size */
425 RET(ff_vk_get_pooled_buffer(vkctx, &pv->frame_size_buf_pool, &pd->frame_size_ref[picture_idx],

Callers 1

Calls 12

av_pix_fmt_desc_getFunction · 0.85
ff_vk_exec_startFunction · 0.85
ff_vk_get_pooled_bufferFunction · 0.85
ff_vk_exec_add_dep_bufFunction · 0.85
ff_vk_exec_add_dep_frameFunction · 0.85
ff_vk_create_imageviewsFunction · 0.85
ff_vk_frame_barrierFunction · 0.85
ff_vk_exec_bind_shaderFunction · 0.85
ff_vk_shader_update_imgFunction · 0.85

Tested by

no test coverage detected