[FFmpeg-cvslog] avfilter/f_interleave: fix some issues with interleaving

Paul B Mahol git at videolan.org
Tue Sep 15 18:23:19 EEST 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Sep 15 17:17:15 2020 +0200| [2524e64dbe4b39644b14bfa943461fd011fafb56] | committer: Paul B Mahol

avfilter/f_interleave: fix some issues with interleaving

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

 libavfilter/f_interleave.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index a18bbe79b3..024657c024 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -65,17 +65,35 @@ static int activate(AVFilterContext *ctx)
     InterleaveContext *s = ctx->priv;
     int64_t q_pts, pts = INT64_MAX;
     int i, nb_eofs = 0, input_idx = -1;
+    int first_eof = 0;
+    int64_t rpts;
+    int status;
     int nb_inputs_with_frames = 0;
 
     FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
 
+    for (i = 0; i < ctx->nb_inputs; i++) {
+        int is_eof = !!ff_inlink_acknowledge_status(ctx->inputs[i], &status, &rpts);
+
+        nb_eofs += is_eof;
+        if (i == 0)
+            first_eof = is_eof;
+    }
+
+    if ((nb_eofs > 0 && s->duration_mode == DURATION_SHORTEST) ||
+        (nb_eofs == ctx->nb_inputs && s->duration_mode == DURATION_LONGEST) ||
+        (first_eof && s->duration_mode == DURATION_FIRST)) {
+        ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
+        return 0;
+    }
+
     for (i = 0; i < ctx->nb_inputs; i++) {
         if (!ff_inlink_queued_frames(ctx->inputs[i]))
             continue;
         nb_inputs_with_frames++;
     }
 
-    if (nb_inputs_with_frames > 0) {
+    if (nb_inputs_with_frames >= ctx->nb_inputs - nb_eofs) {
         for (i = 0; i < ctx->nb_inputs; i++) {
             AVFrame *frame;
 
@@ -115,16 +133,6 @@ static int activate(AVFilterContext *ctx)
         }
     }
 
-    for (i = 0; i < ctx->nb_inputs; i++)
-        nb_eofs += !!ff_outlink_get_status(ctx->inputs[i]);
-
-    if ((nb_eofs > 0 && s->duration_mode == DURATION_SHORTEST) ||
-        (nb_eofs == ctx->nb_inputs && s->duration_mode == DURATION_LONGEST) ||
-        (ff_outlink_get_status(ctx->inputs[0]) && s->duration_mode == DURATION_FIRST)) {
-        ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-        return 0;
-    }
-
     for (i = 0; i < ctx->nb_inputs; i++) {
         if (ff_inlink_queued_frames(ctx->inputs[i]))
             continue;
@@ -135,7 +143,7 @@ static int activate(AVFilterContext *ctx)
         }
     }
 
-    if (i) {
+    if (i == ctx->nb_inputs - nb_eofs && ff_outlink_frame_wanted(outlink)) {
         ff_filter_set_ready(ctx, 100);
         return 0;
     }



More information about the ffmpeg-cvslog mailing list