Commit a425d6ef authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent d8a67817
Loading
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -4559,24 +4559,12 @@ void ivas_dirac_dec_get_response(
    const int16_t ambisonics_order
);
#ifdef IVAS_FLOAT_FIXED
void ivas_dirac_dec_get_response_fixed(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response,
    const Word16 ambisonics_order );

void ivas_dirac_dec_get_response_fixed_Q(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response,
    const Word16 ambisonics_order,
    Word16 Q);

void ivas_dirac_dec_get_response_fx(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 * response,
    const Word16 ambisonics_order);
    const Word16 ambisonics_order,
    Word16 Q_out);
#endif

void calculate_hodirac_sector_parameters(
+23 −254
Original line number Diff line number Diff line
@@ -3284,7 +3284,7 @@ void ivas_get_spar_md_from_dirac_fx(
            if ( n_ts > 1 )
            {
                // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, order );
                ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][i_ts], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][i_ts], Q22 ), response_avg_fx, order );
                ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][i_ts], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][i_ts], Q22 ), response_avg_fx, order, Q30 );
                /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
                {
                    response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 );
@@ -3293,7 +3293,7 @@ void ivas_get_spar_md_from_dirac_fx(
            else if ( useLowerRes )
            {
                // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][0], (int16_t) ele_dirac[band][0], response_avg, order );
                ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][0], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][0], Q22 ), response_avg_fx, order );
                ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][0], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][0], Q22 ), response_avg_fx, order, Q30 );
                /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
                {
                    response_avg[l] = (float) response_avg_fx[l] / ( 1 << 30 );
@@ -3304,7 +3304,7 @@ void ivas_get_spar_md_from_dirac_fx(
                for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ )
                {
                    // ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][block], (int16_t) ele_dirac[band][block], &( response[block][0] ), order );
                    ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][block], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][block], Q22 ), &( response_fx[block][0] ), order );
                    ivas_dirac_dec_get_response_fx( (int16_t) L_shr( azi_dirac_fx[band][block], Q22 ), (int16_t) L_shr( ele_dirac_fx[band][block], Q22 ), &( response_fx[block][0] ), order, Q30 );
                    /*for ( int l = 0; l < MAX_OUTPUT_CHANNELS; l++ )
                    {
                        response[block][l] = (float) response_fx[block][l] / ( 1 << 30 );
@@ -4060,128 +4060,13 @@ void ivas_dirac_dec_get_response(

#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------
 * ivas_dirac_dec_get_response_fixed()
 * ivas_dirac_dec_get_response_fx()
 *
 * Block Q of 29 is maintained
 * calculate reponse, 1 degree resolution
 * Input azimuth and elevation are expected in Q0
 *------------------------------------------------------------------------*/

