And ensure the buffer is synced between threads. Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/h2645_sei.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 33390d389d..9ed2fc5596 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -42,6 +42,7 @@ #include "golomb.h" #include "h2645_sei.h" #include "itut35.h" +#include "refstruct.h" #define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI) #define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI) @@ -495,11 +496,10 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type, case SEI_TYPE_DISPLAY_ORIENTATION: return decode_display_orientation(&h->display_orientation, gb); case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS: - if (!h->film_grain_characteristics) { - h->film_grain_characteristics = av_mallocz(sizeof(*h->film_grain_characteristics)); - if (!h->film_grain_characteristics) - return AVERROR(ENOMEM); - } + ff_refstruct_unref(&h->film_grain_characteristics); + h->film_grain_characteristics = ff_refstruct_allocz(sizeof(*h->film_grain_characteristics)); + if (!h->film_grain_characteristics) + return AVERROR(ENOMEM); return decode_film_grain_characteristics(h->film_grain_characteristics, codec_id, gb); case SEI_TYPE_FRAME_PACKING_ARRANGEMENT: return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id); @@ -556,6 +556,9 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src) } dst->aom_film_grain.enable = src->aom_film_grain.enable; + ff_refstruct_replace(&dst->film_grain_characteristics, + src->film_grain_characteristics); + return 0; } @@ -930,5 +933,5 @@ void ff_h2645_sei_reset(H2645SEI *s) ff_aom_film_grain_uninit_params(&s->aom_film_grain); - av_freep(&s->film_grain_characteristics); + ff_refstruct_unref(&s->film_grain_characteristics); } -- 2.47.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".