From 81de9265462bf86d32e7ba3524f06e6826000315 Mon Sep 17 00:00:00 2001 From: Gregory Pallone Date: Tue, 24 Mar 2026 19:06:12 +0100 Subject: [PATCH] fix panning law for ISM and renderer --- lib_com/options.h | 1 + lib_dec/ivas_mono_dmx_renderer_fx.c | 6 +++ lib_rend/ivas_objectRenderer_sources_fx.c | 11 +++- lib_rend/lib_rend_fx.c | 66 ++++++++++++++++++++++- 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index daede4c0d..8c65846f6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_BASOP_2486_HQ_FINE_GAIN_ALIGNMENT /* Eri: Basop issue 2486: IVAS BASOP used calculations with truncation, EVS BASOP used rounding. This aligns the use of a table lookup. */ #define FIX_1543_MID_LSF_BITS /* VA: float issue 1543: Resolve "MSAN: use-of-uninitialized-value in lib_enc/lsf_enc.c:262:5 for EVS encoder" */ #define FIX_2488_PREVENT_NEG_PITCH /* VA: Fix for 2488, use saturation to prevent possible wrap-around, thus negative pitch values */ +#define FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW /* Orange: float issue 1548: Harmonize non diegetic panning law in ISM and renderers */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 0f8418716..10e9e72e6 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -321,10 +321,16 @@ void ivas_apply_non_diegetic_panning_fx( ) { +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW + Word16 pan = add( mult_r( non_diegetic_pan_gain_fx, 256 ), 256 ); + v_multc_fx_16( input_f_fx, cos_scale_tbl_512[pan], output_fx[1], output_frame ); + v_multc_fx_16( input_f_fx, sin_scale_tbl_512[pan], output_fx[0], output_frame ); +#else Word16 pan = add( mult_r( non_diegetic_pan_gain_fx, 32 ), 32 ); // 0.5.Q15 = 16384 // Q15 v_multc_fx_16( input_f_fx, cos_table_129[pan], output_fx[1], output_frame ); v_multc_fx_16( input_f_fx, cos_table_129[64 - pan], output_fx[0], output_frame ); +#endif return; } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 222a5b0f8..4361a12e9 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -36,7 +36,9 @@ #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" - +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW +#include "rom_com.h" +#endif /*---------------------------------------------------------------------* * Local function prototypes @@ -457,10 +459,17 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( move32(); set32_fx( hrf_left, 0, *filterlength ); set32_fx( hrf_right, 0, *filterlength ); + +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW + Word16 pan = add( mult_r( extract_h( SrcSpatial_p->Pos_p_fx[1] ), 16384 ), 256 ); + hrf_left[0] = L_shl_r( sin_scale_tbl_512[pan], 10 ); + hrf_right[0] = L_shl_r( cos_scale_tbl_512[pan], 10 ); +#else hrf_left[0] = L_shr( L_add( SrcSpatial_p->Pos_p_fx[1], ONE_IN_Q25 ), 1 ); // Q25 move32(); hrf_right[0] = L_sub( ONE_IN_Q25, hrf_left[0] ); // Q25 move32(); +#endif hrf_left_e = 6; move16(); hrf_right_e = 6; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 8ade538fc..7389026d4 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -47,6 +47,9 @@ #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW +#include "rom_com.h" +#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -2649,6 +2652,26 @@ static ivas_error updateMcPanGainsForMcOut( test(); IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) && ( inputMc->nonDiegeticPan ) ) { + + +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW + IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) + { + inputMc->panGains_fx[0][0] = ONE_IN_Q31; + inputMc->panGains_fx[0][1] = 0; + } + ELSE IF( EQ_32( L_add( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ), 0 ) ) + { + inputMc->panGains_fx[0][0] = 0; + inputMc->panGains_fx[0][1] = ONE_IN_Q31; + } + ELSE + { + Word16 pan = add( mult_r( extract_h( inputMc->nonDiegeticPanGain_fx ), 256 ), 256 ); + inputMc->panGains_fx[0][0] = L_deposit_h( sin_scale_tbl_512[pan] ); + inputMc->panGains_fx[0][1] = L_deposit_h( cos_scale_tbl_512[pan] ); + } +#else IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) { inputMc->panGains_fx[0][0] = ONE_IN_Q31; @@ -2660,6 +2683,7 @@ static ivas_error updateMcPanGainsForMcOut( move32(); inputMc->panGains_fx[0][1] = L_sub( ONE_IN_Q31, inputMc->panGains_fx[0][0] ); move32(); +#endif error = IVAS_ERR_OK; move32(); } @@ -2854,6 +2878,24 @@ static ivas_error updateMcPanGainsForBinauralOut( setZeroPanMatrix_fx( inputMc->panGains_fx ); IF( inputMc->base.inConfig == IVAS_AUDIO_CONFIG_MONO ) { +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW + IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) + { + inputMc->panGains_fx[0][0] = ONE_IN_Q31; + inputMc->panGains_fx[0][1] = 0; + } + ELSE IF( EQ_32( L_add( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ), 0 ) ) + { + inputMc->panGains_fx[0][0] = 0; + inputMc->panGains_fx[0][1] = ONE_IN_Q31; + } + ELSE + { + Word16 pan = add( mult_r( extract_h( inputMc->nonDiegeticPanGain_fx ), 256 ), 256 ); + inputMc->panGains_fx[0][0] = L_deposit_h( sin_scale_tbl_512[pan] ); + inputMc->panGains_fx[0][1] = L_deposit_h( cos_scale_tbl_512[pan] ); + } +#else IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) { inputMc->panGains_fx[0][0] = ONE_IN_Q31; @@ -2865,6 +2907,7 @@ static ivas_error updateMcPanGainsForBinauralOut( move32(); inputMc->panGains_fx[0][1] = L_sub( ONE_IN_Q31, inputMc->panGains_fx[0][0] ); move32(); +#endif } ELSE { @@ -6958,10 +7001,29 @@ static ivas_error renderIsmToMc( { IF( ismInput->nonDiegeticPan ) { +#ifdef FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW + IF( EQ_32( ismInput->nonDiegeticPanGain_fx, ONE_IN_Q31 ) ) + { + currentPanGains_fx[0] = ONE_IN_Q31; + currentPanGains_fx[1] = 0; + } + ELSE IF( EQ_32( L_add( ismInput->nonDiegeticPanGain_fx, ONE_IN_Q31 ), 0 ) ) + { + currentPanGains_fx[0] = 0; + currentPanGains_fx[1] = ONE_IN_Q31; + } + ELSE + { + Word16 pan = add( mult_r( extract_h( ismInput->nonDiegeticPanGain_fx ), 256 ), 256 ); + currentPanGains_fx[0] = L_deposit_h( sin_scale_tbl_512[pan] ); + currentPanGains_fx[1] = L_deposit_h( cos_scale_tbl_512[pan] ); + } +#else currentPanGains_fx[0] = L_add( L_shr( ismInput->nonDiegeticPanGain_fx, 1 ), ONE_IN_Q30 ); /* Q31 */ currentPanGains_fx[1] = L_sub( ONE_IN_Q31, currentPanGains_fx[0] ); /* Q31 */ - ismInput->prev_pan_gains_fx[0] = currentPanGains_fx[0]; /* Q31 */ - ismInput->prev_pan_gains_fx[1] = currentPanGains_fx[1]; /* Q31 */ +#endif + ismInput->prev_pan_gains_fx[0] = currentPanGains_fx[0]; /* Q31 */ + ismInput->prev_pan_gains_fx[1] = currentPanGains_fx[1]; /* Q31 */ move32(); move32(); move32(); -- GitLab