From 3f865db7ccf62c5f370c6f27d1e9816121f051e6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 27 May 2025 22:42:16 +0530 Subject: [PATCH 1/9] Precision improvement changes to improve the vad flag selection --- lib_enc/analy_sp_fx.c | 33 ++++++++++++++------------- lib_enc/ivas_core_pre_proc_front_fx.c | 7 +++--- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/nois_est_fx.c | 26 ++++++++++----------- lib_enc/prot_fx_enc.h | 2 +- lib_enc/stat_enc.h | 1 + 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 7062a3090..dbd656dec 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -569,6 +569,8 @@ void ivas_analy_sp_fx( *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 move16(); } + *q_band_energies = *q_fr_bands; + move16(); } ELSE { @@ -578,10 +580,10 @@ void ivas_analy_sp_fx( set32_fx( lf_E, 0, 2 * VOIC_BINS ); set32_fx( band_energies, 0, 2 * NB_BANDS ); set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands) - - LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1) + *Etot = -193760400; // Q24 *q_fr_bands = Q31; *q_lf_E = *q_fr_bands; + move32(); move16(); move16(); } @@ -596,25 +598,24 @@ void ivas_analy_sp_fx( MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); - } - /* Average total log energy over both half-frames */ - *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; - move16(); - IF( LEtot != 0 ) - { - exp = W_norm( LEtot ); - LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp - Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25 - Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 - *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 + /* Average total log energy over both half-frames */ + *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; move16(); + IF( LEtot != 0 ) + { + exp = W_norm( LEtot ); + LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp + Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25 + Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 + *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 + move16(); + } } + *q_band_energies = *q_fr_bands; + move16(); } - *q_band_energies = *q_fr_bands; - move16(); - exp = sub( getScaleFactor32( fr_bands, 2 * NB_BANDS ), 1 ); scale_sig32( fr_bands, 2 * NB_BANDS, exp ); /* q_fr_bands + exp */ *q_fr_bands = add( *q_fr_bands, exp ); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index be208296d..106d7c387 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1258,8 +1258,7 @@ ivas_error pre_proc_front_ivas_fx( noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx, &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, extract_h( st->hNoiseEst->Etot_l_lp_32fx ), - extract_h( st->hNoiseEst->Etot_v_h2_32fx ), &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, - hStereoClassif, NULL, st->ini_frame ); + st->hNoiseEst->Etot_v_h2_32fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame ); test(); IF( lr_vad_enabled && st->idchan == 0 ) @@ -1301,14 +1300,14 @@ ivas_error pre_proc_front_ivas_fx( noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, tmpE_LR_fx[0], q_tmpE_LR[0], fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], lf_E_LR_fx_q, &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, - extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, + extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame ); /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */ noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, tmpE_LR_fx[1], q_tmpE_LR[1], fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], lf_E_LR_fx_q, &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, - extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, + extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame ); } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index a4baf6a00..a6054a841 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -741,7 +741,7 @@ ivas_error front_vad_spar_fx( noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx, hFrontVad->hNoiseEst->ave_enr_q, fr_bands_fx[0], q_fr_bands[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, - lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), extract_h( hFrontVad->hNoiseEst->Etot_v_h2_32fx ), + lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame ); MVR2R_WORD16( st->pitch, st->pitch, 3 ); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 4f178214f..7534a5159 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -358,14 +358,14 @@ void noise_est_init_ivas_fx( move16(); hNoiseEst->Etot_lp_fx = 0; hNoiseEst->Etot_h_fx = 0; - hNoiseEst->Etot_l_fx = 0; + hNoiseEst->Etot_l_32fx = 0; hNoiseEst->Etot_l_lp_32fx = 0; hNoiseEst->Etot_last_32fx = 0; hNoiseEst->Etot_v_h2_32fx = 0; hNoiseEst->sign_dyn_lp_fx = 0; move16(); move16(); - move16(); + move32(); move16(); move32(); move32(); @@ -528,7 +528,7 @@ void noise_est_pre_32fx( Etot_h_32fx = L_sub( L_deposit_h( hNoiseEst->Etot_h_fx ), 671089 ); /* 671089=0.04 in Q24 */ Etot_h_32fx = L_max( Etot_h_32fx, Etot ); - Etot_l_32fx = L_add( L_deposit_h( hNoiseEst->Etot_l_fx ), 1342177 ); /* 1342177 = .08 in Q24 */ + Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, 1342177 ); /* 1342177 = .08 in Q24 */ /* Could even be higher but it also delays first entry to DTX */ IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) ) @@ -590,10 +590,10 @@ void noise_est_pre_32fx( move16(); } - hNoiseEst->Etot_l_fx = extract_h( Etot_l_32fx ); // Q8 + hNoiseEst->Etot_l_32fx = Etot_l_32fx; // Q24 hNoiseEst->Etot_h_fx = extract_h( Etot_h_32fx ); // Q8 hNoiseEst->Etot_lp_fx = extract_h( Etot_lp_32fx ); // Q8 - move16(); + move32(); move16(); move16(); @@ -2213,7 +2213,7 @@ void noise_est_ivas_fx( const Word16 q_lf_E, /* i : Q of lf_E Q0 */ Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */ const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */ - const Word16 Etot_v_h2, /* i : Energy variations Q8 */ + const Word32 Etot_v_h2, /* i : Energy variations Q24 */ Word16 *bg_cnt, /* i : Background burst length timer Q0 */ Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ @@ -3176,14 +3176,14 @@ void noise_est_ivas_fx( haco_ev_max = s_max( tmp, hNoiseEst->lt_haco_ev_fx ); /* Q15 */ /* Etot_l_lp_thr = st->Etot_l_lp + (1.5f + 1.5f * (st->Etot_lp<50.0f))*st->Etot_v_h2; */ - tmp = 12288; - move16(); /* 1.5 Q13 */ + L_tmp = 49152; /* 1.5 Q15 */ + move32(); if ( LT_16( hNoiseEst->Etot_lp_fx, 12800 ) ) /* 50.0 in Q8 */ { - tmp = shl( tmp, 1 ); /*1.5 + 1.5 Q13 */ + L_tmp = L_shl( L_tmp, 1 ); /*1.5 + 1.5 Q15 */ } - Ltmp = hNoiseEst->Etot_l_lp_32fx; - Etot_l_lp_thr = round_fx( L_add( Ltmp, L_shl( L_mult( tmp, Etot_v_h2 ), 2 ) ) ); /* Q13+Q8+1 +2 = Q24 -> Q8*/ + temp = W_mac_32_32( W_mult_32_32( hNoiseEst->Etot_l_lp_32fx, ONE_IN_Q15 ), Etot_v_h2, L_tmp ); // Q40(24+15+1) + Etot_l_lp_thr = W_round32_s( temp ); // Q8 /* enr_bgd = Etot < Etot_l_lp_thr; */ enr_bgd = 0; @@ -3367,8 +3367,8 @@ void noise_est_ivas_fx( move16(); test(); test(); - if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */ - && ( LT_16( sub( Etot, extract_h( hNoiseEst->Etot_l_lp_32fx ) ), shl( Etot_v_h2, 1 ) ) ) /* Q8 , Etot_v_h2 has limited dynmics can be upscaled*/ + if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */ + && ( LT_32( L_sub( L_deposit_h( Etot ), hNoiseEst->Etot_l_lp_32fx ), L_shl( Etot_v_h2, 1 ) ) ) /* Q24 , Etot_v_h2 has limited dynmics can be upscaled*/ && ( GT_16( *st_harm_cor_cnt, 20 ) ) ) { sd1_bgd = 1; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 8e323af82..59d2fdf9a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -404,7 +404,7 @@ void noise_est_ivas_fx( const Word16 q_lf_E, /* i : Q of lf_E Q0 */ Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */ const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */ - const Word16 Etot_v_h2, /* i : Energy variations Q8 */ + const Word32 Etot_v_h2, /* i : Energy variations Q24 */ Word16 *bg_cnt, /* i : Background burst length timer Q0 */ Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 41383f109..b9c515eea 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -549,6 +549,7 @@ typedef struct noise_estimation_structure Word16 bg_cnt; /* Noise estimator - pause length counter */ Word16 Etot_l_fx; /* Q8 Noise estimator - Track energy from below */ Word16 Etot_h_fx; /* Q8 Noise estimator - Track energy from above */ + Word32 Etot_l_32fx; /* Q24 Noise estimator - Track energy from below */ Word16 Etot_l_lp_fx; /* EVS- Q8 Noise estimator - Smoothed low energy */ Word32 Etot_l_lp_32fx; /* IVAS-Q24 Noise estimator - Smoothed low energy */ Word16 Etot_last_fx; /*EVS- Q8*/ -- GitLab From 76177d803521693ee1d7fffbff3ed4fc64e4c648 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 09:33:22 +0530 Subject: [PATCH 2/9] Optimizations in renderer and SBA encoder --- lib_com/ivas_fb_mixer_fx.c | 36 +++ lib_com/ivas_spar_com_fx.c | 78 ++++++- lib_com/options.h | 3 + lib_dec/ivas_binRenderer_internal_fx.c | 139 ++++++++++++ lib_dec/ivas_dirac_dec_fx.c | 19 +- lib_dec/ivas_mc_param_dec_fx.c | 2 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 + lib_dec/ivas_sba_rendering_internal_fx.c | 22 +- lib_enc/ivas_enc_cov_handler_fx.c | 51 ++++- .../ivas_dirac_dec_binaural_functions_fx.c | 205 ++++++++++++++++-- lib_rend/ivas_reverb_fx.c | 11 + lib_rend/ivas_sba_rendering_fx.c | 71 +++++- 12 files changed, 605 insertions(+), 34 deletions(-) diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index d5cd8d4f1..0d8a74514 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -759,6 +759,13 @@ void ivas_fb_mixer_process_fx( pMdft_out_fx[0] = Mdft_out_0_fx; pMdft_out_fx[1] = Mdft_out_1_fx; +#ifdef OPT_SBA_ENC_V1_BE + Word16 total_guard = find_guarded_bits_fx( num_bands ); + Word16 total_guard_2 = find_guarded_bits_fx( shl( frame_len, 1 ) ); + Word16 tmp_q = sub( sub( *q_mixer_mat_fx, total_guard ), 32 ); // Q30 + hFbMixer->q_prior_mixer_fx - 31 - total_guard - 31 + Word16 len = shl( frame_len, 1 ); + Word16 res_q, q_check; +#endif FOR( ch = ( hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hFbMixer->fb_cfg->num_out_chans; ch++ ) { /* Run a loop of 2 to calculate current frame's filterbank output and prev frame's output */ @@ -773,6 +780,12 @@ void ivas_fb_mixer_process_fx( IF( in_out_mixer_map[ch][j] != 0 ) { +#ifdef OPT_SBA_ENC_V1_BE + res_q = add( tmp_q, hFbMixer->q_ppFilterbank_inFR[j] ); + q_check = s_min( q_pOut_fr_fx, res_q ); + scale_sig32( pOut_fr_re_fx, frame_len, sub( q_check, q_pOut_fr_fx ) ); + scale_sig32( pOut_fr_im_fx, frame_len, sub( q_check, q_pOut_fr_fx ) ); +#endif Word32 filterbank_mixer_bins_re_fx[L_FRAME48k]; Word32 filterbank_mixer_bins_im_fx[L_FRAME48k]; Word32 *pFb_inFR_re_fx = hFbMixer->ppFilterbank_inFR_re_fx[j]; // Q(hFbMixer->q_ppFilterbank_inFR_re_fx) @@ -781,8 +794,10 @@ void ivas_fb_mixer_process_fx( set_zero_fx( filterbank_mixer_bins_re_fx, frame_len ); set_zero_fx( filterbank_mixer_bins_im_fx, frame_len ); +#ifndef OPT_SBA_ENC_V1_BE Word16 total_guard = find_guarded_bits_fx( num_bands ); move16(); +#endif FOR( i = 0; i < num_bands; i++ ) { Word16 start_offset = pFb->fb_consts.pFilterbank_bins_start_offset[i]; @@ -808,15 +823,19 @@ void ivas_fb_mixer_process_fx( hFbMixer->prior_mixer_fx[ch][j][i] = mixer_mat_fx[ch][j][i]; // Q(q_mixer_mat_fx) move32(); } +#ifndef OPT_SBA_ENC_V1_BE Word16 res_q = 0; move16(); +#endif FOR( k = 0; k < frame_len; k++ ) { Word32 temp_out_re_fx, temp_out_im_fx; ivas_cmult_fix( filterbank_mixer_bins_re_fx[k], filterbank_mixer_bins_im_fx[k], pFb_inFR_re_fx[k], pFb_inFR_im_fx[k], &temp_out_re_fx, &temp_out_im_fx ); +#ifndef OPT_SBA_ENC_V1_BE res_q = sub( add( sub( sub( add( 30, *q_mixer_mat_fx ), 31 ), total_guard ), hFbMixer->q_ppFilterbank_inFR[j] ), 31 ); + Word16 q_check = s_min( q_pOut_fr_fx, res_q ); IF( NE_16( q_check, q_pOut_fr_fx ) ) { @@ -825,31 +844,48 @@ void ivas_fb_mixer_process_fx( pOut_fr_im_fx[k] = L_shr( pOut_fr_im_fx[k], sub( q_pOut_fr_fx, q_check ) ); // q_pOut_fr_fx -> q_check move32(); } +#endif IF( NE_16( q_check, res_q ) ) { temp_out_re_fx = L_shr( temp_out_re_fx, sub( res_q, q_check ) ); // res_q -> q_check temp_out_im_fx = L_shr( temp_out_im_fx, sub( res_q, q_check ) ); // res_q -> q_check } +#ifndef OPT_SBA_ENC_V1_BE res_q = q_check; move16(); +#endif + pOut_fr_re_fx[k] = L_add_sat( pOut_fr_re_fx[k], temp_out_re_fx ); // res_q move32(); pOut_fr_im_fx[k] = L_add_sat( pOut_fr_im_fx[k], temp_out_im_fx ); // res_q move32(); } +#ifdef OPT_SBA_ENC_V1_BE + q_pOut_fr_fx = q_check; +#else q_pOut_fr_fx = res_q; move16(); +#endif } } +#ifndef OPT_SBA_ENC_V1_BE Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) ); +#else + Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), total_guard_2 ); +#endif scale_sig32( pOut_fr_re_fx, frame_len, scale ); scale_sig32( pOut_fr_im_fx, frame_len, scale ); ivas_imdft_fx( pOut_fr_re_fx, pOut_fr_im_fx, pMdft_out_fx[hist], frame_len ); q_pMdft_out_fx[hist] = add( q_pOut_fr_fx, scale ); move16(); } +#ifdef OPT_SBA_ENC_V1_BE + scale_sig32( pMdft_out_fx[0], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) ); + scale_sig32( pMdft_out_fx[1], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) ); +#else scale_sig32( pMdft_out_fx[0], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) ); scale_sig32( pMdft_out_fx[1], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) ); +#endif ivas_fb_mixer_cross_fading_fx( hFbMixer, ppOut_pcm_fx, pMdft_out_fx[0], pMdft_out_fx[1], ch, frame_len, frame_len ); q_ppOut_pcm_fx[ch] = s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ); move16(); diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index c2ad11e26..ef549a2ae 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -1995,15 +1995,23 @@ static void ivas_calc_post_pred_per_band_enc_fx( Word16 *q_postpred_cov_re ) { Word16 i, j, k; +#ifndef OPT_SBA_ENC_V1_BE Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 min_val; +#else + Word16 max_val; + Word16 temp; + Word32 temp_add; + Word16 e_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; +#endif + Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 tmp_re; Word16 tmp_q; Word16 tmp_e; +#ifndef OPT_SBA_ENC_V1_BE FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) @@ -2013,25 +2021,40 @@ static void ivas_calc_post_pred_per_band_enc_fx( } } + FOR( i = 0; i < num_ch; i++ ) { set32_fx( temp_mat[i], 0, num_ch ); set32_fx( postpred_cov_re[i], 0, num_ch ); } +#endif +#ifdef OPT_SBA_ENC_V1_BE + max_val = MIN16B; + move16(); + temp = sub( 62, q_mixer_mat ); +#else min_val = MAX16B; move16(); +#endif + /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { +#ifndef OPT_SBA_ENC_V1_BE temp_mat[i][j] = 0; +#else + temp_add = 0; +#endif move32(); temp_mat_e[i][j] = 0; move16(); + FOR( k = 0; k < num_ch; k++ ) { +#ifndef OPT_SBA_ENC_V1_BE tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ); tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) ); IF( tmp_re ) @@ -2039,34 +2062,71 @@ static void ivas_calc_post_pred_per_band_enc_fx( temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); move32(); } +#else + tmp_re = Mpy_32_32( cov_real[i][k][band_idx], mixer_mat[j][k][band_idx] ); + tmp_e = sub( temp, q_cov_real[i][k][band_idx] ); + IF( tmp_re ) + { + temp_add = BASOP_Util_Add_Mant32Exp( temp_add, temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); + } +#endif } +#ifdef OPT_SBA_ENC_V1_BE + temp_mat[i][j] = temp_add; + move32(); +#endif } } + tmp_e = sub( Q31, q_mixer_mat ); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { +#ifdef OPT_SBA_ENC_V1_BE + temp_add = 0; + move32(); + e_postpred_cov_re_buf[i][j] = sub( 31, *q_postpred_cov_re ); +#else q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re; +#endif move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ); +#ifdef OPT_SBA_ENC_V1_BE + tmp_q = add( tmp_e, temp_mat_e[k][j] ); +#else tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] ); +#endif IF( tmp_re ) { +#ifndef OPT_SBA_ENC_V1_BE tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] ); postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e ); move32(); q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e ); move16(); +#else + temp_add = BASOP_Util_Add_Mant32Exp( temp_add, e_postpred_cov_re_buf[i][j], tmp_re, tmp_q, &e_postpred_cov_re_buf[i][j] ); +#endif } } +#ifndef OPT_SBA_ENC_V1_BE IF( postpred_cov_re[i][j] ) { min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] ); +#else + if ( temp_add ) + { + max_val = s_max( max_val, e_postpred_cov_re_buf[i][j] ); +#endif } +#ifdef OPT_SBA_ENC_V1_BE + postpred_cov_re[i][j] = temp_add; + move32(); +#endif } } @@ -2077,7 +2137,11 @@ static void ivas_calc_post_pred_per_band_enc_fx( { IF( postpred_cov_re[i][j] ) { +#ifdef OPT_SBA_ENC_V1_BE + postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( max_val, e_postpred_cov_re_buf[i][j] ) ); +#else postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) ); +#endif move32(); } } @@ -2092,13 +2156,21 @@ static void ivas_calc_post_pred_per_band_enc_fx( move32(); } } - +#ifdef OPT_SBA_ENC_V1_BE + if ( EQ_16( max_val, MIN16B ) ) + { + max_val = 0; + move16(); + } + *q_postpred_cov_re = sub( Q31, max_val ); +#else if ( EQ_16( min_val, MAX16B ) ) { min_val = Q31; move16(); } *q_postpred_cov_re = min_val; +#endif move16(); return; diff --git a/lib_com/options.h b/lib_com/options.h index 20a1dc555..09765b959 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,6 +75,9 @@ #define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_SBA_ENC_V1_BE +#define OPT_BIN_RENDERER_V1 +#define OPT_BIN_RENDERER_V2 #define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ #define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c05b8beb2..ee6304e6e 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -54,7 +54,137 @@ * * *-------------------------------------------------------------------------*/ +#ifdef OPT_BIN_RENDERER_V2 +static void ivas_binRenderer_filterModule_fx( + Word32 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q6 */ + Word32 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q6 */ + Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals Q_curr*/ + Word32 CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals Q_curr*/ + const Word16 numTimeSlots, /* i : number of time slots to process */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word16 Q_curr ) +{ + Word16 bandIdx, k, chIdx, tapIdx; + Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; + Word16 Q_filterStates; + const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; + Word16 shift_q; + Word16 shift_q6 = sub( -29 + 6, Q_curr ); + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; + move16(); + + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; + Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + set64_fx( &Cldfb_RealBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); + set64_fx( &Cldfb_ImagBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); + + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); + filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); + + filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 + filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 + filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 + filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 + + FOR( k = 0; k < numTimeSlots; k++ ) + { + Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; + move64(); + move64(); + move64(); + move64(); + + FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) + { + filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; + move32(); + filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; + move32(); + Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); + + + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + } + + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); + + IF( shift_q != 0 ) + { + outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 + outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 + outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 + outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 + hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; + move16(); + } + + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); + + + /* Left Real and Imag */ + + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 + Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 + + + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr + move64(); + + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr + move64(); + + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr + move64(); + + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr + move64(); + } + } + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) + { + out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + } + } + } + + + return; +} +#else /* OPT_BIN_RENDERER_V2 */ static void ivas_binRenderer_filterModule_fx( Word64 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q29 */ Word64 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q29 */ @@ -164,6 +294,7 @@ static void ivas_binRenderer_filterModule_fx( return; } +#endif /* OPT_BIN_RENDERER_V2 */ /*------------------------------------------------------------------------- * ivas_binRenderer_convModuleOpen() @@ -1482,9 +1613,11 @@ void ivas_binRenderer_fx( ) { Word16 chIdx, i, j, k; +#ifndef OPT_BIN_RENDERER_V2 // to be checked: feasibility with 32 bit buffers Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif /* OPT_BIN_RENDERER_V2 */ push_wmops( "fastconv_binaural_rendering" ); /* Compute Convolution */ @@ -1495,8 +1628,10 @@ void ivas_binRenderer_fx( { set32_fx( Cldfb_RealBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); +#ifndef OPT_BIN_RENDERER_V2 set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); +#endif /* OPT_BIN_RENDERER_V2 */ } } @@ -1536,6 +1671,9 @@ void ivas_binRenderer_fx( ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } +#ifdef OPT_BIN_RENDERER_V2 + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); +#else /* OPT_BIN_RENDERER_V2 */ ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -1551,6 +1689,7 @@ void ivas_binRenderer_fx( } } } +#endif /* OPT_BIN_RENDERER_V2 */ /* Obtain the binaural dmx and compute the reverb */ IF( hBinRenderer->hReverb != NULL ) { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 7fecb7ca7..f29133d92 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2227,6 +2227,7 @@ void ivas_dirac_dec_render_sf_fx( } } +#ifndef OPT_BIN_RENDERER_V2 FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -2235,6 +2236,7 @@ void ivas_dirac_dec_render_sf_fx( set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); } } +#endif /* OPT_BIN_RENDERER_V2 */ /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; @@ -3931,8 +3933,8 @@ void ivas_dirac_dec_render_sf_fx( const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22 const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22 #else - const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 - const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 + const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 + const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 #endif efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); } @@ -3973,9 +3975,19 @@ void ivas_dirac_dec_render_sf_fx( { Word32 g_fx; w2_fx = sub( MAX16B, *w1_fx ); +#ifdef OPT_BIN_RENDERER_V2 + g_fx = Madd_32_16( Mpy_32_16_1( gain_fx, *w1_fx ), prev_gain_fx, w2_fx ); // Q15 +#else /* OPT_BIN_RENDERER_V2 */ g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); // Q15 +#endif /* OPT_BIN_RENDERER_V2 */ FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { +#ifdef OPT_BIN_RENDERER_V2 + Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_re_fx ); + move32(); + tc_re_fx++; + Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_im_fx ); +#else /* OPT_BIN_RENDERER_V2 */ Word32 tmp; tmp = Mpy_32_32( g_fx, *tc_re_fx ); Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); @@ -3983,6 +3995,7 @@ void ivas_dirac_dec_render_sf_fx( tc_re_fx++; tmp = Mpy_32_32( g_fx, *tc_im_fx ); Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); +#endif /* OPT_BIN_RENDERER_V2 */ move32(); tc_re_fx++; } @@ -4012,8 +4025,10 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); +#ifndef OPT_BIN_RENDERER_V2 Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 +#endif /* OPT_BIN_RENDERER_V2 */ /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index e0671eea0..0e2de6c01 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2151,6 +2151,7 @@ void ivas_param_mc_dec_render_fx( } } +#ifndef OPT_BIN_RENDERER_V2 FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) @@ -2159,6 +2160,7 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 } } +#endif /* OPT_BIN_RENDERER_V2 */ /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 783b94940..7a1ef1126 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -847,6 +847,7 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); +#ifndef OPT_BIN_RENDERER_V2 FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) @@ -855,6 +856,7 @@ static void ivas_mc_paramupmix_dec_sf( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 } } +#endif /* OPT_BIN_RENDERER_V2 */ /* Implement CLDFB synthesis */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index bbe63e965..d9ee47c84 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -77,7 +77,11 @@ void ivas_sba2mc_cldfb_fixed( FOR( m = 0; m < nb_channels_in; m++ ) { - g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 +#ifdef OPT_BIN_RENDERER_V2 + g_fx = L_shl_sat( hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )], Q2 ); +#else /* OPT_BIN_RENDERER_V2 */ + g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 +#endif /* OPT_BIN_RENDERER_V2 */ p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; @@ -87,9 +91,15 @@ void ivas_sba2mc_cldfb_fixed( p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/ FOR( iBand = 0; iBand < nb_bands; iBand++ ) { +#ifdef OPT_BIN_RENDERER_V2 + *p_realOut_fx = Madd_32_32( *p_realOut_fx, g_fx, *( p_real_fx++ ) ); // Q_real + move32(); + *p_imagOut_fx = Madd_32_32( *p_imagOut_fx, g_fx, *( p_imag_fx++ ) ); // Q_imag +#else /* OPT_BIN_RENDERER_V2 */ *p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real move32(); - *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag + *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag +#endif /* OPT_BIN_RENDERER_V2 */ move32(); p_realOut_fx++; p_imagOut_fx++; @@ -167,7 +177,11 @@ void ivas_mc2sba_fx( /* Add LFE to omni W with gain*/ FOR( k = 0; k < output_frame; k++ ) { +#ifdef OPT_BIN_RENDERER_V2 + buffer_tmp_fx[0][k] = Madd_32_16( buffer_tmp_fx[0][k], L_shl( in_buffer_td_fx[i][k], 1 ), gain_lfe_fx ); /*Q+14-15+1==Q*/ +#else /* OPT_BIN_RENDERER_V2 */ buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/ +#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } @@ -196,7 +210,11 @@ void ivas_mc2sba_fx( { FOR( k = 0; k < output_frame; k++ ) { +#ifdef OPT_BIN_RENDERER_V2 + buffer_tmp_fx[j][k] = Madd_32_32( buffer_tmp_fx[j][k], L_shl( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/ +#else /* OPT_BIN_RENDERER_V2 */ buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/ +#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 59c38aa5d..495e6caa1 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -514,6 +514,9 @@ static void ivas_band_cov_fx( Word16 q_shift, q_shift_tmp; Word16 m, start_bin, active_bins; Word16 num_blocks; +#ifdef OPT_SBA_ENC_V1_BE + Word16 shift_conv, q_shift_cov[IVAS_MAX_NUM_BANDS][IVAS_MAX_NUM_BANDS]; +#endif num_blocks = idiv1616( num_bins, stride ); /* Q0 */ FOR( i = 0; i < num_chans; i++ ) @@ -525,13 +528,24 @@ static void ivas_band_cov_fx( move16(); move16(); +#ifdef OPT_SBA_ENC_V1_BE + q_shift = 31; + move16(); +#endif FOR( k = 0; k < num_bins; k++ ) { pV_re_64bit[k] = W_add( W_mult0_32_32( ppIn_FR_real[i1][k], ppIn_FR_real[j1][k] ), W_mult0_32_32( ppIn_FR_imag[i1][k], ppIn_FR_imag[j1][k] ) ); //(q_In_FR[i1], q_In_FR[j1]) -> (q_In_FR[i1] + q_In_FR[j1]) move64(); +#ifdef OPT_SBA_ENC_V1_BE + q_shift_tmp = W_norm( pV_re_64bit[k] ); + if ( pV_re_64bit[k] != 0 ) + { + q_shift = s_min( q_shift, q_shift_tmp ); + } +#endif } - +#ifndef OPT_SBA_ENC_V1_BE q_shift = 31; move16(); FOR( k = 0; k < num_bins; k++ ) @@ -542,11 +556,17 @@ static void ivas_band_cov_fx( q_shift = s_min( q_shift, q_shift_tmp ); } } +#endif q_shift_tmp = sub( q_shift, 32 ); FOR( k = 0; k < num_bins; k++ ) { +#ifdef OPT_SBA_ENC_V1_BE + pV_re[k] = W_shl_sat_l( pV_re_64bit[k], q_shift_tmp ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) + move32(); +#else pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); +#endif /* perform rounding towards lower value for negative results */ if ( pV_re[k] < 0 ) { @@ -554,6 +574,10 @@ static void ivas_band_cov_fx( } } +#ifdef OPT_SBA_ENC_V1_BE + q_shift_cov[i][j] = Q31; + move16(); +#endif FOR( k = start_band; k < end_band; k++ ) { Word64 temp; @@ -575,7 +599,11 @@ static void ivas_band_cov_fx( /* optional: add temporal weight here */ FOR( m = 0; m < active_bins; m++ ) { +#ifdef OPT_SBA_ENC_V1_BE + temp = W_mac_32_32( temp, cov_ptr[m], p_bin_to_band[m] ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) + 1-> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 9) +#else temp = W_add( temp, W_mult0_32_32( cov_ptr[m], p_bin_to_band[m] ) ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) -> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) +#endif } cov_ptr += stride; move16(); @@ -584,8 +612,19 @@ static void ivas_band_cov_fx( cov_real_64bit[i][j][k] = temp * (Word64) ( num_blocks ); // (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) - guard_bits move64(); move64(); // conservative estimation of a 64 bit multiplication +#ifdef OPT_SBA_ENC_V1_BE + shift_conv = W_norm( cov_real_64bit[i][j][k] ); + if ( cov_real_64bit[i][j][k] != 0 ) + { + q_shift_cov[i][j] = s_min( q_shift_cov[i][j], shift_conv ); + } +#endif } +#ifdef OPT_SBA_ENC_V1_BE + q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q9 ) ); +#else q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q10 ) ); +#endif move16(); } } @@ -594,6 +633,7 @@ static void ivas_band_cov_fx( { FOR( j = i; j < num_chans; j++ ) { +#ifndef OPT_SBA_ENC_V1_BE q_shift = 31; move16(); FOR( k = start_band; k < end_band; k++ ) @@ -605,10 +645,19 @@ static void ivas_band_cov_fx( } } q_shift_tmp = sub( q_shift, 32 ); +#else + q_shift_tmp = sub( q_shift_cov[i][j], 32 ); +#endif FOR( k = start_band; k < end_band; k++ ) { +#ifdef OPT_SBA_ENC_V1_BE + + cov_real[i][j][k] = W_shl_sat_l( cov_real_64bit[i][j][k], q_shift_tmp ); /* q_cov_real[i][j] + q_shift - 32 */ + move32(); +#else cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], q_shift_tmp ) ); /* q_cov_real[i][j] + q_shift - 32 */ move32(); +#endif } q_cov_real[i][j] = add( q_cov_real[i][j], q_shift_tmp ); move16(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 9ea964bcb..2db86d6eb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -694,7 +694,9 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); move32(); move32(); - +#ifdef OPT_BIN_RENDERER_V1 + Word16 ch_len = s_max( 4, numInChannels ); +#endif /* OPT_BIN_RENDERER_V1 */ FOR( i = 0; i < 6; i++ ) { FOR( j = 0; j < 4; j++ ) @@ -854,19 +856,39 @@ static void ivas_dirac_dec_binaural_internal_fx( Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; move16(); +#ifndef OPT_BIN_RENDERER_V1 FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q31 - Q22 ); /*Q31 to Q22*/ } +#endif /* OPT_BIN_RENDERER_V1 */ ivas_sba_prototype_renderer_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe ); +#ifndef OPT_BIN_RENDERER_V1 FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q22 - Q31 ); /*Q31 to Q22*/ } +#endif /* OPT_BIN_RENDERER_V1 */ } Word16 q_inp = Q6; move16(); +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 cha = 0; cha < ch_len; cha++ ) + { + FOR( slot = 0; slot < 4; slot++ ) + { + Word16 q_diff = sub( q_inp, q_cldfb[cha][slot] ); + IF( q_diff != 0 ) + { + Scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, q_diff ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, q_diff ); // Q6 + q_cldfb[cha][slot] = 6; + } + move16(); + } + } +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 cha = 0; cha < 6; cha++ ) { FOR( slot = 0; slot < 4; slot++ ) @@ -877,6 +899,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } +#endif /* OPT_BIN_RENDERER_V1 */ test(); test(); @@ -1853,6 +1876,76 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( q_CrEne = Q31; move16(); +#ifdef OPT_BIN_RENDERER_V1 + Word16 q_diff = sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ); + + IF( q_diff > 0 ) + { + hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], q_diff ); + hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[0][bin] ); + hDiracDecBin->ChEne_e[1][bin] = hDiracDecBin->ChEne_e[0][bin]; + } + ELSE + { + hDiracDecBin->ChEne_fx[0][bin] = L_shl( hDiracDecBin->ChEne_fx[0][bin], q_diff ); + hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[1][bin] ); + hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], q_diff ); + hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[0][bin] ); + hDiracDecBin->ChEneOut_e[1][bin] = hDiracDecBin->ChEneOut_e[0][bin]; + } + ELSE + { + hDiracDecBin->ChEneOut_fx[0][bin] = L_shl( hDiracDecBin->ChEneOut_fx[0][bin], q_diff ); + hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[1][bin] ); + hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], q_diff ); + hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossRe_e[bin] ); + hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossRe_fx[bin] = L_shl( hDiracDecBin->ChCrossRe_fx[bin], q_diff ); + hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossIm_e[bin] ); + hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], q_diff ); + hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossReOut_e[bin] ); + hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossReOut_fx[bin] = L_shl( hDiracDecBin->ChCrossReOut_fx[bin], q_diff ); + hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossImOut_e[bin] ); + hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; + } + move32(); + move16(); + move16(); +#else /* OPT_BIN_RENDERER_V1 */ IF( GT_16( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ) { hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ); @@ -1912,6 +2005,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } move32(); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, @@ -2286,9 +2380,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin]; move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin]; move16(); } q_processMtxPrev_SCCR[bin] = q_processMtx_bin; @@ -2296,13 +2390,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked ); - hDiracDecBin->processMtxRe_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxRe_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxIm_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxIm_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxRe_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxRe_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxIm_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxIm_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) ); move16(); q_processMtx_SCCR[bin] = sub( sub( add( Q28, q_gain ), 31 ), 16 ); move16(); @@ -2311,9 +2405,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin]; move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin]; move16(); } q_processMtxPrev_SCCR[bin] = q_processMtx_SCCR[bin]; @@ -2368,13 +2462,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { FOR( chB = 0; chB < nchanSeparateChannels; chB++ ) { - hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx + hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx move16(); - hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx + hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx move16(); - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev move16(); } } @@ -2421,6 +2515,10 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 *decSlotImPointer_fx; Word16 q_inp_mix, q_reverb = 31; move16(); +#ifdef OPT_BIN_RENDERER_V1 + Word16 ch_len = s_max( 4, numInChannels ); + Word16 eff_q; +#endif /* OPT_BIN_RENDERER_V1 */ IF( processReverb ) @@ -2434,7 +2532,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); q_inp_mix = 31; move16(); +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < ch_len; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2461,7 +2563,14 @@ static void ivas_dirac_dec_binaural_process_output_fx( move16(); } + +#ifdef OPT_BIN_RENDERER_V1 + eff_q = sub( add( q_inp_mix, q_mat ), 15 ); + + FOR( Word16 i = 0; i < ch_len; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2471,8 +2580,13 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( processReverb && LT_16( i, 2 ) ) { +#ifdef OPT_BIN_RENDERER_V1 + scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ + scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ +#else /* OPT_BIN_RENDERER_V1 */ scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ +#endif /* OPT_BIN_RENDERER_V1 */ } } } @@ -2636,7 +2750,11 @@ static void adaptTransportSignalsHeadtracked_fx( move16(); move16(); +#ifdef OPT_BIN_RENDERER_V1 + FOR( i = 0; i < 2; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -3658,7 +3776,7 @@ static void matrixTransp2Mul_fx( { Word16 chA, chB; Word16 min_q_shift; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; IF( Ascale == 1 ) { @@ -4107,10 +4225,18 @@ static void formulate2x2MixingMatrix_fx( Sx_fx[1] = Sqrt32( Sx_fx[1], &exp1 ); move32(); q_Sx = sub( 31, s_max( exp, exp1 ) ); +#ifdef OPT_BIN_RENDERER_V1 + Word16 q_diff = sub( 31, q_Sx ); + Sx_fx[0] = L_shr( Sx_fx[0], sub( q_diff, exp ) ); // q_Sx + move32(); + Sx_fx[1] = L_shr( Sx_fx[1], sub( q_diff, exp1 ) ); // q_Sx + move32(); +#else /* OPT_BIN_RENDERER_V1 */ Sx_fx[0] = L_shr( Sx_fx[0], sub( sub( 31, exp ), q_Sx ) ); // q_Sx move32(); Sx_fx[1] = L_shr( Sx_fx[1], sub( sub( 31, exp1 ), q_Sx ) ); // q_Sx move32(); +#endif /* OPT_BIN_RENDERER_V1 */ matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx ); @@ -4178,11 +4304,18 @@ static void formulate2x2MixingMatrix_fx( move32(); q_Ghat = sub( 31, s_max( exp, exp1 ) ); - +#ifdef OPT_BIN_RENDERER_V1 + q_diff = sub( 31, q_Ghat ); + Ghat_fx[0] = L_shr( Ghat_fx[0], sub( q_diff, exp ) ); // q_Ghat + move32(); + Ghat_fx[1] = L_shr( Ghat_fx[1], sub( q_diff, exp1 ) ); // q_Ghat + move32(); +#else /* OPT_BIN_RENDERER_V1 */ Ghat_fx[0] = L_shr( Ghat_fx[0], sub( sub( 31, exp ), q_Ghat ) ); // q_Ghat move32(); Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); // q_Ghat move32(); +#endif /* OPT_BIN_RENDERER_V1 */ /* Matrix multiplication, tmp = Ky' * G_hat * Q */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4195,8 +4328,8 @@ static void formulate2x2MixingMatrix_fx( q_GhatQ = sub( add( Q31, q_Ghat ), 31 ); exp = sub( s_min( L_norm_arr( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ), L_norm_arr( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ) ), 1 ); - scale_sig32( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); - scale_sig32( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); + scale_sig32( KyRe_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp ); + scale_sig32( KyIm_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp ); q_ky = add( q_ky, exp ); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4204,7 +4337,7 @@ static void formulate2x2MixingMatrix_fx( FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { tmpRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( KyRe_fx[0][chA], GhatQ_fx[0][chB] ), KyRe_fx[1][chA], GhatQ_fx[1][chB] ); - tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( -KyIm_fx[0][chA], GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] ); + tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( L_negate( KyIm_fx[0][chA] ), GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] ); move32(); move32(); } @@ -4254,6 +4387,11 @@ static void formulate2x2MixingMatrix_fx( move32(); // 1310720000 = 10,000.0f in Q17 +#ifdef OPT_BIN_RENDERER_V1 + Word32 thresh = L_shl_sat( 1310720000, sub( q_div, Q17 ) ); // q_div + div_fx[0] = L_min( div_fx[0], thresh ); // q_div + div_fx[1] = L_min( div_fx[1], thresh ); // q_div +#else /* OPT_BIN_RENDERER_V1 */ IF( LT_16( q_div, Q17 ) ) { div_fx[0] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[0] ); // q_div @@ -4270,6 +4408,7 @@ static void formulate2x2MixingMatrix_fx( q_div = Q17; move16(); } +#endif /* OPT_BIN_RENDERER_V1 */ matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); @@ -4286,6 +4425,13 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpRe_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { +#ifdef OPT_BIN_RENDERER_V1 + Word16 hdrm = sub( W_norm( W_tmp ), 32 ); + tmpRe_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); + move32(); + hdrm_re[chA][chB] = add( add( q_temp, q_div ), hdrm ); + move16(); +#else /* OPT_BIN_RENDERER_V1 */ hdrm_re[chA][chB] = sub( W_norm( W_tmp ), 0 ); move16(); W_tmp = W_shl( W_tmp, hdrm_re[chA][chB] ); @@ -4293,6 +4439,7 @@ static void formulate2x2MixingMatrix_fx( move32(); hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 ); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4303,6 +4450,14 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpIm_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { +#ifdef OPT_BIN_RENDERER_V1 + Word16 hdrm = sub( W_norm( W_tmp ), 32 ); + move16(); + tmpIm_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); + move32(); + hdrm_im[chA][chB] = add( add( q_temp, q_div ), hdrm ); + move16(); +#else /* OPT_BIN_RENDERER_V1 */ hdrm_im[chA][chB] = sub( W_norm( W_tmp ), 0 ); move16(); W_tmp = W_shl( W_tmp, hdrm_im[chA][chB] ); @@ -4310,6 +4465,7 @@ static void formulate2x2MixingMatrix_fx( move32(); hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 ); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4322,8 +4478,11 @@ static void formulate2x2MixingMatrix_fx( minimum_s( hdrm_re[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); q_temp = exp; move16(); - minimum_s( hdrm_im[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + minimum_s( hdrm_im[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_temp = s_min( q_temp, exp ); +#ifdef OPT_BIN_RENDERER_V1 + q_temp = sub( q_temp, 1 ); +#endif /* OPT_BIN_RENDERER_V1 */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4337,7 +4496,11 @@ static void formulate2x2MixingMatrix_fx( } matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, +#ifdef OPT_BIN_RENDERER_V1 + 0 /*int Ascale*/, +#else /* OPT_BIN_RENDERER_V1 */ 1 /*int Ascale*/, +#endif /* OPT_BIN_RENDERER_V1 */ 0 /*int Bscale*/, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ @@ -4454,9 +4617,9 @@ static void formulate2x2MixingMatrix_fx( move16(); } #endif - minimum_s( q_Pre[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + minimum_s( q_Pre[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_P = s_min( q_P, exp ); - minimum_s( q_Pim[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + minimum_s( q_Pim[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_P = s_min( q_P, exp ); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 12b94b1a2..b9b897f4a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2271,6 +2271,16 @@ void ivas_binaural_reverb_processSubframe_fx( { Word32 leftRe_fx, rightRe_fx, leftIm_fx, rightIm_fx; +#ifdef OPT_BIN_RENDERER_V2 + leftRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), + hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ); // Q_in + rightRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), + hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ); // Q_in + leftIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ), + hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ); // Q_in + rightIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), + hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ); // Q_in +#else /* OPT_BIN_RENDERER_V2 */ leftRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ) ); // Q_in rightRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), @@ -2279,6 +2289,7 @@ void ivas_binaural_reverb_processSubframe_fx( Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ) ); // Q_in rightIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ) ); // Q_in +#endif /* OPT_BIN_RENDERER_V2 */ hReverb->outputBufferReal_fx[bin][0][sample] = leftRe_fx; // Q_in move32(); diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 5e097ab2b..896742151 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -87,7 +87,11 @@ void ivas_sba_prototype_renderer_fx( Word16 norm_q = 31; // to handle overflow move16(); +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < 2; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { @@ -95,22 +99,39 @@ void ivas_sba_prototype_renderer_fx( } } norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow - Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME]; + Word16 q_inp[2][CLDFB_SLOTS_PER_SUBFRAME]; +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < 2; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { +#ifdef OPT_BIN_RENDERER_V1 + q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], num_cldfb_bands ), L_norm_arr( inIm_fx[i][j], num_cldfb_bands ) ); +#else /* OPT_BIN_RENDERER_V1 */ q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); +#endif /* OPT_BIN_RENDERER_V1 */ move16(); norm_q = s_min( q_inp[i][j], norm_q ); } } +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < 2; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { - scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q - scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q +#ifdef OPT_BIN_RENDERER_V1 + scale_sig32( inRe_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q + scale_sig32( inIm_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q +#else /* OPT_BIN_RENDERER_V1 */ + scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q + scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q +#endif /* OPT_BIN_RENDERER_V1 */ q_cldfb[i][j] = sub( add( q_cldfb[i][j], norm_q ), 2 ); move16(); } @@ -178,12 +199,21 @@ void ivas_sba_prototype_renderer_fx( FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ +#ifdef OPT_BIN_RENDERER_V1 + cldfb_par_fx = Madd_32_32( cldfb_par_fx, mixer_mat_fx[out_ch][in_ch][spar_band], L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 ) ); // hMdDec->Q_mixer_matrix +#else /* OPT_BIN_RENDERER_V1 */ cldfb_par_fx = L_add( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); // hMdDec->Q_mixer_matrix +#endif /* OPT_BIN_RENDERER_V1 */ } } - out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 - out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 +#ifdef OPT_BIN_RENDERER_V1 + out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 + out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 +#else /* OPT_BIN_RENDERER_V1 */ + out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 + out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 +#endif /* OPT_BIN_RENDERER_V1 */ move32(); move32(); } @@ -242,11 +272,41 @@ void ivas_sba_prototype_renderer_fx( { IF( EQ_16( st_ivas->nchan_transport, 1 ) ) /* Dual mono */ { +#ifdef OPT_BIN_RENDERER_V1 + Copy32( inRe_fx[0][ts], inRe_fx[1][ts], num_cldfb_bands ); + Copy32( inIm_fx[0][ts], inIm_fx[1][ts], num_cldfb_bands ); +#else /* OPT_BIN_RENDERER_V1 */ Copy32( inRe_fx[0][ts], inRe_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); Copy32( inIm_fx[0][ts], inIm_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); +#endif /* OPT_BIN_RENDERER_V1 */ } ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) /* Opposing cardioids */ { +#ifdef OPT_BIN_RENDERER_V1 + Word32 temp_signal_fx; + FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ ) + { + Word32 op1 = L_shr( inRe_fx[0][ts][idx], 1 ); + Word32 op2 = L_shr( inRe_fx[1][ts][idx], 1 ); + temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1 + inRe_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1 + move32(); + inRe_fx[0][ts][idx] = temp_signal_fx; + move32(); + } + + FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ ) + { + Word32 op1 = L_shr( inIm_fx[0][ts][idx], 1 ); + Word32 op2 = L_shr( inIm_fx[1][ts][idx], 1 ); + temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1 + move32(); + inIm_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1 + move32(); + inIm_fx[0][ts][idx] = temp_signal_fx; + move32(); + } +#else /* OPT_BIN_RENDERER_V1 */ Word32 temp_signal_fx[CLDFB_NO_CHANNELS_MAX]; FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -267,6 +327,7 @@ void ivas_sba_prototype_renderer_fx( inIm_fx[0][ts][idx] = temp_signal_fx[idx]; move32(); } +#endif /* OPT_BIN_RENDERER_V1 */ } } } -- GitLab From a50df063f2a379c7abb1ab96dc4c36a6675820f7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 09:59:19 +0530 Subject: [PATCH 3/9] Clang formatting changes --- lib_dec/ivas_binRenderer_internal_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index ee6304e6e..ae16bf7b5 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -144,7 +144,7 @@ static void ivas_binRenderer_filterModule_fx( Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 - Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 + Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); -- GitLab From 4e550822a0aef05e9b9eeaf4697ee1c174b0296e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 10 Jul 2025 13:57:57 +0200 Subject: [PATCH 4/9] run clang-format --- lib_dec/ivas_dirac_dec_fx.c | 8 ++++---- lib_rend/ivas_reverb_fx.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 4c74d3144..ee0494190 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1883,8 +1883,8 @@ void ivas_qmetadata_to_dirac_fx( } /* for ( block =...) */ - } /* for ( band = ...) */ - } /* for ( idx_sec = ...)*/ + } /* for ( band = ...) */ + } /* for ( idx_sec = ...)*/ /* Bands not transmitted -> zeroed*/ FOR( b = band_grouping[band]; b < hSpatParamRendCom->num_freq_bands; b++ ) @@ -3919,8 +3919,8 @@ void ivas_dirac_dec_render_sf_fx( const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22 const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22 #else - const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 - const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 + const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 + const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 #endif efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); } diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6e1c9f7cf..8c5e8813d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2301,7 +2301,7 @@ static ivas_error ivas_binaural_reverb_open_fx( #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ #else - const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ #endif const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ -- GitLab From c206c35675831a65be11b3b5a16a9f6d0707ee1a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 10 Jul 2025 14:59:38 +0200 Subject: [PATCH 5/9] fix crash in split rendering smoke test --- .../ivas_dirac_dec_binaural_functions_fx.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 6a3168158..9cd620c22 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2830,20 +2830,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( } } - move16(); -#ifdef OPT_BIN_RENDERER_V1 - FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ - { - FOR( Word16 j = 0; j < nSlots; j++ ) - { - /* Process second / room effect part of binaural output when needed */ - ivas_binaural_reverb_processSubframe_fx( hDiracDecBin->hReverb, numInChannels, nSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - } - } - IF( EQ_16( recompute, 1 ) ) { // scaling input and reverb to same q// @@ -2851,7 +2837,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); q_inp_mix = 31; move16(); +#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < ch_len; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { -- GitLab From 1da9bd79df478fd770d59cae89a7cff10d50ced3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 14 Jul 2025 16:01:00 +1000 Subject: [PATCH 6/9] out of bound access fix --- lib_dec/ivas_binRenderer_internal_fx.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 1b686dc64..a0693deba 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1863,18 +1863,18 @@ void ivas_binRenderer_fx( } } } + +#ifndef OPT_BIN_RENDERER_V2 FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) { - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#ifndef OPT_BIN_RENDERER_V2 + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#endif /* OPT_BIN_RENDERER_V2 */ } } +#endif /* OPT_BIN_RENDERER_V2 */ FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { @@ -2009,20 +2009,16 @@ void ivas_binRenderer_fx( { rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } - +#ifndef OPT_BIN_RENDERER_V2 FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#else set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#endif } } +#endif #ifdef OPT_BIN_RENDERER_V2 ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx], Cldfb_ImagBuffer_Binaural_fx[pos_idx], RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); #else -- GitLab From e4b1213ad3ec7976ffda269e0795a4f10a5790da Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 14 Jul 2025 21:06:32 +1000 Subject: [PATCH 7/9] double left shift on cldfb buffers --- .../ivas_dirac_dec_binaural_functions_fx.c | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 9cd620c22..8bbebc675 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2868,7 +2868,13 @@ static void ivas_dirac_dec_binaural_process_output_fx( move16(); } +#ifdef OPT_BIN_RENDERER_V1 + eff_q = sub( add( q_inp_mix, q_mat ), 15 ); + + FOR( Word16 i = 0; i < ch_len; i++ ) +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 i = 0; i < 6; i++ ) +#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2878,8 +2884,13 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) { +#ifdef OPT_BIN_RENDERER_V1 + scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ + scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ +#else /* OPT_BIN_RENDERER_V1 */ scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ +#endif } } } @@ -2899,34 +2910,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( q_inp_mix = *Q_inp_mix; } - -#ifdef OPT_BIN_RENDERER_V1 - eff_q = sub( add( q_inp_mix, q_mat ), 15 ); - - FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ - { - FOR( Word16 j = 0; j < nSlots; j++ ) - { - - scale_sig32( inRe_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ - scale_sig32( inIm_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ - test(); - IF( processReverb && LT_16( i, 2 ) ) - { -#ifdef OPT_BIN_RENDERER_V1 - scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ - scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ -#else /* OPT_BIN_RENDERER_V1 */ - scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ - scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ -#endif /* OPT_BIN_RENDERER_V1 */ - } - } - } - q_inp_mix = add( q_inp_mix, q_input ); interpVal_fx = 0; -- GitLab From 27acb769c0676cbd4f58b4d525a449796d914fa5 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 16 Jul 2025 14:19:51 +1000 Subject: [PATCH 8/9] fix split rendering issues with merge of OPT_BIN_RENDERER_V2 --- lib_dec/ivas_binRenderer_internal_fx.c | 24 ++++++++++++++++++++---- lib_dec/ivas_dirac_dec_fx.c | 6 ++++-- lib_dec/ivas_mc_param_dec_fx.c | 6 +++--- lib_dec/ivas_mc_paramupmix_dec_fx.c | 6 ++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index a0693deba..615d68a32 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1869,7 +1869,6 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } @@ -2050,7 +2049,9 @@ void ivas_binRenderer_fx( Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - +#ifdef OPT_BIN_RENDERER_V2 + Word16 shift_q; +#endif ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -2064,16 +2065,26 @@ void ivas_binRenderer_fx( ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); +#ifdef OPT_BIN_RENDERER_V2 + shift_q = sub( Q6, sub( *Q_in, 1 ) ); +#endif FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < numTimeSlots; j++ ) { FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) { +#ifdef OPT_BIN_RENDERER_V2 + reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], shift_q ); // Q6 + move32(); + reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], shift_q ); // Q6 + move32(); +#else reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in move32(); reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in move32(); +#endif } } } @@ -2086,8 +2097,8 @@ void ivas_binRenderer_fx( for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q6 + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q6 } } } @@ -2167,8 +2178,13 @@ void ivas_rend_CldfbMultiBinRendProcess( { Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); +#ifndef OPT_BIN_RENDERER_V2 Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig +#else + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q6 ) ); // Q_in + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q6 ) ); // Q_in +#endif } } } diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index ee0494190..7e39db7c0 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -4022,19 +4022,22 @@ void ivas_dirac_dec_render_sf_fx( } } + /*Binaural output in Q6 format*/ ivas_binRenderer_fx( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); -#ifndef OPT_BIN_RENDERER_V2 + Word16 pos_idx; +#ifndef OPT_BIN_RENDERER_V2 FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { Scale_sig32( &Cldfb_RealBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 Scale_sig32( &Cldfb_ImagBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 } +#endif IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -4049,7 +4052,6 @@ void ivas_dirac_dec_render_sf_fx( } } } -#endif /* OPT_BIN_RENDERER_V2 */ /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index d8c1c0c1b..b87ea8d3d 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2150,6 +2150,7 @@ void ivas_param_mc_dec_render_fx( } /* Implement binaural rendering */ + /*Binaural output in Q6 format*/ ivas_binRenderer_fx( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, @@ -2170,8 +2171,8 @@ void ivas_param_mc_dec_render_fx( } } + Word16 pos_idx; #ifndef OPT_BIN_RENDERER_V2 - int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) @@ -2186,7 +2187,7 @@ void ivas_param_mc_dec_render_fx( } } } - +#endif /* OPT_BIN_RENDERER_V2 */ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -2201,7 +2202,6 @@ void ivas_param_mc_dec_render_fx( } } } -#endif /* OPT_BIN_RENDERER_V2 */ /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 252230962..b6da5c01b 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -877,6 +877,7 @@ static void ivas_mc_paramupmix_dec_sf( } /* Implement binaural rendering */ + /*Binaural output in Q6 format*/ ivas_binRenderer_fx( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, @@ -885,8 +886,8 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); + Word16 pos_idx; #ifndef OPT_BIN_RENDERER_V2 - int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) @@ -901,6 +902,7 @@ static void ivas_mc_paramupmix_dec_sf( } } } +#endif /* OPT_BIN_RENDERER_V2 */ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -917,7 +919,7 @@ static void ivas_mc_paramupmix_dec_sf( } } -#endif /* OPT_BIN_RENDERER_V2 */ + /* Implement CLDFB synthesis */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -- GitLab From 4a61a0bb759f1c3008d011853bc00c7546bf4ad3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 16 Jul 2025 15:42:16 +1000 Subject: [PATCH 9/9] fix FOA analysis order split rendering q factor --- lib_dec/ivas_binRenderer_internal_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 615d68a32..66f6c646c 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1968,6 +1968,8 @@ void ivas_binRenderer_fx( Quaternions_ref2.z_fx = 0; #ifndef OPT_BIN_RENDERER_V2 extra_shift = 1; +#else + *Q_in = sub( *Q_in, 1 ); #endif } ELSE -- GitLab