Commit 095a68a4 authored by PLAINSI's avatar PLAINSI
Browse files

Fix covariance smoothing for ParamUpmix

parent a2bcdd0a
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2244,5 +2244,13 @@ enum
    VOIP_RTPDUMP
};

#ifdef FIX_489_COV_SMOOTHING
enum
{
    COV_SMOOTH_SPAR,
    COV_SMOOTH_MC
};
#endif

/* clang-format on */
#endif /* CNST_H */
+61 −16
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@
#include "wmc_auto.h"
#include "prot.h"

#ifdef FIX_489_COV_SMOOTHING
#include "cnst.h"
#endif

#define BAND_SMOOTH_REST_START_IDX ( 2 )
/*-----------------------------------------------------------------------------------------*
 * Function ivas_set_up_cov_smoothing()
@@ -51,6 +55,10 @@ static void ivas_set_up_cov_smoothing(
    ivas_filterbank_t *pFb,
    const float max_update_rate,
    const int16_t min_pool_size
#ifdef FIX_489_COV_SMOOTHING
    ,
    const int16_t smooth_mode /* i  : flag multichannel vs SPAR       */
#endif
#ifndef FIX_331_ALL_BRS
    ,
    const int16_t nchan_inp /* i  : number of input channels       */
@@ -87,6 +95,27 @@ static void ivas_set_up_cov_smoothing(
            }
            hCovState->pSmoothing_factor[j] *= ( j + 1 ) * smooth_fact;

            if ( hCovState->pSmoothing_factor[j] > max_update_rate )
            {
                hCovState->pSmoothing_factor[j] = max_update_rate;
            }
        }
    }
#ifdef FIX_489_COV_SMOOTHING
    else if ( smooth_mode == COV_SMOOTH_MC )
    {
        for ( j = 0; j < pFb->filterbank_num_bands; j++ )
        {
            float update_factor;
            update_factor = 0.0f;

            for ( k = 0; k < pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; k++ )
            {
                update_factor += pFb->fb_bin_to_band.pFb_bin_to_band[j][k];
            }

            hCovState->pSmoothing_factor[j] = update_factor / min_pool_size;

            if ( hCovState->pSmoothing_factor[j] > max_update_rate )
            {
                hCovState->pSmoothing_factor[j] = max_update_rate;
@@ -94,6 +123,8 @@ static void ivas_set_up_cov_smoothing(
        }
    }
    else
    {
#endif
#ifndef FIX_331_ALL_BRS
        if ( nchan_inp <= FOA_CHANNELS )
        {
@@ -137,6 +168,9 @@ static void ivas_set_up_cov_smoothing(
                    hCovState->pSmoothing_factor[j] = max_update_rate;
                }
            }
#ifdef FIX_489_COV_SMOOTHING
        }
#endif
#ifndef FIX_331_ALL_BRS
    }
#endif
@@ -158,6 +192,9 @@ ivas_error ivas_spar_covar_smooth_enc_open(
    ivas_filterbank_t *pFb,                      /* i/o: FB handle                      */
    const int16_t nchan_inp                      /* i  : number of input channels       */
    ,
#ifdef FIX_489_COV_SMOOTHING
    int16_t smooth_mode,
#endif
    const int32_t ivas_total_brate /* i  : IVAS total bitrate             */
)
{
@@ -188,9 +225,17 @@ ivas_error ivas_spar_covar_smooth_enc_open(


#ifndef FIX_331_ALL_BRS
#ifdef FIX_489_COV_SMOOTHING
    ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
#else
    ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, nchan_inp, ivas_total_brate );
#endif
#else
#ifdef FIX_489_COV_SMOOTHING
    ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
#else
    ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, ivas_total_brate );
#endif
#endif

    *hCovState_out = hCovState;
+6 −0
Original line number Diff line number Diff line
@@ -4794,6 +4794,9 @@ ivas_error ivas_spar_covar_enc_open(
    const int32_t input_Fs,                                     /* i  : input sampling rate                     */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
	,
#ifdef FIX_489_COV_SMOOTHING
    int16_t smooth_mode,
#endif
	const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                      */
);

@@ -4826,6 +4829,9 @@ ivas_error ivas_spar_covar_smooth_enc_open(
    ivas_filterbank_t *pFb,                                     /* i/o: FB handle                               */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
    ,
#ifdef FIX_489_COV_SMOOTHING
    int16_t smooth_mode,
#endif
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate             */
);

+2 −0
Original line number Diff line number Diff line
@@ -223,6 +223,8 @@

#define FIX_487_LOWRATE_SBA_TUNING_FIX                  /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */

#define FIX_489_COV_SMOOTHING                           /* Dlb: Fix covariance smoothing for ParamUpmix */


/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+21 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ ivas_error ivas_spar_covar_enc_open(
    const int32_t input_Fs,                 /* i  : input sampling rate            */
    const int16_t nchan_inp                 /* i  : number of input channels       */
    ,
#ifdef FIX_489_COV_SMOOTHING
    int16_t smooth_mode,
#endif
    const int32_t ivas_total_brate /* i  : IVAS total bitrate              */
)
{
@@ -92,6 +95,15 @@ ivas_error ivas_spar_covar_enc_open(
    cov_smooth_cfg.max_bands = IVAS_MAX_NUM_BANDS;
    cov_smooth_cfg.max_update_rate = MAX_UPDATE_RATE;
    cov_smooth_cfg.min_pool_size = MIN_POOL_SIZE;
#ifdef FIX_489_COV_SMOOTHING
#ifdef MC_PARAMUPMIX_MODE
    if ( smooth_mode == COV_SMOOTH_MC )
    {
        cov_smooth_cfg.max_update_rate = 1.0f;
        cov_smooth_cfg.min_pool_size = 20;
    }
#endif
#else
#ifdef MC_PARAMUPMIX_MODE
    if ( nchan_inp == 3 ) /* to discriminate between SPAR and mc there could be a better solution */
    {
@@ -99,8 +111,13 @@ ivas_error ivas_spar_covar_enc_open(
        cov_smooth_cfg.min_pool_size = 20;
    }
#endif
#endif

#ifdef FIX_489_COV_SMOOTHING
    if ( ( error = ivas_spar_covar_smooth_enc_open( &hCovState->pCov_state, &cov_smooth_cfg, pFb, nchan_inp, smooth_mode, ivas_total_brate ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_spar_covar_smooth_enc_open( &hCovState->pCov_state, &cov_smooth_cfg, pFb, nchan_inp, ivas_total_brate ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
@@ -108,7 +125,11 @@ ivas_error ivas_spar_covar_enc_open(
    cov_smooth_cfg.max_update_rate = MAX_UPDATE_RATE_DTX;
    cov_smooth_cfg.min_pool_size = MIN_POOL_SIZE_DTX;

#ifdef FIX_489_COV_SMOOTHING
    if ( ( error = ivas_spar_covar_smooth_enc_open( &hCovState->pCov_dtx_state, &cov_smooth_cfg, pFb, nchan_inp, smooth_mode, ivas_total_brate ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_spar_covar_smooth_enc_open( &hCovState->pCov_dtx_state, &cov_smooth_cfg, pFb, nchan_inp, ivas_total_brate ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
Loading