aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-08 02:29:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-17 01:07:43 +0100
commit49f10c9cb185315a41ee06cf7c4c55abfd470c7a (patch)
treeaf234f87f2962054919519c496f4e823c90721cf
parentec464c96831ac81329187013c35a9b0a4df6b406 (diff)
downloadffmpeg-49f10c9cb185315a41ee06cf7c4c55abfd470c7a.tar.gz
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>
-rw-r--r--libavformat/format.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/format.c b/libavformat/format.c
index 36c0131c12..95060f373d 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -33,6 +33,9 @@ static AVInputFormat *first_iformat = NULL;
/** head of registered output format linked list */
static AVOutputFormat *first_oformat = NULL;
+static AVInputFormat **last_iformat = &first_iformat;
+static AVOutputFormat **last_oformat = &first_oformat;
+
AVInputFormat *av_iformat_next(AVInputFormat *f)
{
if (f)
@@ -51,20 +54,22 @@ AVOutputFormat *av_oformat_next(AVOutputFormat *f)
void av_register_input_format(AVInputFormat *format)
{
- AVInputFormat **p = &first_iformat;
+ AVInputFormat **p = last_iformat;
format->next = NULL;
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
p = &(*p)->next;
+ last_iformat = &format->next;
}
void av_register_output_format(AVOutputFormat *format)
{
- AVOutputFormat **p = &first_oformat;
+ AVOutputFormat **p = last_oformat;
format->next = NULL;
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
p = &(*p)->next;
+ last_oformat = &format->next;
}
int av_match_ext(const char *filename, const char *extensions)