Commit 6d49b311 authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Change macro from float to int; apply BASOP standard format.

parent 10d42196
Loading
Loading
Loading
Loading
Loading
+77 −20
Original line number Diff line number Diff line
@@ -53,10 +53,13 @@
#define N_BANDS_MAX           ( 60 )

#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
#define FC_INPUT_MIN_FX       0          // ( 0.0f )
#define FC_INPUT_MAX_Q14      1638400000 // ( 1.0e+5f ) in Q14
#define ACOUSTIC_RT60_MIN_Q26 67109      // ( 1.0e-3f ) in Q26
#define ACOUSTIC_RT60_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24
#define ACOUSTIC_DSR_MIN_FX   0          // ( 0.0f )
#define ACOUSTIC_DSR_MAX_Q24  1677721600 // ( 1.0e+2f ) in Q24
#define INPUTPREDELAY_MIN_FX  0          // ( 0.0f )
#define INPUTPREDELAY_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24
#endif

@@ -1268,13 +1271,21 @@ ivas_error RenderConfigReader_checkValues(
    IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o  : Renderer configuration handle          */
)
{
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    Word16 band_idx, tab_value_err_count;
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics;
    pRoom_acoustics = &hRenderConfig->roomAcoustics;
    Word16 wall_idx;
    Word16 i;

    tab_value_err_count = 0;
    move16();
#else
    int16_t band_idx, tab_value_err_count;
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics;
    pRoom_acoustics = &hRenderConfig->roomAcoustics;
    tab_value_err_count = 0;
    int16_t wall_idx;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    int16_t i;
#endif

    /* Verify the number of frequency bands in the config input data */
@@ -1284,52 +1295,66 @@ ivas_error RenderConfigReader_checkValues(
    }
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    /* Verify input pre-delay value */
    if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN ) )
    if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN_FX ) )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }
#endif

    /* Verify data per band in the acoustic properties table */
    for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ )
    FOR( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ )
    {
        /* Verify if the frequencies are in the ascending order (required for interpolation) */
        if ( band_idx != 0 )
        IF( band_idx != 0 )
        {
            if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] )
            {
                tab_value_err_count++;
                tab_value_err_count = add( tab_value_err_count, 1 );
            }
        }
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
        /* Check the input frequencies */
        if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN ) )
        if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN_FX ) )
        {
            tab_value_err_count++;
            tab_value_err_count = add( tab_value_err_count, 1 );
        }

        /* Check the input RT60 values */
        if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ), ACOUSTIC_RT60_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], ACOUSTIC_RT60_MIN_Q26 ) )
        {
            tab_value_err_count++;
            tab_value_err_count = add( tab_value_err_count, 1 );
        }
        /* Check the input DSR values */
        if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN ) )
        if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN_FX ) )
        {
            tab_value_err_count++;
            tab_value_err_count = add( tab_value_err_count, 1 );
        }
#endif

        /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
        if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] <= 0 )
        {
            pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX;
            move32();
        }
    }
#else
    /* Verify data per band in the acoustic properties table */
    for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ )
    {
        /* Verify if the frequencies are in the ascending order (required for interpolation) */
        if ( band_idx != 0 )
        {
            if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] )
            {
                tab_value_err_count++;
            }
        }

        /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */
        if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] == 0 )
#endif
        {
            pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX;
        }
    }
#endif

    if ( tab_value_err_count != 0 )
    {
@@ -1337,44 +1362,76 @@ ivas_error RenderConfigReader_checkValues(
    }


#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
    IF( pRoom_acoustics->use_er == 1 )
#else
    if ( pRoom_acoustics->use_er == 1 )
#endif
    {
        /* Room dimensions */
        if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }
        if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }
        if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }
        if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }
        if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }
        if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX )
        {
            pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
            move32();
#endif
        }

        /* Abs Coeff */
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
        FOR( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ )
#else
        for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ )
#endif
        {
            if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX )
            {
                pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
                move32();
#endif
            }
            if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX )
            {
                pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX;
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
                move32();
#endif
            }
        }
#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION
@@ -1385,11 +1442,11 @@ ivas_error RenderConfigReader_checkValues(
        hRenderConfig->distAtt_fx[2] = L_max( 0, hRenderConfig->distAtt_fx[2] ); // min( 10.0f, hRenderConfig->distAtt[2] ) is removed, because distAtt_fx[2] is always < 10.0f in Q30 format.

        /* Verify range of directivity patterns */
        for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
        FOR( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
        {
            hRenderConfig->directivity_fx[i * 3] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3] ) );
            hRenderConfig->directivity_fx[i * 3 + 1] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3 + 1] ) );
            hRenderConfig->directivity_fx[i * 3 + 2] = s_max( 0, s_min( ONE_IN_Q15 - 1, hRenderConfig->directivity_fx[i * 3 + 2] ) );
            hRenderConfig->directivity_fx[imult1616( i, 3 )] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[imult1616( i, 3 )] ) );
            hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 1 )] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 1 )] ) );
            hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = s_max( 0, s_min( ONE_IN_Q15 - 1, hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] ) );
        }
#endif
    }