]>
Commit | Line | Data |
---|---|---|
45516216 | 1 | typedef struct af_data_s { |
2 | int format; | |
3 | } af_data_t; | |
4 | typedef struct af_info_s { | |
5 | const char *info; | |
6 | const char *name; | |
7 | const char *author; | |
8 | const char *comment; | |
9 | const int flags; | |
10 | int (*open) (struct af_instance_s * vf); | |
11 | } af_info_t; | |
12 | typedef struct af_instance_s { | |
13 | af_data_t *(*play) (struct af_instance_s * af, af_data_t * data); | |
14 | void *setup; | |
15 | af_data_t *data; | |
16 | } af_instance_t; | |
17 | typedef struct af_volume_s { | |
18 | int method; | |
19 | float mul; | |
20 | struct { | |
21 | float avg; | |
22 | int len; | |
23 | } mem[128]; | |
24 | float mid_s16; | |
25 | } af_volnorm_t; | |
26 | static void method2_int16(af_volnorm_t * s, af_data_t * c) | |
27 | { | |
28 | register int i = 0; | |
29 | float curavg = 0.0, newavg, avg = 0.0; | |
30 | int tmp, totallen = 0; | |
31 | for (i = 0; i < 128; i++) { | |
32 | avg += s->mem[i].avg * (float)s->mem[i].len; | |
33 | totallen += s->mem[i].len; | |
34 | } | |
35 | if (totallen > 32000) { | |
36 | if (avg >= (32767 * 0.01)) { | |
37 | s->mul = s->mid_s16 / avg; | |
38 | } | |
39 | } | |
40 | } | |
41 | static af_data_t *play(struct af_instance_s *af, af_data_t * data) | |
42 | { | |
43 | af_volnorm_t *s = af->setup; | |
44 | if (af->data->format == (((0 << 2) | (0 << 1) | (1 << 3) | (0 << 0)))) { | |
45 | if (s->method) | |
46 | method2_int16(s, data); | |
47 | } | |
48 | } | |
49 | static int af_open(af_instance_t * af) | |
50 | { | |
51 | af->play = play; | |
52 | } | |
53 | ||
54 | af_info_t af_info_volnorm = { | |
55 | "Volume normalizer filter", "volnorm", | |
56 | "Alex Beregszaszi & Pierre Lombard", "", 0x00000001, af_open | |
57 | }; |