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 processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits 15 : , LC3_INT hrmode 16 : ) 17 : { 18 0 : LC3_INT n = 0, m = 0, k = 0; 19 0 : LC3_INT iter=0; 20 : LC3_FLOAT offset; 21 0 : LC3_INT iter_max = 1; 22 : LC3_INT nz_idx[MAX_LEN]; 23 0 : LC3_INT N_nz = 0, idx = 0; 24 : 25 : 26 0 : memset(resBits, 0, MAX_RESBITS_LEN); 27 : 28 0 : m = targetBits - nBits + 4; 29 0 : if (hrmode) 30 : { 31 0 : m += 10; 32 : } 33 : 34 0 : assert(m <= MAX_RESBITS); 35 : 36 0 : offset = .25; 37 0 : if (hrmode) 38 : { 39 0 : iter_max = EXT_RES_ITER_MAX; 40 : 41 : } 42 0 : for (k = 0; k < L_spec; k ++) 43 : { 44 0 : if (xq[k]) 45 : { 46 0 : nz_idx[N_nz ++] = k; 47 : } 48 : } 49 0 : while (iter < iter_max && n < m) 50 : { 51 0 : k = 0; 52 0 : while (k < N_nz && n < m) 53 : { 54 0 : idx = nz_idx[k]; 55 : 56 0 : if (x[idx] >= (LC3_FLOAT)xq[idx] * gain) 57 : { 58 0 : resBits[n >> 3] |= 1 << (n & 7); 59 0 : x[idx] -= gain * offset; 60 : } 61 : else 62 : { 63 0 : resBits[n >> 3] &= ~(1 << (n & 7)); 64 0 : x[idx] += gain * offset; 65 : } 66 : 67 0 : n++; 68 : 69 0 : k++; 70 : } 71 0 : iter ++; 72 0 : offset *= .5; 73 : } 74 : 75 0 : *numResBits = n; 76 0 : }