[FFmpeg-devel] [PATCH 3/3] avformat/format: av_register_output_format() and av_register_intput_format() that work in O(1) time

Michael Niedermayer michaelni at gmx.at
Tue Dec 17 01:08:48 CET 2013


On Mon, Dec 16, 2013 at 05:17:08PM +0100, Stefano Sabatini wrote:
> On date Sunday 2013-12-08 03:55:23 +0100, Michael Niedermayer encoded:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavformat/format.c |    9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/format.c b/libavformat/format.c
> > index 36c0131..95060f3 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;
> >  }
> 
> LGTM.

applied

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131217/4ac6c6dd/attachment.asc>


More information about the ffmpeg-devel mailing list