From 5d389f994031bc95388b71948e364d4292f3a55c Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 20 Nov 2023 11:27:07 +0100 Subject: [PATCH] fix #906, make sure the low BR SBA smoothing for HOA output is aware of the real subframe size in slots. Under define NONBE_FIX_906_SBA_LBR_SMOOTHING, active --- lib_com/options.h | 2 +- lib_dec/ivas_spar_decoder.c | 42 +++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a4eab8337d..c8834d9f63 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,7 +169,7 @@ #define NONBE_FIX_897_USAN_WITH_MASA_RENDERING /* Nokia: issue #897: USAN null pointer in MASA external renderer to Ambisonics */ #define NONBE_FIX_903_OSBA_TO_STEREO /* VA: issue 903: fix OSBA to stereo rendering issue */ #define NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT /* FhG: issue 811: change double precision functions to float in DFT Stereo */ - +#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 0237a059a5..76e5c6f1fb 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++ ) -- GitLab