Commit e80085b3 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Bug fix in gain_enc_lbr_ivas_fx

Corrects the calculation of log10(Ecode) and maintenance of Q factor of this which then corrects the gcode0 value.
parent f1458362
Loading
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -2525,7 +2525,7 @@ void gain_enc_lbr_ivas_fx(

    /*Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR;
     *gain_inov = 1.0f / (float)sqrt(Ecode);*/
    L_tmp = Dot_product12( code, code, L_subfr, &exp_code );
    L_tmp = Dot_product12( code, code, L_subfr, &exp_code ); /* Q9 + Q9 + 1 + (30-exp_code)*/
    L_inov = L_tmp;                                          /* sets to 'L_tmp' in 1 clock */
    move32();
    /* exp_code: -18 (code in Q9), -6 (/L_SUBFR), -31 (L_tmp Q31->Q0) */
@@ -2599,12 +2599,15 @@ void gain_enc_lbr_ivas_fx(
        /*     gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
        gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
        gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */

        exp_code = sub( exp_code, 18 + 6 + 1 );
        // Ecode = (Ecode / L_subfr)
        L_tmp = L_shr( L_tmp, L_subfr_sf );                     // Q19 + (Q30-exp_code)
                                                                /* Calculation for log10(Ecode) exponent for applying log10 = Q31 - q = Q31 - Q19 - Q30 + exp_code = exp_code - Q18*/
        L_tmp = BASOP_Util_Log10( L_tmp, sub( exp_code, 18 ) ); // new q = Q25
        exp = norm_l( L_tmp );
        frac = Log2_norm_lc( L_shl( L_tmp, exp ) );
        exp = sub( exp_code, exp );
        L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/
        L_tmp = L_shl( L_tmp, exp ); // Q25 + exp
        // 10 in Q27 , ( 10 * log10( Ecode ) )
        L_tmp1 = Mpy_32_32( L_tmp, 1342177280 ); // Q25 + exp + 1 + Q27 - 32 = Q21 + exp
        L_tmp1 = L_shr( L_tmp1, add( 7, exp ) ); // Q21 + exp - 7 - exp = Q14

        L_tmp = Dot_product( b, aux, n_pred ); /*Q25*/
        L_tmp = Mult_32_16( L_tmp, 320 );      /*Q14, 20 in Q4*/