Commit 133fbfc7 authored by Michael Niedermayer's avatar Michael Niedermayer

do O(1) instead of O(n) atomic operations in register functions

about 1ms faster startup time
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 2b215f39
...@@ -206,7 +206,8 @@ av_cold void avcodec_register(AVCodec *codec) ...@@ -206,7 +206,8 @@ av_cold void avcodec_register(AVCodec *codec)
avcodec_init(); avcodec_init();
p = &first_avcodec; p = &first_avcodec;
codec->next = NULL; codec->next = NULL;
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
p = &(*p)->next; p = &(*p)->next;
if (codec->init_static_data) if (codec->init_static_data)
...@@ -3191,7 +3192,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel) ...@@ -3191,7 +3192,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel)
{ {
AVHWAccel **p = &first_hwaccel; AVHWAccel **p = &first_hwaccel;
hwaccel->next = NULL; hwaccel->next = NULL;
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel)) while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
p = &(*p)->next; p = &(*p)->next;
} }
......
...@@ -490,7 +490,7 @@ int avfilter_register(AVFilter *filter) ...@@ -490,7 +490,7 @@ int avfilter_register(AVFilter *filter)
filter->next = NULL; filter->next = NULL;
while(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;
return 0; return 0;
......
...@@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format) ...@@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format)
AVInputFormat **p = &first_iformat; AVInputFormat **p = &first_iformat;
format->next = NULL; format->next = NULL;
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
p = &(*p)->next; p = &(*p)->next;
} }
...@@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format) ...@@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format)
AVOutputFormat **p = &first_oformat; AVOutputFormat **p = &first_oformat;
format->next = NULL; format->next = NULL;
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
p = &(*p)->next; p = &(*p)->next;
} }
......
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