vulkan_decode: port to the new queue family API

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Lynne 2024-08-11 03:27:46 +02:00 committed by Paul B Mahol
parent 90c4647828
commit 8b5d9dd07d
3 changed files with 28 additions and 9 deletions

View File

@ -1118,7 +1118,7 @@ int ff_vk_decode_uninit(AVCodecContext *avctx)
int ff_vk_decode_init(AVCodecContext *avctx)
{
int err, qf, cxpos = 0, cypos = 0, nb_q = 0;
int err, cxpos = 0, cypos = 0, nb_q = 0;
VkResult ret;
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
FFVulkanDecodeShared *ctx;
@ -1183,18 +1183,18 @@ int ff_vk_decode_init(AVCodecContext *avctx)
goto fail;
/* Create queue context */
qf = ff_vk_qf_init(s, &ctx->qf, VK_QUEUE_VIDEO_DECODE_BIT_KHR);
vk_desc = get_codecdesc(avctx->codec_id);
/* Check for support */
if (!(s->video_props[qf].videoCodecOperations & vk_desc->decode_op)) {
av_log(avctx, AV_LOG_ERROR, "Decoding %s not supported on the given "
"queue family %i!\n", avcodec_get_name(avctx->codec_id), qf);
return AVERROR(EINVAL);
err = ff_vk_video_qf_init(s, &ctx->qf,
VK_QUEUE_VIDEO_DECODE_BIT_KHR,
vk_desc->decode_op);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Decoding of %s is not supported by this device\n",
avcodec_get_name(avctx->codec_id));
return err;
}
/* Enable queries if supported */
if (s->query_props[qf].queryResultStatusSupport)
if (s->query_props[ctx->qf.queue_family].queryResultStatusSupport)
nb_q = 1;
session_create.flags = 0x0;

View File

@ -177,6 +177,20 @@ int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
}
}
int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps)
{
for (int i = 0; i < s->hwctx->nb_qf; i++) {
if ((s->hwctx->qf[i].flags & family) &&
(s->hwctx->qf[i].video_caps & caps)) {
qf->queue_family = s->hwctx->qf[i].idx;
qf->nb_queues = s->hwctx->qf[i].num;
return 0;
}
}
return AVERROR(ENOTSUP);
}
av_cold void ff_vk_video_common_uninit(FFVulkanContext *s,
FFVkVideoCommon *common)
{

View File

@ -54,6 +54,11 @@ VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc(const AVPixFm
*/
VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth);
/**
* Chooses a QF and loads it into a context.
*/
int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
VkQueueFlagBits family, VkVideoCodecOperationFlagBitsKHR caps);
/**
* Convert level from Vulkan to AV.