avfilter/formats: Make ff_formats_pixdesc_filter return AVFilterFormats*

Up until now, it has returned the AVFilterFormats list via
an AVFilterFormats** parameter; the actual return value was an int
that was always AVERROR(ENOMEM) on error. The AVFilterFormats**
argument was a pure output parameter which was only documented
by naming the parameter rfmts. Yet nevertheless all callers
initialized the underlying AVFilterFormats* to NULL.

This commit changes this to return a pointer to AVFilterFormats
directly. This is more in line with the API in general, as it
allows to avoid checks for intermediate values.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2021-09-26 00:09:16 +02:00
parent aff855148a
commit 99feb59cf7
14 changed files with 44 additions and 104 deletions

View File

@ -452,7 +452,7 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type)
return ret;
}
int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej)
AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej)
{
unsigned nb_formats, fmt, flags;
AVFilterFormats *formats = NULL;
@ -476,18 +476,17 @@ int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned r
}
if (formats) {
av_assert0(formats->nb_formats == nb_formats);
*rfmts = formats;
return 0;
return formats;
}
formats = av_mallocz(sizeof(*formats));
if (!formats)
return AVERROR(ENOMEM);
return NULL;
formats->nb_formats = nb_formats;
if (nb_formats) {
formats->formats = av_malloc_array(nb_formats, sizeof(*formats->formats));
if (!formats->formats) {
av_freep(&formats);
return AVERROR(ENOMEM);
return NULL;
}
}
}