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 "options.h" 11 : #include "wmc_auto.h" 12 : #include "functions.h" 13 : 14 0 : void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt) 15 : { 16 : LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; 17 : LC3_INT32 i; 18 : 19 0 : ener_prev = 0; ener_curr = 0; mean_nrg_low = 0; mean_nrg_high = 0; 20 : 21 0 : *pc_nbLostCmpt = *pc_nbLostCmpt + 1; 22 : 23 0 : assert(spec_inv_idx > 1); 24 : 25 0 : gg = LC3_POW(10, (((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0)); 26 : 27 0 : for (i = 0; i < spec_inv_idx; i++) 28 : { 29 0 : mean_nrg_low += LC3_POW(q_d_prev[i], 2); 30 : } 31 : 32 0 : mean_nrg_low /= (LC3_FLOAT) spec_inv_idx; 33 : 34 0 : if (spec_inv_idx < yLen) 35 : { 36 0 : for (i = spec_inv_idx; i < yLen; i++) 37 : { 38 0 : mean_nrg_high += LC3_POW(q_d_prev[i], 2); 39 : } 40 : } 41 : 42 0 : mean_nrg_high /= (LC3_FLOAT) (yLen - spec_inv_idx); 43 : 44 0 : for (i = 0; i < spec_inv_idx; i++) 45 : { 46 0 : ener_prev += LC3_POW(q_old_res[i], 2); 47 0 : ener_curr += LC3_POW(q_res[i], 2); 48 : } 49 : 50 0 : *fac = 1; 51 0 : if (ener_prev > 0) 52 : { 53 0 : *fac = LC3_SQRT(ener_curr / ener_prev); 54 : } 55 : 56 0 : fac_local = *fac; 57 0 : if (mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW(*prev_gg, 2) <= ener_curr * LC3_POW(gg, 2)) 58 : { 59 0 : fac_local = *prev_gg / gg; 60 : } 61 : 62 0 : for (i = spec_inv_idx; i < yLen; i++) 63 : { 64 0 : q_res[i] = q_old_res[i] * fac_local; 65 : 66 0 : if (LC3_FABS(q_res[i]) < (1 - 0.375)) 67 : { 68 0 : q_res[i] = 0; 69 : } 70 : } 71 0 : } 72 :