From 31a91255311ea1bbe1e02709c3a34709b46198cf Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 21 Apr 2023 11:46:58 +0200 Subject: [PATCH 1/5] Issue 417: fix incorrect use of TD decorrelator in bitrate switching; under FIX_417_TD_DECORR_BRATE_SW --- lib_com/ivas_prot.h | 11 ++ lib_com/ivas_td_decorr.c | 105 ++++++++++++++++++- lib_com/options.h | 2 +- lib_dec/ivas_masa_dec.c | 27 +++++ lib_dec/ivas_mct_dec.c | 27 ++++- lib_dec/ivas_sba_dec.c | 14 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 20 +++- 7 files changed, 200 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d3e825b63e..79176cd281 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3440,10 +3440,21 @@ void ivas_dirac_dec( const int16_t i_sf ); +#ifdef FIX_417_TD_DECORR_BRATE_SW +ivas_error ivas_td_decorr_reconfig_dec( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate, /* i : total IVAS bitrate */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int32_t output_Fs, /* i : output sampling rate */ + ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ + uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ +); +#else ivas_error ivas_dirac_dec_init_binaural_data( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ ); +#endif void computeDiffuseness_mdft( float **buffer_intensity[DIRAC_NUM_DIMS], diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 23620b3b2d..0215bfcf56 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -87,12 +87,111 @@ static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { }; +#ifdef FIX_417_TD_DECORR_BRATE_SW +#define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) +#define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) +#endif + /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ static int16_t ivas_get_APD_filt_orders( const int16_t num_out_chans, const int32_t output_Fs, int16_t *APD_filt_orders ); -static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t num_out_chans, const int16_t ducking_flag ); + +static void ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t num_out_chans, const int16_t ducking_flag ); + + +#ifdef FIX_417_TD_DECORR_BRATE_SW +/*------------------------------------------------------------------------- + * ivas_td_decorr_reconfig_dec() + * + * Allocate and initialize time domain decorrelator handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_td_decorr_reconfig_dec( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate, /* i : total IVAS bitrate */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int32_t output_Fs, /* i : output sampling rate */ + ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ + uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ +) +{ + uint16_t useTdDecorr_new; + ivas_error error; + + useTdDecorr_new = 0; + if ( ivas_format == SBA_FORMAT ) + { + if ( nchan_transport == 1 ) + { + useTdDecorr_new = 1; + } + } + else if ( ivas_format == MASA_FORMAT ) + { + if ( ( ivas_total_brate < IVAS_48k && nchan_transport == 1 ) || ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + useTdDecorr_new = 1; + } + } + else if ( ivas_format == MC_FORMAT ) + { + if ( ivas_total_brate < IVAS_48k && nchan_transport == 1 ) + { + useTdDecorr_new = 1; + } + } + + if ( *useTdDecorr != useTdDecorr_new ) + { + *useTdDecorr = useTdDecorr_new; + + if ( *useTdDecorr ) + { + if ( ivas_total_brate >= IVAS_13k2 && ivas_format == SBA_FORMAT ) + { + if ( *hTdDecorr == NULL ) + { + if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ivas_total_brate < IVAS_24k4 ) + { + ( *hTdDecorr )->pTrans_det->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR; + } + else + { + ( *hTdDecorr )->pTrans_det->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC_PARA_BIN; + } + } + else + { + if ( *hTdDecorr == NULL ) + { + if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_td_decorr_init( *hTdDecorr, 3, 0 ); + } + } + } + else + { + ivas_td_decorr_dec_close( hTdDecorr ); + } + } + + return IVAS_ERR_OK; +} +#endif /*------------------------------------------------------------------------- @@ -275,7 +374,7 @@ static int16_t ivas_get_APD_filt_orders( * TD decorr Initialisation function *-----------------------------------------------------------------------------------------*/ -static ivas_error ivas_td_decorr_init( +static void ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t num_out_chans, const int16_t ducking_flag ) @@ -295,7 +394,7 @@ static ivas_error ivas_td_decorr_init( } } - return IVAS_ERR_OK; + return; } diff --git a/lib_com/options.h b/lib_com/options.h index 5b8ab37e69..330327a576 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,7 @@ #define FIX_401_DIRAC_RENDERER_META_READ_INDICES /* Nokia: Issue 401: Fix metadata reading indices in DirAC renderer. */ #define FIX_406_IVAS_POSITION /* Eri: Issue 406: Unify IVAS_POSITION to use IVAS_VECTOR3 instead */ #define REND_DEBUGGING_REVISION /* VA: encapsulate rendering debugging options with DEBUGGING */ - +#define FIX_417_TD_DECORR_BRATE_SW /* VA: Issue 417: fix incorrect use of TD decorrelator in bitrate switching */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 3c7e490cbc..4c632081b6 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1093,6 +1093,9 @@ ivas_error ivas_masa_dec_reconfigure( uint16_t *bit_stream; Decoder_State **sts; int32_t ivas_total_brate, last_ivas_total_brate; +#ifdef FIX_417_TD_DECORR_BRATE_SW + int16_t nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -1100,6 +1103,11 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#ifdef FIX_417_TD_DECORR_BRATE_SW + nchan_transport_old = st_ivas->nchan_transport; + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#endif + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ @@ -1157,6 +1165,25 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef FIX_417_TD_DECORR_BRATE_SW + /*-----------------------------------------------------------------* + * TD Decorrelator + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDiracDecBin != NULL ) + { + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + + /*-----------------------------------------------------------------* + * Set-up MASA coding elements and bitrates + *-----------------------------------------------------------------*/ +#endif + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp ); return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 4492968ad8..9f17ccc916 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1046,6 +1046,8 @@ static ivas_error ivas_mc_dec_reconfig( return error; } + +#ifndef FIX_417_TD_DECORR_BRATE_SW /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ @@ -1054,7 +1056,7 @@ static ivas_error ivas_mc_dec_reconfig( { return error; } - +#endif /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded seperately after the allocation of the core coders *-----------------------------------------------------------------*/ @@ -1244,5 +1246,28 @@ static ivas_error ivas_mc_dec_reconfig( #endif } +#ifdef FIX_417_TD_DECORR_BRATE_SW + /*-----------------------------------------------------------------* + * TD Decorrelator + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDiracDecBin != NULL ) + { + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-----------------------------------------------------------------* + * CLDFB instances + *-----------------------------------------------------------------*/ + + if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5377ad9402..f667fed459 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -350,6 +350,20 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifdef FIX_417_TD_DECORR_BRATE_SW + /*-----------------------------------------------------------------* + * TD Decorrelator + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDiracDecBin != NULL ) + { + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 09704b969e..61c4ce5092 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -54,9 +54,11 @@ * Local constants *------------------------------------------------------------------------*/ -#define CLDFB_HALF_BIN_FREQUENCY_OFFSET 0.5f +#define CLDFB_HALF_BIN_FREQUENCY_OFFSET 0.5f +#ifdef FIX_417_TD_DECORR_BRATE_SW #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) +#endif #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS #ifdef NOKIA_ADAPTIVE_BINAURAL_PROTOS_OPT @@ -106,6 +108,7 @@ static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], f static float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_brate ); #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -166,6 +169,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( hBinaural->useSubframeMode = 1; +#ifndef FIX_417_TD_DECORR_BRATE_SW hBinaural->useTdDecorr = 0; if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -188,6 +192,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( hBinaural->useTdDecorr = 1; } } +#endif for ( bin = 0; bin < nBins; bin++ ) { @@ -265,6 +270,18 @@ ivas_error ivas_dirac_dec_init_binaural_data( assert( false ); } +#ifdef FIX_417_TD_DECORR_BRATE_SW + if ( hBinaural->hTdDecorr == NULL ) + { + hBinaural->useTdDecorr = 0; + } + + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + + return error; + } +#else if ( hBinaural->useTdDecorr ) { if ( st_ivas->hDecoderConfig->ivas_total_brate >= IVAS_13k2 && st_ivas->ivas_format == SBA_FORMAT ) @@ -292,6 +309,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( { ivas_td_decorr_dec_close( &( hBinaural->hTdDecorr ) ); } +#endif #ifdef NOKIA_PARAMBIN_REQULARIZATION hBinaural->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); -- GitLab From 2c34a1f0ade862b38172ea31e47d34a4a212a8c3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 21 Apr 2023 11:54:20 +0200 Subject: [PATCH 2/5] build warning --- lib_dec/ivas_masa_dec.c | 3 +-- lib_rend/ivas_dirac_dec_binaural_functions.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 4c632081b6..87e2b6f0d9 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1094,7 +1094,7 @@ ivas_error ivas_masa_dec_reconfigure( Decoder_State **sts; int32_t ivas_total_brate, last_ivas_total_brate; #ifdef FIX_417_TD_DECORR_BRATE_SW - int16_t nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old; + int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; #endif ivas_error error; @@ -1104,7 +1104,6 @@ ivas_error ivas_masa_dec_reconfigure( last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; #ifdef FIX_417_TD_DECORR_BRATE_SW - nchan_transport_old = st_ivas->nchan_transport; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 61c4ce5092..8734991a2d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -278,7 +278,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hBinaural->hTdDecorr ), &( hBinaural->useTdDecorr ) ) ) != IVAS_ERR_OK ) { - return error; } #else -- GitLab From 326185c151666ae1b8f8cc9e8737f339349e3700 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 26 Apr 2023 11:01:09 +0200 Subject: [PATCH 3/5] add CLDFB reconfig to MASA decoder; under FIX_417_TD_DECORR_BRATE_SW --- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_masa_dec.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c0f073af4b..b3598e9e17 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1884,7 +1884,7 @@ void ivas_destroy_dec( /*-------------------------------------------------------------------* - * ivas_init_dec_get_num_cldfb_analyses() + * ivas_init_dec_get_num_cldfb_instances() * * Return number of CLDFB analysis & synthesis instances *-------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 87e2b6f0d9..7523eb7b60 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1177,6 +1177,14 @@ ivas_error ivas_masa_dec_reconfigure( } } + /*-----------------------------------------------------------------* + * CLDFB instances + *-----------------------------------------------------------------*/ + + if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + { + return error; + } /*-----------------------------------------------------------------* * Set-up MASA coding elements and bitrates -- GitLab From 2e2a08ed97a041dab6fae5bc5c89146d71c6759c Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 27 Apr 2023 11:32:07 +0200 Subject: [PATCH 4/5] extend FIX_417_TD_DECORR_BRATE_SW to simplify the operations in McMASA bitrate switching: instead of full dirac close and re-init, only reconfigure td-decorr when necessary. --- lib_dec/ivas_mcmasa_dec.c | 11 +++++++++++ lib_dec/ivas_stat_dec.h | 3 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 0b375d4031..59d215e22c 100755 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -131,6 +131,16 @@ ivas_error ivas_mcmasa_dec_reconfig( } else { +#ifdef FIX_417_TD_DECORR_BRATE_SW + /* if necessary, close/open td-decorrs */ + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* regularization factor is bitrate-dependent */ + st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#else /* the decision for useTdDecorr is done in ivas_dirac_dec_init_binaural_data(). here, comparing against the same condition. */ if ( st_ivas->hDiracDecBin->useTdDecorr != ( ivas_total_brate < IVAS_48k && st_ivas->nchan_transport == 1 ) ) { @@ -141,6 +151,7 @@ ivas_error ivas_mcmasa_dec_reconfig( return error; } } +#endif } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a17c75dda..b6013be7d5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -574,6 +574,9 @@ typedef struct dirac_output_synthesis_cov_state_structure } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; +#ifdef FIX_417_TD_DECORR_BRATE_SW +float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_brate ); +#endif /* MASA stereo transport signal type detection structure */ typedef struct diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c1fa5c3eb5..e7ff7dc33a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -94,8 +94,9 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); +#ifndef FIX_417_TD_DECORR_BRATE_SW static float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_brate ); - +#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() @@ -2026,7 +2027,10 @@ static void hrtfShGetHrtf( *------------------------------------------------------------------------*/ /*! r: Configured reqularization factor value to be set. */ -static float configure_reqularization_factor( +#ifndef FIX_417_TD_DECORR_BRATE_SW +static +#endif +float configure_reqularization_factor( const IVAS_FORMAT ivas_format, /* i: IVAS codec format in use */ const int32_t ivas_brate ) /* i: Current IVAS bitrate */ { -- GitLab From 6e84ef91b29ed1b47e192692e7829f1f78fe3e25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Apr 2023 15:42:40 +0200 Subject: [PATCH 5/5] move function declaration to appropriate header file --- lib_com/ivas_prot.h | 6 ++++ lib_dec/ivas_stat_dec.h | 4 --- lib_rend/ivas_dirac_dec_binaural_functions.c | 30 +++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ddc1cb0ca5..63e80cd8be 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3395,6 +3395,12 @@ ivas_error ivas_td_decorr_reconfig_dec( ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ uint16_t *useTdDecorr /* i/o: TD decorrelator flag */ ); + +/*! r: Configured reqularization factor value */ +float configure_reqularization_factor( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : total IVAS bitrate */ +); #else ivas_error ivas_dirac_dec_init_binaural_data( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b6013be7d5..3de42b0caf 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -574,10 +574,6 @@ typedef struct dirac_output_synthesis_cov_state_structure } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; -#ifdef FIX_417_TD_DECORR_BRATE_SW -float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_brate ); -#endif - /* MASA stereo transport signal type detection structure */ typedef struct { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index e7ff7dc33a..1fbcad6f68 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -2026,40 +2026,42 @@ static void hrtfShGetHrtf( * parametric binauralizer using IVAS codec format and current bitrate. *------------------------------------------------------------------------*/ -/*! r: Configured reqularization factor value to be set. */ +/*! r: Configured reqularization factor value */ #ifndef FIX_417_TD_DECORR_BRATE_SW static #endif -float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i: IVAS codec format in use */ - const int32_t ivas_brate ) /* i: Current IVAS bitrate */ + float + configure_reqularization_factor( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ + ) { float reqularizationFactor; reqularizationFactor = 1.0f; /* Default value */ if ( ivas_format == MASA_FORMAT ) { - if ( ivas_brate >= IVAS_256k ) + if ( ivas_total_brate >= IVAS_256k ) { reqularizationFactor = 0.2f; } - else if ( ivas_brate == IVAS_192k ) + else if ( ivas_total_brate == IVAS_192k ) { reqularizationFactor = 0.3f; } - else if ( ivas_brate == IVAS_160k ) + else if ( ivas_total_brate == IVAS_160k ) { reqularizationFactor = 0.4f; } - else if ( ivas_brate == IVAS_128k ) + else if ( ivas_total_brate == IVAS_128k ) { reqularizationFactor = 0.5f; } - else if ( ivas_brate == IVAS_96k ) + else if ( ivas_total_brate == IVAS_96k ) { reqularizationFactor = 0.6f; } - else if ( ivas_brate >= IVAS_64k ) + else if ( ivas_total_brate >= IVAS_64k ) { reqularizationFactor = 0.8f; } @@ -2071,19 +2073,19 @@ float configure_reqularization_factor( if ( ivas_format == MC_FORMAT ) /* This is always McMASA for parametric binauralizer. */ { - if ( ivas_brate >= IVAS_96k ) + if ( ivas_total_brate >= IVAS_96k ) { reqularizationFactor = 0.3f; } - else if ( ivas_brate >= IVAS_80k ) + else if ( ivas_total_brate >= IVAS_80k ) { reqularizationFactor = 0.5f; } - else if ( ivas_brate >= IVAS_64k ) + else if ( ivas_total_brate >= IVAS_64k ) { reqularizationFactor = 0.7f; } - else if ( ivas_brate >= IVAS_48k ) + else if ( ivas_total_brate >= IVAS_48k ) { reqularizationFactor = 0.8f; } -- GitLab