void ivas_dirac_dec_get_response_fixed(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response,
    const Word16 ambisonics_order )
{
    Word16 index_azimuth, index_elevation;
    Word16 el, e, az;
    Word32 cos_1, cos_2, sin_1, cos_az[3];
    Word32 sin_az[3];
    Word32 f, c;
    Word16 l, m;
    Word16 b, b1, b_2, b1_2, a;

    index_azimuth = ( azimuth + 180 ) % 360;
    index_elevation = elevation + 90;
    e = index_elevation > 90 ? -1 : 1;
    el = index_elevation > 90 ? 180 - index_elevation : index_elevation;

    az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth;
    f = index_azimuth > 180 ? -( 1 << Q29 ) : ( 1 << Q29 );

    cos_1 = dirac_gains_trg_term_int[az][0] >> 1;                                                  // Q29
    cos_2 = Mpy_32_32( cos_1, cos_1 );                                                             // Q27
    sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] >> 1 );                                  // Q27
    cos_az[0] = cos_1;                                                                             // Q29
    cos_az[1] = L_sub( Mpy_32_32( ( 1 << Q30 ), cos_2 ), ( 1 << Q25 ) ) << 4;                      // Q29
    cos_az[2] = L_sub( Mpy_32_32( Mpy_32_32( ( 1 << Q30 ), cos_1 ), cos_az[1] ) << 4, cos_az[0] ); // Q29
    sin_az[0] = sin_1 << 2;                                                                        // Q29
    sin_az[1] = Mpy_32_32( Mpy_32_32( sin_1, ( 1 << Q30 ) ), cos_1 ) << 6;                         // Q29
    sin_az[2] = Mpy_32_32( sin_1, L_sub( L_shl_sat( Mpy_32_32( ( 1 << Q30 ), cos_2 ), 5 ), ( 1 << 29 ) ) ) << 4;

    response[0] = ( 1 << 29 );
    /* Un-optimized code - for reference */
    /*     for( l = 1; l<= ambisonics_order; l++ ) */
    /*     { */
    /*         int16_t b, b1, a; */
    /*         float c; */
    /*         for( m = 0; m < l; m++ ) */
    /*         { */
    /*             b = l*l+m; */
    /*             a = dirac_gains_P_idx[b]; */
    /*             c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */

    /*             if( m%2 == 1 ) */
    /*             { */
    /*                 c = c*e; */
    /*             } */

    /*             response[b] = c * sin_az[l-m-1]; */

    /*             b1 = l*l+2*l-m; */
    /*             response[b1] = c * cos_az[l-m-1]; */

    /*         } */

    /*         b = l*l+l; */
    /*         a = dirac_gains_P_idx[b]; */
    /*         c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */
    /*         if( l%2 == 1) */
    /*         { */
    /*             c = c*e; */
    /*         } */

    /*         response[b] = c; */
    /*     } */

    FOR( l = 1; l <= ambisonics_order; l++ )
    {
        b_2 = l * l;
        b1_2 = l * l + 2 * l;
        FOR( m = 0; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25

            response[b] = Mpy_32_32( c, sin_az[l - m - 1] ) << 6; // Q29

            b1 = b1_2 - m;
            response[b1] = Mpy_32_32( c, cos_az[l - m - 1] ) << 6; // Q29
        }

        FOR( m = 1; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25
            IF( e == -1 )
            {
                c = -c;
            }

            response[b] = Mpy_32_32( c, sin_az[l - m - 1] ) << 6; // Q29

            b1 = b1_2 - m;
            response[b1] = Mpy_32_32( c, cos_az[l - m - 1] ) << 6; // Q29
        }

        b = b_2 + l;
        a = dirac_gains_P_idx[b];
        c = Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ); // Q26
        IF( l % 2 == 1 )
        {
            IF( e == -1 )
            {
                c = -c;
            }
        }

        response[b] = c << 3; // Q29
    }

    return;
}
Word32 local_result_table[91][9] = {
    {
        -1518500224,
@@ -6193,7 +6078,8 @@ void ivas_dirac_dec_get_response_fx(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response_fx,
    const Word16 ambisonics_order )
    const Word16 ambisonics_order,
    Word16 Q_out)
{
    // float response[MAX_OUTPUT_CHANNELS];
    int16_t index_azimuth, index_elevation;
@@ -6203,7 +6089,7 @@ void ivas_dirac_dec_get_response_fx(
    // float sin_az[3];
    Word32 sin_az_fx[3];
    // float f, c;
    Word32 f_fx, c_fx;
    Word32 f_fx;
    Word32 c_fx_better;
    int16_t l, m;
    int16_t b, b1, b_2, b1_2, a;
@@ -6239,7 +6125,7 @@ void ivas_dirac_dec_get_response_fx(
    sin_az_fx[2] = L_shl_sat( Mpy_32_32( sin_1_fx, ( cos_2_fx - ONE_IN_Q29 ) ), 2 );

    // response[0] = 1.0f;
    response_fx[0] = ONE_IN_Q30;
    response_fx[0] = MAX_32;
    /* Un-optimized code - for reference */
    /*     for( l = 1; l<= ambisonics_order; l++ ) */
    /*     { */
@@ -6283,16 +6169,16 @@ void ivas_dirac_dec_get_response_fx(
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
            c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
            //c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
            c_fx_better = local_result_table[el][a];
            // response[b] = c * sin_az[l - m - 1];
            response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
            response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] );
            //response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
            response_fx[b] = L_shl_sat( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out

            b1 = b1_2 - m;
            // response[b1] = c * cos_az[l - m - 1];
            response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
            response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] );
            //response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
            response_fx[b1] = L_shl_sat( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
        }

        for ( m = 1; m < l; m += 2 )
@@ -6300,159 +6186,42 @@ void ivas_dirac_dec_get_response_fx(
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            // c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
            c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
            //c_fx = Mpy_32_32( SQRT2_FIXED, Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] ) );
            c_fx_better = local_result_table[el][a];
            if ( e == -1 )
            {
                c_fx = L_negate( c_fx );
                //c_fx = L_negate( c_fx );
                c_fx_better = L_negate( c_fx_better );
            }
            // c = c * e;

            // response[b] = c * sin_az[l - m - 1];
            response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
            response_fx[b] = Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] );
            //response_fx[b] = Mpy_32_32( L_shl( c_fx, 3 ), sin_az_fx[l - m - 1] );
            response_fx[b] = L_shl_sat(Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
            b1 = b1_2 - m;
            // response[b1] = c * cos_az[l - m - 1];
            response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
            response_fx[b1] = Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] );
            //response_fx[b1] = Mpy_32_32( L_shl( c_fx, 3 ), cos_az_fx[l - m - 1] );
            response_fx[b1] = L_shl_sat(Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 30 ) ); // Q_out
        }

        b = b_2 + l;
        a = dirac_gains_P_idx[b];
        // c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
        c_fx = Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] );
        //c_fx = Mpy_32_32( dirac_gains_norm_term_fx[a], dirac_gains_Pnm_int[el][a] );
        c_fx_better = local_result_table_2[el][a];
        if ( l % 2 == 1 )
        {
            // c = c * e;
            if ( e == -1 )
            {
                c_fx = L_negate( c_fx );
                //c_fx = L_negate( c_fx );
                c_fx_better = L_negate( c_fx_better );
            }
        }

        // response[b] = c;
        response_fx[b] = L_shl( c_fx, 2 );
        response_fx[b] = c_fx_better;
    }

    return;
}

