# HG changeset patch # User michael # Date 1152199697 0 # Node ID 6ce5ece8e2ea5e93470b7fb2aad8b6768a7bd276 # Parent b7826511f7b6b84fe12756391626d6fc07ee92cc noise bitstream filter add priv_data field to AVBitStreamFilterContext diff -r b7826511f7b6 -r 6ce5ece8e2ea allcodecs.c --- a/allcodecs.c Thu Jul 06 15:04:46 2006 +0000 +++ b/allcodecs.c Thu Jul 06 15:28:17 2006 +0000 @@ -664,5 +664,6 @@ av_register_bitstream_filter(&dump_extradata_bsf); av_register_bitstream_filter(&remove_extradata_bsf); + av_register_bitstream_filter(&noise_bsf); } diff -r b7826511f7b6 -r 6ce5ece8e2ea avcodec.h --- a/avcodec.h Thu Jul 06 15:04:46 2006 +0000 +++ b/avcodec.h Thu Jul 06 15:28:17 2006 +0000 @@ -2573,6 +2573,7 @@ typedef struct AVBitStreamFilterContext { + void *priv_data; struct AVBitStreamFilter *filter; AVCodecParserContext *parser; struct AVBitStreamFilterContext *next; @@ -2581,6 +2582,7 @@ typedef struct AVBitStreamFilter { const char *name; + int priv_data_size; int (*filter)(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, @@ -2600,6 +2602,7 @@ extern AVBitStreamFilter dump_extradata_bsf; extern AVBitStreamFilter remove_extradata_bsf; +extern AVBitStreamFilter noise_bsf; /* memory */ diff -r b7826511f7b6 -r 6ce5ece8e2ea bitstream_filter.c --- a/bitstream_filter.c Thu Jul 06 15:04:46 2006 +0000 +++ b/bitstream_filter.c Thu Jul 06 15:28:17 2006 +0000 @@ -15,6 +15,7 @@ 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; @@ -23,6 +24,7 @@ } void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){ + av_freep(&bsfc->priv_data); av_parser_close(bsfc->parser); av_free(bsfc); } @@ -31,6 +33,8 @@ 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); } @@ -39,8 +43,6 @@ 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)) @@ -85,12 +87,38 @@ 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