vp8/mt: flush worker thread, not application thread context, on seek.
authorRonald S. Bultje <rsbultje@gmail.com>
Mon, 11 Jul 2011 04:23:09 +0000 (21:23 -0700)
committerReinhard Tartler <siretart@tauware.de>
Tue, 12 Jul 2011 16:13:35 +0000 (18:13 +0200)
This prevents a crash when seeking.
(cherry picked from commit d1cf45911935cc4fed9afd3a37d99616d31eb9da)

libavcodec/pthread.c
libavcodec/utils.c

index 08ef4ba..9fea9a0 100644 (file)
@@ -746,9 +746,12 @@ void ff_thread_flush(AVCodecContext *avctx)
     if (!avctx->thread_opaque) return;
 
     park_frame_worker_threads(fctx, avctx->thread_count);
-
-    if (fctx->prev_thread)
-        update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
+    if (fctx->prev_thread) {
+        if (fctx->prev_thread != &fctx->threads[0])
+            update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
+        if (avctx->codec->flush)
+            avctx->codec->flush(fctx->threads[0].avctx);
+    }
 
     fctx->next_decoding = fctx->next_finished = 0;
     fctx->delaying = 1;
index c32fda2..bbed726 100644 (file)
@@ -1058,7 +1058,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
     if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
         ff_thread_flush(avctx);
-    if(avctx->codec->flush)
+    else if(avctx->codec->flush)
         avctx->codec->flush(avctx);
 }