Line data Source code
1 : /*==================================================================================== 2 : EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 3 : ====================================================================================*/ 4 : #include <stdint.h> 5 : #include "options.h" /* Compilation switches */ 6 : #include "cnst.h" /* Common constants */ 7 : #include "prot_fx.h" /* Function prototypes */ 8 : 9 : /*-------------------------------------------------------------------------- 10 : * bitallocsum_fx() 11 : * 12 : * Calculate the total number of bits allocated over frame 13 : *--------------------------------------------------------------------------*/ 14 13464 : void bitallocsum_fx( 15 : Word16 *R, /* i : bit-allocation vector Q0 */ 16 : const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ 17 : Word16 *sum, /* o : total number of bits allocated Q0 */ 18 : Word16 *Rsubband, /* o : rate per subband Q3 */ 19 : const Word16 num_bits, /* i : number of bits Q0 */ 20 : const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ 21 : const Word16 *sfmsize /* i : band length Q0 */ 22 : ) 23 : { 24 : Word16 i; 25 : Word16 total, tmp; 26 : Word16 diff; 27 : 28 13464 : total = 0; 29 13464 : move16(); 30 572810 : FOR( i = 0; i < nb_sfm; i++ ) 31 : { 32 559346 : tmp = extract_l( L_mult0( R[i], sfmsize[i] ) ); // Q0 33 559346 : Rsubband[i] = shl( tmp, 3 ); // Q3 34 559346 : move16(); 35 559346 : total = add( total, tmp ); 36 : } 37 13464 : *sum = total; 38 13464 : move16(); 39 : 40 13464 : IF( LE_16( length, L_FRAME32k ) ) 41 : { 42 1578 : diff = sub( num_bits, *sum ); 43 1578 : i = 0; 44 1578 : move16(); 45 9791 : WHILE( diff > 0 ) 46 : { 47 8213 : IF( R[i] > 0 ) 48 : { 49 6885 : Rsubband[i] = add( Rsubband[i], 8 ); 50 6885 : move16(); 51 6885 : diff = sub( diff, 1 ); 52 6885 : *sum = add( *sum, 1 ); 53 6885 : move16(); 54 : } 55 8213 : i = add( i, 1 ); 56 8213 : if ( GE_16( i, nb_sfm ) ) 57 : { 58 0 : i = 0; 59 0 : move16(); 60 : } 61 : } 62 : } 63 13464 : return; 64 : }