Initialize Tizen 2.3
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / enc / src / dtx_enc.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_enc.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39       File             : dtx_enc.h
40       Purpose          : DTX mode computation of SID parameters
41
42 ------------------------------------------------------------------------------
43 */
44
45 #ifndef dtx_enc_h
46 #define dtx_enc_h "$Id $"
47
48 /*----------------------------------------------------------------------------
49 ; INCLUDES
50 ----------------------------------------------------------------------------*/
51 #include "typedef.h"
52 #include "cnst.h"
53 #include "q_plsf.h"
54 #include "gc_pred.h"
55 #include "mode.h"
56 #include "dtx_common_def.h"
57
58 /*--------------------------------------------------------------------------*/
59 #ifdef __cplusplus
60 extern "C"
61 {
62 #endif
63
64     /*----------------------------------------------------------------------------
65     ; MACROS
66     ; [Define module specific macros here]
67     ----------------------------------------------------------------------------*/
68
69     /*----------------------------------------------------------------------------
70     ; DEFINES
71     ; [Include all pre-processor statements here.]
72     ----------------------------------------------------------------------------*/
73
74     /*----------------------------------------------------------------------------
75     ; EXTERNAL VARIABLES REFERENCES
76     ; [Declare variables used in this module but defined elsewhere]
77     ----------------------------------------------------------------------------*/
78
79     /*----------------------------------------------------------------------------
80     ; SIMPLE TYPEDEF'S
81     ----------------------------------------------------------------------------*/
82
83     /*----------------------------------------------------------------------------
84     ; ENUMERATED TYPEDEF'S
85     ----------------------------------------------------------------------------*/
86
87     /*----------------------------------------------------------------------------
88     ; STRUCTURES TYPEDEF'S
89     ----------------------------------------------------------------------------*/
90     typedef struct
91     {
92         Word16 lsp_hist[M * DTX_HIST_SIZE];
93         Word16 log_en_hist[DTX_HIST_SIZE];
94         Word16 hist_ptr;
95         Word16 log_en_index;
96         Word16 init_lsf_vq_index;
97         Word16 lsp_index[3];
98
99         /* DTX handler stuff */
100         Word16 dtxHangoverCount;
101         Word16 decAnaElapsedCount;
102
103     } dtx_encState;
104
105     /*----------------------------------------------------------------------------
106     ; GLOBAL FUNCTION DEFINITIONS
107     ; [List function prototypes here]
108     ----------------------------------------------------------------------------*/
109     /*
110     **************************************************************************
111     *  Function    : dtx_enc_init
112     *  Purpose     : Allocates memory and initializes state variables
113     *  Description : Stores pointer to filter status struct in *st. This
114     *                pointer has to be passed to dtx_enc in each call.
115     *  Returns     : 0 on success
116     *
117     **************************************************************************
118     */
119     Word16 dtx_enc_init(dtx_encState **st, const Word16* lsp_init_data_ptr);
120
121     /*
122     **************************************************************************
123     *
124     *  Function    : dtx_enc_reset
125     *  Purpose     : Resets state memory
126     *  Returns     : 0 on success
127     *
128     **************************************************************************
129     */
130     Word16 dtx_enc_reset(dtx_encState *st, const Word16* lsp_init_data_ptr);
131
132     /*
133     **************************************************************************
134     *
135     *  Function    : dtx_enc_exit
136     *  Purpose     : The memory used for state memory is freed
137     *  Description : Stores NULL in *st
138     *
139     **************************************************************************
140     */
141     void dtx_enc_exit(dtx_encState **st);
142
143     /*
144     **************************************************************************
145     *
146     *  Function    : dtx_enc
147     *  Purpose     :
148     *  Description :
149     *
150     **************************************************************************
151     */
152     void dtx_enc(dtx_encState *st,        /* i/o : State struct                  */
153                  Word16 computeSidFlag,   /* i   : compute SID                   */
154                  Q_plsfState *qSt,        /* i/o : Qunatizer state struct        */
155                  gc_predState* predState, /* i/o : State struct                  */
156                  Word16 **anap,           /* o   : analysis parameters           */
157                  Flag   *pOverflow        /* i/o : overflow indicator            */
158                 );
159
160     /*
161     **************************************************************************
162     *
163     *  Function    : dtx_buffer
164     *  Purpose     : handles the DTX buffer
165     *
166     **************************************************************************
167     */
168     void dtx_buffer(dtx_encState *st,   /* i/o : State struct                    */
169                     Word16 lsp_new[],   /* i   : LSP vector                      */
170                     Word16 speech[],    /* i   : speech samples                  */
171                     Flag   *pOverflow   /* i/o : overflow indicator              */
172                    );
173
174     /*
175     **************************************************************************
176     *
177     *  Function    : tx_dtx_handler
178     *  Purpose     : adds extra speech hangover to analyze speech on the decoding side.
179     *  Description : returns 1 when a new SID analysis may be made
180     *                otherwise it adds the appropriate hangover after a sequence
181     *                with out updates of SID parameters .
182     *
183     **************************************************************************
184     */
185     Word16 tx_dtx_handler(dtx_encState *st,      /* i/o : State struct           */
186                           Word16 vad_flag,       /* i   : vad decision           */
187                           enum Mode *usedMode,   /* i/o : mode changed or not    */
188                           Flag   *pOverflow      /* i/o : overflow indicator     */
189                          );
190
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif  /* _dtx_enc_h_ */
197
198