diff mbox series

[FFmpeg-devel,003/218] avfilter/formats: Add function to create AVFilterFormats with one entry

Message ID PR3PR03MB6665691C4E71111A2542D00A8FAA9@PR3PR03MB6665.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,001/218] avfilter/f_reverse: Don't use redundant query_formats function
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 30, 2021, 1:39 p.m. UTC
Most instances ff_add_formats() actually only ever add one format;
this function can be used to simplify those callers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/formats.c | 6 ++++++
 libavfilter/formats.h | 6 ++++++
 2 files changed, 12 insertions(+)

Comments

Nicolas George Oct. 5, 2021, 10:51 a.m. UTC | #1
Andreas Rheinhardt (12021-09-30):
> Most instances ff_add_formats() actually only ever add one format;
> this function can be used to simplify those callers.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavfilter/formats.c | 6 ++++++
>  libavfilter/formats.h | 6 ++++++
>  2 files changed, 12 insertions(+)

Even if there is only one, it is still a formats list, and the name of
the function should reflect it; "make_format", singular, is not clear.
ff_make_formats_list_single() maybe?

Regards,
diff mbox series

Patch

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 1d2a51c0af..d5b8fa8e50 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -430,6 +430,12 @@  int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
     return 0;
 }
 
+AVFilterFormats *ff_make_format_from_entry(int fmt)
+{
+    int fmts[2] = { fmt, -1 };
+    return ff_make_format_list(fmts);
+}
+
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
     AVFilterFormats *ret = NULL;
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 42fe068765..e19625ae6d 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -208,6 +208,12 @@  int ff_default_query_formats(AVFilterContext *ctx);
 av_warn_unused_result
 AVFilterFormats *ff_make_format_list(const int *fmts);
 
+/**
+ * Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })
+ */
+av_warn_unused_result
+AVFilterFormats *ff_make_format_from_entry(int fmt);
+
 /**
  * Add fmt to the list of media formats contained in *avff.
  * If *avff is NULL the function allocates the filter formats struct