diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2008-02-15 21:38:20 +0000 |
---|---|---|
committer | Vitor Sessak <vitor1001@gmail.com> | 2008-02-15 21:38:20 +0000 |
commit | 6d8c67a778ea6240a8857242dfd926b2bd990a7a (patch) | |
tree | 3e1cd604e1af32a489b39f43f3bd0259bf7a23d5 /libavfilter/avfilter.c | |
parent | e675dccdc01e3fca705711077fc1510768462a17 (diff) | |
download | ffmpeg-6d8c67a778ea6240a8857242dfd926b2bd990a7a.tar.gz |
Change registered filter list to a linked list
Commited in SoC by Bobby Bingham on 2007-08-17 23:24:32
Originally committed as revision 12013 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 2b74227a0c..50d15bf8a7 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -27,9 +27,12 @@ #include "avfilter.h" #include "allfilters.h" -/** list of registered filters, sorted by name */ -static int filter_count = 0; -static AVFilter **filters = NULL; +/** list of registered filters */ +struct FilterList +{ + AVFilter *filter; + struct FilterList *next; +} *filters = NULL; /** helper macros to get the in/out pad on the dst/src filter */ #define link_dpad(link) link->dst-> input_pads[link->dstpad] @@ -239,30 +242,25 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h) link_dpad(link).draw_slice(link, y, h); } -static int filter_cmp(const void *aa, const void *bb) -{ - const AVFilter *a = *(const AVFilter **)aa, *b = *(const AVFilter **)bb; - return strcmp(a->name, b->name); -} - AVFilter *avfilter_get_by_name(char *name) { - AVFilter key = { .name = name, }; - AVFilter *key2 = &key; - AVFilter **ret; + struct FilterList *filt; + + for(filt = filters; filt; filt = filt->next) + if(!strcmp(filt->filter->name, name)) + return filt->filter; - ret = bsearch(&key2, filters, filter_count, sizeof(AVFilter **), filter_cmp); - if(ret) - return *ret; return NULL; } /* FIXME: insert in order, rather than insert at end + resort */ void avfilter_register(AVFilter *filter) { - filters = av_realloc(filters, sizeof(AVFilter*) * (filter_count+1)); - filters[filter_count] = filter; - qsort(filters, ++filter_count, sizeof(AVFilter **), filter_cmp); + struct FilterList *newfilt = av_malloc(sizeof(struct FilterList)); + + newfilt->filter = filter; + newfilt->next = filters; + filters = newfilt; } void avfilter_init(void) @@ -283,8 +281,12 @@ void avfilter_init(void) void avfilter_uninit(void) { - av_freep(&filters); - filter_count = 0; + struct FilterList *tmp; + + for(; filters; filters = tmp) { + tmp = filters->next; + av_free(filters); + } } static int pad_count(const AVFilterPad *pads) |