[FFmpeg-cvslog] r12013 - trunk/libavfilter/avfilter.c

vitor subversion
Fri Feb 15 22:38:21 CET 2008


Author: vitor
Date: Fri Feb 15 22:38:20 2008
New Revision: 12013

Log:
Change registered filter list to a linked list

Commited in SoC by Bobby Bingham on 2007-08-17 23:24:32


Modified:
   trunk/libavfilter/avfilter.c

Modified: trunk/libavfilter/avfilter.c
==============================================================================
--- trunk/libavfilter/avfilter.c	(original)
+++ trunk/libavfilter/avfilter.c	Fri Feb 15 22:38:20 2008
@@ -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 *l
     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)




More information about the ffmpeg-cvslog mailing list