diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-11-24 23:47:33 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-11-24 23:47:33 +0000 |
commit | 86a60fa1acc685013d23c58a29cc5f06a7a97bd9 (patch) | |
tree | 0074be605cb60da6dbd2edb8578128b37af90899 /libavfilter/avfilter.c | |
parent | d0df2fcc3530e3d2ac48db7c4c716d32af7859bd (diff) | |
download | ffmpeg-86a60fa1acc685013d23c58a29cc5f06a7a97bd9.tar.gz |
Implement a new registration system for filters.
Create a new static array containing pointers to the AVFilter
definitions, so that the non-constant next filter in the AVFilter
struct is not anymore required and the AVFilter definitions may be
stored in shareable memory.
Also change the signature for avfilter_register(), make it return an
int since it may fail if there is not enough space in the static array
for the registered filters.
Originally committed as revision 20605 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 450a6328c7..05a0fea47e 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -328,33 +328,36 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h) draw_slice(link, y, h); } -AVFilter *first_avfilter = NULL; +#define MAX_REGISTERED_AVFILTERS_NB 64 + +static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; + +static int next_registered_avfilter_idx = 0; AVFilter *avfilter_get_by_name(const char *name) { - AVFilter *filter; + int i; - for (filter = first_avfilter; filter; filter = filter->next) - if (!strcmp(filter->name, name)) - return filter; + for (i = 0; registered_avfilters[i]; i++) + if (!strcmp(registered_avfilters[i]->name, name)) + return registered_avfilters[i]; return NULL; } -void avfilter_register(AVFilter *filter) +int avfilter_register(AVFilter *filter) { - AVFilter **p; - p = &first_avfilter; - while (*p) - p = &(*p)->next; + if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) + return -1; - *p = filter; - filter->next = NULL; + registered_avfilters[next_registered_avfilter_idx++] = filter; + return 0; } void avfilter_uninit(void) { - first_avfilter = NULL; + memset(registered_avfilters, 0, sizeof(registered_avfilters)); + next_registered_avfilter_idx = 0; } static int pad_count(const AVFilterPad *pads) |