Commit 166b854a authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'switch_div32_newton_part01' into 'main'

lib_rend: replace BASOP_Util_Divide3232_Scale_cadence() by BASOP_Util_Divide3232_Scale_newton() [allow regression]

See merge request !1388
parents 7e04acdc 9c875e06
Loading
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -1658,7 +1658,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        move32();

        /* Formulate average diffuseness over frame */
        frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1
        frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_newton( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1
        exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) );
        hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29
        move32();
@@ -1690,7 +1690,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        move16();
        den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e );
        den = L_max( 1, den );
        IIReneLimiter_fx = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
        IIReneLimiter_fx = BASOP_Util_Divide3232_Scale_newton( num, den, &exp );
        exp = add( sub( num_e, den_e ), add( 5, exp ) );
        IF( L_shr_sat( IIReneLimiter_fx, sub( 31, exp ) ) > 0 )
        {
@@ -3313,7 +3313,7 @@ static void eig2x2_fx(
            tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );

#if 1
            tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp );
            tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
            exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
            normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
            q_tmp2 = sub( 31, exp );
@@ -3389,7 +3389,7 @@ static void eig2x2_fx(
            tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );

#if 1
            tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp );
            tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
            exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
            normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
            q_tmp2 = sub( 31, exp );
@@ -3734,11 +3734,11 @@ static void chol2x2_fx(
        // 4611686 = 1e-12 in Q62
        IF( outRe[0][0] == 0 )
        {
            outRe[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
            outRe[1][0] = BASOP_Util_Divide3232_Scale_newton( c_re, 4611686, &exp );
            move32();
            q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );

            outIm[1][0] = BASOP_Util_Divide3232_Scale_cadence( c_im, 4611686, &exp );
            outIm[1][0] = BASOP_Util_Divide3232_Scale_newton( c_im, 4611686, &exp );
            move32();
            q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
        }
@@ -3795,7 +3795,7 @@ static void chol2x2_fx(
        }
        ELSE
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( temp, e1, &exp );
            temp = BASOP_Util_Divide3232_Scale_newton( temp, e1, &exp );
            q_tmp = add( sub( 31, exp ), sub( q_tmp, q_e ) );
        }
        if ( temp == 0 )
@@ -3840,7 +3840,7 @@ static void chol2x2_fx(
        // 4611686 = Q62
        IF( outRe[1][1] == 0 )
        {
            // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, 4611686, &exp );
            // outRe[0][1] = BASOP_Util_Divide3232_Scale_newton( c_re, 4611686, &exp );
            Word32 tmp1 = 1953125005; /* 1/4611686 Q62 */
            exp = 9;

@@ -3848,7 +3848,7 @@ static void chol2x2_fx(
            move32();
            q_re2 = add( sub( 31, exp ), sub( q_c, 62 ) );

            // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, 4611686, &exp );
            // outIm[0][1] = BASOP_Util_Divide3232_Scale_newton( -c_im, 4611686, &exp );
            outIm[0][1] = Mpy_32_32( tmp1, -c_im );
            move32();
            q_im = add( sub( 31, exp ), sub( q_c, 62 ) );
@@ -3856,13 +3856,13 @@ static void chol2x2_fx(
        ELSE
        {
            {
                // outRe[0][1] = BASOP_Util_Divide3232_Scale_cadence( c_re, outRe[1][1], &exp );
                Word32 tmp1 = BASOP_Util_Divide3232_Scale_cadence( 0x7FFFFFFF, outRe[1][1], &exp );
                // outRe[0][1] = BASOP_Util_Divide3232_Scale_newton( c_re, outRe[1][1], &exp );
                Word32 tmp1 = BASOP_Util_Divide3232_Scale_newton( 0x7FFFFFFF, outRe[1][1], &exp );
                outRe[0][1] = Mpy_32_32( tmp1, c_re );
                move32();
                q_re2 = add( sub( 31, exp ), sub( q_c, q_re1 ) );

                // outIm[0][1] = BASOP_Util_Divide3232_Scale_cadence( -c_im, outRe[1][1], &exp );
                // outIm[0][1] = BASOP_Util_Divide3232_Scale_newton( -c_im, outRe[1][1], &exp );
                outIm[0][1] = Mpy_32_32( tmp1, -c_im );
                move32();
                q_im = add( sub( 31, exp ), sub( q_c, q_re1 ) );
@@ -3885,12 +3885,12 @@ static void chol2x2_fx(
        // 4611686 = 1e-12 in Q62
        IF( e2 == 0 )
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( temp, 4611686, &exp );
            temp = BASOP_Util_Divide3232_Scale_newton( temp, 4611686, &exp );
            q_tmp = add( sub( 31, exp ), sub( q_tmp, 62 ) );
        }
        ELSE
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( temp, e2, &exp );
            temp = BASOP_Util_Divide3232_Scale_newton( temp, e2, &exp );
            q_tmp = add( sub( 31, exp ), sub( q_tmp, q_e ) );
        }
        if ( temp == 0 )
@@ -4038,7 +4038,7 @@ static void formulate2x2MixingMatrix_fx(
    }
    ELSE
    {
        maxEneDiv_fx = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, maxEne_fx, &exp );
        maxEneDiv_fx = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, maxEne_fx, &exp );
        q_maxEneDiv = add( sub( 31, exp ), sub( Q30, q_maxEne ) );
    }
    exp = norm_l( maxEneDiv_fx );
@@ -4103,7 +4103,7 @@ static void formulate2x2MixingMatrix_fx(
        }
        ELSE
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, 4611686, &exp ); // 4611686 = Q62
            temp = BASOP_Util_Divide3232_Scale_newton( E_out1, 4611686, &exp ); // 4611686 = Q62
            exp = sub( exp, sub( q_eout, 62 ) );
            Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
        }
@@ -4112,7 +4112,7 @@ static void formulate2x2MixingMatrix_fx(
    {
        temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp );

        temp = BASOP_Util_Divide3232_Scale_cadence( E_out1, temp, &exp );
        temp = BASOP_Util_Divide3232_Scale_newton( E_out1, temp, &exp );
        exp = sub( exp, sub( q_eout, sub( 31, exp_temp ) ) );
        Ghat_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
    }
@@ -4130,7 +4130,7 @@ static void formulate2x2MixingMatrix_fx(
        }
        ELSE
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, 4611686, &exp1 ); // 4611686 = Q62
            temp = BASOP_Util_Divide3232_Scale_newton( E_out2, 4611686, &exp1 ); // 4611686 = Q62
            exp1 = sub( exp1, sub( q_eout, 62 ) );
            Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
        }
@@ -4139,7 +4139,7 @@ static void formulate2x2MixingMatrix_fx(
    {
        temp = BASOP_Util_Add_Mant32Exp( temp, sub( 31, q_ein ), EPSILON_MANT, EPSILON_EXP, &exp_temp );

        temp = BASOP_Util_Divide3232_Scale_cadence( E_out2, temp, &exp1 );
        temp = BASOP_Util_Divide3232_Scale_newton( E_out2, temp, &exp1 );
        exp1 = sub( exp1, sub( q_eout, sub( 31, exp_temp ) ) );
        Ghat_fx[1] = Sqrt32( temp, &exp1 ); // Q = 31 - exp1
    }
@@ -4198,7 +4198,7 @@ static void formulate2x2MixingMatrix_fx(
    }
    ELSE
    {
        temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, D_fx[0], &exp );
        temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, D_fx[0], &exp );
        exp = sub( exp, sub( Q30, q_D ) );
    }
    div_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
@@ -4331,7 +4331,7 @@ static void formulate2x2MixingMatrix_fx(
                Word16 Pre_shift, Pim_shift;
                temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp );

                temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp );
                temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, temp, &exp );
                Pre_shift = norm_l( Pre_fx[chA][chB] );
                Pim_shift = norm_l( Pim_fx[chA][chB] );
                Pre_fx[chA][chB] = Mpy_32_32( L_shl( Pre_fx[chA][chB], Pre_shift ), temp );
@@ -4375,7 +4375,7 @@ static void formulate2x2MixingMatrix_fx(
        {
            Word16 Pre_shift, Pim_shift;
            temp = BASOP_Util_Add_Mant32Exp( Sx_fx[chB], sub( 31, q_Sx ), EPSILON_MANT, EPSILON_EXP, &exp_temp );
            temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, temp, &exp );
            temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, temp, &exp );
            q_temp = add( sub( sub( q_P, exp ), sub( 31, Q30 ) ), exp_temp );

            Pre_shift = norm_l( Pre_fx[0][chB] );
+10 −10
Original line number Diff line number Diff line
@@ -2097,7 +2097,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            move16();
            exp1 = 0;
            move16();
            tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ),
            tmp32 = BASOP_Util_Divide3232_Scale_newton( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ),
                                                        ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
                                                        &exp1 );
            target_power_y = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp))
@@ -2108,7 +2108,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            move16();
            exp1 = 0;
            move16();
            tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ),
            tmp32 = BASOP_Util_Divide3232_Scale_newton( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ),
                                                        ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp)
                                                        &exp1 );
            target_power_y1 = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp))
@@ -2268,7 +2268,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) )
            {
                p_power_smooth_prev++;
                L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, EPSILON_FX, &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
                L_tmp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q31, EPSILON_FX, &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
                exp_arr[k * num_freq_bands + l] = exp;
                move16();

@@ -2277,7 +2277,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            }
            ELSE
            {
                L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
                L_tmp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/
                exp_arr[k * num_freq_bands + l] = exp;
                move16();

@@ -2495,7 +2495,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

            exp = 0;
            move16();
            L_tmp = BASOP_Util_Divide3232_Scale_cadence( *( p_cy_auto_diff_smooth_prev++ ), ( *( p_power_diff_smooth_prev++ ) ), &exp ); // (Q31 - exp) + (q_a - q_b)
            L_tmp = BASOP_Util_Divide3232_Scale_newton( *( p_cy_auto_diff_smooth_prev++ ), ( *( p_power_diff_smooth_prev++ ) ), &exp ); // (Q31 - exp) + (q_a - q_b)
            exp = sub( Q31, add( sub( Q31, exp ), sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ) ) );

            *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); // (31 - exp)
@@ -3982,7 +3982,7 @@ void ivas_lfe_synth_with_filters_fx(
        }
        ELSE
        {
            lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_cadence( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/
            lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/
            lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp );
            lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp
            lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp );   // Q15
+5 −5
Original line number Diff line number Diff line
@@ -2693,7 +2693,7 @@ void protoSignalComputation2_fx(
            move16();
        }
        q_lr_bb_power = sub( q_lr_bb_power, 1 );                                                                                       /* = (lr_bb_power_fx * 2) */
        temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power))
        temp = BASOP_Util_Divide3232_Scale_newton( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power))
        exp = sub( 31, add( sub( 31, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) );
        temp = BASOP_Util_Log2( temp ); // q25
        IF( NE_32( temp, MIN_32 ) )
@@ -2742,7 +2742,7 @@ void protoSignalComputation2_fx(
            q_lr_hi_power = stereo_type_detect->q_right_hi_power;
        }
        q_lr_hi_power = sub( q_lr_hi_power, 1 );                                                                                       /* = (q_lr_hi_power * 2) */
        temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power)
        temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power)
        exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) );
        temp = BASOP_Util_Log2( temp ); // q25
        IF( NE_32( temp, MIN_32 ) )
@@ -3420,7 +3420,7 @@ void computeDirectionAngles_fx(
        }
        ELSE
        {
            temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, intensityNorm, &exp ); // Q=31-(exp-(30-q_intensityNorm))
            temp = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, intensityNorm, &exp ); // Q=31-(exp-(30-q_intensityNorm))
            exp = sub( exp, sub( Q30, q_intensityNorm ) );
            temp = Sqrt32( temp, &exp ); // Q=31-exp
            q_temp = sub( 31, exp );
+7 −7
Original line number Diff line number Diff line
@@ -140,22 +140,22 @@ static void QuaternionDivision_fx(
{
    Word16 scale_e, result_e = 0, w_q, x_q, y_q, z_q, result_q;

    r->w_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.w_fx ), d, &scale_e );
    r->w_fx = BASOP_Util_Divide3232_Scale_newton( ( q.w_fx ), d, &scale_e );
    move32();
    result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) ); // e+e1-e2//
    w_q = sub( Q31, result_e );

    r->x_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.x_fx ), d, &scale_e );
    r->x_fx = BASOP_Util_Divide3232_Scale_newton( ( q.x_fx ), d, &scale_e );
    move32();
    result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
    x_q = sub( Q31, result_e );

    r->y_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.y_fx ), d, &scale_e );
    r->y_fx = BASOP_Util_Divide3232_Scale_newton( ( q.y_fx ), d, &scale_e );
    move32();
    result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
    y_q = sub( Q31, result_e );

    r->z_fx = BASOP_Util_Divide3232_Scale_cadence( ( q.z_fx ), d, &scale_e );
    r->z_fx = BASOP_Util_Divide3232_Scale_newton( ( q.z_fx ), d, &scale_e );
    move32();
    result_e = add( scale_e, sub( sub( Q31, q.q_fact ), den_e ) );
    z_q = sub( Q31, result_e );
@@ -505,15 +505,15 @@ static IVAS_VECTOR3 VectorNormalize_fx(
    move16();
    length_fx = VectorLength_fx( p, &q_len );

    result_fx.x_fx = BASOP_Util_Divide3232_Scale_cadence( p.x_fx, length_fx, &scale );
    result_fx.x_fx = BASOP_Util_Divide3232_Scale_newton( p.x_fx, length_fx, &scale );
    move32();
    x_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) ); // e+(e1-e2)//

    result_fx.y_fx = BASOP_Util_Divide3232_Scale_cadence( p.y_fx, length_fx, &scale );
    result_fx.y_fx = BASOP_Util_Divide3232_Scale_newton( p.y_fx, length_fx, &scale );
    move32();
    y_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) );

    result_fx.z_fx = BASOP_Util_Divide3232_Scale_cadence( p.z_fx, length_fx, &scale );
    result_fx.z_fx = BASOP_Util_Divide3232_Scale_newton( p.z_fx, length_fx, &scale );
    move32();
    z_qfact = sub( Q31, add( scale, sub( q_len, p.q_fact ) ) );

+11 −11
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ static void response_step_limit_fx(

        IF( X[i] )
        {
            desiredChange = BASOP_Util_Divide3232_Scale_cadence( X[i], X[i - 1], &div_e );
            desiredChange = BASOP_Util_Divide3232_Scale_newton( X[i], X[i - 1], &div_e );
            desiredChange_q = sub( 31, ( div_e ) );
        }

@@ -459,7 +459,7 @@ static void response_step_limit_fx(

        IF( X[i] )
        {
            desiredChange = BASOP_Util_Divide3232_Scale_cadence( X[i], X[i + 1], &div_e );
            desiredChange = BASOP_Util_Divide3232_Scale_newton( X[i], X[i + 1], &div_e );
            desiredChange_q = sub( 31, ( div_e ) );
        }
        IF( GT_16( desiredChange_q, 30 ) )
@@ -742,9 +742,9 @@ void ivas_reverb_calc_color_levels_fx(
            move16();
            cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) );                                                                                                                 // q = 15
            H_filter = L_add( L_shr( L_add( L_shr( Mpy_32_32( coefB[0], coefB[0] ), 1 ), L_shr( Mpy_32_32( coefB[1], coefB[1] ), 1 ) ), 2 ), L_shr( Mpy_32_32( coefB[0], Mpy_32_32( coefB[1], L_shl( cos_w, 15 ) ) ), 1 ) ); // q = 28
            H_filter = BASOP_Util_Divide3232_Scale_cadence( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp );
            H_filter = BASOP_Util_Divide3232_Scale_newton( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp );
            H_filter = Sqrt32( H_filter, &temp );
            T60_est = BASOP_Util_Divide3232_Scale_cadence( L_shl( i_mult( -3, pLoop_delays[loop_idx] ), 2 ), Mpy_32_32( Mpy_32_32( L_add( BASOP_Util_Log2( H_filter ), L_shl( temp, 25 ) ), LOG10_2_Q31 ), L_shl( output_Fs, 8 ) ), &temp ); // conversion of log2 to log10.
            T60_est = BASOP_Util_Divide3232_Scale_newton( L_shl( i_mult( -3, pLoop_delays[loop_idx] ), 2 ), Mpy_32_32( Mpy_32_32( L_add( BASOP_Util_Log2( H_filter ), L_shl( temp, 25 ) ), LOG10_2_Q31 ), L_shl( output_Fs, 8 ) ), &temp ); // conversion of log2 to log10.
            t60[freq_idx] = BASOP_Util_Add_Mant32Exp( T60_est, temp, t60[freq_idx], t60_e[freq_idx], &result_e );
            move16();
            t60_e[freq_idx] = result_e;
@@ -775,14 +775,14 @@ void ivas_reverb_calc_color_levels_fx(
    {
        Word16 temp, temp1, temp2, temp3 = 0, temp4, temp5;
        move16();
        Word32 var1 = BASOP_Util_Divide3232_Scale_cadence( (Word32) i_mult( -6, minDelay ), L_shr( Mpy_32_32( t60[freq_idx], L_shl( output_Fs, 11 ) ), sub( 11, t60_e[freq_idx] ) ), &temp );
        Word32 var1 = BASOP_Util_Divide3232_Scale_newton( (Word32) i_mult( -6, minDelay ), L_shr( Mpy_32_32( t60[freq_idx], L_shl( output_Fs, 11 ) ), sub( 11, t60_e[freq_idx] ) ), &temp );
        var1 = Mpy_32_32( var1, LOG2_10_Q29 ); // e = temp + (31 - 29)
        Word32 A0_square_est = BASOP_util_Pow2( var1, add( temp, 31 - 29 ), &temp );
        Word16 alpha_e;
        Word32 alpha = BASOP_Util_Divide3232_Scale_cadence( -log__0_001, t60[freq_idx], &alpha_e ); // alpha_e  = 1 + alpha_e + (3 - t60_e[257])
        Word32 alpha = BASOP_Util_Divide3232_Scale_newton( -log__0_001, t60[freq_idx], &alpha_e ); // alpha_e  = 1 + alpha_e + (3 - t60_e[257])

        Word32 div11 = BASOP_Util_Divide3232_Scale_cadence( A0_square_est, alpha, &temp1 );                                                                                    // e = temp1 + (temp - alpha_e)
        Word32 div2 = BASOP_Util_Divide3232_Scale_cadence( L_shl( output_Fs, 11 ), L_shr( L_add( Mpy_32_16_1( 1884631649, shl( minDelayDiff, 3 ) ), 14037339 ), 8 ), &temp2 ); // e = temp2, 26.7741 in Q19, 0.8776 in Q31
        Word32 div11 = BASOP_Util_Divide3232_Scale_newton( A0_square_est, alpha, &temp1 );                                                                                    // e = temp1 + (temp - alpha_e)
        Word32 div2 = BASOP_Util_Divide3232_Scale_newton( L_shl( output_Fs, 11 ), L_shr( L_add( Mpy_32_16_1( 1884631649, shl( minDelayDiff, 3 ) ), 14037339 ), 8 ), &temp2 ); // e = temp2, 26.7741 in Q19, 0.8776 in Q31

        const Word32 revPredNormEnergy = Mpy_32_32( div2, div11 ); // q = (15 - temp2) + (15 - temp1) - 15 + 1
        // L_max
@@ -794,7 +794,7 @@ void ivas_reverb_calc_color_levels_fx(
        L_tmp = W_extract_h( W_shl( W_tmp1, W_shift ) );
        temp4 = sub( 3, W_shift );
        div2 = Sqrt32( L_tmp, &temp4 );
        pTarget_color_L[freq_idx] = BASOP_Util_Divide3232_Scale_cadence( div2, div1, &temp5 );
        pTarget_color_L[freq_idx] = BASOP_Util_Divide3232_Scale_newton( div2, div1, &temp5 );
        move32();
        temp5 = add( temp5, sub( temp4, temp3 ) );
        pTarget_color_L_e[freq_idx] = temp5;
@@ -807,7 +807,7 @@ void ivas_reverb_calc_color_levels_fx(
        L_tmp = W_extract_h( W_shl( W_tmp2, W_shift ) );
        temp4 = sub( 3, W_shift );
        div2 = Sqrt32( L_tmp, &temp4 );
        pTarget_color_R[freq_idx] = BASOP_Util_Divide3232_Scale_cadence( div2, div1, &temp5 );
        pTarget_color_R[freq_idx] = BASOP_Util_Divide3232_Scale_newton( div2, div1, &temp5 );
        move32();
        temp5 = add( temp5, sub( temp4, temp3 ) );
        pTarget_color_R_e[freq_idx] = temp5;
@@ -825,7 +825,7 @@ void ivas_reverb_calc_color_levels_fx(
    Word32 div1;
    Word16 temp = 0;
    move16();
    div1 = BASOP_Util_Divide3232_Scale_cadence( L_mult0( 1000, sub( freq_count, 1 ) ), L_shr( output_Fs, 1 ), &temp );
    div1 = BASOP_Util_Divide3232_Scale_newton( L_mult0( 1000, sub( freq_count, 1 ) ), L_shr( output_Fs, 1 ), &temp );
    div1 = BASOP_Util_Add_Mant32Exp( div1, temp, ONE_IN_Q30, 1, &temp );
    idx_pivot = extract_l( L_shr( div1, sub( 31, temp ) ) );
    /* Perform step limiting */
Loading