From 1eff04193e9dc5e08b2dd123bf6070189129aaf3 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 5 Mar 2026 11:04:44 +0200 Subject: [PATCH 1/2] Fix the float issue 1528 by adding a rendering time resolution independent counter. --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer.c | 23 ++++++++++++++++++++++- lib_rend/ivas_prot_rend.h | 8 ++++++++ lib_rend/ivas_stat_rend.h | 3 +++ lib_rend/lib_rend.c | 13 ++++++++++--- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 13a0c786d3..3da1b39ce5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,7 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.258 V3.0 */ #define FIX_FLOAT_1493_MASA_ENCODE_STABILITY_IMPROVE /* Nokia: float issue 1493: Improves float decision stability in MASA encoding by adjusting reduction code */ +#define FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION /* Nokia: float issue 1528: Fixes incorrect compensation for ISM metadata delay in 5ms TD rendering */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 5aed6c3335..7353b2ce65 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -318,6 +318,10 @@ ivas_error ivas_td_binaural_renderer_unwrap( float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame, /* i : output frame length */ const int16_t num_subframes /* i : number of subframes to render */ +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + , + int16_t *metaSfCounter /* i/o: subframe counter for metadata update */ +#endif ) { int16_t subframe_length; @@ -361,7 +365,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( for ( subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + if ( *metaSfCounter == ism_md_subframe_update ) +#else if ( subframe_idx == ism_md_subframe_update ) +#endif { /* Update object position(s) */ if ( ( error = TDREND_Update_object_positions( hBinRendererTd, num_src, ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) @@ -370,6 +378,10 @@ ivas_error ivas_td_binaural_renderer_unwrap( } } +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + *metaSfCounter = ( *metaSfCounter + 1 ) % 4; + +#endif /* Update the listener's location/orientation */ if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL ) ) != IVAS_ERR_OK ) { @@ -722,7 +734,11 @@ ivas_error ivas_td_binaural_open_ext( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_ext( - const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + TDREND_WRAPPER *pTDRend, /* i/o: TD Renderer wrapper structure */ +#else + const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ +#endif const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ @@ -790,8 +806,13 @@ ivas_error ivas_td_binaural_renderer_ext( hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, + ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ), &( pTDRend->metaSfCounter ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 15469e0aa7..d33b372b9c 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -641,10 +641,18 @@ ivas_error ivas_td_binaural_renderer_unwrap( float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame, /* i : output frame length */ const int16_t num_subframes /* i : number of subframes to render */ +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + , + int16_t *metaSfCounter /* i/o: subframe counter for metadata update */ +#endif ); ivas_error ivas_td_binaural_renderer_ext( +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + TDREND_WRAPPER *pTDRend, /* i/o: TD Renderer wrapper structure */ +#else const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ +#endif const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ef082716f9..815355d021 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1141,6 +1141,9 @@ typedef struct int32_t binaural_latency_ns; BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; TDREND_HRFILT_FiltSet_t **hHrtfTD; +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + int16_t metaSfCounter; +#endif } TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3d9609359b..b6c3f61487 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1253,6 +1253,9 @@ static TDREND_WRAPPER defaultTdRendWrapper( w.binaural_latency_ns = 0; w.hBinRendererTd = NULL; w.hHrtfTD = NULL; +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + w.metaSfCounter = 0; +#endif return w; } @@ -5679,7 +5682,11 @@ static ivas_error rotateFrameSba( static ivas_error renderIsmToBinaural( +#ifdef FIX_FLOAT_1528_5MS_REND_ISM_META_DELAY_COMPENSATION + input_ism *ismInput, +#else const input_ism *ismInput, +#endif IVAS_REND_AudioBuffer outAudio ) { float tmpTDRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -7842,8 +7849,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; - float( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float ( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float ( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; if ( hIvasRend == NULL ) { @@ -8211,7 +8218,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 2b4d6a9daa003740223666f14d36598aa9671679 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 5 Mar 2026 12:40:18 +0200 Subject: [PATCH 2/2] Apply clang format in surprising place --- lib_rend/lib_rend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index b6c3f61487..ece820a9ec 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7849,8 +7849,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; - float ( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float ( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; if ( hIvasRend == NULL ) { @@ -8218,7 +8218,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab