1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
36 ------------------------------------------------------------------------------
40 Purpose : Decode comfort noice when in DTX
42 ------------------------------------------------------------------------------
45 /*----------------------------------------------------------------------------
46 ; CONTINUE ONLY IF NOT ALREADY DEFINED
47 ----------------------------------------------------------------------------*/
50 #define dtx_dec_h "$Id $"
52 /*----------------------------------------------------------------------------
54 ----------------------------------------------------------------------------*/
60 #include "dtx_common_def.h"
61 /*--------------------------------------------------------------------------*/
67 /*----------------------------------------------------------------------------
69 ; Define module specific macros here
70 ----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------
74 ; Include all pre-processor statements here.
75 ----------------------------------------------------------------------------*/
77 /*----------------------------------------------------------------------------
78 ; EXTERNAL VARIABLES REFERENCES
79 ; Declare variables used in this module but defined elsewhere
80 ----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------
84 ----------------------------------------------------------------------------*/
87 /*----------------------------------------------------------------------------
88 ; ENUMERATED TYPEDEF'S
89 ----------------------------------------------------------------------------*/
90 enum DTXStateType {SPEECH = 0, DTX, DTX_MUTE};
92 /*----------------------------------------------------------------------------
93 ; STRUCTURES TYPEDEF'S
94 ----------------------------------------------------------------------------*/
97 Word16 since_last_sid;
98 Word16 true_sid_period_inv;
105 Word16 lsf_hist[M*DTX_HIST_SIZE];
107 Word16 lsf_hist_mean[M*DTX_HIST_SIZE];
109 Word16 log_en_hist[DTX_HIST_SIZE];
110 Word16 log_en_hist_ptr;
112 Word16 log_en_adjust;
114 Word16 dtxHangoverCount;
115 Word16 decAnaElapsedCount;
119 Word16 dtxHangoverAdded;
121 enum DTXStateType dtxGlobalState; /* contains previous state */
122 /* updated in main decoder */
124 Word16 data_updated; /* marker to know if CNI data is ever renewed */
128 /*----------------------------------------------------------------------------
129 ; GLOBAL FUNCTION DEFINITIONS
130 ; Function Prototype declaration
131 ----------------------------------------------------------------------------*/
134 * Function : dtx_dec_reset
135 * Purpose : Resets state memory
136 * Returns : 0 on success
138 Word16 dtx_dec_reset(dtx_decState *st);
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*/
160 void dtx_dec_activity_update(dtx_decState *st,
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
170 enum DTXStateType rx_dtx_handler(dtx_decState *st, /* i/o : State struct */
171 enum RXFrameType frame_type,/* i : Frame type */
174 /*----------------------------------------------------------------------------
176 ----------------------------------------------------------------------------*/
181 #endif /* DEC_AMR_H_ */