Commit 651757ef authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Converted rotateFrameMc()

[x] MC to binaural cases are affected by the changes.
Test results - 107 failed, 551 passed, 136 skipped
with highest max abs difference of 570
parent ebae8dc9
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1312,12 +1312,16 @@ int main(
                exit( -1 );
            }
            IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels );

#ifdef IVAS_FLOAT_FIXED
            if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

        }

        for ( i = 0; i < args.inConfig.numAudioObjects; ++i )
+3 −0
Original line number Diff line number Diff line
@@ -518,6 +518,9 @@ const UWord16 cum_n_for_id_th[122] = {
/*----------------------------------------------------------------------------------*
 * Multi-channel LS setups
 *----------------------------------------------------------------------------------*/
/*Azimuth and elevation LS Tables in Q22*/
const Word32 ls_azimuth_CICP1_fx[1] = { 0 };
const Word32 ls_elevation_CICP1_fx[1] = { 0 };

const Word32 ls_azimuth_CICP2_fx[2] = { 125829120, -125829120 };
const Word32 ls_elevation_CICP2_fx[2] = { 0, 0 };
+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ extern const Word32 ism_elevation_borders_fx[4];
extern const UWord16 cum_n_for_id_th[122];

/* Multi-channel input and output setups */

extern const Word32 ls_azimuth_CICP1_fx[1];
extern const Word32 ls_elevation_CICP1_fx[1];
extern const Word32 ls_azimuth_CICP2_fx[2];
extern const Word32 ls_elevation_CICP2_fx[2];
extern const Word32 ls_azimuth_CICP6_fx[5];
+9 −0
Original line number Diff line number Diff line
@@ -1690,6 +1690,15 @@ void rotateAziEle_fx(
    Word32 Rmat[3][3],                                           /* i  : real-space rotation matrix                      */
    const Word16 isPlanar                                      /* i  : is roation planar and elevation meaningless?    */
);

void rotateAziEle_fixed(
    Word16 azi_in,                                               /* i  : output elevation                                */
    Word16 ele_in,                                               /* i  : input elevation                                 */
    Word32 *azi,                                               /* o  : rotated azimuth                                 */
    Word32 *ele,                                               /* o  : rotated elevation                               */
    Word32 Rmat[3][3],                                           /* i  : real-space rotation matrix                      */
    const Word16 isPlanar                                      /* i  : is roation planar and elevation meaningless?    */
);
void SHrotmatgen_fx(
    Word16 SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3],             /* o  : SHD rotation matrix                             */
    Word32 Rmat[3][3],                                           /* i  : real-space rotation matrix                      */
+84 −2
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ void rotateAziEle_fx(
    for ( n = 0; n < 3; n++ )
    {
        temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) );
        dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // q15
        dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30
    }

    /*Conversion cartesian to spherical coordinates*/
@@ -408,6 +408,85 @@ void rotateAziEle_fx(

    return;
}

/*-------------------------------------------------------------------------
 * rotateAziEle()
 *
 * Apply rotation to direction parameters azimuth and elevation
 *------------------------------------------------------------------------*/

void rotateAziEle_fixed(
    Word16 azi_in,        /* i  : output elevation                              */
    Word16 ele_in,        /* i  : input elevation                               */
    Word32 *azi,          /* o  : rotated azimuth                               */
    Word32 *ele,          /* o  : rotated elevation                             */
    Word32 Rmat_fx[3][3], /* i  : real-space rotation matrix                    */
    const Word16 isPlanar /* i  : is rotation planar and elevation meaningless? */
)
{
    Word16 n,radian,temp_16;
    Word32 dv_fx[3], dv_r_fx[3];
    Word32 w_fx;
    Word32 temp;
    Word32 y, x, sqrt_fx;
    Word32 angle;
    /*Conversion spherical to cartesian coordinates*/
    if ( abs( azi_in ) > 180 )
    {
        azi_in = ( azi_in > 0 ) ? ( azi_in - 360 ) : ( azi_in + 360 );
    }
    temp_16 = ele_in;
    w_fx = cosine_table_Q31[abs( temp_16 )];
    temp_16 = azi_in;
    dv_fx[0] = Mpy_32_32( w_fx, cosine_table_Q31[abs( temp_16 )] );
    temp_16 = azi_in;
    dv_fx[1] = Mpy_32_32( w_fx, sine_table_Q31[temp_16 + 180] );
    temp_16 = ele_in;
    dv_fx[2] = sine_table_Q31[temp_16 + 180];

    /*Rotation mtx multiplication*/
    for ( n = 0; n < 3; n++ )
    {
        temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) );
        dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30
    }

    /*Conversion cartesian to spherical coordinates*/
    y = dv_r_fx[1];
    x = dv_r_fx[0];
    radian = BASOP_util_atan2( y ,  x, 0 );//Q13
    
    angle = ( Mpy_32_16_1( _180_OVER_PI_Q25, radian ) >> 1);//Q22


    *azi = (Word32) ( max( L_shl(-180,22), min( L_shl(180,22), angle ) ) );//Q22
    if ( abs(*azi)<=ONE_IN_Q22 )
    {
        *azi = 0;
    }
    if ( isPlanar == 0 )
    {
        sqrt_fx = L_Frac_sqrtQ31( L_add( Mpy_32_32( dv_r_fx[0], dv_r_fx[0] ), Mpy_32_32( dv_r_fx[1], dv_r_fx[1] ) ) );
        y = dv_r_fx[2];
        x = sqrt_fx;
        radian = BASOP_util_atan2(  y ,  x ,0);
        
        angle = ( Mpy_32_16_1( _180_OVER_PI_Q25, radian ) >> 1 );//Q22


        *ele = (Word32) ( max( L_shl( -90, 22 ), min( L_shl( 90, 22 ), angle ) ) ); // Q22
        if ( abs( *ele ) < ONE_IN_Q22 )
        {
            *ele = 0;
        }
    }
    else
    {
        *ele = 0;
    }

    return;
}
#endif
/*-------------------------------------------------------------------------
 * rotateAziEle()
@@ -439,7 +518,10 @@ void rotateAziEle(
    {
        dv_r[n] = Rmat[n][0] * dv[0] + Rmat[n][1] * dv[1] + Rmat[n][2] * dv[2];
    }

    float inter,inter1,inter2;
    inter = atan2f( dv_r[1], dv_r[0] );
    inter1 = min( 180.0f, atan2f( dv_r[1], dv_r[0] ) * _180_OVER_PI );
    inter2 = max( -180.0f, min( 180.0f, atan2f( dv_r[1], dv_r[0] ) * _180_OVER_PI ) );
    /*Conversion cartesian to spherical coordinates*/
    *azi = (int16_t) roundf( max( -180.0f, min( 180.0f, atan2f( dv_r[1], dv_r[0] ) * _180_OVER_PI ) ) );
    if ( isPlanar == 0 )
Loading