Commit 7e8fe4be authored by Anton Khirnov's avatar Anton Khirnov

lavfi: add a function for counting elements in AVFilterPad arrays.

The caller needs to know what valid indices can be passed to
avfilter_pad_get_name/type.
parent 7cdd737b
...@@ -23,6 +23,7 @@ API changes, most recent first: ...@@ -23,6 +23,7 @@ API changes, most recent first:
Add avfilter_init_str(), deprecate avfilter_init_filter(). Add avfilter_init_str(), deprecate avfilter_init_filter().
Add avfilter_init_dict(). Add avfilter_init_dict().
Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags.
Add avfilter_pad_count() for counting filter inputs/outputs.
2013-xx-xx - lavfi 3.7.0 - avfilter.h 2013-xx-xx - lavfi 3.7.0 - avfilter.h
Add AVFilter.priv_class for exporting filter options through the AVOptions API Add AVFilter.priv_class for exporting filter options through the AVOptions API
......
...@@ -304,7 +304,7 @@ void avfilter_uninit(void) ...@@ -304,7 +304,7 @@ void avfilter_uninit(void)
next_registered_avfilter_idx = 0; next_registered_avfilter_idx = 0;
} }
static int pad_count(const AVFilterPad *pads) int avfilter_pad_count(const AVFilterPad *pads)
{ {
int count; int count;
...@@ -377,7 +377,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ...@@ -377,7 +377,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
av_opt_set_defaults(ret->priv); av_opt_set_defaults(ret->priv);
} }
ret->nb_inputs = pad_count(filter->inputs); ret->nb_inputs = avfilter_pad_count(filter->inputs);
if (ret->nb_inputs ) { if (ret->nb_inputs ) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs); ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs);
if (!ret->input_pads) if (!ret->input_pads)
...@@ -388,7 +388,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ...@@ -388,7 +388,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
goto err; goto err;
} }
ret->nb_outputs = pad_count(filter->outputs); ret->nb_outputs = avfilter_pad_count(filter->outputs);
if (ret->nb_outputs) { if (ret->nb_outputs) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_outputs); ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_outputs);
if (!ret->output_pads) if (!ret->output_pads)
......
...@@ -350,6 +350,12 @@ struct AVFilterPad { ...@@ -350,6 +350,12 @@ struct AVFilterPad {
}; };
#endif #endif
/**
* Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
* AVFilter.inputs/outputs).
*/
int avfilter_pad_count(const AVFilterPad *pads);
/** /**
* Get the name of an AVFilterPad. * Get the name of an AVFilterPad.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment