LCOV - code coverage report
Current view: top level - lib_enc - tfa_enc_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 574a190e3c6896c6c4ed10d7f23649709a0c4347 Lines: 48 48 100.0 %
Date: 2025-06-27 02:59:36 Functions: 2 2 100.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"
       7             : #include "basop_util.h"
       8             : #include "cnst.h"
       9             : //#include "prot_fx.h"
      10             : #include "prot_fx.h"     /* Function prototypes                    */
      11             : #include "prot_fx_enc.h" /* Function prototypes                    */
      12             : 
      13             : /*-------------------------------------------------------------------*
      14             :  * tfaCalcEnv()
      15             :  *
      16             :  *
      17             :  *-------------------------------------------------------------------*/
      18             : 
      19         612 : void tfaCalcEnv_fx(
      20             :     const Word16 *shb_speech,
      21             :     Word32 *enr )
      22             : {
      23             :     Word16 i, j, k;
      24             : 
      25         612 :     k = 0;
      26         612 :     move16();
      27       10404 :     FOR( i = 0; i < N_TEC_TFA_SUBFR; i++ )
      28             :     {
      29        9792 :         enr[i] = L_deposit_l( 0 );
      30        9792 :         move32();
      31      205632 :         FOR( j = 0; j < L_TEC_TFA_SUBFR16k; j++ )
      32             :         {
      33      195840 :             enr[i] = L_mac0_sat( enr[i], shb_speech[k], shb_speech[k] );
      34      195840 :             move32();
      35      195840 :             k = add( k, 1 );
      36             :         }
      37             :     }
      38         612 :     return;
      39             : }
      40             : 
      41         612 : Word16 tfaEnc_TBE_fx(
      42             :     const Word32 *enr,
      43             :     const Word16 last_core,
      44             :     const Word16 *voicing,   /* Q15 */
      45             :     const Word16 *pitch_buf, /* Q6 */
      46             :     const Word16 Q_enr )
      47             : {
      48             :     Word16 i;
      49             :     Word32 m_g, m_a; /* m_g: geometrical mean, m_a: arithmetical mean */
      50             :     Word16 voicing_sum;
      51             :     Word16 pitch_buf_sum;
      52             :     Word32 m_a_bottom;
      53             :     Word16 tfa_flag;
      54             : 
      55             :     Word32 L_tmp, L_tmp1;
      56             :     Word16 exp;
      57             : 
      58         612 :     m_a_bottom = L_shl( 625, Q_enr ); /*  10000.0 / N_TEC_TFA_SUBFR in Q_enr */
      59             : 
      60         612 :     tfa_flag = 0;
      61         612 :     move16();
      62             : 
      63         612 :     L_tmp = L_deposit_l( 0 );
      64         612 :     m_a = L_deposit_l( 0 );
      65         612 :     m_g = L_deposit_l( 0 );
      66             : 
      67       10404 :     FOR( i = 0; i < N_TEC_TFA_SUBFR; i++ )
      68             :     {
      69        9792 :         IF( enr[i] != 0 )
      70             :         {
      71        9686 :             m_a = L_add( m_a, L_shr( enr[i], 4 ) ); /* Q_enr */
      72        9686 :             exp = norm_l( enr[i] );
      73        9686 :             L_tmp = BASOP_Util_Log2( L_shl( enr[i], exp ) );
      74        9686 :             exp = sub( sub( 31, exp ), Q_enr );
      75        9686 :             L_tmp = L_add( L_shl( L_deposit_h( exp ), 9 ), L_tmp );
      76        9686 :             m_g = L_add( m_g, L_shr( L_tmp, 4 ) );
      77             :         }
      78             :     }
      79             : 
      80             :     /* energy lower limit */
      81         612 :     IF( LT_32( m_a, m_a_bottom ) )
      82             :     {
      83          69 :         tfa_flag = 0;
      84          69 :         move16();
      85             :     }
      86             :     ELSE
      87             :     {
      88         543 :         exp = norm_l( m_a );
      89         543 :         L_tmp = BASOP_Util_Log2( L_shl( m_a, exp ) );
      90         543 :         exp = sub( sub( 31, exp ), Q_enr );
      91         543 :         m_a = L_add( L_shl( L_deposit_h( exp ), 9 ), L_tmp ); /* Q25 */
      92         543 :         L_tmp = L_add( m_a, -17266211l /*log10(0.7f)/log10(2.f) Q25*/ );
      93         543 :         L_tmp1 = L_add( m_a, -33554432l /*log10(0.5f)/log10(2.f) Q25*/ );
      94             : 
      95         543 :         voicing_sum = add( shr( voicing[0], 1 ), shr( voicing[1], 1 ) );
      96             : 
      97         543 :         pitch_buf_sum = shr( add( shr( pitch_buf[0], 1 ), shr( pitch_buf[1], 1 ) ), 1 );
      98         543 :         pitch_buf_sum = add( pitch_buf_sum, shr( add( shr( pitch_buf[2], 1 ), shr( pitch_buf[3], 1 ) ), 1 ) );
      99             : 
     100         543 :         test();
     101         543 :         test();
     102         543 :         test();
     103         543 :         test();
     104         543 :         test();
     105        1036 :         if ( ( GT_32( m_g, L_tmp ) && GT_16( pitch_buf_sum, 7040 /*110 Q6*/ ) && GT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) ||
     106         517 :              ( EQ_16( last_core, TCX_20_CORE ) && GT_32( m_g, L_tmp1 ) && LT_16( voicing_sum, 22938 /*0.70 Q15*/ ) ) )
     107             :         {
     108          56 :             tfa_flag = 1;
     109          56 :             move16();
     110             :         }
     111             :     }
     112             : 
     113         612 :     return tfa_flag;
     114             : }

Generated by: LCOV version 1.14