From eefded5e45e4eb5b4db6750ddffc5f7a4172f169 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 14 May 2024 21:46:50 +0530 Subject: [PATCH] High_MLD_and_LTV_crash_fix_rend_cleanup [x] Fix for the high MLD issue seen in MASA [x] Fix for LTV assertions (MASA + 4ISM) [x] Cleanup of renderer code --- lib_com/gs_inact_switching_fx.c | 14 +- lib_dec/gain_dec_fx.c | 6 +- lib_dec/ivas_dirac_dec.c | 4 +- lib_rend/ivas_crend.c | 36 +-- lib_rend/ivas_dirac_output_synthesis_dec.c | 12 +- lib_rend/ivas_mcmasa_ana.c | 60 +--- lib_rend/ivas_prot_rend.h | 6 +- lib_rend/ivas_reverb_fft_filter.c | 4 +- lib_rend/ivas_stat_rend.h | 28 +- lib_rend/lib_rend.c | 331 +++++++++++++++++---- 10 files changed, 339 insertions(+), 162 deletions(-) diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 5a9c9a62f..a0150c20b 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -257,9 +257,9 @@ void Inac_switch_ematch_ivas_fx( { FOR(j = 0; j < 8; j++) { - L_tmp = L_mult(*pt_exc, ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */ - L_tmp = L_shl(L_tmp, add(exp, 15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx(L_tmp); + L_tmp = L_mult0(*pt_exc, ftmp); + L_tmp = L_shl(L_tmp, add(exp, 15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx(L_tmp); /*Q_exc - 1*/ pt_exc++; } } @@ -267,15 +267,17 @@ void Inac_switch_ematch_ivas_fx( { FOR(j = 0; j < 16; j++) { - L_tmp = L_mult(*pt_exc,ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */ - L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx(L_tmp); /*Q_exc*/ + L_tmp = L_mult0(*pt_exc,ftmp); + L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx(L_tmp); /*Q_exc - 1*/ pt_exc++; } } } /* Going back to time */ + Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc + Scale_sig( exc2, 240, 1 ); // Q_exc edct_16fx(dct_exc_tmp, exc2, L_frame, 5, element_mode); } diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 6b87bd222..0c686ad6d 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -320,9 +320,9 @@ void gain_dec_tc_ivas_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ - L_tmp = L_shl(L_mult(wgain_code, gcode0_fx), 1); /* Q12*Q0+1 -> Q14 */ - *gain_code_fx= L_shl(L_tmp, add(exp_gcode0, 2)); - move32(); /* Q14 -> Q16 */ + L_tmp = L_mult(wgain_code, gcode0_fx); /* Q12*Q0 -> Q13 */ + *gain_code_fx= L_shl(L_tmp, add(exp_gcode0, 3)); + move32(); /* Q13 -> Q16 */ /**norm_gain_code = *gain_code / *gain_inov;*/ expg = sub(norm_s(*gain_inov_fx),1); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index cbb08a046..82b21930d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4563,7 +4563,7 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), q_proto_direct_buffer[slot_idx], 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), q_proto_diffuse_buffer[slot_idx], 2 * s_min( nchan_transport, hDirACRend->num_outputs_diff ) * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), q_proto_diffuse_buffer[slot_idx], 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { @@ -4861,7 +4861,7 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - 2 * s_min( nchan_transport, hDirACRend->num_outputs_diff ) * hSpatParamRendCom->num_freq_bands ); + 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); } floatToFixed_arrL( p_onset_filter, p_onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands ); // Q30 diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 69b758d40..5d23db160 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2703,71 +2703,71 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ) { - int16_t i; + Word16 i; CREND_HANDLE hCrend; - if ( pCrend == NULL || *pCrend == NULL ) + IF ( pCrend == NULL || *pCrend == NULL ) { return; } - if ( ( *pCrend )->hHrtfCrend != NULL ) + IF ( ( *pCrend )->hHrtfCrend != NULL ) { ivas_hrtf_close( &( *pCrend )->hHrtfCrend ); } { hCrend = ( *pCrend )->hCrend; - if ( hCrend != NULL ) + IF ( hCrend != NULL ) { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { - if ( hCrend->freq_buffer_re_fx[i] != NULL ) + IF ( hCrend->freq_buffer_re_fx[i] != NULL ) { free( hCrend->freq_buffer_re_fx[i] ); hCrend->freq_buffer_re_fx[i] = NULL; } - if ( hCrend->freq_buffer_im_fx[i] != NULL ) + IF ( hCrend->freq_buffer_im_fx[i] != NULL ) { free( hCrend->freq_buffer_im_fx[i] ); hCrend->freq_buffer_im_fx[i] = NULL; } } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR ( i = 0; i < BINAURAL_CHANNELS; i++ ) { - if ( hCrend->prev_out_buffer_fx[i] != NULL ) + IF ( hCrend->prev_out_buffer_fx[i] != NULL ) { free( hCrend->prev_out_buffer_fx[i] ); hCrend->prev_out_buffer_fx[i] = NULL; } } -#ifdef IVAS_FLOAT_FIXED - if ( hCrend->lfe_delay_line_fx != NULL ) +#ifdef IVAS_FLOAT_FIXED_s + IF ( hCrend->lfe_delay_line_fx != NULL ) { free( hCrend->lfe_delay_line_fx ); hCrend->lfe_delay_line_fx = NULL; } #endif - if ( hCrend->lfe_delay_line_fx != NULL ) + IF ( hCrend->lfe_delay_line_fx != NULL ) { free( hCrend->lfe_delay_line_fx); hCrend->lfe_delay_line_fx = NULL; } - if ( hCrend->freq_buffer_re_diffuse_fx != NULL ) + IF ( hCrend->freq_buffer_re_diffuse_fx != NULL ) { free( hCrend->freq_buffer_re_diffuse_fx ); hCrend->freq_buffer_re_diffuse_fx = NULL; } - if ( hCrend->freq_buffer_im_diffuse_fx != NULL ) + IF ( hCrend->freq_buffer_im_diffuse_fx != NULL ) { free( hCrend->freq_buffer_im_diffuse_fx ); hCrend->freq_buffer_im_diffuse_fx = NULL; } - if ( hCrend->hTrack != NULL ) + IF ( hCrend->hTrack != NULL ) { free( hCrend->hTrack ); hCrend->hTrack = NULL; @@ -2775,14 +2775,14 @@ void ivas_rend_closeCrend( ivas_reverb_close( &hCrend->hReverb ); - if ( hCrend->reflections != NULL ) + IF ( hCrend->reflections != NULL ) { - if ( hCrend->reflections->closest_ch_idx != NULL ) + IF ( hCrend->reflections->closest_ch_idx != NULL ) { free( hCrend->reflections->closest_ch_idx ); hCrend->reflections->closest_ch_idx = NULL; } - if ( hCrend->reflections->circ_buffers != NULL ) + IF ( hCrend->reflections->circ_buffers != NULL ) { free( hCrend->reflections->circ_buffers ); hCrend->reflections->circ_buffers = NULL; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 36bc0fef2..1479d8885 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2593,16 +2593,16 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 32) output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = - L_shr( L_add( output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], - Mpy_32_32( g, ( *( p_proto++ ) ) ) ), - Q1 ); + L_add( output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], + L_shr( Mpy_32_32( g, ( *( p_proto++ ) ) ) , + Q1)); move32(); // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 32) output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = - L_shr( L_add( output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], - Mpy_32_32( g, ( *( p_proto++ ) ) ) ), - Q1 ); + L_add( output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], + L_shr( Mpy_32_32( g, ( *( p_proto++ ) ) ), + Q1)); move32(); } } diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 7ca34554e..bf57b3fe7 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -87,11 +87,13 @@ void ivas_mcmasa_param_est_ana_fx( const Word16 input_frame, /* i : Input frame size */ const Word16 nchan_inp /* i : Number of input channels */ ); -#endif // IVAS_FLOAT_FIXED - +#else void ivas_mcmasa_param_est_ana( MCMASA_ANA_HANDLE hMcMasa, float data_f[][L_FRAME48k], float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const int16_t input_frame, const int16_t nchan_inp ); +#endif // IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED static void ivas_mcmasa_dmx( MCMASA_ANA_HANDLE hMcMasa, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_inp ); +#endif static void compute_cov_mtx( float sr[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], float si[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], const int16_t freq, const int16_t N, CovarianceMatrix *COVls ); @@ -236,21 +238,6 @@ ivas_error ivas_mcmasa_ana_open( /* intensity 3-dim */ FOR ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { -#if 1/*TODO: To be removed later*/ - if ( ( hMcMasa->direction_vector_m[i] = (float **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); - } - - for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - if ( ( hMcMasa->direction_vector_m[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); - } - set_zero( hMcMasa->direction_vector_m[i][j], MASA_FREQUENCY_BANDS ); - } -#endif IF( ( hMcMasa->direction_vector_m_fx[i] = (Word32 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); @@ -282,13 +269,6 @@ ivas_error ivas_mcmasa_ana_open( { FOR ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { -#if 1/*TODO: To be removed later*/ - if ( ( hMcMasa->buffer_intensity_real[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); - } - set_zero( hMcMasa->buffer_intensity_real[i][j], MASA_FREQUENCY_BANDS ); -#endif IF ( ( hMcMasa->buffer_intensity_real_fx[i][j] = (Word32 *) malloc( MASA_FREQUENCY_BANDS * sizeof(Word32) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); @@ -300,13 +280,6 @@ ivas_error ivas_mcmasa_ana_open( FOR ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { -#if 1/*TODO: To be removed later*/ - if ( ( hMcMasa->buffer_intensity_real_vert[j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); - } - set_zero( hMcMasa->buffer_intensity_real_vert[j], MASA_FREQUENCY_BANDS ); -#endif IF ( ( hMcMasa->buffer_intensity_real_vert_fx[j] = (Word32 *) malloc( MASA_FREQUENCY_BANDS * sizeof(Word32) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); @@ -315,9 +288,6 @@ ivas_error ivas_mcmasa_ana_open( } set16_fx(hMcMasa->buffer_intensity_real_vert_q, 31, DIRAC_NO_COL_AVG_DIFF ); -#if 1/*TODO: To be removed later*/ - set_zero( hMcMasa->buffer_energy, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); -#endif set_zero_fx( hMcMasa->buffer_energy_fx, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); set16_fx(hMcMasa->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF ); @@ -375,14 +345,11 @@ ivas_error ivas_mcmasa_ana_open( } } -#if 1/*TODO: To be removed later(floating point initialization)*/ - hMcMasa->prevMultiChEne = 0.0f; - hMcMasa->prevDownmixEne = 0.0f; - hMcMasa->prevEQ = 1.0f; -#endif hMcMasa->prevMultiChEne_fx = 0; hMcMasa->prevDownmixEne_fx = 0; - hMcMasa->prevEQ_fx = 32767; + hMcMasa->prevEQ_fx = 2147483647; + hMcMasa->prevEQ_e = 0; + input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); FOR ( i = 0; i < input_frame; i++ ) { @@ -675,7 +642,7 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->buffer_intensity_real_vert_fx[j] ); ( *hMcMasa )->buffer_intensity_real_vert_fx[j] = NULL; } -#if 1/*TODO: To be removed later( freeing float buffer)*/ +#if 0/*TODO: To be removed later( freeing float buffer)*/ FOR ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -809,7 +776,7 @@ void ivas_mcmasa_ana_fx( return; } -#endif +#else void ivas_mcmasa_ana( MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ float data_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ @@ -844,6 +811,7 @@ void ivas_mcmasa_ana( return; } +#endif /*--------------------------------------------------------------------------* @@ -1404,7 +1372,7 @@ void ivas_mcmasa_param_est_ana_fx( } return; } -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED void ivas_mcmasa_param_est_ana( MCMASA_ANA_HANDLE hMcMasa, /* i : McMASA analyzer structure */ float data_f[][L_FRAME48k], /* i : Audio frame in MC-format */ @@ -1807,8 +1775,9 @@ void ivas_mcmasa_param_est_ana( return; } +#endif - +#ifndef IVAS_FLOAT_FIXED /* Compute downmix */ static void ivas_mcmasa_dmx( MCMASA_ANA_HANDLE hMcMasa, @@ -1900,8 +1869,7 @@ static void ivas_mcmasa_dmx( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void ivas_mcmasa_dmx_fx( MCMASA_ANA_HANDLE hMcMasa, Word32 data_f_fx[][L_FRAME48k], diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a3e349c7b..91e724491 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1993,11 +1993,11 @@ int16_t ivas_reverb_fft_filter_init( ivas_reverb_fft_filter_t *fft_filter, const int16_t fft_size ); -#endif void ivas_reverb_fft_filter_ComplexMul( ivas_reverb_fft_filter_t *fft_filter, float *buffer ); +#endif void ivas_reverb_fft_filter_CrossMix( float *buffer0, @@ -2632,8 +2632,7 @@ void ivas_mcmasa_ana_fx( const Word16 nchan_transport, /* i : Number of transport channels */ const Word16 nchan_inp /* i : Number of input channels */ ); -#endif // IVAS_FLOAT_FIXED - +#else void ivas_mcmasa_ana( MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ float data_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ @@ -2641,6 +2640,7 @@ void ivas_mcmasa_ana( const int16_t nchan_transport, /* i : Number of transport channels */ const int16_t nchan_inp /* i : Number of input channels */ ); +#endif // IVAS_FLOAT_FIXED void ivas_mcmasa_ana_close( MCMASA_ANA_HANDLE *hMcMasa /* i/o: analysis McMASA handle */ diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 47b529265..2d029c04c 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -651,7 +651,7 @@ void ivas_reverb_fft_filter_ComplexMul_fx( return; } -#endif +#else /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_fft_filter_ComplexMul() * @@ -683,7 +683,7 @@ void ivas_reverb_fft_filter_ComplexMul( return; } - +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR() * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index aec0c3ebc..fef1c9987 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1295,7 +1295,9 @@ typedef struct ivas_reverb_fft_filter_t { Word16 fft_size; Word32 fft_spectrum_fx[RV_FILTER_MAX_FFT_SIZE]; +#ifndef IVAS_FLOAT_FIXED float fft_spectrum[RV_FILTER_MAX_FFT_SIZE]; +#endif } ivas_reverb_fft_filter_t; @@ -2283,10 +2285,10 @@ typedef struct ivas_masa_decoder_ext_out_meta_struct *MASA_DECODER_EXT_OUT_META_ typedef struct ivas_mcmasa_ana_data_structure { - int16_t nbands; + Word16 nbands; /* CLDFB analysis */ - int16_t num_Cldfb_instances; + Word16 num_Cldfb_instances; HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MCMASA_MAX_ANA_CHANS]; /* DirAC parameter estimation */ @@ -2294,7 +2296,9 @@ typedef struct ivas_mcmasa_ana_data_structure Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */ #endif // IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED float **direction_vector_m[DIRAC_NUM_DIMS]; /* Average direction vector */ +#endif #ifdef IVAS_FLOAT_FIXED Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF]; @@ -2318,27 +2322,31 @@ typedef struct ivas_mcmasa_ana_data_structure Word16 prevEQ_e; Word16 interpolator_e; #endif // IVAS_FLOAT_FIXED - int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; - int16_t block_grouping[5]; + Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; + Word16 block_grouping[5]; /* diffuseness */ - int16_t index_buffer_intensity; + Word16 index_buffer_intensity; +#ifndef IVAS_FLOAT_FIXED float *buffer_intensity_real[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; float *buffer_intensity_real_vert[DIRAC_NO_COL_AVG_DIFF]; float buffer_energy[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS]; - float chnlToFoaMtx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; float chnlToFoaEvenMtx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; float ls_azimuth[MCMASA_MAX_ANA_CHANS]; - int16_t leftNearest[MCMASA_MAX_ANA_CHANS]; - int16_t rightNearest[MCMASA_MAX_ANA_CHANS]; - int16_t numHorizontalChannels; - uint8_t isHorizontalSetup; +#endif + Word16 leftNearest[MCMASA_MAX_ANA_CHANS]; + Word16 rightNearest[MCMASA_MAX_ANA_CHANS]; + Word16 numHorizontalChannels; + UWord8 isHorizontalSetup; + +#ifndef IVAS_FLOAT_FIXED float prevMultiChEne; float prevDownmixEne; float prevEQ; float interpolator[L_FRAME48k]; +#endif MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 9c1d72b5a..e20c61254 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -158,6 +158,7 @@ typedef struct rotation_matrix rot_mat_prev; #ifdef IVAS_FLOAT_FIXED pan_vector_fx prev_pan_gains_fx; + rotation_matrix_fx rot_mat_prev_fx; #endif pan_vector prev_pan_gains; int8_t firstFrameRendered; @@ -231,13 +232,15 @@ typedef struct rotation_gains rot_gains_prev; rotation_gains_Word32 rot_gains_prev_fx; Word16 nonDiegeticPan; - float nonDiegeticPanGain; Word32 nonDiegeticPanGain_fx; lfe_routing lfeRouting; - float *bufferData; Word32 *bufferData_fx; + float *bufferData; int16_t binauralDelaySmp; +#ifndef IVAS_FLOAT_FIXED + float nonDiegeticPanGain; float *lfeDelayBuffer; +#endif Word32 *lfeDelayBuffer_fx; MCMASA_ANA_HANDLE hMcMasa; } input_mc; @@ -1965,7 +1968,23 @@ static void closeHeadRotation( } #endif +#ifdef IVAS_FLOAT_FIXED +static void initRotMatrix_fx( + rotation_matrix_fx rot_mat_fx) +{ + Word16 i; + /* Initialize rotation matrices */ + FOR (i = 0; i < 3; i++) + { + set32_fx(rot_mat_fx[i], 0, 3); + rot_mat_fx[i][i] = ONE_IN_Q30; + } + + return; +} + +#endif static void initRotMatrix( rotation_matrix rot_mat ) { @@ -2247,6 +2266,9 @@ static ivas_error setRendInputActiveIsm( inputIsm->crendWrapper = NULL; inputIsm->hReverb = NULL; inputIsm->tdRendWrapper = defaultTdRendWrapper(); +#ifdef IVAS_FLOAT_FIXED + initRotMatrix_fx(inputIsm->rot_mat_prev_fx); +#endif initRotMatrix( inputIsm->rot_mat_prev ); set_zero( inputIsm->prev_pan_gains, MAX_OUTPUT_CHANNELS ); @@ -3672,6 +3694,176 @@ static ivas_error updateMcPanGains( } #endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error initMcBinauralRendering( + input_mc *inputMc, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + RENDER_CONFIG_DATA *hRendCfg, + uint8_t reconfigureFlag) +{ + ivas_error error; + int32_t binauralDelayNs; + int32_t outSampleRate; + int8_t useTDRend; + + /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) + or planar MC layouts with headrotation, CREND for the rest */ + useTDRend = FALSE; + if (outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) + { + if (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) + { + useTDRend = TRUE; + } + else if ((inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1) && + (inputMc->base.ctx.pHeadRotData->headRotEnabled)) + { + useTDRend = TRUE; + } + } + + /* if TD renderer was open and we need to use CREND, close it */ + if (!reconfigureFlag || (!useTDRend && inputMc->tdRendWrapper.hBinRendererTd != NULL)) + { + ivas_td_binaural_close_fx(&inputMc->tdRendWrapper.hBinRendererTd); + inputMc->tdRendWrapper.hHrtfTD = NULL; + } + + + /* if we need to use TD renderer and CREND was open, close it */ + if (useTDRend) + { + ivas_rend_closeCrend(&inputMc->crendWrapper); + } + + if (!reconfigureFlag || (!useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL)) + { + ivas_reverb_close(&inputMc->hReverb); + } + + if (!reconfigureFlag || (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && !inputMc->base.ctx.pHeadRotData->headRotEnabled)) + { + if (inputMc->efapInWrapper.hEfap != NULL) + { + efap_free_data(&inputMc->efapInWrapper.hEfap); + } + } + + outSampleRate = *inputMc->base.ctx.pOutSampleRate; + + if (useTDRend && inputMc->tdRendWrapper.hBinRendererTd == NULL) + { +#ifdef IVAS_FLOAT_FIXED + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src; + Word16 ivas_format = ( EQ_16( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) ? MC_FORMAT : ISM_FORMAT; + if ( ( error = ivas_td_binaural_open_ext_fx( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK ) + { + return error; + } + + Word16 nchan_rend = num_src; + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputMc->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) + { + IF( Src_p->SrcSpatial_p != NULL ) + { + FOR( Word16 nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) + { + fixedToFloat_arrL( Src_p->SrcSpatial_p->Pos_p_fx + nC * 3, Src_p->SrcSpatial_p->Pos_p + nC * 3, Q31, 3 ); + fixedToFloat_arrL( Src_p->SrcSpatial_p->Front_p_fx + nC * 3, Src_p->SrcSpatial_p->Front_p + nC * 3, Q30, 3 ); + } + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputMc->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + fixedToFloat_arrL( SrcSpatial_p->Pos_p_fx, SrcSpatial_p->Pos_p, Q31, 3 ); + fixedToFloat_arrL( SrcSpatial_p->Front_p_fx, SrcSpatial_p->Front_p, Q30, 3 ); + } + } +#else + if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + if (outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL) + { +#ifdef IVAS_FLOAT_FIXED + if ((error = ivas_reverb_open_fx(&(inputMc->hReverb), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate)) != IVAS_ERR_OK) + { + return error; + } +#else + if ((error = ivas_reverb_open(&(inputMc->hReverb), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate)) != IVAS_ERR_OK) + { + return error; + } +#endif + } + } + else if (!useTDRend && inputMc->crendWrapper == NULL) + { + /* open CREND */ +#ifdef IVAS_FLOAT_FIXED /*Cleanup changes: float to fixed*/ + IF(hRendCfg) + { + hRendCfg->roomAcoustics.acousticPreDelay_fx = floatToFixed(hRendCfg->roomAcoustics.acousticPreDelay, 27); + FOR(int i = 0; i < 60; i++) + { + hRendCfg->roomAcoustics.pFc_input_fx[i] = (Word32)(hRendCfg->roomAcoustics.pFc_input[i] * ONE_IN_Q16); + hRendCfg->roomAcoustics.pAcoustic_rt60_fx[i] = (Word32)((hRendCfg->roomAcoustics.pAcoustic_rt60[i]) * ONE_IN_Q26); + hRendCfg->roomAcoustics.pAcoustic_dsr_fx[i] = (Word32)(hRendCfg->roomAcoustics.pAcoustic_dsr[i] * ONE_IN_Q30); + } + + hRendCfg->roomAcoustics.inputPreDelay_fx = (Word32)(hRendCfg->roomAcoustics.inputPreDelay * ONE_IN_Q27); + hRendCfg->roomAcoustics.dimensions.x_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.x * 4194304); // Q10.22, min value:1, max :999.0 + hRendCfg->roomAcoustics.dimensions.y_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.y * 4194304); // Q10.22 + hRendCfg->roomAcoustics.dimensions.z_fx = (Word32)(hRendCfg->roomAcoustics.dimensions.z * 4194304); // Q10.22 + + + FOR(int ii = 0; ii < 6; ii++) + { + hRendCfg->roomAcoustics.AbsCoeff_fx[ii] = (Word32)(hRendCfg->roomAcoustics.AbsCoeff[ii] * 1073741824); // Q2.30 min :0 max 1 + } + + hRendCfg->roomAcoustics.ListenerOrigin.x_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.x * 4194304); //( 2147483648 >> 2 ); + hRendCfg->roomAcoustics.ListenerOrigin.y_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.y * (4194304)); + hRendCfg->roomAcoustics.ListenerOrigin.z_fx = (Word32)(hRendCfg->roomAcoustics.ListenerOrigin.z * (4194304)); + } +#endif // 1 + if ((error = ivas_rend_openCrend(&inputMc->crendWrapper, (inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate)) != IVAS_ERR_OK) + { + return error; + } + } + + /* Initialise the EFAP handle for rotation on input layout */ + if (inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL) + { + if ((error = initEfap(&inputMc->efapInWrapper, inConfig, NULL)) != IVAS_ERR_OK) + { + return error; + } + } + + /* determine binaural delay ( used for aligning LFE to output signal ) */ + binauralDelayNs = max((inputMc->crendWrapper != NULL) ? inputMc->crendWrapper->binaural_latency_ns : 0, inputMc->tdRendWrapper.binaural_latency_ns); + inputMc->binauralDelaySmp = (int16_t)roundf((float)binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f); + + if (inputMc->binauralDelaySmp > MAX_BIN_DELAY_SAMPLES) + { + return IVAS_ERROR(IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)"); + } + + return IVAS_ERR_OK; +} +#else static ivas_error initMcBinauralRendering( input_mc *inputMc, const AUDIO_CONFIG inConfig, @@ -3831,8 +4023,39 @@ static ivas_error initMcBinauralRendering( return IVAS_ERR_OK; } +#endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error initMcMasaRendering( + input_mc *inputMc, + const AUDIO_CONFIG inConfig, + const Word32 inSampleRate) +{ + ivas_error error; + IF (inputMc->tdRendWrapper.hBinRendererTd != NULL) + { + ivas_td_binaural_close_fx(&inputMc->tdRendWrapper.hBinRendererTd); + inputMc->tdRendWrapper.hHrtfTD = NULL; + } + + ivas_rend_closeCrend(&inputMc->crendWrapper); + + ivas_reverb_close(&inputMc->hReverb); + + IF (inputMc->efapInWrapper.hEfap != NULL) + { + efap_free_data(&inputMc->efapInWrapper.hEfap); + } + + IF ((error = ivas_mcmasa_ana_open(&inputMc->hMcMasa, inConfig, inSampleRate)) != IVAS_ERR_OK) + { + return error; + } + + return IVAS_ERR_OK; +} +#else static ivas_error initMcMasaRendering( input_mc *inputMc, const AUDIO_CONFIG inConfig, @@ -3864,26 +4087,23 @@ static ivas_error initMcMasaRendering( return error; } #ifdef IVAS_FLOAT_FIXED -#if 1 /*Fixed to float conversion for ivas_mcmasa_ana_open (to be removed later)*/ +#if 0 /*Fixed to float conversion for ivas_mcmasa_ana_open (to be removed later)*/ MCMASA_ANA_HANDLE hMcMasa = inputMc->hMcMasa; Word16 i, j; - fixedToFloat_arrL( hMcMasa->ls_azimuth_fx, hMcMasa->ls_azimuth, Q22, MCMASA_MAX_ANA_CHANS ); - FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ ) + //fixedToFloat_arrL( hMcMasa->ls_azimuth_fx, hMcMasa->ls_azimuth, Q22, MCMASA_MAX_ANA_CHANS ); + /*FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ ) { FOR( j = 0; j < FOA_CHANNELS; j++ ) { hMcMasa->chnlToFoaMtx[j][i] = fixedToFloat( hMcMasa->chnlToFoaMtx_fx[j][i], Q31 ); } - } - FOR( i = 0; i < ( inSampleRate / FRAMES_PER_SEC ); i++ ) - { - hMcMasa->interpolator[i] = fixedToFloat( hMcMasa->interpolator_fx[i], Q15 ); - } + }*/ #endif #endif // IVAS_FLOAT_FIXED return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED static lfe_routing defaultLfeRouting( const AUDIO_CONFIG inConfig, @@ -4022,28 +4242,24 @@ static ivas_error setRendInputActiveMc( rendCtx = inputMc->base.ctx; outConfig = *rendCtx.pOutConfig; - if ( !isIoConfigPairSupported( inConfig, outConfig ) ) + IF ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } - - if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = allocateMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) + IF ( ( error = allocateMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = allocateInputBaseBufferData( &inputMc->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + IF((error = allocateInputBaseBufferData(&inputMc->bufferData, MAX_BUFFER_LENGTH)) != IVAS_ERR_OK) { return error; } - if ( ( error = allocateInputBaseBufferData_fx( &inputMc->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + initRendInputBase(&inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH); + + IF ( ( error = allocateInputBaseBufferData_fx( &inputMc->bufferData_fx, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } - initRendInputBase( &inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH ); initRendInputBase_fx( &inputMc->base, inConfig, id, rendCtx, inputMc->bufferData_fx, MAX_BUFFER_LENGTH ); setZeroPanMatrix( inputMc->panGains ); @@ -4058,27 +4274,26 @@ static ivas_error setRendInputActiveMc( initRotGains( inputMc->rot_gains_prev ); initRotGainsWord32_fx( inputMc->rot_gains_prev_fx ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); - set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ); set_val_Word32( inputMc->lfeDelayBuffer_fx, 0, MAX_BIN_DELAY_SAMPLES ); inputMc->binauralDelaySmp = 0; - if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF (EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) { - if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) + IF ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) { return error; } } - if ( outConfig == IVAS_AUDIO_CONFIG_MASA1 || outConfig == IVAS_AUDIO_CONFIG_MASA2 ) + IF ( EQ_16(outConfig , IVAS_AUDIO_CONFIG_MASA1) || EQ_16(outConfig , IVAS_AUDIO_CONFIG_MASA2 )) { - if ( ( error = initMcMasaRendering( inputMc, inConfig, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + IF ( ( error = initMcMasaRendering( inputMc, inConfig, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = updateMcPanGains( inputMc, outConfig ) ) != IVAS_ERR_OK ) + IF ( ( error = updateMcPanGains( inputMc, outConfig ) ) != IVAS_ERR_OK ) { return error; } @@ -4160,16 +4375,13 @@ static void clearInputMc( rendering_context rendCtx; rendCtx = inputMc->base.ctx; - - freeMcLfeDelayBuffer( &inputMc->lfeDelayBuffer ); freeMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx ); - freeInputBaseBufferData( &inputMc->bufferData ); freeInputBaseBufferData_fx( &inputMc->bufferData_fx ); initRendInputBase( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); initRendInputBase_fx( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ - if ( inputMc->efapInWrapper.hEfap != NULL ) + IF ( inputMc->efapInWrapper.hEfap != NULL ) { efap_free_data( &inputMc->efapInWrapper.hEfap ); } @@ -4178,13 +4390,9 @@ static void clearInputMc( ivas_reverb_close( &inputMc->hReverb ); - if ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) + IF ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { -#ifdef IVAS_FLOAT_FIXED ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); -#else - ivas_td_binaural_close( &inputMc->tdRendWrapper.hBinRendererTd ); -#endif inputMc->tdRendWrapper.hHrtfTD = NULL; } @@ -4546,7 +4754,23 @@ static ivas_error updateSbaPanGains( } #endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error initSbaMasaRendering( + input_sba *inputSba, + Word32 inSampleRate) +{ + ivas_error error; + ivas_rend_closeCrend(&inputSba->crendWrapper); + + IF((error = ivas_dirac_ana_open_fx(&inputSba->hDirAC, inSampleRate)) != IVAS_ERR_OK) + { + return error; + } + + return IVAS_ERR_OK; +} +#else static ivas_error initSbaMasaRendering( input_sba *inputSba, int32_t inSampleRate ) @@ -4569,7 +4793,7 @@ static ivas_error initSbaMasaRendering( return IVAS_ERR_OK; } - +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error setRendInputActiveSba( @@ -4971,10 +5195,12 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL; hIvasRend->inputsMc[i].bufferData = NULL; hIvasRend->inputsMc[i].bufferData_fx = NULL; - hIvasRend->inputsMc[i].lfeDelayBuffer = NULL; hIvasRend->inputsMc[i].lfeDelayBuffer_fx = NULL; hIvasRend->inputsMc[i].nonDiegeticPan = nonDiegeticPan; +#ifndef IVAS_FLOAT_FIXED + hIvasRend->inputsMc[i].lfeDelayBuffer = NULL; hIvasRend->inputsMc[i].nonDiegeticPanGain = nonDiegeticPanGain; +#endif Word32 temp = ( abs( (Word32) nonDiegeticPanGain ) ); hIvasRend->inputsMc[i].nonDiegeticPanGain_fx = ( temp == 1 ) ? ( ( nonDiegeticPanGain < 0 ) ? L_negate( ONE_IN_Q31 ) : ONE_IN_Q31 ) : (Word32) ( nonDiegeticPanGain * ( ONE_IN_Q31 ) ); hIvasRend->inputsMc[i].hMcMasa = NULL; @@ -9947,10 +10173,6 @@ static void renderMcToMasa( floatToFixed_arrL( hMcMasa->cldfbAnaEnc[i]->cldfb_state, hMcMasa->cldfbAnaEnc[i]->cldfb_state_fx, q_data, hMcMasa->cldfbAnaEnc[i]->p_filter_length - hMcMasa->cldfbAnaEnc[i]->no_channels ); } /*From here: Cleanup changes for ivas_mcmasa_dmx_fx*/ - f2me( hMcMasa->prevMultiChEne, &hMcMasa->prevMultiChEne_fx, &hMcMasa->prevMultiChEne_e ); - f2me( hMcMasa->prevDownmixEne, &hMcMasa->prevDownmixEne_fx, &hMcMasa->prevDownmixEne_e ); - f2me( hMcMasa->prevEQ, &hMcMasa->prevEQ_fx, &hMcMasa->prevEQ_e ); - floatToFixed_arr( hMcMasa->interpolator, hMcMasa->interpolator_fx, 15, L_FRAME48k ); #endif ivas_mcmasa_ana_fx( mcInput->hMcMasa, tmpRendBuffer_fx, *( outAudio.pq_fact ), mcInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, mcInput->base.inputBuffer.config.numChannels ); #if 1 /*TODO: To be removed later(fixed to float)*/ @@ -9963,38 +10185,14 @@ static void renderMcToMasa( { FOR( int k = 0; k < MASA_FREQUENCY_BANDS; k++ ) { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - hMcMasa->direction_vector_m[i][j][k] = me2f( hMcMasa->direction_vector_m_fx[i][j][k], hMcMasa->direction_vector_e[i][j][k] ); - } hMcMasa->energy[j][k] = me2f( hMcMasa->energy_fx[j][k], hMcMasa->energy_e[j][k] ); } } - FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; i++ ) - { - FOR( int j = 0; j < DIRAC_NUM_DIMS; j++ ) - { - FOR( int k = 0; k < MASA_FREQUENCY_BANDS; k++ ) - hMcMasa->buffer_intensity_real[j][i][k] = fixedToFloat( hMcMasa->buffer_intensity_real_fx[j][i][k], hMcMasa->buffer_intensity_real_q[i] ); - } - FOR( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - hMcMasa->buffer_intensity_real_vert[i][j] = fixedToFloat( hMcMasa->buffer_intensity_real_vert_fx[i][j], hMcMasa->buffer_intensity_real_vert_q[i] ); - } - FOR( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - hMcMasa->buffer_energy[i * j + j] = fixedToFloat( hMcMasa->buffer_energy_fx[i * j + j], hMcMasa->buffer_energy_q[i] ); - } - } /*From here : cleanup changes for ivas_mcmasa_dmx_fx*/ FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { fixedToFloat_arrL( tmpRendBuffer_fx[i], tmpRendBuffer[i], q_data, L_FRAME48k ); } - - hMcMasa->prevMultiChEne = me2f( hMcMasa->prevMultiChEne_fx, hMcMasa->prevMultiChEne_e ); - hMcMasa->prevDownmixEne = me2f( hMcMasa->prevDownmixEne_fx, hMcMasa->prevDownmixEne_e ); - hMcMasa->prevEQ = me2f( hMcMasa->prevEQ_fx, hMcMasa->prevEQ_e ); #endif #else ivas_mcmasa_ana( mcInput->hMcMasa, tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, mcInput->base.inputBuffer.config.numChannels ); @@ -10028,8 +10226,9 @@ static ivas_error renderInputMc( mcInput->base.gain = fix_to_float( mcInput->base.gain_fx, Q30 ); /* Apply input gain to new audio */ +#ifndef IVAS_FLOAT_FIXED v_multc( inAudio.data, mcInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - +#endif v_multc_fixed( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); *outAudio.pq_fact -= 1; // reducing the Q by 1 compensating for the v_mult_fixed done /* set combined orientation subframe info to start info */ -- GitLab