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