History

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.)

Andreas Rheinhardt committed 6 years ago

Commit 27f35fd1 parent c4beb071 file · +6 −6Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/af_amix.c+6−6
@@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx) · 587 unmodified lines
588588
589589 static int query_formats(AVFilterContext *ctx)
590590 {
591− AVFilterFormats *formats = NULL;
591+ static const enum AVSampleFormat sample_fmts[] = {
592+ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
593+ AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
594+ AV_SAMPLE_FMT_NONE
595+ };
592596 AVFilterChannelLayouts *layouts;
593597 int ret;
594598
@@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx) · 3 unmodified lines
598602 goto fail;
599603 }
600604
601− if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 ||
602− (ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 ||
603− (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL )) < 0 ||
604− (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP)) < 0 ||
605− (ret = ff_set_common_formats (ctx, formats)) < 0 ||
605+ if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 0 ||
606606 (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||
607607 (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
608608 goto fail;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t