From 5ec0bdf2c524224f30ba4786f47324970aed4aaa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 May 2015 21:54:47 +0200 Subject: h264: do not update the context fields copied between threads after finish_setup() Should fix a large number of possible races with frame threading. --- libavcodec/h264.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libavcodec/h264.c') diff --git a/libavcodec/h264.c b/libavcodec/h264.c index e39a119364..6fd238d444 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -950,8 +950,12 @@ static void decode_postinit(H264Context *h, int setup_finished) h->next_output_pic->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_SEI); } - if (setup_finished && !h->avctx->hwaccel) + if (setup_finished && !h->avctx->hwaccel) { ff_thread_finish_setup(h->avctx); + + if (h->avctx->active_thread_type & FF_THREAD_FRAME) + h->setup_finished = 1; + } } int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) @@ -1618,6 +1622,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, int ret; h->flags = avctx->flags; + h->setup_finished = 0; /* end of stream, output what is still in the buffers */ out: -- cgit v1.2.3