From 7998b25712a3d66bc26f8d40cf275e4bb9fcb5dc Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 1 Aug 2023 15:22:58 +1000 Subject: [PATCH 1/5] fix for vanishing residuals in SBA mode when W channel in the input is silence --- lib_com/ivas_cnst.h | 4 + lib_com/ivas_fb_mixer.c | 47 ++++++-- lib_com/ivas_prot.h | 54 ++++++++- lib_com/ivas_spar_com.c | 169 +++++++++++++++++++++++----- lib_com/ivas_stat_com.h | 4 + lib_com/options.h | 2 + lib_dec/ivas_spar_decoder.c | 7 ++ lib_dec/ivas_spar_md_dec.c | 124 +++++++++++++++++++-- lib_enc/ivas_enc_cov_handler.c | 146 +++++++++++++++++++++++- lib_enc/ivas_mc_paramupmix_enc.c | 7 +- lib_enc/ivas_spar_encoder.c | 183 ++++++++++++++++++++++++++++--- lib_enc/ivas_spar_md_enc.c | 36 +++++- lib_enc/ivas_stat_enc.h | 5 +- 13 files changed, 721 insertions(+), 67 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4cd06c6ed4..38bb1c9418 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1032,6 +1032,10 @@ typedef enum #define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 +#ifdef FIX_SBA_VANISHING_RESIDUAL +#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) +#endif + #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 #define IVAS_NUM_PROB_MODELS 4 diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index a94a92c548..070a0ff5fa 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -590,14 +590,22 @@ void ivas_fb_mixer_get_windowed_fr( * * FB Mixer cross fading *-----------------------------------------------------------------------------------------*/ - -static void ivas_fb_mixer_cross_fading( - IVAS_FB_MIXER_HANDLE hFbMixer, - float **ppOut_pcm, - float *pMdft_out_old, - float *pMdft_out_new, - const int16_t ch, - const int16_t frame_len ) +#ifndef FIX_SBA_VANISHING_RESIDUAL +static +#endif + void + ivas_fb_mixer_cross_fading( + IVAS_FB_MIXER_HANDLE hFbMixer, + float **ppOut_pcm, + float *pMdft_out_old, + float *pMdft_out_new, + const int16_t ch, + const int16_t frame_len +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t cf_offset +#endif + ) { int16_t k, fade_start_offset, fade_end_offset; @@ -608,17 +616,29 @@ static void ivas_fb_mixer_cross_fading( for ( k = 0; k < fade_start_offset; k++ ) { +#ifdef FIX_SBA_VANISHING_RESIDUAL + ppOut_pcm[ch][k] = pMdft_out_old[k + cf_offset]; +#else ppOut_pcm[ch][k] = pMdft_out_old[k + frame_len]; +#endif } for ( k = fade_start_offset; k < fade_end_offset; k++ ) { +#ifdef FIX_SBA_VANISHING_RESIDUAL + ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset] * hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] + pMdft_out_old[k + cf_offset] * ( 1.0f - hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] ); +#else ppOut_pcm[ch][k] = pMdft_out_new[k + frame_len] * hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] + pMdft_out_old[k + frame_len] * ( 1.0f - hFbMixer->pFilterbank_cross_fade[k - fade_start_offset] ); +#endif } for ( k = fade_end_offset; k < frame_len; k++ ) { +#ifdef FIX_SBA_VANISHING_RESIDUAL + ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset]; +#else ppOut_pcm[ch][k] = pMdft_out_new[k + frame_len]; +#endif } } else @@ -627,7 +647,11 @@ static void ivas_fb_mixer_cross_fading( for ( k = 0; k < frame_len; k++ ) { +#ifdef FIX_SBA_VANISHING_RESIDUAL + ppOut_pcm[ch][k] = pMdft_out_new[k + cf_offset]; +#else ppOut_pcm[ch][k] = pMdft_out_new[k + frame_len]; +#endif } } @@ -717,7 +741,12 @@ void ivas_fb_mixer_process( ivas_imdft( pOut_fr_re, pOut_fr_im, pMdft_out[hist], frame_len ); } - ivas_fb_mixer_cross_fading( hFbMixer, ppOut_pcm, pMdft_out[0], pMdft_out[1], ch, frame_len ); + ivas_fb_mixer_cross_fading( hFbMixer, ppOut_pcm, pMdft_out[0], pMdft_out[1], ch, frame_len +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + frame_len +#endif + ); } return; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 885de08281..898bc5a523 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -114,6 +114,18 @@ ivas_error ivas_spar_md_enc_init const int16_t sba_order /* i : Ambisonic (SBA) order */ ); +#ifdef FIX_SBA_VANISHING_RESIDUAL +int16_t ivas_spar_get_activeW_flag( + ivas_enc_cov_handler_state_t *hCovEnc, + float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + const int16_t dtx_vad, + const int16_t nchan_inp, + const int16_t nchan_transport, + int16_t *res_ind, + const int16_t *dmx_order); +#endif + ivas_error ivas_sba_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -4327,6 +4339,10 @@ ivas_error ivas_spar_md_enc_process( const int16_t nchan_inp, const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i : prior mixer_matrix */ +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ); void ivas_compute_spar_params( @@ -4345,6 +4361,10 @@ void ivas_compute_spar_params( ivas_spar_md_t *hSparMd, float *pWscale, const int16_t from_dirac +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ); void ivas_create_fullr_dmx_mat( @@ -4372,6 +4392,10 @@ void ivas_calc_c_p_coeffs( , const int16_t planarCP #endif +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ); void ivas_get_spar_md_from_dirac( @@ -4390,6 +4414,10 @@ void ivas_get_spar_md_from_dirac( , const uint8_t useLowerRes, const int16_t active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ); /*! r: number of MD subframes */ @@ -4459,7 +4487,11 @@ void ivas_spar_to_dirac( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bw /* i : band joining factor */ + const int16_t bw /* i : band joining factor */ +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ); void ivas_spar_update_md_hist( @@ -4514,6 +4546,14 @@ void ivas_enc_cov_handler_process( const int16_t dtx_vad, const int16_t transient_det[2], const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + int16_t *res_ind, + const int16_t *remix_order, + int16_t *dyn_active_w_flag, + const int16_t nchan_transport, + const int16_t is_sba +#endif ); ivas_error ivas_spar_covar_smooth_enc_open( @@ -5550,6 +5590,18 @@ void ivas_fb_mixer_get_in_out_mapping( int16_t in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */ ); +#ifdef FIX_SBA_VANISHING_RESIDUAL +void ivas_fb_mixer_cross_fading( + IVAS_FB_MIXER_HANDLE hFbMixer, + float **ppOut_pcm, + float *pMdft_out_old, + float *pMdft_out_new, + const int16_t ch, + const int16_t frame_len, + const int16_t cf_offset + ); +#endif + /*! r: number of spectral bands */ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index d597d133fd..7c9ef6bfbf 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -77,11 +77,22 @@ *------------------------------------------------------------------------------------------*/ -static void ivas_get_pred_coeffs( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ppPred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ppDM_Fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t start_band, const int16_t end_band, const int16_t active_w, const int16_t active_w_vlbr, const int16_t dtx_vad, const int16_t from_dirac ); +static void ivas_get_pred_coeffs( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ppPred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ppDM_Fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t start_band, const int16_t end_band, const int16_t active_w, const int16_t active_w_vlbr, const int16_t dtx_vad, const int16_t from_dirac +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag, + const int16_t res_ind +#endif +); static void ivas_reorder_array( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t order[IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t start_band, const int16_t end_band ); -static void ivas_get_Wscaling_factor( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ***mixer_mat, const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, const int16_t num_ch, const int16_t *pNum_dmx, const int16_t bands_bw, const int16_t active_w, const int16_t active_w_vlbr, float *pWscale ); +static void ivas_get_Wscaling_factor( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ***mixer_mat, const int16_t start_band, const int16_t end_band, const int16_t dtx_vad, const int16_t num_ch, const int16_t *pNum_dmx, const int16_t bands_bw, const int16_t active_w, const int16_t active_w_vlbr, float *pWscale +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +); static void ivas_calc_post_pred_per_band( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t num_ch, const int16_t num_dmx, const int16_t band_idx, float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH] ); @@ -462,7 +473,13 @@ static void ivas_get_pred_coeffs( const int16_t active_w, const int16_t active_w_vlbr, const int16_t dtx_vad, - const int16_t from_dirac ) + const int16_t from_dirac +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag, + const int16_t res_ind +#endif +) { int16_t i, j, k, b; float abs_value; @@ -517,7 +534,21 @@ static void ivas_get_pred_coeffs( float real[IVAS_SPAR_MAX_CH - 1], dm_beta_re = 0, dm_g[IVAS_MAX_NUM_BANDS]; float dm_f_local, dm_w, dm_y, DM_F[IVAS_MAX_NUM_BANDS]; float num_f, den_f, passive_g; +#ifdef FIX_SBA_VANISHING_RESIDUAL + float activew_quad_thresh; + if ( dyn_active_w_flag == 1 ) + { + activew_quad_thresh = 1.0f; + } + else + { + activew_quad_thresh = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH; + } + float g_th_sq = activew_quad_thresh * activew_quad_thresh; +#else float g_th_sq = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH * IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH; +#endif + set_zero( dm_alpha, IVAS_MAX_NUM_BANDS ); @@ -580,7 +611,26 @@ static void ivas_get_pred_coeffs( den_f = max( dm_w, 1e-20f ); passive_g = dm_alpha[b] / den_f; +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( dyn_active_w_flag == 1 ) + { + dm_alpha[b] = 0.0f; + dm_w = 0.0f; + for ( i = 0; i < pred_dim; i++ ) + { + dm_v_re[i][b] = 0.0f; + } + dm_v_re[res_ind - 1][b] = 1.0f; + passive_g = activew_quad_thresh; + } +#endif + + +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( passive_g < activew_quad_thresh ) +#else if ( passive_g < IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH ) +#endif { /*linear activeW*/ dm_y = 0; @@ -604,7 +654,13 @@ static void ivas_get_pred_coeffs( float sqrt_val; /* quadratic activeW */ + +#ifdef FIX_SBA_VANISHING_RESIDUAL + num_f = ( dm_beta_re - ( 2 * dm_alpha[b] * activew_quad_thresh ) ); +#else num_f = ( dm_beta_re - ( 2 * dm_alpha[b] * IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH ) ); +#endif + sqrt_val = 4 * dm_alpha[b] * dm_alpha[b] * g_th_sq; sqrt_val += dm_beta_re * dm_beta_re; sqrt_val -= 4 * dm_beta_re * g_th_sq * dm_w; @@ -613,7 +669,11 @@ static void ivas_get_pred_coeffs( den_f = 2 * dm_beta_re * g_th_sq; den_f = max( den_f, 1e-20f ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + dm_g[b] = activew_quad_thresh; +#else dm_g[b] = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH; +#endif DM_F[b] = ( dm_g[b] * num_f ) / den_f; } } @@ -651,7 +711,12 @@ static void ivas_get_Wscaling_factor( const int16_t bands_bw, const int16_t active_w, const int16_t active_w_vlbr, - float *pWscale ) + float *pWscale +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +) { int16_t b, ch; float dm_f_local, abs_val; @@ -670,7 +735,11 @@ static void ivas_get_Wscaling_factor( { pWscale[b] = 1; +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( ( active_w == 1 ) && ( dyn_active_w_flag == 0 ) ) +#else if ( ( active_w == 1 ) && ( pNum_dmx[b * bands_bw] == 1 ) ) +#endif { float Gw_sq, g_sq = 0; @@ -1260,9 +1329,13 @@ void ivas_calc_c_p_coeffs( , const int16_t planarCP #endif +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ) { -#ifndef FIX_280_PLANAR_CP +#ifdef FIX_SBA_VANISHING_RESIDUAL int16_t i, j; #endif float postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -1276,36 +1349,29 @@ void ivas_calc_c_p_coeffs( ivas_calc_c_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, num_ch, num_dmx, band_idx, dtx_vad ); } -#ifndef FIX_280_PLANAR_CP - if ( planarCP ) +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( dyn_active_w_flag ) { for ( i = 0; i < num_ch - num_dmx; i++ ) { - if ( !keep_planar[i] ) + for ( j = 0; j < num_dmx - 1; j++ ) { - for ( j = 0; j < num_dmx - 1; j++ ) - { - pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].C_re[i][j] = 0.0f; - } + pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].C_re[i][j] = 0.0f; } } } #endif - if ( compute_p_flag == 1 ) { ivas_calc_p_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, num_ch, dtx_vad, num_dmx, band_idx ); } -#ifndef FIX_280_PLANAR_CP - if ( planarCP ) +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( dyn_active_w_flag ) { for ( i = num_dmx; i < num_ch; i++ ) { - if ( !keep_planar[i - num_dmx] ) - { - pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].P_re[i - num_dmx] = 0; - } + pSparMd->band_coeffs[band_idx + i_ts * IVAS_MAX_NUM_BANDS].P_re[i - num_dmx] = 0; } } #endif @@ -1560,14 +1626,25 @@ void ivas_compute_spar_params( ivas_spar_md_com_cfg *hSparCfg, ivas_spar_md_t *hSparMd, float *pWscale, - const int16_t from_dirac ) + const int16_t from_dirac +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +) { float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; int16_t b, i, ndm; ivas_get_pred_coeffs( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, active_w_vlbr, - dtx_vad, from_dirac ); + dtx_vad, from_dirac +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag, + hSparMd->res_ind +#endif + ); #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n Prediction Coefficients:\n"); @@ -1601,7 +1678,12 @@ void ivas_compute_spar_params( ivas_get_Wscaling_factor( cov_real, pred_coeffs_re, mixer_mat, start_band, end_band, dtx_vad, num_ch, hSparCfg->num_dmx_chans_per_band, bands_bw, active_w, active_w_vlbr, - pWscale ); + pWscale +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); for ( b = start_band; b < end_band; b++ ) { @@ -1624,9 +1706,19 @@ void ivas_compute_spar_params( if ( ndm != num_ch ) { #ifndef FIX_280_PLANAR_CP - ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, 0 ); + ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, 0 +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); #else - ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1 ); + ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1 +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); #endif #ifdef SPAR_HOA_DBG @@ -1677,7 +1769,12 @@ void ivas_get_spar_md_from_dirac( const int16_t dtx_vad, float Wscale_d[IVAS_MAX_NUM_BANDS], const uint8_t useLowerRes, - const int16_t active_w_vlbr ) + const int16_t active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +) { int16_t num_ch, band, i, j; int16_t block, ch; @@ -1691,6 +1788,10 @@ void ivas_get_spar_md_from_dirac( float **ppMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH]; float *pMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; float en_ratio_fac, diff_norm_order1, diff_norm_order2, diff_norm_order3; +#ifdef FIX_SBA_VANISHING_RESIDUAL + int16_t active_w; +#endif + int16_t ndm, foa_ch, hoa2_ch; float P_dir_fact[IVAS_SPAR_MAX_CH - 1]; const int16_t *remix_order; @@ -1852,7 +1953,6 @@ void ivas_get_spar_md_from_dirac( en_ratio_fac = ( 1.0f - diffuseness[band] ); - for ( i = 0; i < num_ch; i++ ) { for ( j = 0; j < num_ch; j++ ) @@ -1948,8 +2048,23 @@ void ivas_get_spar_md_from_dirac( } #endif +#ifdef FIX_SBA_VANISHING_RESIDUAL + active_w = ( dyn_active_w_flag == 1 ) || ( hSpar_md_cfg->active_w == 1 ); +#endif ivas_compute_spar_params( pCov_real, dm_fv_re, i_ts, ppMixer_mat, start_band, end_band, dtx_vad, - num_ch, 1, hSpar_md_cfg->active_w, active_w_vlbr, hSpar_md_cfg, hSpar_md, Wscale, 1 ); + num_ch, 1, +#ifdef FIX_SBA_VANISHING_RESIDUAL + active_w, +#else + hSpar_md_cfg->active_w, +#endif + active_w_vlbr, + hSpar_md_cfg, hSpar_md, Wscale, 1 +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); if ( mixer_mat != NULL ) { diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 6d2ed4c4e9..38051e76d4 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -221,6 +221,10 @@ typedef struct ivas_spar_md_t int16_t dtx_vad; float en_ratio_slow[IVAS_MAX_NUM_BANDS]; float ref_pow_slow[IVAS_MAX_NUM_BANDS]; +#ifdef FIX_SBA_VANISHING_RESIDUAL + int16_t res_ind; + int16_t prior_dyn_active_w_flag; +#endif } ivas_spar_md_t; typedef struct ivas_spar_md_prev_t diff --git a/lib_com/options.h b/lib_com/options.h index 0e4e064ab7..3198304a63 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -206,6 +206,8 @@ #define FIX_279_CODE_COVERAGE /* Dlb : issue 279 , clean up unused function */ #define FIX_549_PARAM_ISM_BIN_GAIN /* FhG: Issue 549 : fix too quiet binaural output in ParamISM */ +#define FIX_SBA_VANISHING_RESIDUAL /*Dlb : Fix for vanishing residual cases when W channel is 0, TODO: fix DTX*/ + /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 1c839316e5..860dde9c68 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -785,7 +785,14 @@ static void ivas_spar_dec_MD( if ( ivas_total_brate > IVAS_SID_5k2 && !bfi && hSpar->hMdDec->dtx_vad ) { +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( hSpar->hMdDec->spar_md_cfg.nchan_transport == 1 ) + { + hSpar->AGC_flag = get_next_indice( st0, 1 ); + } +#else hSpar->AGC_flag = get_next_indice( st0, 1 ); +#endif ivas_agc_read_bits( hSpar->hAgcDec, st0, hSpar->hMdDec->spar_md_cfg.nchan_transport, hSpar->AGC_flag ); } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index ec363399e4..d011aae47b 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -62,7 +62,12 @@ static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0 * Static functions declaration *------------------------------------------------------------------------------------------*/ -static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr ); +static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, const int16_t active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +); #ifndef FIX_280_PLANAR_CP static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, int16_t *pDo_diff, const int16_t freq_diff, const int16_t planarCP, const int16_t strat, const int32_t ivas_total_brate ); @@ -748,6 +753,9 @@ void ivas_spar_md_dec_process( ivas_spar_md_dec_state_t *hMdDec; int16_t num_md_chs; int16_t num_md_sub_frames; +#ifdef FIX_SBA_VANISHING_RESIDUAL + int16_t dyn_active_w_flag; +#endif int16_t active_w_vlbr; hMdDec = st_ivas->hSpar->hMdDec; @@ -763,6 +771,35 @@ void ivas_spar_md_dec_process( #endif ); + +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( hMdDec->spar_md_cfg.nchan_transport > 1 && hMdDec->spar_md_cfg.nchan_transport <= 3 ) + { + hMdDec->spar_md.res_ind = 0; + dyn_active_w_flag = get_next_indice( st0, 1 ); + if ( dyn_active_w_flag == 1 ) + { + if ( hMdDec->spar_md_cfg.nchan_transport == 2 ) + { + hMdDec->spar_md.res_ind = get_next_indice( st0, 1 ); + hMdDec->spar_md.res_ind += hMdDec->spar_md_cfg.nchan_transport; + } + else if ( hMdDec->spar_md_cfg.nchan_transport == 3 ) + { + hMdDec->spar_md.res_ind = remix_order_set[hMdDec->spar_md_cfg.remix_unmix_order][hMdDec->spar_md_cfg.nchan_transport]; + } + } + } + else + { + dyn_active_w_flag = 0; + if ( hMdDec->spar_md_cfg.nchan_transport == FOA_CHANNELS ) + { + get_next_indice( st0, 1 ); + } + } +#endif + ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, #ifndef FIX_280_PLANAR_CP ivas_spar_br_table_consts[hMdDec->table_idx].usePlanarCoeff, @@ -909,7 +946,12 @@ void ivas_spar_md_dec_process( /* SPAR to DirAC conversion */ if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 ) { - ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw ); + ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); } /* set correct number of bands*/ @@ -1067,7 +1109,15 @@ void ivas_spar_md_dec_process( } } - ivas_get_spar_matrices( hMdDec, num_bands_out, num_md_sub_frames, bw, dtx_vad, nB, num_md_chs, active_w_vlbr ); + ivas_get_spar_matrices( hMdDec, num_bands_out, num_md_sub_frames, bw, dtx_vad, nB, + num_md_chs, + active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + + ); #ifdef DEBUG_SPAR_DIRAC_WRITE_OUT_PRED_PARS { @@ -1319,7 +1369,12 @@ static void ivas_get_spar_matrices( const int16_t dtx_vad, const int16_t nB, const int16_t numch_out, - const int16_t active_w_vlbr ) + const int16_t active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif +) { int16_t num_bands, dmx_ch, split_band; int16_t i, j, k, m, b, i_ts, active_w; @@ -1364,7 +1419,12 @@ static void ivas_get_spar_matrices( { num_bands = num_bands >> 1; } +#ifdef FIX_SBA_VANISHING_RESIDUAL + active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 ); +#else active_w = hMdDec->spar_md_cfg.active_w; +#endif + active_w_dm_fac = ( dtx_vad == 0 ) ? IVAS_ACTIVEW_DM_F_SCALE_DTX : ( ( active_w_vlbr ) ? IVAS_ACTIVEW_DM_F_SCALE_VLBR : IVAS_ACTIVEW_DM_F_SCALE ); for ( i_ts = 0; i_ts < n_ts; i_ts++ ) { @@ -1418,6 +1478,13 @@ static void ivas_get_spar_matrices( IVAS_RMULT_FLOAT( tmp_C2_re[0][3], tmp_C1_re[3][0], re ); tmp_dm_re[0][0] += re; +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( dyn_active_w_flag == 1 ) + { + tmp_dm_re[0][0] *= IVAS_SPAR_DYN_ACTIVEW_THRESH; + } +#endif + tmp_dm_re[0][1] = tmp_C2_re[0][1]; tmp_dm_re[0][2] = tmp_C2_re[0][2]; @@ -2972,6 +3039,12 @@ static void ivas_parse_parameter_bitstream_dtx( sid_bits_len = st0->next_bit_pos - sid_bits_len; zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; assert( zero_pad_bits >= 0 ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( num_dmx_per_band[0] == 2 ) + { + zero_pad_bits -= 1; + } +#endif for ( j = 0; j < zero_pad_bits; j++ ) { get_next_indice( st0, 1 ); @@ -3035,8 +3108,13 @@ void ivas_spar_to_dirac( Decoder_Struct *st_ivas, ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bw /* i : band joining factor */ + const int16_t num_bands_out /* i : number of output bands */ + , + const int16_t bw /* i : band joining factor */ +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ) { DIRAC_DEC_HANDLE hDirAC; @@ -3061,7 +3139,13 @@ void ivas_spar_to_dirac( int16_t enc_param_start_band; int16_t active_w_vlbr; int16_t i, num_subframes; +#ifdef FIX_SBA_VANISHING_RESIDUAL + int16_t active_w; +#endif +#ifdef FIX_SBA_VANISHING_RESIDUAL + active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 ); +#endif sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); start_band = 0; end_band = min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ) / bw; @@ -3109,8 +3193,11 @@ void ivas_spar_to_dirac( if ( st_ivas->nchan_transport == 1 ) { float w_en_norm, f_scale; - +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( active_w ) +#else if ( hMdDec->spar_md_cfg.active_w ) +#endif { if ( dtx_vad == 0 ) { @@ -3240,8 +3327,13 @@ void ivas_spar_to_dirac( /* DirAC MD averaged over 4 subframes and converted to SPAR format similar to encoder processing */ if ( hMdDec->spar_md_cfg.nchan_transport > 1 ) { - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, + st_ivas->hQMetaData->useLowerRes, active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); /* temporarily copy frame-wise prediction coefficients in DirAC bands*/ for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) @@ -3262,7 +3354,12 @@ void ivas_spar_to_dirac( #endif ); ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); + end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); #else num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; @@ -3272,7 +3369,12 @@ void ivas_spar_to_dirac( } ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_subframes, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr ); + end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); #endif if ( st_ivas->hQMetaData->useLowerRes && dtx_vad ) { diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index fcf2efc6c2..1e740a0152 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -107,6 +107,11 @@ ivas_error ivas_spar_covar_enc_open( hCovState->num_bins = (int16_t) ( input_Fs / FRAMES_PER_SEC ); hCovState->prior_dtx_present = 0; +#ifdef FIX_SBA_VANISHING_RESIDUAL + set_zero( hCovState->bb_var_lt, FOA_CHANNELS ); + hCovState->prior_var_flag = -1; +#endif + *hCovEnc = hCovState; return error; @@ -143,6 +148,119 @@ void ivas_spar_covar_enc_close( } +#ifdef FIX_SBA_VANISHING_RESIDUAL +/*-----------------------------------------------------------------------------------------* + * Function ivas_spar_get_activeW_flag() + * + * + *-----------------------------------------------------------------------------------------*/ +int16_t ivas_spar_get_activeW_flag( + ivas_enc_cov_handler_state_t *hCovEnc, + float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], + const int16_t dtx_vad, + const int16_t nchan_inp, + const int16_t nchan_transport, + int16_t *res_ind, + const int16_t *dmx_order ) +{ + int16_t b, ch, num_bands, num_chs, activeW_flag; + float bb_var[FOA_CHANNELS], sm_fact, side_ch_var, en_ratio; + num_chs = min( nchan_inp, FOA_CHANNELS ); + num_bands = ivas_get_num_bands_from_bw_idx( SPAR_CONFIG_BW ); + + set_zero( bb_var, FOA_CHANNELS ); + + if ( dtx_vad == 1 ) + { + for ( ch = 0; ch < num_chs; ch++ ) + { + for ( b = 0; b < num_bands; b++ ) + { + bb_var[ch] += cov_real[ch][ch][b]; + } + } + } + else + { + for ( ch = 0; ch < num_chs; ch++ ) + { + for ( b = 0; b < num_bands; b++ ) + { + bb_var[ch] += cov_dtx_real[ch][ch][b]; + } + } + } + + if ( hCovEnc->prior_var_flag == -1 ) + { + for ( ch = 0; ch < num_chs; ch++ ) + { + hCovEnc->bb_var_lt[ch] = bb_var[ch]; + } + // hCovEnc->prior_var_flag = 0; + } + else + { + sm_fact = 0.5f; + for ( ch = 0; ch < num_chs; ch++ ) + { + hCovEnc->bb_var_lt[ch] = sm_fact * hCovEnc->bb_var_lt[ch] + ( 1 - sm_fact ) * bb_var[ch]; + } + } + + side_ch_var = 0.0f; + for ( ch = nchan_transport; ch < num_chs; ch++ ) + { + side_ch_var += hCovEnc->bb_var_lt[dmx_order[ch]]; + } + + if ( side_ch_var < EPSILON ) + { + activeW_flag = 0; + } + else + { + en_ratio = hCovEnc->bb_var_lt[0] / side_ch_var; + if ( en_ratio < ( IVAS_SPAR_DYN_ACTIVEW_THRESH * IVAS_SPAR_DYN_ACTIVEW_THRESH ) ) + { + activeW_flag = 1; + } + else + { + activeW_flag = 0; + } + } + + if ( activeW_flag ) + { + *res_ind = 0; + if ( nchan_transport == 2 ) + { + int16_t max_idx; + float max_val; + max_idx = nchan_transport; + max_val = hCovEnc->bb_var_lt[max_idx]; + for ( ch = nchan_transport + 1; ch < num_chs; ch++ ) + { + if ( hCovEnc->bb_var_lt[ch] > max_val ) + { + max_idx = ch; + max_val = hCovEnc->bb_var_lt[ch]; + } + } + *res_ind = max_idx; + } + else if ( nchan_transport == 3 ) + { + *res_ind = dmx_order[nchan_transport]; + } + } + + return activeW_flag; +} +#endif + /*-----------------------------------------------------------------------------------------* * Function ivas_enc_cov_handler_process() * @@ -161,7 +279,17 @@ void ivas_enc_cov_handler_process( const int16_t num_ch, const int16_t dtx_vad, const int16_t transient_det[2], - const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ) + const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + int16_t *res_ind, + const int16_t *remix_order, + int16_t *dyn_active_w_flag, + const int16_t nchan_transport, + const int16_t is_sba +#endif + +) { int16_t i, j; int16_t dtx_cov_flag; @@ -177,6 +305,22 @@ void ivas_enc_cov_handler_process( cov_real, HOA_md_ind ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( is_sba ) + { + *res_ind = 0; + if ( nchan_transport > 1 && nchan_transport <= ( FOA_CHANNELS - 1 ) ) + { + *dyn_active_w_flag = ivas_spar_get_activeW_flag( hCovEnc, cov_real, cov_real, dtx_vad, num_ch, nchan_transport, res_ind, + remix_order ); + } + else + { + *dyn_active_w_flag = 0; + } + } +#endif + #ifdef DEBUG_SPAR_WRITE_OUT_COV { static FILE *fid = 0; diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 5c50c3d6bd..8c442a51c6 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -821,7 +821,12 @@ static void ivas_mc_paramupmix_param_est_enc( } } - ivas_enc_cov_handler_process( hMCParamUpmix->hCovEnc[b], pp_in_fr_real, pp_in_fr_imag, cov_real, cov_dtx_real, hMCParamUpmix->hFbMixer->pFb, 0, hMCParamUpmix->hFbMixer->pFb->filterbank_num_bands, MC_PARAMUPMIX_NCH, 0 /*dtx_vad*/, transient_det[b], HOA_md_ind ); + ivas_enc_cov_handler_process( hMCParamUpmix->hCovEnc[b], pp_in_fr_real, pp_in_fr_imag, cov_real, cov_dtx_real, hMCParamUpmix->hFbMixer->pFb, 0, hMCParamUpmix->hFbMixer->pFb->filterbank_num_bands, MC_PARAMUPMIX_NCH, 0 /*dtx_vad*/, transient_det[b], HOA_md_ind +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + NULL, NULL, NULL, 0, 0 +#endif + ); } maxbands = hMCParamUpmix->hFbMixer->pFb->filterbank_num_bands; for ( b = 0; b < MC_PARAMUPMIX_COMBINATIONS; b++ ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b7b5480952..760d406482 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -386,7 +386,13 @@ static ivas_error ivas_spar_cov_md_process( float *ppIn_FR_real[IVAS_SPAR_MAX_CH], float *ppIn_FR_imag[IVAS_SPAR_MAX_CH], const int16_t transient_det[2], - const int16_t dtx_vad ) + const int16_t dtx_vad +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t nchan_transport, + int16_t *dyn_active_w_flag +#endif +) { int16_t i, j, i_ts, b, table_idx; int16_t active_w_vlbr; @@ -443,7 +449,34 @@ static ivas_error ivas_spar_cov_md_process( } } - ivas_enc_cov_handler_process( hSpar->hCovEnc, ppIn_FR_real, ppIn_FR_imag, cov_real, cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind ); + ivas_enc_cov_handler_process( hSpar->hCovEnc, ppIn_FR_real, ppIn_FR_imag, cov_real, cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + &hSpar->hMdEnc->spar_md.res_ind, + remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], + dyn_active_w_flag, nchan_transport, 1 + +#endif + ); + +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( nchan_transport > 1 && nchan_transport <= ( FOA_CHANNELS - 1 ) ) + { + push_next_indice( hMetaData, *dyn_active_w_flag, 1 ); + if ( ( *dyn_active_w_flag == 1 ) && ( nchan_transport == 2 ) ) + { + push_next_indice( hMetaData, hSpar->hMdEnc->spar_md.res_ind - nchan_transport, 1 ); + } + hSpar->front_vad_flag = ( *dyn_active_w_flag == 1 ) ? 1 : hSpar->front_vad_flag; + } + else + { + if ( nchan_transport == FOA_CHANNELS ) + { + push_next_indice( hMetaData, 0, 1 ); + } + } +#endif /*-----------------------------------------------------------------------------------------* * MetaData encoder @@ -451,7 +484,12 @@ static ivas_error ivas_spar_cov_md_process( if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer ); + ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + *dyn_active_w_flag +#endif + ); } if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) @@ -494,12 +532,22 @@ static ivas_error ivas_spar_cov_md_process( Wscale_d[b] = min( 2.0f, max( Wscale_d[b], 1.0f ) ); } - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d, hQMetaData->useLowerRes, active_w_vlbr ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d, hQMetaData->useLowerRes, active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + *dyn_active_w_flag +#endif + ); } if ( hSpar->hMdEnc->spar_hoa_md_flag ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer ); + ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + *dyn_active_w_flag +#endif + ); } return error; @@ -546,6 +594,9 @@ static ivas_error ivas_spar_enc_process( float *ppIn_FR_real[IVAS_SPAR_MAX_CH], *ppIn_FR_imag[IVAS_SPAR_MAX_CH]; float wyzx_del_buf[FOA_CHANNELS][IVAS_FB_1MS_48K_SAMP]; +#ifdef FIX_SBA_VANISHING_RESIDUAL + int16_t dyn_active_w_flag; +#endif int16_t nchan_fb_in; /* ToDo: Commented for now*/ @@ -599,7 +650,11 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { /* fill delay (1 ms) buffer for all Transport channels */ +#ifndef FIX_SBA_VANISHING_RESIDUAL for ( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) +#else + for ( i = 0; i < FOA_CHANNELS; i++ ) +#endif { int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); @@ -666,7 +721,13 @@ static ivas_error ivas_spar_enc_process( * Covariance and MD processing *-----------------------------------------------------------------------------------------*/ - if ( ( error = ivas_spar_cov_md_process( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real, ppIn_FR_imag, transient_det, dtx_vad ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_cov_md_process( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real, ppIn_FR_imag, transient_det, dtx_vad +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + nchan_transport, + &dyn_active_w_flag +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -706,9 +767,35 @@ static ivas_error ivas_spar_enc_process( } } - ivas_enc_cov_handler_process( hSpar->hCovEnc, ppIn_FR_real, ppIn_FR_imag, cov_real, cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind ); + ivas_enc_cov_handler_process( hSpar->hCovEnc, ppIn_FR_real, ppIn_FR_imag, cov_real, cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + &hSpar->hMdEnc->spar_md.res_ind, + remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], + &dyn_active_w_flag, st_ivas->nchan_transport, 1 + +#endif + ); nchan_transport = st_ivas->nchan_transport; +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( nchan_transport > 1 && nchan_transport <= ( FOA_CHANNELS - 1 ) ) + { + push_next_indice( hMetaData, dyn_active_w_flag, 1 ); + if ( ( dyn_active_w_flag == 1 ) && ( nchan_transport == 2 ) ) + { + push_next_indice( hMetaData, hSpar->hMdEnc->spar_md.res_ind - nchan_transport, 1 ); + } + st_ivas->hSpar->front_vad_flag = ( dyn_active_w_flag == 1 ) ? 1 : st_ivas->hSpar->front_vad_flag; + } + else + { + if ( nchan_transport == FOA_CHANNELS ) + { + push_next_indice( hMetaData, 0, 1 ); + } + } +#endif /*-----------------------------------------------------------------------------------------* * MetaData encoder @@ -716,7 +803,13 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer ); + ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, + hSpar->hFbMixer->prior_mixer +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); } if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) @@ -759,12 +852,24 @@ static ivas_error ivas_spar_enc_process( Wscale_d[b] = min( 2.0f, max( Wscale_d[b], 1.0f ) ); } - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d, hQMetaData->useLowerRes, active_w_vlbr ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d, + hQMetaData->useLowerRes, active_w_vlbr +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); } if ( hSpar->hMdEnc->spar_hoa_md_flag ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer ); + ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, + hSpar->hFbMixer->prior_mixer +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); } #endif @@ -883,9 +988,44 @@ static ivas_error ivas_spar_enc_process( #endif if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { - /* delayed W */ - mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); - mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + +#ifdef FIX_SBA_VANISHING_RESIDUAL + /*cross fade between new active W channels and old passive W channel*/ + if ( dyn_active_w_flag == 1 ) + { + if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag != dyn_active_w_flag ) + { + float new_w[L_FRAME48k]; + + /* delayed W */ + mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); + mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + + mvr2r( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], new_w, num_del_samples ); + mvr2r( data_f[hSpar->hMdEnc->spar_md.res_ind], &new_w[num_del_samples], input_frame - num_del_samples ); + + if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag == 0 && dyn_active_w_flag == 1 ) + { + ivas_fb_mixer_cross_fading( hSpar->hFbMixer, p_pcm_tmp, p_pcm_tmp[0], new_w, 0, input_frame, 0 ); + } + else if ( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag == 1 && dyn_active_w_flag == 0 ) + { + ivas_fb_mixer_cross_fading( hSpar->hFbMixer, p_pcm_tmp, new_w, p_pcm_tmp[0], 0, input_frame, 0 ); + } + } + else + { + mvr2r( wyzx_del_buf[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp[0], num_del_samples ); + mvr2r( data_f[hSpar->hMdEnc->spar_md.res_ind], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + } + } + else +#endif + { + /* delayed W */ + mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); + mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); + } for ( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) { @@ -952,6 +1092,7 @@ static ivas_error ivas_spar_enc_process( { ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig ); } +#ifndef FIX_SBA_VANISHING_RESIDUAL else { /* IVAS_fmToDo: This AGC on/off bit should be removed when the command line option to force enable/disable AGC is @@ -960,6 +1101,7 @@ static ivas_error ivas_spar_enc_process( * ivas_agc_enc_get_flag function should be moved to ivas_agc_com.c and renamed when this occurs. */ push_next_indice( hMetaData, 0, 1 ); } +#endif } #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after ivas_agc_enc_process */ @@ -1010,13 +1152,26 @@ static ivas_error ivas_spar_enc_process( for ( j = 0; j < nchan_transport; j++ ) { - mvr2r( p_pcm_tmp[j], data_f[order[j]], input_frame ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( st_ivas->nchan_transport < 3 ) + { + mvr2r( p_pcm_tmp[j], data_f[j], input_frame ); + } + else +#endif + { + mvr2r( p_pcm_tmp[j], data_f[order[j]], input_frame ); + } } for ( ; j < IVAS_SPAR_MAX_DMX_CHS; j++ ) { set_f( data_f[order[j]], 0.0f, input_frame ); } +#ifdef FIX_SBA_VANISHING_RESIDUAL + hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag = dyn_active_w_flag; +#endif + pop_wmops(); /* ToDo: Commented for now */ diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 757f772b13..e8b179e019 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -332,6 +332,10 @@ ivas_error ivas_spar_md_enc_init( ivas_sba_get_spar_hoa_ch_ind( num_channels, hEncoderConfig->ivas_total_brate, hMdEnc->HOA_md_ind ); table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + hMdEnc->spar_md.prior_dyn_active_w_flag = 0; +#endif + ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND, hMdEnc->spar_hoa_dirac2spar_md_flag, 1, hEncoderConfig->Opt_PCA_ON, #ifndef DEBUG_AGC_ENCODER_CMD_OPTION @@ -567,6 +571,10 @@ ivas_error ivas_spar_md_enc_process( const int16_t nchan_inp, const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i : prior mixer_matrix */ +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + const int16_t dyn_active_w_flag +#endif ) { float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; @@ -597,7 +605,11 @@ ivas_error ivas_spar_md_enc_process( num_quant_strats = hMdEnc->spar_md_cfg.num_quant_strats; num_ch = ivas_sba_get_nchan_metadata( sba_order, hEncoderConfig->ivas_total_brate ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + active_w = ( hMdEnc->spar_md_cfg.active_w == 1 ) || ( dyn_active_w_flag == 1 ); +#else active_w = hMdEnc->spar_md_cfg.active_w; +#endif nchan_transport = hMdEnc->spar_md_cfg.nchan_transport; bwidth = ivas_get_bw_idx_from_sample_rate( hEncoderConfig->input_Fs ); @@ -688,7 +700,12 @@ ivas_error ivas_spar_md_enc_process( ivas_compute_spar_params( cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, num_ch, bands_bw, active_w, active_w_vlbr, - &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0 ); + &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0 +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); for ( i = 0; i < num_ch; i++ ) { @@ -740,7 +757,12 @@ ivas_error ivas_spar_md_enc_process( if ( ndm != num_ch ) { - ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag +#endif + ); } } } @@ -889,6 +911,10 @@ ivas_error ivas_spar_md_enc_process( #ifndef FIX_280_PLANAR_CP , planarCP +#endif +#ifdef FIX_SBA_VANISHING_RESIDUAL + , + dyn_active_w_flag #endif ); #ifdef SPAR_HOA_DBG @@ -2084,6 +2110,12 @@ static void ivas_write_parameter_bitstream_dtx( sid_bits_len = hMetaData->nb_bits_tot - sid_bits_len; zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; assert( zero_pad_bits >= 0 ); +#ifdef FIX_SBA_VANISHING_RESIDUAL + if ( num_dmx[0] == 2 ) + { + zero_pad_bits -= 1; + } +#endif while ( zero_pad_bits > 0 ) { j = min( zero_pad_bits, 16 ); diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 59abb33a0a..8fc7630249 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -649,7 +649,10 @@ typedef struct ivas_enc_cov_handler_state_t ivas_cov_smooth_state_t *pCov_dtx_state; int16_t num_bins; int16_t prior_dtx_present; - +#ifdef FIX_SBA_VANISHING_RESIDUAL + float bb_var_lt[FOA_CHANNELS]; + int16_t prior_var_flag; +#endif } ivas_enc_cov_handler_state_t; -- GitLab From b462f6e397c1913139d5d39d6a2fcaaea35adc16 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 1 Aug 2023 15:41:47 +1000 Subject: [PATCH 2/5] instrumentation build fix --- lib_com/ivas_spar_com.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 7c9ef6bfbf..fa462313d6 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -535,7 +535,7 @@ static void ivas_get_pred_coeffs( float dm_f_local, dm_w, dm_y, DM_F[IVAS_MAX_NUM_BANDS]; float num_f, den_f, passive_g; #ifdef FIX_SBA_VANISHING_RESIDUAL - float activew_quad_thresh; + float activew_quad_thresh, g_th_sq; if ( dyn_active_w_flag == 1 ) { activew_quad_thresh = 1.0f; @@ -544,7 +544,7 @@ static void ivas_get_pred_coeffs( { activew_quad_thresh = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH; } - float g_th_sq = activew_quad_thresh * activew_quad_thresh; + g_th_sq = activew_quad_thresh * activew_quad_thresh; #else float g_th_sq = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH * IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH; #endif -- GitLab From 0b76405cf11aead719fb63221115fdcb52428341 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 1 Aug 2023 22:10:02 +1000 Subject: [PATCH 3/5] MSAN fix --- lib_dec/ivas_spar_decoder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 860dde9c68..ccf4ec1c53 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -178,7 +178,9 @@ ivas_error ivas_spar_dec_open( } } hSpar->i_subframe = 0; - +#ifdef FIX_SBA_VANISHING_RESIDUAL + hSpar->AGC_flag = 0; +#endif /*-----------------------------------------------------------------* * Configuration - set SPAR high-level parameters *-----------------------------------------------------------------*/ -- GitLab From bbecfcafe6e2449a14e6ff4eb3d3d9cf17b42e36 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 3 Aug 2023 23:29:05 +1000 Subject: [PATCH 4/5] update selection pytest script to not compare bitstream --- tests/codec_be_on_mr_selection/__init__.py | 6 ++++-- tests/codec_be_on_mr_selection/test_experiments.py | 6 ++++++ tests/conftest.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/codec_be_on_mr_selection/__init__.py b/tests/codec_be_on_mr_selection/__init__.py index da1d8c3578..14f0bb0b17 100644 --- a/tests/codec_be_on_mr_selection/__init__.py +++ b/tests/codec_be_on_mr_selection/__init__.py @@ -127,6 +127,7 @@ def run_check( is_ref_creation, input_file_num=None, keep_files=True, + compare_bitstream=False, ): sampling_rate = 48 output_mode, options = OUTPUT_MODES_AND_OPTIONS_FOR_EXPERIMENT[experiment] @@ -162,8 +163,9 @@ def run_check( ) if not is_ref_creation: - if not is_be_to_ref(dut_bitstream): - pytest.fail(f"Bitstream file differs from reference") + if compare_bitstream: + if not is_be_to_ref(dut_bitstream): + pytest.fail(f"Bitstream file differs from reference") dut_bitstream_to_decoder = dut_bitstream if error_pattern is not None: diff --git a/tests/codec_be_on_mr_selection/test_experiments.py b/tests/codec_be_on_mr_selection/test_experiments.py index 5b2f516893..53fdd8eba9 100644 --- a/tests/codec_be_on_mr_selection/test_experiments.py +++ b/tests/codec_be_on_mr_selection/test_experiments.py @@ -53,6 +53,7 @@ def test_p800( dut_decoder_frontend, update_ref, keep_files, + compare_bitstream, ): run_check( experiment, @@ -65,6 +66,7 @@ def test_p800( dut_decoder_frontend, update_ref == 1, keep_files=keep_files, + compare_bitstream=compare_bitstream, ) @@ -82,6 +84,7 @@ def test_bs1534_no_masa( dut_decoder_frontend, update_ref, keep_files, + compare_bitstream, ): category = "" run_check( @@ -96,6 +99,7 @@ def test_bs1534_no_masa( update_ref == 1, input_file_num=input_file_num, keep_files=keep_files, + compare_bitstream=compare_bitstream, ) @@ -116,6 +120,7 @@ def test_bs1534_masa( dut_decoder_frontend, update_ref, keep_files, + compare_bitstream, ): run_check( experiment, @@ -129,4 +134,5 @@ def test_bs1534_masa( update_ref == 1, input_file_num=input_file_num, keep_files=keep_files, + compare_bitstream=compare_bitstream, ) diff --git a/tests/conftest.py b/tests/conftest.py index e4de453b0e..ac1b37121a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -132,6 +132,14 @@ def pytest_addoption(parser): help="By default, the DUT output files of successful tests are deleted." " Use --keep_files to prevent these deletions.", ) + + parser.addoption( + "--compare_bitstream", + action="store_true", + help="By default, the IVAS encoded bitstream is not compared with ref." + " Use --compare_bitstream to compare IVAS encoded bitstream.", + ) + parser.addoption( "--selection_be_md5_file", @@ -158,6 +166,12 @@ def keep_files(request) -> bool: """ return request.config.option.keep_files +@pytest.fixture(scope="session") +def compare_bitstream(request) -> bool: + """ + Return indication to compare IVAS encoded bitstream. + """ + return request.config.option.compare_bitstream @pytest.fixture(scope="session") def dut_encoder_path(request) -> str: -- GitLab From fc57a62c3df16ed83a6cdd77aa49b2cdef529ea8 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 7 Aug 2023 11:55:15 +1000 Subject: [PATCH 5/5] fix selection BE by increasing side ch energy thresh --- lib_com/ivas_cnst.h | 1 + lib_enc/ivas_enc_cov_handler.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 757028b7ce..894e35190d 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1058,6 +1058,7 @@ typedef enum #ifdef FIX_SBA_VANISHING_RESIDUAL #define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) +#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #endif #define MAX_QUANT_STRATS 3 diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 1e740a0152..5b9ab2801c 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -215,7 +215,7 @@ int16_t ivas_spar_get_activeW_flag( side_ch_var += hCovEnc->bb_var_lt[dmx_order[ch]]; } - if ( side_ch_var < EPSILON ) + if ( side_ch_var < ( IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH * IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH ) ) { activeW_flag = 0; } -- GitLab