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 ------------------------------------------------------------------------------
34 ------------------------------------------------------------------------------
38 Purpose: : Error concealment for pitch and codebook gains
40 ------------------------------------------------------------------------------
45 #define ec_gains_h "$Id $"
47 /*----------------------------------------------------------------------------
49 ----------------------------------------------------------------------------*/
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 ----------------------------------------------------------------------------*/
96 Word16 past_gain_code;
100 /*----------------------------------------------------------------------------
101 ; GLOBAL FUNCTION DEFINITIONS
102 ; [List function prototypes here]
103 ----------------------------------------------------------------------------*/
106 * Function : ec_gain_code_reset
107 * Purpose : Resets state memory
110 Word16 ec_gain_code_reset(
111 ec_gain_codeState *state
116 * Function : ec_gain_code
117 * Purpose : conceal the codebook gain
118 * Call this function only in BFI (instead of normal gain
122 ec_gain_codeState *st, /* i/o : State struct */
123 gc_predState *pred_state, /* i/o : MA predictor state */
124 Word16 state, /* i : state of the state machine */
125 Word16 *gain_code, /* o : decoded innovation gain */
130 * Function : ec_gain_code_update
131 * Purpose : update the codebook gain concealment state;
132 * limit gain_code if the previous frame was bad
133 * Call this function always after decoding (or concealing)
136 void ec_gain_code_update(
137 ec_gain_codeState *st, /* i/o : State struct */
138 Word16 bfi, /* i : flag: frame is bad */
139 Word16 prev_bf, /* i : flag: previous frame was bad */
140 Word16 *gain_code, /* i/o : decoded innovation gain */
146 * Function: ec_gain_pitch_reset
147 * Purpose: Resets state memory
149 Word16 ec_gain_pitch_reset(
150 ec_gain_pitchState *state
154 * Function : ec_gain_pitch_exit
155 * Purpose : The memory used for state memory is freed
157 void ec_gain_pitch_exit(
158 ec_gain_pitchState **state
162 * Function : ec_gain_pitch
163 * Purpose : conceal the pitch gain
164 * Call this function only in BFI (instead of normal gain
168 ec_gain_pitchState *st, /* i/o : state variables */
169 Word16 state, /* i : state of the state machine */
170 Word16 *gain_pitch, /* o : pitch gain (Q14) */
175 * Function : ec_gain_pitch_update
176 * Purpose : update the pitch gain concealment state;
177 * limit gain_pitch if the previous frame was bad
178 * Call this function always after decoding (or concealing)
181 void ec_gain_pitch_update(
182 ec_gain_pitchState *st, /* i/o : state variables */
183 Word16 bfi, /* i : flag: frame is bad */
184 Word16 prev_bf, /* i : flag: previous frame was bad */
185 Word16 *gain_pitch, /* i/o : pitch gain */
194 #endif /* _EC_GAINS_H_ */