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
588 588
589static int query_formats(AVFilterContext *ctx)589static int query_formats(AVFilterContext *ctx)
590{590{
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 };
592 AVFilterChannelLayouts *layouts;596 AVFilterChannelLayouts *layouts;
593 int ret;597 int ret;
594 598
@@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx) · 3 unmodified lines
598 goto fail;602 goto fail;
599 }603 }
600 604
601 if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 ||605 if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 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 ||
606 (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||606 (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||
607 (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)607 (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
608 goto fail;608 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