From 61f412eea3fbcb1e2a8625796760c0e24fa3fb83 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 17 Jan 2023 05:01:45 +0100 Subject: [PATCH 27/92] h264dec: add hwaccel_params_buf --- libavcodec/h264_slice.c | 4 ++++ libavcodec/h264dec.c | 4 ++++ libavcodec/h264dec.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 579f074c42..19c10915d1 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -347,6 +347,10 @@ int ff_h264_update_thread_context(AVCodecContext *dst, return ret; } + ret = av_buffer_replace(&h->hwaccel_params_buf, h1->hwaccel_params_buf); + if (ret < 0) + return ret; + ret = av_buffer_replace(&h->ps.pps_ref, h1->ps.pps_ref); if (ret < 0) return ret; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 0aee724c0d..6559593195 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -341,6 +341,7 @@ static av_cold int h264_decode_end(AVCodecContext *avctx) H264Context *h = avctx->priv_data; int i; + av_buffer_unref(&h->hwaccel_params_buf); ff_h264_remove_all_refs(h); ff_h264_free_tables(h); @@ -470,6 +471,7 @@ static void h264_decode_flush(AVCodecContext *avctx) ff_h264_flush_change(h); ff_h264_sei_uninit(&h->sei); + av_buffer_unref(&h->hwaccel_params_buf); for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) ff_h264_unref_picture(h, &h->DPB[i]); @@ -669,6 +671,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) avpriv_request_sample(avctx, "data partitioning"); break; case H264_NAL_SEI: + av_buffer_unref(&h->hwaccel_params_buf); if (h->setup_finished) { avpriv_request_sample(avctx, "Late SEI"); break; @@ -682,6 +685,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) break; case H264_NAL_SPS: { GetBitContext tmp_gb = nal->gb; + av_buffer_unref(&h->hwaccel_params_buf); if (avctx->hwaccel && avctx->hwaccel->decode_params) { ret = avctx->hwaccel->decode_params(avctx, nal->type, diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 9a1ec1bace..d7352c15d1 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -341,6 +341,8 @@ typedef struct H264Context { H264Picture cur_pic; H264Picture last_pic_for_ec; + AVBufferRef *hwaccel_params_buf; + H264SliceContext *slice_ctx; int nb_slice_ctx; int nb_slice_ctx_queued; -- 2.39.2