LCOV - code coverage report
Current view: top level - lib_dec - gs_dec_amr_wb_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 0 151 0.0 %
Date: 2025-05-03 01:55:50 Functions: 0 6 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" /* Compilation switches                   */
       7             : #include "cnst.h"    /* Common constants                       */
       8             : #include "rom_com.h" /* Static table prototypes                */
       9             : #include "prot_fx.h" /* Function prototypes                    */
      10             : 
      11             : /*-------------------------------------------------------------------*
      12             :  * Local constants
      13             :  *-------------------------------------------------------------------*/
      14             : 
      15             : #define ALP_FX   22938 /* 0.70f */
      16             : #define MALP_FX  ( Word16 )( 32768L - ALP_FX )
      17             : #define ALPMY_FX 28180 /* 0.86f */
      18             : 
      19             : #define BAND3k   15
      20             : #define BIN_1k2  48
      21             : #define BAND_2k  12
      22             : #define BAND_0k4 4
      23             : 
      24             : #define NORMALIZE_SPECS_Q_OUT 6
      25             : #define ENER_FX_Q_GUARD       1
      26             : 
      27             : /*-------------------------------------------------------------------*
      28             :  * Local functions
      29             :  *-------------------------------------------------------------------*/
      30             : static void NoiseFill_fx( Word16 *exc_diffQ_fx, Word16 *seed_tcx, const Word16 Mbands_gn, const Word16 Q_out );
      31             : static void Ener_per_band_fx( const Word16 exc_diff_fx[], const Word16 exc_diff_exp, Word32 y_gain4_fx[] );
      32             : static void Apply_gain_fx( Word16 exc_diffQ_fx[], Word32 L_Ener_per_bd_iQ[], Word32 L_Ener_per_bd_yQ[], const Word16 Q_out );
      33             : static void normalize_spec_fx( Word16 fac_up_fx, Word16 fy_norm_fx[], const Word16 L_frame, const Word16 Q_out );
      34             : static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Word16 dct_in_fx[], const Word16 Q_dct_in, Word16 dct_out_fx[], Word16 Q_dct_out, const Word16 pitch_fx[], const Word16 voice_fac, const Word16 clas, const Word16 coder_type );
      35             : 
      36             : /*-------------------------------------------------------------------*
      37             :  * NoiseFill_fx()
      38             :  *
      39             :  * noise fill function for unvoiced/inactive frames (used only in AMR-WB IO mode)
      40             :  *-------------------------------------------------------------------*/
      41             : 
      42           0 : static void NoiseFill_fx(
      43             :     Word16 *exc_diffQ_fx,   /* i/o: Noise per band                       Q_out*/
      44             :     Word16 *seed_tcx,       /* i  : Seed for noise                          Q0*/
      45             :     const Word16 Mbands_gn, /* i  : number of bands                         Q0*/
      46             :     const Word16 Q_out      /* i  : Q of exc_diffQ_fx[]                     */
      47             : )
      48             : {
      49             :     Word16 i_band, CurBin, EndBin;
      50             :     Word32 L_temp;
      51             :     Word16 fact;
      52           0 :     CurBin = 0;
      53           0 :     move16();
      54           0 :     fact = shr( 24576 /*0.75f in Q15*/, sub( 15, Q_out ) ); /* Q_out */
      55             : 
      56           0 :     FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
      57             :     {
      58           0 :         EndBin = add( CurBin, crit_bins[i_band] );
      59           0 :         FOR( ; CurBin < EndBin; CurBin++ )
      60             :         {
      61           0 :             L_temp = L_mult( Random( seed_tcx ), fact );            /* Q15 + Q_out + 1 */
      62           0 :             L_temp = L_msu( L_temp, exc_diffQ_fx[CurBin], -32768 ); /* Q15 + Q_out + 1*/
      63           0 :             exc_diffQ_fx[CurBin] = round_fx( L_temp );              /* Q_out */
      64           0 :             move16();
      65             :         }
      66             :     }
      67             : 
      68           0 :     return;
      69             : }
      70             : 
      71             : /*-------------------------------------------------------------------*
      72             :  * Ener_per_band_fx()
      73             :  *
      74             :  * Computed the energy per band (used only in AMR-WB IO mode)
      75             :  *-------------------------------------------------------------------*/
      76             : 
      77           0 : static void Ener_per_band_fx(
      78             :     const Word16 exc_diff_fx[], /* i  : target signal                     exp(exc_diff_exp)*/
      79             :     const Word16 exc_diff_exp,  /* i  : Exponent of exc_diff_fx                                                    */
      80             :     Word32 y_gain4_fx[]         /* o  : Energy per band to quantize                                             Q16*/
      81             : )
      82             : {
      83             :     const Word16 *ptr16;
      84             :     Word16 i, j;
      85             :     Word32 L_temp, L_temp2, L_epsilon;
      86             :     Word16 temp, exp;
      87             : 
      88           0 :     exp = shl( exc_diff_exp, 1 );
      89             :     /* To Get 0.01f in Q of (exc_diff_exp-1)^2 */
      90           0 :     L_epsilon = L_shr( 42949673L, sub( 32 + ENER_FX_Q_GUARD * 2, exp ) ); /* Q16 */
      91             : 
      92           0 :     ptr16 = exc_diff_fx;
      93           0 :     FOR( j = 0; j < CRIT_NOIS_BAND; j++ )
      94             :     {
      95           0 :         temp = shr( *ptr16++, ENER_FX_Q_GUARD );  /* Q15 - exc_diff_exp + Q1 */
      96           0 :         L_temp = L_mac0( L_epsilon, temp, temp ); /* Q16 */
      97           0 :         FOR( i = 1; i < crit_bins[j]; i++ )
      98             :         {
      99           0 :             temp = shr( *ptr16++, ENER_FX_Q_GUARD ); /* Q15 - exc_diff_exp + Q1 */
     100           0 :             L_temp = L_mac0( L_temp, temp, temp );   /* Q16 */
     101             :         }
     102           0 :         L_temp2 = L_mult0( 1, 6554 ); /* sqrt of 0.01f in Q16*/
     103           0 :         IF( L_temp != 0 )             /* avoid executing sqrt of 0 (because a div_s is used to invert and then call inv_sqrt) */
     104             :         {
     105           0 :             L_temp2 = Sqrt_Ratio32( L_temp, exp, 1, 0, &i );
     106           0 :             L_temp2 = L_shr_sat( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); /* Q16 */
     107             :         }
     108           0 :         y_gain4_fx[j] = L_temp2; /* Q16 */
     109           0 :         move32();
     110             :     }
     111             : 
     112           0 :     return;
     113             : }
     114             : 
     115             : 
     116             : /*-------------------------------------------------------------------*
     117             :  * Apply_gain_fx()
     118             :  *
     119             :  * Rescaling of the modified excitation vector (used only in AMR-WB IO mode)
     120             :  *-------------------------------------------------------------------*/
     121             : 
     122           0 : static void Apply_gain_fx(
     123             :     Word16 exc_diffQ_fx[],     /* i/o: Quantized excitation              Qx*/
     124             :     Word32 L_Ener_per_bd_iQ[], /* i  : Target ener per band              Q16*/
     125             :     Word32 L_Ener_per_bd_yQ[]  /* i  : Ener per band for norm vector     Qx*/
     126             :     ,
     127             :     const Word16 Q_out )
     128             : {
     129             :     Word16 i_band;
     130             :     Word16 CurBin, EndBin;
     131             :     Word16 y_gain_fx, y_gain_exp;
     132             :     Word16 exp3;
     133             :     Word32 L_temp;
     134             : 
     135             :     /*------------------------------------------------------------------
     136             :      * For all the bands
     137             :      * Find the energy ratio between modified vector and original vector
     138             :      *------------------------------------------------------------------*/
     139             : 
     140           0 :     CurBin = 0;
     141           0 :     move16();
     142           0 :     FOR( i_band = 0; i_band < CRIT_NOIS_BAND; i_band++ )
     143             :     {
     144           0 :         EndBin = add( CurBin, crit_bins[i_band] ); /* Q0 */
     145           0 :         y_gain_exp = norm_l( L_Ener_per_bd_yQ[i_band] );
     146           0 :         exp3 = norm_l( L_Ener_per_bd_iQ[i_band] );                                                                                                                                    /* use 'exp3' as temporary exponent of 'L_Ener_per_bd_iQ[]' */
     147           0 :         y_gain_fx = round_fx_sat( Div_flt32_flt32( L_shl_sat( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl_sat( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); /* y_gain_exp - 31 + Q_out */
     148           0 :         y_gain_exp = add( sub( y_gain_exp, 31 ), Q_out );
     149           0 :         exp3 = sub( y_gain_exp, 16 - 1 );
     150             : 
     151             :         /*------------------------------------------------------------------
     152             :          * For bands below 400 Hz or for unvoiced/inactive frames
     153             :          *   only apply the energy ratio
     154             :          *------------------------------------------------------------------*/
     155             :         {
     156           0 :             FOR( ; CurBin < EndBin; CurBin++ )
     157             :             {
     158           0 :                 L_temp = L_mult( exc_diffQ_fx[CurBin], y_gain_fx ); /* Q16 + Q_out + y_gain_exp */
     159           0 :                 L_temp = L_shr( L_temp, y_gain_exp );               /* Q_out + 16 */
     160           0 :                 exc_diffQ_fx[CurBin] = round_fx( L_temp );          /* Q_out  */
     161           0 :                 move16();
     162             :             }
     163             :         }
     164             :     }
     165             : 
     166           0 :     return;
     167             : }
     168             : 
     169             : /*-------------------------------------------------------------------*
     170             :  * normalize_spec_fx()
     171             :  *
     172             :  * Spectrum normalization (zeroed of bins below a certain threshold) (used only in AMR-WB IO mode)
     173             :  *-------------------------------------------------------------------*/
     174             : 
     175           0 : static void normalize_spec_fx(
     176             :     Word16 fac_up_fx,     /* i  : Core bitrate                                          (Q8)*/
     177             :     Word16 fy_norm_fx[],  /* i/o: Frequency quantized parameter         (Q8)*/
     178             :     const Word16 L_frame, /* i  : Section lenght                                          Q0*/
     179             :     const Word16 Q_out    /* i  : Q of fy_norm_fx[]                                             */
     180             : )
     181             : {
     182             :     Word16 idx, j;
     183             :     Word32 L_temp;
     184             :     Word16 temp, exp;
     185             : 
     186           0 :     idx = emaximum_fx( 0 /* Exponent is not Important */, fy_norm_fx, L_frame, &L_temp ); /* Q0 */
     187           0 :     exp = sub( Q_out, 8 /*Q8 of Fac Up/down*/ );
     188           0 :     temp = Invert16( abs_s( fy_norm_fx[idx] ), &exp ); /* Q15 + exp */
     189           0 :     L_temp = L_mult( temp, fac_up_fx );                /* Q15 + exp + Q8 + 1 */
     190           0 :     exp = sub( 15, exp );
     191           0 :     L_temp = L_shl_sat( L_temp, exp ); /* Q24 + Q_out */
     192           0 :     FOR( j = 0; j < L_frame; j++ )
     193             :     {
     194           0 :         fy_norm_fx[j] = round_fx( Mult_32_16( L_temp, fy_norm_fx[j] ) ); /* Q_out */
     195           0 :         move16();
     196             :     }
     197             : 
     198           0 :     return;
     199             : }
     200             : 
     201             : /*-------------------------------------------------------------------*
     202             :  * gs_dec_amr_wb_fx()
     203             :  *
     204             :  * Modification of decoded excitation vector depending of the content type (used only in AMR-WB IO mode)
     205             :  *-------------------------------------------------------------------*/
     206             : 
     207           0 : static void gs_dec_amr_wb_fx(
     208             :     const long core_brate,    /* i  : bitrate allocated to the core       Q0*/
     209             :     Word16 *seed_tcx,         /* i/o: seed used for noise generation      Q0*/
     210             :     const Word16 dct_in_fx[], /* i  : cdt of residual signal              Q_dct_in*/
     211             :     const Word16 Q_dct_in,    /* i  : Exponent of dct_in_fx               */
     212             :     Word16 dct_out_fx[],      /* o  : dct of pitch only excitation        Q_dct_out*/
     213             :     Word16 Q_dct_out,         /* o  : Exponent of dct_out_fx              */
     214             :     const Word16 pitch_fx[],  /* i  : pitch buffer                        Q6*/
     215             :     const Word16 voice_fac,   /* i  : gain pitch                                                 Q15*/
     216             :     const Word16 clas,        /* i  : signal frame class                  Q0*/
     217             :     const Word16 coder_type   /* i  : coder type                          Q0*/
     218             : )
     219             : {
     220             :     Word16 i, mDiff_len;
     221             :     Word16 exc_diffQ_fx[L_FRAME16k];
     222             :     Word32 Ener_per_bd_iQ_fx[CRIT_NOIS_BAND];
     223             :     Word32 Ener_per_bd_yQ_fx[CRIT_NOIS_BAND];
     224             :     Word16 temp, exp, temp2;
     225             :     Word32 L_temp;
     226             : 
     227             :     /*--------------------------------------------------------------------------------------*
     228             :      * compute the energy per band for the decoded excitation (in frequency domain)
     229             :      *--------------------------------------------------------------------------------------*/
     230             : 
     231           0 :     Ener_per_band_fx( dct_in_fx, Q_dct_in, Ener_per_bd_iQ_fx );
     232             : 
     233             :     /*--------------------------------------------------------------------------------------*
     234             :      * adjust quantization noise for the low level to compensate for the poor 6 bit gainQ
     235             :      *--------------------------------------------------------------------------------------*/
     236             : 
     237           0 :     IF( LT_32( core_brate, ACELP_12k65 ) )
     238             :     {
     239           0 :         temp = 0;
     240           0 :         move16();
     241           0 :         FOR( i = 0; i < CRIT_NOIS_BAND; i++ )
     242             :         {
     243           0 :             temp = s_max( round_fx_sat( Ener_per_bd_iQ_fx[i] ), temp ); /* Q0 */
     244             :         }
     245             : 
     246           0 :         test();
     247           0 :         test();
     248           0 :         IF( ( ( coder_type == INACTIVE ) || EQ_16( clas, VOICED_TRANSITION ) ) && LT_16( temp, 20 ) )
     249             :         {
     250           0 :             FOR( i = 0; i < CRIT_NOIS_BAND; i++ )
     251             :             {
     252           0 :                 Ener_per_bd_iQ_fx[i] = Mult_32_16( Ener_per_bd_iQ_fx[i], crit_bins_corr_fx[i] ); /* Q16 */
     253           0 :                 move32();
     254             :             }
     255             :         }
     256             :     }
     257             : 
     258             :     /*--------------------------------------------------------------------------------------*
     259             :      * Find the lenght of the temporal contribution, with a minimum contribution of 1.2kHz
     260             :      *--------------------------------------------------------------------------------------*/
     261           0 :     temp = s_min( pitch_fx[0], pitch_fx[1] ); /* Q6 */
     262           0 :     temp = s_min( temp, pitch_fx[2] );        /* Q6 */
     263           0 :     temp = s_min( temp, pitch_fx[3] );        /* Q6 */
     264             : 
     265             :     /* etmp14 = 12800.0f/(temp/16.0f)*8.0f */
     266           0 :     exp = 6; /* Pitch in Q6*/
     267           0 :     move16();
     268           0 :     temp = Invert16( temp, &exp );                       /* Q15 */
     269           0 :     L_temp = L_mult( temp, 12800 );                      /* Q15 */
     270           0 :     L_temp = L_shl( L_temp, sub( 3, exp ) ); /* *8.0f */ /* Q15 */
     271           0 :     if ( GE_32( core_brate, ACELP_12k65 ) )
     272             :     {
     273           0 :         L_temp = L_shl( L_temp, 1 ); /* Q16 */
     274             :     }
     275             : 
     276             :     /* (Word16)(etmp14+0.5f) */
     277           0 :     mDiff_len = round_fx( L_temp ); /* Q0 */
     278             : 
     279           0 :     temp = 32767;
     280           0 :     move16();
     281           0 :     L_temp = L_deposit_l( 0 );
     282           0 :     FOR( i = 0; i < CRIT_NOIS_BAND; i++ )
     283             :     {
     284           0 :         temp2 = sub( crit_bands_loc_fx[i], mDiff_len ); /* Q0 */
     285           0 :         temp2 = abs_s( temp2 );                         /* Q0 */
     286           0 :         if ( GT_16( temp, temp2 ) )
     287             :         {
     288           0 :             L_temp = L_msu( L_temp, crit_bins[i], -32768 ); /* Q16 */
     289             :         }
     290           0 :         temp = s_min( temp, temp2 ); /* Q0 */
     291             :     }
     292             : 
     293           0 :     mDiff_len = s_max( round_fx( L_temp ), BIN_1k2 ); /* Q0 */
     294             : 
     295             : 
     296             :     {
     297           0 :         Copy( dct_in_fx, exc_diffQ_fx, mDiff_len ); /* Q_dct_in */
     298           0 :         set16_fx( exc_diffQ_fx + mDiff_len, 0, sub( L_FRAME, mDiff_len ) );
     299             : 
     300             :         /* normalization of the spectrum and noise fill*/
     301           0 :         normalize_spec_fx( 4 * 256, exc_diffQ_fx, mDiff_len, NORMALIZE_SPECS_Q_OUT ); /* Factors in Q8 */
     302             :     }
     303           0 :     NoiseFill_fx( exc_diffQ_fx, seed_tcx, CRIT_NOIS_BAND, NORMALIZE_SPECS_Q_OUT );
     304             :     /*--------------------------------------------------------------------------------------*
     305             :      * Recompute energy per band of the modified excitation vector (in frequency domain)
     306             :      *--------------------------------------------------------------------------------------*/
     307             : 
     308           0 :     Ener_per_band_fx( exc_diffQ_fx, NORMALIZE_SPECS_Q_OUT, Ener_per_bd_yQ_fx );
     309             : 
     310             :     /*--------------------------------------------------------------------------------------*
     311             :      * Compute tilt factor and amplify HF accordingly
     312             :      *--------------------------------------------------------------------------------------*/
     313             : 
     314           0 :     temp = mult_r( sub( 32767 /* 1.0 in Q15 */, voice_fac ), 16384 /* 0.5 in Q15 */ ); /*  Q15 */
     315           0 :     FOR( i = 240; i < L_FRAME; i++ )
     316             :     {
     317           0 :         temp2 = msu_r( -7680 * 65536, -17564, shl( i, 6 ) );     /*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */
     318           0 :         temp2 = mult_r( temp2, temp );                           /* Q15*Q9+1-16 -> Q9 */
     319           0 :         L_temp = L_mult( exc_diffQ_fx[i], s_max( temp2, 512 ) ); /*Q(Qexc_diffQ+10) */
     320           0 :         exc_diffQ_fx[i] = round_fx( L_shl( L_temp, 16 - 10 ) );  /*Qexc_diffQ */
     321           0 :         move16();
     322             :     }
     323             : 
     324             :     /*--------------------------------------------------------------------------------------*
     325             :      * Match the energy of the modified excitation vector to the decoded excitation
     326             :      *--------------------------------------------------------------------------------------*/
     327           0 :     Apply_gain_fx( exc_diffQ_fx, Ener_per_bd_iQ_fx, Ener_per_bd_yQ_fx, sub( NORMALIZE_SPECS_Q_OUT, Q_dct_out ) );
     328             :     /*--------------------------------------------------------------------------------------*
     329             :      * Copy to the output vector
     330             :      *--------------------------------------------------------------------------------------*/
     331             : 
     332           0 :     Copy( exc_diffQ_fx, dct_out_fx, L_FRAME ); /* Q_dct_out */
     333             : 
     334           0 :     return;
     335             : }
     336             : 
     337             : /*-------------------------------------------------------------------*
     338             :  * improv_amr_wb_gs_fx()
     339             :  *
     340             :  * Modify the decoded excitation to increase quality of
     341             :  * unvoiced and audio signals (used only in AMR-WB IO mode)
     342             :  *-------------------------------------------------------------------*/
     343           0 : void improv_amr_wb_gs_fx(
     344             :     const Word16 clas,                 /* i  : signal frame class                                       Q0*/
     345             :     const Word16 coder_type,           /* i  : coder type                                                       Q0*/
     346             :     const Word32 core_brate,           /* i  : bitrate allocated to the core            Q0*/
     347             :     Word16 *seed_tcx,                  /* i/o: Seed used for noise generation           Q0*/
     348             :     Word16 *old_Aq_fx,                 /* i/o: old LPC filter coefficient                       q_old_Aq*/
     349             :     Word16 *mem_syn2_fx,               /* i/o: synthesis memory                    Q_syn*/
     350             :     const Word16 lt_voice_fac_fx,      /* i/o: long term voice factor                      Q14*/
     351             :     const Word16 locattack,            /* i  : Flag for a detected attack          Q0*/
     352             :     Word16 *Aq_fx,                     /* i/o: Decoded LP filter coefficient       q_Aq*/
     353             :     Word16 *exc2_fx,                   /* i/o: Decoded complete excitation         Q_exc2*/
     354             :     const Word16 Q_exc2,               /* i  : Exponent of Exc2                                           */
     355             :     Word16 *mem_tmp_fx,                /* i/o: synthesis temporary memory                  Q_syn*/
     356             :     Word16 *syn_fx,                    /*   o: Decoded synthesis to be updated     Q_syn*/
     357             :     const Word16 Q_syn,                /* i  : Synthesis scaling                                          */
     358             :     const Word16 *pitch_buf_fx,        /* i  : Decoded pitch buffer                                 Q6*/
     359             :     const Word16 Last_ener_fx,         /* i  : Last energy (Q8)                     Q0*/
     360             :     const Word16 rate_switching_reset, /* i  : rate switching reset flag            Q0*/
     361             :     const Word16 last_coder_type       /* i  : Last coder_type                      Q0*/
     362             : )
     363             : {
     364             :     Word16 i, exp_a, exp_b, exp_diff, j;
     365             :     Word16 dct_exc_in_fx[L_FRAME], dct_exc_out_fx[L_FRAME];
     366             :     Word16 Aq_orig[NB_SUBFR * ( M + 1 )], enr_LP_old, enr_LP_new;
     367             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     368           0 :     Flag Overflow = 0;
     369           0 :     move32();
     370             : #endif
     371             : 
     372             :     /*------------------------------------------------------------*
     373             :      * Condition to enter the section on excitation modification
     374             :      *------------------------------------------------------------*/
     375             : 
     376             :     /* Enter the modification for all inactive frames and also for unvoiced frames if bit rate is below 8k85 */
     377             : 
     378           0 :     test();
     379           0 :     test();
     380           0 :     test();
     381           0 :     test();
     382           0 :     test();
     383           0 :     test();
     384           0 :     IF( ( locattack == 0 && LE_32( core_brate, ACELP_12k65 ) ) &&
     385             :         ( ( LT_32( core_brate, ACELP_8k85 ) && NE_16( clas, AUDIO_CLAS ) &&
     386             :             ( ( clas == UNVOICED_CLAS ) || EQ_16( clas, VOICED_TRANSITION ) ) ) ||
     387             :           ( EQ_16( coder_type, INACTIVE ) ) ) )
     388             :     {
     389             :         /*------------------------------------------------------------*
     390             :          * two differents paths:
     391             :          *   unvoiced or inactive
     392             :          *   generic audio sound
     393             :          * LP filter smoothing for inactive parts
     394             :          *------------------------------------------------------------*/
     395           0 :         *seed_tcx = extract_l( L_mult0( pitch_buf_fx[0], pitch_buf_fx[3] ) ); /* Q0 */
     396           0 :         move16();
     397             :         /* last_coder_type == UNVOICED should be understand as INACTIVE, but it is forced to UNVOICED in update_dec */
     398           0 :         test();
     399           0 :         test();
     400           0 :         test();
     401           0 :         IF( EQ_16( coder_type, INACTIVE ) && GT_16( Last_ener_fx, -3 * 256 ) && EQ_16( last_coder_type, UNVOICED ) && rate_switching_reset == 0 ) /* 3.0 x 256 to Go to Q8 */
     402             :         {
     403             : 
     404           0 :             FOR( i = 0; i < NB_SUBFR; i++ )
     405             :             {
     406           0 :                 Copy( Aq_fx, Aq_orig, NB_SUBFR * ( M + 1 ) ); /* q_Aq */
     407             : 
     408           0 :                 exp_a = norm_s( Aq_fx[i * ( M + 1 )] );
     409           0 :                 exp_b = norm_s( old_Aq_fx[i * ( M + 1 )] );
     410           0 :                 exp_diff = sub( exp_a, exp_b );
     411           0 :                 IF( exp_diff > 0 )
     412             :                 {
     413           0 :                     Scale_sig( &old_Aq_fx[i * ( M + 1 )], ( M + 1 ), negate( exp_diff ) ); /* exp_b */
     414             :                 }
     415             :                 ELSE
     416             :                 {
     417           0 :                     Scale_sig( &Aq_fx[i * ( M + 1 )], ( M + 1 ), exp_diff ); /* exp_a */
     418             :                 }
     419           0 :                 FOR( j = i * ( M + 1 ); j < ( i + 1 ) * ( M + 1 ); j++ )
     420             :                 {
     421             : 
     422           0 :                     Aq_fx[j] = round_fx( L_mac( L_mult( ALP_FX, old_Aq_fx[j] ), MALP_FX, Aq_fx[j] ) ); /* q_Aq */
     423           0 :                     move16();
     424             :                 }
     425             :             }
     426             : 
     427             :             /* check the smoothed LP filter stability */
     428           0 :             enr_LP_old = Enr_1_Az_fx( old_Aq_fx, L_SUBFR ); /* Q3 */
     429           0 :             Overflow = 0;
     430           0 :             move16();
     431             : 
     432           0 :             FOR( i = 0; i < NB_SUBFR; i++ )
     433             :             {
     434           0 :                 enr_LP_new = Enr_1_Az_fx_o( Aq_fx + imult1616( i, ( M + 1 ) ), L_SUBFR, &Overflow ); /* Q3 */
     435           0 :                 test();
     436           0 :                 IF( GT_16( shr( enr_LP_new, 7 ), enr_LP_old ) || Overflow )
     437             :                 {
     438             :                     /* filter is unstable, do not modify the excitation */
     439           0 :                     Copy( Aq_orig, Aq_fx, NB_SUBFR * ( M + 1 ) ); /* q_Aq */
     440           0 :                     Overflow = 0;
     441           0 :                     move16();
     442             : 
     443           0 :                     return;
     444             :                 }
     445             : 
     446           0 :                 enr_LP_old = enr_LP_new; /* Q3 */
     447           0 :                 move16();
     448             :             }
     449             :         }
     450             : 
     451             :         /*------------------------------------------------------------*
     452             :          * Find frequency representation of the excitation
     453             :          * Do the excitation modification according to the content
     454             :          * Go back to time domain -> Overwrite exctiation
     455             :          *------------------------------------------------------------*/
     456           0 :         edct_16fx( exc2_fx, dct_exc_in_fx, L_FRAME, 6, EVS_MONO );
     457           0 :         gs_dec_amr_wb_fx( core_brate, seed_tcx, dct_exc_in_fx, Q_exc2, dct_exc_out_fx, Q_exc2, pitch_buf_fx, lt_voice_fac_fx, clas, coder_type );
     458             : 
     459           0 :         edct_16fx( dct_exc_out_fx, exc2_fx, L_FRAME, 6, EVS_MONO );
     460             :         /*------------------------------------------------------------*
     461             :          * Redo core synthesis at 12k8 Hz with the modified excitation
     462             :          *------------------------------------------------------------*/
     463             : 
     464           0 :         Copy( mem_tmp_fx, mem_syn2_fx, M ); /* Q_syn */
     465           0 :         syn_12k8_fx( L_FRAME, Aq_fx, exc2_fx, syn_fx, mem_syn2_fx, 1, Q_exc2, Q_syn );
     466             :     }
     467             : 
     468           0 :     return;
     469             : }

Generated by: LCOV version 1.14