Commit 051f07b0 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

fix for failing OSBA HT test

parent 86438fdf
Loading
Loading
Loading
Loading
Loading
+67 −23
Original line number Diff line number Diff line
@@ -1849,6 +1849,24 @@ void ivas_dirac_dec_render_sf(
                set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands );
            }
        }

        if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 )
        {
            ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom,
                                                          hDirACRend,
                                                          st_ivas->hVBAPdata,
                                                          st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping,
                                                          st_ivas->hMasaIsmData,
                                                          azimuth,
                                                          elevation,
                                                          md_idx,
                                                          surCohRatio,
                                                          st_ivas->hCombinedOrientationData->shd_rot_max_order,
                                                          p_Rmat,
                                                          hodirac_flag );
        }
        else
        {
            ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom,
                                                          hDirACRend,
                                                          st_ivas->hVBAPdata,
@@ -1858,8 +1876,11 @@ void ivas_dirac_dec_render_sf(
                                                          elevation,
                                                          md_idx,
                                                          surCohRatio,
                                                          0,
                                                          NULL,
                                                          hodirac_flag );
        }
    }

    if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 )
    {
@@ -2188,6 +2209,8 @@ void ivas_dirac_dec_render_sf(
        }

        /*Compute PSDs*/
        if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 )
        {
            ivas_dirac_dec_output_synthesis_process_slot( reference_power,
                                                          p_onset_filter,
                                                          azimuth,
@@ -2195,12 +2218,33 @@ void ivas_dirac_dec_render_sf(
                                                          hSpatParamRendCom->diffuseness_vector[md_idx],
                                                          hSpatParamRendCom,
                                                          hDirACRend,
                                                          st_ivas->hCombinedOrientationData->shd_rot_max_order,
                                                          p_Rmat,
                                                          st_ivas->hVBAPdata,
                                                          hDirACRend->hOutSetup,
                                                          nchan_transport,
                                                          md_idx,
                                                          hodirac_flag,
                                                          hDirAC->hConfig->dec_param_estim );
        }
        else
        {
            ivas_dirac_dec_output_synthesis_process_slot( reference_power,
                                                          p_onset_filter,
                                                          azimuth,
                                                          elevation,
                                                          hSpatParamRendCom->diffuseness_vector[md_idx],
                                                          hSpatParamRendCom,
                                                          hDirACRend,
                                                          0,
                                                          0,
                                                          st_ivas->hVBAPdata,
                                                          hDirACRend->hOutSetup,
                                                          nchan_transport,
                                                          md_idx,
                                                          hodirac_flag,
                                                          hDirAC->hConfig->dec_param_estim );
        }

        if ( hDirAC->hConfig->dec_param_estim )
        {
+190 −7
Original line number Diff line number Diff line
@@ -542,6 +542,8 @@ void ivas_dirac_dec_output_synthesis_process_slot(
    const float *diffuseness,
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                         /* i/o: DirAC renderer handle                       */
    const int16_t sh_rot_max_order,
    const float *p_Rmat,               /* i  : rotation matrix             */
    const VBAP_HANDLE hVBAPdata,       /* i  : VBAP structure              */
    const IVAS_OUTPUT_SETUP hOutSetup, /* i  : output setup structure      */
    const int16_t nchan_transport,     /* i  : number of transport channels*/
@@ -588,6 +590,8 @@ void ivas_dirac_dec_output_synthesis_process_slot(
                                                      elevation,
                                                      md_idx,
                                                      NULL,
                                                      2,
                                                      p_Rmat,
                                                      hodirac_flag );
    }

@@ -634,6 +638,8 @@ void ivas_dirac_dec_output_synthesis_process_slot(
                                                      elevation,
                                                      md_idx,
                                                      NULL,
                                                      sh_rot_max_order,
                                                      p_Rmat,
                                                      hodirac_flag );

        if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
@@ -1565,6 +1571,169 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls(
}


/*-------------------------------------------------------------------------
 * ivas_dirac_dec_get_response_split_order()
 *
 * calculate reponse, 1 degree resolution
 *------------------------------------------------------------------------*/

static void ivas_dirac_dec_get_response_split_order(
    const int16_t azimuth,
    const int16_t elevation,
    float *response,
    const int16_t shd_rot_max_order,
    const float *p_Rmat )
{
    int16_t index_azimuth, index_elevation;
    int16_t el, e, az;
    float cos_1, cos_2, sin_1, cos_az[3];
    float sin_az[3];
    float f, c;
    int16_t l, m;
    int16_t b, b1, b_2, b1_2, a;
    float dv_0, dv_1, dv_2, dv_r_0, dv_r_1, dv_r_2;
    float w;

    push_wmops( "ivas_dirac_dec_get_response_split_order" );

    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.0f : 1.0f;

    cos_1 = dirac_gains_trg_term[az][0];
    sin_1 = f * dirac_gains_trg_term[az][1];

    cos_2 = cos_1 * cos_1;

    cos_az[0] = cos_1;
    cos_az[1] = 2.0f * cos_2 - 1.0f;
    cos_az[2] = 2.0f * cos_1 * cos_az[1] - cos_az[0];
    sin_az[0] = sin_1;
    sin_az[1] = sin_1 * 2.0f * cos_1;
    sin_az[2] = sin_1 * ( 4.0f * cos_2 - 1.0f );

    response[0] = 1.0f;
    for ( l = 1; l <= shd_rot_max_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 = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];

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

            b1 = b1_2 - m;
            response[b1] = c * cos_az[l - m - 1];
        }

        for ( m = 1; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
            c = c * e;

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

            b1 = b1_2 - m;
            response[b1] = c * cos_az[l - m - 1];
        }

        b = b_2 + 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;
    }

    /*Conversion spherical to cartesian coordinates*/
    w = -dirac_gains_trg_term[el][1];
    dv_0 = w * cos_1;
    dv_1 = w * sin_1;
    dv_2 = e * dirac_gains_trg_term[el][0];

    /*Rotation mtx multiplication*/
    dv_r_0 = p_Rmat[0] * dv_0 + p_Rmat[1] * dv_1 + p_Rmat[2] * dv_2;
    dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2;
    dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2;

    index_azimuth = ( (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ) + 180 ) % 360;
    index_elevation = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ) + 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.0f : 1.0f;

    cos_1 = dirac_gains_trg_term[az][0];
    sin_1 = f * dirac_gains_trg_term[az][1];

    cos_2 = cos_1 * cos_1;

    cos_az[0] = cos_1;
    cos_az[1] = 2.0f * cos_2 - 1.0f;
    cos_az[2] = 2.0f * cos_1 * cos_az[1] - cos_az[0];
    sin_az[0] = sin_1;
    sin_az[1] = sin_1 * 2.0f * cos_1;
    sin_az[2] = sin_1 * ( 4.0f * cos_2 - 1.0f );

    for ( l = shd_rot_max_order + 1; l <= 3; 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 = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];

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

            b1 = b1_2 - m;
            response[b1] = c * cos_az[l - m - 1];
        }

        for ( m = 1; m < l; m += 2 )
        {
            b = b_2 + m;
            a = dirac_gains_P_idx[b];
            c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a];
            c = c * e;

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

            b1 = b1_2 - m;
            response[b1] = c * cos_az[l - m - 1];
        }

        b = b_2 + 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;
    }

    pop_wmops();

    return;
}


