From 5cbf27793809e870ef47b94612b5e400e321df35 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 13 Aug 2025 18:03:45 +0200 Subject: [PATCH 1/4] add initialization for io_qfactor --- lib_rend/lib_rend_fx.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 96db56e54..5c67307fc 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5977,6 +5977,10 @@ static ivas_error renderIsmToBinauralRoom( move16(); +#if 1 + *ismInput->crendWrapper->p_io_qfactor = *exp; +#endif + /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6732,6 +6736,10 @@ static ivas_error renderMcToBinaural( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; +#if 1 + *mcInput->crendWrapper->p_io_qfactor = exp; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6852,6 +6860,10 @@ static ivas_error renderMcToBinauralRoom( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; +#if 1 + *mcInput->crendWrapper->p_io_qfactor = exp; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6964,6 +6976,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; +#if 1 + *mcInput->crendWrapper->p_io_qfactor = exp; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -7206,6 +7222,10 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray_fx( tmpRotBuffer, tmpRendBuffer ); +#if 1 + *mcInput->crendWrapper->p_io_qfactor = exp; +#endif + /* call CREND (rotation already performed) */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) { @@ -7475,6 +7495,10 @@ static ivas_error renderSbaToMultiBinaural( assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); +#if 1 + *sbaInput->crendWrapper->p_io_qfactor = 0; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) { @@ -7648,6 +7672,10 @@ static ivas_error renderSbaToBinaural( CREND_HANDLE hCrend; hCrend = sbaInput->crendWrapper->hCrend[0]; +#if 1 + *sbaInput->crendWrapper->p_io_qfactor = 0; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -7761,6 +7789,10 @@ static ivas_error renderSbaToBinauralRoom( copyBufferTo2dArray_fx( tmpMcBuffer, tmpCrendBuffer ); // Porting Crend_process function +#if 1 + *sbaInput->crendWrapper->p_io_qfactor = 0; +#endif + /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { -- GitLab From 44c8c589319706d41513180996c622a7ad284a47 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 13 Aug 2025 18:13:38 +0200 Subject: [PATCH 2/4] formatting --- 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 5c67307fc..7c7970928 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5978,7 +5978,7 @@ static ivas_error renderIsmToBinauralRoom( move16(); #if 1 - *ismInput->crendWrapper->p_io_qfactor = *exp; + *ismInput->crendWrapper->p_io_qfactor = *exp; #endif /* render 7_1_4 with BRIRs */ @@ -6977,7 +6977,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( hCrend = mcInput->crendWrapper->hCrend[0]; #if 1 - *mcInput->crendWrapper->p_io_qfactor = exp; + *mcInput->crendWrapper->p_io_qfactor = exp; #endif /* call CREND */ @@ -7790,7 +7790,7 @@ static ivas_error renderSbaToBinauralRoom( // Porting Crend_process function #if 1 - *sbaInput->crendWrapper->p_io_qfactor = 0; + *sbaInput->crendWrapper->p_io_qfactor = 0; #endif /* call CREND */ -- GitLab From b0129ce294cf722635e91eed9c4fefd5ada21da5 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 19 Aug 2025 15:17:55 +0200 Subject: [PATCH 3/4] Modify initialization of sbaInput->crendWrapper->p_io_qfactor. --- lib_com/options.h | 2 +- lib_rend/lib_rend_fx.c | 48 +++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 785ea51ed..a64418e61 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,7 +82,7 @@ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ - +#define FIX_1843_IO_QFACTOR_INIT /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 34d7dc78c..1d6641bd7 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -246,8 +246,11 @@ static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, Word16 to_fix ); static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, const Word16 num_subframes, const Word16 Q_in ); - -static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k] ); +#ifdef FIX_1843_IO_QFACTOR_INIT +static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k], const Word16 *pq_fact ); +#else +static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k]); +#endif /*-------------------------------------------------------------------* @@ -6086,10 +6089,9 @@ static ivas_error renderIsmToBinauralRoom( move16(); -#if 1 +#ifdef FIX_1843_IO_QFACTOR_INIT *ismInput->crendWrapper->p_io_qfactor = *exp; #endif - /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6830,10 +6832,9 @@ static ivas_error renderMcToBinaural( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; -#if 1 +#ifdef FIX_1843_IO_QFACTOR_INIT *mcInput->crendWrapper->p_io_qfactor = exp; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -6955,10 +6956,9 @@ static ivas_error renderMcToBinauralRoom( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; -#if 1 +#ifdef FIX_1843_IO_QFACTOR_INIT *mcInput->crendWrapper->p_io_qfactor = exp; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -7071,10 +7071,9 @@ static ivas_error renderMcCustomLsToBinauralRoom( CREND_HANDLE hCrend; hCrend = mcInput->crendWrapper->hCrend[0]; -#if 1 +#ifdef FIX_1843_IO_QFACTOR_INIT *mcInput->crendWrapper->p_io_qfactor = exp; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -7314,10 +7313,9 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray_fx( tmpRotBuffer, tmpRendBuffer ); -#if 1 +#ifdef FIX_1843_IO_QFACTOR_INIT *mcInput->crendWrapper->p_io_qfactor = exp; #endif - /* call CREND (rotation already performed) */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) { @@ -7501,7 +7499,12 @@ static void renderSbaToSba( static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, - Word32 out[][L_FRAME48k] ) +#ifdef FIX_1843_IO_QFACTOR_INIT + Word32 out[][L_FRAME48k], + const Word16 *pq_fact) +#else + Word32 out[][L_FRAME48k]) +#endif { Word32 tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; @@ -7586,10 +7589,9 @@ static ivas_error renderSbaToMultiBinaural( assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); -#if 1 - *sbaInput->crendWrapper->p_io_qfactor = 0; +#ifdef FIX_1843_IO_QFACTOR_INIT + *sbaInput->crendWrapper->p_io_qfactor = *pq_fact; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ), IVAS_ERR_OK ) ) { @@ -7662,7 +7664,11 @@ static ivas_error renderSbaToSplitBinaural( } else { +#ifdef FIX_1843_IO_QFACTOR_INIT + IF( ( error = renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer, outAudio.pq_fact ) ) != IVAS_ERR_OK ) +#else IF( ( error = renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -7761,10 +7767,9 @@ static ivas_error renderSbaToBinaural( CREND_HANDLE hCrend; hCrend = sbaInput->crendWrapper->hCrend[0]; -#if 1 - *sbaInput->crendWrapper->p_io_qfactor = 0; +#ifdef FIX_1843_IO_QFACTOR_INIT + *sbaInput->crendWrapper->p_io_qfactor = *outAudio.pq_fact; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { @@ -7877,10 +7882,9 @@ static ivas_error renderSbaToBinauralRoom( } copyBufferTo2dArray_fx( tmpMcBuffer, tmpCrendBuffer ); -#if 1 - *sbaInput->crendWrapper->p_io_qfactor = 0; +#ifdef FIX_1843_IO_QFACTOR_INIT + *sbaInput->crendWrapper->p_io_qfactor = *outAudio.pq_fact; #endif - /* call CREND */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) { -- GitLab From 7dd0ef1dd7cb41c29a7b8293b4f41443c6a2c77a Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 19 Aug 2025 15:22:58 +0200 Subject: [PATCH 4/4] apply clang formatting patch. --- 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 1d6641bd7..692b5bb48 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -249,7 +249,7 @@ static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, Word32 Cld #ifdef FIX_1843_IO_QFACTOR_INIT static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k], const Word16 *pq_fact ); #else -static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k]); +static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k] ); #endif @@ -7501,9 +7501,9 @@ static ivas_error renderSbaToMultiBinaural( const AUDIO_CONFIG outConfig, #ifdef FIX_1843_IO_QFACTOR_INIT Word32 out[][L_FRAME48k], - const Word16 *pq_fact) + const Word16 *pq_fact ) #else - Word32 out[][L_FRAME48k]) + Word32 out[][L_FRAME48k] ) #endif { Word32 tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -- GitLab