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 ****************************************************************************************/
33 ------------------------------------------------------------------------------
37 Purpose : codebook gain MA prediction
39 ------------------------------------------------------------------------------
44 #define gc_pred_h "$Id $"
46 /*----------------------------------------------------------------------------
48 ----------------------------------------------------------------------------*/
53 /*--------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------
61 ; [Define module specific macros here]
62 ----------------------------------------------------------------------------*/
64 /*----------------------------------------------------------------------------
66 ; [Include all pre-processor statements here.]
67 ----------------------------------------------------------------------------*/
69 /*----------------------------------------------------------------------------
70 ; EXTERNAL VARIABLES REFERENCES
71 ; [Declare variables used in this module but defined elsewhere]
72 ----------------------------------------------------------------------------*/
74 /*----------------------------------------------------------------------------
76 ----------------------------------------------------------------------------*/
78 /*----------------------------------------------------------------------------
79 ; ENUMERATED TYPEDEF'S
80 ----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------
83 ; STRUCTURES TYPEDEF'S
84 ----------------------------------------------------------------------------*/
87 Word16 past_qua_en[4]; /* normal MA predictor memory, Q10 */
88 /* (contains 20*log10(qua_err)) */
89 Word16 past_qua_en_MR122[4]; /* MA predictor memory for MR122 mode, Q10 */
90 /* (contains log2(qua_err)) */
93 /*----------------------------------------------------------------------------
94 ; GLOBAL FUNCTION DEFINITIONS
95 ; [List function prototypes here]
96 ----------------------------------------------------------------------------*/
98 OSCL_IMPORT_REF Word16 gc_pred_reset(gc_predState *st);
99 /* reset of codebook gain MA predictor state (i.e. set state memory to zero)
102 void gc_pred_exit(gc_predState **st);
103 /* de-initialize codebook gain MA predictor state (i.e. free state struct)
109 gc_predState *st_src, /* i : State struct */
110 gc_predState *st_dest /* o : State struct */
114 * FUNCTION: gc_pred()
115 * PURPOSE: MA prediction of the innovation energy
116 * (in dB/(20*log10(2))) with mean removed).
118 OSCL_IMPORT_REF void gc_pred(
119 gc_predState *st, /* i/o: State struct */
120 enum Mode mode, /* i : AMR mode */
121 Word16 *code, /* i : innovative codebook vector (L_SUBFR) */
122 /* MR122: Q12, other modes: Q13 */
123 Word16 *exp_gcode0, /* o : exponent of predicted gain factor, Q0 */
124 Word16 *frac_gcode0,/* o : fraction of predicted gain factor Q15 */
125 Word16 *exp_en, /* o : exponent of innovation energy, Q0 */
126 /* (only calculated for MR795) */
127 Word16 *frac_en, /* o : fraction of innovation energy, Q15 */
128 /* (only calculated for MR795) */
133 * FUNCTION: gc_pred_update()
134 * PURPOSE: update MA predictor with last quantized energy
136 OSCL_IMPORT_REF void gc_pred_update(
137 gc_predState *st, /* i/o: State struct */
138 Word16 qua_ener_MR122, /* i : quantized energy for update, Q10 */
139 /* (log2(qua_err)) */
140 Word16 qua_ener /* i : quantized energy for update, Q10 */
141 /* (20*log10(qua_err)) */
145 * FUNCTION: gc_pred_average_limited()
146 * PURPOSE: get average of MA predictor state values (with a lower limit)
147 * [used in error concealment]
149 OSCL_IMPORT_REF void gc_pred_average_limited(
150 gc_predState *st, /* i: State struct */
151 Word16 *ener_avg_MR122, /* o: averaged quantized energy, Q10 */
152 /* (log2(qua_err)) */
153 Word16 *ener_avg, /* o: averaged quantized energy, Q10 */
154 /* (20*log10(qua_err)) */
163 #endif /* _GC_PRED_H_ */