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 processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) 15 : { 16 : const LC3_INT *warp_idx_start, *warp_idx_stop; 17 0 : LC3_INT counter, brickwall = 0, i, stop, dist; 18 : LC3_FLOAT d2_mean, d2_sum, e_diff, thr; 19 : const LC3_INT *bw_dist; 20 : 21 0 : warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; 22 0 : warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; 23 : 24 0 : switch (frame_dms) 25 : { 26 0 : case 25: 27 0 : warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; 28 0 : warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; 29 0 : bw_dist = brickwall_dist; 30 0 : break; 31 0 : case 50: 32 0 : warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; 33 0 : warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; 34 0 : bw_dist = brickwall_dist; 35 0 : break; 36 0 : case 75: 37 0 : warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; 38 0 : warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; 39 0 : bw_dist = brickwall_dist_7_5ms; 40 0 : break; 41 0 : case 100: 42 0 : warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; 43 0 : warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; 44 0 : bw_dist = brickwall_dist; 45 0 : break; 46 : } 47 : 48 0 : counter = fs_idx; 49 : 50 0 : d2_sum = sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); 51 : 52 0 : d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); 53 : 54 0 : while (d2_mean < threshold_quiet[counter - 1]) { 55 0 : d2_sum = 0; 56 0 : counter--; 57 0 : if (counter == 0) { 58 0 : break; 59 : } 60 : 61 : /* calculate mean energy per band */ 62 : d2_sum = 63 0 : sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); 64 : 65 0 : d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); 66 : } 67 : 68 0 : *bw_idx = counter; 69 : 70 : /* check if energy difference between bands is present */ 71 0 : if (*bw_idx < fs_idx) { 72 0 : thr = (LC3_FLOAT)threshold_brickwall[counter]; 73 0 : stop = warp_idx_start[counter]; 74 0 : dist = bw_dist[counter]; 75 : 76 0 : for (i = stop; i >= stop - dist; i--) { 77 0 : e_diff = 10.0 * LC3_LOGTEN(d2[i - dist + 1] + FLT_EPSILON) - 10.0 * LC3_LOGTEN(d2[i + 1] + FLT_EPSILON); 78 : 79 0 : if (e_diff > thr) { 80 0 : brickwall = 1; 81 0 : break; 82 : } 83 : } 84 : 85 0 : if (brickwall == 0) { 86 0 : *bw_idx = fs_idx; 87 : } 88 : } 89 0 : }