1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/af_amix: Don't needlessly reallocate table

Replace using ff_add_format() repeatedly by a single call to
ff_make_format_list(). (Right now this also fixes a memleak: If the
first ff_add_format() succeeds and a subsequent call fails, the list
leaks.)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-08-07 16:08:42 +02:00
parent c4beb0783b
commit 27f35fd121

View File

@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx)
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
{ {
AVFilterFormats *formats = NULL; static const enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
AV_SAMPLE_FMT_NONE
};
AVFilterChannelLayouts *layouts; AVFilterChannelLayouts *layouts;
int ret; int ret;
@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx)
goto fail; goto fail;
} }
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 || if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 0 ||
(ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 ||
(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL )) < 0 ||
(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP)) < 0 ||
(ret = ff_set_common_formats (ctx, formats)) < 0 ||
(ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 || (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||
(ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
goto fail; goto fail;