mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
vulkan_encode: set the quality level in session parameters
While running this command ./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y It hit this validation error: Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle = 0x8f000000008f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle = 0xfd00000000fd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR; | MessageID = 0x5dc3dd39 | vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for VkVideoSessionKHR 0x8f000000008f[] does not match the encode quality level (0) VkVideoSessionParametersKHR 0xfd00000000fd[] was created with. The Vulkan spec states: The bound video session parameters object must have been created with the currently set video encode quality level for the bound video session at the time the command is executed on the device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318) This patch adds a new function helper for creating session parameters, which also sets the quality level and it's called by the H.264 and H.265 Vulkan encoders.
This commit is contained in:
parent
39c640e1d6
commit
2bcc124e1a
4 changed files with 42 additions and 36 deletions
|
|
@ -1023,3 +1023,37 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx,
|
||||
void *codec_params_pnext)
|
||||
{
|
||||
VkResult ret;
|
||||
FFVulkanFunctions *vk = &ctx->s.vkfn;
|
||||
FFVulkanContext *s = &ctx->s;
|
||||
|
||||
VkVideoEncodeQualityLevelInfoKHR q_info;
|
||||
VkVideoSessionParametersCreateInfoKHR session_params_create;
|
||||
|
||||
q_info = (VkVideoEncodeQualityLevelInfoKHR) {
|
||||
.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR,
|
||||
.pNext = codec_params_pnext,
|
||||
.qualityLevel = ctx->opts.quality,
|
||||
};
|
||||
session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
|
||||
.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
|
||||
.pNext = &q_info,
|
||||
.videoSession = ctx->common.session,
|
||||
.videoSessionParametersTemplate = VK_NULL_HANDLE,
|
||||
};
|
||||
|
||||
/* Create session parameters */
|
||||
ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create,
|
||||
s->hwctx->alloc, &ctx->session_params);
|
||||
if (ret != VK_SUCCESS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n",
|
||||
ff_vk_ret2str(ret));
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue