From 52a5892faf0c389dc8bc0592bb11a7a1c4d0fa76 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 21 Jan 2026 16:49:42 +0100 Subject: [PATCH 1/4] scale only relevant samples in external renderer temporary buffers --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..06551d04f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,6 +116,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5d5179c53..77277cb9a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6516,9 +6516,17 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, @@ -6528,9 +6536,17 @@ static ivas_error renderIsmToBinaural( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -6793,9 +6809,17 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) ) @@ -6803,9 +6827,17 @@ static ivas_error renderIsmToBinauralReverb( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -7104,9 +7136,17 @@ static ivas_error renderIsmToSplitBinaural( } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_NUM_OBJECTS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } /* Render */ @@ -7118,7 +7158,11 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpProcessing[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } IF( ismInput->hReverb != NULL ) @@ -7521,9 +7565,17 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), @@ -7532,9 +7584,17 @@ static ivas_error renderMcToBinaural( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } } ELSE @@ -7644,9 +7704,17 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer ); +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numChannels, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, @@ -7656,9 +7724,17 @@ static ivas_error renderMcToBinauralRoom( return error; } +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < outAudio.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } } ELSE @@ -8001,9 +8077,17 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; +#ifdef FIX_BASOP_2351_EXTREND_SCALE + FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) +#else FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) +#endif { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#endif } /* Render */ IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK ) @@ -8012,7 +8096,11 @@ static ivas_error renderMcToSplitBinaural( } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#endif } /* Copy rendered audio to tmp storage buffer. Copying directly to output would -- GitLab From 9321a51d2f2730b5ed89632c7d041782eedcfcab Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 21 Jan 2026 17:24:09 +0100 Subject: [PATCH 2/4] clang-format --- lib_rend/lib_rend_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 77277cb9a..c6547b58a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7145,7 +7145,7 @@ static ivas_error renderIsmToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else - Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif } @@ -8086,7 +8086,7 @@ static ivas_error renderMcToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif } /* Render */ @@ -8099,7 +8099,7 @@ static ivas_error renderMcToSplitBinaural( #ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #endif } -- GitLab From f420cac7ece4c7fb5e595b4462b82e9ef6944f7c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 22 Jan 2026 09:56:49 +0100 Subject: [PATCH 3/4] [fix] wrong variable used for number of samples to scale --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b1085638d..71bf1687b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7682,7 +7682,7 @@ static ivas_error renderMcToBinauralRoom( #endif { #ifdef FIX_BASOP_2351_EXTREND_SCALE - Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numChannels, sub( Q11, exp ) ); /* Q11 */ + Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ #else Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ #endif -- GitLab From 79e06d753da7e7f5282212e8a3f8b9994d0e2ef2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 22 Jan 2026 10:19:30 +0100 Subject: [PATCH 4/4] [fix] wrong variable used for ISM split rendering output buffer --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 71bf1687b..d14c35478 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7130,7 +7130,7 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { #ifdef FIX_BASOP_2351_EXTREND_SCALE - Scale_sig32( tmpProcessing[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ + Scale_sig32( tmpProcessing[i], output_frame, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #else Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ #endif -- GitLab