Commit cdc3b6b9 authored by bayers's avatar bayers
Browse files

Merge branch...

Merge branch '906-jbm-spar-low-rate-smoothing-factor-calculation-may-use-undefined-values' into 'main'

[Non-BE] Resolve "JBM: SPAR low rate smoothing factor calculation may use undefined values"

See merge request !1235
parents c0d03a51 1454f7c5
Loading
Loading
Loading
Loading
Loading

lib_com/options.h

100644 → 100755
+1 −1
Original line number Diff line number Diff line
@@ -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 ######################### */
+36 −6
Original line number Diff line number Diff line
@@ -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] );
#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,6 +1147,11 @@ static void ivas_spar_calc_smooth_facs(
        smooth_fac[b] = max( min_smooth_gains1[b], min( max_smooth_gains2[b], smooth_fac[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 )
    {
#endif
        for ( b = 0; b < nbands_spar; b++ )
        {
            for ( i = 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i > 0; i-- )
@@ -1135,7 +1159,9 @@ static void ivas_spar_calc_smooth_facs(
                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++ )