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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
36 ------------------------------------------------------------------------------
40 Purpose : Background noise source charateristic detector (SCD)
42 ------------------------------------------------------------------------------
48 /*----------------------------------------------------------------------------
50 ----------------------------------------------------------------------------*/
54 /*--------------------------------------------------------------------------*/
60 /*----------------------------------------------------------------------------
62 ; [Define module specific macros here]
63 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
67 ; [Include all pre-processor statements here.]
68 ----------------------------------------------------------------------------*/
69 #define L_ENERGYHIST 60
70 #define INV_L_FRAME 102
73 /* 2*(160*x)^2 / 65536 where x is FLP values 150,5 and 50 */
74 #define FRAMEENERGYLIMIT 17578 /* 150 */
75 #define LOWERNOISELIMIT 20 /* 5 */
76 #define UPPERNOISELIMIT 1953 /* 50 */
79 /*----------------------------------------------------------------------------
80 ; EXTERNAL VARIABLES REFERENCES
81 ; [Declare variables used in this module but defined elsewhere]
82 ----------------------------------------------------------------------------*/
84 /*----------------------------------------------------------------------------
86 ----------------------------------------------------------------------------*/
88 /*----------------------------------------------------------------------------
89 ; ENUMERATED TYPEDEF'S
90 ----------------------------------------------------------------------------*/
92 /*----------------------------------------------------------------------------
93 ; STRUCTURES TYPEDEF'S
94 ----------------------------------------------------------------------------*/
97 /* history vector of past synthesis speech energy */
98 Word16 frameEnergyHist[L_ENERGYHIST];
101 Word16 bgHangover; /* counter; number of frames after last speech frame */
105 /*----------------------------------------------------------------------------
106 ; GLOBAL FUNCTION DEFINITIONS
107 ; [List function prototypes here]
108 ----------------------------------------------------------------------------*/
110 * Function : Bgn_scd_init
111 * Purpose : Allocates initializes state memory
112 * Description : Stores pointer to filter status struct in *st. This
113 * pointer has to be passed to Bgn_scd in each call.
114 * Returns : 0 on success
116 Word16 Bgn_scd_init(Bgn_scdState **st);
119 * Function : Bgn_scd_reset
120 * Purpose : Resets state memory
121 * Returns : 0 on success
123 Word16 Bgn_scd_reset(Bgn_scdState *st);
126 * Function : Bgn_scd_exit
127 * Purpose : The memory used for state memory is freed
128 * Description : Stores NULL in *s
131 void Bgn_scd_exit(Bgn_scdState **st);
135 * Purpose : Charaterice synthesis speech and detect background noise
136 * Returns : background noise decision; 0 = bgn, 1 = no bgn
138 Word16 Bgn_scd(Bgn_scdState *st, /* i : State variables for bgn SCD */
139 Word16 ltpGainHist[], /* i : LTP gain history */
140 Word16 speech[], /* o : synthesis speech frame */
141 Word16 *voicedHangover,/* o : # of frames after last voiced frame */
150 #endif /* _BGNSCD_H_ */