Commit 30d00063 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch '968-ism-to-binaural_room_ir-not-be-between-20ms-and-5ms-rendering' into 'main'

[Non-BE] Resolve "ISM to BINAURAL_ROOM_IR not BE between 20ms and 5ms rendering"

See merge request !1333
parents acfa67af 57923340
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@
#define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER           /* Qualcomm: issue 953: fix order or ER channels in LC mode*/
#define NONBE_FIX_949_MC_5MS_FRAMING                          /* Dlb: issue 949: fix for issue 949, distorted output in MC mode with 5ms framing*/
#define NONBE_FIX_952_MC_PARAMUPMIX_5MS                       /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/
#define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX      /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/

/* ##################### End NON-BE switches ########################### */

+111 −32
Original line number Diff line number Diff line
@@ -154,6 +154,24 @@ void ivas_ism_render_sf(
    float gain, prev_gain;
    float tc_local[MAX_NUM_OBJECTS][L_FRAME48k];
    float *p_tc[MAX_NUM_OBJECTS];
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
    int16_t ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx;
    int16_t n_samples_rendered_loop;
#endif

#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
    /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
    slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / st_ivas->hTcBuffer->n_samples_granularity );
    first_sf = st_ivas->hTcBuffer->subframes_rendered;
    last_sf = first_sf;
    n_samples_rendered_loop = 0;

    while ( slots_to_render > 0 )
    {
        slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf];
        last_sf++;
    }
#endif

    num_objects = st_ivas->nchan_transport;
    if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
@@ -166,6 +184,18 @@ void ivas_ism_render_sf(
    tc_offset = st_ivas->hTcBuffer->n_samples_rendered;
    interp_offset = st_ivas->hTcBuffer->n_samples_rendered;

#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
    /* Number of subframes to delay metadata to sync with audio */
    if ( st_ivas->hDecoderConfig->Opt_delay_comp )
    {
        ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 );
    }
    else
    {
        ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2;
    }
#endif

    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        for ( i = 0; i < num_objects; i++ )
@@ -187,9 +217,21 @@ void ivas_ism_render_sf(
        set_f( output_f[i], 0.0f, n_samples_to_render );
    }

#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
    for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    {
        int16_t n_samples_in_subframe;

        n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
#endif

        if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
        {
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
            ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator );
#else
        ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator );
#endif
            interp_offset = 0;
        }

@@ -198,8 +240,18 @@ void ivas_ism_render_sf(
            /* Combined rotation: rotate the object positions depending the head and external orientations */
            if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 )
            {
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
                if ( subframe_idx >= ism_md_subframe_update_jbm )
                {
                    rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
                }
                else
                {
                    rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
                }
#else
            rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup );

#endif
                if ( st_ivas->hEFAPdata != NULL )
                {
                    efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP );
@@ -220,10 +272,18 @@ void ivas_ism_render_sf(
                {
                    g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset];
                    tc = p_tc[i];
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
                    for ( k = 0; k < n_samples_in_subframe; k++ )
#else
                for ( k = 0; k < n_samples_to_render; k++ )
#endif
                    {
                        g2 = 1.0f - *g1;
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
                        output_f[j2][k + n_samples_rendered_loop] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ );
#else
                    output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ );
#endif
                    }
                }

@@ -233,10 +293,29 @@ void ivas_ism_render_sf(
                    st_ivas->hIsmRendererData->prev_gains[i][j] = gain;
                }
            }
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
            p_tc[i] += n_samples_in_subframe;
#endif
        }

        /* update combined orientation access index */
#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
        ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_in_subframe );
#else
    ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render );
#endif

#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX
        n_samples_rendered_loop += n_samples_in_subframe;
        if ( st_ivas->renderer_type == RENDERER_TD_PANNING )
        {
            st_ivas->hTcBuffer->subframes_rendered += 1;
            st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[subframe_idx];
        }
        tc_offset += n_samples_in_subframe;
        interp_offset += n_samples_in_subframe;
    }
#endif

    return;
}