00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <string.h>
00022
00023 #include "avcodec.h"
00024 #include "libavutil/mem.h"
00025
00026 static AVBitStreamFilter *first_bitstream_filter= NULL;
00027
00028 AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f){
00029 if(f) return f->next;
00030 else return first_bitstream_filter;
00031 }
00032
00033 void av_register_bitstream_filter(AVBitStreamFilter *bsf){
00034 bsf->next = first_bitstream_filter;
00035 first_bitstream_filter= bsf;
00036 }
00037
00038 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name){
00039 AVBitStreamFilter *bsf= first_bitstream_filter;
00040
00041 while(bsf){
00042 if(!strcmp(name, bsf->name)){
00043 AVBitStreamFilterContext *bsfc= av_mallocz(sizeof(AVBitStreamFilterContext));
00044 bsfc->filter= bsf;
00045 bsfc->priv_data = bsf->priv_data_size ? av_mallocz(bsf->priv_data_size) : NULL;
00046 return bsfc;
00047 }
00048 bsf= bsf->next;
00049 }
00050 return NULL;
00051 }
00052
00053 void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){
00054 if(bsfc->filter->close)
00055 bsfc->filter->close(bsfc);
00056 av_freep(&bsfc->priv_data);
00057 av_parser_close(bsfc->parser);
00058 av_free(bsfc);
00059 }
00060
00061 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
00062 AVCodecContext *avctx, const char *args,
00063 uint8_t **poutbuf, int *poutbuf_size,
00064 const uint8_t *buf, int buf_size, int keyframe){
00065 *poutbuf= (uint8_t *) buf;
00066 *poutbuf_size= buf_size;
00067 return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe);
00068 }