FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/vad1.h @ 412:810ac4b99025
libtwamr: integrate VAD2 r_fft.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 07 May 2024 01:22:02 +0000 |
parents | 8847c1740e78 |
children |
rev | line source |
---|---|
408
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 **-------------------------------------------------------------------------** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 ** ** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 ** GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 ** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 ** R99 Version 3.3.0 ** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 ** REL-4 Version 4.1.0 ** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ** ** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 **-------------------------------------------------------------------------** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * File : vad1.h |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * Purpose : Voice Activity Detection (VAD) for AMR (option 1) |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #ifndef vad1_h |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #define vad1_h "$Id $" |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 /* |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 * INCLUDE FILES |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "typedef.h" |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "cnst_vad.h" |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 * LOCAL VARIABLES AND TABLES |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * DEFINITION OF DATA TYPES |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* state variable */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 typedef struct { |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 Word16 bckr_est[COMPLEN]; /* background noise estimate */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 Word16 ave_level[COMPLEN]; /* averaged input components for stationary */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* estimation */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 Word16 old_level[COMPLEN]; /* input levels of the previous frame */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 Word16 sub_level[COMPLEN]; /* input levels calculated at the end of |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 a frame (lookahead) */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 Word16 a_data5[3][2]; /* memory for the filter bank */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 Word16 a_data3[5]; /* memory for the filter bank */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 Word16 burst_count; /* counts length of a speech burst */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 Word16 hang_count; /* hangover counter */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 Word16 stat_count; /* stationary counter */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /* Note that each of the following three variables (vadreg, pitch and tone) |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 holds 15 flags. Each flag reserves 1 bit of the variable. The newest |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 flag is in the bit 15 (assuming that LSB is bit 1 and MSB is bit 16). */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 Word16 vadreg; /* flags for intermediate VAD decisions */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 pitch; /* flags for pitch detection */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word16 tone; /* flags for tone detection */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 Word16 complex_high; /* flags for complex detection */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 complex_low; /* flags for complex detection */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word16 oldlag_count, oldlag; /* variables for pitch detection */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 Word16 complex_hang_count; /* complex hangover counter, used by VAD */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 Word16 complex_hang_timer; /* hangover initiator, used by CAD */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 best_corr_hp; /* FIP filtered value Q15 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 Word16 speech_vad_decision; /* final decision */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 complex_warning; /* complex background warning */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Word16 sp_burst_count; /* counts length of a speech burst incl |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 HO addition */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 corr_hp_fast; /* filtered value */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } vadState1; |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 /* |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 * DECLARATION OF PROTOTYPES |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 ******************************************************************************** |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 void vad1_reset (vadState1 *st); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 /* reset of pre processing state (i.e. set state memory to zero) |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 returns 0 on success |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 void vad_complex_detection_update (vadState1 *st, /* i/o : State struct */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 Word16 best_corr_hp /* i : best Corr Q15 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 ); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 void vad_tone_detection (vadState1 *st, /* i/o : State struct */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 Word32 t0, /* i : autocorrelation maxima */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 Word32 t1 /* i : energy */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 ); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 void vad_tone_detection_update ( |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 vadState1 *st, /* i/o : State struct */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 Word16 one_lag_per_frame /* i : 1 if one open-loop lag is |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 calculated per each frame, |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 otherwise 0 */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 ); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 void vad_pitch_detection (vadState1 *st, /* i/o : State struct */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 Word16 lags[] /* i : speech encoder open loop lags */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 ); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 Word16 vad1 (vadState1 *st, /* i/o : State struct */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 Word16 in_buf[] /* i : samples of the input frame |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 inbuf[159] is the very last sample, |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 incl lookahead */ |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 ); |
8847c1740e78
libtwamr: integrate VAD1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 #endif |