From a6acdc425dbcf02f0881703d6fdf0d7d00ba9789 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 15 Oct 2024 17:20:16 +0200 Subject: [PATCH 1/3] issue 1200: fix bug in renderer flush in ISM JBM bitrate switching; under NONBE_1200_ISM_JBM_BRATE_SW_FLUSH --- lib_com/options.h | 1 + lib_dec/ivas_ism_dec.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 0d67f8497f..f50230e129 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -185,6 +185,7 @@ #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ #define FIX_1139_REV_COLORATION_SHORT_T60 /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */ +#define NONBE_1200_ISM_JBM_BRATE_SW_FLUSH /* VA: issue 1200: fix bug in renderer flush in ISM JBM bitrate switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 36945f8155..148b2e9262 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -124,7 +124,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); } +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH { +#endif /* transfer subframe info from DirAC or ParamMC to central tc buffer */ /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */ if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hSpatParamRendCom != NULL && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) @@ -142,10 +144,19 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { +#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH + /* write back info for correct rendering of the flushable samples */ + int16_t nchan_transport_ref = st_ivas->nchan_transport; + st_ivas->nchan_transport = nchan_transport_old; + +#endif if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) { return error; } +#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH + st_ivas->nchan_transport = nchan_transport_ref; +#endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) @@ -155,7 +166,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH } +#endif if ( st_ivas->ism_mode != last_ism_mode ) { @@ -311,19 +324,26 @@ static ivas_error ivas_ism_bitrate_switching_dec( * floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH { +#endif nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH } +#endif /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ + +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH { +#endif int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -359,7 +379,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH } +#endif return error; } -- GitLab From cbd98af924a7a8c14dc0fb4ca44248bdd3fc7fef Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 22 Oct 2024 14:08:58 +0200 Subject: [PATCH 2/3] fix merge issue --- lib_dec/ivas_ism_dec.c | 45 +++++++++++++++++++++++++++++++++++------- lib_dec/lib_dec.c | 2 +- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0d20e39a77..2d66382472 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -47,12 +47,16 @@ *-------------------------------------------------------------------------*/ static ivas_error ivas_ism_bitrate_switching_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nchan_transport_old, /* i : last number of transport channels */ - const ISM_MODE last_ism_mode, /* i : last ISM mode */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nchan_transport_old, /* i : last number of transport channels */ + const ISM_MODE last_ism_mode /* i : last ISM mode */ +#ifndef FIX_HRTF_LOAD + , uint16_t *nSamplesRendered, /* o : number of samples rendered */ const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ +#endif + ) { ivas_error error; @@ -64,11 +68,15 @@ static ivas_error ivas_ism_bitrate_switching_dec( int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; int16_t nchan_out_buff, nchan_out_buff_old; +#ifndef FIX_HRTF_LOAD AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; RENDERER_TYPE renderer_type_old; +#endif +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; +#endif nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -104,12 +112,13 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } +#ifndef FIX_HRTF_LOAD /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; hIntSetupOld = st_ivas->hIntSetup; tc_granularity_new = 1; renderer_type_old = st_ivas->renderer_type; - +#endif /*-----------------------------------------------------------------* * Initialize the needed renderer struct and destroy the unnecessary renderer struct *-----------------------------------------------------------------*/ @@ -387,7 +396,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( } #endif +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else return error; +#endif } @@ -399,18 +412,23 @@ static ivas_error ivas_ism_bitrate_switching_dec( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ +#ifndef FIX_HRTF_LOAD + , uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ +#endif ) { int32_t ivas_total_brate; ivas_error error; int16_t nchan_transport_old; +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /* Assumes that num of input objects are constant */ @@ -439,9 +457,13 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ - if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) + if ( ( st_ivas->ism_mode != last_ism_mode ) || ( ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { +#ifdef FIX_HRTF_LOAD + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -463,7 +485,12 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { + +#ifdef FIX_HRTF_LOAD + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -489,5 +516,9 @@ ivas_error ivas_ism_dec_config( break; } +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else return error; +#endif } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0e9989d3f1..5bcdd3f77d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1146,7 +1146,7 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH st_ivas->nchan_transport = nchan_transport_old; #else -// st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 + //st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 #endif if ( st_ivas->ivas_format == MASA_FORMAT ) { -- GitLab From 7048c098c9f7d1f95f89bf4b7c429391d7ad64b7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 22 Oct 2024 14:21:29 +0200 Subject: [PATCH 3/3] clang-format --- lib_dec/ivas_ism_dec.c | 2 +- lib_dec/lib_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 2d66382472..f20a3d7437 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -56,7 +56,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #endif - ) { ivas_error error; @@ -118,6 +117,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( hIntSetupOld = st_ivas->hIntSetup; tc_granularity_new = 1; renderer_type_old = st_ivas->renderer_type; + #endif /*-----------------------------------------------------------------* * Initialize the needed renderer struct and destroy the unnecessary renderer struct diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5bcdd3f77d..aeced68763 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1146,7 +1146,7 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH st_ivas->nchan_transport = nchan_transport_old; #else - //st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 + // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 #endif if ( st_ivas->ivas_format == MASA_FORMAT ) { -- GitLab