This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/7.1
in repository ffmpeg.

The following commit(s) were added to refs/heads/release/7.1 by this push:
     new a3a36f059a avfilter/af_amerge: fix possible crash with custom layouts
a3a36f059a is described below

commit a3a36f059a44f04e764d841f16c87823007a71fb
Author:     Marton Balint <[email protected]>
AuthorDate: Thu Nov 27 23:57:20 2025 +0100
Commit:     Marton Balint <[email protected]>
CommitDate: Sun Dec 7 21:17:23 2025 +0100

    avfilter/af_amerge: fix possible crash with custom layouts
    
    The check if a native layout can be created from the sources was incomplete 
and
    casued a crash with custom layouts if the layout contained a native channel
    multiple times, as in this example command line:
    
    ffmpeg -lavfi "sine[a0];sine,pan=FL+FL[a1];[a0][a1]amerge[aout]" -map 
"[aout]" -t 1 -f framecrc -
    
    Signed-off-by: Marton Balint <[email protected]>
    (cherry picked from commit e8b10a9b09fff6fa09178634bededf14a6ea598c)
---
 libavfilter/af_amerge.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c
index 16507299b5..dccbbd8415 100644
--- a/libavfilter/af_amerge.c
+++ b/libavfilter/af_amerge.c
@@ -77,7 +77,7 @@ static int query_formats(AVFilterContext *ctx)
     AVChannelLayout *inlayout[SWR_CH_MAX] = { NULL }, outlayout = { 0 };
     uint64_t outmask = 0;
     AVFilterChannelLayouts *layouts;
-    int i, ret, overlap = 0, nb_ch = 0;
+    int i, ret, nb_ch = 0;
 
     for (i = 0; i < s->nb_inputs; i++) {
         if (!ctx->inputs[i]->incfg.channel_layouts ||
@@ -92,15 +92,11 @@ static int query_formats(AVFilterContext *ctx)
             av_channel_layout_describe(inlayout[i], buf, sizeof(buf));
             av_log(ctx, AV_LOG_INFO, "Using \"%s\" for input %d\n", buf, i + 
1);
         }
-        s->in[i].nb_ch = FF_LAYOUT2COUNT(inlayout[i]);
-        if (s->in[i].nb_ch) {
-            overlap++;
-        } else {
-            s->in[i].nb_ch = inlayout[i]->nb_channels;
-            if (av_channel_layout_subset(inlayout[i], outmask))
-                overlap++;
-            outmask |= inlayout[i]->order == AV_CHANNEL_ORDER_NATIVE ?
-                       inlayout[i]->u.mask : 0;
+        s->in[i].nb_ch = inlayout[i]->nb_channels;
+        for (int j = 0; j < s->in[i].nb_ch; j++) {
+            enum AVChannel id = 
av_channel_layout_channel_from_index(inlayout[i], j);
+            if (id >= 0 && id < 64)
+                outmask |= (1ULL << id);
         }
         nb_ch += s->in[i].nb_ch;
     }
@@ -108,7 +104,7 @@ static int query_formats(AVFilterContext *ctx)
         av_log(ctx, AV_LOG_ERROR, "Too many channels (max %d)\n", SWR_CH_MAX);
         return AVERROR(EINVAL);
     }
-    if (overlap) {
+    if (av_popcount64(outmask) != nb_ch) {
         av_log(ctx, AV_LOG_WARNING,
                "Input channel layouts overlap: "
                "output layout will be determined by the number of distinct 
input channels\n");

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to