You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
vulkan_h264: use VK_KHR_video_maintenance2 if available
This avoids having to copy and update the entire SPS/PPS stack.
This commit is contained in:
@ -365,12 +365,15 @@ static int vk_h264_start_frame(AVCodecContext *avctx,
|
|||||||
int err;
|
int err;
|
||||||
int dpb_slot_index = 0;
|
int dpb_slot_index = 0;
|
||||||
H264Context *h = avctx->priv_data;
|
H264Context *h = avctx->priv_data;
|
||||||
H264Picture *pic = h->cur_pic_ptr;
|
|
||||||
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_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;
|
H264VulkanDecodePicture *hp = pic->hwaccel_picture_private;
|
||||||
FFVulkanDecodePicture *vp = &hp->vp;
|
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);
|
err = vk_h264_create_params(avctx, &dec->session_params);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
@ -506,20 +509,45 @@ static int vk_h264_decode_slice(AVCodecContext *avctx,
|
|||||||
static int vk_h264_end_frame(AVCodecContext *avctx)
|
static int vk_h264_end_frame(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
const H264Context *h = avctx->priv_data;
|
const H264Context *h = avctx->priv_data;
|
||||||
|
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
|
||||||
|
FFVulkanDecodeShared *ctx = dec->shared_ctx;
|
||||||
|
|
||||||
H264Picture *pic = h->cur_pic_ptr;
|
H264Picture *pic = h->cur_pic_ptr;
|
||||||
H264VulkanDecodePicture *hp = pic->hwaccel_picture_private;
|
H264VulkanDecodePicture *hp = pic->hwaccel_picture_private;
|
||||||
FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
|
|
||||||
FFVulkanDecodePicture *vp = &hp->vp;
|
FFVulkanDecodePicture *vp = &hp->vp;
|
||||||
FFVulkanDecodePicture *rvp[H264_MAX_PICTURE_COUNT] = { 0 };
|
FFVulkanDecodePicture *rvp[H264_MAX_PICTURE_COUNT] = { 0 };
|
||||||
AVFrame *rav[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)
|
if (!hp->h264_pic_info.sliceCount)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!vp->slices_buf)
|
if (!vp->slices_buf)
|
||||||
return AVERROR(EINVAL);
|
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);
|
int err = vk_h264_create_params(avctx, &dec->session_params);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
Reference in New Issue
Block a user