/*-------------------------------------------------------------------------
 * ivas_dirac_dec_compute_directional_responses()
 *
@@ -1581,6 +1750,8 @@ void ivas_dirac_dec_compute_directional_responses(
    const int16_t *elevation,
    const int16_t md_idx,
    const float *surCohRatio,
    const int16_t shd_rot_max_order, /* i  : split-order rotation method    */
    const float *p_Rmat,             /* i  : rotation matrix                */
    const int16_t hodirac_flag       /* i  : flag to indicate HO-DirAC mode */
)
{
@@ -1651,12 +1822,24 @@ void ivas_dirac_dec_compute_directional_responses(
                set_f( direct_response_hoa, 1.0f, MAX_OUTPUT_CHANNELS );
                set_f( direct_response_dir2, 1.0f, MAX_OUTPUT_CHANNELS );

                if ( p_Rmat != 0 )
                {
                    ivas_dirac_dec_get_response_split_order( azimuth[k], elevation[k], direct_response_hoa, shd_rot_max_order, p_Rmat );

                    if ( hodirac_flag )
                    {
                        ivas_dirac_dec_get_response_split_order( azimuth2[k], elevation2[k], direct_response_dir2, shd_rot_max_order, p_Rmat );
                    }
                }
                else
                {
                    ivas_dirac_dec_get_response( azimuth[k], elevation[k], direct_response_hoa, hDirACRend->hOutSetup.ambisonics_order );

                    if ( hodirac_flag )
                    {
                        ivas_dirac_dec_get_response( azimuth2[k], elevation2[k], direct_response_dir2, hDirACRend->hOutSetup.ambisonics_order );
                    }
                }

                if ( masa_band_mapping == NULL && hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
                {
+4 −0
Original line number Diff line number Diff line
@@ -2216,6 +2216,8 @@ static void ivas_masa_ext_dirac_render_sf(
                                                  elevation,
                                                  md_idx,
                                                  surCohRatio,
                                                  0,
                                                  NULL,
                                                  0 );


@@ -2370,6 +2372,8 @@ static void ivas_masa_ext_dirac_render_sf(
                                                      hSpatParamRendCom->diffuseness_vector[md_idx],
                                                      hSpatParamRendCom,
                                                      hDirACRend,
                                                      0,
                                                      0,
                                                      hMasaExtRend->hVBAPdata,
                                                      hDirACRend->hOutSetup,
                                                      nchan_transport,
+4 −0
Original line number Diff line number Diff line
@@ -435,6 +435,8 @@ void ivas_dirac_dec_output_synthesis_process_slot(
    const float *diffuseness,
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom,       /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const int16_t sh_rot_max_order,
    const float *p_Rmat,                                        /* i  : rotation matrix                             */
    const VBAP_HANDLE hVBAPdata,                                /* i  : VBAP structure                              */
    const IVAS_OUTPUT_SETUP hOutSetup,                          /* i  : output setup structure                      */
    const int16_t nchan_transport,                              /* i  : number of transport channels                */
@@ -501,6 +503,8 @@ void ivas_dirac_dec_compute_directional_responses(
    const int16_t *elevation,
    const int16_t md_idx,
    const float *surCohRatio,
    const int16_t shd_rot_max_order,                            /* i  : split-order rotation method                                    */
    const float *p_Rmat,                                        /* i  : rotation matrix                                                */
    const int16_t hodirac_flag                                  /* i  : flag to indicate HO-DirAC mode                                 */
);