[FFmpeg-cvslog] lavfi/af_amix: make sure the output does not depend on input ordering

Paul B Mahol git at videolan.org
Tue Nov 14 19:19:50 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Oct 28 13:41:01 2023 +0200| [7282137f48c3e71734a2aa55c51b3096a1a63b5f] | committer: Anton Khirnov

lavfi/af_amix: make sure the output does not depend on input ordering

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavfilter/af_amix.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index aa42514106..120a97f48c 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -394,6 +394,8 @@ static int request_samples(AVFilterContext *ctx, int min_samples)
     int i;
 
     av_assert0(s->nb_inputs > 1);
+    if (min_samples == 1 && s->duration_mode == DURATION_FIRST)
+        min_samples = av_audio_fifo_size(s->fifos[0]);
 
     for (i = 1; i < s->nb_inputs; i++) {
         if (!(s->input_state[i] & INPUT_ON) ||
@@ -402,6 +404,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples)
         if (av_audio_fifo_size(s->fifos[i]) >= min_samples)
             continue;
         ff_inlink_request_frame(ctx->inputs[i]);
+        return 0;
     }
     return output_frame(ctx->outputs[0]);
 }
@@ -471,17 +474,13 @@ static int activate(AVFilterContext *ctx)
 
         if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) {
             if (status == AVERROR_EOF) {
-                if (i == 0) {
-                    s->input_state[i] = 0;
+                s->input_state[i] |= INPUT_EOF;
+                if (av_audio_fifo_size(s->fifos[i]) == 0) {
+                    s->input_state[i] &= ~INPUT_ON;
                     if (s->nb_inputs == 1) {
                         ff_outlink_set_status(outlink, status, pts);
                         return 0;
                     }
-                } else {
-                    s->input_state[i] |= INPUT_EOF;
-                    if (av_audio_fifo_size(s->fifos[i]) == 0) {
-                        s->input_state[i] = 0;
-                    }
                 }
             }
         }



More information about the ffmpeg-cvslog mailing list