From 0e1ff48ee48f5d60918aa6f0d99489f8fa90fe8a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 19:09:04 +0530 Subject: [PATCH 1/2] Crash fixes for LTV encoder, ASAN/MSAN fixes --- lib_com/stat_com.h | 3 +- lib_com/tns_base.c | 2 + lib_enc/cod_tcx.c | 127 ++++++++++++++++++++++++---- lib_enc/ext_sig_ana_fx.c | 4 + lib_enc/igf_enc.c | 13 ++- lib_enc/ivas_core_pre_proc_front.c | 8 +- lib_enc/ivas_mct_core_enc.c | 4 + lib_enc/ivas_mct_enc_mct.c | 8 ++ lib_enc/ivas_stereo_mdct_core_enc.c | 9 +- lib_enc/prot_fx_enc.h | 10 ++- lib_enc/tcx_utils_enc_fx.c | 9 +- lib_enc/tns_base_enc_fx.c | 6 +- 12 files changed, 171 insertions(+), 32 deletions(-) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index af097da84..9edc28c03 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -197,7 +197,8 @@ typedef struct TNS_filter_structure Word16 order; /* Filter order. */ Word16 coefIndex[TNS_MAX_FILTER_ORDER]; /* Quantized filter coefficients. */ Word16 predictionGain; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q7 */ - Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. E(PRED_GAIN_E), Q23 */ + Word32 predictionGain32; /* Prediction gain. The ratio of a signal and TNS residual energy. predictionGain_e */ + Word16 predictionGain_e; /*Exponent for predictionGain32 */ Word16 avgSqrCoef; /* Average squared filter coefficient. E(0), Q15 */ } STnsFilter; diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index b5fd1f41f..515746bd5 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1204,6 +1204,8 @@ void ResetTnsData( STnsData *pTnsData ) move16(); pTnsFilter->predictionGain32 = ONE_IN_Q23; /*Q23*/ move32(); + pTnsFilter->predictionGain_e = PRED_GAIN_E; + move16(); pTnsFilter->avgSqrCoef = 0; move16(); pTnsFilter->filterType = TNS_FILTER_OFF; /*Q0*/ diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index d0d36b502..78fe246e3 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -74,8 +74,11 @@ void TNSAnalysisStereo_fx( TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move32(); + Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + move16(); + Word16 sum_e = 0; move16(); - individual_decision[0] = 0; move16(); individual_decision[1] = 0; @@ -210,7 +213,9 @@ void TNSAnalysisStereo_fx( test(); IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; + Word32 maxPredGain_fx = -ONE_IN_Q31; + move32(); + Word16 maxPredGain_e = 0; move16(); sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; @@ -228,30 +233,74 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 - maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 - + meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = meanPredictionGain_fx; + maxPredictionGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } + Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); + if ( flag_1 < 0 ) + { + flag_1 = 0; + move16(); + } test(); test(); test(); - IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && + flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move32(); + move32(); + pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ + move16(); + move16(); + pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ move16(); move16(); } + flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + IF( flag && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredGain_fx = meanPredictionGain_fx; + maxPredGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -454,10 +503,16 @@ void TNSAnalysisStereo_fx( move16(); } } + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -477,7 +532,15 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } @@ -515,7 +578,9 @@ void TNSAnalysisStereo_fx( IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 + move32(); + Word16 maxPredGain_e = 0; move16(); sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; @@ -526,9 +591,23 @@ void TNSAnalysisStereo_fx( pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); + IF ( flag < 0 ) + { + maxPredGain_fx = pFilter->predictionGain32; + move32(); + maxPredGain_e = pFilter->predictionGain_e; + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -600,9 +679,15 @@ void TNSAnalysisStereo_fx( sts[ch]->hTcxEnc->fUseTns[k] = 0; } move16(); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -617,7 +702,15 @@ void TNSAnalysisStereo_fx( move16(); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index fc4a1889a..c437be5be 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1372,7 +1372,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( st->igf ) { Word16 q_spectrum = sub( Q31, hTcxEnc->spectrum_e[frameno] ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); +#else + ProcessIGF_ivas_fx( st, N_MAX + L_MDCT_OVLP_MAX, hTcxEnc->spectrum_fx[frameno], hTcxEnc->spectrum_fx[frameno], &q_spectrum, powerSpec, powerSpec_e, transform_type[frameno] == TCX_20, frameno, 0, vad_hover_flag ); +#endif } } } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 2c9f5a371..6ac6e6811 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -2577,7 +2577,10 @@ Word16 IGFEncWriteConcatenatedBitstream( *-------------------------------------------------------------------*/ void IGFEncApplyMono_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ +#endif const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ @@ -2658,12 +2661,20 @@ void IGFEncApplyMono_ivas_fx( IF( pPowerSpectrumParameter_fx ) { +#ifndef MSAN_FIX FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) +#else + FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) +#endif { common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] ); } +#ifndef MSAN_FIX FOR( Word16 i = 0; i < N_MAX + L_MDCT_OVLP_MAX; i++ ) +#else + FOR( Word16 i = 0; i < powerSpectrum_len; i++ ) +#endif { common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[i], sub( pPowerSpectrumParameter_exp[i], common_pPowerSpectrum_exp ) ); move16(); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index e866dd146..b7a10a4f3 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -630,12 +630,6 @@ ivas_error pre_proc_front_ivas_fx( headroom = 2; move16(); - test(); - test(); - if ( ( st->bwidth == NB || st->max_bwidth == NB ) && GT_32( st->input_Fs, 8000 ) ) - { - headroom = add( headroom, 1 ); - } test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -731,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx( shift = sub( norm_s( inp_max ), headroom ); Word16 Q_min; - shift = s_max( shift, 0 ); + shift = s_max( shift, -1 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); *Q_new = s_min( shift, Q_min ); diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 7a5a83155..d11447c03 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -656,7 +656,11 @@ void ivas_mct_core_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hIGFEnc->spec_be_igf_e = sub( 31, q_origSpec ); st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index ae561c0d0..7e8547841 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -1118,7 +1118,11 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); @@ -1159,7 +1163,11 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#else + ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); +#endif st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); move16(); diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index e85c01db2..b43c8dfdb 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -676,8 +676,11 @@ void stereo_mdct_core_enc_fx( q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ - +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#else + ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#endif } } } @@ -718,7 +721,11 @@ void stereo_mdct_core_enc_fx( Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ +#ifndef MSAN_FIX ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#else + ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); +#endif } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 58da977a7..4d8b74380 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1250,7 +1250,10 @@ void AVQ_cod_lpc_fx( ); void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ +#endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -3092,7 +3095,10 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */ ); -void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ +void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ +#endif const int16_t igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ Word16 e_mdct, /* i : exponent of pMDCTspectrum */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 27c8e6f5f..5e7ca7be8 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3783,7 +3783,10 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) * *---------------------------------------------------------------------*/ void ProcessIGF_ivas_fx( - Encoder_State *st, /* i : Encoder state */ + Encoder_State *st, /* i : Encoder state */ +#ifdef MSAN_FIX + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ +#endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum (*q_spectrum) */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ Word16 *q_spectrum, /* i/o: Q of spectrum */ @@ -3830,7 +3833,11 @@ void ProcessIGF_ivas_fx( IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, *q_spectrum ) ); +#ifndef MSAN_FIX IGFEncApplyMono_ivas_fx( st, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); +#else + IGFEncApplyMono_ivas_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag ); +#endif curr_order = 0; move16(); diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 452842e30..f1881a427 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -862,9 +862,11 @@ static void GetFilterParameters_ivas( Word32 rxx[], Word16 maxOrder, STnsFilter Word16 temp_e = 0; move16(); Word16 temp = BASOP_Util_Divide3232_Scale( rxx_0, L_tmp, &temp_e ); - pTnsFilter->predictionGain32 = L_shl( temp, ( sub( add( 16, temp_e ), PRED_GAIN_E ) ) ); // Q23 + pTnsFilter->predictionGain32 = L_deposit_h( temp ); move32(); - pTnsFilter->predictionGain = extract_h( pTnsFilter->predictionGain32 ); // Q7 + pTnsFilter->predictionGain_e = temp_e; + move16(); + pTnsFilter->predictionGain = shl_sat( temp, sub( temp_e, PRED_GAIN_E ) ); // Q7 move16(); BASOP_SATURATE_WARNING_ON_EVS /* non-linear quantization of TNS lattice coefficients with given resolution */ -- GitLab From 584e1f745784ba714a23de577eee39e0a7edf542 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 19:16:30 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_enc/cod_tcx.c | 2 +- lib_enc/prot_fx_enc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 78fe246e3..88e028c86 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -593,7 +593,7 @@ void TNSAnalysisStereo_fx( // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF ( flag < 0 ) + IF( flag < 0 ) { maxPredGain_fx = pFilter->predictionGain32; move32(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4d8b74380..2e151df8f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1252,7 +1252,7 @@ void AVQ_cod_lpc_fx( void ProcessIGF_ivas_fx( Encoder_State *st, /* i : Encoder state */ #ifdef MSAN_FIX - Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ + Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ #endif Word32 *pMDCTSpectrum, /* i : MDCT spectrum */ const Word32 *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ -- GitLab