Commit 85d74a04 authored by bayers's avatar bayers
Browse files

small code beutifications

parent 32e4f803
Loading
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -716,7 +716,7 @@ void ivas_param_ism_dec(
#ifdef FIX_549_DMX_GAIN
    int16_t output_frame;
    float gain, ene_tc, ene_sum, grad;
    float *last_gain;
    float last_gain;
#endif
    float ref_power[CLDFB_NO_CHANNELS_MAX];
    float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
@@ -744,7 +744,7 @@ void ivas_param_ism_dec(
#ifdef FIX_549_DMX_GAIN
    ene_tc = 0.0f;
    ene_sum = 0.0f;
    last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain );
    last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain;
    output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#endif

@@ -841,13 +841,13 @@ void ivas_param_ism_dec(
    if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 )
    {
        /* Smoothing */
        gain = 0.75f * gain + 0.25f * *( last_gain );
        gain = 0.75f * gain + 0.25f * last_gain;
        /* 10ms ramp */
        grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */
        grad = ( gain - last_gain  ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */
        for ( i = 0; i < ( output_frame / 2 ); i++ )
        {
            output_f[0][i] *= ( *( last_gain ) + i * grad );
            output_f[1][i] *= ( *( last_gain ) + i * grad );
            output_f[0][i] *= ( last_gain  + i * grad );
            output_f[1][i] *= ( last_gain  + i * grad );
        }
        for ( ; i < output_frame; i++ )
        {
@@ -863,7 +863,7 @@ void ivas_param_ism_dec(
            output_f[1][i] *= gain;
        }
    }
    *( last_gain ) = gain;
    st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain;
#endif

    for ( ch = 0; ch < nchan_transport; ch++ )
@@ -1084,7 +1084,7 @@ void ivas_param_ism_dec_digest_tc(
#ifdef FIX_549_DMX_GAIN
    int16_t output_frame;
    float gain, ene_tc, ene_sum, grad;
    float *last_gain;
    float last_gain;
#endif
    float ref_power[CLDFB_NO_CHANNELS_MAX];
    float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
@@ -1098,7 +1098,7 @@ void ivas_param_ism_dec_digest_tc(
#ifdef FIX_549_DMX_GAIN
    ene_tc = 0.0f;
    ene_sum = 0.0f;
    last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain );
    last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain ;
    output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
#endif

@@ -1198,13 +1198,13 @@ void ivas_param_ism_dec_digest_tc(
    if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 )
    {
        /* Smoothing */
        gain = 0.75f * gain + 0.25f * *( last_gain );
        gain = 0.75f * gain + 0.25f * last_gain ;
        /* 10ms ramp */
        grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */
        grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */
        for ( i = 0; i < ( output_frame / 2 ); i++ )
        {
            transport_channels_f[0][i] *= ( *( last_gain ) + i * grad );
            transport_channels_f[1][i] *= ( *( last_gain ) + i * grad );
            transport_channels_f[0][i] *= ( last_gain  + i * grad );
            transport_channels_f[1][i] *= ( last_gain  + i * grad );
        }
        for ( ; i < output_frame; i++ )
        {
@@ -1220,7 +1220,7 @@ void ivas_param_ism_dec_digest_tc(
            transport_channels_f[1][i] *= gain;
        }
    }
    *( last_gain ) = gain;
    st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain;
#endif

    for ( ch = 0; ch < nchan_transport; ch++ )
+19 −19
Original line number Diff line number Diff line
@@ -224,8 +224,8 @@ void ivas_param_ism_stereo_dmx(
    float stereo_dmx[2][L_FRAME48k];
#ifdef FIX_549_DMX_GAIN
    float dmx_gain, ene_dmx, ene_data, grad;
    float *last_dmx_gain;
    float *last_cardioid_left;
    float last_dmx_gain;
    float last_cardioid_left;
#endif
    ISM_METADATA_HANDLE hIsmMetaData;

@@ -238,8 +238,7 @@ void ivas_param_ism_stereo_dmx(
    dmx_gain = 0;
    ene_dmx = 0;
    ene_data = 0;
    last_dmx_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain );
    last_cardioid_left = &( st_ivas->hDirAC->hParamIsm->last_cardioid_left[0] );
    last_dmx_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain;
#endif

    /* Set the stereo dmx to zero */
@@ -250,7 +249,9 @@ void ivas_param_ism_stereo_dmx(
    for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ )
    {
        hIsmMetaData = st_ivas->hIsmMetaData[i];

#ifdef FIX_549_DMX_GAIN
        last_cardioid_left = st_ivas->hDirAC->hParamIsm->last_cardioid_left[i];
#endif
        /*Compute the Cardioids for the corresponding object direction */
        tmp = hIsmMetaData->azimuth * ( EVS_PI / 180 );
        tmp_1 = ( EVS_PI / 2 ) + azi_shift;
@@ -268,19 +269,19 @@ void ivas_param_ism_stereo_dmx(
#else
        if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 )
        {
            float last_cardioid_right;
            last_cardioid_right = 1.0f - last_cardioid_left;
            /* Smoothing */
            cardioid_left[i] = 0.75f * cardioid_left[i] + 0.25f * *( last_cardioid_left );
            grad = ( cardioid_left[i] - *( last_cardioid_left ) ) * 2.0f / input_frame; /* for the right cardioid, multiply with -1 */
            cardioid_left[i] = 0.75f * cardioid_left[i] + 0.25f * last_cardioid_left;
            grad = ( cardioid_left[i] - last_cardioid_left ) * 2.0f / (float) input_frame; /* for the right cardioid, multiply with -1 */
            /* Cardioids sum up to 1 */
            cardioid_right[i] = 1.0f - cardioid_left[i]; /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */
            /* Loop over all samples */
            for ( j = 0; j < input_frame / 2; j++ )
            {
                float last_cardioid_right;
                last_cardioid_right = 1.0f - *( last_cardioid_left );
                tmp = data[i][j];
                stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp );      /* DMX Left */
                stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1 ) ) * tmp ); /* DMX Right */
                stereo_dmx[0][j] += ( ( last_cardioid_left + j * grad ) * tmp );              /* DMX Left */
                stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1.0f ) ) * tmp ); /* DMX Right */
                ene_data += ( tmp * tmp );                                                    /* energy of all objects combined */
            }
            for ( ; j < input_frame; j++ )
@@ -304,8 +305,7 @@ void ivas_param_ism_stereo_dmx(
                ene_data += ( tmp * tmp );                   /* energy of all objects combined */
            }
        }
        *( last_cardioid_left ) = cardioid_left[i];
        last_cardioid_left++;
        st_ivas->hDirAC->hParamIsm->last_cardioid_left[i] = cardioid_left[i];
