diff options
Diffstat (limited to 'libavcodec/bitstream_filter.c')
-rw-r--r-- | libavcodec/bitstream_filter.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c index f524d3e..3275326 100644 --- a/libavcodec/bitstream_filter.c +++ b/libavcodec/bitstream_filter.c @@ -1,26 +1,27 @@ /* * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <string.h> #include "avcodec.h" +#include "libavutil/atomic.h" #include "libavutil/mem.h" static AVBitStreamFilter *first_bitstream_filter = NULL; @@ -35,15 +36,16 @@ AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f) void av_register_bitstream_filter(AVBitStreamFilter *bsf) { - bsf->next = first_bitstream_filter; - first_bitstream_filter = bsf; + do { + bsf->next = first_bitstream_filter; + } while(bsf->next != avpriv_atomic_ptr_cas((void * volatile *)&first_bitstream_filter, bsf->next, bsf)); } AVBitStreamFilterContext *av_bitstream_filter_init(const char *name) { - AVBitStreamFilter *bsf = first_bitstream_filter; + AVBitStreamFilter *bsf = NULL; - while (bsf) { + while (bsf = av_bitstream_filter_next(bsf)) { if (!strcmp(name, bsf->name)) { AVBitStreamFilterContext *bsfc = av_mallocz(sizeof(AVBitStreamFilterContext)); @@ -52,13 +54,14 @@ AVBitStreamFilterContext *av_bitstream_filter_init(const char *name) bsf->priv_data_size ? av_mallocz(bsf->priv_data_size) : NULL; return bsfc; } - bsf = bsf->next; } return NULL; } void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc) { + if (!bsfc) + return; if (bsfc->filter->close) bsfc->filter->close(bsfc); av_freep(&bsfc->priv_data); |