[FFmpeg-cvslog] avfilter/avf_showspectrum: properly handle EOF case

Paul B Mahol git at videolan.org
Sat Jun 6 20:51:15 EEST 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Jun  6 19:07:35 2020 +0200| [7826fbfeaacca0d7af1387bbfd367db3c6dfd5d5] | committer: Paul B Mahol

avfilter/avf_showspectrum: properly handle EOF case

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

 libavfilter/avf_showspectrum.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index a4dd7b7879..e99f377fb0 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -1434,7 +1434,8 @@ static int activate(AVFilterContext *ctx)
         }
     }
 
-    if (s->outpicref && av_audio_fifo_size(s->fifo) >= s->win_size) {
+    if (s->outpicref && (av_audio_fifo_size(s->fifo) >= s->win_size ||
+        ff_outlink_get_status(inlink))) {
         AVFrame *fin = ff_get_audio_buffer(inlink, s->win_size);
         if (!fin)
             return AVERROR(ENOMEM);
@@ -1462,7 +1463,7 @@ static int activate(AVFilterContext *ctx)
 
         av_frame_free(&fin);
         av_audio_fifo_drain(s->fifo, s->hop_size);
-        if (ret <= 0)
+        if (ret <= 0 && !ff_outlink_get_status(inlink))
             return ret;
     }
 
@@ -1493,15 +1494,18 @@ static int activate(AVFilterContext *ctx)
     }
 
     FF_FILTER_FORWARD_STATUS(inlink, outlink);
-    if (ff_outlink_frame_wanted(outlink) && av_audio_fifo_size(s->fifo) < s->win_size) {
-        ff_inlink_request_frame(inlink);
+    if (av_audio_fifo_size(s->fifo) >= s->win_size ||
+        ff_outlink_get_status(inlink) == AVERROR_EOF) {
+        ff_filter_set_ready(ctx, 10);
         return 0;
     }
 
-    if (av_audio_fifo_size(s->fifo) >= s->win_size) {
-        ff_filter_set_ready(ctx, 10);
+    if (ff_outlink_frame_wanted(outlink) && av_audio_fifo_size(s->fifo) < s->win_size &&
+        ff_outlink_get_status(inlink) != AVERROR_EOF) {
+        ff_inlink_request_frame(inlink);
         return 0;
     }
+
     return FFERROR_NOT_READY;
 }
 



More information about the ffmpeg-cvslog mailing list