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 5 : 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 5 : Word16 tmp_nb_bits_tot = 0;
46 5 : move16();
47 : Word16 Es_pred;
48 : Word16 dct_res[L_FRAME16k], dct_epit[L_FRAME16k];
49 5 : Word16 m_mean = 0;
50 5 : 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 5 : SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
57 5 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
58 5 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
59 5 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
60 :
61 5 : m_mean = 0;
62 5 : move16();
63 5 : tmp_nb_bits_tot = 0;
64 5 : move16();
65 :
66 5 : T0_tmp = 64;
67 5 : move16();
68 5 : T0_frac_tmp = 0;
69 5 : move16();
70 5 : Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */
71 5 : hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0;
72 5 : move16();
73 5 : Es_pred = 0;
74 5 : 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 5 : IF( attack_flag > 0 )
83 : {
84 0 : push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
85 : }
86 : ELSE
87 : {
88 5 : push_indice( hBstr, IND_GSC_ATTACK, 0, 1 );
89 : }
90 :
91 :
92 5 : test();
93 5 : test();
94 5 : test();
95 5 : test();
96 5 : test();
97 5 : test();
98 5 : test();
99 5 : 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 5 : test();
108 5 : IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) )
109 : {
110 30 : FOR( i = 0; i < 5; i++ )
111 : {
112 25 : test();
113 25 : 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 5 : test();
121 5 : test();
122 5 : test();
123 5 : test();
124 5 : 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 5 : 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 5 : test();
152 5 : test();
153 5 : IF( ( hGSCEnc->cor_strong_limit == 0 || EQ_16( st_fx->coder_type, INACTIVE ) ) && GE_32( st_fx->core_brate, ACELP_9k60 ) )
154 : {
155 5 : nb_subfr = 2;
156 5 : move16();
157 5 : nb_subfr_flag = 0;
158 5 : move16();
159 5 : hGSCEnc->cor_strong_limit = 0;
160 5 : 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 5 : test();
171 5 : test();
172 5 : test();
173 5 : 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 5 : 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 5 : ELSE IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
185 : {
186 : /* nb_subfr_flag can only have the value 0 or 1 */
187 5 : push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 );
188 : }
189 : }
190 5 : test();
191 5 : 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 5 : test();
202 5 : test();
203 5 : test();
204 5 : test();
205 5 : test();
206 5 : test();
207 5 : test();
208 5 : test();
209 5 : 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 5 : 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 5 : edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
234 5 : edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode );
235 : /*---------------------------------------------------------------*
236 : * Calculate energy dynamics
237 : *---------------------------------------------------------------*/
238 5 : Lm_mean = L_deposit_l( 0 );
239 45 : FOR( i = 7; i < 15; i++ )
240 : {
241 : /*m_mean = add(m_mean,edyn_fx( dct_res+i*16, 16, Q_new )); */
242 40 : Lm_mean = L_mac( Lm_mean, edyn_fx( dct_res + i * 16, 16, Q_new ), 4096 ); /*Q7*/
243 : }
244 5 : m_mean = round_fx( Lm_mean ); /*Q7*/
245 :
246 5 : 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 3 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
250 3 : move16();
251 : }
252 : ELSE
253 : {
254 : /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
255 2 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
256 2 : move16();
257 : }
258 5 : 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 5 : hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
267 5 : move16();
268 5 : 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 5 : 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 5 : 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 5 : 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 5 : 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 5 : IF( last_pit_bin == 0 )
307 : {
308 0 : hLPDmem->tilt_code = 0;
309 0 : move16();
310 : }
311 : ELSE
312 : {
313 : /*last_pit_bin++;*/
314 5 : 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 5 : tmp_nb_bits_tot = hBstr->nb_bits_tot;
323 5 : move16();
324 :
325 :
326 5 : if ( st_fx->extl_brate > 0 )
327 : {
328 : /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
329 5 : tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 );
330 : }
331 5 : test();
332 5 : test();
333 5 : 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 5 : 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 5 : edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
346 5 : 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 5 : 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 5 : IF( st_fx->hBWE_TD != NULL )
357 : {
358 5 : 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 5 : set16_fx( voice_factors, 0, NB_SUBFR );
366 5 : interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
367 : }
368 : }
369 : /*--------------------------------------------------------------------------------------*
370 : * Synthesis
371 : *--------------------------------------------------------------------------------------*/
372 :
373 5 : p_Aq = Aq;
374 25 : FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_SUBFR )
375 : {
376 20 : Syn_filt_s( 1, p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
377 20 : p_Aq += ( M + 1 );
378 : }
379 :
380 : /*--------------------------------------------------------------------------------------*
381 : * Updates
382 : *--------------------------------------------------------------------------------------*/
383 :
384 5 : 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 5 : move16();
386 5 : Copy( exc_wo_nf, exc, st_fx->L_frame );
387 :
388 5 : return;
389 : }
390 :
391 15095 : 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 15095 : Word16 tmp_nb_bits_tot = 0;
414 : Word16 Es_pred;
415 : Word16 dct_res[L_FRAME16k], dct_epit[L_FRAME16k];
416 15095 : 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 15095 : SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
423 15095 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
424 15095 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
425 15095 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
426 :
427 15095 : m_mean = 0;
428 15095 : move16();
429 15095 : tmp_nb_bits_tot = 0;
430 15095 : move16();
431 :
432 15095 : T0_tmp = 64;
433 15095 : move16();
434 15095 : T0_frac_tmp = 0;
435 15095 : move16();
436 15095 : Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
437 15095 : Copy_Scale_sig( &hLPDmem->mem_w0, &hGSCEnc->mem_w0_tmp_fx, 1, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
438 15095 : move16();
439 15095 : Es_pred = 0;
440 15095 : 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 15095 : test();
449 15095 : if ( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 )
450 : {
451 15095 : push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
452 : }
453 :
454 15095 : IF( attack_flag > 0 )
455 : {
456 0 : push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
457 : }
458 : ELSE
459 : {
460 15095 : push_indice( hBstr, IND_GSC_ATTACK, 0, 1 );
461 : }
462 :
463 :
464 15095 : test();
465 15095 : test();
466 15095 : test();
467 15095 : test();
468 15095 : test();
469 15095 : test();
470 15095 : test();
471 15095 : 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 5588 : 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 15095 : test();
480 15095 : IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) )
481 : {
482 21642 : FOR( i = 0; i < 5; i++ )
483 : {
484 18035 : test();
485 18035 : 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 15095 : test();
493 15095 : test();
494 15095 : test();
495 15095 : test();
496 15095 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->GSC_noisy_speech && st_fx->GSC_IVAS_mode == 0 ) )
497 : {
498 5586 : nb_subfr = NB_SUBFR;
499 5586 : move16();
500 5586 : test();
501 5586 : test();
502 5586 : 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 2070 : nb_subfr = 2;
505 2070 : move16();
506 : }
507 5586 : hGSCEnc->cor_strong_limit = 0;
508 5586 : move16();
509 5586 : nb_subfr_flag = 1;
510 5586 : move16();
511 : }
512 9509 : 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 6850 : test();
524 6850 : test();
525 6850 : 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 5564 : nb_subfr = SWNB_SUBFR;
537 5564 : move16();
538 5564 : nb_subfr_flag = 1;
539 5564 : move16();
540 : }
541 :
542 6850 : test();
543 6850 : test();
544 6850 : test();
545 6850 : 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 6850 : test();
553 6850 : 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 6850 : 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 15095 : test();
564 15095 : 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 15095 : test();
575 15095 : test();
576 15095 : test();
577 15095 : test();
578 15095 : test();
579 15095 : test();
580 15095 : test();
581 15095 : test();
582 15095 : 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 15095 : 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 15095 : edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
607 15095 : edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode );
608 : /*---------------------------------------------------------------*
609 : * Calculate energy dynamics
610 : *---------------------------------------------------------------*/
611 15095 : Lm_mean = L_deposit_l( 0 );
612 135855 : FOR( i = 7; i < 15; i++ )
613 : {
614 : /*m_mean = add(m_mean,edyn_fx( dct_res+i*16, 16, Q_new )); */
615 120760 : Lm_mean = L_mac( Lm_mean, edyn_fx( dct_res + i * 16, 16, Q_new ), 4096 ); /*Q7*/
616 : }
617 15095 : m_mean = round_fx( Lm_mean ); /*Q7*/
618 :
619 15095 : 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 6863 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
623 6863 : move16();
624 : }
625 : ELSE
626 : {
627 : /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
628 8232 : hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
629 8232 : move16();
630 : }
631 15095 : IF( NE_16( st_fx->coder_type, INACTIVE ) )
632 : {
633 10935 : 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 10935 : move16();
635 10935 : hGSCEnc->noise_lev = s_min( hGSCEnc->noise_lev, NOISE_LEVEL_SP3 );
636 10935 : move16();
637 : }
638 :
639 15095 : hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
640 15095 : move16();
641 15095 : IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
642 : {
643 4890 : hGSCEnc->noise_lev = NOISE_LEVEL_SP2;
644 4890 : move16();
645 4890 : IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
646 : {
647 2790 : hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
648 2790 : move16();
649 : }
650 2100 : ELSE IF( st_fx->GSC_noisy_speech == 0 )
651 : {
652 1991 : hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
653 1991 : move16();
654 : }
655 : }
656 10205 : ELSE IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
657 : {
658 5037 : hGSCEnc->noise_lev = s_max( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 );
659 5037 : 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 15095 : 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 15095 : IF( last_pit_bin == 0 )
678 : {
679 2274 : hLPDmem->tilt_code = 0;
680 2274 : move16();
681 : }
682 : ELSE
683 : {
684 : /*last_pit_bin++;*/
685 12821 : 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 15095 : tmp_nb_bits_tot = hBstr->nb_bits_tot;
694 15095 : move16();
695 :
696 :
697 15095 : if ( st_fx->extl_brate > 0 )
698 : {
699 : /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
700 14979 : tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 );
701 : }
702 15095 : test();
703 15095 : test();
704 15095 : 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 318 : tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 );
708 : }
709 :
710 15095 : Word16 Q_exc = Q_new;
711 15095 : move16();
712 15095 : 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 15095 : edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
719 15095 : Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) );
720 15095 : edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
721 15095 : Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) );
722 15095 : Q_exc = Q_new;
723 15095 : move16();
724 : /*--------------------------------------------------------------------------------------*
725 : * Remove potential pre-echo in case an onset has been detected
726 : *--------------------------------------------------------------------------------------*/
727 :
728 15095 : 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 15095 : IF( st_fx->hBWE_TD != NULL )
734 : {
735 15095 : 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 12436 : set16_fx( voice_factors, 0, NB_SUBFR );
743 12436 : interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
744 : }
745 : }
746 : /*--------------------------------------------------------------------------------------*
747 : * Synthesis
748 : *--------------------------------------------------------------------------------------*/
749 :
750 15095 : p_Aq = Aq; /* Q12 */
751 78134 : FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_SUBFR )
752 : {
753 63039 : Syn_filt_s( 1, p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
754 63039 : p_Aq += ( M + 1 );
755 : }
756 :
757 : /*--------------------------------------------------------------------------------------*
758 : * Updates
759 : *--------------------------------------------------------------------------------------*/
760 15095 : 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 15095 : move16();
763 15095 : Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_new */
764 :
765 15095 : 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 5 : 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 5 : GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
826 5 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
827 :
828 5 : set16_fx( inpulses_fx, 0, NB_SFM );
829 5 : set16_fx( imaxpulse_fx, 0, NB_SFM );
830 :
831 : /*--------------------------------------------------------------------------------------*
832 : * Initialization
833 : *--------------------------------------------------------------------------------------*/
834 :
835 5 : bit = bits_used;
836 5 : move16();
837 5 : test();
838 5 : test();
839 5 : test();
840 5 : 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 5 : move16();
845 5 : set16_fx( exc_diffQ, 0, st_fx->L_frame );
846 5 : 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 5 : Vr_subt( res_dct_in, exc_dct_in, exc_diff, st_fx->L_frame );
854 5 : exc_diff[0] = 0;
855 5 : 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 5 : IF( Diff_len == 0 )
863 : {
864 0 : tmp_band = 0;
865 0 : move16();
866 : }
867 : ELSE
868 : {
869 5 : tmp_band = hGSCEnc->mem_last_pit_band;
870 5 : move16();
871 : }
872 :
873 5 : 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 5 : i = 0;
879 5 : move16();
880 30 : WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
881 : {
882 30 : IF( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) )
883 : {
884 5 : BREAK;
885 : }
886 25 : i++;
887 : }
888 :
889 5 : test();
890 5 : test();
891 5 : test();
892 5 : 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 5 : 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 5 : *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */
901 5 : move16();
902 :
903 : /*--------------------------------------------------------------------------------------*
904 : * Frequency encoder
905 : *--------------------------------------------------------------------------------------*/
906 :
907 5 : 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 5 : max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth,
909 5 : st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
910 :
911 5 : Q_tmp = Q_exc;
912 5 : move16();
913 5 : IF( bit == 0 )
914 : {
915 0 : set16_fx( concat_out, 0, L_FRAME16k );
916 : }
917 : ELSE
918 : {
919 5 : 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 5 : Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
922 5 : bit = sub( bit, tmp );
923 : }
924 : /* write unused bits */
925 5 : 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 5 : seed_init = 0;
933 5 : move16();
934 5 : last_bin = 0;
935 5 : move16();
936 5 : set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k );
937 :
938 45 : FOR( j = 0; j < nb_subbands; j++ )
939 : {
940 40 : Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); /*Q12*/
941 :
942 40 : last_bin = s_max( last_bin, max_ener_band[j] );
943 :
944 40 : bitallocation_band[max_ener_band[j]] = 1;
945 40 : move16();
946 :
947 40 : seed_init = add( seed_init, inpulses_fx[j] );
948 40 : move16();
949 : }
950 5 : test();
951 5 : 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 38 : seed_init = extract_l( L_shl( seed_init, 3 ) );
959 : }
960 256 : IF( concat_out[j] < 0 )
961 : {
962 32 : seed_init = add( seed_init, 3 );
963 32 : move16();
964 : }
965 : }
966 2 : hGSCEnc->seed_tcx = seed_init;
967 2 : move16();
968 : }
969 5 : test();
970 5 : 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 5 : 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 5 : highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ,
1002 5 : &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
1003 5 : hGSCEnc->last_exc_dct_in_fx, &st_fx->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type,
1004 5 : 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 5 : exc_dct_in[0] = 0;
1007 5 : move16();
1008 :
1009 5 : return;
1010 : }
1011 :
1012 :
1013 22672 : 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 22672 : hGSCEnc = st->hGSCEnc;
1058 22672 : hBstr = st->hBstr;
1059 :
1060 22672 : bit = bits_used;
1061 22672 : move16();
1062 :
1063 22672 : test();
1064 22672 : test();
1065 22672 : test();
1066 22672 : 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 7056 : bit = add( bit, GSC_LRES_NB_NITS );
1069 : }
1070 :
1071 22672 : set16_fx( exc_diffQ_fx, 0, st->L_frame );
1072 22672 : 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 22672 : v_sub_16( res_dct_in_fx, exc_dct_in_fx, exc_diff_fx, st->L_frame ); /* Q_exc */
1080 22672 : exc_diff_fx[0] = 0;
1081 22672 : 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 22672 : IF( Diff_len == 0 )
1090 : {
1091 2274 : tmp_band = 0;
1092 : }
1093 : ELSE
1094 : {
1095 20398 : tmp_band = hGSCEnc->mem_last_pit_band;
1096 : }
1097 22672 : move16();
1098 :
1099 22672 : 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 22672 : i = 0;
1106 22672 : move16();
1107 :
1108 105729 : WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
1109 : {
1110 105729 : IF( LE_32( st->core_brate, brate_intermed_tbl[i] ) )
1111 : {
1112 22672 : BREAK;
1113 : }
1114 83057 : i++;
1115 : }
1116 :
1117 22672 : test();
1118 22672 : test();
1119 22672 : test();
1120 33607 : if ( st->element_mode > EVS_MONO && EQ_16( st->coder_type, AUDIO ) &&
1121 17910 : 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 1249 : i--;
1124 : }
1125 :
1126 22672 : 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 22672 : *tmp_noise_fx = mult( mean_gain_fx, 20480 ); // 20480 => 10 in Q11
1129 22672 : move16(); // Q8
1130 :
1131 : /*--------------------------------------------------------------------------------------*
1132 : * PVQ encoder
1133 : *--------------------------------------------------------------------------------------*/
1134 :
1135 22672 : 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 22672 : set16_fx( npulses, 0, NB_SFM );
1138 :
1139 22672 : IF( bit == 0 )
1140 : {
1141 0 : set16_fx( concat_out_fx, 0, L_FRAME16k );
1142 : }
1143 : ELSE
1144 : {
1145 22672 : Word16 Q_concat = Q12;
1146 22672 : move16();
1147 22672 : 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 22672 : 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 22672 : last_bin = 0;
1160 22672 : move16();
1161 22672 : set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k );
1162 22672 : seed_init = 0;
1163 22672 : move16();
1164 :
1165 22672 : max_eq = 0;
1166 22672 : move16();
1167 :
1168 22672 : test();
1169 22672 : test();
1170 22672 : test();
1171 22672 : test();
1172 22672 : 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 12405 : j = emaximum_fx( Q12, concat_out_fx, shl( nb_subbands, 4 ), &L_tmp );
1175 12405 : IF( LE_16( add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ), ONE_IN_Q12 ) )
1176 : {
1177 7039 : max_eq = 32767; /* Q15 */
1178 7039 : move16();
1179 : }
1180 : ELSE
1181 : {
1182 5366 : max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ) ); /* Q15 */
1183 : }
1184 : }
1185 :
1186 185473 : FOR( j = 0; j < nb_subbands; j++ )
1187 : {
1188 162801 : Copy( concat_out_fx + i_mult( j, 16 ), exc_diffQ_fx + i_mult( max_ener_band[j], 16 ), 16 ); /* Q12 */
1189 :
1190 162801 : IF( GT_16( max_ener_band[j], last_bin ) )
1191 : {
1192 117960 : last_bin = max_ener_band[j];
1193 117960 : move16();
1194 : }
1195 :
1196 162801 : bitallocation_band[max_ener_band[j]] = 1;
1197 162801 : move16();
1198 :
1199 162801 : seed_init = add( seed_init, npulses[j] );
1200 : }
1201 22672 : test();
1202 22672 : 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 463573 : FOR( j = 0; j < nb_subbands * 16; j++ )
1206 : {
1207 460096 : IF( concat_out_fx[j] > 0 )
1208 : {
1209 67338 : seed_init = (Word16) L_mult0( seed_init, 8 );
1210 67338 : move16();
1211 : }
1212 460096 : IF( concat_out_fx[j] < 0 )
1213 : {
1214 67556 : seed_init = (Word16) L_add( seed_init, 3 );
1215 67556 : move16();
1216 : }
1217 : }
1218 :
1219 3477 : hGSCEnc->seed_tcx = seed_init;
1220 3477 : move16();
1221 : }
1222 :
1223 22672 : test();
1224 22672 : IF( EQ_32( st->core_brate, ACELP_8k00 ) && st->bwidth != NB )
1225 : {
1226 42 : bitallocation_exc[0] = 0;
1227 42 : move16();
1228 42 : bitallocation_exc[1] = 0;
1229 42 : move16();
1230 :
1231 42 : if ( exc_diffQ_fx[L_FRAME8k - 2] != 0 )
1232 : {
1233 1 : bitallocation_exc[0] = 1;
1234 1 : move16();
1235 : }
1236 :
1237 42 : if ( exc_diffQ_fx[L_FRAME8k - 1] != 0 )
1238 : {
1239 3 : bitallocation_exc[1] = 1;
1240 3 : 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 22672 : test();
1251 22672 : test();
1252 22672 : test();
1253 22672 : 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 22563 : ELSE IF( st->core_brate < ACELP_7k20 && st->GSC_noisy_speech == 1 && st->coder_type <= UNVOICED )
1262 : {
1263 1931355 : FOR( i = 0; i < L_FRAME; i++ )
1264 : {
1265 1923840 : exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq ); /* Q12 */
1266 1923840 : move16();
1267 : }
1268 : }
1269 : ELSE
1270 : {
1271 15048 : 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 22672 : Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in );
1275 22672 : IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) )
1276 : {
1277 22615 : 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 22615 : hGSCEnc->Q_last_exc_dct_in = Q_exc_new;
1279 22615 : move16();
1280 : }
1281 : ELSE
1282 : {
1283 57 : Scale_sig( exc_dct_in_fx, st->L_frame, sub( Q_exc_new, *Q_exc ) ); /* Q_exc_new */
1284 57 : *Q_exc = Q_exc_new;
1285 57 : move16();
1286 : }
1287 :
1288 : /*--------------------------------------------------------------------------------------*
1289 : * Estimate noise level
1290 : *--------------------------------------------------------------------------------------*/
1291 22672 : 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 22672 : 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 22672 : 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 22672 : exc_dct_in_fx[0] = 0;
1296 22672 : move16();
1297 :
1298 22672 : 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 120800 : 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 120800 : 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 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
1333 120800 : Flag Overflow = 0;
1334 120800 : move32();
1335 : #endif
1336 :
1337 120800 : ener_mean = L_shl( 1, shl( Qnew, 1 ) ); /*2*Qnew*/
1338 120800 : ener_max = L_shl( 1, shl( Qnew, 1 ) );
1339 :
1340 2053600 : FOR( j = 0; j < lvec; j++ )
1341 : {
1342 1932800 : L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/
1343 1932800 : ener_max = L_max( ener_max, L_tmp );
1344 1932800 : ener_mean = L_add_o( ener_mean, L_tmp, &Overflow );
1345 : }
1346 : /*dyn = 10.0f * (ener_max / ener_mean);*/
1347 120800 : ener_mean = Mult_32_16( ener_mean, div_s( 1, lvec ) ); /*2*Qnew*/
1348 :
1349 120800 : IF( ener_mean > 0 )
1350 : {
1351 120800 : exp1 = norm_l( ener_mean );
1352 120800 : tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow );
1353 120800 : exp1 = sub( 30, exp1 );
1354 :
1355 120800 : exp2 = norm_l( ener_max );
1356 120800 : tmp2 = extract_h( L_shl( ener_max, exp2 ) );
1357 120800 : exp2 = sub( 30, exp2 );
1358 :
1359 120800 : scale = shr( sub( tmp1, tmp2 ), 15 );
1360 120800 : tmp2 = shl( tmp2, scale );
1361 120800 : exp2 = sub( exp2, scale );
1362 :
1363 120800 : exp3 = sub( exp1, exp2 );
1364 :
1365 120800 : tmp = div_s( tmp2, tmp1 ); /*Q(15+exp3)*/
1366 :
1367 120800 : L_tmp = L_shr_r( L_mult( tmp, 10 ), exp3 );
1368 120800 : dyn = round_fx( L_shl( L_tmp, 7 ) ); /*Q7*/
1369 : }
1370 : ELSE
1371 : {
1372 0 : dyn = 1280; /* 10.0f in Q7 */
1373 0 : move16();
1374 : }
1375 120800 : return dyn; /* Q7 */
1376 : }
1377 :
1378 :
1379 : /*-------------------------------------------------------------------*
1380 : * GSC_enc_init_fx()
1381 : *
1382 : * Initialize GSC encoder state structure
1383 : *-------------------------------------------------------------------*/
1384 :
1385 3853 : void GSC_enc_init_fx(
1386 : GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */
1387 : )
1388 : {
1389 : /* AC mode */
1390 3853 : hGSCEnc->seed_tcx = 15687; /* Q0 */
1391 3853 : move16();
1392 3853 : hGSCEnc->cor_strong_limit = 1;
1393 3853 : move16();
1394 3853 : set16_fx( hGSCEnc->last_exc_dct_in_fx, 0, L_FRAME16k );
1395 3853 : hGSCEnc->Q_last_exc_dct_in = Q15;
1396 3853 : move16();
1397 3853 : set16_fx( hGSCEnc->last_bitallocation_band, 0, 6 );
1398 :
1399 3853 : hGSCEnc->mem_last_pit_band = BAND1k2 + 1;
1400 3853 : move16();
1401 3853 : hGSCEnc->Last_frame_ener_fx = MAX_32;
1402 3853 : move32();
1403 3853 : hGSCEnc->lt_gpitch_fx = 0;
1404 3853 : move16();
1405 3853 : move16();
1406 3853 : hGSCEnc->pit_exc_hangover = 0;
1407 3853 : move16();
1408 :
1409 3853 : hGSCEnc->mem_w0_tmp_fx = 0;
1410 3853 : move16();
1411 :
1412 3853 : set16_fx( hGSCEnc->mem_syn_tmp_fx, 0, M );
1413 3853 : hGSCEnc->mid_dyn_fx = 5120; /*40 -> Q7 */
1414 3853 : move16();
1415 3853 : hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
1416 3853 : move16();
1417 3853 : hGSCEnc->past_dyn_dec = 0;
1418 3853 : move16();
1419 :
1420 :
1421 3853 : return;
1422 : }
|