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 : Speech decoder routine.
42 ------------------------------------------------------------------------------
45 /*----------------------------------------------------------------------------
46 ; CONTINUE ONLY IF NOT ALREADY DEFINED
47 ----------------------------------------------------------------------------*/
49 #define DEC_AMR_H "$Id $"
51 /*----------------------------------------------------------------------------
53 ----------------------------------------------------------------------------*/
66 #include "get_const_tbls.h"
68 /*--------------------------------------------------------------------------*/
74 /*----------------------------------------------------------------------------
76 ; Define module specific macros here
77 ----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------
81 ; Include all pre-processor statements here.
82 ----------------------------------------------------------------------------*/
83 #define EXC_ENERGY_HIST_LEN 9
84 #define LTP_GAIN_HISTORY_LEN 9
85 /*----------------------------------------------------------------------------
86 ; EXTERNAL VARIABLES REFERENCES
87 ; Declare variables used in this module but defined elsewhere
88 ----------------------------------------------------------------------------*/
90 /*----------------------------------------------------------------------------
92 ----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------
95 ; ENUMERATED TYPEDEF'S
96 ----------------------------------------------------------------------------*/
98 /*----------------------------------------------------------------------------
99 ; STRUCTURES TYPEDEF'S
100 ----------------------------------------------------------------------------*/
103 /* Excitation vector */
104 Word16 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
107 /* Lsp (Line spectral pairs) */
108 /* Word16 lsp[M]; */ /* Used by CN codec */
111 /* Filter's memory */
114 /* pitch sharpening */
118 /* Memories for bad frame handling */
122 Word16 excEnergyHist[EXC_ENERGY_HIST_LEN];
124 /* Variable holding received ltpLag, used in background noise and BFI */
127 /* Variables for the source characteristic detector (SCD) */
128 Word16 inBackgroundNoise;
129 Word16 voicedHangover;
130 Word16 ltpGainHistory[LTP_GAIN_HISTORY_LEN];
132 Bgn_scdState background_state;
135 Cb_gain_averageState Cb_gain_averState;
136 lsp_avgState lsp_avg_st;
138 D_plsfState lsfState;
139 ec_gain_pitchState ec_gain_p_st;
140 ec_gain_codeState ec_gain_c_st;
141 gc_predState pred_state;
142 ph_dispState ph_disp_st;
143 dtx_decState dtxDecoderState;
145 CommonAmrTbls common_amr_tbls;
148 /*----------------------------------------------------------------------------
149 ; GLOBAL FUNCTION DEFINITIONS
150 ; Function Prototype declaration
151 ----------------------------------------------------------------------------*/
153 * Function : Decoder_amr_init
154 * Purpose : Allocates initializes state memory
155 * Description : Stores pointer to filter status struct in *st. This
156 * pointer has to be passed to Decoder_amr in each call.
157 * Returns : 0 on success
159 Word16 Decoder_amr_init(Decoder_amrState *st);
162 * Function : Decoder_amr_reset
163 * Purpose : Resets state memory
164 * Returns : 0 on success
166 Word16 Decoder_amr_reset(Decoder_amrState *st, enum Mode mode);
169 * Function : Decoder_amr_exit
170 * Purpose : The memory used for state memory is freed
171 * Description : Stores NULL in *s
174 void Decoder_amr_exit(Decoder_amrState **st);
177 * Function : Decoder_amr
178 * Purpose : Speech decoder routine.
182 Decoder_amrState *st, /* i/o : State variables */
183 enum Mode mode, /* i : AMR mode */
184 Word16 parm[], /* i : vector of synthesis parameters
186 enum RXFrameType frame_type, /* i : received frame type */
187 Word16 synth[], /* o : synthesis speech (L_FRAME) */
188 Word16 A_t[] /* o : decoded LP filter in 4 subframes
192 /*----------------------------------------------------------------------------
194 ----------------------------------------------------------------------------*/
199 #endif /* DEC_AMR_H_ */