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" /* Compilation switches */
6 : #include "cnst.h" /* Common constants */
7 : #include "prot_fx.h" /* Function prototypes */
8 : #include "rom_com_fx.h" /* Static table prototypes */
9 : #include "rom_com.h" /* Static table prototypes */
10 : #include "prot_fx_enc.h" /* Function prototypes */
11 :
12 : /*======================================================================*/
13 : /* FUNCTION : encod_gen_voic_fx() */
14 : /*----------------------------------------------------------------------*/
15 : /* PURPOSE : encode generic (GC), voiced (VC) and AMR-WB IO frames */
16 : /* */
17 : /*----------------------------------------------------------------------*/
18 : /* INPUT ARGUMENTS : */
19 : /* _ (Struct) st_fx : encoder static memory */
20 : /* _ (Word16) L_frame_fx : length of the frame Q0 */
21 :
22 : /* _ (Word16[]) speech_fx : input speech Q0 */
23 : /* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */
24 : /* _ (Word16[]) A_fx : unquantized A(z) filter */
25 : /* with bandwidth expansion Q12 */
26 : /* _ (Word16) coder_type : coding type */
27 : /* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */
28 : /* _ (Word16[]) T_op_fx : open loop pitch Q0 */
29 : /* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/
30 : /* _ (Word16[]) res_fx : residual signal Q_new */
31 : /* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */
32 : /* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */
33 : /* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/
34 : /* _ (Word16) shift : shift */
35 : /* _ (Word16) Q_new : */
36 : /*-----------------------------------------------------------------------*/
37 : /* OUTPUT ARGUMENTS : */
38 : /* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */
39 : /* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */
40 : /* _ (Word16[]) syn_fx :core synthesis Q_new */
41 : /* _ (Word16[]) voice_factors_fx: voicing factors Q15 */
42 : /* _ (Word16[]) bwe_exc_fx : excitation for SWB TBE Q0 */
43 : /*-----------------------------------------------------------------------*/
44 :
45 :
46 : /*-----------------------------------------------------------------------*/
47 : /* RETURN ARGUMENTS : */
48 : /* _ None */
49 : /*=======================================================================*/
50 :
51 1295 : void encod_gen_voic_fx(
52 : Encoder_State *st_fx, /* i/o: state structure */
53 : const Word16 speech_fx[], /* i : input speech Q0*/
54 : const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
55 : const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
56 : const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
57 : const Word16 *res_fx, /* i : residual signal Q_new*/
58 : Word16 *syn_fx, /* i/o: core synthesis Q_new*/
59 : Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
60 : Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
61 : Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
62 : Word16 *voice_factors_fx, /* o : voicing factors Q15*/
63 : Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
64 : Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
65 : const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
66 : const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
67 : Word16 shift,
68 : Word16 Q_new )
69 : {
70 : Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
71 : Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */
72 : Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */
73 : Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
74 : Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
75 : Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */
76 1295 : Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
77 : Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
78 1295 : Word16 gain_pit_fx = 0; /* Pitch gain */
79 1295 : move16();
80 : Word16 voice_fac_fx; /* Voicing factor */
81 1295 : Word32 gain_code_fx = 0; /* Gain of code */
82 1295 : move32();
83 1295 : Word16 gain_inov_fx = 0; /* inovation gain */
84 1295 : move16();
85 : Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
86 : Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
87 : Word16 i, i_subfr_fx; /* tmp variables */
88 1295 : Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
89 1295 : move16();
90 1295 : move16();
91 : Word16 T0_min_fx, T0_max_fx; /* pitch variables */
92 : Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
93 : Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
94 : Word16 clip_gain_fx; /* LSF clip gain */
95 : const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
96 1295 : Word16 error_fx = 0;
97 1295 : Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
98 1295 : move16();
99 1295 : move16();
100 : Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
101 1295 : Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
102 1295 : Word32 norm_gain_code_fx = 0;
103 1295 : move16();
104 1295 : move32();
105 : Word16 pitch_limit_flag;
106 : Word16 gcode16;
107 : Word32 Ltmp;
108 : Word32 Ltmp1;
109 : Word32 Lgcode;
110 : Word16 tmp1_fx;
111 : Word16 shift_wsp;
112 : Word16 harm_flag_acelp;
113 : Word16 lp_select, lp_flag, L_frame;
114 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
115 1295 : Flag Overflow = 0;
116 1295 : move32();
117 : #endif
118 1295 : SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
119 1295 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
120 1295 : SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
121 1295 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
122 :
123 : /*------------------------------------------------------------------*
124 : * Initializations
125 : *------------------------------------------------------------------*/
126 :
127 1295 : gain_pit_fx = 0;
128 1295 : move16();
129 1295 : gain_code_fx = L_deposit_l( 0 );
130 1295 : gain_preQ_fx = 0;
131 1295 : move16();
132 1295 : unbits_PI_fx = 0;
133 1295 : move16();
134 1295 : error_fx = 0;
135 1295 : move16();
136 1295 : L_frame = st_fx->L_frame;
137 1295 : move16();
138 :
139 :
140 1295 : IF( EQ_16( L_frame, L_FRAME ) )
141 : {
142 671 : T0_max_fx = PIT_MAX;
143 671 : move16();
144 671 : T0_min_fx = PIT_MIN;
145 671 : move16();
146 : }
147 : ELSE /* L_frame == L_FRAME16k */
148 : {
149 624 : T0_max_fx = PIT16k_MAX;
150 624 : move16();
151 624 : T0_min_fx = PIT16k_MIN;
152 624 : move16();
153 : }
154 1295 : lp_flag = st_fx->acelp_cfg.ltf_mode;
155 1295 : move16();
156 :
157 1295 : *unbits_fx = 0;
158 1295 : move16();
159 :
160 1295 : p_Aw_fx = Aw_fx; /* Q12 */
161 1295 : p_Aq_fx = Aq_fx; /* Q12 */
162 1295 : pt_pitch_fx = pitch_buf_fx; /* Q6 */
163 1295 : gain_preQ_fx = 0;
164 1295 : move16();
165 1295 : set16_fx( code_preQ_fx, 0, L_SUBFR );
166 :
167 1295 : shift_wsp = add( Q_new, shift );
168 :
169 : /* set and write harmonicity flag */
170 1295 : harm_flag_acelp = 0;
171 1295 : move16();
172 1295 : test();
173 1295 : test();
174 1295 : IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) )
175 : {
176 0 : if ( GT_16( st_fx->last_harm_flag_acelp, 2 ) )
177 : {
178 0 : harm_flag_acelp = 1;
179 0 : move16();
180 : }
181 :
182 0 : push_indice( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 );
183 : }
184 :
185 : /*------------------------------------------------------------------*
186 : * ACELP subframe loop
187 : *------------------------------------------------------------------*/
188 :
189 7099 : FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
190 : {
191 :
192 : /*----------------------------------------------------------------*
193 : * Find the the excitation search target "xn" and innovation
194 : * target in residual domain "cn"
195 : * Compute impulse response, h1[], of weighted synthesis filter
196 : *----------------------------------------------------------------*/
197 :
198 5804 : Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
199 :
200 5804 : find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
201 5804 : res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
202 :
203 5804 : Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
204 5804 : Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/
205 :
206 : /* scaling of xn[] to limit dynamic at 12 bits */
207 5804 : Scale_sig( xn_fx, L_SUBFR, shift );
208 :
209 11608 : *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
210 5804 : L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
211 :
212 5804 : tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
213 :
214 : /*-----------------------------------------------------------------*
215 : * Find adaptive exitation
216 : *-----------------------------------------------------------------*/
217 :
218 5804 : pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
219 :
220 : /*-----------------------------------------------------------------*
221 : * Gain clipping test to avoid unstable synthesis on frame erasure
222 : *-----------------------------------------------------------------*/
223 :
224 5804 : clip_gain_fx = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr_fx, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
225 :
226 5804 : if ( EQ_16( st_fx->coder_type, INACTIVE ) )
227 : {
228 : /* in case of AVQ inactive, limit the gain to 0.65 */
229 0 : clip_gain_fx = 2;
230 0 : move16();
231 : }
232 :
233 : /*-----------------------------------------------------------------*
234 : * LP filtering of the adaptive excitation, codebook target computation
235 : *-----------------------------------------------------------------*/
236 :
237 5804 : lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
238 : xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
239 :
240 5804 : IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
241 : {
242 5804 : push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
243 : }
244 :
245 : /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
246 5804 : hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/
247 :
248 : /*-----------------------------------------------------------------*
249 : * Transform domain contribution encoding - active frames
250 : *-----------------------------------------------------------------*/
251 :
252 5804 : test();
253 5804 : IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) )
254 : {
255 3120 : transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
256 : xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
257 : }
258 :
259 : /*-----------------------------------------------------------------*
260 : * Innovation encoding
261 : *-----------------------------------------------------------------*/
262 :
263 5804 : inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame,
264 5804 : st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx,
265 5804 : gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift );
266 :
267 : /*-----------------------------------------------------------------*
268 : * Gain encoding
269 : *-----------------------------------------------------------------*/
270 :
271 5804 : IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
272 : {
273 0 : gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx,
274 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
275 : }
276 5804 : ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
277 : {
278 3120 : gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
279 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp );
280 : }
281 : ELSE
282 : {
283 2684 : gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx,
284 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
285 : }
286 5804 : IF( st_fx->Opt_SC_VBR )
287 : {
288 0 : if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
289 : {
290 : /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
291 0 : st_fx->clip_var_fx[1] = gain_pit_fx; /*Q14*/
292 0 : move16();
293 : }
294 : }
295 5804 : gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );
296 :
297 5804 : Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
298 5804 : gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/
299 :
300 5804 : hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
301 5804 : move16();
302 :
303 : /*-----------------------------------------------------------------*
304 : * Transform domain contribution encoding - inactive frames
305 : *-----------------------------------------------------------------*/
306 :
307 5804 : test();
308 5804 : IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) )
309 : {
310 0 : transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
311 : Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
312 : }
313 :
314 : /*-----------------------------------------------------------------*
315 : * Update memory of the weighting filter
316 : *-----------------------------------------------------------------*/
317 :
318 : /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
319 5804 : Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/
320 5804 : Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/
321 5804 : Ltmp = L_negate( Ltmp );
322 5804 : Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */
323 5804 : Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */
324 5804 : Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */
325 5804 : hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
326 5804 : move16();
327 5804 : IF( gain_preQ_fx != 0 )
328 : {
329 3120 : tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new );
330 :
331 202800 : FOR( i = 0; i < L_SUBFR; i++ )
332 : {
333 : /* Contribution from AVQ layer */
334 199680 : Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/
335 199680 : Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */
336 :
337 : /* Compute exc2 */
338 199680 : Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */
339 199680 : exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
340 199680 : move16();
341 :
342 : /* code in Q9, gain_pit in Q14 */
343 199680 : Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
344 199680 : Ltmp = L_shl( Ltmp, 5 ); /* Q15 */
345 199680 : Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */
346 199680 : Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
347 199680 : exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
348 : }
349 : }
350 : ELSE
351 : {
352 : /*-----------------------------------------------------------------*
353 : * Construct adaptive part of the excitation
354 : * Save the non-enhanced excitation for FEC_exc
355 : *-----------------------------------------------------------------*/
356 174460 : FOR( i = 0; i < L_SUBFR; i++ )
357 : {
358 : /* code in Q9, gain_pit in Q14 */
359 171776 : Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
360 171776 : Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */
361 171776 : Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */
362 171776 : Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/
363 171776 : exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
364 : }
365 : }
366 : /*-----------------------------------------------------------------*
367 : * Prepare TBE excitation
368 : *-----------------------------------------------------------------*/
369 :
370 : #ifdef REMOVE_EVS_DUPLICATES
371 5804 : prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
372 5804 : &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
373 5804 : T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
374 5804 : st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
375 : #else
376 : prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
377 : &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
378 : T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate );
379 : #endif
380 :
381 : /*-----------------------------------------------------------------*
382 : * Synthesize speech to update mem_syn[].
383 : * Update A(z) filters
384 : *-----------------------------------------------------------------*/
385 :
386 5804 : Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
387 :
388 5804 : p_Aw_fx += ( M + 1 );
389 5804 : p_Aq_fx += ( M + 1 );
390 5804 : pt_pitch_fx++;
391 : }
392 :
393 : /* write reserved bits */
394 1295 : WHILE( unbits_PI_fx > 0 )
395 : {
396 0 : i = s_min( unbits_PI_fx, 16 );
397 0 : push_indice( hBstr, IND_UNUSED, 0, i );
398 0 : unbits_PI_fx -= i;
399 : }
400 1295 : IF( st_fx->Opt_SC_VBR )
401 : {
402 : /* SC-VBR */
403 0 : hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
404 0 : move16();
405 0 : hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
406 0 : move16();
407 : }
408 1295 : return;
409 : }
410 :
411 117159 : void encod_gen_voic_ivas_fx(
412 : Encoder_State *st_fx, /* i/o: state structure */
413 : const Word16 speech_fx[], /* i : input speech Qnew -1 */
414 : const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
415 : const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
416 : const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
417 : const Word16 *res_fx, /* i : residual signal Q_new*/
418 : Word16 *syn_fx, /* i/o: core synthesis Q_new - 1*/
419 : Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
420 : Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
421 : Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
422 : Word16 *voice_factors_fx, /* o : voicing factors Q15*/
423 : Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
424 : Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
425 : const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
426 : const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
427 : Word16 shift,
428 : Word16 Q_new )
429 : {
430 : Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
431 : Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */
432 : Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */
433 : Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
434 : Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
435 : Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */
436 117159 : Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
437 : Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
438 117159 : Word16 gain_pit_fx = 0; /* Pitch gain */
439 117159 : move16();
440 : Word16 voice_fac_fx; /* Voicing factor */
441 117159 : Word32 gain_code_fx = 0; /* Gain of code */
442 117159 : Word16 gain_inov_fx = 0; /* inovation gain */
443 117159 : move32();
444 117159 : move16();
445 : Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
446 : Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
447 : Word16 i, i_subfr_fx; /* tmp variables */
448 117159 : Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
449 117159 : move16();
450 117159 : move16();
451 : Word16 T0_min_fx, T0_max_fx; /* pitch variables */
452 : Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
453 : Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
454 : Word16 clip_gain_fx; /* LSF clip gain */
455 : const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
456 117159 : Word16 error_fx = 0;
457 117159 : Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
458 117159 : move16();
459 117159 : move16();
460 : Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
461 117159 : Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
462 117159 : Word32 norm_gain_code_fx = 0;
463 117159 : move16();
464 117159 : move32();
465 : Word16 pitch_limit_flag;
466 : Word16 gcode16;
467 : Word32 Ltmp;
468 : Word32 Ltmp1;
469 : Word32 Lgcode;
470 : Word16 tmp1_fx;
471 : Word16 shift_wsp;
472 : Word16 harm_flag_acelp;
473 : Word16 lp_select, lp_flag, L_frame;
474 : Word16 q_h1;
475 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
476 117159 : Flag Overflow = 0;
477 117159 : move32();
478 : #endif
479 117159 : SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
480 117159 : BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
481 117159 : LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
482 :
483 : /*------------------------------------------------------------------*
484 : * Initializations
485 : *------------------------------------------------------------------*/
486 :
487 117159 : gain_pit_fx = 0;
488 117159 : move16();
489 117159 : gain_code_fx = L_deposit_l( 0 );
490 117159 : gain_preQ_fx = 0;
491 117159 : move16();
492 117159 : unbits_PI_fx = 0;
493 117159 : move16();
494 117159 : error_fx = 0;
495 117159 : move16();
496 117159 : L_frame = st_fx->L_frame;
497 117159 : move16();
498 :
499 :
500 117159 : IF( EQ_16( L_frame, L_FRAME ) )
501 : {
502 53320 : T0_max_fx = PIT_MAX;
503 53320 : move16();
504 53320 : T0_min_fx = PIT_MIN;
505 53320 : move16();
506 : }
507 : ELSE /* L_frame == L_FRAME16k */
508 : {
509 63839 : T0_max_fx = PIT16k_MAX;
510 63839 : move16();
511 63839 : T0_min_fx = PIT16k_MIN;
512 63839 : move16();
513 : }
514 117159 : lp_flag = st_fx->acelp_cfg.ltf_mode;
515 117159 : move16();
516 :
517 117159 : *unbits_fx = 0;
518 117159 : move16();
519 :
520 117159 : p_Aw_fx = Aw_fx; /*Q12*/
521 117159 : p_Aq_fx = Aq_fx; /*Q12*/
522 117159 : pt_pitch_fx = pitch_buf_fx; /*Q6*/
523 117159 : gain_preQ_fx = 0;
524 117159 : move16();
525 117159 : set16_fx( code_preQ_fx, 0, L_SUBFR );
526 :
527 117159 : shift_wsp = add( Q_new, shift );
528 : #ifdef TEST_HR
529 117159 : if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
530 : {
531 104602 : shift_wsp = sub( shift_wsp, 1 );
532 : }
533 : #endif
534 : /* set and write harmonicity flag */
535 117159 : harm_flag_acelp = 0;
536 117159 : move16();
537 117159 : test();
538 117159 : test();
539 117159 : IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) )
540 : {
541 8031 : if ( GT_16( st_fx->last_harm_flag_acelp, 2 ) )
542 : {
543 712 : harm_flag_acelp = 1;
544 712 : move16();
545 : }
546 :
547 8031 : push_indice( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 );
548 : }
549 :
550 : /*------------------------------------------------------------------*
551 : * ACELP subframe loop
552 : *------------------------------------------------------------------*/
553 :
554 649634 : FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
555 : {
556 :
557 : /*----------------------------------------------------------------*
558 : * Find the the excitation search target "xn" and innovation
559 : * target in residual domain "cn"
560 : * Compute impulse response, h1[], of weighted synthesis filter
561 : *----------------------------------------------------------------*/
562 :
563 532475 : Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
564 :
565 532475 : find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
566 532475 : res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
567 :
568 532475 : q_h1 = sub( 14, norm_s( h1_fx[0] ) );
569 532475 : Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
570 532475 : Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
571 : /* scaling of xn[] to limit dynamic at 12 bits */
572 532475 : Scale_sig( xn_fx, L_SUBFR, shift );
573 :
574 1064950 : *pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
575 532475 : L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */
576 532475 : move16();
577 :
578 532475 : tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
579 :
580 : /*-----------------------------------------------------------------*
581 : * Find adaptive exitation
582 : *-----------------------------------------------------------------*/
583 :
584 532475 : pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
585 :
586 : /*-----------------------------------------------------------------*
587 : * Gain clipping test to avoid unstable synthesis on frame erasure
588 : *-----------------------------------------------------------------*/
589 :
590 532475 : clip_gain_fx = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr_fx, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
591 :
592 532475 : if ( EQ_16( st_fx->coder_type, INACTIVE ) )
593 : {
594 : /* in case of AVQ inactive, limit the gain to 0.65 */
595 13015 : clip_gain_fx = 2;
596 13015 : move16();
597 : }
598 :
599 : /*-----------------------------------------------------------------*
600 : * LP filtering of the adaptive excitation, codebook target computation
601 : *-----------------------------------------------------------------*/
602 :
603 532475 : lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
604 : xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
605 :
606 532475 : IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
607 : {
608 464191 : push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
609 : }
610 :
611 : /*-----------------------------------------------------------------*
612 : * Transform domain contribution encoding - active frames
613 : *-----------------------------------------------------------------*/
614 :
615 532475 : test();
616 532475 : IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) )
617 : {
618 51435 : transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
619 : xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
620 : }
621 :
622 : /*-----------------------------------------------------------------*
623 : * Innovation encoding
624 : *-----------------------------------------------------------------*/
625 :
626 532475 : inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame,
627 532475 : st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx,
628 532475 : gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new );
629 :
630 : /*-----------------------------------------------------------------*
631 : * Gain encoding
632 : *-----------------------------------------------------------------*/
633 :
634 532475 : IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
635 : {
636 : #ifdef TEST_HR
637 13496 : gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx,
638 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
639 : #else
640 : gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx,
641 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
642 : #endif
643 : }
644 518979 : ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
645 : {
646 : #ifdef TEST_HR
647 40510 : gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
648 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp );
649 : #else
650 : gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
651 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) );
652 : #endif
653 : }
654 : ELSE
655 : {
656 : #ifdef TEST_HR
657 478469 : gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx,
658 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
659 : #else
660 : gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx,
661 : &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
662 : #endif
663 : }
664 532475 : IF( st_fx->Opt_SC_VBR )
665 : {
666 0 : if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
667 : {
668 : /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
669 0 : st_fx->clip_var_fx[1] = gain_pit_fx; /* Q14 */
670 0 : move16();
671 : }
672 : }
673 532475 : gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );
674 :
675 532475 : Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
676 532475 : gcode16 = round_fx_o( Lgcode, &Overflow );
677 :
678 532475 : hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */
679 532475 : move16();
680 :
681 : /*-----------------------------------------------------------------*
682 : * Transform domain contribution encoding - inactive frames
683 : *-----------------------------------------------------------------*/
684 :
685 532475 : test();
686 532475 : IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) )
687 : {
688 13015 : transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
689 : Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
690 : }
691 :
692 : /*-----------------------------------------------------------------*
693 : * Update memory of the weighting filter
694 : *-----------------------------------------------------------------*/
695 :
696 :
697 : /*At this point
698 : xn has to be in Qnew
699 : yn has to be in Qnew
700 : y2_fx has to be in Q9
701 : gcode16 in Q_new
702 : gain_pit_fx in Q14
703 : */
704 532475 : Scale_sig( xn_fx, L_SUBFR, 1 );
705 532475 : Scale_sig( y1_fx, L_SUBFR, 1 );
706 : /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
707 532475 : Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] );
708 532475 : Ltmp = L_shl( Ltmp, add( 5, shift ) );
709 532475 : Ltmp = L_negate( Ltmp );
710 532475 : Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 );
711 532475 : Ltmp = L_add( Ltmp, Ltmp2 );
712 532475 : Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx );
713 532475 : Ltmp = L_sub( Ltmp, Ltmp3 );
714 :
715 : /*Ltmp is in Q14 + Qnew here
716 : We need memWo in Qnew -1 */
717 :
718 532475 : Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1
719 532475 : hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
720 532475 : move16();
721 532475 : IF( gain_preQ_fx != 0 )
722 : {
723 64436 : tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new );
724 :
725 4188340 : FOR( i = 0; i < L_SUBFR; i++ )
726 : {
727 : /* Contribution from AVQ layer */
728 4123904 : Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow );
729 4123904 : Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow );
730 :
731 : /* Compute exc2 */
732 4123904 : Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
733 4123904 : exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
734 4123904 : move16();
735 :
736 : /* code in Q9, gain_pit in Q14 */
737 4123904 : Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */
738 4123904 : Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */
739 4123904 : Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/
740 4123904 : Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/
741 4123904 : exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
742 4123904 : move16();
743 : }
744 : }
745 : ELSE
746 : {
747 : /*-----------------------------------------------------------------*
748 : * Construct adaptive part of the excitation
749 : * Save the non-enhanced excitation for FEC_exc
750 : *-----------------------------------------------------------------*/
751 30422535 : FOR( i = 0; i < L_SUBFR; i++ )
752 : {
753 : /* code in Q9, gain_pit in Q14 */
754 : /*gcode16 in Qnew*/
755 29954496 : Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */
756 29954496 : Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */
757 29954496 : Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/
758 29954496 : Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */
759 29954496 : exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
760 : }
761 : }
762 : /*-----------------------------------------------------------------*
763 : * Prepare TBE excitation
764 : *-----------------------------------------------------------------*/
765 :
766 532475 : prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
767 532475 : &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
768 532475 : T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
769 532475 : st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
770 :
771 : /*-----------------------------------------------------------------*
772 : * Synthesize speech to update mem_syn[].
773 : * Update A(z) filters
774 : *-----------------------------------------------------------------*/
775 :
776 532475 : syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
777 :
778 532475 : p_Aw_fx += ( M + 1 );
779 532475 : p_Aq_fx += ( M + 1 );
780 532475 : pt_pitch_fx++;
781 : }
782 :
783 : /* write reserved bits */
784 117159 : WHILE( unbits_PI_fx > 0 )
785 : {
786 0 : i = s_min( unbits_PI_fx, 16 );
787 0 : push_indice( hBstr, IND_UNUSED, 0, i );
788 0 : unbits_PI_fx -= i;
789 : }
790 117159 : IF( st_fx->Opt_SC_VBR )
791 : {
792 : /* SC-VBR */
793 0 : hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx;
794 0 : move16();
795 0 : hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
796 0 : move16();
797 : }
798 117159 : return;
799 : }
|