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 processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits 15 : , LC3_INT hrmode 16 : ) 17 : { 18 0 : LC3_INT k = 0, n = 0; 19 0 : LC3_FLOAT offset1 = 0, offset2 = 0; 20 0 : LC3_FLOAT offset = 0; 21 : LC3_INT nz_idx[MAX_LEN]; 22 0 : LC3_INT N_nz = 0, idx = 0; 23 : 24 0 : LC3_INT iter = 0, iter_max = 1; 25 : 26 0 : if (hrmode) 27 : { 28 0 : iter_max = EXT_RES_ITER_MAX; 29 0 : offset = offset1 = offset2 = 0.25; 30 : } 31 : else 32 : { 33 0 : offset1 = 0.1875; 34 0 : offset2 = 0.3125; 35 : } 36 : 37 0 : if (hrmode) 38 : { 39 : /* enumerat non-zero coefficients */ 40 0 : for (k = 0; k < L_spec; k ++) 41 : { 42 0 : if (x[k]) 43 : { 44 0 : nz_idx[N_nz ++] = k; 45 : } 46 : } 47 : /* apply residual corrections */ 48 0 : while (n < resQBits && iter < iter_max) 49 : { 50 0 : for (k = 0; k < N_nz; k ++) 51 : { 52 0 : idx = nz_idx[k]; 53 : 54 0 : if ((prm[n >> 3] & 1 << (n & 7)) == 0) 55 : { 56 0 : x[idx] -= offset; 57 : } 58 : else 59 : { 60 : 61 0 : x[idx] += offset; 62 : } 63 0 : if (++n >= resQBits) 64 : { 65 0 : break; 66 : } 67 : } 68 0 : offset *= 0.5; 69 0 : iter ++; 70 : } 71 : } 72 : else 73 : { 74 0 : while (k < L_spec && n < resQBits) { 75 0 : if (x[k] != 0) { 76 0 : if ((prm[n >> 3] & 1 << (n & 7)) == 0) 77 : { 78 0 : if (x[k] > 0) { 79 0 : x[k] -= offset1; 80 : } else { 81 0 : x[k] -= offset2; 82 : } 83 : } else { 84 0 : if (x[k] > 0) { 85 0 : x[k] += offset2; 86 : } else { 87 0 : x[k] += offset1; 88 : } 89 : } 90 0 : n++; 91 : } 92 : 93 0 : k++; 94 : } 95 : } 96 0 : *bitsRead = n; 97 0 : }