diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 801fd7ed9eed71713524ff84b2f52ed68104faf9..4fb0a0b58b663b7f74a8b6ec295cf4e925439f6f --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,7 +168,7 @@ #endif #define NONBE_FIX_874_OMASA_BRSW_2TD /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/ #define NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* FhG: isse 871: crash in ACELP core encoder with OSBA */ - +#define NONBE_FIX_906_SBA_LBR_SMOOTHING /* FhG: issue #906: fix SBA low bit rate smoothing for HOA2/HOA3 output */ /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 0237a059a5b259878f0f097541319eb86daae255..76e5c6f1fbad8ce91e4e4f49f68f30614349d1e5 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1062,6 +1062,10 @@ static void ivas_spar_calc_smooth_facs( float *cldfb_in_ts_re[CLDFB_NO_COL_MAX], float *cldfb_in_ts_im[CLDFB_NO_COL_MAX], int16_t nbands_spar, +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + const int16_t nSlots, + const int16_t isFirstSubframe, +#endif ivas_fb_bin_to_band_data_t *bin2band, float *smooth_fac, float smooth_buf[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1] ) @@ -1083,15 +1087,30 @@ static void ivas_spar_calc_smooth_facs( subframe_band_nrg[b] = 0.f; while ( bin < CLDFB_NO_CHANNELS_MAX && b == bin2band->p_cldfb_map_to_spar_band[bin] ) { +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + for ( ts = 0; ts < nSlots; ts++ ) +#else for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) +#endif { subframe_band_nrg[b] += cldfb_in_ts_re[ts][bin] * cldfb_in_ts_re[ts][bin] + cldfb_in_ts_im[ts][bin] * cldfb_in_ts_im[ts][bin]; } bin++; } subframe_band_nrg[b] = sqrtf( subframe_band_nrg[b] ); - smooth_buf[b][0] = subframe_band_nrg[b]; - +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + if ( isFirstSubframe && nSlots < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + /* fill up to full 5ms subframe */ + smooth_buf[b][0] += subframe_band_nrg[b]; + } + else + { +#endif + smooth_buf[b][0] = subframe_band_nrg[b]; +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + } +#endif /* calculate short and long energy averages */ smooth_short_avg[b] = EPSILON; for ( i = 0; i < 2 * SBA_DIRAC_NRG_SMOOTH_SHORT; i++ ) @@ -1128,14 +1147,21 @@ static void ivas_spar_calc_smooth_facs( smooth_fac[b] = max( min_smooth_gains1[b], min( max_smooth_gains2[b], smooth_fac[b] ) ); } - for ( b = 0; b < nbands_spar; b++ ) +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + /* only update if we collected a full 5ms worth of energies for the buffer */ + if ( isFirstSubframe || nSlots == MAX_PARAM_SPATIAL_SUBFRAMES ) { - for ( i = 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i > 0; i-- ) +#endif + for ( b = 0; b < nbands_spar; b++ ) { - smooth_buf[b][i] = smooth_buf[b][i - 1]; + for ( i = 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i > 0; i-- ) + { + smooth_buf[b][i] = smooth_buf[b][i - 1]; + } } +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING } - +#endif return; } @@ -1685,7 +1711,11 @@ void ivas_spar_dec_upmixer_sf( if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) { +#ifdef NONBE_FIX_906_SBA_LBR_SMOOTHING + ivas_spar_calc_smooth_facs( cldfb_in_ts_re[0], cldfb_in_ts_im[0], num_spar_bands, hSpar->subframe_nbslots[hSpar->subframes_rendered], hSpar->subframes_rendered == 0, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_buf ); +#else ivas_spar_calc_smooth_facs( cldfb_in_ts_re[0], cldfb_in_ts_im[0], num_spar_bands, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_buf ); +#endif } for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )