Commit 5a0e4734 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_REND_ISM_XFADE, FIX_REND_ISM_POS_ROUNDING, FIX_REND_ISM_STEREO_PANNING

parent c1aa9197
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -4660,7 +4660,6 @@ void ivas_ism_render(
    const int16_t output_frame                                  /* i  : output frame length per channel                 */
);

#ifdef FIX_REND_ISM_STEREO_PANNING
void ivas_ism_get_stereo_gains(
    const float azimuth,                                        /* i  : object azimuth                                  */
    const float elevation,                                      /* i  : object elevation                                */
@@ -4668,7 +4667,6 @@ void ivas_ism_get_stereo_gains(
    float *right_gain                                           /* o  : right channel gain                              */
);

#endif
void ivas_mc2sba(
    IVAS_OUTPUT_SETUP hIntSetup,                                /* i  : Format of decoder output                        */
    float buffer_td[][L_FRAME48k],                              /* i/o: MC signals (on input) and the HOA3 (on output)  */
+0 −3
Original line number Diff line number Diff line
@@ -148,9 +148,6 @@
#define SBA_BR_SWITCHING                                /* Issue 114: Changes for sba bit rate switching*/
#define BRATE_SWITCHING_RENDERING                       /* Bitrate switching changes related to the renderers */
#define FIX_150                                         /* Issue 150: Crash in EVS mono, HQ_HARMONIC mode, related to BASOP_NOGLOB */
#define FIX_REND_ISM_XFADE                              /* Issue 193: Crossfade inconsistencies in ISM between decoder and external renderer */
#define FIX_REND_ISM_POS_ROUNDING                       /* Issue 193: (Temporary solution until fix for #215) Align rounding of ISM position data in external renderer */
#define FIX_REND_ISM_STEREO_PANNING                     /* Issue 193: Use tangent panning for ISM to stereo in external renderer */
#define FIX_REND_ROUNDING                               /* Issue 195: Align float to int16 conversion in renderer with decoder */
#define FIX_REND_MONO_DMX                               /* Issue 195: Fix mono downmix coefficients in decoder and renderer */
#define FIX_REND_ROT_MC_BIN                             /* Issue 195: Fix wrong EFAP handle passed to renderer, resulting in no rotation for BINAURAL_ROOM output */
+0 −44
Original line number Diff line number Diff line
@@ -82,11 +82,7 @@ ivas_error ivas_ism_renderer_open(
    interpolator_length = (uint16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );
    for ( i = 0; i < interpolator_length; i++ )
    {
#ifdef FIX_REND_ISM_XFADE
        st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 );
#else
        st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length );
#endif
    }

    return error;
@@ -144,43 +140,10 @@ void ivas_ism_render(
    {
        if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO )
        {
#ifdef FIX_REND_ISM_STEREO_PANNING
            ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth,
                                       st_ivas->hIsmMetaData[i]->elevation,
                                       &gains[i][0],
                                       &gains[i][1] );
#else
            float aziRad, eleRad;
            float y, mappedX, aziRadMapped, A, A2, A3;
            const float LsAngleRad = 30.0f * PI_OVER_180;

            /* Convert azi and ele to an azi value of the cone of confusion */
            aziRad = st_ivas->hIsmMetaData[i]->azimuth * PI_OVER_180;
            eleRad = st_ivas->hIsmMetaData[i]->elevation * PI_OVER_180;
            y = ( sinf( aziRad ) * cosf( eleRad ) );
            mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) );
            aziRadMapped = atan2f( y, mappedX );

            /* Determine the amplitude panning gains */
            if ( aziRadMapped >= LsAngleRad )
            { /* Left side */
                gains[i][0] = 1.0f;
                gains[i][1] = 0.0f;
            }
            else if ( aziRadMapped <= -LsAngleRad )
            { /* Right side */
                gains[i][0] = 0.0f;
                gains[i][1] = 1.0f;
            }
            else /* Tangent panning law */
            {
                A = tanf( aziRadMapped ) / tanf( LsAngleRad );
                A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f );
                A3 = 1.0f / ( A2 * A2 + 1.0f );
                gains[i][0] = sqrtf( A3 );
                gains[i][1] = sqrtf( 1.0f - A3 );
            }
#endif
        }
        else
        {
@@ -191,14 +154,9 @@ void ivas_ism_render(
            }
            else
            {
#ifdef FIX_REND_ISM_POS_ROUNDING
                // TODO tmu review when #215 is resolved
                azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f );
                elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f );
#else
                azimuth = (int16_t) ( st_ivas->hIsmMetaData[i]->azimuth + 0.5f );
                elevation = (int16_t) ( st_ivas->hIsmMetaData[i]->elevation + 0.5f );
