FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/agc.h @ 484:20d44cfc219c
CHANGES: list all new command line utils
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 20 May 2024 01:42:38 +0000 |
parents | 6b33f3ba4289 |
children |
rev | line source |
---|---|
253
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : agc.h |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Scales the postfilter output on a subframe basis |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * : by automatic control of the subframe gain. |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #ifndef agc_h |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #define agc_h "$Id $" |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * INCLUDE FILES |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "typedef.h" |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 * DEFINITION OF DATA TYPES |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 typedef struct { |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 Word16 past_gain; |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } agcState; |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * DECLARATION OF PROTOTYPES |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ***************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * Function : agc_reset |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * Purpose : Reset of agc (i.e. set state memory to 1.0) |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * Returns : 0 on success |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 */ |
307
6b33f3ba4289
libtwamr: go for single-chunk-state approach
Mychaela Falconia <falcon@freecalypso.org>
parents:
253
diff
changeset
|
49 void agc_reset (agcState *st); |
253
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * Function : agc |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * Purpose : Scales the postfilter output on a subframe basis |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 * Description : sig_out[n] = sig_out[n] * gain[n]; |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * where gain[n] is the gain at the nth sample given by |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * gain[n] = agc_fac * gain[n-1] + (1 - agc_fac) g_in/g_out |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * g_in/g_out is the square root of the ratio of energy at |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * the input and output of the postfilter. |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 int agc ( |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 agcState *st, /* i/o : agc state */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 Word16 *sig_in, /* i : postfilter input signal, (l_trm) */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 Word16 *sig_out, /* i/o : postfilter output signal, (l_trm) */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 Word16 agc_fac, /* i : AGC factor */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Word16 l_trm /* i : subframe size */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 ); |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 /* |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 * Function: agc2 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * Purpose: Scales the excitation on a subframe basis |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 ************************************************************************** |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 void agc2 ( |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 Word16 *sig_in, /* i : postfilter input signal */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 Word16 *sig_out, /* i/o : postfilter output signal */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 Word16 l_trm /* i : subframe size */ |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 ); |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 |
54f6bc41ed10
libtwamr: integrate a* modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 #endif |