Statistics
| Branch: | Revision:

ffmpeg / libavcodec / bitstream_filter.c @ 8bf63e1c

History | View | Annotate | Download (2.01 KB)

1 04d7f601 Diego Biurrun
/*
2
 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3
 *
4 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7 04d7f601 Diego Biurrun
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
10 04d7f601 Diego Biurrun
 *
11 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
12 04d7f601 Diego Biurrun
 * 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 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
18 04d7f601 Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20 748c2fca Michael Niedermayer
21
#include "avcodec.h"
22
23
AVBitStreamFilter *first_bitstream_filter= NULL;
24
25
void av_register_bitstream_filter(AVBitStreamFilter *bsf){
26
    bsf->next = first_bitstream_filter;
27
    first_bitstream_filter= bsf;
28
}
29
30
AVBitStreamFilterContext *av_bitstream_filter_init(const char *name){
31
    AVBitStreamFilter *bsf= first_bitstream_filter;
32
33
    while(bsf){
34
        if(!strcmp(name, bsf->name)){
35
            AVBitStreamFilterContext *bsfc= av_mallocz(sizeof(AVBitStreamFilterContext));
36
            bsfc->filter= bsf;
37 514e0831 Michael Niedermayer
            bsfc->priv_data= av_mallocz(bsf->priv_data_size);
38 748c2fca Michael Niedermayer
            return bsfc;
39
        }
40
        bsf= bsf->next;
41
    }
42
    return NULL;
43
}
44
45
void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){
46 514e0831 Michael Niedermayer
    av_freep(&bsfc->priv_data);
47 748c2fca Michael Niedermayer
    av_parser_close(bsfc->parser);
48
    av_free(bsfc);
49
}
50
51
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
52
                               AVCodecContext *avctx, const char *args,
53
                     uint8_t **poutbuf, int *poutbuf_size,
54
                     const uint8_t *buf, int buf_size, int keyframe){
55 514e0831 Michael Niedermayer
    *poutbuf= (uint8_t *) buf;
56
    *poutbuf_size= buf_size;
57 748c2fca Michael Niedermayer
    return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe);
58
}