Commit 3bb26b30 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_1727_fix' into 'main'

Fix for 3GPP issue 1727: Renderer crash with assert for OMASA to MASA output...

See merge request !1735
parents 98f09f30 4272cc79
Loading
Loading
Loading
Loading
+0 −115
Original line number Diff line number Diff line
@@ -778,121 +778,6 @@ void computeDirectionVectors_fx(
    return;
}

/*-------------------------------------------------------------------------
 * computeDiffuseness()
 *
 *
 *------------------------------------------------------------------------*/

void computeDiffuseness_fx(
    Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity)
    const Word32 *buffer_energy,                                     // i: Q(q_factor_energy)
    const Word16 num_freq_bands,
    Word32 *diffuseness, // o: exp(out_exp)
    Word16 q_factor_intensity,
    Word16 q_factor_energy,
    Word16 *out_exp /*Ouput Q*/
)
{
    Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX];
    Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX];
    Word32 energy_slow[CLDFB_NO_CHANNELS_MAX];
    Word16 i, j, k;
    Word32 tmp = 0, tmp_1;
    move32();
    Word32 *p_tmp;
    const Word32 *p_tmp_c;

    /* Compute Intensity slow and energy slow */

    set32_fx( intensity_slow, 0, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX );
    set32_fx( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX );
    set32_fx( energy_slow, 0, CLDFB_NO_CHANNELS_MAX );

    FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i )
    {
        /* Energy slow */
        p_tmp_c = buffer_energy + i * num_freq_bands;
        FOR( k = 0; k < num_freq_bands; k++ )
        {
            energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy)
            move32();
        }

        /* Intensity slow */
        FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
        {
            p_tmp = buffer_intensity[j][i];

            FOR( k = 0; k < num_freq_bands; k++ )
            {
                intensity_slow[j * num_freq_bands + k] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] );
                move32();
            }
        }
    }

    /* intensity_slow.^2 + intensity_slow_abs*/
    FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
    {
        p_tmp = intensity_slow + j * num_freq_bands;

        FOR( k = 0; k < num_freq_bands; k++ )
        {
            *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 )
            intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] );
            move32();
            move32();
        }
    }
    Word16 init_exp = sub( 62, shl( q_factor_intensity, 1 ) ); // 31 - ( 2 * q_factor_intensity - 31 )
    Word16 exp;

    Word16 exp1 = 0, exp2;
    move16();
    /* Compute Diffuseness */
    p_tmp = intensity_slow_abs;
    FOR( i = 0; i < num_freq_bands; ++i )
    {
        exp = init_exp;
        move16();
        Word32 temp = *( p_tmp++ );
        move32();
        tmp_1 = Sqrt32( temp, &exp );
        tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i], 1 ), &exp1 ) );
        exp2 = add( sub( 31, exp1 ), sub( sub( 31, exp ), q_factor_energy ) );
        IF( GT_32( exp2, 30 ) )
        {
            tmp = L_shr( tmp, sub( exp2, 30 ) );
            exp2 = sub( exp2, sub( exp2, 30 ) );
        }
        tmp = L_sub( L_shl( 1, exp2 ), tmp );
        // diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) );

        IF( LT_32( tmp, L_shl( 1, exp2 ) ) )
        {
            IF( tmp < 0 )
            {
                diffuseness[i] = 0;
            }
            ELSE
            {
                diffuseness[i] = tmp;
            }
        }
        ELSE
        {
            diffuseness[i] = L_shl( 1, exp2 );
        }
        out_exp[i] = exp2;

        move32();
        move16();
    }
    return;
}


/*-------------------------------------------------------------------------
 * computeDiffuseness()
 *
+0 −12
Original line number Diff line number Diff line
@@ -4951,18 +4951,6 @@ void computeDirectionVectors_fx(
    Word32 *direction_vector_z,
    Word16 *q_factor );


void computeDiffuseness_fx(
    Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF],
    const Word32 *buffer_energy,
    const Word16 num_freq_bands,
    Word32 *diffuseness,
    Word16 q_factor_intensity,
    Word16 q_factor_energy,
    Word16 *out_exp

);

void computeDiffuseness_fixed(
    Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF],
    const Word32 *buffer_energy,
+89 −184

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ void diffuse_meta_merge_1x1_fx(

                tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( EPSILON_FX, total_nrg_fx ), &scale );
                scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) );
                dir_nrg_ratio_fx = L_sub( L_shl( 1, scale ), L_deposit_h( tmp ) );
                dir_nrg_ratio_fx = L_sub( L_shl_sat( 1, sub( 31, scale ) ), L_deposit_h( tmp ) );
                dir_nrg_ratio_e = scale;
                move16();

@@ -239,7 +239,7 @@ void diffuse_meta_merge_1x1_fx(
                {
                    new_diff_ratio_fx = L_sub( L_shl( 1, sub( 31, new_dir_ratio_e ) ), new_dir_ratio_fx ); /* Q(31 - new_dir_ratiio_e) */
                }
                outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, new_dir_ratio_e ) ), UINT8_MAX );
                outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX );
                move16();
            }
            ELSE
+100 −208

File changed.

Preview size limit exceeded, changes collapsed.

Loading