[FFmpeg-cvslog] afifo: fix request_samples on the last frame in certain cases

Anton Khirnov git at videolan.org
Sun May 12 14:30:25 CEST 2013


ffmpeg | branch: release/1.1 | Anton Khirnov <anton at khirnov.net> | Tue Apr 16 21:53:56 2013 +0200| [ddeb6eeeb1c1343ef40d276335e58a6d75ebd5ba] | committer: Reinhard Tartler

afifo: fix request_samples on the last frame in certain cases

The current code can fail to return the last frame if it contains
exactly the requested number of samples.

Fixes the join filter test, which previously did not include the last
408 samples in most cases.

CC:libav-stable at libav.org

Signed-off-by: Diego Biurrun <diego at biurrun.de>
(cherry picked from commit 9bfc6e02bae9de354fb9ba09a8a140e83eeadf7d)

Signed-off-by: Reinhard Tartler <siretart at tauware.de>

Conflicts:
	libavfilter/fifo.c
	tests/fate/filter-audio.mak

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

 libavfilter/fifo.c |   36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 88c44fe..3faa84f 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -184,8 +184,25 @@ static int return_audio_frame(AVFilterContext *ctx)
         }
 
         while (s->buf_out->audio->nb_samples < s->allocated_samples) {
-            int len = FFMIN(s->allocated_samples - s->buf_out->audio->nb_samples,
-                            head->audio->nb_samples);
+            int len;
+
+            if (!s->root.next &&
+                (ret = ff_request_frame(ctx->inputs[0])) < 0) {
+                if (ret == AVERROR_EOF) {
+                    av_samples_set_silence(s->buf_out->extended_data,
+                                           s->buf_out->audio->nb_samples,
+                                           s->allocated_samples -
+                                           s->buf_out->audio->nb_samples,
+                                           nb_channels, link->format);
+                    s->buf_out->audio->nb_samples = s->allocated_samples;
+                    break;
+                }
+                return ret;
+            }
+            head = s->root.next->buf;
+
+            len = FFMIN(s->allocated_samples - s->buf_out->audio->nb_samples,
+                        head->audio->nb_samples);
 
             av_samples_copy(s->buf_out->extended_data, head->extended_data,
                             s->buf_out->audio->nb_samples, 0, len, nb_channels,
@@ -195,21 +212,6 @@ static int return_audio_frame(AVFilterContext *ctx)
             if (len == head->audio->nb_samples) {
                 avfilter_unref_buffer(head);
                 queue_pop(s);
-
-                if (!s->root.next &&
-                    (ret = ff_request_frame(ctx->inputs[0])) < 0) {
-                    if (ret == AVERROR_EOF) {
-                        av_samples_set_silence(s->buf_out->extended_data,
-                                               s->buf_out->audio->nb_samples,
-                                               s->allocated_samples -
-                                               s->buf_out->audio->nb_samples,
-                                               nb_channels, link->format);
-                        s->buf_out->audio->nb_samples = s->allocated_samples;
-                        break;
-                    }
-                    return ret;
-                }
-                head = s->root.next->buf;
             } else {
                 buffer_offset(link, head, len);
             }



More information about the ffmpeg-cvslog mailing list