Module: libav
Branch: release/9
Commit: ddeb6eeeb1c1343ef40d276335e58a6d75ebd5ba

Author:    Anton Khirnov <[email protected]>
Committer: Reinhard Tartler <[email protected]>
Date:      Tue Apr 16 21:53:56 2013 +0200

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:[email protected]

Signed-off-by: Diego Biurrun <[email protected]>
(cherry picked from commit 9bfc6e02bae9de354fb9ba09a8a140e83eeadf7d)

Signed-off-by: Reinhard Tartler <[email protected]>

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

---

 libavfilter/fifo.c |   36 +++++++++++++++++++-----------------
 1 files 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);
             }

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to