1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
33 ------------------------------------------------------------------------------
36 This file contains all the constant definitions, prototype and structure
37 definitions needed by vad_1.c
39 ------------------------------------------------------------------------------
42 /*----------------------------------------------------------------------------
43 ; CONTINUE ONLY IF NOT ALREADY DEFINED
44 ----------------------------------------------------------------------------*/
46 #define vad_1_h "$Id $"
48 /*----------------------------------------------------------------------------
50 ----------------------------------------------------------------------------*/
54 /*--------------------------------------------------------------------------*/
60 /*----------------------------------------------------------------------------
62 ; Define module specific macros here
63 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
67 ; Include all pre-processor statements here.
68 ----------------------------------------------------------------------------*/
70 /*----------------------------------------------------------------------------
71 ; EXTERNAL VARIABLES REFERENCES
72 ; Declare variables used in this module but defined elsewhere
73 ----------------------------------------------------------------------------*/
75 /*----------------------------------------------------------------------------
77 ----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------
80 ; ENUMERATED TYPEDEF'S
81 ----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------
84 ; STRUCTURES TYPEDEF'S
85 ----------------------------------------------------------------------------*/
90 Word16 bckr_est[COMPLEN]; /* background noise estimate */
91 Word16 ave_level[COMPLEN]; /* averaged input components for stationary */
93 Word16 old_level[COMPLEN]; /* input levels of the previous frame */
94 Word16 sub_level[COMPLEN]; /* input levels calculated at the end of
95 a frame (lookahead) */
96 Word16 a_data5[3][2]; /* memory for the filter bank */
97 Word16 a_data3[5]; /* memory for the filter bank */
99 Word16 burst_count; /* counts length of a speech burst */
100 Word16 hang_count; /* hangover counter */
101 Word16 stat_count; /* stationary counter */
103 /* Note that each of the following three variables (vadreg, pitch and tone)
104 holds 15 flags. Each flag reserves 1 bit of the variable. The newest
105 flag is in the bit 15 (assuming that LSB is bit 1 and MSB is bit 16). */
106 Word16 vadreg; /* flags for intermediate VAD decisions */
107 Word16 pitch; /* flags for pitch detection */
108 Word16 tone; /* flags for tone detection */
109 Word16 complex_high; /* flags for complex detection */
110 Word16 complex_low; /* flags for complex detection */
112 Word16 oldlag_count, oldlag; /* variables for pitch detection */
114 Word16 complex_hang_count; /* complex hangover counter, used by VAD */
115 Word16 complex_hang_timer; /* hangover initiator, used by CAD */
117 Word16 best_corr_hp; /* FIP filtered value Q15 */
119 Word16 speech_vad_decision; /* final decision */
120 Word16 complex_warning; /* complex background warning */
122 Word16 sp_burst_count; /* counts length of a speech burst incl */
123 Word16 corr_hp_fast; /* filtered value */
125 /*----------------------------------------------------------------------------
126 ; GLOBAL FUNCTION DEFINITIONS
127 ; Function Prototype declaration
128 ----------------------------------------------------------------------------*/
129 Word16 vad1_init(vadState1 **st);
130 /* initialize one instance of the pre processing state.
131 Stores pointer to filter status struct in *st. This pointer has to
132 be passed to vad in each call.
136 Word16 vad1_reset(vadState1 *st);
137 /* reset of pre processing state (i.e. set state memory to zero)
141 void vad1_exit(vadState1 **st);
142 /* de-initialize pre processing state (i.e. free status struct)
146 void vad_complex_detection_update(vadState1 *st, /* i/o : State struct */
147 Word16 best_corr_hp /* i : best Corr Q15 */
150 void vad_tone_detection(vadState1 *st, /* i/o : State struct */
151 Word32 t0, /* i : autocorrelation maxima */
152 Word32 t1, /* i : energy */
156 void vad_tone_detection_update(
157 vadState1 *st, /* i/o : State struct */
158 Word16 one_lag_per_frame, /* i : 1 if one open-loop lag is
159 calculated per each frame,
164 void vad_pitch_detection(vadState1 *st, /* i/o : State struct */
165 Word16 lags[], /* i : speech encoder open loop lags */
169 Word16 vad1(vadState1 *st, /* i/o : State struct */
170 Word16 in_buf[], /* i : samples of the input frame
171 inbuf[159] is the very last sample,
176 /*----------------------------------------------------------------------------
178 ----------------------------------------------------------------------------*/
183 #endif /* _VAD1_H_ */