Commit c0a33c47 authored by Michael Niedermayer's avatar Michael Niedermayer

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

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 00bef643
...@@ -456,6 +456,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha ...@@ -456,6 +456,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
} }
static AVFilter *first_filter; static AVFilter *first_filter;
static AVFilter **last_filter = &first_filter;
#if !FF_API_NOCONST_GET_NAME #if !FF_API_NOCONST_GET_NAME
const const
...@@ -476,7 +477,7 @@ AVFilter *avfilter_get_by_name(const char *name) ...@@ -476,7 +477,7 @@ AVFilter *avfilter_get_by_name(const char *name)
int avfilter_register(AVFilter *filter) int avfilter_register(AVFilter *filter)
{ {
AVFilter **f = &first_filter; AVFilter **f = last_filter;
int i; int i;
/* the filter must select generic or internal exclusively */ /* the filter must select generic or internal exclusively */
...@@ -492,6 +493,7 @@ int avfilter_register(AVFilter *filter) ...@@ -492,6 +493,7 @@ int avfilter_register(AVFilter *filter)
while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter)) while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
f = &(*f)->next; f = &(*f)->next;
last_filter = &filter->next;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment