diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-04-16 21:53:56 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2013-05-04 10:44:51 +0200 |
commit | ddeb6eeeb1c1343ef40d276335e58a6d75ebd5ba (patch) | |
tree | dbd805ee649d272726601fbc5da179c7f8eabfd9 /libavfilter | |
parent | 5aac0811100ee5db9d03d7488b69cc321854da70 (diff) | |
download | ffmpeg-ddeb6eeeb1c1343ef40d276335e58a6d75ebd5ba.tar.gz |
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@libav.org
Signed-off-by: Diego Biurrun <diego@biurrun.de>
(cherry picked from commit 9bfc6e02bae9de354fb9ba09a8a140e83eeadf7d)
Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Conflicts:
libavfilter/fifo.c
tests/fate/filter-audio.mak
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/fifo.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c index 88c44fe3b9..3faa84fd55 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); } |