You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/format: av_register_output_format() and av_register_intput_format() that work in O(1) time
Reviewed-by: Stefano Sabatini Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -33,6 +33,9 @@ static AVInputFormat *first_iformat = NULL;
|
|||||||
/** head of registered output format linked list */
|
/** head of registered output format linked list */
|
||||||
static AVOutputFormat *first_oformat = NULL;
|
static AVOutputFormat *first_oformat = NULL;
|
||||||
|
|
||||||
|
static AVInputFormat **last_iformat = &first_iformat;
|
||||||
|
static AVOutputFormat **last_oformat = &first_oformat;
|
||||||
|
|
||||||
AVInputFormat *av_iformat_next(AVInputFormat *f)
|
AVInputFormat *av_iformat_next(AVInputFormat *f)
|
||||||
{
|
{
|
||||||
if (f)
|
if (f)
|
||||||
@@ -51,20 +54,22 @@ AVOutputFormat *av_oformat_next(AVOutputFormat *f)
|
|||||||
|
|
||||||
void av_register_input_format(AVInputFormat *format)
|
void av_register_input_format(AVInputFormat *format)
|
||||||
{
|
{
|
||||||
AVInputFormat **p = &first_iformat;
|
AVInputFormat **p = last_iformat;
|
||||||
|
|
||||||
format->next = NULL;
|
format->next = NULL;
|
||||||
while(*p || 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;
|
||||||
|
last_iformat = &format->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void av_register_output_format(AVOutputFormat *format)
|
void av_register_output_format(AVOutputFormat *format)
|
||||||
{
|
{
|
||||||
AVOutputFormat **p = &first_oformat;
|
AVOutputFormat **p = last_oformat;
|
||||||
|
|
||||||
format->next = NULL;
|
format->next = NULL;
|
||||||
while(*p || 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;
|
||||||
|
last_oformat = &format->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
int av_match_ext(const char *filename, const char *extensions)
|
int av_match_ext(const char *filename, const char *extensions)
|
||||||
|
Reference in New Issue
Block a user