[FFmpeg-devel] [PATCH] avfilter/fifo: fix failed assertion

Muhammad Faiz mfcc64 at gmail.com
Tue Oct 13 10:54:24 CEST 2015


-------------- next part --------------
From 93ba60f844d8e81435eeefe6cc7cac2d79d518c6 Mon Sep 17 00:00:00 2001
From: Muhammad Faiz <mfcc64 at gmail.com>
Date: Tue, 13 Oct 2015 15:09:17 +0700
Subject: [PATCH] avfilter/fifo: fix failed assertion

some filters make fifo filter fail:
at least showcqt and showwaves (i don't check all)
command:
ffmpeg -loglevel debug -filter_complex "amovie=audio.mp3, showcqt, fifo" -f null -y /dev/null
message:
Assertion fifo->root.next failed at libavfilter/fifo.c:240
Aborted
---
 libavfilter/fifo.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index e477cff..ae670e2 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -187,9 +187,9 @@ static int return_audio_frame(AVFilterContext *ctx)
         }
 
         while (s->out->nb_samples < s->allocated_samples) {
-            int len;
+            int len, must_break = 0;
 
-            if (!s->root.next) {
+            while (!s->root.next) {
                 ret = ff_request_frame(ctx->inputs[0]);
                 if (ret == AVERROR_EOF) {
                     av_samples_set_silence(s->out->extended_data,
@@ -198,11 +198,13 @@ static int return_audio_frame(AVFilterContext *ctx)
                                            s->out->nb_samples,
                                            nb_channels, link->format);
                     s->out->nb_samples = s->allocated_samples;
+                    must_break = 1;
                     break;
                 } else if (ret < 0)
                     return ret;
-                av_assert0(s->root.next); // If ff_request_frame() succeeded then we should have a frame
             }
+            if (must_break)
+                break;
             head = s->root.next->frame;
 
             len = FFMIN(s->allocated_samples - s->out->nb_samples,
@@ -231,13 +233,12 @@ static int request_frame(AVFilterLink *outlink)
     FifoContext *fifo = outlink->src->priv;
     int ret = 0;
 
-    if (!fifo->root.next) {
+    while (!fifo->root.next) {
         if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) {
             if (ret == AVERROR_EOF && outlink->request_samples)
                 return return_audio_frame(outlink->src);
             return ret;
         }
-        av_assert0(fifo->root.next);
     }
 
     if (outlink->request_samples) {
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list