[FFmpeg-cvslog] threads: fix old frames returned after avcodec_flush_buffers()

Uoti Urpala git at videolan.org
Sat Mar 17 23:52:39 CET 2012


ffmpeg | branch: master | Uoti Urpala <uau at glyph.nonexistent.invalid> | Fri Mar 16 05:42:26 2012 +0200| [05b9a89ed71846be266f283b9d188e0fcb2f0323] | committer: Ronald S. Bultje

threads: fix old frames returned after avcodec_flush_buffers()

Calling avcodec_flush_buffers() and then avcodec_decode_video2() with
a 0-sized packet (to get remaining buffered frames) could incorrectly
return an old frame from before the avcodec_flush_buffers() call. Add
a loop in ff_thread_flush() to zero the got_frame field of each thread
to ensure the old frames will not be returned.

Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=05b9a89ed71846be266f283b9d188e0fcb2f0323
---

 libavcodec/pthread.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 4a02823..2e4c6a8 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -884,6 +884,9 @@ void ff_thread_flush(AVCodecContext *avctx)
     fctx->next_decoding = fctx->next_finished = 0;
     fctx->delaying = 1;
     fctx->prev_thread = NULL;
+    // Make sure decode flush calls with size=0 won't return old frames
+    for (int i = 0; i < avctx->thread_count; i++)
+        fctx->threads[i].got_frame = 0;
 }
 
 static int *allocate_progress(PerThreadContext *p)



More information about the ffmpeg-cvslog mailing list