00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <string.h>
00023
00024 #include "avcodec.h"
00025 #include "libavutil/mem.h"
00026
00027
00028 static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
00029 uint8_t **poutbuf, int *poutbuf_size,
00030 const uint8_t *buf, int buf_size, int keyframe){
00031 unsigned int *state= bsfc->priv_data;
00032 int amount= args ? atoi(args) : (*state % 10001+1);
00033 int i;
00034
00035 if(amount <= 0)
00036 return AVERROR(EINVAL);
00037
00038 *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
00039
00040 memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
00041 for(i=0; i<buf_size; i++){
00042 (*state) += (*poutbuf)[i] + 1;
00043 if(*state % amount == 0)
00044 (*poutbuf)[i] = *state;
00045 }
00046 return 1;
00047 }
00048
00049 AVBitStreamFilter ff_noise_bsf={
00050 "noise",
00051 sizeof(int),
00052 noise,
00053 };