@@ -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;
And ensure the buffer is synced between threads. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/hevc/hevcdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)