From 28d2ca67cfd0f60473ca9b332b7d982925d2d854 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 27 Apr 2023 14:14:52 +0200 Subject: [PATCH 1/3] add renderer reconfiguration in MASA bitrate switching. changes are under flag FIX_425_MASA_BRSW_RENDERER. requires the changes under FIX_417_TD_DECORR_BRATE_SW to be included in the underlying code for proper operation. --- lib_com/options.h | 1 + lib_dec/ivas_masa_dec.c | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4318ec9128..5740da18e4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define FIX_416_ISM_BR_SWITCHING /* FhG: add missing CLDFB reconfig to ISM BR switching */ #define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ +#define FIX_425_MASA_BRSW_RENDERER /* Nokia: Issue 425: renderer not reconfigure in MASA bitrate switching */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 9cadbcc4fc..fe8192e1dc 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1077,6 +1077,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_425_MASA_BRSW_RENDERER + int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -1084,6 +1087,37 @@ 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_425_MASA_BRSW_RENDERER + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); + + /* renderer might have changed, reselect */ + ivas_renderer_select( st_ivas ); + + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( st_ivas->hDirAC != NULL ) + { + /* reconfigure existing DirAC dec */ + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + /* init a new DirAC dec */ + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( st_ivas->renderer_type == RENDERER_DISABLE && st_ivas->hDirAC != NULL ) + { + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); + } +#endif + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ @@ -1141,6 +1175,20 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef FIX_425_MASA_BRSW_RENDERER + /*-----------------------------------------------------------------* + * 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 + *-----------------------------------------------------------------*/ +#endif ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp ); return error; -- GitLab From 9e60f9b28619ea5477037361d0e130844d7a92e8 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Fri, 28 Apr 2023 10:50:43 +0200 Subject: [PATCH 2/3] set bitrate-dependent regularization factor --- lib_dec/ivas_masa_dec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 0b2178b97f..f70535878a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1176,7 +1176,13 @@ ivas_error ivas_masa_dec_reconfigure( } } } - +#ifdef FIX_425_MASA_BRSW_RENDERER + if ( st_ivas->hDiracDecBin != NULL ) + { + /* regularization factor is bitrate-dependent */ + st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + } +#endif #ifdef FIX_417_TD_DECORR_BRATE_SW /*-----------------------------------------------------------------* * TD Decorrelator -- GitLab From 304ebdfabf3e8450084caa2f0231b617aaa88a49 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 2 May 2023 17:09:50 +0200 Subject: [PATCH 3/3] remove the DirAC dec reconfig from the renderer part, since it's done later --- lib_dec/ivas_masa_dec.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index f70535878a..32bfcb960d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1095,29 +1095,20 @@ ivas_error ivas_masa_dec_reconfigure( /* renderer might have changed, reselect */ ivas_renderer_select( st_ivas ); - if ( st_ivas->renderer_type != RENDERER_DISABLE ) + if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->hDirAC == NULL ) { - if ( st_ivas->hDirAC != NULL ) + /* init a new DirAC dec */ + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { - /* reconfigure existing DirAC dec */ - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - /* init a new DirAC dec */ - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } else if ( st_ivas->renderer_type == RENDERER_DISABLE && st_ivas->hDirAC != NULL ) { + /* close unnecessary DirAC dec */ ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); } + /* possible reconfigure is done later */ #endif /*-----------------------------------------------------------------* -- GitLab