Commit 7b56dddd authored by Clément Bœsch's avatar Clément Bœsch

lavfi/amerge: fix input pad name behaviour.

This fixes two problems:
 - the invalid pad.name stack pointer after init() ends
 - the duplicated name for all inputs
parent 20361bcc
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include "libavutil/audioconvert.h" #include "libavutil/audioconvert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h" #include "libavutil/bprint.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libswresample/swresample.h" // only for SWR_CH_MAX #include "libswresample/swresample.h" // only for SWR_CH_MAX
...@@ -61,8 +62,10 @@ static av_cold void uninit(AVFilterContext *ctx) ...@@ -61,8 +62,10 @@ static av_cold void uninit(AVFilterContext *ctx)
AMergeContext *am = ctx->priv; AMergeContext *am = ctx->priv;
int i; 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); ff_bufqueue_discard_all(&am->in[i].queue);
av_freep(&ctx->input_pads[i].name);
}
av_freep(&am->in); av_freep(&am->in);
} }
...@@ -293,7 +296,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -293,7 +296,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
{ {
AMergeContext *am = ctx->priv; AMergeContext *am = ctx->priv;
int ret, i; int ret, i;
char name[16];
am->class = &amerge_class; am->class = &amerge_class;
av_opt_set_defaults(am); av_opt_set_defaults(am);
...@@ -306,13 +308,15 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -306,13 +308,15 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
if (!am->in) if (!am->in)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (i = 0; i < am->nb_inputs; i++) { for (i = 0; i < am->nb_inputs; i++) {
char *name = av_asprintf("in%d", i);
if (!name)
return AVERROR(ENOMEM);
AVFilterPad pad = { AVFilterPad pad = {
.name = name, .name = name,
.type = AVMEDIA_TYPE_AUDIO, .type = AVMEDIA_TYPE_AUDIO,
.filter_samples = filter_samples, .filter_samples = filter_samples,
.min_perms = AV_PERM_READ | AV_PERM_PRESERVE, .min_perms = AV_PERM_READ | AV_PERM_PRESERVE,
}; };
snprintf(name, sizeof(name), "in%d", i);
ff_insert_inpad(ctx, i, &pad); ff_insert_inpad(ctx, i, &pad);
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment