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 959969 : void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, 15 : LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi) 16 : { 17 : LC3_FLOAT tmp[MAX_LEN_PCM_PLC]; 18 : 19 959969 : move_float(tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length); 20 959969 : move_float(&PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length); 21 959969 : move_float(&PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length); 22 : 23 959969 : if (bfi != 1) 24 : { 25 956738 : *nbLostCmpt = 0; 26 956738 : *cum_alpha = 1; 27 : 28 956738 : if (PlcAdvSetup) 29 : { 30 956738 : move_float(PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M); 31 956738 : move_float(PlcAdvSetup->scf_q_old, scf_q, M); 32 : /* PLC fullband transient detector setting for non-bfi frames */ 33 956738 : PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ 34 : } 35 : } 36 : 37 959969 : *prevprevBfi = *prevBfi; 38 959969 : *prevBfi = bfi; 39 959969 : } 40 : 41 43892 : void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, 42 : LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape) 43 : { 44 : LC3_INT32 i, j, N_grp; 45 : LC3_INT32 local_prev_bfi; 46 : LC3_INT32 fs_idx; 47 43892 : LC3_FLOAT E_tot = 0.0; 48 : LC3_INT32 l_grp; 49 : LC3_FLOAT *pX; 50 : 51 43892 : if (bfi != 1) /* compute only for bfi== 0 or 2 */ 52 : { 53 43836 : fs_idx = (LC3_INT32)floor(yLen / 100); 54 43836 : assert(fs_idx < 5); 55 43836 : N_grp = xavg_N_grp[fs_idx]; 56 : 57 43836 : local_prev_bfi = prev_bfi; 58 43836 : if (local_prev_bfi == 2) { 59 0 : local_prev_bfi = 0; 60 : } 61 : 62 : 63 : /* Copy old to oold grp shape */ 64 438360 : for (i = 0; i < MAX_LGW; i++) 65 : { 66 394524 : stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; 67 : } 68 : 69 : /* Accumulate DC-coupled bins to total */ 70 43836 : E_tot = 0; 71 43836 : pX = q_d; /* ptr setup */ 72 219180 : for (i = 0; i < mdct_grp_bins[0]; i++) 73 : { 74 175344 : E_tot += sqrf( *pX ); 75 175344 : pX++; 76 : } 77 : 78 : /* Accumulate middle grps and add to total */ 79 350672 : for (i = 0; i < (N_grp - 1); i++) 80 : { 81 306836 : l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; ; 82 306836 : stPhECU_old_grp_shape[i] = 0.0; 83 14333076 : for (j = 0; j < l_grp; j++) { 84 14026240 : stPhECU_old_grp_shape[i] += sqrf( *pX ); 85 14026240 : pX++; 86 : } 87 306836 : E_tot += stPhECU_old_grp_shape[i]; 88 : } 89 : 90 : /* Accumulate last subbband and add to total */ 91 43836 : stPhECU_old_grp_shape[(N_grp - 1)] = 0.0; 92 43836 : l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; 93 43836 : assert( (mdct_grp_bins[N_grp] - mdct_grp_bins[0]) <= yLen); 94 3375372 : for (j = 0; j < l_grp; j++) 95 : { 96 3331536 : stPhECU_old_grp_shape[(N_grp - 1)] += sqrf( *pX ); 97 3331536 : pX++; 98 : } 99 43836 : E_tot += stPhECU_old_grp_shape[(N_grp - 1)]; 100 : 101 : 102 : /* Normalize shape */ 103 394508 : for (i = 0; i < (N_grp); i++) { 104 350672 : if (E_tot > 0.0) { 105 349952 : stPhECU_old_grp_shape[i] /= E_tot; 106 : } 107 : else 108 : { 109 720 : stPhECU_old_grp_shape[i] = 0.0; 110 : } 111 : } 112 43836 : if (local_prev_bfi == 1) { 113 210 : for (i = 0; i < MAX_LGW; i++) { 114 189 : stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; 115 : } 116 : } 117 : }/*bfi*/ 118 43892 : return; 119 : } 120 : 121 956738 : void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen) 122 : { 123 956738 : move_float(q_d_prev, q_d_fl_c, yLen); 124 956738 : } 125 :