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 ----------------------------------------------------------------------------*/
55 /*--------------------------------------------------------------------------*/
61 /*----------------------------------------------------------------------------
63 ; [Define module specific macros here]
64 ----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------
68 ; [Include all pre-processor statements here.]
69 ----------------------------------------------------------------------------*/
70 #define L_CBGAINHIST 7
72 /*----------------------------------------------------------------------------
73 ; EXTERNAL VARIABLES REFERENCES
74 ; [Declare variables used in this module but defined elsewhere]
75 ----------------------------------------------------------------------------*/
77 /*----------------------------------------------------------------------------
79 ----------------------------------------------------------------------------*/
81 /*----------------------------------------------------------------------------
82 ; ENUMERATED TYPEDEF'S
83 ----------------------------------------------------------------------------*/
85 /*----------------------------------------------------------------------------
86 ; STRUCTURES TYPEDEF'S
87 ----------------------------------------------------------------------------*/
90 /* history vector of past synthesis speech energy */
91 Word16 cbGainHistory[L_CBGAINHIST];
94 Word16 hangVar; /* counter; */
95 Word16 hangCount; /* counter; */
97 } Cb_gain_averageState;
99 /*----------------------------------------------------------------------------
100 ; GLOBAL FUNCTION DEFINITIONS
101 ; [List function prototypes here]
102 ----------------------------------------------------------------------------*/
104 * Function : Cb_gain_average_init
105 * Purpose : Allocates initializes state memory
106 * Description : Stores pointer to filter status struct in *st. This
107 * pointer has to be passed to Cb_gain_average in each call.
108 * Returns : 0 on success
110 Word16 Cb_gain_average_init(Cb_gain_averageState **st);
113 * Function : Cb_gain_average_reset
114 * Purpose : Resets state memory
115 * Returns : 0 on success
117 Word16 Cb_gain_average_reset(Cb_gain_averageState *st);
120 * Function : Cb_gain_average_exit
121 * Purpose : The memory used for state memory is freed
122 * Description : Stores NULL in *s
125 void Cb_gain_average_exit(Cb_gain_averageState **st);
128 * Function : Cb_gain_average
129 * Purpose : Charaterice synthesis speech and detect background noise
130 * Returns : background noise decision; 0 = bgn, 1 = no bgn
132 Word16 Cb_gain_average(
133 Cb_gain_averageState *st, /* i/o : State variables for CB gain avergeing */
134 enum Mode mode, /* i : AMR mode */
135 Word16 gain_code, /* i : CB gain Q1 */
136 Word16 lsp[], /* i : The LSP for the current frame Q15 */
137 Word16 lspAver[], /* i : The average of LSP for 8 frames Q15 */
138 Word16 bfi, /* i : bad frame indication flag */
139 Word16 prev_bf, /* i : previous bad frame indication flag */
140 Word16 pdfi, /* i : potential degraded bad frame ind flag */
141 Word16 prev_pdf, /* i : prev pot. degraded bad frame ind flag */
142 Word16 inBackgroundNoise, /* i : background noise decision */
143 Word16 voicedHangover, /* i : # of frames after last voiced frame */
152 #endif /* _C_G_AVER_H_ */