#endif

                if ( st_ivas->hIntSetup.is_planar_setup )
                {
@@ -240,7 +198,6 @@ void ivas_ism_render(
    return;
}

#ifdef FIX_REND_ISM_STEREO_PANNING
void ivas_ism_get_stereo_gains(
    const float azimuth,   /* i  : object azimuth       */
    const float elevation, /* i  : object elevation     */
@@ -279,4 +236,3 @@ void ivas_ism_get_stereo_gains(
        *right_gain = sqrtf( 1.0f - A3 );
    }
}
#endif
+0 −13
Original line number Diff line number Diff line
@@ -305,35 +305,22 @@ void ivas_ism2sba(

    for ( i = 0; i < num_objects; i++ )
    {
#ifdef FIX_REND_ISM_POS_ROUNDING
        // TODO tmu review when #215 is resolved
        azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f );
        elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f );
#else
        azimuth = (int16_t) ( hIsmMetaData[i]->azimuth + 0.5f );
        elevation = (int16_t) ( hIsmMetaData[i]->elevation + 0.5f );
#endif

        /*get HOA gets for direction (ACN/SN3D)*/
        ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order );

        for ( j = 0; j < sba_num_chans; j++ )
        {
#ifdef FIX_REND_ISM_XFADE
            g1 = 1.f;
#endif
            g2 = 0.f;
            for ( k = 0; k < output_frame; k++ )
            {
#ifdef FIX_REND_ISM_XFADE
                buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k];
                g2 += 1.f / ( output_frame - 1 );
                g1 = 1.0f - g2;
#else
                g2 += 1.f / output_frame;
                g1 = 1.0f - g2;
                buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k];
#endif
            }
            hIsmRendererData->prev_gains[i][j] = gains[j];
        }
+0 −18
Original line number Diff line number Diff line
@@ -3796,7 +3796,6 @@ static ivas_error renderIsmToMc(
    wmops_sub_start( "renderIsmToMc" );

/* TODO(sgi): Possible optimization: less processing needed if position didn't change */
#ifdef FIX_REND_ISM_STEREO_PANNING
    if ( *ismInput->base.ctx.pOutConfig == IVAS_REND_AUDIO_CONFIG_STEREO )
    {
        set_zero( currentPanGains, 16 );
@@ -3812,29 +3811,20 @@ static ivas_error renderIsmToMc(
                                   &previousPanGains[1] );
    }
    else
#endif
    {
#ifdef FIX_REND_ISM_POS_ROUNDING
        // TODO tmu review when #215 is resolved
        if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper,
                                     (int16_t) floorf( ismInput->currentPos.azimuth + 0.5f ),
                                     (int16_t) floorf( ismInput->currentPos.elevation + 0.5f ),
                                     currentPanGains ) ) != IVAS_ERR_OK )
#else
        if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, ismInput->currentPos.azimuth, ismInput->currentPos.elevation, currentPanGains ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
#ifdef FIX_REND_ISM_POS_ROUNDING
        // TODO tmu review when #215 is resolved
        if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper,
                                     (int16_t) floorf( ismInput->previousPos.azimuth + 0.5f ),
                                     (int16_t) floorf( ismInput->previousPos.elevation + 0.5f ),
                                     previousPanGains ) ) != IVAS_ERR_OK )
#else
        if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, ismInput->previousPos.azimuth, ismInput->previousPos.elevation, previousPanGains ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -3871,15 +3861,11 @@ static ivas_error renderIsmToSba(
        return error;
    }

#ifdef FIX_REND_ISM_POS_ROUNDING
    // TODO tmu review when #215 is resolved
    ivas_dirac_dec_get_response( (int16_t) floorf( ismInput->previousPos.azimuth + 0.5f ),
                                 (int16_t) floorf( ismInput->previousPos.elevation + 0.5f ),
                                 previousPanGains,
                                 ambiOrderOut );
#else
    ivas_dirac_dec_get_response( (int16_t) ismInput->previousPos.azimuth, (int16_t) ismInput->previousPos.elevation, previousPanGains, ambiOrderOut );
#endif

    if ( ( ismInput->currentPos.azimuth == ismInput->previousPos.azimuth ) &&
         ( ismInput->currentPos.elevation == ismInput->previousPos.elevation ) )
@@ -3888,15 +3874,11 @@ static ivas_error renderIsmToSba(
    }
    else
    {
#ifdef FIX_REND_ISM_POS_ROUNDING
        // TODO tmu review when #215 is resolved
        ivas_dirac_dec_get_response( (int16_t) floorf( ismInput->currentPos.azimuth + 0.5f ),
                                     (int16_t) floorf( ismInput->currentPos.elevation + 0.5f ),
                                     currentPanGains,
                                     ambiOrderOut );
#else
        ivas_dirac_dec_get_response( (int16_t) ismInput->currentPos.azimuth, (int16_t) ismInput->currentPos.elevation, currentPanGains, ambiOrderOut );
#endif
    }

    /* Assume num channels in audio buffer to be 1.