Libav
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 Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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/mem.h"
25 
27 
29 {
30  if (f)
31  return f->next;
32  else
34 }
35 
37 {
39  first_bitstream_filter = bsf;
40 }
41 
43 {
45 
46  while (bsf) {
47  if (!strcmp(name, bsf->name)) {
50  bsfc->filter = bsf;
51  bsfc->priv_data =
53  return bsfc;
54  }
55  bsf = bsf->next;
56  }
57  return NULL;
58 }
59 
61 {
62  if (bsfc->filter->close)
63  bsfc->filter->close(bsfc);
64  av_freep(&bsfc->priv_data);
65  av_parser_close(bsfc->parser);
66  av_free(bsfc);
67 }
68 
70  AVCodecContext *avctx, const char *args,
71  uint8_t **poutbuf, int *poutbuf_size,
72  const uint8_t *buf, int buf_size, int keyframe)
73 {
74  *poutbuf = (uint8_t *)buf;
75  *poutbuf_size = buf_size;
76  return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size,
77  buf, buf_size, keyframe);
78 }
memory handling functions
struct AVBitStreamFilter * next
Definition: avcodec.h:4304
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
AVCodecParserContext * parser
Definition: avcodec.h:4291
uint8_t
const char * name
static AVBitStreamFilter * first_bitstream_filter
const char * name
Definition: avcodec.h:4297
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:186
void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc)
AVBitStreamFilter * av_bitstream_filter_next(const AVBitStreamFilter *f)
AVBitStreamFilterContext * av_bitstream_filter_init(const char *name)
void av_parser_close(AVCodecParserContext *s)
Definition: parser.c:207
void av_register_bitstream_filter(AVBitStreamFilter *bsf)
NULL
Definition: eval.c:55
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1050
struct AVBitStreamFilter * filter
Definition: avcodec.h:4290
void(* close)(AVBitStreamFilterContext *bsfc)
Definition: avcodec.h:4303
int(* filter)(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
Definition: avcodec.h:4299
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205