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/src/include/gc_pred.h 32 33 ------------------------------------------------------------------------------ 34 REVISION HISTORY 35 36 Description: Replaced "int" and/or "char" with OSCL defined types. 37 38 Description: Moved _cplusplus #ifdef after Include section. 39 40 Who: Date: 41 Description: 42 43 ------------------------------------------------------------------------------ 44 INCLUDE DESCRIPTION 45 46 File : gc_pred.h 47 Purpose : codebook gain MA prediction 48 49 ------------------------------------------------------------------------------ 50 */ 51 52 #ifndef _GC_PRED_H_ 53 #define _GC_PRED_H_ 54 #define gc_pred_h "$Id $" 55 56 /*---------------------------------------------------------------------------- 57 ; INCLUDES 58 ----------------------------------------------------------------------------*/ 59 #include "typedef.h" 60 #include "mode.h" 61 62 63 /*--------------------------------------------------------------------------*/ 64 #ifdef __cplusplus 65 extern "C" 66 { 67 #endif 68 69 /*---------------------------------------------------------------------------- 70 ; MACROS 71 ; [Define module specific macros here] 72 ----------------------------------------------------------------------------*/ 73 74 /*---------------------------------------------------------------------------- 75 ; DEFINES 76 ; [Include all pre-processor statements here.] 77 ----------------------------------------------------------------------------*/ 78 79 /*---------------------------------------------------------------------------- 80 ; EXTERNAL VARIABLES REFERENCES 81 ; [Declare variables used in this module but defined elsewhere] 82 ----------------------------------------------------------------------------*/ 83 84 /*---------------------------------------------------------------------------- 85 ; SIMPLE TYPEDEF'S 86 ----------------------------------------------------------------------------*/ 87 88 /*---------------------------------------------------------------------------- 89 ; ENUMERATED TYPEDEF'S 90 ----------------------------------------------------------------------------*/ 91 92 /*---------------------------------------------------------------------------- 93 ; STRUCTURES TYPEDEF'S 94 ----------------------------------------------------------------------------*/ 95 typedef struct 96 { 97 Word16 past_qua_en[4]; /* normal MA predictor memory, Q10 */ 98 /* (contains 20*log10(qua_err)) */ 99 Word16 past_qua_en_MR122[4]; /* MA predictor memory for MR122 mode, Q10 */ 100 /* (contains log2(qua_err)) */ 101 } gc_predState; 102 103 /*---------------------------------------------------------------------------- 104 ; GLOBAL FUNCTION DEFINITIONS 105 ; [List function prototypes here] 106 ----------------------------------------------------------------------------*/ 107 108 Word16 gc_pred_reset(gc_predState *st); 109 /* reset of codebook gain MA predictor state (i.e. set state memory to zero) 110 returns 0 on success 111 */ 112 void gc_pred_exit(gc_predState **st); 113 /* de-initialize codebook gain MA predictor state (i.e. free state struct) 114 stores NULL in *st 115 */ 116 117 void 118 gc_pred_copy( 119 gc_predState *st_src, /* i : State struct */ 120 gc_predState *st_dest /* o : State struct */ 121 ); 122 123 /* 124 * FUNCTION: gc_pred() 125 * PURPOSE: MA prediction of the innovation energy 126 * (in dB/(20*log10(2))) with mean removed). 127 */ 128 void gc_pred( 129 gc_predState *st, /* i/o: State struct */ 130 enum Mode mode, /* i : AMR mode */ 131 Word16 *code, /* i : innovative codebook vector (L_SUBFR) */ 132 /* MR122: Q12, other modes: Q13 */ 133 Word16 *exp_gcode0, /* o : exponent of predicted gain factor, Q0 */ 134 Word16 *frac_gcode0,/* o : fraction of predicted gain factor Q15 */ 135 Word16 *exp_en, /* o : exponent of innovation energy, Q0 */ 136 /* (only calculated for MR795) */ 137 Word16 *frac_en, /* o : fraction of innovation energy, Q15 */ 138 /* (only calculated for MR795) */ 139 Flag *pOverflow 140 ); 141 142 /* 143 * FUNCTION: gc_pred_update() 144 * PURPOSE: update MA predictor with last quantized energy 145 */ 146 void gc_pred_update( 147 gc_predState *st, /* i/o: State struct */ 148 Word16 qua_ener_MR122, /* i : quantized energy for update, Q10 */ 149 /* (log2(qua_err)) */ 150 Word16 qua_ener /* i : quantized energy for update, Q10 */ 151 /* (20*log10(qua_err)) */ 152 ); 153 154 /* 155 * FUNCTION: gc_pred_average_limited() 156 * PURPOSE: get average of MA predictor state values (with a lower limit) 157 * [used in error concealment] 158 */ 159 void gc_pred_average_limited( 160 gc_predState *st, /* i: State struct */ 161 Word16 *ener_avg_MR122, /* o: averaged quantized energy, Q10 */ 162 /* (log2(qua_err)) */ 163 Word16 *ener_avg, /* o: averaged quantized energy, Q10 */ 164 /* (20*log10(qua_err)) */ 165 Flag *pOverflow 166 ); 167 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* _GC_PRED_H_ */ 174 175 176 177