FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bitstream_filter.c
Go to the documentation of this file.
1 /*
2  * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <string.h>
22 
23 #include "avcodec.h"
24 #include "libavutil/atomic.h"
25 #include "libavutil/mem.h"
26 
28 
30 {
31  if (f)
32  return f->next;
33  else
35 }
36 
38 {
39  do {
41  } while(bsf->next != avpriv_atomic_ptr_cas((void * volatile *)&first_bitstream_filter, bsf->next, bsf));
42 }
43 
45 {
47 
48  while (bsf) {
49  if (!strcmp(name, bsf->name)) {
52  bsfc->filter = bsf;
53  bsfc->priv_data =
54  bsf->priv_data_size ? av_mallocz(bsf->priv_data_size) : NULL;
55  return bsfc;
56  }
57  bsf = bsf->next;
58  }
59  return NULL;
60 }
61 
63 {
64  if (!bsfc)
65  return;
66  if (bsfc->filter->close)
67  bsfc->filter->close(bsfc);
68  av_freep(&bsfc->priv_data);
69  av_parser_close(bsfc->parser);
70  av_free(bsfc);
71 }
72 
74  AVCodecContext *avctx, const char *args,
75  uint8_t **poutbuf, int *poutbuf_size,
76  const uint8_t *buf, int buf_size, int keyframe)
77 {
78  *poutbuf = (uint8_t *)buf;
79  *poutbuf_size = buf_size;
80  return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size,
81  buf, buf_size, keyframe);
82 }