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

Merge branch '3gpp_issue_1449_fix_3' into 'main'

Fix for 3GPP issue 1449: OMASA Complexity measurement crashes

See merge request !1523
parents d61cd826 e123cac9
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -618,6 +618,7 @@ void ivas_wb_tbe_dec_fx(
    move16();
    Word32 dummy2[HILBERT_MEM_SIZE];
    Word16 f, inc;
    Word64 W_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -853,17 +854,20 @@ void ivas_wb_tbe_dec_fx(
            move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */
        }

        prev_pow = 0;
        move32();
        W_tmp = 0;
        move64();
        IF( st_fx->element_mode > EVS_MONO )
        {
            tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
            prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
            W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
        }
        FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
        {
            prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
            W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/
        }
        exp = W_norm( W_tmp );
        prev_pow = W_extract_h( W_shl( W_tmp, exp ) );
        exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 );

        rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) );

@@ -901,7 +905,7 @@ void ivas_wb_tbe_dec_fx(
        }

        Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow,
                                   shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp );
                                   exp, &exp );

        FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
        {
+8 −4
Original line number Diff line number Diff line
@@ -2463,19 +2463,23 @@ static void reduce_metadata_further_fx(
        }

        /* Determine if to merge over frequency instead of time */
        meanRatio = 0;
        move32();
        W_tmp = 0;
        move64();
        FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
        {
            FOR( band = 0; band < numCodingBands; band++ )
            {
                meanRatio = L_add( meanRatio, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ) ); // hMasa->data.q_energy - 1
                W_tmp = W_mac_32_16( W_tmp, Mpy_32_32( hqmetadata->q_direction[0].band_data[band].energy_ratio_fx[sf], energy[sf][band] ), 1 ); // hMasa->data.q_energy
            }
        }
        shift = W_norm( W_tmp );
        meanRatio = W_extract_h( W_shl( W_tmp, shift ) ); // Q:sub( add( hMasa->data.q_energy, shift ), 32 )
        shift = sub( 31, sub( add( hMasa->data.q_energy, shift ), 32 ) );

        IF( totalEnergySum != 0 )
        {
            meanRatio = BASOP_Util_Divide3232_Scale_newton( meanRatio, totalEnergySum, &exp );
            exp = add( add( exp, 1 ), tmp2 ); // 31 - (hMasa->data.q_energy - 1) - 31 - hMasa->data.q_energy - tmp2 => 1 + tmp2
            exp = add( exp, sub( shift, sub( 31, add( hMasa->data.q_energy, tmp2 ) ) ) ); // exp + (shift - (31 - hMasa->data.q_energy - tmp2)) => 1 + tmp2
        }
        ELSE
        {
+2 −2
Original line number Diff line number Diff line
@@ -285,10 +285,10 @@ static void convolve_tc_fx(
        L_sum = L_mult( g[0], h[n] ); /* Qx */
        FOR( i = 1; i < len; i++ )
        {
            L_sum = L_mac( L_sum, g[i], h[n - i] ); /* Qx + 16 */
            L_sum = L_mac_sat( L_sum, g[i], h[n - i] ); /* Qx + 16 */
        }

        y[n] = round_fx( L_sum ); /* Qx */
        y[n] = round_fx_sat( L_sum ); /* Qx */
    }
}
/*-------------------------------------------------------------------*