OSDN Git Service

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