annotate noise_bsf.c @ 7069:92bcfa9ba977 libavcodec

Factorize I >> (c->tbls->bits - 1) out.
author michael
date Thu, 19 Jun 2008 10:29:36 +0000
parents 969b9d3d3f45
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
1 /*
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
3 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
4 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
5 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
8 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
10 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
14 * Lesser General Public License for more details.
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
15 *
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 3422
diff changeset
19 */
3421
b7826511f7b6 AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff changeset
20
b7826511f7b6 AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff changeset
21 #include "avcodec.h"
b7826511f7b6 AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff changeset
22
b7826511f7b6 AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
diff changeset
23
3422
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
24 static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
25 uint8_t **poutbuf, int *poutbuf_size,
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
26 const uint8_t *buf, int buf_size, int keyframe){
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
27 unsigned int *state= bsfc->priv_data;
6131
969b9d3d3f45 Randomly change the amount of noise if nothing is explicitly set.
michael
parents: 5035
diff changeset
28 int amount= args ? atoi(args) : (*state % 10001+1);
3422
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
29 int i;
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
30
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
31 *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
32
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
33 memcpy(*poutbuf, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
34 for(i=0; i<buf_size; i++){
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
35 (*state) += (*poutbuf)[i] + 1;
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
36 if(*state % amount == 0)
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
37 (*poutbuf)[i] = *state;
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
38 }
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
39 return 1;
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
40 }
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
41
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
42 AVBitStreamFilter noise_bsf={
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
43 "noise",
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
44 sizeof(int),
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
45 noise,
6ce5ece8e2ea noise bitstream filter
michael
parents: 3421
diff changeset
46 };