diff --git a/lib_com/cnst.h b/lib_com/cnst.h index d518dff0df3cce6bdc2ac6b56907403c49643e27..a35f5280c228de623d417afd7d4b602f10a01077 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2240,5 +2240,13 @@ enum VOIP_RTPDUMP }; +#ifdef FIX_489_COV_SMOOTHING +typedef enum _COV_SMOOTHING_TYPE +{ + COV_SMOOTH_SPAR, + COV_SMOOTH_MC +} COV_SMOOTHING_TYPE; +#endif + /* clang-format on */ #endif /* CNST_H */ diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 1860e6ac70cad5a82a3a76290368f46b027d6c41..e407bccc6c67c6b7193b70b88faa8b45890f57e5 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -35,6 +35,9 @@ #ifdef DEBUGGING #include "debug.h" #endif +#ifdef FIX_489_COV_SMOOTHING +#include "cnst.h" +#endif #include "ivas_prot.h" #include "wmc_auto.h" #include "prot.h" @@ -50,7 +53,12 @@ static void ivas_set_up_cov_smoothing( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, const float max_update_rate, - const int16_t min_pool_size, + const int16_t min_pool_size +#ifdef FIX_489_COV_SMOOTHING + , + const COV_SMOOTHING_TYPE smooth_mode /* i : flag multichannel vs SPAR */ +#endif + , const int32_t ivas_total_brate ) { int16_t j, k; @@ -88,7 +96,30 @@ static void ivas_set_up_cov_smoothing( } } } +#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; + } + } + } +#endif else + { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { float update_factor; @@ -108,6 +139,8 @@ static void ivas_set_up_cov_smoothing( hCovState->pSmoothing_factor[j] = max_update_rate; } } + } + hCovState->prior_bank_idx = -1; return; @@ -126,6 +159,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 + COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { @@ -155,7 +191,11 @@ ivas_error ivas_spar_covar_smooth_enc_open( } +#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 *hCovState_out = hCovState; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9b6871695e56d46bd1beea1d76c54e10aac37b2e..650473d85221fc723834ea642781869912856ea8 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4733,6 +4733,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 + COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC*/ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); @@ -4763,6 +4766,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 + COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC*/ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 0a9e37c1919f261176a716f120c3fdb52a08ab68..bc6458d295bb9ed29e0f0cb866d74d3172401c88 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -203,6 +203,8 @@ #define FIX_HBR_MASAMETA /* Nokia: Fixes to HBR MASA metadata at 384 and 512 kbps. Addresses issues 438 and 477 as well. */ #define FIX_482_DUMMYDEC_INIT /* Nokia: fix issue #428: missing inits for dummyDec in IVAS_rend */ #define FIX_468_16KHZ_PUPMIX /* Dlb: Fix issue 468 for Param Upmix at 16kHz sampling rate */ +#define FIX_489_COV_SMOOTHING /* Dlb: Fix covariance smoothing for ParamUpmix */ + #define FIX_485_STATIC_BUFFERS /* FhG: move static buffers in DirAC parameter estimator to the DirAC struct */ diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 2d1c5425bf37e061f1d25340ef70b0397c40e7e6..61c4ccaef9afc4edcd578f279edb6194c4781c6d 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -68,6 +68,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 + COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { @@ -85,13 +88,25 @@ 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 + if ( smooth_mode == COV_SMOOTH_MC ) + { + cov_smooth_cfg.max_update_rate = 1.0f; + cov_smooth_cfg.min_pool_size = 20; + } +#else if ( nchan_inp == 3 ) /* to discriminate between SPAR and mc there could be a better solution */ { cov_smooth_cfg.max_update_rate = 1.0f; cov_smooth_cfg.min_pool_size = 20; } +#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; } @@ -99,7 +114,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; } diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 997b0043ac4f62e51363c6fb40569e2eb03e9b34..0d5f69d800527839890c9ac4df6381dfedd58d0d 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -206,7 +206,11 @@ ivas_error ivas_mc_paramupmix_enc_open( for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { /* Covariance handle */ +#ifdef FIX_489_COV_SMOOTHING + if ( ( error = ivas_spar_covar_enc_open( &( hMCParamUpmix->hCovEnc[i] ), hMCParamUpmix->hFbMixer->pFb, input_Fs, MC_PARAMUPMIX_NCH + 1, COV_SMOOTH_MC, st_ivas->hEncoderConfig->ivas_total_brate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_covar_enc_open( &( hMCParamUpmix->hCovEnc[i] ), hMCParamUpmix->hFbMixer->pFb, input_Fs, MC_PARAMUPMIX_NCH + 1, st_ivas->hEncoderConfig->ivas_total_brate ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 651dcb2741d4d35c7a7fc88008570e12e2853aef..642fef906a7cb0e2bb75c71da7c9807f0c8483af 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -134,7 +134,11 @@ ivas_error ivas_spar_enc_open( } /* Covariance handle */ +#ifdef FIX_489_COV_SMOOTHING + if ( ( error = ivas_spar_covar_enc_open( &( hSpar->hCovEnc ), hSpar->hFbMixer->pFb, input_Fs, nchan_inp, COV_SMOOTH_SPAR, hEncoderConfig->ivas_total_brate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_spar_covar_enc_open( &( hSpar->hCovEnc ), hSpar->hFbMixer->pFb, input_Fs, nchan_inp, hEncoderConfig->ivas_total_brate ) ) != IVAS_ERR_OK ) +#endif { return error; }