diff mbox series

[FFmpeg-devel,03/10] avfilter/avfilter: Add avfilter_filter_pad_count()

Message ID AM7PR03MB6660A719B347B1905817292E8FFC9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,01/10] fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 15, 2021, 9:55 a.m. UTC
It is intended as replacement for avfilter_pad_count(). In contrast to
the latter, it avoids a loop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Missing APIchanges entry and version bump.

 libavfilter/avfilter.c | 5 +++++
 libavfilter/avfilter.h | 5 +++++
 2 files changed, 10 insertions(+)

Comments

Nicolas George Aug. 20, 2021, 9:05 a.m. UTC | #1
Andreas Rheinhardt (12021-08-15):
> It is intended as replacement for avfilter_pad_count(). In contrast to
> the latter, it avoids a loop.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Missing APIchanges entry and version bump.
> 
>  libavfilter/avfilter.c | 5 +++++
>  libavfilter/avfilter.h | 5 +++++
>  2 files changed, 10 insertions(+)

LGTM.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 15d469ed59..5032fd99d6 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -563,6 +563,11 @@  int avfilter_pad_count(const AVFilterPad *pads)
     av_assert0(!"AVFilterPad list not from a filter");
 }
 
+unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
+{
+    return is_output ? filter->nb_outputs : filter->nb_inputs;
+}
+
 static const char *default_filter_name(void *filter_ctx)
 {
     AVFilterContext *ctx = filter_ctx;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index f1f19a0548..0905f308eb 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -332,6 +332,11 @@  typedef struct AVFilter {
     int (*activate)(AVFilterContext *ctx);
 } AVFilter;
 
+/**
+ * Get the number of elements in an AVFilter's inputs or outputs array.
+ */
+unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output);
+
 /**
  * Process multiple parts of the frame concurrently.
  */