Loading lib_com/ivas_cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -1063,6 +1063,11 @@ 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) #define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #endif #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 #define IVAS_NUM_PROB_MODELS 4 Loading lib_com/ivas_fb_mixer.c +38 −9 Original line number Diff line number Diff line Loading @@ -590,14 +590,22 @@ void ivas_fb_mixer_get_windowed_fr( * * FB Mixer cross fading *-----------------------------------------------------------------------------------------*/ static void ivas_fb_mixer_cross_fading( #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 ) 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; Loading @@ -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 Loading @@ -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 } } Loading Loading @@ -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; Loading lib_com/ivas_prot.h +55 −2 Original line number Diff line number Diff line Loading @@ -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 */ ); Loading Loading @@ -4390,8 +4402,13 @@ 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 /* i : flag to indicate dynamic active W*/ #endif #ifdef FIX_527_SBA_MONO_INPUT ,const int16_t dirac_mono_flag , const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA*/ #endif ); Loading @@ -4411,6 +4428,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( Loading Loading @@ -4438,6 +4459,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( Loading @@ -4456,6 +4481,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 */ Loading Loading @@ -4526,6 +4555,10 @@ void ivas_spar_to_dirac( 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 */ #ifdef FIX_SBA_VANISHING_RESIDUAL , const int16_t dyn_active_w_flag /* i : dynamic active W flag */ #endif ); void ivas_spar_update_md_hist( Loading Loading @@ -4585,6 +4618,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( Loading Loading @@ -5935,6 +5976,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 */ Loading lib_com/ivas_spar_com.c +142 −27 Original line number Diff line number Diff line Loading @@ -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] ); Loading Loading @@ -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; Loading Loading @@ -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, g_th_sq; if ( dyn_active_w_flag == 1 ) { activew_quad_thresh = 1.0f; } else { activew_quad_thresh = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_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 set_zero( dm_alpha, IVAS_MAX_NUM_BANDS ); Loading Loading @@ -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; Loading @@ -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; Loading @@ -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; } } Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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]; Loading @@ -1276,12 +1349,10 @@ 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++ ) { Loading @@ -1289,25 +1360,20 @@ void ivas_calc_c_p_coeffs( } } } } #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; } } } #endif } Loading Loading @@ -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"); Loading Loading @@ -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++ ) { Loading @@ -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 Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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++ ) Loading Loading @@ -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 ) { Loading lib_com/ivas_stat_com.h +4 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,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 Loading Loading
lib_com/ivas_cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -1063,6 +1063,11 @@ 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) #define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #endif #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 #define IVAS_NUM_PROB_MODELS 4 Loading
lib_com/ivas_fb_mixer.c +38 −9 Original line number Diff line number Diff line Loading @@ -590,14 +590,22 @@ void ivas_fb_mixer_get_windowed_fr( * * FB Mixer cross fading *-----------------------------------------------------------------------------------------*/ static void ivas_fb_mixer_cross_fading( #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 ) 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; Loading @@ -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 Loading @@ -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 } } Loading Loading @@ -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; Loading
lib_com/ivas_prot.h +55 −2 Original line number Diff line number Diff line Loading @@ -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 */ ); Loading Loading @@ -4390,8 +4402,13 @@ 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 /* i : flag to indicate dynamic active W*/ #endif #ifdef FIX_527_SBA_MONO_INPUT ,const int16_t dirac_mono_flag , const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA*/ #endif ); Loading @@ -4411,6 +4428,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( Loading Loading @@ -4438,6 +4459,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( Loading @@ -4456,6 +4481,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 */ Loading Loading @@ -4526,6 +4555,10 @@ void ivas_spar_to_dirac( 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 */ #ifdef FIX_SBA_VANISHING_RESIDUAL , const int16_t dyn_active_w_flag /* i : dynamic active W flag */ #endif ); void ivas_spar_update_md_hist( Loading Loading @@ -4585,6 +4618,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( Loading Loading @@ -5935,6 +5976,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 */ Loading
lib_com/ivas_spar_com.c +142 −27 Original line number Diff line number Diff line Loading @@ -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] ); Loading Loading @@ -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; Loading Loading @@ -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, g_th_sq; if ( dyn_active_w_flag == 1 ) { activew_quad_thresh = 1.0f; } else { activew_quad_thresh = IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_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 set_zero( dm_alpha, IVAS_MAX_NUM_BANDS ); Loading Loading @@ -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; Loading @@ -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; Loading @@ -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; } } Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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]; Loading @@ -1276,12 +1349,10 @@ 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++ ) { Loading @@ -1289,25 +1360,20 @@ void ivas_calc_c_p_coeffs( } } } } #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; } } } #endif } Loading Loading @@ -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"); Loading Loading @@ -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++ ) { Loading @@ -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 Loading Loading @@ -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; Loading @@ -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; Loading Loading @@ -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++ ) Loading Loading @@ -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 ) { Loading
lib_com/ivas_stat_com.h +4 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,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 Loading