Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <assert.h>
38 : #include <stdint.h>
39 : #include "options.h"
40 : #ifdef DEBUGGING
41 : #include "debug.h"
42 : #endif
43 : #include <math.h>
44 : #include "prot.h"
45 : #include "rom_com.h"
46 : #include "wmc_auto.h"
47 : #ifdef DEBUG_PLOT
48 : #include "deb_out.h"
49 : #endif
50 :
51 :
52 : /*-------------------------------------------------------------------*
53 : * core_signal_analysis_high_bitrate()
54 : *
55 : *
56 : *-------------------------------------------------------------------*/
57 :
58 882281 : void core_signal_analysis_high_bitrate(
59 : const float *new_samples,
60 : const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */
61 : float lsp_new[],
62 : float lsp_mid[],
63 : Encoder_State *st,
64 : float *mdst_spectrum[2],
65 : int16_t pTnsSize[],
66 : int16_t pTnsBits[],
67 : int16_t param_core[],
68 : int16_t *ltpBits,
69 : float *windowed_samples, /* i/o: backup of windowed time signal */
70 : const int16_t L_frame,
71 : const int16_t L_frameTCX,
72 : const int16_t last_element_mode,
73 : const int16_t vad_hover_flag /* i : VAD hangover flag */
74 : )
75 : {
76 882281 : TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
77 :
78 882281 : const int16_t last_overlap = st->hTcxCfg->tcx_last_overlap_mode;
79 882281 : const int16_t curr_overlap = st->hTcxCfg->tcx_curr_overlap_mode;
80 882281 : const int16_t minWindowLen = st->hTcxCfg->tcx_mdct_window_min_lengthFB - 1;
81 : int16_t i, frameno;
82 : int16_t L_subframe;
83 882281 : int16_t left_overlap = -1, right_overlap = -1, folding_offset;
84 : float buf[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for TCX20/TCX10 windowing */
85 : float mdstWin[N_MAX + L_MDCT_OVLP_MAX]; /* Buffer for MDST windowing */
86 : float *powerSpec;
87 : float *tcx20Win;
88 : float tcx5Win[N_TCX10_MAX / 2 + L_MDCT_OVLP_MAX]; /* Buffer for TCX5 windowing and interleaving. */
89 882281 : float *interleaveBuf = tcx5Win;
90 : int16_t nSubframes;
91 : int16_t overlap_mode[3];
92 882281 : int16_t *transform_type = hTcxEnc->transform_type;
93 : float r[M + 1];
94 : float A[M + 1];
95 : float *lsp[2];
96 882281 : const int16_t tcx10SizeFB = 2 * st->hTcxCfg->tcx5SizeFB;
97 882281 : const int16_t tcx5SizeFB = st->hTcxCfg->tcx5SizeFB;
98 882281 : const int16_t tcx10Size = 2 * st->hTcxCfg->tcx5Size;
99 882281 : int16_t alw_pitch_lag_12k8[2], alw_pitch_lag_12k8_wc = -1;
100 882281 : float alw_voicing[2], alw_voicing_wc = -1;
101 882281 : int16_t disable_ltp = 0;
102 :
103 882281 : if ( last_element_mode != st->element_mode )
104 : {
105 1780 : disable_ltp = 1; /* disable TCX-LTP in stereo switching to avoid discontinuities in synthesis */
106 : }
107 :
108 882281 : powerSpec = tcx20Win = buf; /* Share memory for windowed TD signal and for the power spectrum */
109 :
110 : /*--------------------------------------------------------------*
111 : * Input Signal Processing: copy, HP filter, pre-emphasis
112 : *---------------------------------------------------------------*/
113 :
114 882281 : if ( st->tcxonly && st->element_mode != IVAS_CPE_MDCT )
115 : {
116 : /* Copy Samples */
117 106898 : mvr2r( new_samples, st->new_speech_enc, L_frame );
118 : }
119 :
120 : /*--------------------------------------------------------------*
121 : * TCX-LTP
122 : *---------------------------------------------------------------*/
123 :
124 882281 : if ( st->element_mode == IVAS_CPE_DFT )
125 : {
126 14309 : tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->wspeech_enc, NULL, st->wspeech_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
127 : }
128 867972 : else if ( st->element_mode != IVAS_CPE_MDCT )
129 : {
130 220903 : tcx_ltp_encode( st, hTcxEnc->tcxMode, L_frame, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->speech_enc + st->encoderLookahead_enc, T_op, ¶m_core[1 + NOISE_FILL_RANGES], ltpBits, NULL, disable_ltp, st->element_mode );
131 : }
132 :
133 882281 : if ( st->tcxonly && st->element_mode != IVAS_CPE_MDCT )
134 : {
135 106898 : mvr2r( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame );
136 :
137 106898 : preemph( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) );
138 : }
139 :
140 882281 : if ( hTcxEnc->tcxMode == TCX_10 )
141 : {
142 16888 : mvs2s( ¶m_core[1 + NOISE_FILL_RANGES], ¶m_core[NPRM_DIV + 1 + NOISE_FILL_RANGES], LTPSIZE );
143 : }
144 :
145 882281 : if ( st->element_mode != IVAS_CPE_MDCT )
146 : {
147 235212 : lsp[0] = lsp_new;
148 235212 : lsp[1] = lsp_mid;
149 : }
150 :
151 : /*-------------------------------------------------------------------------*
152 : * Decision matrix for the transform and overlap length
153 : *--------------------------------------------------------------------------*/
154 :
155 882281 : if ( st->element_mode != IVAS_CPE_MDCT )
156 : {
157 235212 : alw_pitch_lag_12k8[0] = st->pitch[0];
158 235212 : alw_pitch_lag_12k8[1] = st->pitch[1];
159 235212 : alw_voicing[0] = st->voicing[0];
160 235212 : alw_voicing[1] = st->voicing[1];
161 235212 : alw_pitch_lag_12k8_wc = min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] );
162 235212 : alw_voicing_wc = max( alw_voicing[0], alw_voicing[1] );
163 : }
164 :
165 882281 : overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame */
166 :
167 882281 : if ( hTcxEnc->tcxMode == TCX_20 )
168 : {
169 865393 : nSubframes = 1;
170 865393 : transform_type[0] = TCX_20;
171 865393 : transform_type[1] = TCX_20;
172 865393 : overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame */
173 :
174 865393 : if ( st->element_mode != IVAS_CPE_MDCT )
175 : {
176 233135 : alw_pitch_lag_12k8[0] = alw_pitch_lag_12k8_wc;
177 233135 : alw_voicing[0] = alw_voicing_wc;
178 : }
179 : }
180 : else
181 : {
182 16888 : nSubframes = 2;
183 16888 : if ( curr_overlap == FULL_OVERLAP )
184 : {
185 11063 : transform_type[0] = TCX_5;
186 11063 : transform_type[1] = TCX_10;
187 11063 : overlap_mode[1] = ( last_overlap == HALF_OVERLAP ) ? HALF_OVERLAP : MIN_OVERLAP; /* Overlap between 2nd and 3rd sub-frame */
188 : }
189 5825 : else if ( last_overlap == FULL_OVERLAP )
190 : {
191 5177 : transform_type[0] = TCX_10;
192 5177 : transform_type[1] = TCX_5;
193 5177 : overlap_mode[1] = ( curr_overlap == HALF_OVERLAP ) ? HALF_OVERLAP : MIN_OVERLAP; /* Overlap between 1st and 2nd sub-frame */
194 : }
195 : else
196 : {
197 648 : transform_type[0] = transform_type[1] = TCX_5;
198 648 : overlap_mode[1] = ( last_overlap == HALF_OVERLAP && curr_overlap == HALF_OVERLAP ) ? HALF_OVERLAP : MIN_OVERLAP; /* Overlap between 2nd and 3rd sub-frame */
199 : }
200 16888 : overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame */
201 : }
202 :
203 882281 : if ( st->igf && transform_type[0] != TCX_20 )
204 : {
205 11807 : IGFEncResetTCX10BitCounter( st->hIGFEnc );
206 : }
207 :
208 1781450 : for ( frameno = 0; frameno < nSubframes; frameno++ )
209 : {
210 : /*-------------------------------------------------------------------------*
211 : * Get MDCT output and TNS parameters. Apply TNS in the spectrum if needed
212 : *--------------------------------------------------------------------------*/
213 :
214 899169 : L_subframe = L_frameTCX / nSubframes;
215 :
216 899169 : if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP )
217 : {
218 856052 : wtda( hTcxEnc->new_speech_TCX, tcx20Win, NULL, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX );
219 :
220 856052 : if ( windowed_samples != NULL ) /* store overlap data for later */
221 : {
222 630867 : assert( frameno == 0 );
223 630867 : windowed_samples[0] = (float) overlap_mode[frameno];
224 630867 : windowed_samples[1] = (float) overlap_mode[frameno + 1];
225 : }
226 856052 : if ( st->element_mode != IVAS_CPE_MDCT )
227 : {
228 : /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */
229 225185 : WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 1, 1 );
230 : }
231 : }
232 : else
233 : {
234 : /* Windowing of the 2xTCX5 subframes or 1xTCX10 or 1xTCX20 */
235 43117 : WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno], overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, tcx20Win, st->element_mode != IVAS_CPE_MDCT, 1 );
236 :
237 43117 : if ( windowed_samples != NULL ) /* save windowed speech_TCX samples */
238 : {
239 31013 : assert( L_subframe + ( left_overlap + right_overlap ) / 2 < 2 * L_FRAME_MAX / nSubframes - L_FRAME_MAX / 8 );
240 31013 : windowed_samples[frameno * L_FRAME_MAX + 0] = (float) overlap_mode[frameno];
241 31013 : windowed_samples[frameno * L_FRAME_MAX + 1] = (float) overlap_mode[frameno + 1];
242 31013 : mvr2r( tcx20Win, windowed_samples + frameno * L_FRAME_MAX + 2, L_subframe + ( left_overlap + right_overlap ) / 2 );
243 : }
244 : }
245 :
246 899169 : if ( transform_type[frameno] == TCX_5 )
247 : {
248 : /* Outer left folding */
249 2094646 : for ( i = 0; i < left_overlap / 2; i++ )
250 : {
251 2077110 : tcx20Win[left_overlap / 2 + i] -= tcx20Win[left_overlap / 2 - 1 - i];
252 : }
253 :
254 17536 : if ( st->element_mode == IVAS_CPE_MDCT && frameno == 0 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
255 : {
256 414766 : for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
257 : {
258 407440 : tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
259 : }
260 : }
261 :
262 : /* Outer right folding */
263 752246 : for ( i = 0; i < right_overlap / 2; i++ )
264 : {
265 734710 : tcx20Win[L_subframe + left_overlap / 2 - 1 - i] += tcx20Win[L_subframe + left_overlap / 2 + i];
266 : }
267 :
268 : /* 2xTCX5 */
269 17536 : L_subframe = tcx5SizeFB;
270 17536 : folding_offset = left_overlap / 2;
271 :
272 52608 : for ( i = 0; i < 2; i++ )
273 : {
274 35072 : WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, tcx20Win + i * tcx5SizeFB, &L_subframe, tcx5Win, st->element_mode != IVAS_CPE_MDCT, 1 );
275 :
276 35072 : TCX_MDCT( tcx5Win, hTcxEnc->spectrum[frameno] + i * tcx5SizeFB, left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
277 :
278 : /* high-band gain control in case of BWS */
279 35072 : if ( st->bwidth_sw_cnt > 0 )
280 : {
281 88 : v_multc( hTcxEnc->spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, hTcxEnc->spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), L_subframe - L_FRAME16k / ( 2 * nSubframes ) );
282 : }
283 : }
284 : }
285 : else /* transform_type[frameno] != TCX_5 */
286 : {
287 881633 : assert( transform_type[frameno] == TCX_10 || transform_type[frameno] == TCX_20 );
288 :
289 881633 : if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP )
290 : {
291 856052 : edct( tcx20Win, hTcxEnc->spectrum[frameno], L_subframe, st->element_mode );
292 :
293 856052 : v_multc( hTcxEnc->spectrum[frameno], (float) sqrt( (float) NORM_MDCT_FACTOR / L_subframe ), hTcxEnc->spectrum[frameno], L_subframe );
294 : }
295 : else
296 : {
297 : /* TCX20/TCX10 */
298 25581 : if ( st->element_mode == IVAS_CPE_MDCT && frameno == 0 && transform_type[0] == TCX_10 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
299 : {
300 219448 : for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
301 : {
302 215160 : tcx20Win[left_overlap + i] -= hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
303 : }
304 : }
305 :
306 25581 : TCX_MDCT( tcx20Win, hTcxEnc->spectrum[frameno], left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
307 : }
308 :
309 : /* high-band gain control in case of BWS */
310 881633 : if ( st->bwidth_sw_cnt > 0 )
311 : {
312 2921 : v_multc( hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, hTcxEnc->spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes );
313 : }
314 :
315 881633 : if ( st->element_mode != IVAS_CPE_MDCT )
316 : {
317 : /* For TCX20 at bitrates up to 64 kbps we need the power spectrum */
318 235058 : if ( hTcxEnc->tcxMode == TCX_20 && ( st->total_brate < HQ_96k || st->igf ) )
319 : {
320 : /* Compute noise-measure flags for spectrum filling and quantization */
321 231971 : AnalyzePowerSpectrum( st, L_subframe * st->L_frame / hTcxEnc->L_frameTCX, L_subframe, left_overlap, right_overlap, hTcxEnc->spectrum[frameno], ( ( hTcxEnc->tcxMode == TCX_20 ) && ( st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP ) ) ? mdstWin : tcx20Win, powerSpec );
322 : }
323 : }
324 : }
325 :
326 899169 : if ( st->element_mode == IVAS_CPE_MDCT )
327 : {
328 661880 : L_subframe = L_frameTCX / nSubframes;
329 :
330 661880 : if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP )
331 : {
332 630867 : wtda_ext( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 );
333 : }
334 : else
335 : {
336 : /* Windowing for the MDST */
337 31013 : WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 );
338 : }
339 :
340 661880 : if ( transform_type[frameno] == TCX_5 )
341 : {
342 : /* Outer left folding */
343 1870905 : for ( i = 0; i < left_overlap / 2; i++ )
344 : {
345 1855600 : mdstWin[left_overlap / 2 + i] += mdstWin[left_overlap / 2 - 1 - i];
346 : }
347 :
348 15305 : if ( frameno == 0 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
349 : {
350 414766 : for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
351 : {
352 407440 : mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
353 : }
354 : }
355 :
356 : /* Outer right folding */
357 635005 : for ( i = 0; i < right_overlap / 2; i++ )
358 : {
359 619700 : mdstWin[L_subframe + left_overlap / 2 - 1 - i] -= mdstWin[L_subframe + left_overlap / 2 + i];
360 : }
361 :
362 : /* 2xTCX5 */
363 15305 : L_subframe = tcx5SizeFB;
364 15305 : folding_offset = left_overlap / 2;
365 :
366 45915 : for ( i = 0; i < 2; i++ )
367 : {
368 30610 : WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1 );
369 :
370 30610 : TCX_MDST( tcx5Win, mdst_spectrum[frameno] + i * tcx5SizeFB, left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
371 : /* high-band gain control in case of BWS */
372 30610 : if ( st->bwidth_sw_cnt > 0 )
373 : {
374 86 : v_multc( mdst_spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, mdst_spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), L_subframe - L_FRAME16k / ( 2 * nSubframes ) );
375 : }
376 : }
377 : }
378 : else /* transform_type[frameno] != TCX_5 */
379 : {
380 646575 : if ( transform_type[frameno] == TCX_20 && st->hTcxCfg->tcx_last_overlap_mode != TRANSITION_OVERLAP )
381 : {
382 630867 : edst( mdstWin, mdst_spectrum[frameno], L_subframe, st->element_mode );
383 :
384 630867 : v_multc( mdst_spectrum[frameno], (float) sqrt( (float) NORM_MDCT_FACTOR / L_subframe ), mdst_spectrum[frameno], L_subframe );
385 : }
386 : else
387 : {
388 15708 : if ( frameno == 0 && transform_type[0] == TCX_10 && overlap_mode[0] == FULL_OVERLAP && L_subframe - left_overlap > minWindowLen )
389 : {
390 219448 : for ( i = minWindowLen; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */
391 : {
392 215160 : mdstWin[left_overlap + i] += hTcxEnc->speech_TCX[-1 - i] * st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] * st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i];
393 : }
394 : }
395 :
396 15708 : TCX_MDST( mdstWin, mdst_spectrum[frameno], left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode );
397 : }
398 :
399 : /* high-band gain control in case of BWS */
400 646575 : if ( st->bwidth_sw_cnt > 0 )
401 : {
402 1912 : v_multc( mdst_spectrum[frameno] + L_FRAME16k / nSubframes, (float) ( st->bwidth_sw_cnt ) / (float) BWS_TRAN_PERIOD, mdst_spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes );
403 : }
404 : }
405 : }
406 :
407 899169 : if ( st->element_mode != IVAS_CPE_MDCT )
408 : {
409 237289 : TNSAnalysis( st->hTcxCfg, L_frameTCX, st->hTcxCfg->tcx_coded_lines, transform_type[frameno], ( frameno == 0 ) && ( st->last_core == ACELP_CORE ), hTcxEnc->spectrum[frameno], st->hTranDet, -1, &hTcxEnc->tnsData[frameno], &hTcxEnc->fUseTns[frameno], NULL );
410 :
411 237289 : if ( st->hTcxCfg->fIsTNSAllowed )
412 : {
413 161582 : EncodeTnsData( st->hTcxCfg->pCurrentTnsConfig, &hTcxEnc->tnsData[frameno], param_core + frameno * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, pTnsSize + frameno, pTnsBits + frameno );
414 : }
415 :
416 237289 : if ( transform_type[frameno] == TCX_5 )
417 : {
418 : /* group sub-windows: interleave bins according to their frequencies */
419 533031 : for ( i = 0; i < tcx5SizeFB; i++ )
420 : {
421 530800 : interleaveBuf[2 * i] = hTcxEnc->spectrum[frameno][i];
422 530800 : interleaveBuf[2 * i + 1] = hTcxEnc->spectrum[frameno][tcx5SizeFB + i];
423 : }
424 2231 : mvr2r( interleaveBuf, hTcxEnc->spectrum[frameno], tcx10SizeFB );
425 : }
426 :
427 : /*--------------------------------------------------------------*
428 : * LPC analysis
429 : *---------------------------------------------------------------*/
430 :
431 237289 : if ( st->tcxonly )
432 : {
433 108975 : HBAutocorrelation( st->hTcxCfg, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &st->speech_enc_pe[frameno * tcx10Size], L_frame / nSubframes, r );
434 :
435 108975 : adapt_lag_wind( r, M, alw_pitch_lag_12k8[frameno], alw_voicing[frameno], st->sr_core );
436 :
437 108975 : lev_dur( A, r, M, NULL );
438 :
439 108975 : a2lsp_stab( A, lsp[nSubframes - 1 - frameno], st->lspold_enc );
440 : }
441 :
442 237289 : if ( st->igf )
443 : {
444 226631 : ProcessIGF( st, hTcxEnc->spectrum[frameno], hTcxEnc->spectrum[frameno], powerSpec, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag );
445 : }
446 : }
447 : }
448 882281 : if ( st->element_mode != IVAS_CPE_MDCT )
449 : {
450 : /* Copy memory */
451 235212 : mvr2r( lsp_new, st->lspold_enc, M );
452 : }
453 :
454 882281 : return;
455 : }
|