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.)
Unified · Split
| @@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx) · 587 unmodified lines | ||
| 588 | 588 | |
| 589 | 589 | static 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 | 596 | AVFilterChannelLayouts *layouts; |
| 593 | 597 | int ret; |
| 594 | 598 | |
| @@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx) · 3 unmodified lines | ||
| 598 | 602 | goto fail; |
| 599 | 603 | } |
| 600 | 604 | |
| 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 || | |
| 606 | 606 | (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 || |
| 607 | 607 | (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) |
| 608 | 608 | goto fail; |