#endif
    }

@@ -319,13 +319,13 @@ void ivas_param_ism_stereo_dmx(
    /* Smoothing */
    if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 )
    {
        dmx_gain = 0.75f * dmx_gain + 0.25f * *( last_dmx_gain );
        dmx_gain = 0.75f * dmx_gain + 0.25f * last_dmx_gain;
        /* 10ms ramp */
        grad = ( dmx_gain - *( last_dmx_gain ) ) * 2.0f / input_frame; /* slope between two consecutive gains, 480 samples length */
        grad = ( dmx_gain - last_dmx_gain ) * 2.0f / (float) input_frame; /* slope between two consecutive gains, 480 samples length */
        for ( i = 0; i < ( input_frame / 2 ); i++ )
        {
            stereo_dmx[0][i] *= ( *( last_dmx_gain ) + i * grad );
            stereo_dmx[1][i] *= ( *( last_dmx_gain ) + i * grad );
            stereo_dmx[0][i] *= ( last_dmx_gain + i * grad );
            stereo_dmx[1][i] *= ( last_dmx_gain + i * grad );
        }
        for ( ; i < input_frame; i++ )
        {
@@ -341,7 +341,7 @@ void ivas_param_ism_stereo_dmx(
            stereo_dmx[1][j] *= dmx_gain;
        }
    }
    *( last_dmx_gain ) = dmx_gain;
    st_ivas->hDirAC->hParamIsm->last_dmx_gain = dmx_gain;
#endif
    /* Copy the stereo dmx to data variable */
    mvr2r( stereo_dmx[0], data[0], input_frame );