Line data Source code
1 : /*==================================================================================== 2 : EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.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 10856 : 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 10856 : total = 0; 29 10856 : move16(); 30 461556 : FOR( i = 0; i < nb_sfm; i++ ) 31 : { 32 450700 : tmp = extract_l( L_mult0( R[i], sfmsize[i] ) ); // Q0 33 450700 : Rsubband[i] = shl( tmp, 3 ); // Q3 34 450700 : move16(); 35 450700 : total = add( total, tmp ); 36 : } 37 10856 : *sum = total; 38 10856 : move16(); 39 : 40 10856 : IF( LE_16( length, L_FRAME32k ) ) 41 : { 42 1310 : diff = sub( num_bits, *sum ); 43 1310 : i = 0; 44 1310 : move16(); 45 8216 : WHILE( diff > 0 ) 46 : { 47 6906 : IF( R[i] > 0 ) 48 : { 49 5815 : Rsubband[i] = add( Rsubband[i], 8 ); 50 5815 : move16(); 51 5815 : diff = sub( diff, 1 ); 52 5815 : *sum = add( *sum, 1 ); 53 5815 : move16(); 54 : } 55 6906 : i = add( i, 1 ); 56 6906 : if ( GE_16( i, nb_sfm ) ) 57 : { 58 1 : i = 0; 59 1 : move16(); 60 : } 61 : } 62 : } 63 10856 : return; 64 : }