[FFmpeg-cvslog] avfilter/af_surround: drain input at EOF

Paul B Mahol git at videolan.org
Fri Mar 16 13:39:39 EET 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Mar 16 12:30:17 2018 +0100| [5941179e28b996b9ddfc18bf4981af14d621dc83] | committer: Paul B Mahol

avfilter/af_surround: drain input at EOF

Signed-off-by: Paul B Mahol <onemda at gmail.com>

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

 libavfilter/af_surround.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
index 460e18cd5a..f29afecbfb 100644
--- a/libavfilter/af_surround.c
+++ b/libavfilter/af_surround.c
@@ -1390,6 +1390,27 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     return 0;
 }
 
+static int request_frame(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx = outlink->src;
+    AudioSurroundContext *s = ctx->priv;
+    int ret = 0;
+
+    ret = ff_request_frame(ctx->inputs[0]);
+
+    if (ret == AVERROR_EOF && av_audio_fifo_size(s->fifo) > 0 && av_audio_fifo_size(s->fifo) < s->buf_size) {
+        AVFrame *in;
+
+        in = ff_get_audio_buffer(outlink, s->buf_size - av_audio_fifo_size(s->fifo));
+        if (!in)
+            return AVERROR(ENOMEM);
+        ret = filter_frame(ctx->inputs[0], in);
+        av_audio_fifo_drain(s->fifo, s->buf_size);
+    }
+
+    return ret;
+}
+
 static av_cold void uninit(AVFilterContext *ctx)
 {
     AudioSurroundContext *s = ctx->priv;
@@ -1445,9 +1466,10 @@ static const AVFilterPad inputs[] = {
 
 static const AVFilterPad outputs[] = {
     {
-        .name         = "default",
-        .type         = AVMEDIA_TYPE_AUDIO,
-        .config_props = config_output,
+        .name          = "default",
+        .type          = AVMEDIA_TYPE_AUDIO,
+        .request_frame = request_frame,
+        .config_props  = config_output,
     },
     { NULL }
 };



More information about the ffmpeg-cvslog mailing list