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