Commit a9b30958 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Manuel Jander
Browse files

Fix for 3GPP issue 1531: Low-bitrate OMASA shows a bit high MLD (over 10) in...

Fix for 3GPP issue 1531: Low-bitrate OMASA shows a bit high MLD (over 10) in BASOP decoder rendering to binaural

Link #1531
parent e4d93a77
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -285,7 +285,17 @@ void FEC_clas_estim_fx(


            Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] );
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                IF( LT_16( sub( pos, T0 ), sub( L_frame, L_SUBFR ) ) )
                {
                    T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 );
                }
            }
            ELSE
            {
                T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 );
            }
            pos_limit = sub( L_frame, L_SUBFR );
            j = s_min( 1, s_max( 0, sub( pos, pos_limit ) ) );
            Ltmp = L_deposit_l( cor_max[0] );
+39 −10
Original line number Diff line number Diff line
@@ -3584,24 +3584,53 @@ static void matrixTransp1Mul_fx(
    Word16 chA, chB;
    Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );

    Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
    Word64 tmp64_1, tmp64_2;
    Word16 tmp16, q_common = 63;
    move16();

    FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
    {
        FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
        {
            outRe_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ),
                                                                     Are_fx[1][chA], Bre_fx[1][chB] ),
                                                         Aim_fx[0][chA], Bim_fx[0][chB] ),
                                             Aim_fx[1][chA], Bim_fx[1][chB] );
            tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
            tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
            tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 );                                                      // Q: add( add( q_A, q_B ), 1 )
            move64();
            tmp16 = W_norm( tmp_outRe_fx[chA][chB] );
            tmp_outRe_fx[chA][chB] = W_shl( tmp_outRe_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
            move64();
            q_tmp_outRe_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
            move16();
            q_common = s_min( q_tmp_outRe_fx[chA][chB], q_common );


            tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
            tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
            tmp_outIm_fx[chA][chB] = W_sub( tmp64_1, tmp64_2 );                                                      // Q: add( add( q_A, q_B ), 1 )
            move64();
            tmp16 = W_norm( tmp_outIm_fx[chA][chB] );
            tmp_outIm_fx[chA][chB] = W_shl( tmp_outIm_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
            move64();
            q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
            move16();
            q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common );
        }
    }
    FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
    {
        FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
        {
            outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) );
            move32();
            outIm_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ),
                                                                     Are_fx[1][chA], Bim_fx[1][chB] ),
                                                         Aim_fx[0][chA], Bre_fx[0][chB] ),
                                             Aim_fx[1][chA], Bre_fx[1][chB] );
            outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) );
            move32();
        }
    }
    *q_out = sub( add( q_A, q_B ), 31 );

    *q_out = sub( q_common, 32 );
    move16();
    if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) )
    {
+33 −18
Original line number Diff line number Diff line
@@ -1754,7 +1754,7 @@ void protoSignalComputation2_fx(
    Word32 RealSubtract_fx, ImagSubtract_fx;
    Word32 left_bb_power_fx, right_bb_power_fx, total_bb_power_fx, lr_bb_power_fx;
    Word32 left_hi_power_fx, right_hi_power_fx, total_hi_power_fx, lr_hi_power_fx;
    Word32 sum_power_fx, Left_power_fx, Right_power_fx;
    Word32 sum_power_fx, Left_power_fx, Right_power_fx, Total_power_fx;
    Word16 q_lr_bb_power, q_lr_hi_power;
    Word32 lr_total_bb_ratio_fx, lr_total_hi_ratio_fx;
    Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx;
@@ -2120,7 +2120,10 @@ void protoSignalComputation2_fx(
#else
        q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) );
#endif

        Word16 exp_left_hi_power = 0, exp_right_hi_power = 0, exp_total_hi_power = 0, exp_temppp;
        move16();
        move16();
        move16();
        FOR( l = 0; l < num_freq_bands; l++ )
        {
#ifdef FIX_867_CLDFB_NRG_SCALE
@@ -2166,17 +2169,28 @@ void protoSignalComputation2_fx(
            // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] );
            total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power
#endif

            IF( GT_16( l, MASA_HI_FREQ_START_BIN ) )
            {
                left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx );    // q_Left_Right_power
                right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power
                                                                                // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] );
#ifdef FIX_867_CLDFB_NRG_SCALE
                total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], sub( head_room, total_shift[qidx] ) ) ) ); // q_Left_Right_power
#else
                total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power
#endif
                W_tmp1 = W_add( W_mult0_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ), W_mult0_32_32( ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] ) );
                q_shift = W_norm( W_tmp1 );
                Left_power_fx = W_extract_h( W_shl( W_tmp1, q_shift ) );
                exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );

                left_hi_power_fx = BASOP_Util_Add_Mant32Exp( left_hi_power_fx, exp_left_hi_power, Left_power_fx, exp_temppp, &exp_left_hi_power ); // exp:exp_left_hi_power

                W_tmp2 = W_add( W_mult0_32_32( RealBuffer_fx[1][0][l], RealBuffer_fx[1][0][l] ), W_mult0_32_32( ImagBuffer_fx[1][0][l], ImagBuffer_fx[1][0][l] ) );
                q_shift = W_norm( W_tmp2 );
                Right_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) );
                exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );

                right_hi_power_fx = BASOP_Util_Add_Mant32Exp( right_hi_power_fx, exp_right_hi_power, Right_power_fx, exp_temppp, &exp_right_hi_power ); // exp:exp_right_hi_power

                W_tmp2 = W_add( W_tmp1, W_tmp2 );
                q_shift = W_norm( W_tmp2 );
                Total_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) );
                exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) );

                total_hi_power_fx = BASOP_Util_Add_Mant32Exp( total_hi_power_fx, exp_total_hi_power, Total_power_fx, exp_temppp, &exp_total_hi_power ); // exp:exp_total_hi_power
            }

            IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) )
@@ -2704,15 +2718,16 @@ void protoSignalComputation2_fx(
        lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21

#ifdef FIX_867_CLDFB_NRG_SCALE
        stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );
        stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), exp_left_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );
        move32();
        stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power );
        move16();
        stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power );

        stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), exp_right_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power );
        move32();
        stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power );
        move16();
        stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power );
        stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), exp_total_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power );
        move32();
#else
        stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power );