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 "defines.h" 13 : #include "functions.h" 14 : 15 0 : void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ 16 : LC3_INT32 n_plocs, 17 : LC3_FLOAT *f0est, /* i/o f0est */ 18 : const LC3_INT32 Xabs_len, 19 : LC3_FLOAT *f0binPtr, /* i */ 20 : LC3_FLOAT *f0gainPtr, /* i */ 21 : const LC3_INT32 nSubm 22 : ) 23 : { 24 : LC3_FLOAT sens; 25 : LC3_INT32 i, j, high_idx, breakflag; 26 : LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; 27 : LC3_FLOAT f0bin; 28 : LC3_FLOAT f0gain; 29 : 30 0 : f0bin = *f0binPtr; 31 0 : f0gain = *f0gainPtr; 32 : 33 0 : if (n_plocs > 0 && f0gain > 0.25) { 34 : 35 0 : sens = 0.5; 36 0 : if (f0gain < 0.75) { 37 0 : sens = 0.25; 38 : } 39 : 40 0 : high_idx = -1; 41 0 : for (i = 0; i < n_plocs; i++) { 42 0 : if (plocs[i] <= 25) { /* 25 ~= 1550 Hz */ 43 0 : high_idx = MAX(high_idx, i); 44 : } else { 45 : /* Optimization, only works if plocs vector is sorted. Which it should be. */ 46 0 : break; 47 : } 48 : } 49 : 50 0 : if (high_idx != -1) { 51 0 : high_idx++; 52 0 : move_float(f0est_lim, f0est, high_idx); 53 : 54 0 : breakflag = 0; 55 0 : for (i = 0; i < nSubm; i++) { 56 0 : for (j = 0; j < high_idx; j++) { 57 0 : if (LC3_FABS(f0est_lim[j] - (i+1) * f0bin) < sens) { 58 0 : f0est[j] = (i+1)*f0bin; 59 0 : plocs[j] = MIN(Xabs_len-1, MAX(1,(LC3_INT32) LC3_ROUND(f0est[j]))); 60 0 : breakflag = 1; 61 0 : break; 62 : } 63 : } 64 0 : if (breakflag) { 65 0 : break; 66 : } 67 0 : sens *= 0.875; 68 : } 69 : } 70 : } 71 : 72 0 : return; 73 : } 74 :