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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Aug 15 12:55:31 EEST 2021


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 at outlook.com>
---
Missing APIchanges entry and version bump.

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

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.
  */
-- 
2.30.2



More information about the ffmpeg-devel mailing list