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

Function ff_vk_decode_init

libavcodec/vulkan_decode.c:1291–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1289}
1290
1291int ff_vk_decode_init(AVCodecContext *avctx)
1292{
1293 int err;
1294 FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
1295 FFVulkanDecodeShared *ctx;
1296 FFVulkanContext *s;
1297 int async_depth;
1298 const VkVideoProfileInfoKHR *profile;
1299 const FFVulkanDecodeDescriptor *vk_desc;
1300
1301 VkVideoSessionCreateInfoKHR session_create = {
1302 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR,
1303 };
1304
1305 err = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VULKAN);
1306 if (err < 0)
1307 return err;
1308
1309 /* Initialize contexts */
1310 ctx = dec->shared_ctx;
1311 s = &ctx->s;
1312
1313 err = ff_vk_init(s, avctx, NULL, avctx->hw_frames_ctx);
1314 if (err < 0)
1315 return err;
1316
1317 vk_desc = get_codecdesc(avctx->codec_id);
1318
1319 profile = get_video_profile(ctx, avctx->codec_id);
1320 if ((vk_desc->queue_flags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) && !profile) {
1321 av_log(avctx, AV_LOG_ERROR, "Video profile missing from frames context!");
1322 return AVERROR(EINVAL);
1323 }
1324
1325 /* Create queue context */
1326 vk_desc = get_codecdesc(avctx->codec_id);
1327 ctx->qf = ff_vk_qf_find(s, vk_desc->queue_flags, vk_desc->decode_op);
1328 if (!ctx->qf) {
1329 av_log(avctx, AV_LOG_ERROR, "Decoding of %s is not supported by this device\n",
1330 avcodec_get_name(avctx->codec_id));
1331 return err;
1332 }
1333
1334 session_create.queueFamilyIndex = ctx->qf->idx;
1335 session_create.maxCodedExtent = ctx->caps.maxCodedExtent;
1336 session_create.maxDpbSlots = ctx->caps.maxDpbSlots;
1337 session_create.maxActiveReferencePictures = ctx->caps.maxActiveReferencePictures;
1338 session_create.pictureFormat = s->hwfc->format[0];
1339 session_create.referencePictureFormat = session_create.pictureFormat;
1340 session_create.pStdHeaderVersion = &vk_desc->ext_props;
1341 session_create.pVideoProfile = profile;
1342#ifdef VK_KHR_video_maintenance2
1343 if (ctx->s.extensions & FF_VK_EXT_VIDEO_MAINTENANCE_2)
1344 session_create.flags = VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
1345#endif
1346
1347 /* Create decode exec context for this specific main thread.
1348 * 2 async contexts per thread was experimentally determined to be optimal

Callers 4

vk_decode_prores_initFunction · 0.85
vk_decode_ffv1_initFunction · 0.85
vk_decode_dpx_initFunction · 0.85

Calls 15

ff_vk_initFunction · 0.85
get_codecdescFunction · 0.85
get_video_profileFunction · 0.85
av_logFunction · 0.85
ff_vk_qf_findFunction · 0.85
avcodec_get_nameFunction · 0.85
ff_vk_exec_pool_initFunction · 0.85
ff_vk_video_common_initFunction · 0.85
av_hwframe_ctx_allocFunction · 0.85
ff_vk_find_structFunction · 0.85
av_hwframe_ctx_initFunction · 0.85

Tested by

no test coverage detected