Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <stdint.h>
34 : #include "options.h"
35 : #include "prot_fx.h" /* Function prototypes */
36 : #include "prot_fx_enc.h" /* Function prototypes */
37 : #include "rom_com.h"
38 : #include "stl.h"
39 :
40 : /*--------------------------------------------------------------------------*
41 : * GetSubbandCorrIndex2_har()
42 : *
43 : * Finds the index of best correlation between highband (*inBuf) and lowband (*predBuf) for current subband of length (fLen)
44 : *--------------------------------------------------------------------------*/
45 0 : static Word16 GetSubbandCorrIndex2_har_fx( /* o : best correlation index */
46 : const Word32 *L_inBuf, /* i : target buffer (i.e., highband signal) : spectra */
47 : const Word16 fLen, /* i : window length */
48 : const Word16 *predBuf_fx, /* i : prediction buffer (i.e., lowband) : sspectra */
49 : const Word16 predBufLen, /* i : sspectra buffer size */
50 : const Word16 maxLag_fx, /* i : search length */
51 : const GainItem_fx *G_item_fx, /* i : */
52 : const Word16 nZero_fx, /* i : number of nonzero components used in */
53 : Word16 *prev_frame_bstindx_fx /* i : previous frame best Indices */
54 : )
55 : {
56 : Word16 i, j;
57 : Word16 bestIdx_fx;
58 : Word32 L_lagCorr_sq;
59 : Word32 L_lagEnergy;
60 :
61 : Word32 L_energy;
62 : Word32 L_corr;
63 : Word32 L_corr_sq;
64 :
65 : Word16 corr_sq_hi_fx;
66 : Word32 L_corr_sq_tmp;
67 : Word32 L_lagCorr_sq_tmp;
68 : Word16 corr_sq_fx;
69 : Word16 lagCorr_sq_fx;
70 : Word32 L_energy_tmp;
71 : Word32 L_lagEnergy_tmp;
72 : Word16 energy_fx;
73 : Word16 lagEnergy_fx;
74 :
75 : Word16 N1_fx, N2_fx;
76 : Word16 exp_safe_e;
77 :
78 : Word16 exp_corr;
79 : Word16 exp_energy;
80 :
81 : Word32 L_buf;
82 :
83 : Word16 ibuf_fx[L_FRAME32k];
84 : Word16 pbuf_fx[L_FRAME32k];
85 : Word16 *ptr_pbuf;
86 : Word16 exp_shift;
87 :
88 : Word16 exp_norm;
89 :
90 : Word32 L_tmp;
91 :
92 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
93 0 : Flag Overflow = 0;
94 0 : move16();
95 : #endif
96 :
97 0 : exp_safe_e = 4;
98 0 : move16();
99 :
100 0 : L_tmp = L_deposit_l( 0 );
101 0 : FOR( i = 0; i < fLen; i++ )
102 : {
103 0 : L_tmp = L_or( L_tmp, L_abs( L_inBuf[i] ) );
104 : }
105 0 : exp_norm = norm_l( L_tmp );
106 0 : exp_shift = sub( exp_norm, exp_safe_e );
107 :
108 0 : FOR( i = 0; i < fLen; i++ )
109 : {
110 0 : ibuf_fx[i] = extract_h( L_shl( L_inBuf[i], exp_shift ) ); /* Qi+exp_shift-16 */
111 0 : move16();
112 : }
113 :
114 0 : FOR( i = 0; i < predBufLen; i++ )
115 : {
116 0 : pbuf_fx[i] = shr( predBuf_fx[i], exp_safe_e );
117 0 : move16(); /* Qss-exp_safe_e */
118 : }
119 :
120 0 : bestIdx_fx = 0;
121 0 : move16();
122 0 : L_lagCorr_sq = L_deposit_l( 0 );
123 0 : L_lagEnergy = 0x7FFFFFFF;
124 0 : move32();
125 :
126 0 : N1_fx = s_max( 0x0, sub( *prev_frame_bstindx_fx, shr( maxLag_fx, 1 ) ) );
127 0 : IF( *prev_frame_bstindx_fx < 0 )
128 : {
129 0 : N2_fx = sub( maxLag_fx, 1 );
130 : }
131 : ELSE
132 : {
133 0 : N2_fx = s_min( sub( maxLag_fx, 1 ), add( *prev_frame_bstindx_fx, shr( maxLag_fx, 1 ) ) );
134 : }
135 0 : predBuf_fx += N1_fx;
136 0 : ptr_pbuf = pbuf_fx + N1_fx;
137 :
138 :
139 0 : Overflow = 0;
140 0 : move16();
141 :
142 : /* find the best lag */
143 0 : FOR( i = N1_fx; i <= N2_fx; i++ )
144 : {
145 0 : L_corr = L_deposit_l( 0 );
146 :
147 : /* get the energy, remove the old and update with the new energy index */
148 :
149 0 : L_energy = L_deposit_l( 0 );
150 0 : FOR( j = 0; j < fLen; j++ )
151 : {
152 : /*energy += *predBuf * *predBuf; */
153 0 : L_energy = L_mac_o( L_energy, *ptr_pbuf, *ptr_pbuf, &Overflow ); /* Q*2-1; */
154 0 : ptr_pbuf++;
155 : }
156 :
157 0 : ptr_pbuf -= fLen;
158 :
159 : /* get cross-correlation */
160 0 : IF( L_energy != 0x0L )
161 : {
162 0 : L_corr = L_deposit_l( 0 );
163 0 : FOR( j = 0; j < nZero_fx; j++ )
164 : {
165 : /*corr += inBuf[G_item[j].gainIndex]* predBuf[G_item[j].gainIndex]; */
166 0 : L_corr = L_mac_o( L_corr, ibuf_fx[G_item_fx[j].gainIndex_fx], ptr_pbuf[G_item_fx[j].gainIndex_fx], &Overflow ); /* Q*2-1 */
167 : }
168 :
169 : /*corr_sq = corr*corr; */
170 0 : exp_norm = norm_l( L_corr );
171 0 : exp_norm = sub( exp_norm, 1 ); /* added for Overflow 0x8000 * 0x8000 -> Overflow */
172 0 : L_corr_sq = L_shl( L_corr, exp_norm );
173 0 : corr_sq_hi_fx = extract_h( L_corr_sq );
174 :
175 0 : L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */
176 0 : L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */
177 0 : if ( Overflow != 0 )
178 : {
179 0 : L_corr_sq = 0x0L;
180 0 : move32();
181 : }
182 :
183 0 : Overflow = 0;
184 0 : move16();
185 :
186 : /* normalize for L_lagCorr_sq and L_corr_sq */
187 0 : L_buf = L_or( L_lagCorr_sq, L_corr_sq );
188 0 : exp_corr = norm_l( L_buf );
189 0 : L_corr_sq_tmp = L_shl( L_corr_sq, exp_corr );
190 0 : L_lagCorr_sq_tmp = L_shl( L_lagCorr_sq, exp_corr );
191 0 : corr_sq_fx = extract_h( L_corr_sq_tmp );
192 0 : lagCorr_sq_fx = extract_h( L_lagCorr_sq_tmp );
193 :
194 : /* normalize for L_lagEnergy and L_energy */
195 0 : L_buf = L_or( L_lagEnergy, L_energy );
196 0 : exp_energy = norm_l( L_buf );
197 0 : L_energy_tmp = L_shl( L_energy, exp_energy );
198 0 : L_lagEnergy_tmp = L_shl( L_lagEnergy, exp_energy );
199 0 : energy_fx = extract_h( L_energy_tmp );
200 0 : lagEnergy_fx = extract_h( L_lagEnergy_tmp );
201 :
202 : /*if( (double)lagCorr_sq*(double)energy < (double)corr_sq*(double)lagEnergy ) */
203 0 : IF( L_msu( L_mult( lagCorr_sq_fx, energy_fx ), corr_sq_fx, lagEnergy_fx ) < 0 )
204 : {
205 0 : bestIdx_fx = i;
206 0 : move16();
207 0 : L_lagCorr_sq = L_add( L_corr_sq, 0 );
208 0 : L_lagEnergy = L_add( L_energy, 0 );
209 : }
210 : }
211 0 : predBuf_fx++;
212 0 : ptr_pbuf++;
213 : }
214 :
215 0 : test();
216 0 : IF( L_lagCorr_sq == 0x0 && *prev_frame_bstindx_fx < 0 )
217 : {
218 0 : bestIdx_fx = 0x0;
219 0 : move16();
220 : }
221 : ELSE
222 : {
223 0 : if ( L_lagCorr_sq == 0x0 )
224 : {
225 0 : bestIdx_fx = *prev_frame_bstindx_fx;
226 0 : move16();
227 : }
228 : }
229 :
230 0 : *prev_frame_bstindx_fx = bestIdx_fx;
231 0 : move16();
232 :
233 0 : return bestIdx_fx;
234 : }
235 :
236 : /*--------------------------------------------------------------------------*
237 : * getswbindices_har()
238 : *
239 : * Finds the pulse index of best correlation between highband (*yos) and lowband (*y2) for two groups of length sbLen
240 : *--------------------------------------------------------------------------*/
241 :
242 0 : static void getswbindices_har_fx(
243 : const Word32 *L_yos, /* i : original input spectrum */
244 : Word16 exp_refBuf, /* i : */
245 : Word16 *y2_fx, /* i : decoded spectrum */
246 : const Word16 nBands_search_fx, /* i : number of bands */
247 : Word16 *lagIndices_fx, /* o : pulse index */
248 : Word16 *prev_frame_bstindx_fx, /* i/o: prev frame index */
249 : const Word16 swb_lowband_fx, /* i : length of the LF spectrum */
250 : const Word16 *subband_offsets_fx, /* i : */
251 : const Word16 *sbWidth_fx, /* i : */
252 : const Word16 *subband_search_offset_fx /* i : */
253 : )
254 : {
255 : Word16 i, j, k, sb, tmp;
256 : Word16 *ptr_predBuf;
257 : GainItem_fx Nbiggest_fx[(NB_SWB_SUBBANDS_HAR_SEARCH_SB) *N_NBIGGEST_PULSEARCH];
258 : Word16 n_nbiggestsearch_fx[NB_SWB_SUBBANDS_HAR];
259 :
260 : Word16 search_offset_fx[NB_SWB_SUBBANDS_HAR_SEARCH_SB];
261 : Word16 nlags_fx[NB_SWB_SUBBANDS_HAR_SEARCH_SB];
262 :
263 : Word16 low_freqsgnl_fx[L_FRAME32k]; /* Qy2 (sspectra) */
264 :
265 0 : ptr_predBuf = y2_fx;
266 :
267 : /* Get the number of HF groups for performing Similarity search */
268 0 : FOR( sb = 0; sb < nBands_search_fx; sb++ )
269 : {
270 : /*nlags[sb] = (short)pow(2, bits_lagIndices_mode0_Har[sb]); */
271 0 : nlags_fx[sb] = shl( 1, bits_lagIndices_mode0_Har[sb] );
272 0 : move16();
273 : }
274 :
275 0 : j = 0;
276 0 : move16();
277 0 : FOR( sb = 0; sb < nBands_search_fx; sb++ )
278 : {
279 : /* Find NBiggest samples in HF Groups */
280 0 : FindNBiggest2_simple_fx_har( L_yos + add( swb_lowband_fx, subband_offsets_fx[sb] ), exp_refBuf, Nbiggest_fx + j,
281 0 : sbWidth_fx[sb], &n_nbiggestsearch_fx[sb], N_NBIGGEST_PULSEARCH );
282 :
283 0 : search_offset_fx[sb] = subband_search_offset_fx[sb];
284 0 : move16();
285 0 : j = add( j, N_NBIGGEST_PULSEARCH );
286 : }
287 :
288 : /* Similarity Search for the HF spectrum */
289 0 : FOR( sb = 0; sb < nBands_search_fx; sb++ )
290 : {
291 0 : IF( sb == 0 )
292 : {
293 : /* copy SSmoothed LF Spectrum */
294 0 : ptr_predBuf = y2_fx + sub( search_offset_fx[sb], shr( nlags_fx[sb], 1 ) );
295 0 : tmp = add( sbWidth_fx[sb], nlags_fx[sb] );
296 0 : FOR( i = 0; i < tmp; i++ )
297 : {
298 0 : low_freqsgnl_fx[i] = *ptr_predBuf++;
299 0 : move16();
300 : }
301 : }
302 : ELSE
303 : {
304 : /* copy SSmoothed LF Spectrum */
305 0 : k = 0;
306 0 : move16();
307 0 : tmp = sub( search_offset_fx[sb], add( sbWidth_fx[sb], shr( nlags_fx[sb], 1 ) ) );
308 0 : FOR( j = add( search_offset_fx[sb], shr( nlags_fx[sb], 1 ) ); j > tmp; j-- )
309 : {
310 0 : low_freqsgnl_fx[k] = y2_fx[j];
311 0 : move16();
312 0 : k++;
313 : }
314 : }
315 : /* correlation b/w HF spectrum Group1 of length sbLen and decoded LF spectrum */
316 0 : lagIndices_fx[sb] = (Word16) GetSubbandCorrIndex2_har_fx( L_yos + add( swb_lowband_fx, subband_offsets_fx[sb] ),
317 0 : sbWidth_fx[sb],
318 : low_freqsgnl_fx,
319 0 : add( sbWidth_fx[sb], nlags_fx[sb] ),
320 0 : nlags_fx[sb], Nbiggest_fx + ( sb * N_NBIGGEST_PULSEARCH ),
321 0 : n_nbiggestsearch_fx[sb], &prev_frame_bstindx_fx[sb] );
322 0 : move16();
323 : }
324 :
325 0 : return;
326 : }
327 : /*--------------------------------------------------------------------------*
328 : * GetSubbandCorrIndex2_pulsestep_fx()
329 : *
330 : *--------------------------------------------------------------------------*/
331 :
332 152 : static Word16 GetSubbandCorrIndex2_pulsestep_fx(
333 : const Word32 *L_inBuf, /* i: original input vector (highband) */
334 : const Word16 *predBuf_fx, /* i: spectrum smoothing vector */
335 : const Word16 *predBufMa_fx, /* i: moving averaged spectrum smoothing vector Q=Qss */
336 : const Word16 fLen, /* i: subband length of highband */
337 : const Word16 maxLag, /* i: number of search pulse number */
338 : const GainItem_fx *gi_fx, /* i: lag gain structure */
339 : const Word16 nZero, /* i: */
340 : const Word16 ssearch_buflim, /* i: length of search buffer */
341 : const Word16 *predBuf_ni_fx /* i: spectrum including noise smoothing vector */
342 : )
343 : {
344 : Word16 i, j;
345 : Word16 absPos_fx;
346 : Word16 bestIdx_fx;
347 : Word32 L_lagCorr_sq;
348 : Word32 L_lagEnergy;
349 :
350 : const Word16 *ptr_predBuf;
351 :
352 : Word32 L_energy;
353 : Word32 L_corr;
354 : Word16 corr_fx;
355 :
356 : Word32 L_corr_sq;
357 :
358 :
359 : Word16 hiBuf_fx[L_FRAME32k];
360 : Word16 exp_norm_hi;
361 :
362 : Word16 exp_norm;
363 : Word32 L_corr_sq_tmp;
364 : Word32 L_lagCorr_sq_tmp;
365 : Word16 corr_sq_fx;
366 : Word16 lagCorr_sq_fx;
367 : Word32 L_energy_tmp;
368 : Word32 L_lagEnergy_tmp;
369 : Word16 energy_fx;
370 : Word16 lagEnergy_fx;
371 :
372 : Word16 ib_flag_fx;
373 :
374 : Word32 L_buf;
375 : Word32 L_buf2;
376 : Word32 L_temp;
377 :
378 : Word16 ssBuf_fx[L_FRAME32k];
379 : Word16 ssBuf_ni_fx[L_FRAME32k];
380 : Word16 *ptr_ssBuf_ni_fx;
381 : Word16 exp_norm_ss;
382 :
383 152 : set16_fx( hiBuf_fx, 0x0, L_FRAME32k );
384 152 : set16_fx( ssBuf_fx, 0x0, L_FRAME32k );
385 :
386 152 : ib_flag_fx = 0;
387 152 : move16();
388 :
389 152 : absPos_fx = 0;
390 152 : move16();
391 152 : bestIdx_fx = -1;
392 152 : move16();
393 152 : L_lagCorr_sq = L_deposit_l( 0 );
394 152 : L_lagEnergy = 0x7FFFFFFFL;
395 152 : move32();
396 :
397 152 : ptr_predBuf = predBuf_fx;
398 : /* This part must be computed on parent function. */
399 152 : exp_norm_ss = 2;
400 152 : move16();
401 :
402 152 : j = add( ssearch_buflim, fLen );
403 34200 : FOR( i = 0; i < j; i++ )
404 : {
405 34048 : ssBuf_fx[i] = shr( predBuf_fx[i], exp_norm_ss );
406 34048 : move16(); /* Qss+exp_norm_ss */
407 34048 : ssBuf_ni_fx[i] = shr( predBuf_ni_fx[i], exp_norm_ss );
408 34048 : move16(); /* Qss+exp_norm_ss */
409 : }
410 :
411 152 : L_temp = L_deposit_l( 0 );
412 12008 : FOR( i = 0; i < fLen; i++ )
413 : {
414 11856 : L_temp = L_or( L_temp, L_abs( L_inBuf[i] ) );
415 : }
416 152 : exp_norm_hi = norm_l( L_temp );
417 152 : exp_norm_hi = sub( exp_norm_hi, 3 ); /* max 109 < 2^7 , sspectrum is sparse, it is't need 4 */
418 :
419 12008 : FOR( i = 0; i < fLen; i++ )
420 : {
421 11856 : hiBuf_fx[i] = extract_h( L_shl( L_inBuf[i], exp_norm_hi ) );
422 11856 : move16(); /* Qsh+exp_norm_hi-16 */
423 : }
424 :
425 : /* Get the initial energy for zero lag */
426 152 : test();
427 780 : WHILE( *ptr_predBuf == 0 && LT_16( absPos_fx, ssearch_buflim ) )
428 : {
429 628 : test();
430 628 : ptr_predBuf++;
431 628 : absPos_fx = add( absPos_fx, 1 );
432 : }
433 :
434 152 : IF( EQ_16( absPos_fx, ssearch_buflim ) )
435 : {
436 0 : ptr_predBuf--;
437 0 : absPos_fx = sub( absPos_fx, 1 );
438 : }
439 :
440 152 : ptr_ssBuf_ni_fx = ssBuf_ni_fx + absPos_fx;
441 152 : L_energy = L_deposit_l( 0 );
442 12008 : FOR( i = 0; i < fLen; i++ )
443 : {
444 11856 : L_energy = L_mac( L_energy, *ptr_ssBuf_ni_fx, *ptr_ssBuf_ni_fx ); /* (Qss-exp_norm_ss)*2+1 */
445 11856 : ptr_ssBuf_ni_fx++;
446 : }
447 :
448 152 : ptr_ssBuf_ni_fx -= fLen;
449 :
450 152 : L_lagEnergy = L_add( L_energy, 0 );
451 :
452 : /* Find the best lag */
453 608 : FOR( i = 0; i < maxLag; i++ )
454 : {
455 456 : L_corr = L_deposit_l( 0 );
456 :
457 : /* Get the energy, remove the old and update with the new energy index */
458 456 : L_energy = L_deposit_l( 0 );
459 33516 : FOR( j = 0; j < fLen; j++ )
460 : {
461 33060 : L_energy = L_mac( L_energy, *ptr_ssBuf_ni_fx, *ptr_ssBuf_ni_fx );
462 33060 : ptr_ssBuf_ni_fx++;
463 : }
464 456 : ptr_ssBuf_ni_fx -= fLen;
465 :
466 : /* Get cross-correlation */
467 456 : IF( L_energy != 0x0L )
468 : {
469 456 : L_corr = L_deposit_l( 0 );
470 8624 : FOR( j = 0; j < nZero; j++ )
471 : {
472 : /*corr += inBuf[G_item[j].gainIndex]* predBufMa[G_item[j].gainIndex]; */
473 8168 : L_corr = L_mac( L_corr, hiBuf_fx[gi_fx[j].gainIndex_fx], predBufMa_fx[gi_fx[j].gainIndex_fx] ); /* Qsh+Qss+1 */
474 : }
475 :
476 : /*corr_sq = corr*corr; */
477 456 : exp_norm = norm_l( L_corr );
478 456 : exp_norm = sub( exp_norm, 1 ); /* added for Overflow 0x8000 * 0x8000 -> Overflow */
479 456 : L_corr_sq = L_shl( L_corr, exp_norm );
480 456 : corr_fx = extract_h( L_corr_sq );
481 456 : L_corr_sq = L_mult( corr_fx, corr_fx ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */
482 456 : L_corr_sq = L_shr( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */
483 :
484 : /*if( (lagCorr_sq == 0.0f && corr_sq == 0.0f) || (double)lagCorr_sq*(double)energy < (double)corr_sq*(double)lagEnergy ) */
485 : /*{ */
486 : /* bestIdx = i; */
487 : /* bestAbsPos = absPos; */
488 : /* lagCorr_sq = corr_sq; */
489 : /* lagCorr = corr; */
490 : /* lagEnergy = energy; */
491 : /*} */
492 : /* normalize for L_lagCorr_sq and L_corr_sq */
493 456 : L_buf = L_or( L_lagCorr_sq, L_corr_sq );
494 456 : exp_norm = norm_l( L_buf ); /* overflow allowed */
495 456 : L_corr_sq_tmp = L_shl( L_corr_sq, exp_norm );
496 456 : L_lagCorr_sq_tmp = L_shl( L_lagCorr_sq, exp_norm );
497 456 : corr_sq_fx = extract_h( L_corr_sq_tmp );
498 456 : lagCorr_sq_fx = extract_h( L_lagCorr_sq_tmp );
499 :
500 : /* normalize for L_lagEnergy and L_energy */
501 456 : L_buf = L_or( L_lagEnergy, L_energy );
502 456 : exp_norm = norm_l( L_buf ); /* overflow allowed */
503 456 : L_energy_tmp = L_shl( L_energy, exp_norm );
504 456 : L_lagEnergy_tmp = L_shl( L_lagEnergy, exp_norm );
505 456 : energy_fx = extract_h( L_energy_tmp );
506 456 : lagEnergy_fx = extract_h( L_lagEnergy_tmp );
507 :
508 456 : L_buf = L_or( L_lagCorr_sq, L_corr_sq );
509 456 : L_buf2 = L_msu( L_mult( lagCorr_sq_fx, energy_fx ), corr_sq_fx, lagEnergy_fx );
510 456 : test();
511 456 : IF( L_buf == 0 || L_buf2 < 0 )
512 : {
513 348 : bestIdx_fx = i;
514 348 : move16();
515 348 : L_lagCorr_sq = L_add( L_corr_sq, 0 );
516 348 : L_lagEnergy = L_add( L_energy, 0 );
517 : }
518 : }
519 456 : ptr_predBuf++;
520 456 : ptr_ssBuf_ni_fx++;
521 456 : absPos_fx++;
522 456 : test();
523 1642 : WHILE( *ptr_predBuf == 0 && LT_16( absPos_fx, ssearch_buflim ) )
524 : {
525 1186 : test();
526 1186 : ptr_predBuf++;
527 1186 : ptr_ssBuf_ni_fx++;
528 1186 : absPos_fx = add( absPos_fx, 1 );
529 : }
530 :
531 456 : IF( GE_16( absPos_fx, ssearch_buflim ) )
532 : {
533 0 : if ( EQ_16( bestIdx_fx, -1 ) )
534 : {
535 0 : ib_flag_fx = 1;
536 0 : move16();
537 : }
538 :
539 0 : BREAK;
540 : }
541 : }
542 :
543 152 : if ( EQ_16( ib_flag_fx, 1 ) )
544 : {
545 0 : bestIdx_fx = 0;
546 0 : move16();
547 : }
548 :
549 152 : return bestIdx_fx;
550 : }
551 : /*--------------------------------------------------------------------------*
552 : * GetSWBIndices_fx()
553 : *
554 : *--------------------------------------------------------------------------*/
555 38 : static void GetSWBIndices_fx(
556 : const Word16 *predBuf_fx, /* i : low-frequency band */
557 : /*const Word16 Qss,*/ /* i : Q value of predBuf_fx */
558 : const Word32 *L_targetBuf, /* i : SWB MDCT coeff. */
559 : const Word16 Qsh, /* i : Q value of L_targetBuf */
560 : const Word16 nBands_search, /* i : number of search subbands */
561 : const Word16 *sbWidth, /* i : subband lengths */
562 : Word16 *lagIndices, /* o : selected lags for subband coding */
563 : const Word16 predBufLen, /* i : low-frequency band length */
564 : GainItem_fx *gi_fx, /* o : most representative region */
565 : const Word16 *subband_offsets, /* o : N biggest components */
566 : Word16 *predBuf_ni_fx /* i : low-frequency band filled noise */
567 : )
568 : {
569 : Word16 j;
570 : Word16 sb, tmp;
571 : Word16 sbLen;
572 : Word16 n_nbiggestsearch_fx[NB_SWB_SUBBANDS];
573 : Word16 ssearch_buflim_fx;
574 : Word16 search_offset_fx[NB_SWB_SUBBANDS];
575 : Word16 nlags_fx[NB_SWB_SUBBANDS];
576 :
577 : Word16 exp_refBuf;
578 : Word16 sspectra_ma_fx[L_FRAME32k];
579 :
580 :
581 : Word32 L_temp;
582 :
583 :
584 : /* Initializations */
585 38 : exp_refBuf = Qsh;
586 :
587 38 : j = 0;
588 38 : move16();
589 190 : FOR( sb = 0; sb < nBands_search; sb++ )
590 : {
591 152 : FindNBiggest2_simple_fx_har( L_targetBuf + subband_offsets[sb], exp_refBuf, gi_fx + j, sbWidth[sb], &n_nbiggestsearch_fx[sb], N_NBIGGEST_PULSEARCH );
592 :
593 152 : j = add( j, N_NBIGGEST_PULSEARCH );
594 152 : move16();
595 : }
596 :
597 : /* Selection of most representative subband (full search) */
598 190 : FOR( sb = 0; sb < nBands_search; sb++ )
599 : {
600 152 : nlags_fx[sb] = shl( 1, bits_lagIndices_modeNormal[sb] );
601 152 : move16();
602 : }
603 :
604 190 : FOR( sb = 0; sb < nBands_search; sb++ )
605 : {
606 152 : search_offset_fx[sb] = subband_search_offsets[sb];
607 152 : move16();
608 : }
609 :
610 38 : sspectra_ma_fx[0] = add( shr( predBuf_ni_fx[0], 1 ), shr( predBuf_ni_fx[1], 1 ) );
611 38 : move16();
612 38 : tmp = sub( predBufLen, 1 );
613 9690 : FOR( sb = 1; sb < tmp; sb++ )
614 : {
615 : /*sspectra_ma[sb] = (predBuf[sb-1] + predBuf[sb] + predBuf[sb+1])/3.0f; */
616 9652 : L_temp = L_mult( predBuf_ni_fx[sb], 10922 ); /* 10922 = 0.33333 (Q15) */
617 9652 : L_temp = L_add( L_temp, L_mult( predBuf_ni_fx[sb - 1], 10922 ) );
618 9652 : L_temp = L_add( L_temp, L_mult( predBuf_ni_fx[sb + 1], 10922 ) ); /* Qss+15+1 */
619 9652 : sspectra_ma_fx[sb] = round_fx( L_temp );
620 9652 : move16();
621 : }
622 38 : sspectra_ma_fx[sb] = add( shr( predBuf_ni_fx[sb - 1], 1 ), shr( predBuf_ni_fx[sb], 1 ) );
623 38 : move16();
624 :
625 : /* Partial search for rest of subbands except the last which is fixed */
626 190 : FOR( sb = 0; sb < nBands_search; sb++ )
627 : {
628 152 : sbLen = sbWidth[sb];
629 152 : ssearch_buflim_fx = sub( predBufLen, add( sbLen, search_offset_fx[sb] ) );
630 304 : lagIndices[sb] = GetSubbandCorrIndex2_pulsestep_fx(
631 152 : L_targetBuf + subband_offsets[sb],
632 152 : predBuf_fx + search_offset_fx[sb],
633 152 : sspectra_ma_fx + search_offset_fx[sb],
634 152 : sbLen, nlags_fx[sb], gi_fx + ( sb * N_NBIGGEST_PULSEARCH ),
635 152 : n_nbiggestsearch_fx[sb],
636 152 : ssearch_buflim_fx, predBuf_ni_fx + search_offset_fx[sb] );
637 152 : move16();
638 : }
639 38 : }
640 : /*--------------------------------------------------------------------------*
641 : * gethar_noisegn_fx()
642 : *
643 : *--------------------------------------------------------------------------*/
644 :
645 0 : static void gethar_noisegn_fx(
646 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
647 : const Word32 L_spectra[], /* i : Qs input MDCT */
648 : const Word16 QsL, /* i : Q0 Q value for L_spectra, L_xSynth_har */
649 : const Word16 noise_flr_fx[], /* i : Qss noise floor */
650 : const Word16 Qss, /* i : Q0 Q value for noise_flr_fx, sspectra */
651 : Word32 L_xSynth_har[], /* o : Qs output SWB MDCT */
652 : const Word16 sbWidth[], /* i : Q0 band width for SWB */
653 : const Word16 lagIndices[], /* i : Q0 lag Indices */
654 : const Word16 bands, /* i : Q0 all band number */
655 : const Word16 har_bands, /* i : Q0 harmonic band number */
656 : const Word16 fLenLow, /* i : Q0 low frequency band width */
657 : const Word16 fLenHigh, /* i : Q0 SWB band width */
658 : const Word16 subband_offsets[], /* i : Q0 offset */
659 : const Word16 subband_search_offset[], /* i : Q0 offset */
660 : const Word16 band_start[], /* i : Q0 band start array */
661 : const Word16 band_end[], /* i : Q0 band end array */
662 : const Word16 band_width[], /* i : Q0 band width */
663 : Word32 L_band_energy[], /* i : Qbe band energy (Log scale) */
664 : const Word16 Qbe, /* i : Q0 Q value for L_band_energy */
665 : Word32 L_be_tonal[], /* o : QbeL tonal energy */
666 : Word16 *QbeL, /* o : Q0 Q value for L_be_tonal */
667 : const Word16 *sspectra_fx, /* i : Qss smoothed spectrum */
668 : const Word16 har_freq_est2, /* i : Q0 for harmonic structure */
669 : const Word16 pos_max_hfe2, /* i/o : Q0 for harmonic structure */
670 : Word16 *pul_res_fx, /* o : Q0 */
671 : GainItem_fx pk_sf_fx[] /* o : */
672 : )
673 : {
674 : Word16 i;
675 :
676 : Word32 L_xSynth_har_sft[L_FRAME32k];
677 : Word32 L_hfspec_sft[L_FRAME32k];
678 :
679 : Word32 L_hfspec[L_FRAME32k];
680 :
681 : GainItem_fx get_pk_fx[N_NBIGGEST_SEARCH_LRG_B];
682 : Word16 n_nbiggestsearch_fx, imin_fx, gqlevs_fx;
683 :
684 : Word32 L_g1, L_g2;
685 : Word16 exp_safe;
686 : Word32 L_temp;
687 :
688 : Word16 exp_normn, exp_normd;
689 : Word16 temp_fx;
690 : Word16 div_fx;
691 :
692 : Word16 exp_norm_g1, exp_norm_g2;
693 : Word16 sqrt_fx, Qsqrt;
694 : Word16 g_fx;
695 : Word16 exp, frac;
696 :
697 : Word16 dmin_fx, d_fx;
698 :
699 : Word16 temp_lo, temp_hi;
700 : Word16 Qg;
701 : #ifndef ISSUE_1867_replace_overflow_libenc
702 : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
703 : Flag Overflow = 0;
704 : move16();
705 : #endif
706 : #endif
707 : /*Generate HF noise*/
708 0 : genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow,
709 : fLenHigh, sbWidth, lagIndices, subband_offsets, subband_search_offset );
710 :
711 0 : Copy32( &L_spectra[fLenLow], L_hfspec, fLenHigh );
712 0 : FindNBiggest2_simple_fx_har( L_hfspec, QsL, get_pk_fx, fLenHigh, &n_nbiggestsearch_fx, N_NBIGGEST_SEARCH_LRG_B );
713 0 : FOR( i = 0; i < n_nbiggestsearch_fx; i++ )
714 : {
715 0 : L_hfspec[get_pk_fx[i].gainIndex_fx] = 0x0;
716 0 : move16();
717 : }
718 :
719 0 : L_temp = 0x0;
720 0 : move32();
721 0 : FOR( i = 0; i < fLenHigh; i++ )
722 : {
723 0 : L_temp = L_or( L_temp, L_abs( L_hfspec[i] ) );
724 : }
725 0 : exp_norm_g1 = norm_l( L_temp );
726 0 : FOR( i = 0; i < fLenHigh; i++ )
727 : {
728 0 : L_hfspec_sft[i] = L_shl( L_hfspec[i], exp_norm_g1 );
729 0 : move32();
730 : }
731 :
732 0 : L_temp = 0x0;
733 0 : move32();
734 0 : FOR( i = 0; i < fLenHigh; i++ )
735 : {
736 0 : L_temp = L_or( L_temp, L_abs( L_xSynth_har[i] ) );
737 : }
738 0 : exp_norm_g2 = norm_l( L_temp );
739 0 : FOR( i = 0; i < fLenHigh; i++ )
740 : {
741 0 : L_xSynth_har_sft[i] = L_shl( L_xSynth_har[i], exp_norm_g2 );
742 0 : move32();
743 : }
744 :
745 0 : exp_safe = 4;
746 0 : move16();
747 0 : L_g1 = L_deposit_l( 0 );
748 0 : L_g2 = L_deposit_l( 0 );
749 0 : FOR( i = 0; i < fLenHigh; i++ )
750 : {
751 0 : temp_fx = round_fx( L_shr( L_hfspec_sft[i], exp_safe ) );
752 0 : L_g1 = L_mac( L_g1, temp_fx, temp_fx ); /* 4: safe shift */
753 0 : temp_fx = round_fx( L_shr( L_xSynth_har_sft[i], exp_safe ) );
754 0 : L_g2 = L_mac( L_g2, temp_fx, temp_fx ); /* 4: safe shift */
755 : }
756 :
757 : /*g = (float) log10(sqrt(g1/g2));*/
758 : /* Div Part */
759 0 : exp_normn = norm_l( L_g1 );
760 0 : exp_normn = sub( exp_normn, 1 );
761 0 : exp_normd = norm_l( L_g2 );
762 0 : temp_fx = extract_h( L_shl( L_g2, exp_normd ) );
763 0 : exp_normd = sub( exp_normd, 16 );
764 :
765 0 : imin_fx = 0;
766 0 : move16();
767 0 : test();
768 0 : IF( L_g1 != 0 && temp_fx != 0x0 )
769 : {
770 0 : div_fx = div_l( L_shl( L_g1, exp_normn ), temp_fx );
771 : /* SQRT Part */
772 0 : sqrt_32n_16_fx( L_deposit_h( div_fx ), add( add( sub( exp_normn, exp_normd ), shl( sub( exp_norm_g1, exp_norm_g2 ), 1 ) ), 15 ), &sqrt_fx, &Qsqrt ); /* (exp_normn-exp_normd+(exp_norm_g1-exp_norm_g2)*2 -1)+16 */
773 :
774 : /* Log10 Part */
775 0 : g_fx = 0x0;
776 0 : move16();
777 0 : IF( sqrt_fx > 0x0 )
778 : {
779 0 : L_temp = L_deposit_l( sqrt_fx );
780 :
781 0 : exp = norm_l( L_temp );
782 0 : frac = Log2_norm_lc( L_shl( L_temp, exp ) );
783 0 : exp = sub( 30, exp );
784 0 : exp = sub( exp, Qsqrt );
785 0 : L_temp = L_Comp( exp, frac );
786 :
787 0 : L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */
788 : #ifdef ISSUE_1867_replace_overflow_libenc
789 0 : L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */
790 0 : g_fx = round_fx_sat( L_temp );
791 : #else
792 : L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */
793 : g_fx = round_fx_o( L_temp, &Overflow );
794 : #endif
795 : }
796 :
797 0 : gqlevs_fx = 4;
798 0 : move16();
799 0 : dmin_fx = 32767;
800 0 : move16();
801 0 : imin_fx = 0;
802 0 : move16();
803 :
804 0 : FOR( i = 0; i < gqlevs_fx; i++ )
805 : {
806 0 : d_fx = abs_s( g_fx - gain_table_SWB_BWE_fx[i] );
807 0 : IF( LT_16( d_fx, dmin_fx ) )
808 : {
809 0 : dmin_fx = d_fx;
810 0 : move16();
811 0 : imin_fx = i;
812 0 : move16();
813 : }
814 : }
815 : }
816 :
817 0 : push_indice( hBstr, IND_NOISEG, imin_fx, 2 );
818 :
819 : /*g=(float) pow (10.0f,gain_table[imin]);*/
820 0 : L_temp = L_mult( gain_table_SWB_BWE_fx[imin_fx], 27213 ); /* Q14+Q13+1=Q28 log(10)/log(2)=3.3219 27213.23(Q13) */
821 0 : L_temp = L_shr( L_temp, 12 ); /* Q28-Q12 -> Q16 */
822 0 : temp_lo = L_Extract_lc( L_temp, &temp_hi );
823 0 : Qg = sub( 14, temp_hi );
824 0 : g_fx = extract_l( Pow2( 14, temp_lo ) );
825 0 : g_fx = shl( g_fx, sub( 11, Qg ) );
826 :
827 0 : ton_ene_est_fx(
828 : L_xSynth_har, QsL, L_be_tonal, QbeL, L_band_energy, Qbe,
829 : band_start, band_end, band_width, fLenLow, fLenHigh, bands, har_bands, g_fx,
830 : pk_sf_fx, Qss, pul_res_fx );
831 :
832 0 : return;
833 : }
834 : /*--------------------------------------------------------------------------*
835 : * EncodeSWBSubbands()
836 : *
837 : * Main routine for generic SWB coding. High-frequency subband
838 : * replicated based on the lowband signal. A search is perform
839 : * find lowband indices denoting the selected lowband subband.
840 : *--------------------------------------------------------------------------*/
841 38 : static void EncodeSWBSubbands_fx(
842 : Encoder_State *st_fx, /* i/o: encoder state structure */
843 : Word32 *L_spectra, /* i/o: MDCT domain spectrum */
844 : Word16 QsL, /* i : Q value for L_spectra */
845 : const Word16 fLenLow_fx, /* i : lowband length */
846 : const Word16 fLenHigh_fx, /* i : highband length */
847 : const Word16 nBands_fx, /* i : number of subbands */
848 : const Word16 nBands_search_fx, /* i : number of subbands to be searched for BWE */
849 : const Word16 *sbWidth_fx, /* i : subband lengths */
850 : const Word16 *subband_offsets_fx, /* i : Subband offset for BWE */
851 : Word16 *lagIndices_fx, /* o : lowband index for each subband */
852 : const Word16 BANDS_fx, /* i : noise estimate from WB part */
853 : const Word16 *band_start_fx, /* i : Number subbands/Frame */
854 : const Word16 *band_end_fx, /* i : Band Start of each SB */
855 : Word32 *L_band_energy, /* i : Band end of each SB, :Qbe */
856 : Word16 Qbe, /* i : Q value of band energy */
857 : const Word16 *p2a_flags_fx, /* i : BAnd energy of each SB */
858 : const Word16 hqswb_clas_fx, /* i : lowband synthesis */
859 : Word16 *prev_frm_index_fx, /* i : clas information */
860 : const Word16 har_bands_fx, /* i/o: Index of the previous Frame */
861 : const Word16 *subband_search_offset_fx, /* i : Number of harmonic LF bands */
862 : Word16 *prev_frm_hfe2, /* i/o: */
863 : Word16 *prev_stab_hfe2, /* i/o: */
864 : const Word16 band_width_fx[], /* i : band width */
865 : const Word32 L_spectra_ni[], /* i : Qs noise injected spectra */
866 : Word16 *ni_seed_fx /* i/o: random seed */
867 : )
868 : {
869 : Word16 i, k;
870 : Word16 sspectra_fx[L_FRAME32k];
871 : Word16 sspectra_ni_fx[L_FRAME32k];
872 : Word16 sspectra_diff_fx[L_FRAME32k];
873 : Word16 Qss; /* Q value of Smoothed Spectrum low-subband */
874 : Word32 L_be_tonal[SWB_HAR_RAN1]; /* Q */
875 : Word16 ss_min_fx; /* Qss */
876 : Word32 L_th_g[NB_SWB_SUBBANDS];
877 : Word16 QbeL;
878 : GainItem_fx pk_sf_fx[(NB_SWB_SUBBANDS) *8];
879 : Word16 pul_res_fx[NB_SWB_SUBBANDS];
880 :
881 : GainItem_fx Nbiggest_fx[NB_SWB_SUBBANDS * N_NBIGGEST_PULSEARCH];
882 :
883 : Word32 L_xSynth_har[L_FRAME32k]; /* Qs */
884 :
885 : Word16 lagGains_fx[NB_SWB_SUBBANDS];
886 : Word16 QlagGains[NB_SWB_SUBBANDS];
887 : Word16 har_freq_est1, har_freq_est2;
888 : Word16 flag_dis;
889 : Word16 pos_max_hfe2;
890 38 : HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
891 :
892 38 : har_freq_est1 = 0;
893 38 : move16();
894 38 : har_freq_est2 = 0;
895 38 : move16();
896 38 : flag_dis = 1;
897 38 : move16();
898 38 : pos_max_hfe2 = 0;
899 38 : move16();
900 :
901 38 : set16_fx( sspectra_fx, 0, fLenLow_fx );
902 38 : set16_fx( sspectra_ni_fx, 0, fLenLow_fx );
903 38 : set32_fx( L_xSynth_har, 0, L_FRAME32k );
904 38 : set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS );
905 :
906 :
907 38 : IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) )
908 : {
909 0 : pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 );
910 0 : noise_extr_corcod_fx( L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, hHQ_core->prev_hqswb_clas, &hHQ_core->prev_ni_ratio_fx, &Qss );
911 : /* Find best indices for each group */
912 0 : getswbindices_har_fx(
913 : L_spectra,
914 : QsL, sspectra_ni_fx,
915 : nBands_search_fx, lagIndices_fx, prev_frm_index_fx, fLenLow_fx, subband_offsets_fx, sbWidth_fx, subband_search_offset_fx );
916 :
917 : /* Write the indices into the bitstream */
918 0 : FOR( k = 0; k < nBands_search_fx; k++ )
919 : {
920 0 : push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] );
921 : }
922 :
923 0 : IF( flag_dis == 0 )
924 : {
925 0 : test();
926 0 : IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) )
927 : {
928 0 : har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] );
929 0 : move16();
930 : }
931 : }
932 :
933 0 : gethar_noisegn_fx( st_fx->hBstr, L_spectra, QsL, sspectra_diff_fx, Qss, L_xSynth_har,
934 : sbWidth_fx, lagIndices_fx, BANDS_fx, har_bands_fx, fLenLow_fx, fLenHigh_fx,
935 : subband_offsets_fx, subband_search_offset_fx, band_start_fx, band_end_fx, band_width_fx,
936 : L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx,
937 : har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx );
938 :
939 :
940 0 : Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx,
941 : p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx );
942 :
943 0 : IF( flag_dis == 0 )
944 : {
945 0 : *prev_frm_hfe2 = 0;
946 0 : move16();
947 : }
948 : ELSE
949 : {
950 0 : *prev_frm_hfe2 = har_freq_est2;
951 0 : move16();
952 : }
953 :
954 0 : FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
955 : {
956 0 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
957 : {
958 0 : L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
959 0 : move32(); /* QsL */
960 : }
961 : }
962 : }
963 : ELSE
964 : {
965 38 : ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx );
966 :
967 : /* Get lag indices */
968 38 : GetSWBIndices_fx( sspectra_fx, /*Qss,*/ L_spectra + fLenLow_fx, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx,
969 : Nbiggest_fx, subband_offsets_fx, sspectra_fx );
970 :
971 : /* Bitstream operations */
972 190 : FOR( k = 0; k < nBands_fx; k++ )
973 : {
974 152 : IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) )
975 : {
976 5 : lagIndices_fx[k] = 0;
977 5 : move16();
978 5 : lagGains_fx[k] = 0;
979 5 : move16();
980 5 : QlagGains[k] = 15;
981 5 : move16();
982 : }
983 : ELSE
984 : {
985 147 : push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] );
986 : }
987 : }
988 :
989 38 : convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_fx, sspectra_fx, sbWidth_fx, fLenLow_fx );
990 :
991 38 : GetlagGains_fx( sspectra_ni_fx, Qss, &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, lagGains_fx, QlagGains );
992 190 : FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
993 : {
994 152 : lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */
995 152 : move16();
996 : }
997 :
998 190 : FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
999 : {
1000 152 : L_th_g[k] = L_deposit_l( 0 );
1001 152 : move32();
1002 152 : IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 )
1003 : {
1004 147 : L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */
1005 147 : move32();
1006 : }
1007 : }
1008 :
1009 38 : GetSynthesizedSpecThinOut_fx( sspectra_ni_fx, Qss, L_xSynth_har, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, lagGains_fx, QlagGains, fLenLow_fx );
1010 :
1011 : /*Level adjustment for the missing bands*/
1012 38 : noiseinj_hf_fx( L_xSynth_har, QsL, L_th_g, L_band_energy, Qbe, hHQ_core->prev_En_sb_fx, p2a_flags_fx, BANDS_fx, band_start_fx, band_end_fx, fLenLow_fx, fLenHigh_fx );
1013 :
1014 :
1015 190 : FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
1016 : {
1017 152 : IF( p2a_flags_fx[k] == 0 )
1018 : {
1019 11520 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
1020 : {
1021 11373 : L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
1022 11373 : move32(); /* Qob */
1023 : }
1024 : }
1025 : ELSE
1026 : {
1027 488 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
1028 : {
1029 483 : L_spectra[i] = L_spectra_ni[i];
1030 483 : move32();
1031 : }
1032 : }
1033 : }
1034 : }
1035 :
1036 38 : return;
1037 : }
1038 :
1039 0 : static void EncodeSWBSubbands_ivas_fx(
1040 : Encoder_State *st_fx, /* i/o: encoder state structure */
1041 : Word32 *L_spectra, /* i/o: MDCT domain spectrum */
1042 : Word16 QsL, /* i : Q value for L_spectra */
1043 : const Word16 fLenLow_fx, /* i : lowband length */
1044 : const Word16 fLenHigh_fx, /* i : highband length */
1045 : const Word16 nBands_fx, /* i : number of subbands */
1046 : const Word16 nBands_search_fx, /* i : number of subbands to be searched for BWE */
1047 : const Word16 *sbWidth_fx, /* i : subband lengths */
1048 : const Word16 *subband_offsets_fx, /* i : Subband offset for BWE */
1049 : Word16 *lagIndices_fx, /* o : lowband index for each subband */
1050 : const Word16 BANDS_fx, /* i : noise estimate from WB part */
1051 : const Word16 *band_start_fx, /* i : Number subbands/Frame */
1052 : const Word16 *band_end_fx, /* i : Band Start of each SB */
1053 : Word32 *L_band_energy, /* i : Band end of each SB, :Qbe */
1054 : Word16 Qbe, /* i : Q value of band energy */
1055 : const Word16 *p2a_flags_fx, /* i : BAnd energy of each SB */
1056 : const Word16 hqswb_clas_fx, /* i : lowband synthesis */
1057 : Word16 *prev_frm_index_fx, /* i : clas information */
1058 : const Word16 har_bands_fx, /* i/o: Index of the previous Frame */
1059 : const Word16 *subband_search_offset_fx, /* i : Number of harmonic LF bands */
1060 : Word16 *prev_frm_hfe2, /* i/o: */
1061 : Word16 *prev_stab_hfe2, /* i/o: */
1062 : const Word16 band_width_fx[], /* i : band width */
1063 : const Word32 L_spectra_ni[], /* i : Qs noise injected spectra */
1064 : Word16 *ni_seed_fx /* i/o: random seed */
1065 : )
1066 : {
1067 : Word16 i, k;
1068 : Word16 sspectra_fx[L_FRAME32k];
1069 : Word16 sspectra_ni_fx[L_FRAME32k];
1070 : Word16 sspectra_diff_fx[L_FRAME32k];
1071 : Word16 Qss; /* Q value of Smoothed Spectrum low-subband */
1072 : Word32 L_be_tonal[SWB_HAR_RAN1]; /* Q */
1073 : Word16 ss_min_fx; /* Qss */
1074 : Word32 L_th_g[NB_SWB_SUBBANDS];
1075 : Word16 QbeL;
1076 : GainItem_fx pk_sf_fx[(NB_SWB_SUBBANDS) *8];
1077 : Word16 pul_res_fx[NB_SWB_SUBBANDS];
1078 :
1079 : GainItem_fx Nbiggest_fx[NB_SWB_SUBBANDS * N_NBIGGEST_PULSEARCH];
1080 :
1081 : Word32 L_xSynth_har[L_FRAME32k]; /* Qs */
1082 :
1083 : Word16 lagGains_fx[NB_SWB_SUBBANDS];
1084 : Word16 QlagGains[NB_SWB_SUBBANDS];
1085 : Word16 har_freq_est1, har_freq_est2;
1086 : Word16 flag_dis;
1087 : Word16 pos_max_hfe2;
1088 0 : HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
1089 :
1090 0 : har_freq_est1 = 0;
1091 0 : move16();
1092 0 : har_freq_est2 = 0;
1093 0 : move16();
1094 0 : flag_dis = 1;
1095 0 : move16();
1096 0 : pos_max_hfe2 = 0;
1097 0 : move16();
1098 :
1099 0 : set16_fx( sspectra_fx, 0, fLenLow_fx );
1100 0 : set16_fx( sspectra_ni_fx, 0, fLenLow_fx );
1101 0 : set32_fx( L_xSynth_har, 0, L_FRAME32k );
1102 0 : set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS );
1103 :
1104 :
1105 0 : IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) )
1106 : {
1107 0 : pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 );
1108 0 : noise_extr_corcod_fx( L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, hHQ_core->prev_hqswb_clas, &hHQ_core->prev_ni_ratio_fx, &Qss );
1109 : /* Find best indices for each group */
1110 0 : getswbindices_har_fx(
1111 : L_spectra,
1112 : QsL, sspectra_ni_fx,
1113 : nBands_search_fx, lagIndices_fx, prev_frm_index_fx, fLenLow_fx, subband_offsets_fx, sbWidth_fx, subband_search_offset_fx );
1114 :
1115 : /* Write the indices into the bitstream */
1116 0 : FOR( k = 0; k < nBands_search_fx; k++ )
1117 : {
1118 0 : push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] );
1119 : }
1120 :
1121 0 : IF( flag_dis == 0 )
1122 : {
1123 0 : test();
1124 0 : IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) )
1125 : {
1126 0 : har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] );
1127 0 : move16();
1128 : }
1129 : }
1130 :
1131 0 : gethar_noisegn_fx( st_fx->hBstr, L_spectra, QsL, sspectra_diff_fx, Qss, L_xSynth_har,
1132 : sbWidth_fx, lagIndices_fx, BANDS_fx, har_bands_fx, fLenLow_fx, fLenHigh_fx,
1133 : subband_offsets_fx, subband_search_offset_fx, band_start_fx, band_end_fx, band_width_fx,
1134 : L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx,
1135 : har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx );
1136 :
1137 :
1138 0 : Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx,
1139 : p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx );
1140 :
1141 0 : IF( flag_dis == 0 )
1142 : {
1143 0 : *prev_frm_hfe2 = 0;
1144 0 : move16();
1145 : }
1146 : ELSE
1147 : {
1148 0 : *prev_frm_hfe2 = har_freq_est2;
1149 0 : move16();
1150 : }
1151 :
1152 0 : FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
1153 : {
1154 0 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
1155 : {
1156 0 : L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
1157 0 : move32(); /* QsL */
1158 : }
1159 : }
1160 : }
1161 : ELSE
1162 : {
1163 0 : ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx );
1164 :
1165 : /* Get lag indices */
1166 0 : GetSWBIndices_fx( sspectra_fx, /*Qss,*/ L_spectra + fLenLow_fx, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx,
1167 : Nbiggest_fx, subband_offsets_fx, sspectra_fx );
1168 :
1169 : /* Bitstream operations */
1170 0 : FOR( k = 0; k < nBands_fx; k++ )
1171 : {
1172 0 : IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) )
1173 : {
1174 0 : lagIndices_fx[k] = 0;
1175 0 : move16();
1176 0 : lagGains_fx[k] = 0;
1177 0 : move16();
1178 0 : QlagGains[k] = 15;
1179 0 : move16();
1180 : }
1181 : ELSE
1182 : {
1183 0 : push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] );
1184 : }
1185 : }
1186 :
1187 0 : convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_fx, sspectra_fx, sbWidth_fx, fLenLow_fx );
1188 :
1189 0 : GetlagGains_fx( sspectra_ni_fx, Qss, &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, lagGains_fx, QlagGains );
1190 0 : FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
1191 : {
1192 0 : lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */
1193 0 : move16();
1194 : }
1195 :
1196 0 : FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
1197 : {
1198 0 : L_th_g[k] = L_deposit_l( 0 );
1199 0 : move32();
1200 0 : IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 )
1201 : {
1202 0 : L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */
1203 0 : move32();
1204 : }
1205 : }
1206 :
1207 0 : GetSynthesizedSpecThinOut_fx( sspectra_ni_fx, Qss, L_xSynth_har, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, lagGains_fx, QlagGains, fLenLow_fx );
1208 :
1209 : /*Level adjustment for the missing bands*/
1210 0 : noiseinj_hf_fx( L_xSynth_har, QsL, L_th_g, L_band_energy, Qbe, hHQ_core->prev_En_sb_fx, p2a_flags_fx, BANDS_fx, band_start_fx, band_end_fx, fLenLow_fx, fLenHigh_fx );
1211 :
1212 :
1213 0 : FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
1214 : {
1215 0 : IF( p2a_flags_fx[k] == 0 )
1216 : {
1217 0 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
1218 : {
1219 0 : L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
1220 0 : move32(); /* Qob */
1221 : }
1222 : }
1223 : ELSE
1224 : {
1225 0 : FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
1226 : {
1227 0 : L_spectra[i] = L_spectra_ni[i];
1228 0 : move32();
1229 : }
1230 : }
1231 : }
1232 : }
1233 :
1234 0 : return;
1235 : }
1236 : /*--------------------------------------------------------------------------*
1237 : * swb_bwe_enc_lr()
1238 : *
1239 : * Main encoding routine of SWB BWE for the LR MDCT core
1240 : *--------------------------------------------------------------------------*/
1241 38 : void swb_bwe_enc_lr_fx(
1242 : Encoder_State *st_fx, /* i/o: encoder state structure */
1243 : const Word32 L_m_core[], /* i : lowband synthesis */
1244 : Word16 QsL, /* i : Q value */
1245 : const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */
1246 : Word32 L_m[], /* o : highband synthesis with lowband zeroed */
1247 : const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
1248 : Word16 BANDS_fx, /* i : Total number of Subbands in a frame */
1249 : Word16 *band_start_fx, /* i : band start of each SB */
1250 : Word16 *band_end_fx, /* i : band end of each SB */
1251 : Word32 *L_band_energy, /* i : band_energy of each SB */
1252 : Word16 Qbe, /* i : Q value of band energy */
1253 : Word16 *p2a_flags_fx, /* i : HF tonal indicator */
1254 : const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */
1255 : Word16 lowlength_fx, /* i : lowband length */
1256 : Word16 highlength_fx, /* i : highband length */
1257 : Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */
1258 : const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
1259 : Word16 *prev_frm_hfe2, /* i/o: */
1260 : Word16 *prev_stab_hfe2, /* i/o: */
1261 : const Word16 band_width_fx[], /* i : band_width information */
1262 : const Word32 L_y2_ni[], /* i : band_width information */
1263 : Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
1264 : )
1265 : {
1266 : Word16 k;
1267 : Word16 nBands_fx;
1268 : Word16 nBands_search_fx;
1269 : Word16 wBands_fx[NB_SWB_SUBBANDS];
1270 : Word16 lagIndices_fx[NB_SWB_SUBBANDS];
1271 : Word16 swb_lowband_fx, swb_highband_fx, allband_fx;
1272 :
1273 : const Word16 *subband_offsets_fx;
1274 : const Word16 *subband_search_offset_fx;
1275 :
1276 : Word32 *p_L_m;
1277 :
1278 38 : subband_search_offset_fx = subband_search_offsets_13p2kbps_Har;
1279 38 : subband_offsets_fx = subband_offsets_sub5_13p2kbps_Har;
1280 :
1281 38 : hf_parinitiz_fx( L_total_brate, hqswb_clas_fx, lowlength_fx, highlength_fx, wBands_fx, &subband_search_offset_fx, &subband_offsets_fx, &nBands_fx, &nBands_search_fx, &swb_lowband_fx, &swb_highband_fx );
1282 38 : allband_fx = add( swb_lowband_fx, swb_highband_fx );
1283 38 : move16();
1284 :
1285 : /* Prepare m[], low part from WB core, high part from 32k input */
1286 38 : Copy32( L_m_core, L_m, swb_lowband_fx );
1287 38 : Copy32( &L_m_orig[swb_lowband_fx], &L_m[swb_lowband_fx], swb_highband_fx );
1288 :
1289 38 : EncodeSWBSubbands_fx(
1290 : st_fx,
1291 : L_m, QsL,
1292 : swb_lowband_fx, swb_highband_fx, nBands_fx, nBands_search_fx, wBands_fx, subband_offsets_fx,
1293 : lagIndices_fx,
1294 : BANDS_fx, band_start_fx, band_end_fx,
1295 : L_band_energy, Qbe,
1296 : p2a_flags_fx,
1297 : hqswb_clas_fx, prev_frm_index_fx, har_bands_fx, subband_search_offset_fx,
1298 : prev_frm_hfe2, prev_stab_hfe2,
1299 : band_width_fx, L_y2_ni, ni_seed_fx );
1300 :
1301 38 : p_L_m = &L_m[sub( allband_fx, 1 )];
1302 38 : *p_L_m = Mult_32_16( *p_L_m, 2028 );
1303 38 : move32();
1304 38 : p_L_m--; /* 0.0625 = 2028 (Q15) */
1305 38 : *p_L_m = Mult_32_16( *p_L_m, 4096 );
1306 38 : move32();
1307 38 : p_L_m--; /* 0.125 = 4096 (Q15) */
1308 38 : *p_L_m = Mult_32_16( *p_L_m, 8192 );
1309 38 : move32();
1310 38 : p_L_m--; /* 0.25 = 8192 (Q15) */
1311 38 : *p_L_m = Mult_32_16( *p_L_m, 16384 );
1312 38 : move32();
1313 38 : p_L_m--; /* 0.5 = 16384 (Q15) */
1314 :
1315 : /* set low frequencies to zero */
1316 9766 : FOR( k = 0; k < swb_lowband_fx; k++ )
1317 : {
1318 9728 : L_m[k] = L_deposit_l( 0 );
1319 9728 : move32();
1320 : }
1321 :
1322 38 : return;
1323 : }
1324 :
1325 0 : void swb_bwe_enc_lr_ivas_fx(
1326 : Encoder_State *st_fx, /* i/o: encoder state structure */
1327 : const Word32 L_m_core[], /* i : lowband synthesis */
1328 : Word16 QsL, /* i : Q value */
1329 : const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */
1330 : Word32 L_m[], /* o : highband synthesis with lowband zeroed */
1331 : const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
1332 : Word16 BANDS_fx, /* i : Total number of Subbands in a frame */
1333 : Word16 *band_start_fx, /* i : band start of each SB */
1334 : Word16 *band_end_fx, /* i : band end of each SB */
1335 : Word32 *L_band_energy, /* i : band_energy of each SB */
1336 : Word16 Qbe, /* i : Q value of band energy */
1337 : Word16 *p2a_flags_fx, /* i : HF tonal indicator */
1338 : const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */
1339 : Word16 lowlength_fx, /* i : lowband length */
1340 : Word16 highlength_fx, /* i : highband length */
1341 : Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */
1342 : const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
1343 : Word16 *prev_frm_hfe2, /* i/o: */
1344 : Word16 *prev_stab_hfe2, /* i/o: */
1345 : const Word16 band_width_fx[], /* i : band_width information */
1346 : const Word32 L_y2_ni[], /* i : band_width information */
1347 : Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
1348 : )
1349 : {
1350 : Word16 k;
1351 : Word16 nBands_fx;
1352 : Word16 nBands_search_fx;
1353 : Word16 wBands_fx[NB_SWB_SUBBANDS];
1354 : Word16 lagIndices_fx[NB_SWB_SUBBANDS];
1355 : Word16 swb_lowband_fx, swb_highband_fx, allband_fx;
1356 :
1357 : const Word16 *subband_offsets_fx;
1358 : const Word16 *subband_search_offset_fx;
1359 :
1360 : Word32 *p_L_m;
1361 :
1362 0 : subband_search_offset_fx = subband_search_offsets_13p2kbps_Har;
1363 0 : subband_offsets_fx = subband_offsets_sub5_13p2kbps_Har;
1364 :
1365 0 : hf_parinitiz_fx( L_total_brate, hqswb_clas_fx, lowlength_fx, highlength_fx, wBands_fx, &subband_search_offset_fx, &subband_offsets_fx, &nBands_fx, &nBands_search_fx, &swb_lowband_fx, &swb_highband_fx );
1366 0 : allband_fx = add( swb_lowband_fx, swb_highband_fx );
1367 0 : move16();
1368 :
1369 : /* Prepare m[], low part from WB core, high part from 32k input */
1370 0 : Copy32( L_m_core, L_m, swb_lowband_fx );
1371 0 : Copy32( &L_m_orig[swb_lowband_fx], &L_m[swb_lowband_fx], swb_highband_fx );
1372 :
1373 0 : EncodeSWBSubbands_ivas_fx(
1374 : st_fx,
1375 : L_m, QsL,
1376 : swb_lowband_fx, swb_highband_fx, nBands_fx, nBands_search_fx, wBands_fx, subband_offsets_fx,
1377 : lagIndices_fx,
1378 : BANDS_fx, band_start_fx, band_end_fx,
1379 : L_band_energy, Qbe,
1380 : p2a_flags_fx,
1381 : hqswb_clas_fx, prev_frm_index_fx, har_bands_fx, subband_search_offset_fx,
1382 : prev_frm_hfe2, prev_stab_hfe2,
1383 : band_width_fx, L_y2_ni, ni_seed_fx );
1384 :
1385 0 : p_L_m = &L_m[sub( allband_fx, 1 )];
1386 0 : *p_L_m = Mult_32_16( *p_L_m, 2028 );
1387 0 : move32();
1388 0 : p_L_m--; /* 0.0625 = 2028 (Q15) */
1389 0 : *p_L_m = Mult_32_16( *p_L_m, 4096 );
1390 0 : move32();
1391 0 : p_L_m--; /* 0.125 = 4096 (Q15) */
1392 0 : *p_L_m = Mult_32_16( *p_L_m, 8192 );
1393 0 : move32();
1394 0 : p_L_m--; /* 0.25 = 8192 (Q15) */
1395 0 : *p_L_m = Mult_32_16( *p_L_m, 16384 );
1396 0 : move32();
1397 0 : p_L_m--; /* 0.5 = 16384 (Q15) */
1398 :
1399 : /* set low frequencies to zero */
1400 0 : FOR( k = 0; k < swb_lowband_fx; k++ )
1401 : {
1402 0 : L_m[k] = L_deposit_l( 0 );
1403 0 : move32();
1404 : }
1405 :
1406 0 : return;
1407 : }
|