Line data Source code
1 : /*====================================================================================
2 : EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
3 : ====================================================================================*/
4 : #include <stdint.h>
5 : #include "options.h"
6 : #include "cnst.h"
7 : #include "rom_com_fx.h"
8 : #include "rom_com.h"
9 : #include "prot_fx.h" /* Function prototypes */
10 : #include "prot_fx_enc.h" /* Function prototypes */
11 :
12 : /*-------------------------------------------------------------------*
13 : * Local function prototypes
14 : *-------------------------------------------------------------------*/
15 :
16 : static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew );
17 :
18 : /*-------------------------------------------------------------------*
19 : * encod_audio()
20 : *
21 : * Encode audio (AC) frames
22 : *-------------------------------------------------------------------*/
23 8 : void encod_audio_fx(
24 : Encoder_State *st_fx, /* i/o: State structure */
25 : const Word16 speech[], /* i : input speech Q_new */
26 : const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */
27 : const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */
28 : const Word16 *res, /* i : residual signal Q_new */
29 : Word16 *synth, /* i/o: core synthesis Q-1 */
30 : Word16 *exc, /* i/o: current non-enhanced excitation Q_new */
31 : Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
32 : Word16 *voice_factors, /* o : voicing factors Q15 */
33 : Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
34 : const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */
35 : Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */
36 : Word16 *tmp_noise, /* o : noise energy Q2*/
37 : const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
38 : const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
39 : Word16 Q_new,
40 : Word16 shift )
41 : {
42 : const Word16 *p_Aq;
43 : Word16 i, i_subfr, nb_subfr, last_pit_bin;
44 : Word16 T0_tmp, T0_frac_tmp, nb_subfr_flag;
45 8 : Word16 tmp_nb_bits_tot = 0;
46 8 : move16();
47 : Word16 Es_pred;
48 : Word16 dct_res[L_FRAME16k], dct_epit[L_FRAME16k];
49 8 : Word16 m_mean = 0;
50 8 : move16();
51 : Word16 saved_bit_pos;
52 : Word16 exc_wo_nf[L_FRAME16k];
53 : Word32 Lm_mean;
54 : Word16 nb_bits;
55 : Word16 indice;
56 8 : SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
57 8 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
58 8 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
59 8 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
60 :
61 8 : m_mean = 0;
62 8 : move16();
63 8 : tmp_nb_bits_tot = 0;
64 8 : move16();
65 :
66 8 : T0_tmp = 64;
67 8 : move16();
68 8 : T0_frac_tmp = 0;
69 8 : move16();
70 8 : Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */
71 8 : hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0;
72 8 : move16();
73 8 : Es_pred = 0;
74 8 : move16();
75 :
76 : /*---------------------------------------------------------------*
77 : * Encode GSC IVAS mode
78 : * Encode GSC attack flag (used to reduce possible pre-echo)
79 : * Encode GSC SWB speech flag
80 : *---------------------------------------------------------------*/
81 :
82 8 : IF( attack_flag > 0 )
83 : {
84 0 : push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
85 : }
86 : ELSE
87 : {
88 8 : push_indice( hBstr, IND_GSC_ATTACK, 0, 1 );
89 : }
90 :
91 :
92 8 : test();
93 8 : test();
94 8 : test();
95 8 : test();
96 8 : test();
97 8 : test();
98 8 : test();
99 8 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( NE_16( st_fx->coder_type, INACTIVE ) && ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
100 : ( GT_16( st_fx->element_mode, EVS_MONO ) && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
101 : {
102 0 : push_indice( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 );
103 : }
104 : /*---------------------------------------------------------------*
105 : * Find and encode the number of subframes
106 : *---------------------------------------------------------------*/
107 8 : test();
108 8 : IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) )
109 : {
110 48 : FOR( i = 0; i < 5; i++ )
111 : {
112 40 : test();
113 40 : if ( GT_16( abs_s( hSpMusClas->gsc_lt_diff_etot_fx[MAX_LT - i - 1] ), 1536 /*6.0 in Q8*/ ) && EQ_16( hGSCEnc->cor_strong_limit, 1 ) )
114 : {
115 0 : hGSCEnc->cor_strong_limit = 0;
116 0 : move16();
117 : }
118 : }
119 : }
120 8 : test();
121 8 : test();
122 8 : test();
123 8 : test();
124 8 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->GSC_noisy_speech && st_fx->GSC_IVAS_mode == 0 ) )
125 : {
126 0 : nb_subfr = NB_SUBFR;
127 0 : move16();
128 0 : test();
129 0 : test();
130 0 : if ( st_fx->GSC_IVAS_mode > 0 && LT_16( st_fx->GSC_IVAS_mode, 3 ) && LT_32( st_fx->core_brate, GSC_L_RATE_STG ) )
131 : {
132 0 : nb_subfr = 2;
133 0 : move16();
134 : }
135 0 : hGSCEnc->cor_strong_limit = 0;
136 0 : move16();
137 0 : nb_subfr_flag = 1;
138 0 : move16();
139 : }
140 8 : ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || EQ_16( st_fx->coder_type, INACTIVE ) ) )
141 : {
142 0 : hGSCEnc->cor_strong_limit = 0;
143 0 : nb_subfr = SWNB_SUBFR;
144 0 : nb_subfr_flag = 1;
145 0 : move16();
146 0 : move16();
147 0 : move16();
148 : }
149 : ELSE
150 : {
151 8 : test();
152 8 : test();
153 8 : IF( ( hGSCEnc->cor_strong_limit == 0 || EQ_16( st_fx->coder_type, INACTIVE ) ) && GE_32( st_fx->core_brate, ACELP_9k60 ) )
154 : {
155 8 : nb_subfr = 2;
156 8 : move16();
157 8 : nb_subfr_flag = 0;
158 8 : move16();
159 8 : hGSCEnc->cor_strong_limit = 0;
160 8 : move16();
161 : }
162 : ELSE
163 : {
164 0 : nb_subfr = SWNB_SUBFR;
165 0 : move16();
166 0 : nb_subfr_flag = 1;
167 0 : move16();
168 : }
169 :
170 8 : test();
171 8 : test();
172 8 : test();
173 8 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( GT_16( hSpMusClas->mold_corr_fx, 26214 ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) && NE_16( st_fx->coder_type, INACTIVE ) ) )
174 : {
175 0 : nb_subfr = shl( nb_subfr, 1 );
176 0 : nb_subfr_flag = s_or( nb_subfr_flag, 0x2 );
177 0 : logic16();
178 : }
179 :
180 8 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
181 : {
182 0 : push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 2 );
183 : }
184 8 : ELSE IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
185 : {
186 : /* nb_subfr_flag can only have the value 0 or 1 */
187 8 : push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 );
188 : }
189 : }
190 8 : test();
191 8 : if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
192 : {
193 0 : nb_subfr = NB_SUBFR16k;
194 0 : move16();
195 : }
196 :
197 : /*---------------------------------------------------------------*
198 : * Compute adaptive (pitch) excitation contribution
199 : *---------------------------------------------------------------*/
200 :
201 8 : test();
202 8 : test();
203 8 : test();
204 8 : test();
205 8 : test();
206 8 : test();
207 8 : test();
208 8 : test();
209 8 : IF( !( st_fx->GSC_IVAS_mode > 0 && EQ_16( st_fx->L_frame, i_mult( nb_subfr, 2 * L_SUBFR ) ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
210 : ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
211 : ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
212 : {
213 0 : IF( ( st_fx->element_mode > EVS_MONO ) )
214 : {
215 0 : nb_bits = 5;
216 0 : move16();
217 : }
218 : ELSE
219 : {
220 0 : nb_bits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )];
221 0 : move16();
222 : }
223 0 : Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new );
224 0 : push_indice( hBstr, IND_ES_PRED, indice, nb_bits );
225 : }
226 :
227 8 : enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
228 : &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );
229 :
230 : /*---------------------------------------------------------------*
231 : * DCT transform
232 : *---------------------------------------------------------------*/
233 8 : edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
234 8 : edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode );
235 : /*---------------------------------------------------------------*
236 : * Calculate energy dynamics
237 : *---------------------------------------------------------------*/
238 8 : Lm_mean = L_deposit_l( 0 );
239 72 : FOR( i = 7; i < 15; i++ )
240 : {
241 : /*m_mean = add(m_mean,edyn_fx( dct_res+i*16, 16, Q_new )); */
242 64 : Lm_mean = L_mac( Lm_mean, edyn_fx( dct_res + i * 16, 16, Q_new ), 4096 ); /*Q7*/
243 : }
244 8 : m_mean = round_fx( Lm_mean ); /*Q7*/
245 :
246 8 : IF( GT_16( m_mean, hGSCEnc->mid_dyn_fx ) )
247 : {
248 : /*st_fx->mid_dyn_fx = 0.2f * st_fx->mid_dyn_fx + 0.8f * m_mean;*/
249 5 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
250 5 : move16();
251 : }
252 : ELSE
253 : {
254 : /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
255 3 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
256 3 : move16();
257 : }
258 8 : IF( NE_16( st_fx->coder_type, INACTIVE ) )
259 : {
260 0 : hGSCEnc->noise_lev = sub( ( NOISE_LEVEL_SP3 + 1 ), usquant_fx( hGSCEnc->mid_dyn_fx, &m_mean, MIN_DYNAMIC_FX, shr( GSF_NF_DELTA_FX, 1 ), GSC_NF_STEPS ) );
261 0 : move16();
262 0 : hGSCEnc->noise_lev = s_min( hGSCEnc->noise_lev, NOISE_LEVEL_SP3 );
263 0 : move16();
264 : }
265 :
266 8 : hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
267 8 : move16();
268 8 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
269 : {
270 0 : hGSCEnc->noise_lev = NOISE_LEVEL_SP2;
271 0 : move16();
272 0 : IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
273 : {
274 0 : hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
275 0 : move16();
276 : }
277 0 : ELSE IF( st_fx->GSC_noisy_speech == 0 )
278 : {
279 0 : hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
280 0 : move16();
281 : }
282 : }
283 8 : ELSE IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
284 : {
285 0 : hGSCEnc->noise_lev = s_max( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 );
286 0 : move16();
287 0 : push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ), 2 );
288 : }
289 8 : ELSE IF( st_fx->GSC_noisy_speech )
290 : {
291 0 : hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
292 0 : move16();
293 0 : move16();
294 : }
295 : ELSE
296 : {
297 8 : push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP0 ), 3 );
298 : }
299 :
300 : /*---------------------------------------------------------------*
301 : * Find and encode the last band where the adaptive (pitch) contribution is significant
302 : *---------------------------------------------------------------*/
303 :
304 8 : last_pit_bin = Pit_exc_contribution_len_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new );
305 :
306 8 : IF( last_pit_bin == 0 )
307 : {
308 0 : hLPDmem->tilt_code = 0;
309 0 : move16();
310 : }
311 : ELSE
312 : {
313 : /*last_pit_bin++;*/
314 8 : last_pit_bin = add( last_pit_bin, 1 );
315 : }
316 :
317 : /*--------------------------------------------------------------------------------------*
318 : * GSC encoder
319 : *--------------------------------------------------------------------------------------*/
320 :
321 : /* Find the current total number of bits used */
322 8 : tmp_nb_bits_tot = hBstr->nb_bits_tot;
323 8 : move16();
324 :
325 :
326 8 : if ( st_fx->extl_brate > 0 )
327 : {
328 : /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
329 8 : tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 );
330 : }
331 8 : test();
332 8 : test();
333 8 : if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
334 : {
335 : /* add 5 bits for noisiness */
336 0 : tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 );
337 : }
338 :
339 8 : gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, Q_new );
340 :
341 : /*--------------------------------------------------------------------------------------*
342 : * iDCT transform
343 : *--------------------------------------------------------------------------------------*/
344 :
345 8 : edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
346 8 : edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
347 : /*--------------------------------------------------------------------------------------*
348 : * Remove potential pre-echo in case an onset has been detected
349 : *--------------------------------------------------------------------------------------*/
350 :
351 8 : pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame );
352 :
353 : /*--------------------------------------------------------------------------------------*
354 : * Update BWE excitation
355 : *--------------------------------------------------------------------------------------*/
356 8 : IF( st_fx->hBWE_TD != NULL )
357 : {
358 8 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
359 : {
360 0 : set16_fx( voice_factors, 0, NB_SUBFR16k );
361 0 : interp_code_4over2_fx( exc, bwe_exc, L_FRAME16k );
362 : }
363 : ELSE
364 : {
365 8 : set16_fx( voice_factors, 0, NB_SUBFR );
366 8 : interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
367 : }
368 : }
369 : /*--------------------------------------------------------------------------------------*
370 : * Synthesis
371 : *--------------------------------------------------------------------------------------*/
372 :
373 8 : p_Aq = Aq;
374 40 : FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_SUBFR )
375 : {
376 32 : Syn_filt_s( 1, p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
377 32 : p_Aq += ( M + 1 );
378 : }
379 :
380 : /*--------------------------------------------------------------------------------------*
381 : * Updates
382 : *--------------------------------------------------------------------------------------*/
383 :
384 8 : hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */
385 8 : move16();
386 8 : Copy( exc_wo_nf, exc, st_fx->L_frame );
387 :
388 8 : return;
389 : }
390 :
391 15091 : void encod_audio_ivas_fx(
392 : Encoder_State *st_fx, /* i/o: State structure */
393 : const Word16 speech[], /* i : input speech Q_new */
394 : const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */
395 : const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */
396 : const Word16 *res, /* i : residual signal Q_new */
397 : Word16 *synth, /* i/o: core synthesis Q-1 */
398 : Word16 *exc, /* i/o: current non-enhanced excitation Q_new */
399 : Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
400 : Word16 *voice_factors, /* o : voicing factors Q15 */
401 : Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
402 : const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */
403 : Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */
404 : Word16 *tmp_noise, /* o : noise energy Q8*/
405 : const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
406 : const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
407 : Word16 Q_new,
408 : Word16 shift )
409 : {
410 : const Word16 *p_Aq;
411 : Word16 i, i_subfr, nb_subfr, last_pit_bin;
412 : Word16 T0_tmp, T0_frac_tmp, nb_subfr_flag;
413 15091 : Word16 tmp_nb_bits_tot = 0;
414 : Word16 Es_pred;
415 : Word16 dct_res[L_FRAME16k], dct_epit[L_FRAME16k];
416 15091 : Word16 m_mean = 0;
417 : Word16 saved_bit_pos;
418 : Word16 exc_wo_nf[L_FRAME16k];
419 : Word32 Lm_mean;
420 : Word16 nb_bits;
421 : Word16 indice;
422 15091 : SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
423 15091 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
424 15091 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
425 15091 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
426 :
427 15091 : m_mean = 0;
428 15091 : move16();
429 15091 : tmp_nb_bits_tot = 0;
430 15091 : move16();
431 :
432 15091 : T0_tmp = 64;
433 15091 : move16();
434 15091 : T0_frac_tmp = 0;
435 15091 : move16();
436 15091 : Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
437 15091 : Copy_Scale_sig( &hLPDmem->mem_w0, &hGSCEnc->mem_w0_tmp_fx, 1, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
438 15091 : move16();
439 15091 : Es_pred = 0;
440 15091 : move16();
441 :
442 : /*---------------------------------------------------------------*
443 : * Encode GSC IVAS mode
444 : * Encode GSC attack flag (used to reduce possible pre-echo)
445 : * Encode GSC SWB speech flag
446 : *---------------------------------------------------------------*/
447 :
448 15091 : test();
449 15091 : if ( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 )
450 : {
451 15091 : push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
452 : }
453 :
454 15091 : IF( attack_flag > 0 )
455 : {
456 0 : push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
457 : }
458 : ELSE
459 : {
460 15091 : push_indice( hBstr, IND_GSC_ATTACK, 0, 1 );
461 : }
462 :
463 :
464 15091 : test();
465 15091 : test();
466 15091 : test();
467 15091 : test();
468 15091 : test();
469 15091 : test();
470 15091 : test();
471 15091 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( NE_16( st_fx->coder_type, INACTIVE ) && ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
472 : ( GT_16( st_fx->element_mode, EVS_MONO ) && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
473 : {
474 5573 : push_indice( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 );
475 : }
476 : /*---------------------------------------------------------------*
477 : * Find and encode the number of subframes
478 : *---------------------------------------------------------------*/
479 15091 : test();
480 15091 : IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) )
481 : {
482 21696 : FOR( i = 0; i < 5; i++ )
483 : {
484 18080 : test();
485 18080 : if ( GT_16( abs_s( hSpMusClas->gsc_lt_diff_etot_fx[MAX_LT - i - 1] ), 1536 ) && EQ_16( hGSCEnc->cor_strong_limit, 1 ) )
486 : {
487 101 : hGSCEnc->cor_strong_limit = 0;
488 101 : move16();
489 : }
490 : }
491 : }
492 15091 : test();
493 15091 : test();
494 15091 : test();
495 15091 : test();
496 15091 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->GSC_noisy_speech && st_fx->GSC_IVAS_mode == 0 ) )
497 : {
498 5571 : nb_subfr = NB_SUBFR;
499 5571 : move16();
500 5571 : test();
501 5571 : test();
502 5571 : if ( st_fx->GSC_IVAS_mode > 0 && LT_16( st_fx->GSC_IVAS_mode, 3 ) && LT_32( st_fx->core_brate, GSC_L_RATE_STG ) )
503 : {
504 2041 : nb_subfr = 2;
505 2041 : move16();
506 : }
507 5571 : hGSCEnc->cor_strong_limit = 0;
508 5571 : move16();
509 5571 : nb_subfr_flag = 1;
510 5571 : move16();
511 : }
512 9520 : ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || EQ_16( st_fx->coder_type, INACTIVE ) ) )
513 : {
514 2659 : hGSCEnc->cor_strong_limit = 0;
515 2659 : nb_subfr = SWNB_SUBFR;
516 2659 : nb_subfr_flag = 1;
517 2659 : move16();
518 2659 : move16();
519 2659 : move16();
520 : }
521 : ELSE
522 : {
523 6861 : test();
524 6861 : test();
525 6861 : IF( ( hGSCEnc->cor_strong_limit == 0 || EQ_16( st_fx->coder_type, INACTIVE ) ) && GE_32( st_fx->core_brate, ACELP_9k60 ) )
526 : {
527 1286 : nb_subfr = 2;
528 1286 : move16();
529 1286 : nb_subfr_flag = 0;
530 1286 : move16();
531 1286 : hGSCEnc->cor_strong_limit = 0;
532 1286 : move16();
533 : }
534 : ELSE
535 : {
536 5575 : nb_subfr = SWNB_SUBFR;
537 5575 : move16();
538 5575 : nb_subfr_flag = 1;
539 5575 : move16();
540 : }
541 :
542 6861 : test();
543 6861 : test();
544 6861 : test();
545 6861 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( GT_16( hSpMusClas->mold_corr_fx, 26214 ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) && NE_16( st_fx->coder_type, INACTIVE ) ) )
546 : {
547 0 : nb_subfr = shl( nb_subfr, 1 );
548 0 : nb_subfr_flag |= 0x2;
549 0 : logic16();
550 : }
551 :
552 6861 : test();
553 6861 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
554 : {
555 0 : push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 2 );
556 : }
557 6861 : ELSE IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
558 : {
559 : /* nb_subfr_flag can only have the value 0 or 1 */
560 1294 : push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 );
561 : }
562 : }
563 15091 : test();
564 15091 : if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
565 : {
566 0 : nb_subfr = NB_SUBFR16k;
567 0 : move16();
568 : }
569 :
570 : /*---------------------------------------------------------------*
571 : * Compute adaptive (pitch) excitation contribution
572 : *---------------------------------------------------------------*/
573 :
574 15091 : test();
575 15091 : test();
576 15091 : test();
577 15091 : test();
578 15091 : test();
579 15091 : test();
580 15091 : test();
581 15091 : test();
582 15091 : IF( !( st_fx->GSC_IVAS_mode > 0 && EQ_16( st_fx->L_frame, i_mult( nb_subfr, 2 * L_SUBFR ) ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
583 : ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
584 : ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
585 : {
586 696 : IF( ( st_fx->element_mode > EVS_MONO ) )
587 : {
588 696 : nb_bits = 5;
589 696 : move16();
590 : }
591 : ELSE
592 : {
593 0 : nb_bits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )];
594 0 : move16();
595 : }
596 696 : Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new );
597 696 : push_indice( hBstr, IND_ES_PRED, indice, nb_bits );
598 : }
599 :
600 15091 : enc_pit_exc_ivas_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
601 : &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );
602 :
603 : /*---------------------------------------------------------------*
604 : * DCT transform
605 : *---------------------------------------------------------------*/
606 15091 : edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
607 15091 : edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode );
608 : /*---------------------------------------------------------------*
609 : * Calculate energy dynamics
610 : *---------------------------------------------------------------*/
611 15091 : Lm_mean = L_deposit_l( 0 );
612 135819 : FOR( i = 7; i < 15; i++ )
613 : {
614 : /*m_mean = add(m_mean,edyn_fx( dct_res+i*16, 16, Q_new )); */
615 120728 : Lm_mean = L_mac( Lm_mean, edyn_fx( dct_res + i * 16, 16, Q_new ), 4096 ); /*Q7*/
616 : }
617 15091 : m_mean = round_fx( Lm_mean ); /*Q7*/
618 :
619 15091 : IF( GT_16( m_mean, hGSCEnc->mid_dyn_fx ) )
620 : {
621 : /*st_fx->mid_dyn_fx = 0.2f * st_fx->mid_dyn_fx + 0.8f * m_mean;*/
622 6874 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
623 6874 : move16();
624 : }
625 : ELSE
626 : {
627 : /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
628 8217 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
629 8217 : move16();
630 : }
631 15091 : IF( NE_16( st_fx->coder_type, INACTIVE ) )
632 : {
633 10910 : hGSCEnc->noise_lev = sub( ( NOISE_LEVEL_SP3 + 1 ), usquant_fx( hGSCEnc->mid_dyn_fx, &m_mean, MIN_DYNAMIC_FX, shr( GSF_NF_DELTA_FX, 1 ), GSC_NF_STEPS ) );
634 10910 : move16();
635 10910 : hGSCEnc->noise_lev = s_min( hGSCEnc->noise_lev, NOISE_LEVEL_SP3 );
636 10910 : move16();
637 : }
638 :
639 15091 : hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
640 15091 : move16();
641 15091 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
642 : {
643 4875 : hGSCEnc->noise_lev = NOISE_LEVEL_SP2;
644 4875 : move16();
645 4875 : IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
646 : {
647 2805 : hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
648 2805 : move16();
649 : }
650 2070 : ELSE IF( st_fx->GSC_noisy_speech == 0 )
651 : {
652 1961 : hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
653 1961 : move16();
654 : }
655 : }
656 10216 : ELSE IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
657 : {
658 5048 : hGSCEnc->noise_lev = s_max( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 );
659 5048 : push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ), 2 );
660 : }
661 5168 : ELSE IF( st_fx->GSC_noisy_speech )
662 : {
663 696 : hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
664 696 : move16();
665 : }
666 : ELSE
667 : {
668 4472 : push_indice( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP0 ), 3 );
669 : }
670 :
671 : /*---------------------------------------------------------------*
672 : * Find and encode the last band where the adaptive (pitch) contribution is significant
673 : *---------------------------------------------------------------*/
674 :
675 15091 : last_pit_bin = Pit_exc_contribution_len_ivas_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new );
676 :
677 15091 : IF( last_pit_bin == 0 )
678 : {
679 2253 : hLPDmem->tilt_code = 0;
680 2253 : move16();
681 : }
682 : ELSE
683 : {
684 : /*last_pit_bin++;*/
685 12838 : last_pit_bin = add( last_pit_bin, 1 );
686 : }
687 :
688 : /*--------------------------------------------------------------------------------------*
689 : * GSC encoder
690 : *--------------------------------------------------------------------------------------*/
691 :
692 : /* Find the current total number of bits used */
693 15091 : tmp_nb_bits_tot = hBstr->nb_bits_tot;
694 15091 : move16();
695 :
696 :
697 15091 : if ( st_fx->extl_brate > 0 )
698 : {
699 : /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
700 14975 : tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 );
701 : }
702 15091 : test();
703 15091 : test();
704 15091 : if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
705 : {
706 : /* add 5 bits for noisiness */
707 339 : tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 );
708 : }
709 :
710 15091 : Word16 Q_exc = Q_new;
711 15091 : move16();
712 15091 : gsc_enc_ivas_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc );
713 :
714 : /*--------------------------------------------------------------------------------------*
715 : * iDCT transform
716 : *--------------------------------------------------------------------------------------*/
717 :
718 15091 : edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
719 15091 : Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) );
720 15091 : edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
721 15091 : Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) );
722 15091 : Q_exc = Q_new;
723 15091 : move16();
724 : /*--------------------------------------------------------------------------------------*
725 : * Remove potential pre-echo in case an onset has been detected
726 : *--------------------------------------------------------------------------------------*/
727 :
728 15091 : pre_echo_att_ivas_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_exc, st_fx->last_coder_type, st_fx->L_frame );
729 :
730 : /*--------------------------------------------------------------------------------------*
731 : * Update BWE excitation
732 : *--------------------------------------------------------------------------------------*/
733 15091 : IF( st_fx->hBWE_TD != NULL )
734 : {
735 15091 : IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
736 : {
737 2659 : set16_fx( voice_factors, 0, NB_SUBFR16k );
738 2659 : interp_code_4over2_fx( exc, bwe_exc, L_FRAME16k );
739 : }
740 : ELSE
741 : {
742 12432 : set16_fx( voice_factors, 0, NB_SUBFR );
743 12432 : interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
744 : }
745 : }
746 : /*--------------------------------------------------------------------------------------*
747 : * Synthesis
748 : *--------------------------------------------------------------------------------------*/
749 :
750 15091 : p_Aq = Aq; /* Q12 */
751 78114 : FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_SUBFR )
752 : {
753 63023 : Syn_filt_s( 1, p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
754 63023 : p_Aq += ( M + 1 );
755 : }
756 :
757 : /*--------------------------------------------------------------------------------------*
758 : * Updates
759 : *--------------------------------------------------------------------------------------*/
760 15091 : Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) );
761 : /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */
762 15091 : move16();
763 15091 : Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_new */
764 :
765 15091 : return;
766 : }
767 :
768 : /*================================================================================*/
769 : /* FUNCTION : void gsc_enc_fx () */
770 : /*--------------------------------------------------------------------------------*/
771 : /* PURPOSE : Generic audio signal encoder */
772 : /*--------------------------------------------------------------------------------*/
773 : /* INPUT ARGUMENTS : */
774 : /* _ (Word16) res_dct_in : dct of residual signal Q_exc */
775 : /* _ (Word16) Diff_len : Lenght of the difference signal Q0 */
776 : /* _ (Word16) coder_type : coding type Q0 */
777 : /* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */
778 : /* _ (Word16) nb_subfr : Number of subframe considered Q0 */
779 : /* _ (Word16) Qexc : Q format of exc_dct_in */
780 : /*--------------------------------------------------------------------------------*/
781 : /* OUTPUT ARGUMENTS : */
782 : /* _ None */
783 : /*--------------------------------------------------------------------------------*/
784 : /* INPUT/OUTPUT ARGUMENTS : */
785 : /* Encoder_State *st_fx:Encoder State Structure */
786 : /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Q_exc */
787 : /*--------------------------------------------------------------------------------*/
788 : /* RETURN ARGUMENTS : */
789 : /* _None */
790 : /*================================================================================*/
791 :
792 :
793 8 : void gsc_enc_fx(
794 : Encoder_State *st_fx, /* i/o: State structure */
795 : Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/
796 : Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
797 : const Word16 Diff_len,
798 : const Word16 bits_used,
799 : const Word16 nb_subfr,
800 : Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/
801 : Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
802 : Word16 *tmp_noise, /* o : noise energy Q2*/
803 : Word16 Q_exc )
804 : {
805 : Word16 y2_filt[L_FRAME16k];
806 : Word16 exc_diffQ[L_FRAME16k];
807 : Word16 exc_diff[L_FRAME16k];
808 : Word16 bit, tmp;
809 : Word16 nb_subbands;
810 : Word16 pvq_len, i;
811 : Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
812 : Word16 tmp_band;
813 : Word16 concat_in[L_FRAME16k];
814 : Word16 concat_out[L_FRAME16k];
815 : Word16 max_ener_band[MBANDS_GN_BITALLOC16k], j;
816 : Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
817 : Word16 last_bin, mean_gain;
818 : Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
819 : Word16 bitallocation_exc[2];
820 :
821 : Word16 inpulses_fx[NB_SFM];
822 : Word16 imaxpulse_fx[NB_SFM];
823 : Word16 Q_tmp;
824 : Word16 seed_init;
825 8 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
826 8 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
827 :
828 8 : set16_fx( inpulses_fx, 0, NB_SFM );
829 8 : set16_fx( imaxpulse_fx, 0, NB_SFM );
830 :
831 : /*--------------------------------------------------------------------------------------*
832 : * Initialization
833 : *--------------------------------------------------------------------------------------*/
834 :
835 8 : bit = bits_used;
836 8 : move16();
837 8 : test();
838 8 : test();
839 8 : test();
840 8 : if ( EQ_16( st_fx->coder_type, INACTIVE ) && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
841 : {
842 0 : bit = add( bit, GSC_LRES_NB_NITS );
843 : }
844 8 : move16();
845 8 : set16_fx( exc_diffQ, 0, st_fx->L_frame );
846 8 : set16_fx( y2_filt, 0, st_fx->L_frame );
847 :
848 : /*--------------------------------------------------------------------------------------*
849 : * Calculate the difference between the residual spectrum and the spectrum of adaptive excitation
850 : * (non valuable temporal content present in exc_dct_in is already zeroed)
851 : *--------------------------------------------------------------------------------------*/
852 :
853 8 : Vr_subt( res_dct_in, exc_dct_in, exc_diff, st_fx->L_frame );
854 8 : exc_diff[0] = 0;
855 8 : move16();
856 :
857 : /*--------------------------------------------------------------------------------------*
858 : * Multiply the difference spectrum with the normalized spectral shape of the residual signal
859 : * This improves the stability of the differnece spectrum since the spectral shape of the
860 : * residual signal is less suseptible to rapid changes than the difference spectrum
861 : *--------------------------------------------------------------------------------------*/
862 8 : IF( Diff_len == 0 )
863 : {
864 0 : tmp_band = 0;
865 0 : move16();
866 : }
867 : ELSE
868 : {
869 8 : tmp_band = hGSCEnc->mem_last_pit_band;
870 8 : move16();
871 : }
872 :
873 8 : Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ );
874 :
875 : /*--------------------------------------------------------------------------------------*
876 : * Gain quantizaion
877 : *--------------------------------------------------------------------------------------*/
878 8 : i = 0;
879 8 : move16();
880 48 : WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
881 : {
882 48 : IF( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) )
883 : {
884 8 : BREAK;
885 : }
886 40 : i++;
887 : }
888 :
889 8 : test();
890 8 : test();
891 8 : test();
892 8 : if ( GT_16( st_fx->element_mode, EVS_MONO ) && EQ_16( st_fx->coder_type, AUDIO ) &&
893 0 : LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
894 : {
895 0 : i--;
896 : }
897 :
898 8 : mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ );
899 :
900 8 : *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */
901 8 : move16();
902 :
903 : /*--------------------------------------------------------------------------------------*
904 : * Frequency encoder
905 : *--------------------------------------------------------------------------------------*/
906 :
907 8 : bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ,
908 8 : max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth,
909 8 : st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
910 :
911 8 : Q_tmp = Q_exc;
912 8 : move16();
913 8 : IF( bit == 0 )
914 : {
915 0 : set16_fx( concat_out, 0, L_FRAME16k );
916 : }
917 : ELSE
918 : {
919 8 : tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end,
920 : gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
921 8 : Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
922 8 : bit = sub( bit, tmp );
923 : }
924 : /* write unused bits */
925 8 : WHILE( bit > 0 )
926 : {
927 0 : i = s_min( bit, 16 );
928 0 : push_indice( hBstr, IND_UNUSED, 0, i );
929 0 : bit = sub( bit, i );
930 : }
931 : /* Reorder Q bands */
932 8 : seed_init = 0;
933 8 : move16();
934 8 : last_bin = 0;
935 8 : move16();
936 8 : set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k );
937 :
938 72 : FOR( j = 0; j < nb_subbands; j++ )
939 : {
940 64 : Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); /*Q12*/
941 :
942 64 : last_bin = s_max( last_bin, max_ener_band[j] );
943 :
944 64 : bitallocation_band[max_ener_band[j]] = 1;
945 64 : move16();
946 :
947 64 : seed_init = add( seed_init, inpulses_fx[j] );
948 64 : move16();
949 : }
950 8 : test();
951 8 : IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */
952 : && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_enc to UNVOICED */
953 : {
954 258 : FOR( j = 0; j < shl( nb_subbands, 4 ); j++ )
955 : {
956 256 : IF( concat_out[j] > 0 )
957 : {
958 31 : seed_init = extract_l( L_shl( seed_init, 3 ) );
959 : }
960 256 : IF( concat_out[j] < 0 )
961 : {
962 37 : seed_init = add( seed_init, 3 );
963 37 : move16();
964 : }
965 : }
966 2 : hGSCEnc->seed_tcx = seed_init;
967 2 : move16();
968 : }
969 8 : test();
970 8 : IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
971 : {
972 0 : bitallocation_exc[0] = 0;
973 0 : move16();
974 0 : bitallocation_exc[1] = 0;
975 0 : move16();
976 0 : if ( exc_diffQ[L_FRAME8k - 2] != 0 )
977 : {
978 0 : bitallocation_exc[0] = 1;
979 0 : move16();
980 : }
981 0 : if ( exc_diffQ[L_FRAME8k - 1] != 0 )
982 : {
983 0 : bitallocation_exc[1] = 1;
984 0 : move16();
985 : }
986 : }
987 :
988 : /*--------------------------------------------------------------------------------------*
989 : * Skip adaptive (pitch) contribution frequency band (no noise added over the adaptive (pitch) contribution)
990 : * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
991 : * Gain is based on the inter-correlation gain between the pulses found and residual signal
992 : *--------------------------------------------------------------------------------------*/
993 :
994 : {
995 8 : freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame );
996 : }
997 : /*--------------------------------------------------------------------------------------*
998 : * Estimate noise level
999 : *--------------------------------------------------------------------------------------*/
1000 :
1001 8 : highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ,
1002 8 : &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
1003 8 : hGSCEnc->last_exc_dct_in_fx, &st_fx->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type,
1004 8 : st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
1005 :
1006 8 : exc_dct_in[0] = 0;
1007 8 : move16();
1008 :
1009 8 : return;
1010 : }
1011 :
1012 :
1013 22654 : void gsc_enc_ivas_fx(
1014 : Encoder_State *st, /* i/o: State structure */
1015 : Word16 res_dct_in_fx[],
1016 : /* i : dct of residual signal */ // Q_exc
1017 : Word16 exc_dct_in_fx[],
1018 : /* i/o: dct of pitch-only excitation / total excitation */ // Q_exc
1019 : const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
1020 : const Word16 bits_used, /* i : Number of bit used before frequency Q */
1021 : const Word16 nb_subfr, /* i : Number of subframe considered */
1022 : const Word16 *lsf_new_fx, /* Qx2.56 */
1023 : /* i : ISFs at the end of the frame */ // Q15
1024 : Word16 *exc_wo_nf_fx,
1025 : /* o : excitation (in f domain) without noisefill */ // Q_exc
1026 : Word16 *tmp_noise_fx, /* o : long-term noise energy Q8*/
1027 : Word16 *Q_exc )
1028 : {
1029 : Word16 i;
1030 : GSC_ENC_HANDLE hGSCEnc;
1031 : BSTR_ENC_HANDLE hBstr;
1032 : Word16 exc_diffQ_fx[L_FRAME16k];
1033 : Word16 exc_diff_fx[L_FRAME16k];
1034 : Word16 bit;
1035 : Word16 nb_subbands;
1036 : Word16 pvq_len;
1037 : Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; /*Q3*/
1038 : Word16 tmp_band;
1039 : Word16 concat_in_fx[L_FRAME16k];
1040 : Word16 concat_out_fx[L_FRAME16k];
1041 : Word16 max_ener_band[MBANDS_GN_BITALLOC16k], j;
1042 : Word16 Ener_per_bd_iQ_fx[MBANDS_GN16k];
1043 : Word16 last_bin;
1044 : Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
1045 : Word16 bitallocation_exc[2];
1046 : Word16 npulses[NB_SFM];
1047 : Word16 maxpulse[NB_SFM];
1048 : Word16 mean_gain_fx;
1049 : Word16 seed_init;
1050 : Word32 L_tmp;
1051 : Word16 max_eq;
1052 :
1053 : /*--------------------------------------------------------------------------------------*
1054 : * Initialization
1055 : *--------------------------------------------------------------------------------------*/
1056 :
1057 22654 : hGSCEnc = st->hGSCEnc;
1058 22654 : hBstr = st->hBstr;
1059 :
1060 22654 : bit = bits_used;
1061 22654 : move16();
1062 :
1063 22654 : test();
1064 22654 : test();
1065 22654 : test();
1066 22654 : if ( st->coder_type == INACTIVE && ( EQ_16( st->tdm_LRTD_flag, 1 ) || EQ_16( st->element_mode, IVAS_SCE ) ) && LE_32( st->core_brate, GSC_LRES_GAINQ_LIMIT ) )
1067 : {
1068 7044 : bit = add( bit, GSC_LRES_NB_NITS );
1069 : }
1070 :
1071 22654 : set16_fx( exc_diffQ_fx, 0, st->L_frame );
1072 22654 : set16_fx( Ener_per_bd_iQ_fx, 0, MBANDS_GN16k );
1073 :
1074 : /*--------------------------------------------------------------------------------------*
1075 : * Calculate the difference between the residual spectrum and the spectrum of adaptive excitation
1076 : * (non valuable temporal content present in exc_dct_in is already zeroed)
1077 : *--------------------------------------------------------------------------------------*/
1078 :
1079 22654 : v_sub_16( res_dct_in_fx, exc_dct_in_fx, exc_diff_fx, st->L_frame ); /* Q_exc */
1080 22654 : exc_diff_fx[0] = 0;
1081 22654 : move16();
1082 :
1083 : /*--------------------------------------------------------------------------------------*
1084 : * Multiply the difference spectrum with the normalized spectral shape of the residual signal
1085 : * This improves the stability of the differnece spectrum since the spectral shape of the
1086 : * residual signal is less suseptible to rapid changes than the difference spectrum
1087 : *--------------------------------------------------------------------------------------*/
1088 :
1089 22654 : IF( Diff_len == 0 )
1090 : {
1091 2253 : tmp_band = 0;
1092 : }
1093 : ELSE
1094 : {
1095 20401 : tmp_band = hGSCEnc->mem_last_pit_band;
1096 : }
1097 22654 : move16();
1098 :
1099 22654 : Ener_per_band_comp_ivas_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame );
1100 :
1101 : /*--------------------------------------------------------------------------------------*
1102 : * Gain quantizaion
1103 : *--------------------------------------------------------------------------------------*/
1104 :
1105 22654 : i = 0;
1106 22654 : move16();
1107 :
1108 105628 : WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
1109 : {
1110 105628 : IF( LE_32( st->core_brate, brate_intermed_tbl[i] ) )
1111 : {
1112 22654 : BREAK;
1113 : }
1114 82974 : i++;
1115 : }
1116 :
1117 22654 : test();
1118 22654 : test();
1119 22654 : test();
1120 33564 : if ( st->element_mode > EVS_MONO && EQ_16( st->coder_type, AUDIO ) &&
1121 17859 : LE_32( st->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
1122 : {
1123 1226 : i--;
1124 : }
1125 :
1126 22654 : mean_gain_fx = gsc_gainQ_ivas_fx( hBstr, st->element_mode, st->idchan, Ener_per_bd_iQ_fx, Ener_per_bd_iQ_fx, brate_intermed_tbl[i], st->coder_type, st->bwidth, st->L_frame, st->tdm_LRTD_flag, st->core_brate );
1127 :
1128 22654 : *tmp_noise_fx = mult( mean_gain_fx, 20480 ); // 20480 => 10 in Q11
1129 22654 : move16(); // Q8
1130 :
1131 : /*--------------------------------------------------------------------------------------*
1132 : * PVQ encoder
1133 : *--------------------------------------------------------------------------------------*/
1134 :
1135 22654 : bands_and_bit_alloc_ivas_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ_fx, max_ener_band, bits_per_bands, &nb_subbands, exc_diff_fx, concat_in_fx, &pvq_len, st->coder_type, st->bwidth, st->GSC_noisy_speech, st->L_frame, st->element_mode, st->GSC_IVAS_mode );
1136 :
1137 22654 : set16_fx( npulses, 0, NB_SFM );
1138 :
1139 22654 : IF( bit == 0 )
1140 : {
1141 0 : set16_fx( concat_out_fx, 0, L_FRAME16k );
1142 : }
1143 : ELSE
1144 : {
1145 22654 : Word16 Q_concat = Q12;
1146 22654 : move16();
1147 22654 : bit = sub( bit, pvq_core_enc_ivas_fx( hBstr, concat_in_fx, concat_out_fx, &Q_concat, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, npulses, maxpulse, ACELP_CORE ) );
1148 : }
1149 :
1150 : /* write unused bits */
1151 22654 : WHILE( bit > 0 )
1152 : {
1153 0 : i = s_min( bit, 16 );
1154 0 : push_indice( hBstr, IND_UNUSED, 0, i );
1155 0 : bit = sub( bit, i );
1156 : }
1157 :
1158 : /* Reorder Q bands */
1159 22654 : last_bin = 0;
1160 22654 : move16();
1161 22654 : set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k );
1162 22654 : seed_init = 0;
1163 22654 : move16();
1164 :
1165 22654 : max_eq = 0;
1166 22654 : move16();
1167 :
1168 22654 : test();
1169 22654 : test();
1170 22654 : test();
1171 22654 : test();
1172 22654 : IF( ( ( ( LT_32( st->core_brate, ACELP_7k20 ) && EQ_16( st->GSC_noisy_speech, 1 ) ) || LT_32( st->core_brate, 6000 ) ) && LE_16( st->coder_type, UNVOICED ) ) || GE_16( st->GSC_IVAS_mode, 1 ) )
1173 : {
1174 12376 : j = emaximum_fx( Q12, concat_out_fx, shl( nb_subbands, 4 ), &L_tmp );
1175 12376 : IF( LE_16( add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ), ONE_IN_Q12 ) )
1176 : {
1177 7022 : max_eq = 32767; /* Q15 */
1178 7022 : move16();
1179 : }
1180 : ELSE
1181 : {
1182 5354 : max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ) ); /* Q15 */
1183 : }
1184 : }
1185 :
1186 185331 : FOR( j = 0; j < nb_subbands; j++ )
1187 : {
1188 162677 : Copy( concat_out_fx + i_mult( j, 16 ), exc_diffQ_fx + i_mult( max_ener_band[j], 16 ), 16 ); /* Q12 */
1189 :
1190 162677 : IF( GT_16( max_ener_band[j], last_bin ) )
1191 : {
1192 117939 : last_bin = max_ener_band[j];
1193 117939 : move16();
1194 : }
1195 :
1196 162677 : bitallocation_band[max_ener_band[j]] = 1;
1197 162677 : move16();
1198 :
1199 162677 : seed_init = add( seed_init, npulses[j] );
1200 : }
1201 22654 : test();
1202 22654 : IF( NE_16( st->last_coder_type, AUDIO ) /* First audio frame */
1203 : && NE_16( st->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_enc to UNVOICED */
1204 : {
1205 462850 : FOR( j = 0; j < nb_subbands * 16; j++ )
1206 : {
1207 459376 : IF( concat_out_fx[j] > 0 )
1208 : {
1209 67056 : seed_init = (Word16) L_mult0( seed_init, 8 );
1210 67056 : move16();
1211 : }
1212 459376 : IF( concat_out_fx[j] < 0 )
1213 : {
1214 67283 : seed_init = (Word16) L_add( seed_init, 3 );
1215 67283 : move16();
1216 : }
1217 : }
1218 :
1219 3474 : hGSCEnc->seed_tcx = seed_init;
1220 3474 : move16();
1221 : }
1222 :
1223 22654 : test();
1224 22654 : IF( EQ_32( st->core_brate, ACELP_8k00 ) && st->bwidth != NB )
1225 : {
1226 43 : bitallocation_exc[0] = 0;
1227 43 : move16();
1228 43 : bitallocation_exc[1] = 0;
1229 43 : move16();
1230 :
1231 43 : if ( exc_diffQ_fx[L_FRAME8k - 2] != 0 )
1232 : {
1233 1 : bitallocation_exc[0] = 1;
1234 1 : move16();
1235 : }
1236 :
1237 43 : if ( exc_diffQ_fx[L_FRAME8k - 1] != 0 )
1238 : {
1239 4 : bitallocation_exc[1] = 1;
1240 4 : move16();
1241 : }
1242 : }
1243 :
1244 : /*--------------------------------------------------------------------------------------*
1245 : * Skip adaptive (pitch) contribution frequency band (no noise added over the adaptive (pitch) contribution)
1246 : * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
1247 : * Gain is based on the inter-correlation gain between the pulses found and residual signal
1248 : *--------------------------------------------------------------------------------------*/
1249 :
1250 22654 : test();
1251 22654 : test();
1252 22654 : test();
1253 22654 : IF( st->GSC_IVAS_mode >= 1 && st->GSC_noisy_speech == 1 )
1254 : {
1255 21037 : FOR( i = 64; i < st->L_frame; i++ )
1256 : {
1257 20928 : exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq ); /* Q12 */
1258 20928 : move16();
1259 : }
1260 : }
1261 22545 : ELSE IF( st->core_brate < ACELP_7k20 && st->GSC_noisy_speech == 1 && st->coder_type <= UNVOICED )
1262 : {
1263 1927757 : FOR( i = 0; i < L_FRAME; i++ )
1264 : {
1265 1920256 : exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq ); /* Q12 */
1266 1920256 : move16();
1267 : }
1268 : }
1269 : ELSE
1270 : {
1271 15044 : freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st->coder_type, hGSCEnc->noise_lev, st->core_brate, exc_diffQ_fx, Q12, st->L_frame );
1272 : }
1273 :
1274 22654 : Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in );
1275 22654 : IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) )
1276 : {
1277 22603 : Scale_sig( hGSCEnc->last_exc_dct_in_fx, st->L_frame, sub( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ); /* Q_exc_new */
1278 22603 : hGSCEnc->Q_last_exc_dct_in = Q_exc_new;
1279 22603 : move16();
1280 : }
1281 : ELSE
1282 : {
1283 51 : Scale_sig( exc_dct_in_fx, st->L_frame, sub( Q_exc_new, *Q_exc ) ); /* Q_exc_new */
1284 51 : *Q_exc = Q_exc_new;
1285 51 : move16();
1286 : }
1287 :
1288 : /*--------------------------------------------------------------------------------------*
1289 : * Estimate noise level
1290 : *--------------------------------------------------------------------------------------*/
1291 22654 : highband_exc_dct_in_ivas_fx( st->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ_fx /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ_fx, nb_subfr, exc_dct_in_fx /* Q_exc */,
1292 22654 : st->last_coder_type, bitallocation_band, lsf_new_fx /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st->coder_type,
1293 22654 : st->bwidth, exc_wo_nf_fx, Q12, Q_exc, st->GSC_noisy_speech, NULL, st->L_frame, st->element_mode, st->GSC_IVAS_mode );
1294 :
1295 22654 : exc_dct_in_fx[0] = 0;
1296 22654 : move16();
1297 :
1298 22654 : return;
1299 : }
1300 :
1301 : /*======================================================================*/
1302 : /* FUNCTION : edyn_fx() */
1303 : /*----------------------------------------------------------------------*/
1304 : /* PURPOSE : Calculate energy dynamics in a vector */
1305 : /* (ratio of energy maximum to energy mean) */
1306 : /* */
1307 : /*----------------------------------------------------------------------*/
1308 : /* INPUT ARGUMENTS : */
1309 : /* _ (Word16 *) vec : ratio of max to mean Qnew */
1310 : /* _ (Word16) lvec : input vector */
1311 : /* _ (Word16) Q_new : */
1312 : /*-----------------------------------------------------------------------*/
1313 : /* OUTPUT ARGUMENTS : */
1314 : /* _ (Word16) dyn : ratio of energy maximum to energy mean (Q7) */
1315 : /*-----------------------------------------------------------------------*/
1316 :
1317 : /*-----------------------------------------------------------------------*/
1318 : /* RETURN ARGUMENTS : */
1319 : /* _ None */
1320 : /*=======================================================================*/
1321 :
1322 120792 : static Word16 edyn_fx( /* o : ratio of max to mean */
1323 : const Word16 *vec, /* i : input vector Qnew*/
1324 : const Word16 lvec, /* i : length of input vector */
1325 : Word16 Qnew )
1326 : {
1327 120792 : Word16 j = 0;
1328 : Word16 dyn;
1329 : Word32 L_tmp, ener_max, ener_mean;
1330 : Word16 tmp, exp2, tmp2, tmp1, exp1, exp3;
1331 : Word16 scale;
1332 : #ifndef ISSUE_1867_replace_overflow_libenc
1333 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
1334 : Flag Overflow = 0;
1335 : move32();
1336 : #endif
1337 : #endif
1338 :
1339 120792 : ener_mean = L_shl( 1, shl( Qnew, 1 ) ); /*2*Qnew*/
1340 120792 : ener_max = L_shl( 1, shl( Qnew, 1 ) );
1341 :
1342 2053464 : FOR( j = 0; j < lvec; j++ )
1343 : {
1344 1932672 : L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/
1345 1932672 : ener_max = L_max( ener_max, L_tmp );
1346 : #ifdef ISSUE_1867_replace_overflow_libenc
1347 1932672 : ener_mean = L_add_sat( ener_mean, L_tmp );
1348 : #else
1349 : ener_mean = L_add_o( ener_mean, L_tmp, &Overflow );
1350 : #endif
1351 : }
1352 : /*dyn = 10.0f * (ener_max / ener_mean);*/
1353 120792 : ener_mean = Mult_32_16( ener_mean, div_s( 1, lvec ) ); /*2*Qnew*/
1354 :
1355 120792 : IF( ener_mean > 0 )
1356 : {
1357 120792 : exp1 = norm_l( ener_mean );
1358 : #ifdef ISSUE_1867_replace_overflow_libenc
1359 120792 : tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) );
1360 : #else
1361 : tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow );
1362 : #endif
1363 120792 : exp1 = sub( 30, exp1 );
1364 :
1365 120792 : exp2 = norm_l( ener_max );
1366 120792 : tmp2 = extract_h( L_shl( ener_max, exp2 ) );
1367 120792 : exp2 = sub( 30, exp2 );
1368 :
1369 120792 : scale = shr( sub( tmp1, tmp2 ), 15 );
1370 120792 : tmp2 = shl( tmp2, scale );
1371 120792 : exp2 = sub( exp2, scale );
1372 :
1373 120792 : exp3 = sub( exp1, exp2 );
1374 :
1375 120792 : tmp = div_s( tmp2, tmp1 ); /*Q(15+exp3)*/
1376 :
1377 120792 : L_tmp = L_shr_r( L_mult( tmp, 10 ), exp3 );
1378 120792 : dyn = round_fx( L_shl( L_tmp, 7 ) ); /*Q7*/
1379 : }
1380 : ELSE
1381 : {
1382 0 : dyn = 1280; /* 10.0f in Q7 */
1383 0 : move16();
1384 : }
1385 120792 : return dyn; /* Q7 */
1386 : }
1387 :
1388 :
1389 : /*-------------------------------------------------------------------*
1390 : * GSC_enc_init_fx()
1391 : *
1392 : * Initialize GSC encoder state structure
1393 : *-------------------------------------------------------------------*/
1394 :
1395 3898 : void GSC_enc_init_fx(
1396 : GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */
1397 : )
1398 : {
1399 : /* AC mode */
1400 3898 : hGSCEnc->seed_tcx = 15687; /* Q0 */
1401 3898 : move16();
1402 3898 : hGSCEnc->cor_strong_limit = 1;
1403 3898 : move16();
1404 3898 : set16_fx( hGSCEnc->last_exc_dct_in_fx, 0, L_FRAME16k );
1405 3898 : hGSCEnc->Q_last_exc_dct_in = Q15;
1406 3898 : move16();
1407 3898 : set16_fx( hGSCEnc->last_bitallocation_band, 0, 6 );
1408 :
1409 3898 : hGSCEnc->mem_last_pit_band = BAND1k2 + 1;
1410 3898 : move16();
1411 3898 : hGSCEnc->Last_frame_ener_fx = MAX_32;
1412 3898 : move32();
1413 3898 : hGSCEnc->lt_gpitch_fx = 0;
1414 3898 : move16();
1415 3898 : move16();
1416 3898 : hGSCEnc->pit_exc_hangover = 0;
1417 3898 : move16();
1418 :
1419 3898 : hGSCEnc->mem_w0_tmp_fx = 0;
1420 3898 : move16();
1421 :
1422 3898 : set16_fx( hGSCEnc->mem_syn_tmp_fx, 0, M );
1423 3898 : hGSCEnc->mid_dyn_fx = 5120; /*40 -> Q7 */
1424 3898 : move16();
1425 3898 : hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
1426 3898 : move16();
1427 3898 : hGSCEnc->past_dyn_dec = 0;
1428 3898 : move16();
1429 :
1430 :
1431 3898 : return;
1432 : }
|