From 756f3a7daf18f402ec56a7f52ea8742d905edf18 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 17 Jan 2023 05:02:02 +0100 Subject: [PATCH 71/72] hevcdec: add hwaccel_params_buf --- libavcodec/hevcdec.c | 9 +++++++++ libavcodec/hevcdec.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 7c9b46240c..5df831688c 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2969,6 +2969,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) switch (s->nal_unit_type) { case HEVC_NAL_VPS: + av_buffer_unref(&s->hwaccel_params_buf); if (s->avctx->hwaccel && s->avctx->hwaccel->decode_params) { ret = s->avctx->hwaccel->decode_params(s->avctx, nal->type, @@ -2982,6 +2983,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) goto fail; break; case HEVC_NAL_SPS: + av_buffer_unref(&s->hwaccel_params_buf); if (s->avctx->hwaccel && s->avctx->hwaccel->decode_params) { ret = s->avctx->hwaccel->decode_params(s->avctx, nal->type, @@ -2996,6 +2998,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) goto fail; break; case HEVC_NAL_PPS: + av_buffer_unref(&s->hwaccel_params_buf); if (s->avctx->hwaccel && s->avctx->hwaccel->decode_params) { ret = s->avctx->hwaccel->decode_params(s->avctx, nal->type, @@ -3455,6 +3458,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) ff_dovi_ctx_unref(&s->dovi_ctx); av_buffer_unref(&s->rpu_buf); + av_buffer_unref(&s->hwaccel_params_buf); av_freep(&s->md5_ctx); @@ -3606,6 +3610,10 @@ static int hevc_update_thread_context(AVCodecContext *dst, if (ret < 0) return ret; + ret = av_buffer_replace(&s->hwaccel_params_buf, s0->hwaccel_params_buf); + if (ret < 0) + return ret; + ret = av_buffer_replace(&s->rpu_buf, s0->rpu_buf); if (ret < 0) return ret; @@ -3683,6 +3691,7 @@ static void hevc_decode_flush(AVCodecContext *avctx) s->max_ra = INT_MAX; s->eos = 1; + av_buffer_unref(&s->hwaccel_params_buf); if (avctx->hwaccel->flush) avctx->hwaccel->flush(avctx); } diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 15c4113bdd..774cd95947 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -509,6 +509,8 @@ typedef struct HEVCContext { uint8_t *sao_pixel_buffer_h[3]; uint8_t *sao_pixel_buffer_v[3]; + AVBufferRef *hwaccel_params_buf; + HEVCParamSets ps; HEVCSEI sei; struct AVMD5 *md5_ctx; -- 2.39.2