Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <stdint.h>
34 : #include "options.h"
35 : #ifdef DEBUGGING
36 : #include "debug.h"
37 : #endif
38 : #include "cnst.h"
39 : #include "ivas_cnst.h"
40 : #include "rom_enc.h"
41 : #include "rom_com.h"
42 : #include "prot.h"
43 : #include "ivas_prot.h"
44 : #include <assert.h>
45 : #include "wmc_auto.h"
46 : #include <math.h>
47 :
48 :
49 : /*-----------------------------------------------------------------------------------------*
50 : * Function front_vad()
51 : *
52 : * Standalone front-VAD module
53 : *-----------------------------------------------------------------------------------------*/
54 :
55 438645 : ivas_error front_vad(
56 : CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */
57 : Encoder_State *st, /* i/o: encoder state structure */
58 : const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
59 : FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */
60 : const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
61 : const int16_t input_frame, /* i : frame length */
62 : int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
63 : float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */
64 : float Etot_LR[], /* o : total energy Left & Right channel */
65 : float lf_E[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */
66 : int16_t localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */
67 : int16_t vad_hover_flag[], /* o : VAD hangover flag */
68 : float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN*/
69 : float *PS_out, /* o : energy spectrum */
70 : float *Bin_E_out /* o : log-energy spectrum of the current frame */
71 : )
72 : {
73 : ENC_CORE_HANDLE *sts;
74 : float band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN */
75 : float PS[L_FRAME / 2]; /* speech/music clasif. parameters */
76 : float snr_sum_he; /* HE SAD parameters */
77 : float Bin_E[L_FFT]; /* per bin log energy spectrum for mid-frame */
78 : float Bin_E_old[L_FFT / 2]; /* old per bin log energy spectrum for mid-frame */
79 : float fft_buffLR[2 * L_FFT]; /* fft buffer */
80 : int16_t n, n_chan, dummy;
81 : int16_t element_mode, last_element_mode;
82 : ivas_error error;
83 :
84 438645 : error = IVAS_ERR_OK;
85 438645 : push_wmops( "front_vad" );
86 :
87 438645 : if ( hCPE != NULL )
88 : {
89 420855 : n_chan = CPE_CHANNELS;
90 420855 : sts = &hCPE->hCoreCoder[0];
91 420855 : element_mode = hCPE->element_mode;
92 420855 : last_element_mode = hCPE->last_element_mode;
93 : }
94 17790 : else if ( st != NULL )
95 : {
96 17790 : n_chan = 1;
97 17790 : sts = &st;
98 17790 : element_mode = IVAS_SCE;
99 17790 : last_element_mode = IVAS_SCE;
100 : }
101 : else
102 : {
103 0 : assert( 0 && "Either CPE or SCE must be given!" );
104 : return IVAS_ERR_INTERNAL_FATAL;
105 : }
106 :
107 438645 : snr_sum_he = 0;
108 1298145 : for ( n = 0; n < n_chan; n++ )
109 : {
110 859500 : localVAD_HE_SAD[n] = 0;
111 859500 : vad_hover_flag[n] = 0;
112 859500 : vad_flag_dtx[n] = 1;
113 : }
114 :
115 : /*------------------------------------------------------------------*
116 : * Allocate/deallocate hFrontVad handles in case of element_mode change
117 : *-----------------------------------------------------------------*/
118 :
119 438645 : if ( sts[0]->ini_frame > 0 && MCT_flag == 0 && last_element_mode != element_mode )
120 : {
121 1737 : if ( element_mode == IVAS_CPE_MDCT )
122 : {
123 749 : if ( hFrontVads[0] != NULL )
124 : {
125 189 : for ( n = 0; n < n_chan; n++ )
126 : {
127 126 : front_vad_destroy( &hFrontVads[n] );
128 126 : hFrontVads[n] = NULL;
129 : }
130 : }
131 : }
132 : else
133 : {
134 988 : if ( sts[0]->Opt_DTX_ON && hFrontVads[0] == NULL )
135 : {
136 180 : for ( n = 0; n < n_chan; n++ )
137 : {
138 120 : if ( ( error = front_vad_create( &hFrontVads[n], hEncoderConfig ) ) != IVAS_ERR_OK )
139 : {
140 0 : return error;
141 : }
142 : }
143 : }
144 : }
145 : }
146 :
147 : /* Only run VAD if DTX is on and TD stereo or unified stereo is selected */
148 438645 : if ( hFrontVads[0] != NULL && element_mode != IVAS_CPE_MDCT )
149 : {
150 : #ifdef DEBUGGING
151 : /* If stereo switching is not enabled and TD is selected restore element_mode to TD every frame before the VAD */
152 : if ( hCPE != NULL && hCPE->stereo_mode_cmdl == IVAS_CPE_TD )
153 : {
154 : hCPE->element_mode = IVAS_CPE_TD;
155 : }
156 : #endif
157 :
158 : /*------------------------------------------------------------------*
159 : * VAD
160 : *-----------------------------------------------------------------*/
161 :
162 49758 : set_zero( band_energies_LR, 2 * NB_BANDS );
163 :
164 131484 : for ( n = 0; n < n_chan; n++ )
165 : {
166 : FRONT_VAD_ENC_HANDLE hFrontVad;
167 81726 : hFrontVad = hFrontVads[n];
168 :
169 : /* Move previous frame 12k8 signal */
170 81726 : mvr2r( hFrontVad->buffer_12k8 + L_FFT, hFrontVad->buffer_12k8, L_FFT / 2 );
171 :
172 : /* Resample to 12k8 */
173 81726 : modify_Fs( sts[n]->input, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8 + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim, ( sts[0]->max_bwidth == NB ) );
174 :
175 : /* Preemphasis */
176 81726 : preemph( hFrontVad->buffer_12k8 + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph );
177 :
178 81726 : analy_sp( IVAS_CPE_TD, hCPE, sts[0]->input_Fs, hFrontVad->buffer_12k8 + L_FFT / 2 - 3 * ( L_SUBFR / 2 ), Bin_E, Bin_E_old, fr_bands[n], lf_E[n], &Etot_LR[n], sts[0]->min_band, sts[0]->max_band, band_energies, PS, fft_buffLR );
179 :
180 : /* add up energies for later calculating average of channel energies */
181 81726 : v_add( &band_energies[0], &band_energies_LR[0], &band_energies_LR[0], 2 * NB_BANDS );
182 :
183 81726 : noise_est_pre( Etot_LR[n], hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 );
184 :
185 : /* wb_vad */
186 81726 : hFrontVad->hVAD->vad_flag = wb_vad( sts[n], fr_bands[n], &dummy, &dummy, &dummy, &snr_sum_he, &localVAD_HE_SAD[n], &dummy, hFrontVad->hVAD, hFrontVad->hNoiseEst, hFrontVad->lp_speech, hFrontVad->lp_noise );
187 :
188 81726 : if ( n == 0 && n_chan > 1 && last_element_mode == IVAS_CPE_DFT )
189 : {
190 30245 : sts[1]->last_coder_type = sts[0]->last_coder_type;
191 : }
192 :
193 : /* DTX hangover addition */
194 81726 : vad_flag_dtx[n] = dtx_hangover_addition( sts[n], hFrontVad->hVAD->vad_flag, hFrontVad->lp_speech - hFrontVad->lp_noise, 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho );
195 :
196 81726 : if ( n_chan == 1 )
197 : {
198 17790 : sts[n]->vad_flag = hFrontVad->hVAD->vad_flag;
199 : }
200 : }
201 :
202 49758 : if ( n_chan == CPE_CHANNELS )
203 : {
204 : /* get average channel energies, adding up was already done, so only need to scale by number of channels */
205 31968 : v_multc( &band_energies_LR[0], 0.5f, &band_energies_LR[0], 2 * NB_BANDS );
206 :
207 : /* Logical OR between L and R decisions */
208 31968 : vad_flag_dtx[0] = vad_flag_dtx[0] || vad_flag_dtx[1];
209 : }
210 :
211 49758 : if ( sts[0]->hFdCngEnc != NULL )
212 : {
213 31968 : resetFdCngEnc( sts[0] );
214 : }
215 :
216 : /* Part of DTX to decide if SID/NO_DATA */
217 49758 : if ( vad_flag_dtx[0] == 0 && sts[0]->ini_frame > 2 ) /* CNG coding starts after 3 frames */
218 : {
219 14098 : if ( sts[0]->fd_cng_reset_flag == 0 )
220 : {
221 14052 : if ( hCPE != NULL )
222 : {
223 10467 : hCPE->element_mode = IVAS_CPE_DFT;
224 10467 : sts[1]->active_cnt = 0;
225 : }
226 : }
227 : else
228 : {
229 46 : vad_flag_dtx[0] = 1;
230 : }
231 : }
232 : else
233 : {
234 35660 : vad_flag_dtx[0] = 1;
235 : }
236 : }
237 :
238 438645 : if ( PS_out != NULL )
239 : {
240 17790 : mvr2r( PS, PS_out, L_FRAME / 2 );
241 : }
242 :
243 438645 : if ( Bin_E_out != NULL )
244 : {
245 17790 : mvr2r( Bin_E, Bin_E_out, L_FRAME );
246 : }
247 :
248 438645 : pop_wmops();
249 438645 : return error;
250 : }
251 :
252 :
253 : /*-----------------------------------------------------------------------------------------*
254 : * Function front_vad_create()
255 : *
256 : * Allocate and initialize Standalone front-VAD module
257 : *-----------------------------------------------------------------------------------------*/
258 :
259 251 : ivas_error front_vad_create(
260 : FRONT_VAD_ENC_HANDLE *hFrontVad_out, /* i/o: front-VAD handle */
261 : const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */
262 : )
263 : {
264 : FRONT_VAD_ENC_HANDLE hFrontVad;
265 :
266 251 : if ( ( hFrontVad = (FRONT_VAD_ENC_HANDLE) malloc( sizeof( FRONT_VAD_ENC ) ) ) == NULL )
267 : {
268 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for front-VAD structure \n" ) );
269 : }
270 :
271 251 : if ( ( hFrontVad->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL )
272 : {
273 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ) );
274 : }
275 251 : noise_est_init( hFrontVad->hNoiseEst );
276 :
277 251 : if ( ( hFrontVad->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL )
278 : {
279 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) );
280 : }
281 251 : wb_vad_init( hFrontVad->hVAD );
282 :
283 251 : hFrontVad->lp_speech = 45.0f; /* Initialize the long-term active speech level in dB */
284 251 : hFrontVad->lp_noise = 0.0f; /* Initialize the long-term noise level in dB */
285 251 : set_f( hFrontVad->mem_decim, 0, 2 * L_FILT_MAX );
286 251 : set_f( hFrontVad->buffer_12k8, 0, 3 * L_FRAME / 2 );
287 251 : hFrontVad->mem_preemph = 0;
288 251 : hFrontVad->ini_frame = 0;
289 251 : hFrontVad->hVAD->vad_flag = 1;
290 :
291 : /* allocate delay buffer to compensate for filterbank delay */
292 251 : hFrontVad->delay_samples = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS );
293 251 : hFrontVad->delay_buf = NULL;
294 251 : if ( hFrontVad->delay_samples > 0 )
295 : {
296 251 : if ( ( hFrontVad->delay_buf = (float *) malloc( hFrontVad->delay_samples * sizeof( float ) ) ) == NULL )
297 : {
298 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD delay buffer\n" ) );
299 : }
300 251 : set_f( hFrontVad->delay_buf, 0, hFrontVad->delay_samples );
301 : }
302 :
303 251 : *hFrontVad_out = hFrontVad;
304 :
305 251 : return IVAS_ERR_OK;
306 : }
307 :
308 :
309 : /*-----------------------------------------------------------------------------------------*
310 : * Function front_vad_destroy()
311 : *
312 : * Deallocate Standalone front-VAD module
313 : *-----------------------------------------------------------------------------------------*/
314 :
315 251 : void front_vad_destroy(
316 : FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */
317 : )
318 : {
319 251 : if ( *hFrontVad != NULL )
320 : {
321 251 : free( ( *hFrontVad )->hNoiseEst );
322 251 : ( *hFrontVad )->hNoiseEst = NULL;
323 :
324 251 : free( ( *hFrontVad )->hVAD );
325 251 : ( *hFrontVad )->hVAD = NULL;
326 :
327 251 : if ( ( *hFrontVad )->delay_buf != NULL )
328 : {
329 251 : free( ( *hFrontVad )->delay_buf );
330 251 : ( *hFrontVad )->delay_buf = NULL;
331 : }
332 :
333 251 : free( *hFrontVad );
334 251 : *hFrontVad = NULL;
335 : }
336 :
337 251 : return;
338 : }
339 :
340 :
341 : /*-----------------------------------------------------------------------------------------*
342 : * Function front_vad_spar()
343 : *
344 : * Standalone front-VAD module for SPAR
345 : *-----------------------------------------------------------------------------------------*/
346 :
347 159500 : ivas_error front_vad_spar(
348 : SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */
349 : const float *omni_in, /* i : omnidirectional input signal */
350 : ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */
351 : const int16_t input_frame /* i : input frame length */
352 : )
353 : {
354 : FRONT_VAD_ENC_HANDLE hFrontVad;
355 : float input[L_FRAME48k];
356 : int16_t vad_flag_dtx[1];
357 : float fr_bands[1][2 * NB_BANDS];
358 : float Etot[1];
359 : float lf_E[1][2 * VOIC_BINS];
360 : int16_t localVAD_HE_SAD[1];
361 : int16_t vad_hover_flag[1];
362 : float band_energies[2 * NB_BANDS];
363 : int16_t high_lpn_flag;
364 : Encoder_State *st;
365 : float tmpN[NB_BANDS], tmpE[NB_BANDS];
366 : float corr_shift, dummy, res_energy;
367 : float A[NB_SUBFR16k * ( M + 1 )], Aw[NB_SUBFR16k * ( M + 1 )];
368 : float epsP[M + 1];
369 : float lsp_new[M];
370 : float lsp_mid[M];
371 : int16_t alw_pitch_lag_12k8[2];
372 : float alw_voicing[2];
373 : float cor_map_sum;
374 : float ncharX;
375 : float sp_div;
376 : float non_staX;
377 : int16_t loc_harm;
378 : float S_map[L_FFT / 2];
379 : float *inp_12k8;
380 : float old_wsp[L_WSP];
381 : float *wsp;
382 : float relE;
383 : int16_t flag_spitch;
384 : float PS[L_FRAME / 2];
385 : int16_t old_pitch;
386 : ivas_error error;
387 :
388 159500 : push_wmops( "front_vad_SPAR" );
389 159500 : error = IVAS_ERR_OK;
390 159500 : hFrontVad = hSpar->hFrontVad;
391 159500 : st = hSpar->hCoreCoderVAD;
392 :
393 159500 : if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD )
394 : {
395 : /*------------------------------------------------------------------*
396 : * Initialization
397 : *-----------------------------------------------------------------*/
398 :
399 17790 : inp_12k8 = hFrontVad->buffer_12k8;
400 17790 : mvr2r( st->old_wsp, old_wsp, L_WSP_MEM );
401 17790 : wsp = old_wsp + L_WSP_MEM;
402 :
403 17790 : st->core_brate = -1; /* updated in dtx() */
404 17790 : st->input_bwidth = st->last_input_bwidth;
405 :
406 : /*------------------------------------------------------------------*
407 : * compensate for SPAR filterbank delay
408 : *-----------------------------------------------------------------*/
409 :
410 17790 : st->input = input;
411 17790 : mvr2r( omni_in, st->input, input_frame );
412 :
413 17790 : delay_signal( st->input, input_frame, hFrontVad->delay_buf, hFrontVad->delay_samples );
414 :
415 : /*------------------------------------------------------------------*
416 : * Front-VAD
417 : *-----------------------------------------------------------------*/
418 :
419 17790 : if ( ( error = front_vad( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands, Etot, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies, &PS[0], &st->Bin_E[0] ) ) != IVAS_ERR_OK )
420 : {
421 0 : return error;
422 : }
423 :
424 17790 : noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 );
425 17790 : corr_shift = correlation_shift( hFrontVad->hNoiseEst->totalNoise );
426 17790 : dtx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 );
427 :
428 : /* linear prediction analysis */
429 17790 : alw_pitch_lag_12k8[0] = st->old_pitch_la;
430 17790 : alw_pitch_lag_12k8[1] = st->old_pitch_la;
431 17790 : alw_voicing[0] = st->voicing[2];
432 17790 : alw_voicing[1] = st->voicing[2];
433 17790 : analy_lp( inp_12k8, L_FRAME, L_LOOK_12k8, &res_energy, A, epsP, lsp_new, lsp_mid, st->lsp_old1, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */ );
434 :
435 17790 : relE = Etot[0] - st->lp_speech;
436 :
437 17790 : find_wsp( L_FRAME, L_SUBFR, NB_SUBFR, A, Aw, inp_12k8, TILT_FAC, wsp, &st->mem_wsp, GAMMA1, L_LOOK_12k8 );
438 :
439 17790 : if ( st->vad_flag == 0 )
440 : {
441 : /* reset the OL pitch tracker memories during inactive frames */
442 3827 : pitch_ol_init( &st->old_thres, &st->old_pitch, &st->delta_pit, &st->old_corr );
443 : }
444 :
445 17790 : old_pitch = st->pitch[1];
446 17790 : pitch_ol( st->pitch, st->voicing, &st->old_pitch, &st->old_corr, corr_shift, &st->old_thres, &st->delta_pit, st->old_wsp2, wsp, st->mem_decim2, relE, L_LOOK_12k8, st->clas, st->input_bwidth, st->Opt_SC_VBR );
447 :
448 : /* Updates for adaptive lag window memory */
449 17790 : st->old_pitch_la = st->pitch[2];
450 :
451 : /* Detection of very short stable pitch period */
452 17790 : StableHighPitchDetect( &flag_spitch, st->pitch, st->voicing, st->Bin_E, wsp, st->localVAD, &st->voicing_sm, &st->voicing0_sm, &st->LF_EnergyRatio_sm, &st->predecision_flag, &st->diff_sm, &st->energy_sm );
453 :
454 17790 : if ( st->hSpMusClas != NULL )
455 : {
456 : int16_t dummy_int;
457 17790 : dummy_int = 0;
458 17790 : loc_harm = multi_harm( st->Bin_E, hFrontVad->hNoiseEst->old_S, hFrontVad->hNoiseEst->cor_map, &hFrontVad->hNoiseEst->multi_harm_limit, st->total_brate, st->bwidth, ( st->hGSCEnc != NULL ) ? &st->hGSCEnc->cor_strong_limit : &dummy_int, &st->hSpMusClas->mean_avr_dyn, &st->hSpMusClas->last_sw_dyn, &cor_map_sum, &dummy, S_map );
459 : }
460 :
461 17790 : noise_est( st, old_pitch, tmpN, epsP, Etot[0], Etot[0] - hFrontVad->lp_speech, corr_shift, tmpE, fr_bands[0], &cor_map_sum, &ncharX, &sp_div, &non_staX, &loc_harm, lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, hFrontVad->hNoiseEst->Etot_l_lp, &dummy, S_map, NULL, hFrontVad, hFrontVad->ini_frame );
462 :
463 17790 : vad_param_updt( st, corr_shift, corr_shift, A, st->pitch[1], &hFrontVad, 1 );
464 :
465 : /* 1st stage speech/music classification (GMM model) */
466 : /* run only to get 'high_lpn_flag' parameter */
467 17790 : ivas_smc_gmm( st, NULL, localVAD_HE_SAD[0], Etot[0], lsp_new, cor_map_sum, epsP, PS, non_staX, relE, &high_lpn_flag, flag_spitch );
468 :
469 : /* long-term energy update */
470 17790 : long_enr( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot );
471 :
472 : /* increase ini_frame counter */
473 17790 : hFrontVad->ini_frame = min( hFrontVad->ini_frame + 1, MAX_FRAME_COUNTER );
474 17790 : st->ini_frame = hFrontVad->ini_frame;
475 :
476 17790 : hSpar->front_vad_flag = st->vad_flag;
477 17790 : hSpar->front_vad_dtx_flag = 1;
478 17790 : if ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA )
479 : {
480 3585 : hSpar->front_vad_dtx_flag = 0;
481 : }
482 17790 : hSpar->force_front_vad = 1;
483 17790 : st->last_core = 0;
484 : }
485 : else
486 : {
487 141710 : hSpar->front_vad_flag = 1;
488 141710 : hSpar->front_vad_dtx_flag = 0;
489 141710 : hSpar->force_front_vad = 0;
490 : }
491 :
492 159500 : pop_wmops();
493 159500 : return error;
494 : }
|