diff --git a/lib_com/options.h b/lib_com/options.h index f658242a46c44fb3c5e31bd4356b81539a2b5981..2361ee2184c9e80c2abf8ca7f10589281bb5fe3c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,7 +75,7 @@ #define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ #define NON_BE_FIX_807_MASA_DTX_BRSW /* Nokia: adds fix to check existence of DTX encoder for secondary channel in TD mode */ #define FIX_BASOP_812_NAN_COHSNR /* FhG: BASOP issue 812: fix nan values in sparse frames for cohSNR value in ITD estimation*/ - +#define FIX_828_PORT_1152_FROM_FLT_REPO /* FhG: fix for issue 828 - fix uninitialized value used in BASOP */ /* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index b2828ae9f6a1cb101cdb029f74ce394cd2427603..5e97ae8e69ff315024137c0928300e9ee7b72006 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -537,8 +537,8 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( hTonalMDCTConc->lastBlockData.spectralData_exp = sub( mdctSpectrum_exp, s ); move16(); - move16(); hTonalMDCTConc->lastBlockData.gain_tcx_exp = gain_tcx_exp; + move16(); Copy( scaleFactors, hTonalMDCTConc->lastBlockData.scaleFactors, hTonalMDCTConc->nScaleFactors ); } @@ -1463,6 +1463,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { Word32 num, den; Word16 exp_num, exp_den; + Word32 max_concealment_value; exp_num = cngLevelBackgroundTrace_bfi_e; move16(); @@ -1489,29 +1490,34 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp = L_deposit_h( 0 ); exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, add( concealment_noise_e, exp ) ); - - IF( GT_16( exp, 0 ) ) + (void) maximum_abs_32_fx( concealment_noise, crossOverFreq, &max_concealment_value ); + IF( GT_32( max_concealment_value, 0 ) ) { - g = shr( g, exp ); - *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; - } - ELSE - { - crossfadeGain = shl( crossfadeGain, exp ); - *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); - } - /*make a headroom for mdct_shaping*/ - exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); - /* assert(exp < 0);*/ - IF( exp < 0 ) - { - *mdctSpectrum_exp = SPEC_EXP_DEC; - move16(); - } - ELSE - { - exp = 0; - move16(); + IF( GT_16( exp, 0 ) ) + { + g = shr( g, exp ); + *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); + } + ELSE + { + crossfadeGain = shl( crossfadeGain, exp ); + *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); + move16(); + } + /*make a headroom for mdct_shaping*/ + exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); + /* assert(exp < 0);*/ + IF( LT_16( exp, 0 ) ) + { + *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); + } + ELSE + { + exp = 0; + move16(); + } } FOR( i = 0; i < crossOverFreq; i++ ) @@ -1535,15 +1541,17 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move32(); hTonalMDCTConc->faded_signal_nrg = L_add( hTonalMDCTConc->faded_signal_nrg, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ) ); + move32(); } - - hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 ); - FOR( i = crossOverFreq; i < hTonalMDCTConc->lastBlockData.nSamples; i++ ) { mdctSpectrum[i] = 0; move32(); } + *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); + move16(); + hTonalMDCTConc->faded_signal_nrg_exp = shl( *mdctSpectrum_exp, 1 ); + move16(); } } ELSE @@ -1638,6 +1646,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { Word32 num, den; Word16 exp_num, exp_den; + Word32 max_concealment_value; exp_num = cngLevelBackgroundTrace_bfi_e; move16(); @@ -1665,29 +1674,34 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( L_tmp = L_deposit_h( 0 ); exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, add( concealment_noise_e, exp ) ); - IF( GT_16( exp, 0 ) ) - { - g = shr( g, exp ); - *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; - move16(); - } - ELSE - { - crossfadeGain = shl( crossfadeGain, exp ); - *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); - } - /*make a headroom for mdct_shaping*/ - exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); - /* assert(exp < 0);*/ - IF( exp < 0 ) - { - *mdctSpectrum_exp = SPEC_EXP_DEC; - move16(); - } - ELSE + (void) maximum_abs_32_fx( concealment_noise, hTonalMDCTConc->pTCI->lowerIndex[0], &max_concealment_value ); + IF( GT_32( max_concealment_value, 0 ) ) { - exp = 0; - move16(); + IF( GT_16( exp, 0 ) ) + { + g = shr( g, exp ); + *mdctSpectrum_exp = hTonalMDCTConc->lastBlockData.spectralData_exp; + move16(); + } + ELSE + { + crossfadeGain = shl( crossfadeGain, exp ); + *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); + move16(); + } + /*make a headroom for mdct_shaping*/ + exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); + /* assert(exp < 0);*/ + IF( LT_16( exp, 0 ) ) + { + *mdctSpectrum_exp = SPEC_EXP_DEC; + move16(); + } + ELSE + { + exp = 0; + move16(); + } } FOR( l = 0; l < hTonalMDCTConc->pTCI->lowerIndex[0]; l++ ) @@ -1874,6 +1888,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( { crossfadeGain = shl( crossfadeGain, exp ); *mdctSpectrum_exp = sub( hTonalMDCTConc->lastBlockData.spectralData_exp, exp ); + move16(); } /*make a headroom for mdct_shaping*/ exp = sub( *mdctSpectrum_exp, SPEC_EXP_DEC ); diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 56f2e9ee62b8761b19c8811896359942d6f19e0d..46edff2f22e832e21f2a7a3c30bb4f9c2861fb08 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -578,7 +578,14 @@ static int16_t stereo_dft_enc_itd_vad( float Spd[STEREO_DFT_N_16k_ENC / 2 + 1]; + +#ifdef FIX_828_PORT_1152_FROM_FLT_REPO + /* Spd is later only used starting at itd_vad_band_tbl[0], so only compute values starting from there */ + /* -> this avoids uninitialized values in Spd_L and Spd_R at index 0 to be used */ + for ( i = itd_vad_band_tbl[0]; i <= STEREO_DFT_N_16k_ENC / 2; i++ ) +#else for ( i = 0; i <= STEREO_DFT_N_16k_ENC / 2; i++ ) +#endif { Spd[i] = 0.5f * ( Spd_L[i] + Spd_R[i] ); }