diff --git a/lib_com/options.h b/lib_com/options.h index f974f4b8ae1c281f4c474e6f0197fd9577a7db15..5dca1a6a4a36781e06864446ccb936205bc6ec6d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,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 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a27b9c9c2abf6720c8b68e9725e0894e6555c185..feeac307cd2e76dc2e25ed31682a6633c09d6f3b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6487,9 +6487,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, @@ -6499,9 +6507,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 ) @@ -6764,9 +6780,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 ) ) @@ -6774,9 +6798,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 ) @@ -7079,9 +7111,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 { - Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#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 */ @@ -7093,7 +7133,11 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { +#ifdef FIX_BASOP_2351_EXTREND_SCALE + 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 } IF( ismInput->hReverb != NULL ) @@ -7496,9 +7540,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 ) ), @@ -7507,9 +7559,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 @@ -7619,9 +7679,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.numSamplesPerChannel, 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, @@ -7631,9 +7699,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 @@ -7976,9 +8052,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 { - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ +#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 ) @@ -7987,7 +8071,11 @@ static ivas_error renderMcToSplitBinaural( } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ +#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