diff options
author | Lynne <dev@lynne.ee> | 2023-06-21 18:24:55 +0200 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2023-06-22 18:17:54 +0200 |
commit | 4ff303a7b827de2179c6e346959e36960e57b5ba (patch) | |
tree | 6b903fb1ec88d718ea657db2221f867e9525fff6 /libavcodec/vulkan_av1.c | |
parent | 343716bd744a44cb15205af73c6e6ad0fdaa0b7b (diff) | |
download | ffmpeg-4ff303a7b827de2179c6e346959e36960e57b5ba.tar.gz |
vulkan_decode: simplify and make session parameter generation more robust
This commit scraps a bool to signal to recreate the session parameters,
but instead destroys them, forcing them to be recreated.
As this can happen between start_frame and end_frame, do this
at both places.
Diffstat (limited to 'libavcodec/vulkan_av1.c')
-rw-r--r-- | libavcodec/vulkan_av1.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 005998b1bd..e953096b89 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -229,12 +229,10 @@ static int vk_av1_start_frame(AVCodecContext *avctx, const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; - if (!dec->session_params || dec->params_changed) { - av_buffer_unref(&dec->session_params); + if (!dec->session_params) { err = vk_av1_create_params(avctx, &dec->session_params); if (err < 0) return err; - dec->params_changed = 0; } if (!ap->frame_id_set) { @@ -530,12 +528,19 @@ static int vk_av1_decode_slice(AVCodecContext *avctx, static int vk_av1_end_frame(AVCodecContext *avctx) { const AV1DecContext *s = avctx->priv_data; + FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; const AV1Frame *pic = &s->cur_frame; AV1VulkanDecodePicture *ap = pic->hwaccel_picture_private; FFVulkanDecodePicture *vp = &ap->vp; FFVulkanDecodePicture *rvp[AV1_NUM_REF_FRAMES] = { 0 }; AVFrame *rav[AV1_NUM_REF_FRAMES] = { 0 }; + if (!dec->session_params) { + int err = vk_av1_create_params(avctx, &dec->session_params); + if (err < 0) + return err; + } + for (int i = 0; i < vp->decode_info.referenceSlotCount; i++) { const AV1Frame *rp = ap->ref_src[i]; AV1VulkanDecodePicture *rhp = rp->hwaccel_picture_private; @@ -578,7 +583,7 @@ const AVHWAccel ff_av1_vulkan_hwaccel = { .frame_priv_data_size = sizeof(AV1VulkanDecodePicture), .init = &ff_vk_decode_init, .update_thread_context = &ff_vk_update_thread_context, - .decode_params = &ff_vk_params_changed, + .decode_params = &ff_vk_params_invalidate, .flush = &ff_vk_decode_flush, .uninit = &ff_vk_decode_uninit, .frame_params = &ff_vk_frame_params, |