From 3370be1db9ca61b5b9f30bf2c9c3b87c2bc4fe07 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 24 May 2024 11:44:42 +0530 Subject: [PATCH] Fixed LTV crash for [stereo at 48 kbps, 16 kHz in, 16 kHz out, DTX on, JBM Prof 5] --- lib_dec/er_dec_tcx_fx.c | 4 +- lib_dec/fd_cng_dec.c | 8 +++ lib_dec/fd_cng_dec_fx.c | 10 ++-- lib_dec/ivas_jbm_dec.c | 57 ++++++++++++++++++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 10 ++++ 5 files changed, 82 insertions(+), 7 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 4a0208b9d..0e42d360e 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1949,13 +1949,13 @@ void con_tcx_ivas_fx( { Word16 lsp_local[M], lsp_fade[M], alpha_inv; - alpha_inv = 16384 - alpha_delayed; + alpha_inv = sub(16384, alpha_delayed); E_LPC_a_lsp_conversion(A_local, lsp_local, lsp_local, M); FOR (i = 0; i < M; i++) { - lsp_fade[i] = alpha_delayed * lsp_local[i] + alpha_inv * st->lspold_cng[i]; + lsp_fade[i] = add(mult_r(alpha_delayed, lsp_local[i]), mult_r(alpha_inv, st->lspold_cng[i])); } E_LPC_f_lsp_a_conversion(lsp_fade, A_local, M); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index ba1d1f4b1..11b68e171 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -2022,6 +2022,14 @@ void generate_masking_noise_ivas_fx( Word32 scale_fx = 0x40000000; // 1.0 in Q30 move32(); + Word16 shift = getScaleFactor32(hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + hFdCngCom->cngNoiseLevelExp = sub(hFdCngCom->cngNoiseLevelExp, shift); + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ *exp_out = Q15; move16(); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 290e0f5be..4aa367379 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1207,7 +1207,6 @@ Word16 ApplyFdCng_ivas_fx( Flag Overflow = 0; Flag Carry = 0; #endif - Word64 W_tmp; Word16 L_frame, last_L_frame; //Word32 *sidNoiseEst; @@ -1556,13 +1555,14 @@ Word16 ApplyFdCng_ivas_fx( } /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ - W_tmp = 0; + L_tmp = 0; + move32(); FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ ) { - W_tmp = W_add( W_tmp, L_shr( cngNoiseLevel[j], sub( 31, *cngNoiseLevel_exp ) ) ); + L_tmp = L_add_sat( L_tmp, L_shl_sat(cngNoiseLevel[j], 31 - *cngNoiseLevel_exp) ); } - L_tmp = W_extract_h( W_shl( W_tmp, 32 ) ); - L_tmp_exp = 31; + L_tmp_exp = 0; + move16(); #ifdef BASOP_NOGLOB IF(L_shl_o(L_tmp, L_tmp_exp, &Overflow) > 21474836 /*0.01f Q31*/) #else diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6460c0c5d..4ed5d0f63 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -223,6 +223,13 @@ ivas_error ivas_jbm_dec_tc_fx( { IF( st_ivas->hSCE[ch] != NULL ) { + Word16 shift = getScaleFactor32(st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); Q_cngNoiseLevel[ch] = sub(31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp); } } @@ -2271,6 +2278,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( { nchan_transport = 1; /* Only one channel transported */ } + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } #endif ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -2413,6 +2430,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_transport = 1; /* Only one channel transported */ } #endif + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -2529,6 +2556,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_transport = 1; /* Only one channel transported */ } #endif + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -2644,6 +2681,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_transport = 1; /* Only one channel transported */ } #endif + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -2876,6 +2923,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_transport = 1; /* Only one channel transported */ } #endif + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 15a45f4a7..0b9a5447d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1166,6 +1166,16 @@ static void ivas_dirac_dec_binaural_internal( IF( abs_s( (Word16) st_ivas->cldfbAnaDec[1]->scale_flt ) != 0 ) st_ivas->cldfbAnaDec[1]->q_scale = norm_s( (Word16) st_ivas->cldfbAnaDec[1]->scale_flt ); st_ivas->cldfbAnaDec[1]->scale = (Word16) ( st_ivas->cldfbAnaDec[1]->scale_flt * ( 1 << st_ivas->cldfbAnaDec[1]->q_scale ) ); + IF(st_ivas->hSCE[0]) + { + Word16 shift = getScaleFactor32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN); + IF(LT_16(sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift), 4)) + { + shift = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4); + } + scale_sig32(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift); + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub(st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift); + } Word16 q_cldfb[6][CLDFB_SLOTS_PER_SUBFRAME] = { 0 }; FOR( Word16 ind = 0; ind < 6; ind++ ) { -- GitLab