Before this, they were only added to the delayed release queue and not
freed until later. This could lead to unnecessary memory use or buffer
exhaustion.
---
 libavcodec/pthread.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 2e4c6a8..7c17b99 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -884,9 +884,13 @@ 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;
+    for (int i = 0; i < avctx->thread_count; i++) {
+        PerThreadContext *p = &fctx->threads[i];
+        // Make sure decode flush calls with size=0 won't return old frames
+        p->got_frame = 0;
+
+        release_delayed_buffers(p);
+    }
 }
 
 static int *allocate_progress(PerThreadContext *p)
-- 
1.7.9.2

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to