[FFmpeg-devel] [PATCH] h264: Support multi-field closed captions by using AVBufferRef and not resetting per field

James Almer jamrial at gmail.com
Thu Aug 16 21:08:01 EEST 2018


On 8/16/2018 7:52 AM, joshdk at ob-encoder.com wrote:
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index ede9a1a6ea..7bbe65878f 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -429,6 +429,12 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
>                         MAX_DELAYED_PIC_COUNT + 2, h, h1);
>  
>      h->frame_recovered       = h1->frame_recovered;
> +    if (h1->sei.a53_caption.buf_ref) {
> +        h->sei.a53_caption.buf_ref = av_buffer_ref(h1->sei.a53_caption.buf_ref);
> +        av_buffer_unref(&h1->sei.a53_caption.buf_ref);
> +    }
> +    else
> +        h->sei.a53_caption.buf_ref = NULL;

Going back to this, and judging by similar buffers above, you probably
need to first unref h->sei.a53_caption.buf_ref unconditionally before
checking if you need to make it a reference to
h1->sei.a53_caption.buf_ref, the latter which should itself not be unreffed.

Could you corroborate this by running your samples through gcc-tsan or
clang-tsan?


More information about the ffmpeg-devel mailing list