[FFmpeg-cvslog] vulkan_h264: use VK_KHR_video_maintenance2 if available
Lynne
git at videolan.org
Mon Mar 17 09:52:13 EET 2025
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Fri Mar 14 13:41:10 2025 +0100| [53f156bccc4886b687f6433ed5e69cf827e9f666] | committer: Lynne
vulkan_h264: use VK_KHR_video_maintenance2 if available
This avoids having to copy and update the entire SPS/PPS stack.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53f156bccc4886b687f6433ed5e69cf827e9f666
---
libavcodec/vulkan_h264.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c
index 71cf2c3ad7..dc8b542e01 100644
--- a/libavcodec/vulkan_h264.c
+++ b/libavcodec/vulkan_h264.c
@@ -365,12 +365,15 @@ static int vk_h264_start_frame(AVCodecContext *avctx,
int err;
int dpb_slot_index = 0;
H264Context *h = avctx->priv_data;
- H264Picture *pic = h->cur_pic_ptr;
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
+ FFVulkanDecodeShared *ctx = dec->shared_ctx;
+
+ H264Picture *pic = h->cur_pic_ptr;
H264VulkanDecodePicture *hp = pic->hwaccel_picture_private;
FFVulkanDecodePicture *vp = &hp->vp;
- if (!dec->session_params) {
+ if (!dec->session_params &&
+ !(ctx->s.extensions & FF_VK_EXT_VIDEO_MAINTENANCE_2)) {
err = vk_h264_create_params(avctx, &dec->session_params);
if (err < 0)
return err;
@@ -506,20 +509,45 @@ static int vk_h264_decode_slice(AVCodecContext *avctx,
static int vk_h264_end_frame(AVCodecContext *avctx)
{
const H264Context *h = avctx->priv_data;
+ FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
+ FFVulkanDecodeShared *ctx = dec->shared_ctx;
+
H264Picture *pic = h->cur_pic_ptr;
H264VulkanDecodePicture *hp = pic->hwaccel_picture_private;
- FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
FFVulkanDecodePicture *vp = &hp->vp;
FFVulkanDecodePicture *rvp[H264_MAX_PICTURE_COUNT] = { 0 };
AVFrame *rav[H264_MAX_PICTURE_COUNT] = { 0 };
+#ifdef VK_KHR_video_maintenance2
+ StdVideoH264ScalingLists vksps_scaling;
+ StdVideoH264HrdParameters vksps_vui_header;
+ StdVideoH264SequenceParameterSetVui vksps_vui;
+ StdVideoH264SequenceParameterSet vksps;
+ StdVideoH264ScalingLists vkpps_scaling;
+ StdVideoH264PictureParameterSet vkpps;
+ VkVideoDecodeH264InlineSessionParametersInfoKHR h264_params;
+
+ if (ctx->s.extensions & FF_VK_EXT_VIDEO_MAINTENANCE_2) {
+ set_sps(h->ps.sps, &vksps_scaling,
+ &vksps_vui_header, &vksps_vui, &vksps);
+ set_pps(h->ps.pps, h->ps.sps, &vkpps_scaling, &vkpps);
+ h264_params = (VkVideoDecodeH264InlineSessionParametersInfoKHR) {
+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_INLINE_SESSION_PARAMETERS_INFO_KHR,
+ .pStdSPS = &vksps,
+ .pStdPPS = &vkpps,
+ };
+ hp->h264_pic_info.pNext = &h264_params;
+ }
+#endif
+
if (!hp->h264_pic_info.sliceCount)
return 0;
if (!vp->slices_buf)
return AVERROR(EINVAL);
- if (!dec->session_params) {
+ if (!dec->session_params &&
+ !(ctx->s.extensions & FF_VK_EXT_VIDEO_MAINTENANCE_2)) {
int err = vk_h264_create_params(avctx, &dec->session_params);
if (err < 0)
return err;
More information about the ffmpeg-cvslog
mailing list