From d9f39a790e2977f01ea020678dde27391cafff7f Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 17 Jan 2023 05:02:02 +0100 Subject: [PATCH 28/92] 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 d120aaeae1..a18dc6cc79 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2984,6 +2984,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, @@ -2997,6 +2998,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, @@ -3011,6 +3013,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, @@ -3477,6 +3480,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); @@ -3628,6 +3632,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; @@ -3705,6 +3713,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 && avctx->hwaccel->flush) avctx->hwaccel->flush(avctx); } diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index ddb6e2b5d9..514fc4daa4 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -514,6 +514,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