Commit 8a7bc3f3 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Merge branch '1741_basop_enable_switches' into 'main-pc'

[Allow-regression][Non-BE][Rend Non-BE]Enable switches following HRTF model MR - main-pc

See merge request !1817
parents ce5d1817 63f05e3b
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -110,11 +110,9 @@
#endif

#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
//#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES			  /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers	*/
#endif
#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES       /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers	*/

//#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format*/
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format*/
#define FIX_WARNING_RENDER_CONFIG                       /* Orange: fix warning on windows build */
#define FIX_INV_DIFFUSE_WEIGHT                          /* Orange : Fix error in energy compensation in late binaural */

@@ -124,6 +122,7 @@
/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF   */           /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */

#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT              /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */
#define FIX_1741_REVERB_TIMES_Q_FORMAT                  /* Philips: reverberation times in Q26 format instead of Q31 */

/* #################### End BASOP porting switches ############################ */

+5 −1
Original line number Diff line number Diff line
@@ -503,7 +503,11 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx(
                Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); /*Q14*/
            }
        }
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
        Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q26*/
#else
        Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/
#endif
        Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/
        Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX );           /*Q28*/
        *hHrtfParambin = hrtfParambin;
+62 −15
Original line number Diff line number Diff line
@@ -288,46 +288,93 @@ ivas_error ivas_HRTF_statistics_init(

    switch ( sampleRate )
    {
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
        case 48000:
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx;
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( defaultHRIR_left_avg_power_48kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_right_avg_power_48kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_coherence_48kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
            break;
        case 32000:
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx;
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( defaultHRIR_left_avg_power_32kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_right_avg_power_32kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_coherence_32kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
            break;
        case 16000:
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_l_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
            if ( HrtfStatistics->average_energy_r_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) );
            HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
            if ( HrtfStatistics->inter_aural_coherence_dyn == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
            }
            floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC_16KHZ );  /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
            HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
            HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
            HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
            break;
#else

        case 48000:
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx;
            break;
        case 32000:
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx;
            break;
        case 16000:
            HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx;
            HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx;
            HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx;
#endif
            break;
#endif
    }
    HrtfStatistics->fromROM = TRUE;

+14 −0
Original line number Diff line number Diff line
@@ -1158,6 +1158,20 @@ void ivas_reverb_interpolate_acoustic_data_fx(
  Word16 *pOutput_t60_e, //output e
  Word16 *pOutput_dsr_e  //output e
);
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
void ivas_reverb_interpolate_energies_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc, //input in Q16
    const Word32 *pInput_ene_l, //input in Q28
    const Word32 *pInput_ene_r, //input in Q28
    const Word16 output_table_size,
    const Word32 *pOutput_fc,
    Word32 *pOutput_ene_l_m, // output m
    Word32 *pOutput_ene_r_m, // output m
    Word16 *pOutput_ene_l_e, //output e
    Word16 *pOutput_ene_r_e  //output e
);
#endif
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
void ivas_reverb_get_hrtf_set_properties_fx(
  Word32 **ppHrtf_set_L_re,
+82 −0
Original line number Diff line number Diff line
@@ -920,6 +920,88 @@ void ivas_reverb_interpolate_acoustic_data_fx(
    return;
}

#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
/*-------------------------------------------------------------------*
 * ivas_reverb_interpolate_energies_fx()
 *
 * Interpolates data from the input average energy to the FFT pFilter uniform grid
 * Note: the fc frequencies both for the input and the output must be in the ascending order
 *-------------------------------------------------------------------*/


void ivas_reverb_interpolate_energies_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc,    // input in Q16
    const Word32 *pInput_ene_l, // input in Q28
    const Word32 *pInput_ene_r, // input in Q28
    const Word16 output_table_size,
    const Word32 *pOutput_fc, // Q16
    Word32 *pOutput_ene_l_m,
    Word32 *pOutput_ene_r_m,
    Word16 *pOutput_ene_l_e,
    Word16 *pOutput_ene_r_e )
{
    Word16 input_idx, output_idx;
    Word32 rel_offset;
    Word16 rel_offset_e;
    input_idx = 0;
    move16();

    FOR( output_idx = 0; output_idx < output_table_size; output_idx++ )
    {
        /* if the bin frequency is lower than the 1st frequency point in the input table, take this 1st point */
        IF( LT_32( pOutput_fc[output_idx], pInput_fc[0] ) )
        {
            input_idx = 0;
            move16();
            rel_offset = 0;
            move32();
            rel_offset_e = 0;
            move16();
        }
        ELSE
        {
            /* if the bin frequency is higher than the last frequency point in the input table, take this last point */
            IF( GT_32( pOutput_fc[output_idx], pInput_fc[input_table_size - 1] ) )
            {
                input_idx = sub( input_table_size, 2 );
                rel_offset = ONE_IN_Q30; // Q30;
                move32();
                rel_offset_e = 1;
                move16();
            }
            /* otherwise use linear interpolation between 2 consecutive points in the input table */
            ELSE
            {
                WHILE( GT_32( pOutput_fc[output_idx], pInput_fc[input_idx + 1] ) )
                {
                    input_idx = add( input_idx, 1 );
                }
                rel_offset = BASOP_Util_Divide3232_Scale( L_sub( pOutput_fc[output_idx], pInput_fc[input_idx] ), L_sub( pInput_fc[input_idx + 1], pInput_fc[input_idx] ), &rel_offset_e ); // q15
                rel_offset = L_shl_sat( rel_offset, add( 16, rel_offset_e ) );
                rel_offset_e = 0;
                move16();
            }
        }
        Word32 mult1;
        Word16 mult_e = 0;
        move16();
        mult1 = Mpy_32_32( rel_offset, L_sub( pInput_ene_l[input_idx + 1], pInput_ene_l[input_idx] ) );
        pOutput_ene_l_m[output_idx] = BASOP_Util_Add_Mant32Exp( pInput_ene_l[input_idx], 3, mult1, add( 3, rel_offset_e ), &mult_e ); // 31 - (31 - rel_offset_e + 28 - 31)
        move32();
        pOutput_ene_l_e[output_idx] = mult_e;
        move16();

        mult1 = Mpy_32_32( rel_offset, L_sub( pInput_ene_r[input_idx + 1], pInput_ene_r[input_idx] ) );
        pOutput_ene_r_m[output_idx] = BASOP_Util_Add_Mant32Exp( pInput_ene_r[input_idx], 3, mult1, add( 3, rel_offset_e ), &mult_e ); // 31 - (31 - rel_offset_e + 28 - 31)
        move32();
        pOutput_ene_r_e[output_idx] = mult_e;
        move16();
    }

    return;
}
#endif

#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
/*-------------------------------------------------------------------*
Loading