From 0b76a8c22fc6bc4b1fa63be5992f052d5313b8df Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 16 Jan 2024 19:37:35 +0530 Subject: [PATCH] Windows crash issue [x] Fixed variable q factor and mean calculation issue. With this change, crash observed in windows is resolved. --- lib_com/ivas_prot_fx.h | 3 ++- lib_com/ivas_sns_com_fx.c | 7 ++++--- lib_dec/tonalMDCTconcealment.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 97c0a37dc..5ad13d3a4 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -163,7 +163,8 @@ void sns_compute_scf_fx( Word32 spectrum[], const PsychoacousticParameters *pPsychParams, const Word16 L_frame, - Word32 *scf ); + Word32 *scf, + Word16 q); void sns_interpolate_scalefactors_fx( Word32 *scf_int, /* o : interpolated scalefactors for spectrum shaping */ diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index a059cc6f7..57c621abc 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -54,7 +54,8 @@ void sns_compute_scf_fx( Word32 spectrum[], const PsychoacousticParameters *pPsychParams, const Word16 L_frame, - Word32 *scf ) + Word32 *scf, + Word16 q) { Word16 i, n, k; Word32 x[FDNS_NPTS], xs[FDNS_NPTS], mean, xl4[SNS_NPTS], nf, xl[FDNS_NPTS]; @@ -163,7 +164,7 @@ void sns_compute_scf_fx( { Word16 e_tmp = norm_l( xs[i] ); Word16 f_tmp = Log2_norm_lc( L_shl( xs[i], e_tmp ) ); - e_tmp = sub( sub( 30, e_tmp ), 12 ); + e_tmp = sub( sub( 30, e_tmp ), q ); /* Note: Mpy_32_16 is used temporarily for this computation, It needs to be replaced with appropriate BASOP. */ xl[i] = Mpy_32_16( e_tmp, f_tmp, 16384 ); /* Q16 */ } @@ -204,7 +205,7 @@ void sns_compute_scf_fx( /* Remove mean and scaling */ sum = 0; for (Word16 ind = 0; ind < SNS_NPTS; ind++) { - sum += (Word64)xl4[i]; + sum += (Word64)xl4[ind]; } mean = (Word32)(sum >> 4); diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 51c1afd4e..649fae812 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1221,7 +1221,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas( if(abs((Word32)whitenend_noise_shape[k])!=0) q = s_min(q, norm_l( whitenend_noise_shape[k] )); } - q -= find_guarded_bits_fx(L_frame) + 2; + q -= find_guarded_bits_fx(L_frame) - 2; //q -= 1; FOR( Word16 k = 0; k < L_FRAME16k; k++ ) @@ -1229,7 +1229,7 @@ void TonalMdctConceal_whiten_noise_shape_ivas( whitenend_noise_shape_fx[k] = q>=0 ? ((Word32) ( whitenend_noise_shape[k] *(1<< q) )):((Word32) ( whitenend_noise_shape[k] / (1<< q) )); } - sns_compute_scf_fx( whitenend_noise_shape_fx, psychParams, L_frame, scf_fx ); + sns_compute_scf_fx( whitenend_noise_shape_fx, psychParams, L_frame, scf_fx, q ); sns_interpolate_scalefactors_fx( scfs_int_fx, scf_fx, ENC ); sns_interpolate_scalefactors_fx( scfs_bg_fx, scf_fx, DEC ); -- GitLab