void ivas_dirac_dec_get_response_fixed_Q(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 *response,
    const Word16 ambisonics_order,
    Word16 Q_out )
{
    Word16 index_azimuth, index_elevation;
    Word16 el, e, az;
    Word32 cos_1, cos_2, sin_1, cos_az[3];
    Word32 sin_az[3];
    Word32 f, c;
    Word16 l, m;
    Word16 b, b1, b_2, b1_2, a;

    index_azimuth = ( azimuth + 180 ) % 360;
    index_elevation = elevation + 90;
    e = index_elevation > 90 ? -1 : 1;
    el = index_elevation > 90 ? 180 - index_elevation : index_elevation;

    az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth;
    f = index_azimuth > 180 ? -( 1 << Q29 ) : ( 1 << Q29 );

    cos_1 = dirac_gains_trg_term_int[az][0] >> 1;                                                  // Q29
    cos_2 = Mpy_32_32( cos_1, cos_1 );                                                             // Q27
    sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] >> 1 );                                  // Q27
    cos_az[0] = cos_1;                                                                             // Q29
    cos_az[1] = L_sub( Mpy_32_32( ( 1 << Q30 ), cos_2 ), ( 1 << Q25 ) ) << 4;                      // Q29
    cos_az[2] = L_sub( Mpy_32_32( Mpy_32_32( ( 1 << Q30 ), cos_1 ), cos_az[1] ) << 4, cos_az[0] ); // Q29
    sin_az[0] = sin_1 << 2;                                                                        // Q29
    sin_az[1] = Mpy_32_32( Mpy_32_32( sin_1, ( 1 << Q30 ) ), cos_1 ) << 6;                         // Q29
    sin_az[2] = Mpy_32_32( sin_1, L_sub( L_shl_sat( Mpy_32_32( ( 1 << Q30 ), cos_2 ), 5 ), ( 1 << 29 ) ) ) << 4;

    response[0] = L_shl( 1, Q_out );
    /* Un-optimized code - for reference */
    /*     for( l = 1; l<= ambisonics_order; l++ ) */
    /*     { */
    /*         int16_t b, b1, a; */
    /*         float c; */
    /*         for( m = 0; m < l; m++ ) */
    /*         { */
    /*             b = l*l+m; */
    /*             a = dirac_gains_P_idx[b]; */
    /*             c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */

    /*             if( m%2 == 1 ) */
    /*             { */
    /*                 c = c*e; */
    /*             } */

    /*             response[b] = c * sin_az[l-m-1]; */

    /*             b1 = l*l+2*l-m; */
    /*             response[b1] = c * cos_az[l-m-1]; */

    /*         } */

    /*         b = l*l+l; */
    /*         a = dirac_gains_P_idx[b]; */
    /*         c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */
    /*         if( l%2 == 1) */
    /*         { */
    /*             c = c*e; */
    /*         } */

    /*         response[b] = c; */
    /*     } */

    FOR( l = 1; l <= ambisonics_order; l++ )
    {
        b_2 = l * l;
        b1_2 = l * l + 2 * l;
        FOR( m = 0; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25

            response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), Q_out - Q23 ); // Q_out

            b1 = b1_2 - m;
            response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), Q_out - Q23 ); // Q_out
        }

        FOR( m = 1; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25
            IF( e == -1 )
            {
                c = -c;
            }

            response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), Q_out - Q23 ); // Q29

            b1 = b1_2 - m;
            response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), Q_out - Q23 ); // Q29
        }

        b = b_2 + l;
        a = dirac_gains_P_idx[b];
        c = Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ); // Q26
        IF( l % 2 == 1 )
        {
            IF( e == -1 )
            {
                c = -c;
            }
        }

        response[b] = L_shl( c, Q_out - Q26 ); // Q29
        //response_fx[b] = L_shl( c_fx, 2 );
        response_fx[b] = L_shl_sat(c_fx_better, sub( Q_out, 30 ) ); // Q_out
    }

    return;
