+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include "avcodec.h"
if(!strcmp(name, bsf->name)){
AVBitStreamFilterContext *bsfc= av_mallocz(sizeof(AVBitStreamFilterContext));
bsfc->filter= bsf;
+ bsfc->priv_data= av_mallocz(bsf->priv_data_size);
return bsfc;
}
bsf= bsf->next;
}
void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){
+ av_freep(&bsfc->priv_data);
av_parser_close(bsfc->parser);
av_free(bsfc);
}
AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size, int keyframe){
+ *poutbuf= (uint8_t *) buf;
+ *poutbuf_size= buf_size;
return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe);
}
const uint8_t *buf, int buf_size, int keyframe){
int cmd= args ? *args : 0;
/* cast to avoid warning about discarding qualifiers */
- *poutbuf= (uint8_t *) buf;
- *poutbuf_size= buf_size;
if(avctx->extradata){
if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) && cmd=='a')
||(keyframe && (cmd=='k' || !cmd))
return 0;
}
+static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size, int keyframe){
+ int amount= args ? atoi(args) : 10000;
+ unsigned int *state= bsfc->priv_data;
+ int i;
+
+ *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ for(i=0; i<buf_size; i++){
+ (*state) += (*poutbuf)[i] + 1;
+ if(*state % amount == 0)
+ (*poutbuf)[i] = *state;
+ }
+ return 1;
+}
+
AVBitStreamFilter dump_extradata_bsf={
"dump_extra",
+ 0,
dump_extradata,
};
AVBitStreamFilter remove_extradata_bsf={
"remove_extra",
+ 0,
remove_extradata,
};
+
+AVBitStreamFilter noise_bsf={
+ "noise",
+ sizeof(int),
+ noise,
+};