diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-04 23:39:25 -0400 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-14 10:04:01 -0400 |
commit | 6aaac24d72a7da631173209841a3944fcb4a3309 (patch) | |
tree | 4b475e1648073cd36acad767e54486722ac3c15f | |
parent | 8ededd583622359062622cf008144a1511d50bbd (diff) | |
download | ffmpeg-6aaac24d72a7da631173209841a3944fcb4a3309.tar.gz |
avfilter/all: propagate errors of functions from avfilter/formats
Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM).
This propagates the return values.
All of these were found by using av_warn_unused_result, demonstrating its utility.
Tested with FATE. I am least sure of the changes to avfilter/filtergraph,
since I don't know what/how reduce_format is intended to behave and how it should
react to errors.
Fixes: CID 1325680, 1325679, 1325678.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Previous version Reviewed-by: Nicolas George <george@nsup.org>
Previous version Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
63 files changed, 476 insertions, 436 deletions
diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c index b6c420a4a9..ac9dea8f64 100644 --- a/libavfilter/aeval.c +++ b/libavfilter/aeval.c @@ -350,36 +350,34 @@ static int aeval_query_formats(AVFilterContext *ctx) static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }; + int ret; // inlink supports any channel layout layouts = ff_all_channel_counts(); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; if (eval->same_chlayout) { layouts = ff_all_channel_counts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_set_common_channel_layouts(ctx, layouts); + if ((ret = ff_set_common_channel_layouts(ctx, layouts)) < 0) + return ret; } else { // outlink supports only requested output channel layout layouts = NULL; - ff_add_channel_layout(&layouts, + if ((ret = ff_add_channel_layout(&layouts, eval->out_channel_layout ? eval->out_channel_layout : - FF_COUNT2LAYOUT(eval->nb_channels)); - ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts); + FF_COUNT2LAYOUT(eval->nb_channels))) < 0) + return ret; + if ((ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts)) < 0) + return ret; } formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_samplerates(ctx, formats); - - return 0; + return ff_set_common_samplerates(ctx, formats); } static int aeval_config_output(AVFilterLink *outlink) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index 4fdcb09d2d..1439177bd0 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -57,9 +57,10 @@ static const AVOption aformat_options[] = { AVFILTER_DEFINE_CLASS(aformat); -#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \ +#define PARSE_FORMATS(str, type, list, add_to_list, unref_fn, get_fmt, none, desc) \ do { \ char *next, *cur = str, sep; \ + int ret; \ \ if (str && strchr(str, ',')) { \ av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "\ @@ -78,7 +79,10 @@ do { \ av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\ return AVERROR(EINVAL); \ } \ - add_to_list(&list, fmt); \ + if ((ret = add_to_list(&list, fmt)) < 0) { \ + unref_fn(&list); \ + return ret; \ + } \ \ cur = next; \ } \ @@ -95,11 +99,11 @@ static av_cold int init(AVFilterContext *ctx) AFormatContext *s = ctx->priv; PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, - ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); - PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, + ff_add_format, ff_formats_unref, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); + PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, ff_formats_unref, get_sample_rate, 0, "sample rate"); PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, - ff_add_channel_layout, av_get_channel_layout, 0, + ff_add_channel_layout, ff_channel_layouts_unref, av_get_channel_layout, 0, "channel layout"); return 0; diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c index e125895682..b56f32e13c 100644 --- a/libavfilter/af_agate.c +++ b/libavfilter/af_agate.c @@ -77,7 +77,8 @@ static int query_formats(AVFilterContext *ctx) AVFilterChannelLayouts *layouts; int ret; - ff_add_format(&formats, AV_SAMPLE_FMT_DBL); + if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL)) < 0) + return ret; ret = ff_set_common_formats(ctx, formats); if (ret < 0) return ret; diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index 410d6134d7..2b4edb09ff 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -78,7 +78,7 @@ static int query_formats(AVFilterContext *ctx) int64_t inlayout[SWR_CH_MAX], outlayout = 0; AVFilterFormats *formats; AVFilterChannelLayouts *layouts; - int i, overlap = 0, nb_ch = 0; + int i, ret, overlap = 0, nb_ch = 0; for (i = 0; i < s->nb_inputs; i++) { if (!ctx->inputs[i]->in_channel_layouts || @@ -125,17 +125,22 @@ static int query_formats(AVFilterContext *ctx) *(route[i]++) = out_ch_number++; } formats = ff_make_format_list(ff_packed_sample_fmts_array); - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; for (i = 0; i < s->nb_inputs; i++) { layouts = NULL; - ff_add_channel_layout(&layouts, inlayout[i]); - ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); + if ((ret = ff_add_channel_layout(&layouts, inlayout[i])) < 0) + return ret; + if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts)) < 0) + return ret; } layouts = NULL; - ff_add_channel_layout(&layouts, outlayout); - ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts); - ff_set_common_samplerates(ctx, ff_all_samplerates()); - return 0; + if ((ret = ff_add_channel_layout(&layouts, outlayout)) < 0) + return ret; + if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) + return ret; + + return ff_set_common_samplerates(ctx, ff_all_samplerates()); } static int config_output(AVFilterLink *outlink) diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index 9a3cbd4dcd..434dd907f6 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -537,12 +537,13 @@ static int query_formats(AVFilterContext *ctx) int ret; layouts = ff_all_channel_layouts(); - if (!layouts) return AVERROR(ENOMEM); - ff_add_format(&formats, AV_SAMPLE_FMT_FLT); - ff_add_format(&formats, AV_SAMPLE_FMT_FLTP); + if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT)) < 0) + return ret; + if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0) + return ret; ret = ff_set_common_formats(ctx, formats); if (ret < 0) return ret; diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index b5af70e775..028e105318 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -88,25 +88,23 @@ static int query_formats(AVFilterContext *ctx) AVFilterFormats *in_formats, *out_formats; AVFilterFormats *in_samplerates, *out_samplerates; AVFilterChannelLayouts *in_layouts, *out_layouts; + int ret; av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format); av_opt_get_int(aresample->swr, "osr", 0, &out_rate); av_opt_get_int(aresample->swr, "ocl", 0, &out_layout); in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); - if (!in_formats) - return AVERROR(ENOMEM); - ff_formats_ref (in_formats, &inlink->out_formats); + if ((ret = ff_formats_ref(in_formats, &inlink->out_formats)) < 0) + return ret; in_samplerates = ff_all_samplerates(); - if (!in_samplerates) - return AVERROR(ENOMEM); - ff_formats_ref (in_samplerates, &inlink->out_samplerates); + if ((ret = ff_formats_ref(in_samplerates, &inlink->out_samplerates)) < 0) + return ret; in_layouts = ff_all_channel_counts(); - if (!in_layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts)) < 0) + return ret; if(out_rate > 0) { int ratelist[] = { out_rate, -1 }; @@ -114,28 +112,25 @@ static int query_formats(AVFilterContext *ctx) } else { out_samplerates = ff_all_samplerates(); } - if (!out_samplerates) { - av_log(ctx, AV_LOG_ERROR, "Cannot allocate output samplerates.\n"); - return AVERROR(ENOMEM); - } - ff_formats_ref(out_samplerates, &outlink->in_samplerates); + if ((ret = ff_formats_ref(out_samplerates, &outlink->in_samplerates)) < 0) + return ret; if(out_format != AV_SAMPLE_FMT_NONE) { int formatlist[] = { out_format, -1 }; out_formats = ff_make_format_list(formatlist); } else out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); - ff_formats_ref(out_formats, &outlink->in_formats); + if ((ret = ff_formats_ref(out_formats, &outlink->in_formats)) < 0) + return ret; if(out_layout) { int64_t layout_list[] = { out_layout, -1 }; out_layouts = avfilter_make_format64_list(layout_list); } else out_layouts = ff_all_channel_counts(); - ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts); - return 0; + return ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts); } diff --git a/libavfilter/af_astreamsync.c b/libavfilter/af_astreamsync.c index becfe34074..d08da260fe 100644 --- a/libavfilter/af_astreamsync.c +++ b/libavfilter/af_astreamsync.c @@ -89,20 +89,23 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { - int i; + int i, ret; AVFilterFormats *formats, *rates; AVFilterChannelLayouts *layouts; for (i = 0; i < 2; i++) { formats = ctx->inputs[i]->in_formats; - ff_formats_ref(formats, &ctx->inputs[i]->out_formats); - ff_formats_ref(formats, &ctx->outputs[i]->in_formats); + if ((ret = ff_formats_ref(formats, &ctx->inputs[i]->out_formats)) < 0 || + (ret = ff_formats_ref(formats, &ctx->outputs[i]->in_formats)) < 0) + return ret; rates = ff_all_samplerates(); - ff_formats_ref(rates, &ctx->inputs[i]->out_samplerates); - ff_formats_ref(rates, &ctx->outputs[i]->in_samplerates); + if ((ret = ff_formats_ref(rates, &ctx->inputs[i]->out_samplerates)) < 0 || + (ret = ff_formats_ref(rates, &ctx->outputs[i]->in_samplerates)) < 0) + return ret; layouts = ctx->inputs[i]->in_channel_layouts; - ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); - ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts)) < 0 || + (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[i]->in_channel_layouts)) < 0) + return ret; } return 0; } diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c index 37b47b2d7b..9e95a98d00 100644 --- a/libavfilter/af_channelmap.c +++ b/libavfilter/af_channelmap.c @@ -289,18 +289,15 @@ static int channelmap_query_formats(AVFilterContext *ctx) ChannelMapContext *s = ctx->priv; AVFilterChannelLayouts *layouts; AVFilterChannelLayouts *channel_layouts = NULL; + int ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - - ff_add_channel_layout(&channel_layouts, s->output_layout); - - ff_set_common_formats(ctx, ff_planar_sample_fmts()); - ff_set_common_samplerates(ctx, ff_all_samplerates()); - - ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts); - ff_channel_layouts_ref(channel_layouts, &ctx->outputs[0]->in_channel_layouts); + if ((ret = ff_add_channel_layout (&channel_layouts, s->output_layout )) < 0 || + (ret = ff_set_common_formats (ctx , ff_planar_sample_fmts() )) < 0 || + (ret = ff_set_common_samplerates (ctx , ff_all_samplerates() )) < 0 || + (ret = ff_channel_layouts_ref (layouts , &ctx->inputs[0]->out_channel_layouts)) < 0 || + (ret = ff_channel_layouts_ref (channel_layouts , &ctx->outputs[0]->in_channel_layouts)) < 0) + return ret; return 0; } diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c index b3756e2be9..f50414984a 100644 --- a/libavfilter/af_channelsplit.c +++ b/libavfilter/af_channelsplit.c @@ -82,20 +82,23 @@ static int query_formats(AVFilterContext *ctx) { ChannelSplitContext *s = ctx->priv; AVFilterChannelLayouts *in_layouts = NULL; - int i; + int i, ret; - ff_set_common_formats (ctx, ff_planar_sample_fmts()); - ff_set_common_samplerates(ctx, ff_all_samplerates()); + if ((ret = ff_set_common_formats(ctx, ff_planar_sample_fmts())) < 0 || + (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) + return ret; - ff_add_channel_layout(&in_layouts, s->channel_layout); - ff_channel_layouts_ref(in_layouts, &ctx->inputs[0]->out_channel_layouts); + if ((ret = ff_add_channel_layout(&in_layouts, s->channel_layout)) < 0 || + (ret = ff_channel_layouts_ref(in_layouts, &ctx->inputs[0]->out_channel_layouts)) < 0) + return ret; for (i = 0; i < ctx->nb_outputs; i++) { AVFilterChannelLayouts *out_layouts = NULL; uint64_t channel = av_channel_layout_extract_channel(s->channel_layout, i); - ff_add_channel_layout(&out_layouts, channel); - ff_channel_layouts_ref(out_layouts, &ctx->outputs[i]->in_channel_layouts); + if ((ret = ff_add_channel_layout(&out_layouts, channel)) < 0 || + (ret = ff_channel_layouts_ref(out_layouts, &ctx->outputs[i]->in_channel_layouts)) < 0) + return ret; } return 0; diff --git a/libavfilter/af_earwax.c b/libavfilter/af_earwax.c index c3109976f8..b0ba4cff65 100644 --- a/libavfilter/af_earwax.c +++ b/libavfilter/af_earwax.c @@ -78,15 +78,17 @@ typedef struct { static int query_formats(AVFilterContext *ctx) { static const int sample_rates[] = { 44100, -1 }; + int ret; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layout = NULL; - ff_add_format(&formats, AV_SAMPLE_FMT_S16); - ff_set_common_formats(ctx, formats); - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_set_common_channel_layouts(ctx, layout); - ff_set_common_samplerates(ctx, ff_make_format_list(sample_rates)); + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_S16 )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_STEREO )) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0 || + (ret = ff_set_common_samplerates (ctx , ff_make_format_list(sample_rates) )) < 0) + return ret; return 0; } diff --git a/libavfilter/af_extrastereo.c b/libavfilter/af_extrastereo.c index 9d23e88646..a746006f71 100644 --- a/libavfilter/af_extrastereo.c +++ b/libavfilter/af_extrastereo.c @@ -45,15 +45,15 @@ static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layout = NULL; + int ret; - ff_add_format(&formats, AV_SAMPLE_FMT_FLT); - ff_set_common_formats(ctx, formats); - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_set_common_channel_layouts(ctx, layout); + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_STEREO)) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); return ff_set_common_samplerates(ctx, formats); } diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c index 4c1f6a075c..f5a1c5060d 100644 --- a/libavfilter/af_join.c +++ b/libavfilter/af_join.c @@ -245,20 +245,21 @@ static int join_query_formats(AVFilterContext *ctx) { JoinContext *s = ctx->priv; AVFilterChannelLayouts *layouts = NULL; - int i; + int i, ret; - ff_add_channel_layout(&layouts, s->channel_layout); - ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts); + if ((ret = ff_add_channel_layout(&layouts, s->channel_layout)) < 0 || + (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) + return ret; for (i = 0; i < ctx->nb_inputs; i++) { layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts)) < 0) + return ret; } - ff_set_common_formats (ctx, ff_planar_sample_fmts()); - ff_set_common_samplerates(ctx, ff_all_samplerates()); + if ((ret = ff_set_common_formats(ctx, ff_planar_sample_fmts())) < 0 || + (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) + return ret; return 0; } diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index 9117cc09c9..1eb102c10a 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -227,27 +227,29 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layouts; + int ret; pan->pure_gains = are_gains_pure(pan); /* libswr supports any sample and packing formats */ - ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO)); + if ((ret = ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO))) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_samplerates(ctx, formats); + if ((ret = ff_set_common_samplerates(ctx, formats)) < 0) + return ret; // inlink supports any channel layout layouts = ff_all_channel_counts(); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; // outlink supports only requested output channel layout layouts = NULL; - ff_add_channel_layout(&layouts, + if ((ret = ff_add_channel_layout(&layouts, pan->out_channel_layout ? pan->out_channel_layout : - FF_COUNT2LAYOUT(pan->nb_output_channels)); - ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts); - return 0; + FF_COUNT2LAYOUT(pan->nb_output_channels))) < 0) + return ret; + return ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts); } static int config_props(AVFilterLink *link) diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c index c41985787d..c8f6f9666d 100644 --- a/libavfilter/af_replaygain.c +++ b/libavfilter/af_replaygain.c @@ -323,19 +323,21 @@ static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layout = NULL; - int i; + int i, ret; - ff_add_format(&formats, AV_SAMPLE_FMT_FLT); - ff_set_common_formats(ctx, formats); - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_set_common_channel_layouts(ctx, layout); + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_STEREO)) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0) + return ret; formats = NULL; - for (i = 0; i < FF_ARRAY_ELEMS(freqinfos); i++) - ff_add_format(&formats, freqinfos[i].sample_rate); - ff_set_common_samplerates(ctx, formats); + for (i = 0; i < FF_ARRAY_ELEMS(freqinfos); i++) { + if ((ret = ff_add_format(&formats, freqinfos[i].sample_rate)) < 0) + return ret; + } - return 0; + return ff_set_common_samplerates(ctx, formats); } static int config_input(AVFilterLink *inlink) diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index 375f480bcf..e3c6a20696 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -90,22 +90,25 @@ static int query_formats(AVFilterContext *ctx) { AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; + AVFilterFormats *in_formats, *out_formats, *in_samplerates, *out_samplerates; + AVFilterChannelLayouts *in_layouts, *out_layouts; + int ret; - AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); - AVFilterFormats *out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); - AVFilterFormats *in_samplerates = ff_all_samplerates(); - AVFilterFormats *out_samplerates = ff_all_samplerates(); - AVFilterChannelLayouts *in_layouts = ff_all_channel_layouts(); - AVFilterChannelLayouts *out_layouts = ff_all_channel_layouts(); - - ff_formats_ref(in_formats, &inlink->out_formats); - ff_formats_ref(out_formats, &outlink->in_formats); - - ff_formats_ref(in_samplerates, &inlink->out_samplerates); - ff_formats_ref(out_samplerates, &outlink->in_samplerates); + if (!(in_formats = ff_all_formats (AVMEDIA_TYPE_AUDIO)) || + !(out_formats = ff_all_formats (AVMEDIA_TYPE_AUDIO)) || + !(in_samplerates = ff_all_samplerates ( )) || + !(out_samplerates = ff_all_samplerates ( )) || + !(in_layouts = ff_all_channel_layouts ( )) || + !(out_layouts = ff_all_channel_layouts ( ))) + return AVERROR(ENOMEM); - ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts); - ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts); + if ((ret = ff_formats_ref (in_formats, &inlink->out_formats )) < 0 || + (ret = ff_formats_ref (out_formats, &outlink->in_formats )) < 0 || + (ret = ff_formats_ref (in_samplerates, &inlink->out_samplerates )) < 0 || + (ret = ff_formats_ref (out_samplerates, &outlink->in_samplerates )) < 0 || + (ret = ff_channel_layouts_ref (in_layouts, &inlink->out_channel_layouts)) < 0 || + (ret = ff_channel_layouts_ref (out_layouts, &outlink->in_channel_layouts)) < 0) + return ret; return 0; } diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c index f2157edbb0..29b3753691 100644 --- a/libavfilter/af_sidechaincompress.c +++ b/libavfilter/af_sidechaincompress.c @@ -229,28 +229,21 @@ static int query_formats(AVFilterContext *ctx) return AVERROR(EAGAIN); } - ff_add_channel_layout(&layouts, ctx->inputs[0]->in_channel_layouts->channel_layouts[0]); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts); + if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->in_channel_layouts->channel_layouts[0])) < 0 || + (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) + return ret; for (i = 0; i < 2; i++) { layouts = ff_all_channel_counts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts)) < 0) + return ret; } formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ret = ff_set_common_formats(ctx, formats); - if (ret < 0) + if ((ret = ff_set_common_formats(ctx, formats)) < 0) return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); return ff_set_common_samplerates(ctx, formats); } diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c index 6a3265d631..e19ada47d0 100644 --- a/libavfilter/af_stereotools.c +++ b/libavfilter/af_stereotools.c @@ -92,16 +92,15 @@ static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layout = NULL; + int ret; - ff_add_format(&formats, AV_SAMPLE_FMT_DBL); - ff_set_common_formats(ctx, formats); - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_set_common_channel_layouts(ctx, layout); + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_DBL )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_STEREO)) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - return ff_set_common_samplerates(ctx, formats); } diff --git a/libavfilter/af_stereowiden.c b/libavfilter/af_stereowiden.c index 7c5f2d4923..154a8b1538 100644 --- a/libavfilter/af_stereowiden.c +++ b/libavfilter/af_stereowiden.c @@ -55,15 +55,15 @@ static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layout = NULL; + int ret; - ff_add_format(&formats, AV_SAMPLE_FMT_FLT); - ff_set_common_formats(ctx, formats); - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_set_common_channel_layouts(ctx, layout); + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_STEREO)) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); return ff_set_common_samplerates(ctx, formats); } diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c index 28d4500a25..94bd0cab3a 100644 --- a/libavfilter/asrc_anullsrc.c +++ b/libavfilter/asrc_anullsrc.c @@ -80,10 +80,12 @@ static int query_formats(AVFilterContext *ctx) ANullContext *null = ctx->priv; int64_t chlayouts[] = { null->channel_layout, -1 }; int sample_rates[] = { null->sample_rate, -1 }; + int ret; - ff_set_common_formats (ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO)); - ff_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); - ff_set_common_samplerates (ctx, ff_make_format_list(sample_rates)); + if ((ret = ff_set_common_formats (ctx, ff_all_formats (AVMEDIA_TYPE_AUDIO))) < 0 || + (ret = ff_set_common_channel_layouts (ctx, avfilter_make_format64_list (chlayouts ))) < 0 || + (ret = ff_set_common_samplerates (ctx, ff_make_format_list (sample_rates ))) < 0) + return ret; return 0; } diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c index a99f2dc923..b3f83abd74 100644 --- a/libavfilter/asrc_flite.c +++ b/libavfilter/asrc_flite.c @@ -205,18 +205,20 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { FliteContext *flite = ctx->priv; + int ret; AVFilterChannelLayouts *chlayouts = NULL; int64_t chlayout = av_get_default_channel_layout(flite->wave->num_channels); AVFilterFormats *sample_formats = NULL; AVFilterFormats *sample_rates = NULL; - ff_add_channel_layout(&chlayouts, chlayout); - ff_set_common_channel_layouts(ctx, chlayouts); - ff_add_format(&sample_formats, AV_SAMPLE_FMT_S16); - ff_set_common_formats(ctx, sample_formats); - ff_add_format(&sample_rates, flite->wave->sample_rate); - ff_set_common_samplerates (ctx, sample_rates); + if ((ret = ff_add_channel_layout (&chlayouts , chlayout )) < 0 || + (ret = ff_set_common_channel_layouts (ctx , chlayouts )) < 0 || + (ret = ff_add_format (&sample_formats, AV_SAMPLE_FMT_S16 )) < 0 || + (ret = ff_set_common_formats (ctx , sample_formats )) < 0 || + (ret = ff_add_format (&sample_rates , flite->wave->sample_rate)) < 0 || + (ret = ff_set_common_samplerates (ctx , sample_rates )) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index 5a470cf921..7c1e9932a6 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -70,24 +70,21 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); - - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_channel_layouts_ref(layout, &inlink->out_channel_layouts); + if ((ret = ff_formats_ref (formats, &inlink->out_formats )) < 0 || + (ret = ff_add_channel_layout (&layout, AV_CH_LAYOUT_STEREO )) < 0 || + (ret = ff_channel_layouts_ref (layout , &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c index bc9e2356bc..30985f3d49 100644 --- a/libavfilter/avf_avectorscope.c +++ b/libavfilter/avf_avectorscope.c @@ -126,24 +126,21 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); - - ff_add_channel_layout(&layout, AV_CH_LAYOUT_STEREO); - ff_channel_layouts_ref(layout, &inlink->out_channel_layouts); + if ((ret = ff_formats_ref (formats, &inlink->out_formats )) < 0 || + (ret = ff_add_channel_layout (&layout, AV_CH_LAYOUT_STEREO )) < 0 || + (ret = ff_channel_layouts_ref (layout , &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index 8d736a424c..5a4b356ea8 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -80,6 +80,7 @@ static int query_formats(AVFilterContext *ctx) unsigned type, nb_str, idx0 = 0, idx, str, seg; AVFilterFormats *formats, *rates = NULL; AVFilterChannelLayouts *layouts = NULL; + int ret; for (type = 0; type < TYPE_ALL; type++) { nb_str = cat->nb_streams[type]; @@ -88,26 +89,26 @@ static int query_formats(AVFilterContext *ctx) /* Set the output formats */ formats = ff_all_formats(type); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &ctx->outputs[idx]->in_formats); + if ((ret = ff_formats_ref(formats, &ctx->outputs[idx]->in_formats)) < 0) + return ret; + if (type == AVMEDIA_TYPE_AUDIO) { rates = ff_all_samplerates(); - if (!rates) - return AVERROR(ENOMEM); - ff_formats_ref(rates, &ctx->outputs[idx]->in_samplerates); + if ((ret = ff_formats_ref(rates, &ctx->outputs[idx]->in_samplerates)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &ctx->outputs[idx]->in_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[idx]->in_channel_layouts)) < 0) + return ret; } /* Set the same formats for each corresponding input */ for (seg = 0; seg < cat->nb_segments; seg++) { - ff_formats_ref(formats, &ctx->inputs[idx]->out_formats); + if ((ret = ff_formats_ref(formats, &ctx->inputs[idx]->out_formats)) < 0) + return ret; if (type == AVMEDIA_TYPE_AUDIO) { - ff_formats_ref(rates, &ctx->inputs[idx]->out_samplerates); - ff_channel_layouts_ref(layouts, &ctx->inputs[idx]->out_channel_layouts); + if ((ret = ff_formats_ref(rates, &ctx->inputs[idx]->out_samplerates)) < 0 || + (ret = ff_channel_layouts_ref(layouts, &ctx->inputs[idx]->out_channel_layouts)) < 0) + return ret; } idx += ctx->nb_outputs; } diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index e939d8fb7a..ce42cd645a 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -136,28 +136,25 @@ static int query_formats(AVFilterContext *ctx) static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE }; static const int64_t channel_layouts[] = { AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO_DOWNMIX, -1 }; static const int samplerates[] = { 44100, 48000, -1 }; + int ret; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0) + return ret; layouts = avfilter_make_format64_list(channel_layouts); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_make_format_list(samplerates); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; /* set output video format */ formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c index 8961d3cce5..0f2ae22c4a 100644 --- a/libavfilter/avf_showfreqs.c +++ b/libavfilter/avf_showfreqs.c @@ -128,28 +128,25 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; /* set output video format */ formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 11c32463bf..936db605a6 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -126,28 +126,25 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }; + int ret; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; /* set output video format */ formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c index 9accfb068f..95b5388912 100644 --- a/libavfilter/avf_showvolume.c +++ b/libavfilter/avf_showvolume.c @@ -85,26 +85,23 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c index b75c6666c8..77ff913f3a 100644 --- a/libavfilter/avf_showwaves.c +++ b/libavfilter/avf_showwaves.c @@ -117,28 +117,25 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; + int ret; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0) + return ret; formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0) + return ret; /* set output video format */ formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index b42983140a..bc10665c3f 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -317,18 +317,15 @@ static int filter_query_formats(AVFilterContext *ctx) sanitize_channel_layouts(ctx, ctx->outputs[i]->in_channel_layouts); formats = ff_all_formats(type); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; if (type == AVMEDIA_TYPE_AUDIO) { samplerates = ff_all_samplerates(); - if (!samplerates) - return AVERROR(ENOMEM); - ff_set_common_samplerates(ctx, samplerates); + if ((ret = ff_set_common_samplerates(ctx, samplerates)) < 0) + return ret; chlayouts = ff_all_channel_layouts(); - if (!chlayouts) - return AVERROR(ENOMEM); - ff_set_common_channel_layouts(ctx, chlayouts); + if ((ret = ff_set_common_channel_layouts(ctx, chlayouts)) < 0) + return ret; } return 0; } @@ -728,7 +725,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) return 0; } -#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \ +#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format, unref_format) \ do { \ for (i = 0; i < filter->nb_inputs; i++) { \ AVFilterLink *link = filter->inputs[i]; \ @@ -769,9 +766,9 @@ static int reduce_formats_on_filter(AVFilterContext *filter) int i, j, k, ret = 0; REDUCE_FORMATS(int, AVFilterFormats, formats, formats, - nb_formats, ff_add_format); + nb_formats, ff_add_format, ff_formats_unref); REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats, - nb_formats, ff_add_format); + nb_formats, ff_add_format, ff_formats_unref); /* reduce channel layouts */ for (i = 0; i < filter->nb_inputs; i++) { @@ -795,7 +792,8 @@ static int reduce_formats_on_filter(AVFilterContext *filter) (!FF_LAYOUT2COUNT(fmt) || fmts->all_counts)) { /* Turn the infinite list into a singleton */ fmts->all_layouts = fmts->all_counts = 0; - ff_add_channel_layout(&outlink->in_channel_layouts, fmt); + if (ff_add_channel_layout(&outlink->in_channel_layouts, fmt) < 0) + ret = 1; break; } diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 3206bd9dfe..5db86abd8a 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -302,13 +302,13 @@ static int vsink_query_formats(AVFilterContext *ctx) CHECK_LIST_SIZE(pixel_fmts) if (buf->pixel_fmts_size) { for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++) - if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) { - ff_formats_unref(&formats); + if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) return ret; - } - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; } else { - ff_default_query_formats(ctx); + if ((ret = ff_default_query_formats(ctx)) < 0) + return ret; } return 0; @@ -346,25 +346,20 @@ static int asink_query_formats(AVFilterContext *ctx) if (buf->sample_fmts_size) { for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++) - if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) { - ff_formats_unref(&formats); + if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) return ret; - } - ff_set_common_formats(ctx, formats); + if ((ret = ff_set_common_formats(ctx, formats)) < 0) + return ret; } if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++) - if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) { - ff_channel_layouts_unref(&layouts); + if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) return ret; - } for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) - if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) { - ff_channel_layouts_unref(&layouts); + if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) return ret; - } if (buf->all_channel_counts) { if (layouts) av_log(ctx, AV_LOG_WARNING, @@ -372,17 +367,17 @@ static int asink_query_formats(AVFilterContext *ctx) else if (!(layouts = ff_all_channel_counts())) return AVERROR(ENOMEM); } - ff_set_common_channel_layouts(ctx, layouts); + if ((ret = ff_set_common_channel_layouts(ctx, layouts)) < 0) + return ret; } if (buf->sample_rates_size) { formats = NULL; for (i = 0; i < NB_ITEMS(buf->sample_rates); i++) - if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) { - ff_formats_unref(&formats); + if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) return ret; - } - ff_set_common_samplerates(ctx, formats); + if ((ret = ff_set_common_samplerates(ctx, formats)) < 0) + return ret; } return 0; diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 45e219a084..3920b048db 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -314,23 +314,27 @@ static int query_formats(AVFilterContext *ctx) AVFilterChannelLayouts *channel_layouts = NULL; AVFilterFormats *formats = NULL; AVFilterFormats *samplerates = NULL; + int ret; switch (ctx->outputs[0]->type) { case AVMEDIA_TYPE_VIDEO: - ff_add_format(&formats, c->pix_fmt); - ff_set_common_formats(ctx, formats); + if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0) + return ret; break; case AVMEDIA_TYPE_AUDIO: - ff_add_format(&formats, c->sample_fmt); - ff_set_common_formats(ctx, formats); - - ff_add_format(&samplerates, c->sample_rate); - ff_set_common_samplerates(ctx, samplerates); + if ((ret = ff_add_format (&formats , c->sample_fmt )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_format (&samplerates, c->sample_rate)) < 0 || + (ret = ff_set_common_samplerates (ctx , samplerates )) < 0) + return ret; - ff_add_channel_layout(&channel_layouts, + if ((ret = ff_add_channel_layout(&channel_layouts, c->channel_layout ? c->channel_layout : - FF_COUNT2LAYOUT(c->channels)); - ff_set_common_channel_layouts(ctx, channel_layouts); + FF_COUNT2LAYOUT(c->channels))) < 0) + return ret; + if ((ret = ff_set_common_channel_layouts(ctx, channel_layouts)) < 0) + return ret; break; default: return AVERROR(EINVAL); diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c index b65d57cfae..91fffd5e06 100644 --- a/libavfilter/drawutils.c +++ b/libavfilter/drawutils.c @@ -532,10 +532,12 @@ AVFilterFormats *ff_draw_supported_pixel_formats(unsigned flags) enum AVPixelFormat i; FFDrawContext draw; AVFilterFormats *fmts = NULL; + int ret; for (i = 0; av_pix_fmt_desc_get(i); i++) - if (ff_draw_init(&draw, i, flags) >= 0) - ff_add_format(&fmts, i); + if (ff_draw_init(&draw, i, flags) >= 0 && + (ret = ff_add_format(&fmts, i)) < 0) + return NULL; return fmts; } diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c index 2b9340b500..0ca0d229ed 100644 --- a/libavfilter/f_drawgraph.c +++ b/libavfilter/f_drawgraph.c @@ -110,11 +110,11 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts); - if (!fmts_list) - return AVERROR(ENOMEM); - ff_formats_ref(fmts_list, &outlink->in_formats); + if ((ret = ff_formats_ref(fmts_list, &outlink->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 20c9426b6e..b9ea11bb84 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -826,6 +826,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterChannelLayouts *layouts; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; + int ret; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; static const int input_srate[] = {48000, -1}; // ITU-R BS.1770 provides coeff only for 48kHz @@ -834,9 +835,8 @@ static int query_formats(AVFilterContext *ctx) /* set optional output video format */ if (ebur128->do_video) { formats = ff_make_format_list(pix_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; outlink = ctx->outputs[1]; } @@ -844,22 +844,19 @@ static int query_formats(AVFilterContext *ctx) * Note: ff_set_common_* functions are not used because they affect all the * links, and thus break the video format negotiation */ formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_formats); - ff_formats_ref(formats, &outlink->in_formats); + if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0 || + (ret = ff_formats_ref(formats, &outlink->in_formats)) < 0) + return ret; layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); - ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0 || + (ret = ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts)) < 0) + return ret; formats = ff_make_format_list(input_srate); - if (!formats) - return AVERROR(ENOMEM); - ff_formats_ref(formats, &inlink->out_samplerates); - ff_formats_ref(formats, &outlink->in_samplerates); + if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0 || + (ret = ff_formats_ref(formats, &outlink->in_samplerates)) < 0) + return ret; return 0; } diff --git a/libavfilter/formats.c b/libavfilter/formats.c index a28be60a65..2b13cbf3db 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -300,17 +300,20 @@ AVFilterChannelLayouts *avfilter_make_format64_list(const int64_t *fmts) return formats; } -#define ADD_FORMAT(f, fmt, type, list, nb) \ +#define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \ do { \ type *fmts; \ void *oldf = *f; \ \ - if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) \ + if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \ + unref_fn(f); \ return AVERROR(ENOMEM); \ + } \ \ fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \ sizeof(*(*f)->list)); \ if (!fmts) { \ + unref_fn(f); \ if (!oldf) \ av_freep(f); \ return AVERROR(ENOMEM); \ @@ -322,14 +325,14 @@ do { \ int ff_add_format(AVFilterFormats **avff, int64_t fmt) { - ADD_FORMAT(avff, fmt, int, formats, nb_formats); + ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats); return 0; } int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) { av_assert1(!(*l && (*l)->all_layouts)); - ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts); + ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, uint64_t, channel_layouts, nb_channel_layouts); return 0; } @@ -340,12 +343,14 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type) if (type == AVMEDIA_TYPE_VIDEO) { const AVPixFmtDescriptor *desc = NULL; while ((desc = av_pix_fmt_desc_next(desc))) { - ff_add_format(&ret, av_pix_fmt_desc_get_id(desc)); + if (ff_add_format(&ret, av_pix_fmt_desc_get_id(desc)) < 0) + return NULL; } } else if (type == AVMEDIA_TYPE_AUDIO) { enum AVSampleFormat fmt = 0; while (av_get_sample_fmt_name(fmt)) { - ff_add_format(&ret, fmt); + if (ff_add_format(&ret, fmt) < 0) + return NULL; fmt++; } } @@ -370,7 +375,8 @@ AVFilterFormats *ff_planar_sample_fmts(void) for (fmt = 0; av_get_bytes_per_sample(fmt)>0; fmt++) if (av_sample_fmt_is_planar(fmt)) - ff_add_format(&ret, fmt); + if (ff_add_format(&ret, fmt) < 0) + return NULL; return ret; } @@ -399,15 +405,17 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) return ret; } -#define FORMATS_REF(f, ref) \ +#define FORMATS_REF(f, ref, unref_fn) \ void *tmp; \ \ - if (!ref) \ - return AVERROR_BUG; \ + if (!f || !ref) \ + return AVERROR(ENOMEM); \ \ tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \ - if (!tmp) \ + if (!tmp) { \ + unref_fn(&f); \ return AVERROR(ENOMEM); \ + } \ f->refs = tmp; \ f->refs[f->refcount++] = ref; \ *ref = f; \ @@ -415,12 +423,12 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref) { - FORMATS_REF(f, ref); + FORMATS_REF(f, ref, ff_channel_layouts_unref); } int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) { - FORMATS_REF(f, ref); + FORMATS_REF(f, ref, ff_formats_unref); } #define FIND_REF_INDEX(ref, idx) \ @@ -488,25 +496,29 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) FORMATS_CHANGEREF(oldref, newref); } -#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \ +#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref_fn, unref_fn, list) \ int count = 0, i; \ \ if (!fmts) \ - return AVERROR_BUG; \ + return AVERROR(ENOMEM); \ \ for (i = 0; i < ctx->nb_inputs; i++) { \ if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) { \ - int ret = ref(fmts, &ctx->inputs[i]->out_fmts); \ - if (ret < 0) \ + int ret = ref_fn(fmts, &ctx->inputs[i]->out_fmts); \ + if (ret < 0) { \ + unref_fn(&fmts); \ return ret; \ + } \ count++; \ } \ } \ for (i = 0; i < ctx->nb_outputs; i++) { \ if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) { \ - int ret = ref(fmts, &ctx->outputs[i]->in_fmts); \ - if (ret < 0) \ + int ret = ref_fn(fmts, &ctx->outputs[i]->in_fmts); \ + if (ret < 0) { \ + unref_fn(&fmts); \ return ret; \ + } \ count++; \ } \ } \ @@ -523,14 +535,14 @@ int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts) { SET_COMMON_FORMATS(ctx, layouts, in_channel_layouts, out_channel_layouts, - ff_channel_layouts_ref, channel_layouts); + ff_channel_layouts_ref, ff_channel_layouts_unref, channel_layouts); } int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates) { SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates, - ff_formats_ref, formats); + ff_formats_ref, ff_formats_unref, formats); } /** @@ -541,7 +553,7 @@ int ff_set_common_samplerates(AVFilterContext *ctx, int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) { SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats, - ff_formats_ref, formats); + ff_formats_ref, ff_formats_unref, formats); } static int default_query_formats_common(AVFilterContext *ctx, diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index bbdcbc8cd0..0c2ceed316 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -333,7 +333,7 @@ static int movie_query_formats(AVFilterContext *ctx) MovieContext *movie = ctx->priv; int list[] = { 0, -1 }; int64_t list64[] = { 0, -1 }; - int i; + int i, ret; for (i = 0; i < ctx->nb_outputs; i++) { MovieStream *st = &movie->st[i]; @@ -343,16 +343,20 @@ static int movie_query_formats(AVFilterContext *ctx) switch (c->codec_type) { case AVMEDIA_TYPE_VIDEO: list[0] = c->pix_fmt; - ff_formats_ref(ff_make_format_list(list), &outlink->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(list), &outlink->in_formats)) < 0) + return ret; break; case AVMEDIA_TYPE_AUDIO: list[0] = c->sample_fmt; - ff_formats_ref(ff_make_format_list(list), &outlink->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(list), &outlink->in_formats)) < 0) + return ret; list[0] = c->sample_rate; - ff_formats_ref(ff_make_format_list(list), &outlink->in_samplerates); + if ((ret = ff_formats_ref(ff_make_format_list(list), &outlink->in_samplerates)) < 0) + return ret; list64[0] = c->channel_layout; - ff_channel_layouts_ref(avfilter_make_format64_list(list64), - &outlink->in_channel_layouts); + if ((ret = ff_channel_layouts_ref(avfilter_make_format64_list(list64), + &outlink->in_channel_layouts)) < 0) + return ret; break; } } diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c index a478de527a..8a1ca22da5 100644 --- a/libavfilter/vf_alphamerge.c +++ b/libavfilter/vf_alphamerge.c @@ -57,11 +57,16 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_NONE }; static const enum AVPixelFormat alpha_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; - AVFilterFormats *main_formats = ff_make_format_list(main_fmts); - AVFilterFormats *alpha_formats = ff_make_format_list(alpha_fmts); - ff_formats_ref(main_formats, &ctx->inputs[0]->out_formats); - ff_formats_ref(alpha_formats, &ctx->inputs[1]->out_formats); - ff_formats_ref(main_formats, &ctx->outputs[0]->in_formats); + AVFilterFormats *main_formats, *alpha_formats; + int ret; + + if (!(main_formats = ff_make_format_list(main_fmts)) || + !(alpha_formats = ff_make_format_list(alpha_fmts))) + return AVERROR(ENOMEM); + if ((ret = ff_formats_ref(main_formats , &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(alpha_formats, &ctx->inputs[1]->out_formats)) < 0 || + (ret = ff_formats_ref(main_formats , &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index 0e9bafd700..ef01cf98e1 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -118,14 +118,15 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & (AV_PIX_FMT_FLAG_HWACCEL | AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_PAL)) && (desc->flags & AV_PIX_FMT_FLAG_PLANAR || desc->nb_components == 1) && - (!(desc->flags & AV_PIX_FMT_FLAG_BE) == !HAVE_BIGENDIAN || desc->comp[0].depth == 8)) - ff_add_format(&formats, fmt); + (!(desc->flags & AV_PIX_FMT_FLAG_BE) == !HAVE_BIGENDIAN || desc->comp[0].depth == 8) && + (ret = ff_add_format(&formats, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, formats); diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index b695a6ffe1..93a58da480 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -93,13 +93,14 @@ typedef struct CropContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & (AV_PIX_FMT_FLAG_HWACCEL | AV_PIX_FMT_FLAG_BITSTREAM)) && - !((desc->log2_chroma_w || desc->log2_chroma_h) && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR))) - ff_add_format(&formats, fmt); + !((desc->log2_chroma_w || desc->log2_chroma_h) && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) && + (ret = ff_add_format(&formats, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, formats); diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c index 320e90d052..9af2a133ac 100644 --- a/libavfilter/vf_detelecine.c +++ b/libavfilter/vf_detelecine.c @@ -116,14 +116,15 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *pix_fmts = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL || desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)) - ff_add_format(&pix_fmts, fmt); + desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) && + (ret = ff_add_format(&pix_fmts, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, pix_fmts); diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c index 8c7b435861..b72f043521 100644 --- a/libavfilter/vf_displace.c +++ b/libavfilter/vf_displace.c @@ -76,8 +76,7 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; - ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); - return 0; + return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); } static void displace_planar(DisplaceContext *s, const AVFrame *in, diff --git a/libavfilter/vf_elbg.c b/libavfilter/vf_elbg.c index 9805eccbbd..b34136bd78 100644 --- a/libavfilter/vf_elbg.c +++ b/libavfilter/vf_elbg.c @@ -83,6 +83,7 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { ELBGContext *elbg = ctx->priv; + int ret; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, AV_PIX_FMT_ABGR, AV_PIX_FMT_BGRA, @@ -99,8 +100,9 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE }; - ff_formats_ref(ff_make_format_list(pix_fmts), &ctx->inputs[0]->out_formats); - ff_formats_ref(ff_make_format_list(pal8_fmt), &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts), &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(ff_make_format_list(pal8_fmt), &ctx->outputs[0]->in_formats)) < 0) + return ret; } return 0; } diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c index 47a174856e..1cb05e443a 100644 --- a/libavfilter/vf_extractplanes.c +++ b/libavfilter/vf_extractplanes.c @@ -99,7 +99,7 @@ static int query_formats(AVFilterContext *ctx) const enum AVPixelFormat *out_pixfmts; const AVPixFmtDescriptor *desc; AVFilterFormats *avff; - int i, depth = 0, be = 0; + int i, ret, depth = 0, be = 0; if (!ctx->inputs[0]->in_formats || !ctx->inputs[0]->in_formats->nb_formats) { @@ -107,7 +107,8 @@ static int query_formats(AVFilterContext *ctx) } if (!ctx->inputs[0]->out_formats) - ff_formats_ref(ff_make_format_list(in_pixfmts), &ctx->inputs[0]->out_formats); + if ((ret = ff_formats_ref(ff_make_format_list(in_pixfmts), &ctx->inputs[0]->out_formats)) < 0) + return ret; avff = ctx->inputs[0]->in_formats; desc = av_pix_fmt_desc_get(avff->formats[0]); @@ -129,7 +130,8 @@ static int query_formats(AVFilterContext *ctx) out_pixfmts = out16le_pixfmts; for (i = 0; i < ctx->nb_outputs; i++) - ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c index d0d68071fd..ca55ff1f66 100644 --- a/libavfilter/vf_fieldorder.c +++ b/libavfilter/vf_fieldorder.c @@ -55,13 +55,12 @@ static int query_formats(AVFilterContext *ctx) desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) && desc->nb_components && !desc->log2_chroma_h && - (ret = ff_add_format(&formats, pix_fmt)) < 0) { - ff_formats_unref(&formats); + (ret = ff_add_format(&formats, pix_fmt)) < 0) return ret; - } } - ff_formats_ref(formats, &ctx->inputs[0]->out_formats); - ff_formats_ref(formats, &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(formats, &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(formats, &ctx->outputs[0]->in_formats)) < 0) + return ret; } return 0; diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index bbefe51c0f..0a98fead32 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -370,11 +370,14 @@ static int query_formats(AVFilterContext *ctx) { Frei0rContext *s = ctx->priv; AVFilterFormats *formats = NULL; + int ret; if (s->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) { - ff_add_format(&formats, AV_PIX_FMT_BGRA); + if ((ret = ff_add_format(&formats, AV_PIX_FMT_BGRA)) < 0) + return ret; } else if (s->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) { - ff_add_format(&formats, AV_PIX_FMT_RGBA); + if ((ret = ff_add_format(&formats, AV_PIX_FMT_RGBA)) < 0) + return ret; } else { /* F0R_COLOR_MODEL_PACKED32 */ static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_BGRA, AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_ARGB, AV_PIX_FMT_NONE diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index 362bd013a9..96ffca880b 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -44,15 +44,16 @@ typedef struct FlipContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *pix_fmts = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL || desc->flags & AV_PIX_FMT_FLAG_BITSTREAM || (desc->log2_chroma_w != desc->log2_chroma_h && - desc->comp[0].plane == desc->comp[1].plane))) - ff_add_format(&pix_fmts, fmt); + desc->comp[0].plane == desc->comp[1].plane)) && + (ret = ff_add_format(&pix_fmts, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, pix_fmts); diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c index d8e935a28e..12ab21ce56 100644 --- a/libavfilter/vf_histogram.c +++ b/libavfilter/vf_histogram.c @@ -155,6 +155,7 @@ static int query_formats(AVFilterContext *ctx) HistogramContext *h = ctx->priv; const enum AVPixelFormat *pix_fmts; AVFilterFormats *fmts_list; + int ret; switch (h->mode) { case MODE_WAVEFORM: @@ -173,7 +174,8 @@ static int query_formats(AVFilterContext *ctx) } if (!ctx->inputs[0]->out_formats) - ff_formats_ref(ff_make_format_list(levels_in_pix_fmts), &ctx->inputs[0]->out_formats); + if ((ret = ff_formats_ref(ff_make_format_list(levels_in_pix_fmts), &ctx->inputs[0]->out_formats)) < 0) + return ret; avff = ctx->inputs[0]->in_formats; desc = av_pix_fmt_desc_get(avff->formats[0]); rgb = desc->flags & AV_PIX_FMT_FLAG_RGB; @@ -197,7 +199,8 @@ static int query_formats(AVFilterContext *ctx) out_pix_fmts = levels_out_yuv9_pix_fmts; else // if (bits == 10) out_pix_fmts = levels_out_yuv10_pix_fmts; - ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_il.c b/libavfilter/vf_il.c index d370b5257a..7aedb87d89 100644 --- a/libavfilter/vf_il.c +++ b/libavfilter/vf_il.c @@ -84,12 +84,14 @@ AVFILTER_DEFINE_CLASS(il); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); - if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) - ff_add_format(&formats, fmt); + if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) && + !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) && + (ret = ff_add_format(&formats, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, formats); diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c index aa11d31720..38a4663a2c 100644 --- a/libavfilter/vf_maskedmerge.c +++ b/libavfilter/vf_maskedmerge.c @@ -58,8 +58,7 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_NONE }; - ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); - return 0; + return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); } static int process_frame(FFFrameSync *fs) diff --git a/libavfilter/vf_mergeplanes.c b/libavfilter/vf_mergeplanes.c index ea796be10f..2d9db843f4 100644 --- a/libavfilter/vf_mergeplanes.c +++ b/libavfilter/vf_mergeplanes.c @@ -116,22 +116,25 @@ static int query_formats(AVFilterContext *ctx) { MergePlanesContext *s = ctx->priv; AVFilterFormats *formats = NULL; - int i; + int i, ret; s->outdesc = av_pix_fmt_desc_get(s->out_fmt); for (i = 0; av_pix_fmt_desc_get(i); i++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i); if (desc->comp[0].depth == s->outdesc->comp[0].depth && - av_pix_fmt_count_planes(i) == desc->nb_components) - ff_add_format(&formats, i); + av_pix_fmt_count_planes(i) == desc->nb_components && + (ret = ff_add_format(&formats, i)) < 0) + return ret; } for (i = 0; i < s->nb_inputs; i++) - ff_formats_ref(formats, &ctx->inputs[i]->out_formats); + if ((ret = ff_formats_ref(formats, &ctx->inputs[i]->out_formats)) < 0) + return ret; formats = NULL; - ff_add_format(&formats, s->out_fmt); - ff_formats_ref(formats, &ctx->outputs[0]->in_formats); + if ((ret = ff_add_format(&formats, s->out_fmt)) < 0 || + (ret = ff_formats_ref(formats, &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c index c3c7f749fe..7e4f6058d1 100644 --- a/libavfilter/vf_neighbor.c +++ b/libavfilter/vf_neighbor.c @@ -49,8 +49,7 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; - ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); - return 0; + return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); } static av_cold void uninit(AVFilterContext *ctx) diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c index c658bba8c1..dbdae7d90f 100644 --- a/libavfilter/vf_noise.c +++ b/libavfilter/vf_noise.c @@ -133,12 +133,13 @@ static av_cold int init_noise(NoiseContext *n, int comp) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); - if (desc->flags & AV_PIX_FMT_FLAG_PLANAR && !(desc->comp[0].depth & 7)) - ff_add_format(&formats, fmt); + if (desc->flags & AV_PIX_FMT_FLAG_PLANAR && !(desc->comp[0].depth & 7) + && (ret = ff_add_format(&formats, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, formats); diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 81c9cc1665..3c61731431 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -247,31 +247,37 @@ static int query_formats(AVFilterContext *ctx) AVFilterFormats *main_formats; AVFilterFormats *overlay_formats; + int ret; switch (s->format) { case OVERLAY_FORMAT_YUV420: - main_formats = ff_make_format_list(main_pix_fmts_yuv420); - overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv420); + if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv420)) || + !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv420))) + return AVERROR(ENOMEM); break; case OVERLAY_FORMAT_YUV422: - main_formats = ff_make_format_list(main_pix_fmts_yuv422); - overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422); + if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv422)) || + !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422))) + return AVERROR(ENOMEM); break; case OVERLAY_FORMAT_YUV444: - main_formats = ff_make_format_list(main_pix_fmts_yuv444); - overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444); + if (!(main_formats = ff_make_format_list(main_pix_fmts_yuv444)) || + !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444))) + return AVERROR(ENOMEM); break; case OVERLAY_FORMAT_RGB: - main_formats = ff_make_format_list(main_pix_fmts_rgb); - overlay_formats = ff_make_format_list(overlay_pix_fmts_rgb); + if (!(main_formats = ff_make_format_list(main_pix_fmts_rgb)) || + !(overlay_formats = ff_make_format_list(overlay_pix_fmts_rgb))) + return AVERROR(ENOMEM); break; default: av_assert0(0); } - ff_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats); - ff_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats); - ff_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats ); + if ((ret = ff_formats_ref(main_formats , &ctx->inputs[MAIN]->out_formats )) < 0 || + (ret = ff_formats_ref(overlay_formats, &ctx->inputs[OVERLAY]->out_formats)) < 0 || + (ret = ff_formats_ref(main_formats , &ctx->outputs[MAIN]->in_formats )) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 025bb53589..df57c10982 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -92,6 +92,7 @@ static int query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat in_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; static const enum AVPixelFormat out_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; + int ret; AVFilterFormats *in = ff_make_format_list(in_fmts); AVFilterFormats *out = ff_make_format_list(out_fmts); if (!in || !out) { @@ -99,8 +100,9 @@ static int query_formats(AVFilterContext *ctx) av_freep(&out); return AVERROR(ENOMEM); } - ff_formats_ref(in, &ctx->inputs[0]->out_formats); - ff_formats_ref(out, &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index f8350ac585..1225a660bb 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -132,6 +132,7 @@ static int query_formats(AVFilterContext *ctx) static const enum AVPixelFormat in_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; static const enum AVPixelFormat inpal_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; static const enum AVPixelFormat out_fmts[] = {AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE}; + int ret; AVFilterFormats *in = ff_make_format_list(in_fmts); AVFilterFormats *inpal = ff_make_format_list(inpal_fmts); AVFilterFormats *out = ff_make_format_list(out_fmts); @@ -141,9 +142,10 @@ static int query_formats(AVFilterContext *ctx) av_freep(&out); return AVERROR(ENOMEM); } - ff_formats_ref(in, &ctx->inputs[0]->out_formats); - ff_formats_ref(inpal, &ctx->inputs[1]->out_formats); - ff_formats_ref(out, &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(inpal, &ctx->inputs[1]->out_formats)) < 0 || + (ret = ff_formats_ref(out , &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index fd98abf7ea..1032688021 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -188,11 +188,11 @@ static int query_formats(AVFilterContext *ctx) if ((sws_isSupportedInput(pix_fmt) || sws_isSupportedEndiannessConversion(pix_fmt)) && (ret = ff_add_format(&formats, pix_fmt)) < 0) { - ff_formats_unref(&formats); return ret; } } - ff_formats_ref(formats, &ctx->inputs[0]->out_formats); + if ((ret = ff_formats_ref(formats, &ctx->inputs[0]->out_formats)) < 0) + return ret; } if (ctx->outputs[0]) { const AVPixFmtDescriptor *desc = NULL; @@ -202,11 +202,11 @@ static int query_formats(AVFilterContext *ctx) if ((sws_isSupportedOutput(pix_fmt) || pix_fmt == AV_PIX_FMT_PAL8 || sws_isSupportedEndiannessConversion(pix_fmt)) && (ret = ff_add_format(&formats, pix_fmt)) < 0) { - ff_formats_unref(&formats); return ret; } } - ff_formats_ref(formats, &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->in_formats)) < 0) + return ret; } return 0; diff --git a/libavfilter/vf_showpalette.c b/libavfilter/vf_showpalette.c index e4d59b62c8..807dfb1d95 100644 --- a/libavfilter/vf_showpalette.c +++ b/libavfilter/vf_showpalette.c @@ -46,6 +46,7 @@ static int query_formats(AVFilterContext *ctx) { static const enum AVPixelFormat in_fmts[] = {AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE}; static const enum AVPixelFormat out_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; + int ret; AVFilterFormats *in = ff_make_format_list(in_fmts); AVFilterFormats *out = ff_make_format_list(out_fmts); if (!in || !out) { @@ -53,8 +54,9 @@ static int query_formats(AVFilterContext *ctx) av_freep(&out); return AVERROR(ENOMEM); } - ff_formats_ref(in, &ctx->inputs[0]->out_formats); - ff_formats_ref(out, &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 || + (ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c index 8a90caada7..c4bbd6166d 100644 --- a/libavfilter/vf_stack.c +++ b/libavfilter/vf_stack.c @@ -43,14 +43,15 @@ typedef struct StackContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *pix_fmts = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_HWACCEL || - desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)) - ff_add_format(&pix_fmts, fmt); + desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) && + (ret = ff_add_format(&pix_fmts, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, pix_fmts); diff --git a/libavfilter/vf_swapuv.c b/libavfilter/vf_swapuv.c index 624e6b624f..1a82ef3cc9 100644 --- a/libavfilter/vf_swapuv.c +++ b/libavfilter/vf_swapuv.c @@ -77,12 +77,12 @@ static int is_planar_yuv(const AVPixFmtDescriptor *desc) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); - if (is_planar_yuv(desc)) - ff_add_format(&formats, fmt); + if (is_planar_yuv(desc) && (ret = ff_add_format(&formats, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, formats); diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c index bb091e1f3c..37343bc134 100644 --- a/libavfilter/vf_telecine.c +++ b/libavfilter/vf_telecine.c @@ -102,14 +102,15 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *pix_fmts = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL || desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)) - ff_add_format(&pix_fmts, fmt); + desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) && + (ret = ff_add_format(&pix_fmts, fmt)) < 0) + return ret; } return ff_set_common_formats(ctx, pix_fmts); diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 484b8e874e..3b6e36ad8f 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -63,15 +63,16 @@ typedef struct TransContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *pix_fmts = NULL; - int fmt; + int fmt, ret; for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_HWACCEL || desc->flags & AV_PIX_FMT_FLAG_BITSTREAM || - desc->log2_chroma_w != desc->log2_chroma_h)) - ff_add_format(&pix_fmts, fmt); + desc->log2_chroma_w != desc->log2_chroma_h) && + (ret = ff_add_format(&pix_fmts, fmt)) < 0) + return ret; } diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c index 730f55f5fb..5f7cd56565 100644 --- a/libavfilter/vf_vectorscope.c +++ b/libavfilter/vf_vectorscope.c @@ -140,7 +140,7 @@ static int query_formats(AVFilterContext *ctx) const enum AVPixelFormat *out_pix_fmts; const AVPixFmtDescriptor *desc; AVFilterFormats *avff; - int depth, rgb, i; + int depth, rgb, i, ret; if (!ctx->inputs[0]->in_formats || !ctx->inputs[0]->in_formats->nb_formats) { @@ -154,7 +154,8 @@ static int query_formats(AVFilterContext *ctx) in_pix_fmts = in2_pix_fmts; else in_pix_fmts = in1_pix_fmts; - ff_formats_ref(ff_make_format_list(in_pix_fmts), &ctx->inputs[0]->out_formats); + if ((ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), &ctx->inputs[0]->out_formats)) < 0) + return ret; } avff = ctx->inputs[0]->in_formats; @@ -180,7 +181,8 @@ static int query_formats(AVFilterContext *ctx) out_pix_fmts = out_yuv10_pix_fmts; else out_pix_fmts = out_yuv8_pix_fmts; - ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats); + if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats)) < 0) + return ret; return 0; } diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c index 314746dc94..3d1d36ffeb 100644 --- a/libavfilter/vsrc_life.c +++ b/libavfilter/vsrc_life.c @@ -428,10 +428,7 @@ static int query_formats(AVFilterContext *ctx) } fmts_list = ff_make_format_list(pix_fmts); - if (!fmts_list) - return AVERROR(ENOMEM); - ff_set_common_formats(ctx, fmts_list); - return 0; + return ff_set_common_formats(ctx, fmts_list); } static const AVFilterPad life_outputs[] = { |