Initialize Tizen 2.3
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / dec_amr.h
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: dec_amr.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39      File             : dec_amr.h
40      Purpose          : Speech decoder routine.
41
42 ------------------------------------------------------------------------------
43 */
44
45 /*----------------------------------------------------------------------------
46 ; CONTINUE ONLY IF NOT ALREADY DEFINED
47 ----------------------------------------------------------------------------*/
48 #ifndef DEC_AMR_H
49 #define DEC_AMR_H "$Id $"
50
51 /*----------------------------------------------------------------------------
52 ; INCLUDES
53 ----------------------------------------------------------------------------*/
54 #include "typedef.h"
55 #include "cnst.h"
56 #include "mode.h"
57 #include "dtx_dec.h"
58 #include "d_plsf.h"
59 #include "gc_pred.h"
60 #include "ec_gains.h"
61 #include "ph_disp.h"
62 #include "c_g_aver.h"
63 #include "bgnscd.h"
64 #include "lsp_avg.h"
65 #include "frame.h"
66 #include "get_const_tbls.h"
67
68 /*--------------------------------------------------------------------------*/
69 #ifdef __cplusplus
70 extern "C"
71 {
72 #endif
73
74     /*----------------------------------------------------------------------------
75     ; MACROS
76     ; Define module specific macros here
77     ----------------------------------------------------------------------------*/
78
79     /*----------------------------------------------------------------------------
80     ; DEFINES
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     ----------------------------------------------------------------------------*/
89
90     /*----------------------------------------------------------------------------
91     ; SIMPLE TYPEDEF'S
92     ----------------------------------------------------------------------------*/
93
94     /*----------------------------------------------------------------------------
95     ; ENUMERATED TYPEDEF'S
96     ----------------------------------------------------------------------------*/
97
98     /*----------------------------------------------------------------------------
99     ; STRUCTURES TYPEDEF'S
100     ----------------------------------------------------------------------------*/
101     typedef struct
102     {
103         /* Excitation vector */
104         Word16 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
105         Word16 *exc;
106
107         /* Lsp (Line spectral pairs) */
108         /* Word16 lsp[M]; */      /* Used by CN codec */
109         Word16 lsp_old[M];
110
111         /* Filter's memory */
112         Word16 mem_syn[M];
113
114         /* pitch sharpening */
115         Word16 sharp;
116         Word16 old_T0;
117
118         /* Memories for bad frame handling */
119         Word16 prev_bf;
120         Word16 prev_pdf;
121         Word16 state;
122         Word16 excEnergyHist[EXC_ENERGY_HIST_LEN];
123
124         /* Variable holding received ltpLag, used in background noise and BFI */
125         Word16 T0_lagBuff;
126
127         /* Variables for the source characteristic detector (SCD) */
128         Word16 inBackgroundNoise;
129         Word16 voicedHangover;
130         Word16 ltpGainHistory[LTP_GAIN_HISTORY_LEN];
131
132         Bgn_scdState background_state;
133         Word16 nodataSeed;
134
135         Cb_gain_averageState Cb_gain_averState;
136         lsp_avgState lsp_avg_st;
137
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;
144         Flag overflow;
145         CommonAmrTbls common_amr_tbls;
146     } Decoder_amrState;
147
148     /*----------------------------------------------------------------------------
149     ; GLOBAL FUNCTION DEFINITIONS
150     ; Function Prototype declaration
151     ----------------------------------------------------------------------------*/
152     /*
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
158      */
159     Word16 Decoder_amr_init(Decoder_amrState *st);
160
161     /*
162      *  Function    : Decoder_amr_reset
163      *  Purpose     : Resets state memory
164      *  Returns     : 0 on success
165      */
166     Word16 Decoder_amr_reset(Decoder_amrState *st, enum Mode mode);
167
168     /*
169      *  Function    : Decoder_amr_exit
170      *  Purpose     : The memory used for state memory is freed
171      *  Description : Stores NULL in *s
172      *  Returns     : void
173      */
174     void Decoder_amr_exit(Decoder_amrState **st);
175
176     /*
177      *  Function    : Decoder_amr
178      *  Purpose     : Speech decoder routine.
179      *  Returns     : 0
180      */
181     void Decoder_amr(
182         Decoder_amrState *st,  /* i/o : State variables                       */
183         enum Mode mode,        /* i   : AMR mode                              */
184         Word16 parm[],         /* i   : vector of synthesis parameters
185                                     (PRM_SIZE)                            */
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
189                                     (AZ_SIZE)                             */
190     );
191
192     /*----------------------------------------------------------------------------
193     ; END
194     ----------------------------------------------------------------------------*/
195 #ifdef __cplusplus
196 }
197 #endif
198
199 #endif /* DEC_AMR_H_ */
200
201
202