• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /* ------------------------------------------------------------------
2   * Copyright (C) 1998-2009 PacketVideo
3   *
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
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
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
13   * express or implied.
14   * See the License for the specific language governing permissions
15   * and limitations under the License.
16   * -------------------------------------------------------------------
17   */
18  /****************************************************************************************
19  Portions of this file are derived from the following 3GPP standard:
20  
21      3GPP TS 26.073
22      ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23      Available from http://www.3gpp.org
24  
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  ****************************************************************************************/
29  /*
30  
31   Filename: /audio/gsm_amr/c/include/vad_1.h
32  
33  ------------------------------------------------------------------------------
34   REVISION HISTORY
35  
36   Description: Placed header file in the proper template format.  Added
37   parameter pOverflow for the basic math ops.
38  
39   Description:  Replaced "int" and/or "char" with OSCL defined types.
40  
41   Description: Moved _cplusplus #ifdef after Include section.
42  
43   Description:
44  
45  ------------------------------------------------------------------------------
46   INCLUDE DESCRIPTION
47  
48   This file contains all the constant definitions, prototype and structure
49   definitions needed by vad_1.c
50  
51  ------------------------------------------------------------------------------
52  */
53  
54  /*----------------------------------------------------------------------------
55  ; CONTINUE ONLY IF NOT ALREADY DEFINED
56  ----------------------------------------------------------------------------*/
57  #ifndef vad_1_h
58  #define vad_1_h "$Id $"
59  
60  /*----------------------------------------------------------------------------
61  ; INCLUDES
62  ----------------------------------------------------------------------------*/
63  #include "typedef.h"
64  #include "cnst_vad.h"
65  
66  /*--------------------------------------------------------------------------*/
67  #ifdef __cplusplus
68  extern "C"
69  {
70  #endif
71  
72      /*----------------------------------------------------------------------------
73      ; MACROS
74      ; Define module specific macros here
75      ----------------------------------------------------------------------------*/
76  
77      /*----------------------------------------------------------------------------
78      ; DEFINES
79      ; Include all pre-processor statements here.
80      ----------------------------------------------------------------------------*/
81  
82      /*----------------------------------------------------------------------------
83      ; EXTERNAL VARIABLES REFERENCES
84      ; Declare variables used in this module but defined elsewhere
85      ----------------------------------------------------------------------------*/
86  
87      /*----------------------------------------------------------------------------
88      ; SIMPLE TYPEDEF'S
89      ----------------------------------------------------------------------------*/
90  
91      /*----------------------------------------------------------------------------
92      ; ENUMERATED TYPEDEF'S
93      ----------------------------------------------------------------------------*/
94  
95      /*----------------------------------------------------------------------------
96      ; STRUCTURES TYPEDEF'S
97      ----------------------------------------------------------------------------*/
98      /* state variable */
99      typedef struct
100      {
101  
102          Word16 bckr_est[COMPLEN];    /* background noise estimate                */
103          Word16 ave_level[COMPLEN];   /* averaged input components for stationary */
104          /*    estimation                            */
105          Word16 old_level[COMPLEN];   /* input levels of the previous frame       */
106          Word16 sub_level[COMPLEN];   /* input levels calculated at the end of
107                                        a frame (lookahead)                   */
108          Word16 a_data5[3][2];        /* memory for the filter bank               */
109          Word16 a_data3[5];           /* memory for the filter bank               */
110  
111          Word16 burst_count;          /* counts length of a speech burst          */
112          Word16 hang_count;           /* hangover counter                         */
113          Word16 stat_count;           /* stationary counter                       */
114  
115          /* Note that each of the following three variables (vadreg, pitch and tone)
116             holds 15 flags. Each flag reserves 1 bit of the variable. The newest
117             flag is in the bit 15 (assuming that LSB is bit 1 and MSB is bit 16). */
118          Word16 vadreg;               /* flags for intermediate VAD decisions     */
119          Word16 pitch;                /* flags for pitch detection                */
120          Word16 tone;                 /* flags for tone detection                 */
121          Word16 complex_high;         /* flags for complex detection              */
122          Word16 complex_low;          /* flags for complex detection              */
123  
124          Word16 oldlag_count, oldlag; /* variables for pitch detection            */
125  
126          Word16 complex_hang_count;   /* complex hangover counter, used by VAD    */
127          Word16 complex_hang_timer;   /* hangover initiator, used by CAD          */
128  
129          Word16 best_corr_hp;         /* FIP filtered value Q15                   */
130  
131          Word16 speech_vad_decision;  /* final decision                           */
132          Word16 complex_warning;      /* complex background warning               */
133  
134          Word16 sp_burst_count;       /* counts length of a speech burst incl     */
135          Word16 corr_hp_fast;         /* filtered value                           */
136      } vadState1;
137      /*----------------------------------------------------------------------------
138      ; GLOBAL FUNCTION DEFINITIONS
139      ; Function Prototype declaration
140      ----------------------------------------------------------------------------*/
141      Word16 vad1_init(vadState1 **st);
142      /* initialize one instance of the pre processing state.
143         Stores pointer to filter status struct in *st. This pointer has to
144         be passed to vad in each call.
145         returns 0 on success
146       */
147  
148      Word16 vad1_reset(vadState1 *st);
149      /* reset of pre processing state (i.e. set state memory to zero)
150         returns 0 on success
151       */
152  
153      void vad1_exit(vadState1 **st);
154      /* de-initialize pre processing state (i.e. free status struct)
155         stores NULL in *st
156       */
157  
158      void vad_complex_detection_update(vadState1 *st,       /* i/o : State struct     */
159                                        Word16 best_corr_hp /* i   : best Corr Q15    */
160                                       );
161  
162      void vad_tone_detection(vadState1 *st,  /* i/o : State struct            */
163                              Word32 t0,     /* i   : autocorrelation maxima  */
164                              Word32 t1,     /* i   : energy                  */
165                              Flag   *pOverflow
166                             );
167  
168      void vad_tone_detection_update(
169          vadState1 *st,             /* i/o : State struct              */
170          Word16 one_lag_per_frame,  /* i   : 1 if one open-loop lag is
171                                                calculated per each frame,
172                                                otherwise 0                     */
173          Flag *pOverflow
174      );
175  
176      void vad_pitch_detection(vadState1 *st,   /* i/o : State struct                  */
177                               Word16 lags[],  /* i   : speech encoder open loop lags */
178                               Flag   *pOverflow
179                              );
180  
181      Word16 vad1(vadState1 *st,   /* i/o : State struct                      */
182                  Word16 in_buf[], /* i   : samples of the input frame
183                                  inbuf[159] is the very last sample,
184                                  incl lookahead                          */
185                  Flag *pOverflow
186                 );
187  
188      /*----------------------------------------------------------------------------
189      ; END
190      ----------------------------------------------------------------------------*/
191  #ifdef __cplusplus
192  }
193  #endif
194  
195  #endif /* _VAD1_H_ */
196  
197  
198