Initialize Tizen 2.3
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / dtx_dec.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: dtx_dec.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39     File             : dtx_dec.h
40     Purpose          : Decode comfort noice when in DTX
41
42 ------------------------------------------------------------------------------
43 */
44
45 /*----------------------------------------------------------------------------
46 ; CONTINUE ONLY IF NOT ALREADY DEFINED
47 ----------------------------------------------------------------------------*/
48 #ifndef DTX_DEC_H
49 #define DTX_DEC_H
50 #define dtx_dec_h "$Id $"
51
52 /*----------------------------------------------------------------------------
53 ; INCLUDES
54 ----------------------------------------------------------------------------*/
55 #include "typedef.h"
56 #include "d_plsf.h"
57 #include "gc_pred.h"
58 #include "c_g_aver.h"
59 #include "frame.h"
60 #include "dtx_common_def.h"
61 /*--------------------------------------------------------------------------*/
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66
67     /*----------------------------------------------------------------------------
68     ; MACROS
69     ; Define module specific macros here
70     ----------------------------------------------------------------------------*/
71
72     /*----------------------------------------------------------------------------
73     ; DEFINES
74     ; Include all pre-processor statements here.
75     ----------------------------------------------------------------------------*/
76
77     /*----------------------------------------------------------------------------
78     ; EXTERNAL VARIABLES REFERENCES
79     ; Declare variables used in this module but defined elsewhere
80     ----------------------------------------------------------------------------*/
81
82     /*----------------------------------------------------------------------------
83     ; SIMPLE TYPEDEF'S
84     ----------------------------------------------------------------------------*/
85
86
87     /*----------------------------------------------------------------------------
88     ; ENUMERATED TYPEDEF'S
89     ----------------------------------------------------------------------------*/
90     enum DTXStateType {SPEECH = 0, DTX, DTX_MUTE};
91
92     /*----------------------------------------------------------------------------
93     ; STRUCTURES TYPEDEF'S
94     ----------------------------------------------------------------------------*/
95     typedef struct
96     {
97         Word16 since_last_sid;
98         Word16 true_sid_period_inv;
99         Word16 log_en;
100         Word16 old_log_en;
101         Word32 L_pn_seed_rx;
102         Word16 lsp[M];
103         Word16 lsp_old[M];
104
105         Word16 lsf_hist[M*DTX_HIST_SIZE];
106         Word16 lsf_hist_ptr;
107         Word16 lsf_hist_mean[M*DTX_HIST_SIZE];
108         Word16 log_pg_mean;
109         Word16 log_en_hist[DTX_HIST_SIZE];
110         Word16 log_en_hist_ptr;
111
112         Word16 log_en_adjust;
113
114         Word16 dtxHangoverCount;
115         Word16 decAnaElapsedCount;
116
117         Word16 sid_frame;
118         Word16 valid_data;
119         Word16 dtxHangoverAdded;
120
121         enum DTXStateType dtxGlobalState;     /* contains previous state */
122         /* updated in main decoder */
123
124         Word16 data_updated;      /* marker to know if CNI data is ever renewed */
125
126     } dtx_decState;
127
128     /*----------------------------------------------------------------------------
129     ; GLOBAL FUNCTION DEFINITIONS
130     ; Function Prototype declaration
131     ----------------------------------------------------------------------------*/
132
133     /*
134      *  Function    : dtx_dec_reset
135      *  Purpose     : Resets state memory
136      *  Returns     : 0 on success
137      */
138     Word16 dtx_dec_reset(dtx_decState *st);
139
140     /*
141      *  Function    : dtx_dec
142      *  Purpose     :
143      *  Description :
144      */
145     void dtx_dec(
146         dtx_decState *st,                /* i/o : State struct                    */
147         Word16 mem_syn[],                /* i/o : AMR decoder state               */
148         D_plsfState* lsfState,           /* i/o : decoder lsf states              */
149         gc_predState* predState,         /* i/o : prediction states               */
150         Cb_gain_averageState* averState, /* i/o : CB gain average states          */
151         enum DTXStateType new_state,     /* i   : new DTX state                   */
152         enum Mode mode,                  /* i   : AMR mode                        */
153         Word16 parm[],                   /* i   : Vector of synthesis parameters  */
154         CommonAmrTbls* common_amr_tbls,  /* i   : Ptr to struct of table ptrs     */
155         Word16 synth[],                  /* o   : synthesised speech              */
156         Word16 A_t[],                    /* o   : decoded LP filter in 4 subframes*/
157         Flag   *pOverflow
158     );
159
160     void dtx_dec_activity_update(dtx_decState *st,
161                                  Word16 lsf[],
162                                  Word16 frame[],
163                                  Flag   *pOverflow);
164
165     /*
166      *  Function    : rx_dtx_handler
167      *  Purpose     : reads the frame type and checks history
168      *  Description : to decide what kind of DTX/CNI action to perform
169      */
170     enum DTXStateType rx_dtx_handler(dtx_decState *st,           /* i/o : State struct */
171                                      enum RXFrameType frame_type,/* i   : Frame type   */
172                                      Flag *pOverflow);
173
174     /*----------------------------------------------------------------------------
175     ; END
176     ----------------------------------------------------------------------------*/
177 #ifdef __cplusplus
178 }
179 #endif
180
181 #endif /* DEC_AMR_H_ */