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/****************************************************************************************
19Portions 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)
26Permission to distribute, modify and use this file under the standard license
27terms listed above has been obtained from the copyright holder.
28****************************************************************************************/
29/*
30------------------------------------------------------------------------------
31
32
33
34 Filename: /audio/gsm_amr/c/include/dec_amr.h
35
36     Date: 02/06/2002
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41 Description: Update function prototype for Decoder_amr(). Include overflow
42              flag in Decode_amrState structure
43
44 Description:  Replaced "int" and/or "char" with OSCL defined types.
45
46 Description: Moved _cplusplus #ifdef after Include section.
47
48 Description:
49
50------------------------------------------------------------------------------
51 INCLUDE DESCRIPTION
52
53     File             : dec_amr.h
54     Purpose          : Speech decoder routine.
55
56------------------------------------------------------------------------------
57*/
58
59/*----------------------------------------------------------------------------
60; CONTINUE ONLY IF NOT ALREADY DEFINED
61----------------------------------------------------------------------------*/
62#ifndef DEC_AMR_H
63#define DEC_AMR_H "$Id $"
64
65/*----------------------------------------------------------------------------
66; INCLUDES
67----------------------------------------------------------------------------*/
68#include "typedef.h"
69#include "cnst.h"
70#include "mode.h"
71#include "dtx_dec.h"
72#include "d_plsf.h"
73#include "gc_pred.h"
74#include "ec_gains.h"
75#include "ph_disp.h"
76#include "c_g_aver.h"
77#include "bgnscd.h"
78#include "lsp_avg.h"
79#include "frame.h"
80
81/*--------------------------------------------------------------------------*/
82#ifdef __cplusplus
83extern "C"
84{
85#endif
86
87    /*----------------------------------------------------------------------------
88    ; MACROS
89    ; Define module specific macros here
90    ----------------------------------------------------------------------------*/
91
92    /*----------------------------------------------------------------------------
93    ; DEFINES
94    ; Include all pre-processor statements here.
95    ----------------------------------------------------------------------------*/
96#define EXC_ENERGY_HIST_LEN  9
97#define LTP_GAIN_HISTORY_LEN 9
98    /*----------------------------------------------------------------------------
99    ; EXTERNAL VARIABLES REFERENCES
100    ; Declare variables used in this module but defined elsewhere
101    ----------------------------------------------------------------------------*/
102
103    /*----------------------------------------------------------------------------
104    ; SIMPLE TYPEDEF'S
105    ----------------------------------------------------------------------------*/
106
107    /*----------------------------------------------------------------------------
108    ; ENUMERATED TYPEDEF'S
109    ----------------------------------------------------------------------------*/
110
111    /*----------------------------------------------------------------------------
112    ; STRUCTURES TYPEDEF'S
113    ----------------------------------------------------------------------------*/
114    typedef struct Decoder_amrState
115    {
116        /* Excitation vector */
117        Word16 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
118        Word16 *exc;
119
120        /* Lsp (Line spectral pairs) */
121        /* Word16 lsp[M]; */      /* Used by CN codec */
122        Word16 lsp_old[M];
123
124        /* Filter's memory */
125        Word16 mem_syn[M];
126
127        /* pitch sharpening */
128        Word16 sharp;
129        Word16 old_T0;
130
131        /* Memories for bad frame handling */
132        Word16 prev_bf;
133        Word16 prev_pdf;
134        Word16 state;
135        Word16 excEnergyHist[EXC_ENERGY_HIST_LEN];
136
137        /* Variable holding received ltpLag, used in background noise and BFI */
138        Word16 T0_lagBuff;
139
140        /* Variables for the source characteristic detector (SCD) */
141        Word16 inBackgroundNoise;
142        Word16 voicedHangover;
143        Word16 ltpGainHistory[LTP_GAIN_HISTORY_LEN];
144
145        Bgn_scdState background_state;
146        Word16 nodataSeed;
147
148        Cb_gain_averageState Cb_gain_averState;
149        lsp_avgState lsp_avg_st;
150
151        D_plsfState lsfState;
152        ec_gain_pitchState ec_gain_p_st;
153        ec_gain_codeState ec_gain_c_st;
154        gc_predState pred_state;
155        ph_dispState ph_disp_st;
156        dtx_decState dtxDecoderState;
157        Flag overflow;
158    } Decoder_amrState;
159
160    /*----------------------------------------------------------------------------
161    ; GLOBAL FUNCTION DEFINITIONS
162    ; Function Prototype declaration
163    ----------------------------------------------------------------------------*/
164    /*
165     *  Function    : Decoder_amr_init
166     *  Purpose     : Allocates initializes state memory
167     *  Description : Stores pointer to filter status struct in *st. This
168     *                pointer has to be passed to Decoder_amr in each call.
169     *  Returns     : 0 on success
170     */
171    Word16 Decoder_amr_init(Decoder_amrState *st);
172
173    /*
174     *  Function    : Decoder_amr_reset
175     *  Purpose     : Resets state memory
176     *  Returns     : 0 on success
177     */
178    Word16 Decoder_amr_reset(Decoder_amrState *st, enum Mode mode);
179
180    /*
181     *  Function    : Decoder_amr
182     *  Purpose     : Speech decoder routine.
183     *  Returns     : 0
184     */
185    void Decoder_amr(
186        Decoder_amrState *st,  /* i/o : State variables                       */
187        enum Mode mode,        /* i   : AMR mode                              */
188        Word16 parm[],         /* i   : vector of synthesis parameters
189                                    (PRM_SIZE)                            */
190        enum RXFrameType frame_type, /* i   : received frame type               */
191        Word16 synth[],        /* o   : synthesis speech (L_FRAME)            */
192        Word16 A_t[]           /* o   : decoded LP filter in 4 subframes
193                                    (AZ_SIZE)                             */
194    );
195
196    /*----------------------------------------------------------------------------
197    ; END
198    ----------------------------------------------------------------------------*/
199#ifdef __cplusplus
200}
201#endif
202
203#endif /* DEC_AMR_H_ */
204
205
206
207