Commit 81de9265 authored by Gregory Pallone's avatar Gregory Pallone
Browse files

fix panning law for ISM and renderer

parent 543a97c3
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 ########################### */

+6 −0
Original line number Diff line number Diff line
@@ -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;
}
+10 −1
Original line number Diff line number Diff line
@@ -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;
+64 −2
Original line number Diff line number Diff line
@@ -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,8 +7001,27 @@ 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 */
#endif
            ismInput->prev_pan_gains_fx[0] = currentPanGains_fx[0]; /* Q31 */
            ismInput->prev_pan_gains_fx[1] = currentPanGains_fx[1]; /* Q31 */
            move32();