Line data Source code
1 : /****************************************************************************** 2 : * ETSI TS 103 634 V1.5.1 * 3 : * Low Complexity Communication Codec Plus (LC3plus) * 4 : * * 5 : * Copyright licence is solely granted through ETSI Intellectual Property * 6 : * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * 7 : * estoppel or otherwise. * 8 : ******************************************************************************/ 9 : 10 : #include "defines.h" 11 : #include "functions.h" 12 : 13 0 : void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 frame_dms, Word8 *scratchBuffer) 14 : { 15 : Word16 s; 16 : Word32 nrg; 17 : Word16 smax; 18 : Counter band; 19 : const Word16 *pre_emph; 20 : const Word16 *pre_emph_e; 21 : Word16 * d2_band_fx_exp; 22 : 23 : #ifdef DYNMEM_COUNT 24 : Dyn_Mem_In("processPreEmphasis_fx", sizeof(struct { 25 : Word16 s; 26 : Word32 nrg; 27 : Word16 smax; 28 : Counter band; 29 : const Word16 *pre_emph; 30 : const Word16 *pre_emph_e; 31 : Word16 * d2_band_fx_exp; 32 : })); 33 : #endif 34 : 35 0 : d2_band_fx_exp = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER_PLC = 160 bytes */ 36 : 37 0 : pre_emph = lpc_lin_pre_emphasis[fs_idx]; 38 0 : pre_emph_e = lpc_lin_pre_emphasis_e[fs_idx]; 39 0 : SWITCH (frame_dms) 40 : { 41 0 : case 25: 42 0 : pre_emph = lpc_lin_pre_emphasis_2_5ms[fs_idx]; 43 0 : pre_emph_e = lpc_lin_pre_emphasis_e_2_5ms[fs_idx]; 44 0 : BREAK; 45 0 : case 50: 46 0 : pre_emph = lpc_lin_pre_emphasis_5ms[fs_idx]; 47 0 : pre_emph_e = lpc_lin_pre_emphasis_e_5ms[fs_idx]; 48 0 : BREAK; 49 0 : case 75: 50 0 : pre_emph = lpc_lin_pre_emphasis_7_5ms[fs_idx]; 51 0 : pre_emph_e = lpc_lin_pre_emphasis_e_7_5ms[fs_idx]; 52 0 : BREAK; 53 : } 54 : 55 0 : ASSERT(n_bands==20 || n_bands==40 || n_bands==60 || n_bands ==80); 56 : 57 : /* start processing */ 58 0 : smax = -31; move16(); 59 : 60 0 : FOR (band = 0; band < n_bands; band++) 61 : { 62 0 : nrg = Mpy_32_16_lc3plus(d2_fx[band], pre_emph[band]); 63 : 64 0 : if (nrg == 0) 65 : { 66 0 : s = 31; move16(); 67 : } 68 : 69 0 : if (nrg != 0) 70 : { 71 0 : s = norm_l(nrg); 72 : } 73 : 74 0 : d2_fx[band] = L_shl_pos(nrg, s); move32(); 75 0 : d2_band_fx_exp[band] = sub(pre_emph_e[band], s); move16(); 76 : 77 0 : smax = s_max(smax, d2_band_fx_exp[band]); 78 : } 79 : 80 : /* Rescale band energies */ 81 0 : FOR (band = 0; band < n_bands; band++) 82 : { 83 0 : d2_fx[band] = L_shr_pos(d2_fx[band], s_min(sub(smax, d2_band_fx_exp[band]), 31)); move32(); 84 : } 85 : /* Save common exponent for all bands */ 86 0 : *d2_fx_exp = add(*d2_fx_exp, smax); move16(); 87 : 88 : #ifdef DYNMEM_COUNT 89 : Dyn_Mem_Out(); 90 : #endif 91 0 : } 92 : 93 :