[FFmpeg-devel] [PATCH 5/5] avcodec/hevc/hevcdec: use the RefStruct API for h264db
James Almer
jamrial at gmail.com
Fri Oct 25 05:26:13 EEST 2024
And ensure the buffer is synced between threads.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/hevc/hevcdec.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index f2bdf6134e..357d7d0f1d 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3416,7 +3416,7 @@ static int hevc_frame_end(HEVCContext *s, HEVCLayerContext *l)
return AVERROR_BUG;
case AV_FILM_GRAIN_PARAMS_H274:
if (!s->h274db) {
- s->h274db = av_mallocz(sizeof(*s->h274db));
+ s->h274db = ff_refstruct_allocz(sizeof(*s->h274db));
if (!s->h274db)
return AVERROR(ENOMEM);
}
@@ -3849,7 +3849,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
av_buffer_unref(&s->rpu_buf);
av_freep(&s->md5_ctx);
- av_freep(&s->h274db);
+ ff_refstruct_unref(&s->h274db);
ff_container_fifo_free(&s->output_fifo);
@@ -3985,6 +3985,8 @@ static int hevc_update_thread_context(AVCodecContext *dst,
}
}
+ ff_refstruct_replace(&s->h274db, s0->h274db);
+
ret = ff_h2645_sei_ctx_replace(&s->sei.common, &s0->sei.common);
if (ret < 0)
return ret;
--
2.47.0
More information about the ffmpeg-devel
mailing list