comparison libtwamr/vad1.h @ 408:8847c1740e78

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