diff --git a/lib_com/options.h b/lib_com/options.h index 4a8f7d3216b51408a7977fe6497cc240c60a706b..54347c8f135043e28fa3098f7c18f2610f4bdda4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,6 +190,8 @@ #define FIX_956_DECODER_COMMAND_LINE_FIX /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ #define FIX_958_667_DISABLE_INITIAL_PLC_SUPPRESSION /* Ericsson: Fix related to issue 667 in IVAS BASOP. Handling of initial lost frame in IVAS causes non-BE on EVS BASOP 26.444 */ +#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 BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index e60e17608ece168e1d3a03464f0762391dfe0d0c..5e01f7e4c468a43a49a0ab2e17ee7ff7b56315e9 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -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,56 +217,105 @@ void ivas_ism_render_sf( set_f( output_f[i], 0.0f, n_samples_to_render ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) +#ifdef NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); - interp_offset = 0; - } + int16_t n_samples_in_subframe; - for ( i = 0; i < num_objects; i++ ) - { - /* 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 ) - { - rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); + n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; +#endif - if ( st_ivas->hEFAPdata != NULL ) - { - efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); - } + 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; } - lfe_index = 0; - for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) + for ( i = 0; i < num_objects; i++ ) { - if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) + /* 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 ) { - ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; +#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 ); + } } - gain = st_ivas->hIsmRendererData->gains[i][j]; - prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; - if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) + lfe_index = 0; + for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) { - g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; - tc = p_tc[i]; - for ( k = 0; k < n_samples_to_render; k++ ) + if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) + { + ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; + } + + gain = st_ivas->hIsmRendererData->gains[i][j]; + prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; + if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { - g2 = 1.0f - *g1; + 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 + } } - } - /* update here only in case of head rotation */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) - { - st_ivas->hIsmRendererData->prev_gains[i][j] = gain; + /* update here only in case of head rotation */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) + { + 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 */ + /* 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; }