+0 −1
Original line number Diff line number Diff line
@@ -779,7 +779,6 @@ static void filt_mu_fx(
            Overflow = 0;
        }
#endif

#else
        sig_out[n] = shl( mult_r( ga, temp ), 1 );
#endif
+76 −74
Original line number Diff line number Diff line
@@ -109,8 +109,10 @@ static Word16 IGF_replaceTCXNoise_1( /**< ou
    nE = 0;
    move32();

    FOR( sb = start; sb < stop; sb++ ){
        IF( TCXNoise[sb] ){
    FOR( sb = start; sb < stop; sb++ )
    {
        IF ( TCXNoise[sb] )
        {
            tmp16 = extract_h( L_shl( in[sb], s_l ) );
        }
        IF ( TCXNoise[sb] )
+1 −1
Original line number Diff line number Diff line
@@ -1927,7 +1927,7 @@ ivas_error ivas_binRenderer_open_fx(
        {
            FOR( k = 0; k < 11; k++ )
            {
                ivas_dirac_dec_get_response_fixed( (Word16) L_shr_r( ls_azimuth_CICP19_fx[k], 22 ), (Word16) L_shr_r( ls_elevation_CICP19_fx[k], 22 ), hBinRenderer->hReverb->foa_enc_fx[k], 1 );
                ivas_dirac_dec_get_response_fx( (Word16) L_shr_r( ls_azimuth_CICP19_fx[k], 22 ), (Word16) L_shr_r( ls_elevation_CICP19_fx[k], 22 ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 );
                // Q29: hBinRenderer->hReverb->foa_enc_fx[k]
            }
        }
Loading