Commit cc0decd0 authored by norvell's avatar norvell
Browse files

Merge branch 'main' into ci/test-new-basop-ci-branch

parents 8a46d337 f7e4301a
Loading
Loading
Loading
Loading
Loading
+14 −28
Original line number Diff line number Diff line
@@ -2043,8 +2043,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17036;
                hs->p_filter = CLDFB80_10_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_10_SCALE );
                hs->scale = (Word16) ( CLDFB80_10_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_10_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2064,8 +2063,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15388;
                hs->p_filter = LDQMF_10_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_10_SCALE );
                hs->scale = (Word16) ( LDQMF_10_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_10_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2098,8 +2096,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17051;
                hs->p_filter = CLDFB80_16_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_16_SCALE );
                hs->scale = (Word16) ( CLDFB80_16_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_16_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2119,8 +2116,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15388;
                hs->p_filter = LDQMF_16_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_16_SCALE );
                hs->scale = (Word16) ( LDQMF_16_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_16_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2153,8 +2149,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17050;
                hs->p_filter = CLDFB80_20_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_20_SCALE );
                hs->scale = (Word16) ( CLDFB80_20_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_20_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2174,8 +2169,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15390;
                hs->p_filter = LDQMF_20_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_20_SCALE );
                hs->scale = (Word16) ( LDQMF_20_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_20_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2208,8 +2202,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17051;
                hs->p_filter = CLDFB80_30_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_30_SCALE );
                hs->scale = (Word16) ( CLDFB80_30_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_30_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2229,8 +2222,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15388;
                hs->p_filter = LDQMF_30_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_30_SCALE );
                hs->scale = (Word16) ( LDQMF_30_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_30_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2263,8 +2255,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17050;
                hs->p_filter = CLDFB80_32_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_32_SCALE );
                hs->scale = (Word16) ( CLDFB80_32_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_32_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2284,8 +2275,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15392;
                hs->p_filter = LDQMF_32_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_32_SCALE );
                hs->scale = (Word16) ( LDQMF_32_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_32_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2318,8 +2308,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_re_fx = NULL;
                hs->p_filter_sf = (Word16) 17051;
                hs->p_filter = CLDFB80_40_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_40_SCALE );
                hs->scale = (Word16) ( CLDFB80_40_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_40_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2339,8 +2328,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15391;
                hs->p_filter = LDQMF_40_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_40_SCALE );
                hs->scale = (Word16) ( LDQMF_40_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_40_SCALE_FX_Q8;
#endif
            }
            break;
@@ -2373,8 +2361,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = NULL;
                hs->p_filter_sf = (Word16) 17051;
                hs->p_filter = CLDFB80_60_fx;
                hs->q_scale = norm_s( (Word16) CLDFB80_60_SCALE );
                hs->scale = (Word16) ( CLDFB80_60_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = CLDFB80_60_SCALE_FX_Q8;
#endif
            }
            else if ( hs->prototype == CLDFB_PROTOTYPE_5_00MS )
@@ -2394,8 +2381,7 @@ static void cldfb_init_proto_and_twiddles(
                hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->p_filter_sf = (Word16) 15391;
                hs->p_filter = LDQMF_60_fx;
                hs->q_scale = norm_s( (Word16) LDQMF_60_SCALE );
                hs->scale = (Word16) ( LDQMF_60_SCALE * ( 1 << hs->q_scale ) );
                hs->scale = LDQMF_60_SCALE_FX_Q8;
#endif
            }
            break;
+14 −0
Original line number Diff line number Diff line
@@ -794,6 +794,13 @@ typedef enum
#define CLDFB80_32_SCALE                   88.303848f
#define CLDFB80_40_SCALE                   88.304726f
#define CLDFB80_60_SCALE                   88.028412f
#define CLDFB80_10_SCALE_FX_Q8             ( 22603 )
#define CLDFB80_16_SCALE_FX_Q8             ( 22605 )
#define CLDFB80_20_SCALE_FX_Q8             ( 22605 )
#define CLDFB80_30_SCALE_FX_Q8             ( 22588 )
#define CLDFB80_32_SCALE_FX_Q8             ( 22606 )
#define CLDFB80_40_SCALE_FX_Q8             ( 22606 )
#define CLDFB80_60_SCALE_FX_Q8             ( 22535 )

#define LDQMF_10_SCALE                      84.567841f
#define LDQMF_16_SCALE                      84.567932f
@@ -802,6 +809,13 @@ typedef enum
#define LDQMF_32_SCALE                      84.568001f
#define LDQMF_40_SCALE                      84.567986f
#define LDQMF_60_SCALE                      84.303284f
#define LDQMF_10_SCALE_FX_Q8                ( 21649 )
#define LDQMF_16_SCALE_FX_Q8                ( 21649 )
#define LDQMF_20_SCALE_FX_Q8                ( 21649 )
#define LDQMF_30_SCALE_FX_Q8                ( 21632 )
#define LDQMF_32_SCALE_FX_Q8                ( 21649 )
#define LDQMF_40_SCALE_FX_Q8                ( 21649 )
#define LDQMF_60_SCALE_FX_Q8                ( 21582 )

#define L_FFT                               256                     /* Spectral analysis - length of the FFT */
#define LOG2_L_FFT                          8                       /* Spectral analysis - log2 of L_FFT */
+4 −16
Original line number Diff line number Diff line
@@ -384,12 +384,12 @@ ivas_error create_cpe_dec(
ivas_error create_mct_dec_fx(
	Decoder_Struct *st_ivas /* i/o: IVAS decoder structure  */
);
#endif // IVAS_FLOAT_FIXED
#else // IVAS_FLOAT_FIXED

ivas_error create_mct_dec(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
);

#endif
ivas_error mct_dec_reconfigure(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const uint16_t b_nchan_change                               /* i  : flag indicating different channel count */
@@ -4553,24 +4553,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] = L_shl_sat( 1, Q_out );
    /* 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;
+2 −3
Original line number Diff line number Diff line
@@ -781,8 +781,7 @@ typedef struct cldfb_filter_bank_struct
    Word16 filtermode;

    float scale_flt;                                /* scaling of frequency domain */
    Word16 scale;
    Word16 q_scale;
    Word16 scale; /* scaling of frequency domain */ /* Q8 */

} CLDFB_FILTER_BANK, *HANDLE_CLDFB_FILTER_BANK;

Loading