[FFmpeg-cvslog] avfilter: avfilter_register() that works in O(1) time

Michael Niedermayer git at videolan.org
Thu Jan 9 01:03:17 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Dec  8 02:27:11 2013 +0100| [c0a33c477094b7fec2eeff86b6d93bad934e2f98] | committer: Michael Niedermayer

avfilter: avfilter_register() that works in O(1) time

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0a33c477094b7fec2eeff86b6d93bad934e2f98
---

 libavfilter/avfilter.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 2567ce9..269ba8e 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -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;
 }



More information about the ffmpeg-cvslog mailing list