Commit dca4cf2b authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Reverb opening and initialization related to fix for #1075

parent 8e47edee
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2100,10 +2100,21 @@ ivas_error ivas_init_decoder(
#ifdef NONBE_FIX_1075
            if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
            {
#ifdef FIX_1053_REVERB_RECONFIGURATION
                if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
                if ( ( error = ivas_reverb_init( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#endif
            }
#endif

@@ -2178,10 +2189,21 @@ ivas_error ivas_init_decoder(
#ifdef NONBE_FIX_1075
            if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
            {
#ifdef FIX_1053_REVERB_RECONFIGURATION
                if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
                if ( ( error = ivas_reverb_init( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#endif
            }
#endif
        }
+11 −0
Original line number Diff line number Diff line
@@ -1254,10 +1254,21 @@ static ivas_error ivas_mc_dec_reconfig(
#ifdef NONBE_FIX_1075
                if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
                {
#ifdef FIX_1053_REVERB_RECONFIGURATION
                    if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                    if ( ( error = ivas_reverb_init( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
#else
                    if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
#endif
                }
#endif

+11 −0
Original line number Diff line number Diff line
@@ -387,10 +387,21 @@ ivas_error ivas_omasa_dec_config(
#ifdef NONBE_FIX_1075
                    if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
                    {
#ifdef FIX_1053_REVERB_RECONFIGURATION
                        if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                        {
                            return error;
                        }
                        if ( ( error = ivas_reverb_init( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                        {
                            return error;
                        }
#else
                        if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                        {
                            return error;
                        }
#endif
                    }
#endif
                }
+11 −0
Original line number Diff line number Diff line
@@ -506,10 +506,21 @@ ivas_error ivas_sba_dec_reconfigure(
#ifdef NONBE_FIX_1075
                if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
                {
#ifdef FIX_1053_REVERB_RECONFIGURATION
                    if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                    if ( ( error = ivas_reverb_init( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
#else
                    if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
#endif
                }
#endif
            }
+45 −1
Original line number Diff line number Diff line
@@ -49,7 +49,9 @@
 *------------------------------------------------------------------------------------------*/

#define OTR_UPDATE_RATE (float) FRAMES_PER_SEC /* rate of the Process() calls [Hz]; 1x per IVAS frame */

#ifdef NONBE_FIX_738_QUATERNION_SLERP_PRECISION
#define COS_ONE_TENTH_DEGREE ( 0.999998476913288f )
#endif

/*------------------------------------------------------------------------------------------*
 * Local functions
@@ -157,12 +159,53 @@ void QuaternionSlerp(
    const float t,
    IVAS_QUATERNION *const r )
{
#ifdef NONBE_FIX_738_QUATERNION_SLERP_PRECISION
    IVAS_QUATERNION r1, r2;
    float phi, sinPhi, cosPhi, s1, s2;

    QuaternionNormalize( q1, &r1 );
    QuaternionNormalize( q2, &r2 );

    cosPhi = QuaternionDotProduct( r1, r2 );

    if ( cosPhi < 0 )
    {
        cosPhi = -cosPhi;
        r2.w = -r2.w;
        r2.x = -r2.x;
        r2.y = -r2.y;
        r2.z = -r2.z;
    }

    /* Angle less than one degree, use linear interpolation */
    if ( cosPhi >= COS_ONE_TENTH_DEGREE )
    {
        r->w = r1.w + t * ( r2.w - r1.w );
        r->x = r1.x + t * ( r2.x - r1.x );
        r->y = r1.y + t * ( r2.y - r1.y );
        r->z = r1.z + t * ( r2.z - r1.z );
    }
    else
    {
        phi = acosf( cosPhi );
        sinPhi = sinf( phi );

        s1 = sinf( ( 1 - t ) * phi );
        s2 = sinf( t * phi );

        r->w = ( s1 * r1.w + s2 * r2.w ) / sinPhi;
        r->x = ( s1 * r1.x + s2 * r2.x ) / sinPhi;
        r->y = ( s1 * r1.y + s2 * r2.y ) / sinPhi;
        r->z = ( s1 * r1.z + s2 * r2.z ) / sinPhi;
    }
#else
    float angle, denom, s, s2;

    s = QuaternionDotProduct( q1, q2 );

    if ( fabsf( s ) >= 1.0f )
    {

        *r = q2;
        return;
    }
@@ -177,6 +220,7 @@ void QuaternionSlerp(
    r->z = ( q1.z * s + q2.z * s2 ) / denom;
    r->w = ( q1.w * s + q2.w * s2 ) / denom;

#endif
    QuaternionNormalize( *r, r );

    return;