]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_amerge.c
Merge commit 'a854362b40f0e458db5a1fb0d2612a5702ee0ace'
[ffmpeg] / libavfilter / af_amerge.c
index 1b29e88757432b5dc4c3498ec19aa38eef58deb5..77ea297cd105efc63f33b3215a3cae95c48531ad 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "libavutil/audioconvert.h"
+#include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
 #include "libswresample/swresample.h" // only for SWR_CH_MAX
@@ -50,7 +51,7 @@ typedef struct {
 
 static const AVOption amerge_options[] = {
     { "inputs", "specify the number of inputs", OFFSET(nb_inputs),
-      AV_OPT_TYPE_INT, { .dbl = 2 }, 2, SWR_CH_MAX, FLAGS },
+      AV_OPT_TYPE_INT, { .i64 = 2 }, 2, SWR_CH_MAX, FLAGS },
     {0}
 };
 
@@ -61,8 +62,10 @@ static av_cold void uninit(AVFilterContext *ctx)
     AMergeContext *am = ctx->priv;
     int i;
 
-    for (i = 0; i < am->nb_inputs; i++)
+    for (i = 0; i < am->nb_inputs; i++) {
         ff_bufqueue_discard_all(&am->in[i].queue);
+        av_freep(&ctx->input_pads[i].name);
+    }
     av_freep(&am->in);
 }
 
@@ -99,7 +102,8 @@ static int query_formats(AVFilterContext *ctx)
     }
     if (overlap) {
         av_log(ctx, AV_LOG_WARNING,
-               "Inputs overlap: output layout will be meaningless\n");
+               "Input channel layouts overlap: "
+               "output layout will be determined by the number of distinct input channels\n");
         for (i = 0; i < nb_ch; i++)
             am->route[i] = i;
         outlayout = av_get_default_channel_layout(nb_ch);
@@ -293,7 +297,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
 {
     AMergeContext *am = ctx->priv;
     int ret, i;
-    char name[16];
 
     am->class = &amerge_class;
     av_opt_set_defaults(am);
@@ -306,13 +309,15 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
     if (!am->in)
         return AVERROR(ENOMEM);
     for (i = 0; i < am->nb_inputs; i++) {
+        char *name = av_asprintf("in%d", i);
         AVFilterPad pad = {
             .name             = name,
             .type             = AVMEDIA_TYPE_AUDIO,
             .filter_samples   = filter_samples,
             .min_perms        = AV_PERM_READ | AV_PERM_PRESERVE,
         };
-        snprintf(name, sizeof(name), "in%d", i);
+        if (!name)
+            return AVERROR(ENOMEM);
         ff_insert_inpad(ctx, i, &pad);
     }
     return 0;