]> git.sesse.net Git - ffmpeg/commitdiff
avfilter: avfilter_register() that works in O(1) time
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 8 Dec 2013 01:27:11 +0000 (02:27 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Jan 2014 23:53:04 +0000 (00:53 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/avfilter.c

index 2567ce92c1c327cc1aa3f76f09c3b4d0ff901a49..269ba8e0644ea7d18465d50570c1e58674cdab64 100644 (file)
@@ -456,6 +456,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
 }
 
 static AVFilter *first_filter;
+static AVFilter **last_filter = &first_filter;
 
 #if !FF_API_NOCONST_GET_NAME
 const
@@ -476,7 +477,7 @@ AVFilter *avfilter_get_by_name(const char *name)
 
 int avfilter_register(AVFilter *filter)
 {
-    AVFilter **f = &first_filter;
+    AVFilter **f = last_filter;
     int i;
 
     /* the filter must select generic or internal exclusively */
@@ -492,6 +493,7 @@ int avfilter_register(AVFilter *filter)
 
     while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
         f = &(*f)->next;
+    last_filter = &filter->next;
 
     return 0;
 }