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 32 33 34 Filename: /audio/gsm_amr/c/src/include/ec_gains.h 35 36 Date: 01/28/2002 37 38 ------------------------------------------------------------------------------ 39 REVISION HISTORY 40 41 Description: Replaced "int" and/or "char" with OSCL defined types. 42 43 Description: Moved _cplusplus #ifdef after Include section. 44 45 Description: 46 47 ------------------------------------------------------------------------------ 48 INCLUDE DESCRIPTION 49 50 File : ec_gains.c 51 Purpose: : Error concealment for pitch and codebook gains 52 53 ------------------------------------------------------------------------------ 54 */ 55 56 #ifndef _EC_GAINS_H_ 57 #define _EC_GAINS_H_ 58 #define ec_gains_h "$Id $" 59 60 /*---------------------------------------------------------------------------- 61 ; INCLUDES 62 ----------------------------------------------------------------------------*/ 63 #include "typedef.h" 64 #include "gc_pred.h" 65 66 67 /*--------------------------------------------------------------------------*/ 68 #ifdef __cplusplus 69 extern "C" 70 { 71 #endif 72 73 /*---------------------------------------------------------------------------- 74 ; MACROS 75 ; [Define module specific macros here] 76 ----------------------------------------------------------------------------*/ 77 78 /*---------------------------------------------------------------------------- 79 ; DEFINES 80 ; [Include all pre-processor statements here.] 81 ----------------------------------------------------------------------------*/ 82 83 /*---------------------------------------------------------------------------- 84 ; EXTERNAL VARIABLES REFERENCES 85 ; [Declare variables used in this module but defined elsewhere] 86 ----------------------------------------------------------------------------*/ 87 88 /*---------------------------------------------------------------------------- 89 ; SIMPLE TYPEDEF'S 90 ----------------------------------------------------------------------------*/ 91 92 /*---------------------------------------------------------------------------- 93 ; ENUMERATED TYPEDEF'S 94 ----------------------------------------------------------------------------*/ 95 96 /*---------------------------------------------------------------------------- 97 ; STRUCTURES TYPEDEF'S 98 ----------------------------------------------------------------------------*/ 99 typedef struct 100 { 101 Word16 pbuf[5]; 102 Word16 past_gain_pit; 103 Word16 prev_gp; 104 } ec_gain_pitchState; 105 106 typedef struct 107 { 108 Word16 gbuf[5]; 109 Word16 past_gain_code; 110 Word16 prev_gc; 111 } ec_gain_codeState; 112 113 /*---------------------------------------------------------------------------- 114 ; GLOBAL FUNCTION DEFINITIONS 115 ; [List function prototypes here] 116 ----------------------------------------------------------------------------*/ 117 118 /* 119 * Function : ec_gain_code_reset 120 * Purpose : Resets state memory 121 * 122 */ 123 Word16 ec_gain_code_reset( 124 ec_gain_codeState *state 125 ); 126 127 128 /* 129 * Function : ec_gain_code 130 * Purpose : conceal the codebook gain 131 * Call this function only in BFI (instead of normal gain 132 * decoding function) 133 */ 134 void ec_gain_code( 135 ec_gain_codeState *st, /* i/o : State struct */ 136 gc_predState *pred_state, /* i/o : MA predictor state */ 137 Word16 state, /* i : state of the state machine */ 138 Word16 *gain_code, /* o : decoded innovation gain */ 139 Flag *pOverflow 140 ); 141 142 /* 143 * Function : ec_gain_code_update 144 * Purpose : update the codebook gain concealment state; 145 * limit gain_code if the previous frame was bad 146 * Call this function always after decoding (or concealing) 147 * the gain 148 */ 149 void ec_gain_code_update( 150 ec_gain_codeState *st, /* i/o : State struct */ 151 Word16 bfi, /* i : flag: frame is bad */ 152 Word16 prev_bf, /* i : flag: previous frame was bad */ 153 Word16 *gain_code, /* i/o : decoded innovation gain */ 154 Flag *pOverflow 155 ); 156 157 158 /* 159 * Function: ec_gain_pitch_reset 160 * Purpose: Resets state memory 161 */ 162 Word16 ec_gain_pitch_reset( 163 ec_gain_pitchState *state 164 ); 165 166 /* 167 * Function : ec_gain_pitch_exit 168 * Purpose : The memory used for state memory is freed 169 */ 170 void ec_gain_pitch_exit( 171 ec_gain_pitchState **state 172 ); 173 174 /* 175 * Function : ec_gain_pitch 176 * Purpose : conceal the pitch gain 177 * Call this function only in BFI (instead of normal gain 178 * decoding function) 179 */ 180 void ec_gain_pitch( 181 ec_gain_pitchState *st, /* i/o : state variables */ 182 Word16 state, /* i : state of the state machine */ 183 Word16 *gain_pitch, /* o : pitch gain (Q14) */ 184 Flag *pOverflow 185 ); 186 187 /* 188 * Function : ec_gain_pitch_update 189 * Purpose : update the pitch gain concealment state; 190 * limit gain_pitch if the previous frame was bad 191 * Call this function always after decoding (or concealing) 192 * the gain 193 */ 194 void ec_gain_pitch_update( 195 ec_gain_pitchState *st, /* i/o : state variables */ 196 Word16 bfi, /* i : flag: frame is bad */ 197 Word16 prev_bf, /* i : flag: previous frame was bad */ 198 Word16 *gain_pitch, /* i/o : pitch gain */ 199 Flag *pOverflow 200 ); 201 202 203 #ifdef __cplusplus 204 } 205 #endif 206 207 #endif /* _EC_GAINS_H_ */ 208 209 210