LCOV - code coverage report
Current view: top level - lib_enc - waveadjust_fec_cod_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main @ 43b7b28dcb1471ff5d355252c4b8f37ee7ecc268 Lines: 0 32 0.0 %
Date: 2025-11-02 02:02:47 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : #include <stdint.h>
       6             : #include "options.h" /* for wmc_tool */
       7             : #include "cnst.h"
       8             : #include "rom_com.h"
       9             : #include "stat_com.h"
      10             : #include "prot_fx.h"     /* Function prototypes                    */
      11             : #include "prot_fx_enc.h" /* Function prototypes                    */
      12             : 
      13             : 
      14             : /*-------------------------------------------------------------------*
      15             :  * SFM_Cal_fx()
      16             :  *
      17             :  *
      18             :  *--------------------------------------------------------------------*/
      19             : 
      20           0 : Word32 SFM_Cal_fx(
      21             :     Word32 magn[], /*Q = Qx*/
      22             :     Word16 n       /*Q = Q0*/
      23             : )
      24             : {
      25             :     /* Counted Dymamic RAM: 16 words */
      26             :     Word32 logCurFlatness;
      27             :     Word32 magn_abs, frac, logMagn, sumLogMagn, sumMagn;
      28             :     Word16 i, norm_value, logSumMagn, logn;
      29           0 :     sumLogMagn = L_deposit_l( 0 );
      30           0 :     sumMagn = L_deposit_l( 0 );
      31           0 :     FOR( i = 0; i < n; i++ )
      32             :     {
      33             :         /* log2(magn(i)) */
      34           0 :         magn_abs = L_abs( magn[i] );
      35           0 :         norm_value = norm_l( L_max( magn_abs, 1 ) );
      36             :         /* next two codes lost precision. */
      37           0 :         frac = L_and( L_shr( L_shl( magn_abs, norm_value ), 22 ), 0xFF );
      38           0 :         logMagn = L_deposit_l( add( shl( sub( 30, norm_value ), 8 ), kLog2TableFrac_x[frac] ) );
      39             :         ; /* Q8 */
      40             :         /* sum(log2(magn(i))) */
      41           0 :         sumLogMagn = L_add( sumLogMagn, logMagn ); /* Q8 */
      42             : 
      43           0 :         sumMagn = L_add_sat( sumMagn, magn_abs ); /*Qx*/
      44             :     }
      45             : 
      46           0 :     IF( EQ_32( sumMagn, MAX_32 ) )
      47             :     {
      48           0 :         sumMagn = L_deposit_l( 0 );
      49           0 :         FOR( i = 0; i < n; i++ )
      50             :         {
      51           0 :             magn_abs = L_shr( L_abs( magn[i] ), 8 ); /* Qx-8 */
      52           0 :             sumMagn = L_add( sumMagn, magn_abs );
      53             :         }
      54             :         /* log2(sumMagn) */
      55           0 :         norm_value = norm_l( sumMagn );
      56           0 :         frac = L_and( L_shr( L_shl( sumMagn, norm_value ), 22 ), 0xFF );
      57           0 :         logSumMagn = add( shl( sub( 38, norm_value ), 8 ), kLog2TableFrac_x[frac] ); /* Q8 */
      58             :     }
      59             :     ELSE
      60             :     {
      61             :         /* log2(sumMagn) */
      62           0 :         norm_value = norm_l( sumMagn );
      63           0 :         frac = L_and( L_shr( L_shl( sumMagn, norm_value ), 22 ), 0xFF );
      64           0 :         logSumMagn = add( shl( sub( 30, norm_value ), 8 ), kLog2TableFrac_x[frac] ); /* Q8 */
      65             :     }
      66             : 
      67             :     /* log2(n) */
      68           0 :     norm_value = norm_l( n );
      69           0 :     frac = L_and( L_shr( L_shl( n, norm_value ), 22 ), 0xFF );
      70           0 :     logn = add( shl( sub( 30, norm_value ), 8 ), kLog2TableFrac_x[frac] ); /* Q8 */
      71             : 
      72             : 
      73           0 :     logMagn = L_sub( L_mult0( n, sub( logSumMagn, logn ) ), sumLogMagn );
      74           0 :     logMagn = (Word32) L_max( 0, logMagn );
      75             : 
      76           0 :     logCurFlatness = L_deposit_l( div_l( L_shl( logMagn, 1 ), n ) );
      77           0 :     frac = L_and( logCurFlatness, 0xFF );
      78           0 :     norm_value = (Word16) L_shr( logCurFlatness, 8 );
      79             : 
      80           0 :     logCurFlatness = L_sub( kExp2TableFrac_x[frac], 33 );
      81           0 :     logCurFlatness = L_shl( logCurFlatness, sub( 16, norm_value ) ); /* Q31 */
      82             : 
      83             : 
      84           0 :     return logCurFlatness;
      85             : }

Generated by: LCOV version 1.14