[FFmpeg-devel] [PATCH 2/3] avfilter/avfilter: avfilter_register() that works in O(1) time
Stefano Sabatini
stefasab at gmail.com
Mon Dec 16 17:16:37 CET 2013
On date Sunday 2013-12-08 03:55:22 +0100, Michael Niedermayer encoded:
> This also flips the order of the list
> avfilters should be unique and thus the order should not matter
>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavfilter/avfilter.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 2567ce9..c564b45 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -476,7 +476,6 @@ AVFilter *avfilter_get_by_name(const char *name)
>
> int avfilter_register(AVFilter *filter)
> {
> - AVFilter **f = &first_filter;
> int i;
>
> /* the filter must select generic or internal exclusively */
> @@ -488,10 +487,9 @@ int avfilter_register(AVFilter *filter)
> || (!input->start_frame && !input->end_frame));
> }
>
> - filter->next = NULL;
> -
> - while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
> - f = &(*f)->next;
> + do {
> + filter->next = first_filter;
> + } while (filter->next != avpriv_atomic_ptr_cas((void * volatile *)&first_filter, filter->next, filter));
why do you need a loop for this?
Also, will the order in ffmpeg -filters remain the same (I suppose not).
--
FFmpeg = Fantastic and Fundamental Miracolous Philosofic Exuberant Gladiator
More information about the ffmpeg-devel
mailing list