diff --git a/apps/decoder.c b/apps/decoder.c index 197f90b8d0d5152c152906f96d46aadbd60ddfda..0b83b180db809fbcb1e2b67aefae7976e64c69a7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -388,12 +388,20 @@ int main( /*------------------------------------------------------------------------------------------* * Configure the decoder *------------------------------------------------------------------------------------------*/ - +#ifdef FIX_356_ISM_METADATA_SYNC +#ifdef FIX_439_OTR_PARAMS + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif +#else #ifdef FIX_439_OTR_PARAMS if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain ) ) != IVAS_ERR_OK ) #endif +#endif + { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 518a28aba7891a99013151f77d36ebfdcb544980..003d9422451fb3fd2b6fda1c1ff11047a0a3d816 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -69,17 +69,10 @@ int32_t get_delay( { delay = IVAS_ENC_DELAY_NS; -#ifdef FIX_356_ISM_METADATA_SYNC - if ( ivas_format == ISM_FORMAT || ivas_format == MASA_FORMAT ) - { - delay = 0; /* All delay is compensated in the decoder with MASA/ISM */ - } -#else if ( ivas_format == MASA_FORMAT ) { delay = 0; /* All delay is compensated in the decoder with MASA */ } -#endif } if ( ivas_format == SBA_FORMAT ) @@ -111,17 +104,10 @@ int32_t get_delay( delay += IVAS_FB_DEC_DELAY_NS; } -#ifdef FIX_356_ISM_METADATA_SYNC - if ( ivas_format == ISM_FORMAT || ivas_format == MASA_FORMAT ) - { - delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with ISM/MASA */ - } -#else if ( ivas_format == MASA_FORMAT ) { delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with MASA */ } -#endif } } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 7069e7d08f802323211d6f43aae28406273d84b3..e0e6a28725bfe326089cee562935aac2896210c3 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -268,6 +268,7 @@ ivas_error ivas_dec( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { + #ifdef JBM_TSM_ON_TCS if ( ( ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8aa2f72f4538e9c104ae2f81afe2a0e9754ac7d2..1849ce6bdf2477cc1436d15bc99a67a4d435fe46 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -76,7 +76,16 @@ ivas_error ivas_td_binaural_renderer( ) { #ifdef FIX_356_ISM_METADATA_SYNC - int16_t ism_md_subframe_update = 2; + int16_t ism_md_subframe_update; + + if ( st_ivas->hDecoderConfig->Opt_delay_comp ) + { + ism_md_subframe_update = 1; + } + else + { + ism_md_subframe_update = 2; + } return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, @@ -113,8 +122,19 @@ void ObjRenderIVASSubframe( float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t ch, slot_size, slots_to_render, output_frame; #ifdef FIX_356_ISM_METADATA_SYNC - int16_t ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2; /* Number of subframes to delay metadata to sync with audio */ + int16_t ism_md_subframe_update_jbm; int16_t c_indx, nS; + + /* 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 for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index af9d5da5f4f7fe0dd5d67026fff4ac1f3ad6ceb9..e3b97e632d771f81654c10a8aea4cd2264f05636 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1224,7 +1224,9 @@ typedef struct decoder_config_structure #ifdef JBM_TSM_ON_TCS int16_t voip_active; #endif - +#ifdef FIX_356_ISM_METADATA_SYNC + int16_t Opt_delay_comp; /* flag indicating delay compensation active */ +#endif } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2b04b15c8550934023952a6cf5e27f24989860f0..6e26744341e6bce7869ae2dc8a97d838465cabc0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -276,6 +276,11 @@ static void init_decoder_config( #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 0; #endif + +#ifdef FIX_356_ISM_METADATA_SYNC + hDecoderConfig->Opt_delay_comp = 0; +#endif + return; } @@ -442,7 +447,12 @@ ivas_error IVAS_DEC_Configure( #endif const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ - const float non_diegetic_pan_gain /* i : non diegetic panning gain */ +#ifdef FIX_356_ISM_METADATA_SYNC + const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ + const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#else + const float non_diegetic_pan_gain /* i : non diegetic panning gain */ +#endif ) { Decoder_Struct *st_ivas; @@ -498,6 +508,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled; hDecoderConfig->Opt_non_diegetic_pan = Opt_non_diegetic_pan; hDecoderConfig->non_diegetic_pan_gain = non_diegetic_pan_gain; +#ifdef FIX_356_ISM_METADATA_SYNC + hDecoderConfig->Opt_delay_comp = delayCompensationEnabled; +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -1592,14 +1605,6 @@ ivas_error IVAS_DEC_GetDelay( nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); nSamples[0] = nSamples[1] + nSamples[2]; -#ifdef FIX_356_ISM_METADATA_SYNC - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - /* note: in ISM, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ - nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); - } -#endif - *timeScale = hDecoderConfig->output_Fs; return IVAS_ERR_OK; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 65e36b055ba91935b429c60c6cd4fd97eff99136..d8418916e2210cedebf872262bf2f21803144eae 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -152,7 +152,12 @@ ivas_error IVAS_DEC_Configure( #endif const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ +#ifdef FIX_356_ISM_METADATA_SYNC + const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ + const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#else const float non_diegetic_pan_gain /* i : non diegetic panning gain */ +#endif ); void IVAS_DEC_Close( diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 3d929e78c7dc4ee6c4f3f85bd3cc160e95db113c..b6427949a0acce5a3f017352d36f3a875263df05 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -278,6 +278,9 @@ ivas_error ivas_td_binaural_renderer_unwrap( int16_t subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; ivas_error error; +#ifdef FIX_356_ISM_METADATA_SYNC + int16_t c_indx, nS; +#endif #ifdef JBM_TSM_ON_TCS float *p_reverb_signal[BINAURAL_CHANNELS]; int16_t ch; @@ -291,9 +294,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; #ifdef FIX_356_ISM_METADATA_SYNC - int16_t c_indx, nS; c_indx = 0; - for ( nS = 0; nS < num_src; nS++ ) { if ( !( ivas_format == MC_FORMAT && nS == lfe_idx ) ) /* Skip LFE for MC */ @@ -369,10 +370,11 @@ ivas_error TDREND_GetMix( float output[][L_FRAME48k], /* i/o: ISM object synth / rendered output in 0,1 */ #endif const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ #ifdef FIX_356_ISM_METADATA_SYNC - , + const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ const int16_t ism_md_subframe_update /* Number of subframes to delay ism metadata to sync with audio */ +#else + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ #endif ) { @@ -386,9 +388,9 @@ ivas_error TDREND_GetMix( float hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; int16_t intp_count; float pan_left, pan_right; - #ifdef FIX_356_ISM_METADATA_SYNC int16_t subframe_update_flag; + subframe_update_flag = subframe_idx == ism_md_subframe_update; #endif @@ -415,13 +417,11 @@ ivas_error TDREND_GetMix( if ( ( SrcRend_p->PlayStatus == TDREND_PLAYSTATUS_PLAYING ) && ( hBinRendererTd->Listener_p->PoseUpdated || SrcSpatial_p->Updated ) ) { TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, Src_p->hrf_left_prev, - Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p, #ifdef FIX_356_ISM_METADATA_SYNC - subframe_update_flag + Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p, subframe_update_flag ); #else - subframe_idx + Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p, subframe_idx ); #endif - ); } /* Render source if needed */ @@ -691,7 +691,7 @@ ivas_error ivas_td_binaural_renderer_ext( AUDIO_CONFIG transport_config; ivas_error error; #ifdef FIX_356_ISM_METADATA_SYNC - int16_t ism_md_subframe_update_ext = 0; + int16_t ism_md_subframe_update_ext; #endif #ifdef JBM_TSM_ON_TCS float *p_output[MAX_OUTPUT_CHANNELS]; @@ -708,6 +708,9 @@ ivas_error ivas_td_binaural_renderer_ext( inConfigType = getAudioConfigType( inConfig ); lfe_idx = LFE_CHANNEL; hIsmMetaData[0] = NULL; +#ifdef FIX_356_ISM_METADATA_SYNC + ism_md_subframe_update_ext = 0; +#endif if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { @@ -754,7 +757,7 @@ ivas_error ivas_td_binaural_renderer_ext( #ifdef FIX_356_ISM_METADATA_SYNC if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, - ( headRotData != NULL ) ? headRotData->Pos : NULL, ism_md_subframe_update, output, output_frame ) ) != IVAS_ERR_OK ) + ( headRotData != NULL ) ? headRotData->Pos : NULL, ism_md_subframe_update_ext, output, output_frame ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index bcd56aa643e64c9e317545842f0efaa4cd0e75ef..de652e6f984a32beba9a91d5836e7dfe92d3cfb0 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -291,10 +291,11 @@ ivas_error TDREND_GetMix( float output[][L_FRAME48k], /* i/o: ISM object synth / rendered output in 0,1 */ #endif const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ #ifdef FIX_356_ISM_METADATA_SYNC - , + const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ const int16_t ism_md_subframe_update /* Number of subframes to delay metadata to sync with audio */ +#else + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ #endif );