Commit 7993a4ff authored by vaillancour's avatar vaillancour
Browse files

possible small complexity reduction and precision improvement

parent a185318f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -175,4 +175,7 @@
#define NONBE_FIX_1402_WAVEADJUST               /* VA: BASOP iisue 1402: fix waveform adjustment decoder PLC */
#define FIX_ISSUE_1376                          /* VA: Fix for issue 1376 (issue with GSC excitation) */
#define OPT_SBA_AVOID_SPAR_RESCALE              /* Optimization made to spar decoder and IGF */

#define IMPROV_PRECISION                        /* Place where precision can be cost free improved */
#define IMPROV_PRECISION_EVSBE                  /* Place where precision can be cost free improved, might affect EVS BE */
#endif
+13 −1
Original line number Diff line number Diff line
@@ -2732,16 +2732,28 @@ void stereoFdCngCoherence_fx(
        move16();
        move16();

#ifdef IMPROV_PRECISION_EVSBE
        cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_mac( L_mult( pt_fftL[0], pt_fftR[0] ), pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
        eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mac( L_mult( pt_fftL[0], pt_fftL[0] ), pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
        eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mac( L_mult( pt_fftR[0], pt_fftR[0] ), pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */
#else
        cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */
        eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */
        eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */

#endif
        FOR( i = 1; i < L_FFT / 2; i++ )
        {
#ifdef IMPROV_PRECISION_EVSBE
            cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_mac( L_mult( pt_fftL[i], pt_fftR[i] ), pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ), shl( fft_exp, 1 ), &cr_exp );  /* exp(cr_exp) */
            ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_mac( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), pt_fftL[L_FFT - i], pt_fftR[i] ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */
            eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mac( L_mult( pt_fftL[i], pt_fftL[i] ), pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ), shl( fft_exp, 1 ), &eL_exp );  /* exp(eL_exp) */
            eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mac( L_mult( pt_fftR[i], pt_fftR[i] ), pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ), shl( fft_exp, 1 ), &eR_exp );  /* exp(eR_exp) */
#else
            cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp );  /* exp(cr_exp) */
            ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */
            eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp );  /* exp(eL_exp) */
            eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp );  /* exp(eR_exp) */
#endif
        }
        test();
        test();
+8 −0
Original line number Diff line number Diff line
@@ -295,7 +295,11 @@ void ivas_param_ism_stereo_dmx_fx(
        {
            tmp = L_add( tmp, 2 * EVS_PI_FX );
        }
#ifdef IMPROV_PRECISION
        cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14
#else
        cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14
#endif
        move16();

        IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 )
@@ -303,7 +307,11 @@ void ivas_param_ism_stereo_dmx_fx(
            Word16 last_cardioid_right;
            last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left );
            /* Smoothing */
#ifdef IMPROV_PRECISION 
            cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ) ; // Q14
#else
            cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14
#endif
            move16();
            Word32 grad_32 = L_mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14+Q16 = Q30 */ /* for the right cardioid, multiply with -1 */
            /* Cardioids sum up to 1 */
+4 −0
Original line number Diff line number Diff line
@@ -1476,7 +1476,11 @@ static void ivas_omasa_dmx_fx(
                    g1 = interpolator[k];
                    move16();
                    g2 = sub( MAX_WORD16, g1 );                                                                                                                    /*q15*/
#ifdef IMPROV_PRECISION_EVSBE
                    data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/
#else
                    data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_add( L_mult( g1, gains[j] ), L_mult( g2, prev_gains[i][j] ) ) /*q31*/, data_in[i][k] ) ); /*Qx*/
#endif
                    move32();
                }
            }
+16 −0
Original line number Diff line number Diff line
@@ -400,9 +400,15 @@ void tdm_configure_enc_fx(

    hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */
    move16();
#ifdef IMPROV_PRECISION
    sts[0]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx );
    move16();
    sts[1]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx );
#else
    sts[0]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), mult( 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ) );
    move16();
    sts[1]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), mult( 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ) );
#endif
    move16();

    test();
@@ -799,11 +805,21 @@ static void tdm_downmix_plain_ivas_fx(
)
{
    Word16 i;
#ifdef IMPROV_PRECISION
    Word16 One_m_Ratio_fx16, ratio_L_fx16;
    One_m_Ratio_fx16 = extract_h( One_m_Ratio_fx );
    ratio_L_fx16 = extract_h( ratio_L_fx );
#endif

    FOR( i = start_index; i < end_index; i++ )
    {
#ifdef IMPROV_PRECISION
        FR_Y_fx[i] = mac_r( L_mult( Right_in_fx[i], One_m_Ratio_fx16 ), Left_in_fx[i], ratio_L_fx16 );
        LR_X_fx[i] = msu_r( L_mult( Left_in_fx[i], One_m_Ratio_fx16 ), Right_in_fx[i], ratio_L_fx16 );
#else
        FR_Y_fx[i] = add( mult( Right_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Left_in_fx[i], extract_h( ratio_L_fx ) ) );
        LR_X_fx[i] = sub( mult( Left_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Right_in_fx[i], extract_h( ratio_L_fx ) ) );
#endif
        move16();
        move16();
    }
Loading