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 "functions.h" 11 : #include "rom_basop_util_lc3plus.h" 12 : 13 0 : void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms) 14 : { 15 : 16 : Dyn_Mem_Deluxe_In( 17 : Counter iBand; 18 : Word32 d2_fx_sum; 19 : Word32 d2_fx_mean; 20 : Word32 delta_energy; 21 : Word16 d2_fx_sum_exp; 22 : Word16 d2_fx_mean_exp; 23 : Word16 nrg_below_thresh; 24 : Word16 counter; 25 : Word16 brickwall; 26 : Word16 stop; 27 : Word16 brickwall_dist; 28 : const Word16 *warp_idx_start, *warp_idx_stop, *bw_brickwall_dist; 29 : ); 30 : 31 0 : SWITCH (frame_dms) 32 : { 33 0 : case 25: 34 0 : warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; move16(); 35 0 : warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; move16(); 36 0 : bw_brickwall_dist = BW_brickwall_dist_2_5ms; 37 0 : BREAK; 38 0 : case 50: 39 0 : warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; move16(); 40 0 : warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; move16(); 41 0 : bw_brickwall_dist = BW_brickwall_dist_5ms; 42 0 : BREAK; 43 0 : case 75: 44 0 : warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; move16(); 45 0 : warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; move16(); 46 0 : bw_brickwall_dist = BW_brickwall_dist_7_5ms; 47 0 : BREAK; 48 0 : default: /* 100 */ 49 0 : warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; move16(); 50 0 : warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; move16(); 51 0 : bw_brickwall_dist = BW_brickwall_dist; 52 0 : BREAK; 53 : } 54 : 55 0 : counter = fs_idx; 56 : DO 57 : { 58 : 59 : /* counter is 0...num_idxs-1 */ 60 0 : counter = sub(counter, 1); 61 : 62 : /* always code the lowest band (NB), skip check against threshold if counter == -1 */ 63 0 : IF (counter < 0) 64 : { 65 0 : BREAK; 66 : } 67 : 68 0 : d2_fx_mean = 0; move32(); 69 0 : d2_fx_mean_exp = 0; move16(); 70 : 71 0 : iBand = warp_idx_start[counter]; move16(); 72 0 : d2_fx_sum = d2_fx[iBand]; move32(); 73 0 : d2_fx_sum_exp = d2_fx_exp; move16(); 74 : 75 0 : iBand++; 76 0 : FOR (; iBand <= warp_idx_stop[counter]; iBand++) 77 : { 78 0 : d2_fx_sum = BASOP_Util_Add_Mant32Exp_lc3plus(d2_fx[iBand], d2_fx_exp, d2_fx_sum, d2_fx_sum_exp, &d2_fx_sum_exp); 79 : } 80 : /* Energy-sum */ 81 0 : d2_fx_mean = Mpy_32_16_lc3plus(d2_fx_sum, InvIntTable[add(sub(warp_idx_stop[counter], warp_idx_start[counter]), 1)]); 82 0 : d2_fx_mean_exp = d2_fx_sum_exp; move16(); 83 : 84 : /* check if above threshold */ 85 0 : nrg_below_thresh = BASOP_Util_Cmp_Mant32Exp_lc3plus(BW_thresh_quiet[counter], BW_thresh_quiet_exp, d2_fx_mean, 86 : d2_fx_mean_exp); /* true if firstNumber > secondNumber */ 87 : } 88 : WHILE (nrg_below_thresh > 0) 89 0 : ; 90 : 91 0 : *bw_idx = add(1, counter); move16(); 92 : 93 : /* addtional check for brickwall characteristic */ 94 0 : IF (sub(fs_idx, *bw_idx) > 0) 95 : { 96 0 : brickwall = 0; move16(); 97 0 : stop = add(warp_idx_start[counter + 1], 1); 98 0 : brickwall_dist = bw_brickwall_dist[counter + 1]; 99 : 100 0 : FOR (iBand = stop; iBand >= sub(stop, brickwall_dist); iBand--) 101 : { 102 : /* Band(x) > Band(x-3)*Thr */ 103 : delta_energy = 104 0 : L_sub(Mpy_32_16_lc3plus(d2_fx[iBand - brickwall_dist], BW_thresh_brickwall[counter + 1]), d2_fx[iBand]); 105 0 : if (delta_energy > 0) 106 : { 107 0 : brickwall = 1; move16(); 108 : } 109 0 : IF (brickwall) 110 : { 111 0 : BREAK; 112 : } 113 : } 114 0 : if (brickwall == 0) 115 : { 116 0 : *bw_idx = fs_idx; 117 : } 118 : } 119 : 120 : Dyn_Mem_Deluxe_Out(); 121 0 : } 122 :