[FFmpeg-cvslog] lavfi/fifo: fix flushing when using request_samples

Anton Khirnov git at videolan.org
Tue Aug 6 09:40:23 CEST 2013


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Aug  4 12:10:23 2013 +0200| [3799376dd3373ee255651ed542c75b15665801a8] | committer: Anton Khirnov

lavfi/fifo: fix flushing when using request_samples

If any samples are still buffered when request_frame returns EOF, they
won't be returned currently.

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

 libavfilter/fifo.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 8d981ce..a58ce9f 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -147,10 +147,14 @@ static int return_audio_frame(AVFilterContext *ctx)
 {
     AVFilterLink *link = ctx->outputs[0];
     FifoContext *s = ctx->priv;
-    AVFrame *head = s->root.next->frame;
+    AVFrame *head = s->root.next ? s->root.next->frame : NULL;
     AVFrame *out;
     int ret;
 
+    /* if head is NULL then we're flushing the remaining samples in out */
+    if (!head && !s->out)
+        return AVERROR_EOF;
+
     if (!s->out &&
         head->nb_samples >= link->request_samples &&
         calc_ptr_alignment(head) >= 32) {
@@ -227,8 +231,11 @@ static int request_frame(AVFilterLink *outlink)
     int ret = 0;
 
     if (!fifo->root.next) {
-        if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0)
+        if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) {
+            if (ret == AVERROR_EOF && outlink->request_samples)
+                return return_audio_frame(outlink->src);
             return ret;
+        }
     }
 
     if (outlink->request_samples) {



More information about the ffmpeg-cvslog mailing list