From c9539e4caf73ef33f913dec74004173a025a9205 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Feb 2025 17:00:36 +0100 Subject: [PATCH 01/42] issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors; under NONBE_1118_EVS_LR_HQ_BITERROR --- lib_com/options.h | 4 ++-- lib_dec/hq_lr_dec.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index be86aa6f64..a53176017f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,9 +173,9 @@ #define NONBE_1279_COUNTER_OVERFLOW /* VA: issue 1279: Avoid possible overflow of counter st->Nb_ACELP_frames */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ - - #define NONBE_1231_BASOP_819_THRESHOLD_MASA2TOTAL /* Nokia: add fix for precision limitation in comparison with masa2total energy ratio threshold to be aligned with BASOP*/ +#define NONBE_1118_EVS_LR_HQ_BITERROR /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index b2389c53e6..e96b22a109 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -264,6 +264,16 @@ void hq_lr_dec( exp = sub( exp, 30 ); Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); +#ifdef NONBE_1118_EVS_LR_HQ_BITERROR + + /* safety check in case of bit errors */ + if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) + { + st->BER_detect = 1; + set_f( yout, 0, inner_frame ); + return; + } +#endif } FOR( i = 0; i < bands; i++ ) -- GitLab From 9a0b58a88f9e12aa3f439e9a52fee7d94ef4baa3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Feb 2025 17:48:14 +0100 Subject: [PATCH 02/42] update --- lib_dec/hq_lr_dec.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index e96b22a109..ccb840404f 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -264,16 +264,6 @@ void hq_lr_dec( exp = sub( exp, 30 ); Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); -#ifdef NONBE_1118_EVS_LR_HQ_BITERROR - - /* safety check in case of bit errors */ - if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) - { - st->BER_detect = 1; - set_f( yout, 0, inner_frame ); - return; - } -#endif } FOR( i = 0; i < bands; i++ ) @@ -645,10 +635,30 @@ void hq_lr_dec( IF( sub( i, highband ) >= 0 ) { +#ifdef NONBE_1118_EVS_LR_HQ_BITERROR + /* safety check in case of bit errors */ + if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) + { + st->BER_detect = 1; + set_f( yout, 0, inner_frame ); + return; + } + +#endif enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ } ELSE IF( sub( i, lowband ) >= 0 ) { +#ifdef NONBE_1118_EVS_LR_HQ_BITERROR + /* safety check in case of bit errors */ + if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) + { + st->BER_detect = 1; + set_f( yout, 0, inner_frame ); + return; + } + +#endif enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ } } -- GitLab From 4bc35e93e3ae7f3a813ad8186e811594f60bad71 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 17 Mar 2025 14:34:01 +0100 Subject: [PATCH 03/42] issue 1293: fix G.192 decoder crash when first frame is lost; under NONBE_1293_CRASH_FIRST_FRAME_LOST --- lib_com/options.h | 3 ++- lib_dec/lib_dec.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6dea2ea9d7..e64caebb85 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,8 +175,9 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ - #define NONBE_1231_BASOP_819_THRESHOLD_MASA2TOTAL /* Nokia: add fix for precision limitation in comparison with masa2total energy ratio threshold to be aligned with BASOP*/ +#define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7640228d3b..5aaf6245bb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1081,6 +1081,13 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + /* If TSM is generally enabled, we have to wait for the first good frame. Otherwise, we directly decode the first frame in any case. */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) @@ -1221,6 +1228,13 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -1360,6 +1374,13 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -1593,7 +1614,12 @@ ivas_error IVAS_DEC_PrepareRenderer( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_dec_prepare_renderer( hIvasDec->st_ivas ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( hIvasDec->hasBeenFedFirstGoodFrame ) +#endif + { + ivas_dec_prepare_renderer( hIvasDec->st_ivas ); + } hIvasDec->hasBeenPreparedRendering = true; @@ -1777,6 +1803,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + error = IVAS_ERR_OK; st_ivas = hIvasDec->st_ivas; output_config = st_ivas->hDecoderConfig->output_config; -- GitLab From 1943032ee0e3c91f9d2cc608e498a0222acb0cc4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 17 Mar 2025 15:50:38 +0100 Subject: [PATCH 04/42] fix EVS decoder --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5aaf6245bb..7b9daa3096 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1082,7 +1082,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + if ( !hIvasDec->hasBeenFedFirstGoodFrame && !hIvasDec->isInitialized ) { return IVAS_ERR_OK; } -- GitLab From f556cacd168b1cadad995cc7286cf63d3d672b6d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 17 Mar 2025 19:45:31 +0100 Subject: [PATCH 05/42] fix EVS decoder when two first frames are lost --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7b9daa3096..305ec140ed 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1082,7 +1082,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - if ( !hIvasDec->hasBeenFedFirstGoodFrame && !hIvasDec->isInitialized ) + if ( !hIvasDec->hasBeenFedFirstGoodFrame && !hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */ { return IVAS_ERR_OK; } @@ -1615,7 +1615,7 @@ ivas_error IVAS_DEC_PrepareRenderer( } #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - if ( hIvasDec->hasBeenFedFirstGoodFrame ) + if ( hIvasDec->hasBeenFedFirstGoodFrame || hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */ #endif { ivas_dec_prepare_renderer( hIvasDec->st_ivas ); -- GitLab From 36f80fc538aed2972c74e02c7a455788cba16ffb Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Mar 2025 09:06:09 +0100 Subject: [PATCH 06/42] remove wrongly merged compilation flag --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4ccf556f1c..76dd1586c4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,6 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ -#define NONBE_1231_BASOP_819_THRESHOLD_MASA2TOTAL /* Nokia: add fix for precision limitation in comparison with masa2total energy ratio threshold to be aligned with BASOP*/ #define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 9a9ce37e13d7fa6e8f9b0d99318c57cc4640d1e3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 20 Mar 2025 10:15:19 +0100 Subject: [PATCH 07/42] fix uninitialized parameter reading --- lib_dec/lib_dec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 305ec140ed..50e00cc381 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1231,6 +1231,8 @@ ivas_error IVAS_DEC_GetEditableParameters( #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { + hIvasEditableParameters->num_obj = 0; + return IVAS_ERR_OK; } #endif -- GitLab From 9443b718f0639fd96e88f178916705d64af0db39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 17:28:01 +0100 Subject: [PATCH 08/42] issue 1303: Renderer granularity revision; under NONBE_1303_REND_GRANULARITY --- lib_com/ivas_prot.h | 13 ++++++++ lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 25 +++++++++++++-- lib_dec/ivas_ism_dec.c | 4 +++ lib_dec/ivas_ism_param_dec.c | 15 +++++++++ lib_dec/ivas_jbm_dec.c | 26 +++++++++++++++ lib_dec/ivas_masa_dec.c | 12 +++++++ lib_dec/ivas_mc_param_dec.c | 6 ++++ lib_dec/ivas_mc_paramupmix_dec.c | 6 ++++ lib_dec/ivas_mct_dec.c | 5 +++ lib_dec/ivas_output_config.c | 33 ++++++++++++++++++++ lib_dec/ivas_sba_dec.c | 4 +++ lib_dec/ivas_spar_decoder.c | 8 +++++ lib_dec/lib_dec.c | 27 ++++++++++++++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 13 +++++++- 15 files changed, 195 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ad871926d0..4722f322d2 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -656,6 +656,13 @@ void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef NONBE_1303_REND_GRANULARITY +/*! r: secondary binaural renderer type */ +RENDERER_TYPE ivas_renderer_secondary_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +#endif ivas_error ivas_mc_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -885,10 +892,16 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef NONBE_1303_REND_GRANULARITY + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ +#endif ); ivas_error ivas_jbm_dec_tc_buffer_open( diff --git a/lib_com/options.h b/lib_com/options.h index 84ce770c97..c28d4b16e8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,7 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ #define NONBE_1289_STEREO_SW_TO_MONO /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */ +#define NONBE_1303_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 74ea4a34b8..95a32865d2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2127,7 +2127,11 @@ ivas_error ivas_init_decoder( } } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); +#else granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) @@ -2167,6 +2171,16 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + { + return error; + } +#else + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); @@ -2189,6 +2203,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2203,7 +2218,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2382,12 +2397,18 @@ ivas_error ivas_init_decoder( *-----------------------------------------------------------------*/ if ( st_ivas->hTcBuffer == NULL ) - { /* no module has yet open the TC buffer, open a default one */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), output_Fs ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#else n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0438755a31..15f2b72392 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -124,7 +124,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index df1be1d5b1..93202b94cf 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -403,7 +403,11 @@ ivas_error ivas_param_ism_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef NONBE_1303_REND_GRANULARITY + int16_t i, granularity; +#else int16_t i; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; IVAS_OUTPUT_SETUP hOutSetup; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -539,6 +543,9 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); +#endif if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { @@ -578,7 +585,11 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -591,7 +602,11 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; +#ifdef NONBE_1303_REND_GRANULARITY + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2376de298a..cdef1d6677 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2060,6 +2060,31 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef NONBE_1303_REND_GRANULARITY + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) +{ + int16_t render_granularity; + + if ( renderer_type == RENDERER_BINAURAL_OBJECTS_TD || /* TD renderer */ + renderer_type == RENDERER_BINAURAL_MIXER_CONV || renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM || /* Crend */ + renderer_type_sec == RENDERER_BINAURAL_OBJECTS_TD /* TD rend as a secondary renderer -> set the common granularity for both renderers */ + ) + { + /* 5 ms granularity */ + render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else + { + /* 1.25 ms granularity */ + render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + } + + return render_granularity; +} +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ @@ -2086,6 +2111,7 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 48c6f45571..d4b301408c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -727,7 +727,13 @@ ivas_error ivas_masa_dec_open( nchan_to_allocate++; } +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1474,7 +1480,11 @@ ivas_error ivas_masa_dec_reconfigure( TC_BUFFER_MODE buffer_mode_new; int16_t n_samples_granularity; +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -1491,7 +1501,9 @@ ivas_error ivas_masa_dec_reconfigure( } if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { +#ifndef NONBE_1303_REND_GRANULARITY n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ +#endif if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index e97adc27d1..98e2cdf5d4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -457,7 +457,13 @@ ivas_error ivas_param_mc_dec_open( if ( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 26a5124783..a6ecd68b2f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -391,7 +391,13 @@ ivas_error ivas_mc_paramupmix_dec_open( nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; } +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 164a245eaa..2a6970e227 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -795,7 +795,12 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { /* flush already done in IVAS_DEC_ReadFormat() */ diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index ac06064065..0476796816 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -479,3 +479,36 @@ void ivas_renderer_select( return; } + + +#ifdef NONBE_1303_REND_GRANULARITY +/*-------------------------------------------------------------------------* + * ivas_renderer_secondary_select() + * + * Select and configure IVAS secondary binaural renderer (used in combine formats) + *-------------------------------------------------------------------------*/ + +/*! r: secondary binaural renderer type */ +RENDERER_TYPE ivas_renderer_secondary_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + RENDERER_TYPE renderer_type; + AUDIO_CONFIG output_config; + + /* disabled by default */ + renderer_type = RENDERER_DISABLE; + output_config = st_ivas->hDecoderConfig->output_config; + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_BINAURAL ) + { + renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + + return renderer_type; +} +#endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index df7b021c9f..5b8ffbde8a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -194,6 +194,9 @@ ivas_error ivas_sba_dec_reconfigure( } /* determine new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /* this will change anyway only with binaural */ @@ -201,6 +204,7 @@ ivas_error ivas_sba_dec_reconfigure( { granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; } +#endif /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index e984b9251c..b256ae2af8 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -228,8 +228,10 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate += st_ivas->nchan_ism; } +#ifndef NONBE_1303_REND_GRANULARITY granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) ) { if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) @@ -249,6 +251,11 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate = 2 * BINAURAL_CHANNELS; } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -258,6 +265,7 @@ ivas_error ivas_spar_dec_open( } if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#endif ` { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7640228d3b..75356605a6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -919,7 +919,11 @@ ivas_error IVAS_DEC_ReadFormat( MC_MODE mc_mode_old; int16_t nchan_transport_old; AUDIO_CONFIG intern_config_old, transport_config_old, output_config; +#ifdef NONBE_1303_REND_GRANULARITY + RENDERER_TYPE renderer_type_old, renderer_type_sec_new, renderer_type_sec_old; +#else RENDERER_TYPE renderer_type_old; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -934,6 +938,9 @@ ivas_error IVAS_DEC_ReadFormat( intern_config_old = st_ivas->intern_config; transport_config_old = st_ivas->transport_config; renderer_type_old = st_ivas->renderer_type; +#ifdef NONBE_1303_REND_GRANULARITY + renderer_type_sec_old = ivas_renderer_secondary_select( st_ivas ); +#endif output_config = st_ivas->hDecoderConfig->output_config; @@ -956,6 +963,9 @@ ivas_error IVAS_DEC_ReadFormat( } ivas_renderer_select( st_ivas ); +#ifdef NONBE_1303_REND_GRANULARITY + renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); +#endif switch ( st_ivas->renderer_type ) { @@ -982,10 +992,17 @@ ivas_error IVAS_DEC_ReadFormat( } *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; +#ifdef NONBE_1303_REND_GRANULARITY + if ( renderer_type_sec_new == RENDERER_BINAURAL_OBJECTS_TD ) + { + *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; + } +#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_BINAURAL ) { *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } +#endif *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) @@ -1034,13 +1051,23 @@ ivas_error IVAS_DEC_ReadFormat( } } +#ifdef NONBE_1303_REND_GRANULARITY + if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || + ( renderer_type_sec_old != renderer_type_sec_new && renderer_type_sec_old != RENDERER_DISABLE ) ) +#else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) +#endif { /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); +#else int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif st_ivas->nchan_transport = nchan_transport_old; + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c5810cb6d3..50d62a7594 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -151,6 +151,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; } +#ifdef NONBE_1303_REND_GRANULARITY + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + renderer_type = st_ivas->renderer_type; + +#endif for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; @@ -169,10 +175,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( hDiracDecBin->phHrtfParambin = NULL; } +#ifndef NONBE_1303_REND_GRANULARITY output_Fs = st_ivas->hDecoderConfig->output_Fs; nBins = st_ivas->hSpatParamRendCom->num_freq_bands; renderer_type = st_ivas->renderer_type; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) @@ -324,11 +331,15 @@ ivas_error ivas_dirac_dec_init_binaural_data( nchan_to_allocate = BINAURAL_CHANNELS + st_ivas->nchan_ism; } +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); +#else ` n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } +#endif if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { -- GitLab From b1f36ecaaab589407e3ba8ee48ed3766fa8d0dac Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 17:54:57 +0100 Subject: [PATCH 09/42] fix --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 95a32865d2..c51a7c4c46 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2403,7 +2403,7 @@ ivas_error ivas_init_decoder( granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), output_Fs ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) #else n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); -- GitLab From 1f6221c0e7cace329ca1ec90ddad5a8024f459a6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 18:12:03 +0100 Subject: [PATCH 10/42] fix warnings --- lib_dec/ivas_masa_dec.c | 5 ++++- lib_dec/ivas_mc_param_dec.c | 5 ++++- lib_dec/ivas_mc_paramupmix_dec.c | 5 ++++- lib_dec/ivas_sba_dec.c | 2 ++ lib_dec/ivas_spar_decoder.c | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index d4b301408c..395cd39596 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -696,6 +696,9 @@ ivas_error ivas_masa_dec_open( if ( st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { int16_t nchan_to_allocate, nchan_transport; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -728,7 +731,7 @@ ivas_error ivas_masa_dec_open( } #ifdef NONBE_1303_REND_GRANULARITY - int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 98e2cdf5d4..048f26e379 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -437,6 +437,9 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; if ( st_ivas->hDecoderConfig->Opt_tsm ) @@ -458,7 +461,7 @@ ivas_error ivas_param_mc_dec_open( if ( st_ivas->hTcBuffer == NULL ) { #ifdef NONBE_1303_REND_GRANULARITY - int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index a6ecd68b2f..81bd4023a4 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -374,6 +374,9 @@ ivas_error ivas_mc_paramupmix_dec_open( { int16_t nchan_to_allocate; int16_t nchan_tc; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -392,7 +395,7 @@ ivas_error ivas_mc_paramupmix_dec_open( } #ifdef NONBE_1303_REND_GRANULARITY - int16_t granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5b8ffbde8a..6f0b4e3c43 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -163,6 +163,7 @@ ivas_error ivas_sba_dec_reconfigure( /* we may need to flush only for binaural and OSBA and TSM */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifndef NONBE_1303_REND_GRANULARITY RENDERER_TYPE renderer_type_new; int16_t sba_order_internal; @@ -193,6 +194,7 @@ ivas_error ivas_sba_dec_reconfigure( } } +#endif /* determine new granularity */ #ifdef NONBE_1303_REND_GRANULARITY granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b256ae2af8..205bc77859 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -265,7 +265,7 @@ ivas_error ivas_spar_dec_open( } if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) -#endif ` +#endif { return error; } -- GitLab From 452c31553b28f1465221a1b2afb6ba0e183fa203 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 18:17:37 +0100 Subject: [PATCH 11/42] fix --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c51a7c4c46..28a1554ff0 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2400,7 +2400,7 @@ ivas_error ivas_init_decoder( { /* no module has yet open the TC buffer, open a default one */ #ifdef NONBE_1303_REND_GRANULARITY - granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), output_Fs ); + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) -- GitLab From 183958b62ce325d041ac00e8e42140a82c50cbf3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 18:22:10 +0100 Subject: [PATCH 12/42] cleaning --- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 50d62a7594..3be1a116d7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -333,7 +333,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( #ifdef NONBE_1303_REND_GRANULARITY n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); -#else ` +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { -- GitLab From c582f3082ad178b6d729c315a3078a9390b5268e Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 19:05:46 +0100 Subject: [PATCH 13/42] simplification --- lib_dec/ivas_init_dec.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 28a1554ff0..aac6720870 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2126,18 +2126,16 @@ ivas_error ivas_init_decoder( return error; } } +#ifndef NONBE_1303_REND_GRANULARITY -#ifdef NONBE_1303_REND_GRANULARITY - granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); -#else granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2170,16 +2168,7 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; - -#ifdef NONBE_1303_REND_GRANULARITY - granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) - { - return error; - } -#else +#ifndef NONBE_1303_REND_GRANULARITY if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { -- GitLab From 134ce55e68724c8ee3e9c867f3181cb07859ef96 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 19:35:07 +0100 Subject: [PATCH 14/42] call ivas_jbm_dec_set_discard_samples() at one common place --- lib_dec/ivas_ism_dec.c | 7 +++++-- lib_dec/ivas_masa_dec.c | 2 ++ lib_dec/ivas_mct_dec.c | 6 +++++- lib_dec/ivas_sba_dec.c | 12 ++++++++++++ lib_dec/lib_dec.c | 12 +++++++++++- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 15f2b72392..7752b2f96e 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -122,6 +122,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ #ifdef NONBE_1303_REND_GRANULARITY @@ -142,7 +143,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } - +#endif if ( st_ivas->ism_mode != last_ism_mode ) { /* EFAP handle */ @@ -310,7 +311,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; - +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 395cd39596..2ab0291e73 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1502,6 +1502,7 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } +#ifndef NONBE_1303_REND_GRANULARITY if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { #ifndef NONBE_1303_REND_GRANULARITY @@ -1522,6 +1523,7 @@ ivas_error ivas_masa_dec_reconfigure( /* flush already done in IVAS_DEC_ReadFormat() */ } } +#endif } else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 2a6970e227..c1aa1870f4 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -793,6 +793,7 @@ static ivas_error ivas_mc_dec_reconfig( } } +#ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ #ifdef NONBE_1303_REND_GRANULARITY @@ -813,7 +814,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - +#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); @@ -1300,6 +1301,9 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6f0b4e3c43..2eb2ee17f2 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -208,6 +208,17 @@ ivas_error ivas_sba_dec_reconfigure( } #endif +#ifdef NONBE_1303_REND_GRANULARITY + if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + /* make sure the changed number of slots in the last subframe is not lost in the following steps */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } + st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } +#else /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -227,6 +238,7 @@ ivas_error ivas_sba_dec_reconfigure( } st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; } +#endif } /* save old */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 75356605a6..4485ff6b72 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1053,7 +1053,7 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef NONBE_1303_REND_GRANULARITY if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( renderer_type_sec_old != renderer_type_sec_new && renderer_type_sec_old != RENDERER_DISABLE ) ) + ( renderer_type_sec_old != renderer_type_sec_new ) ) #else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) @@ -1075,6 +1075,16 @@ ivas_error IVAS_DEC_ReadFormat( return error; } } +#ifdef NONBE_1303_REND_GRANULARITY + /* 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 ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } } -- GitLab From aa7f453906bc7b868c2b7e124132622e533fd1b1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 22 Mar 2025 20:10:38 +0100 Subject: [PATCH 15/42] fix (avoid the adjustment in the very first frame) --- lib_dec/lib_dec.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4485ff6b72..831a65b101 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1053,21 +1053,17 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef NONBE_1303_REND_GRANULARITY if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( renderer_type_sec_old != renderer_type_sec_new ) ) -#else - if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) -#endif + ( renderer_type_sec_old != renderer_type_sec_new && st_ivas->ini_active_frame > 0 ) ) { - /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv - render what still fits in the new granularity */ -#ifdef NONBE_1303_REND_GRANULARITY int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); -#else - int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); -#endif st_ivas->nchan_transport = nchan_transport_old; + if ( st_ivas->hTcBuffer == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* JBM: when granularity goes down, render what still fits in the new granularity */ if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) @@ -1075,8 +1071,7 @@ ivas_error IVAS_DEC_ReadFormat( return error; } } -#ifdef NONBE_1303_REND_GRANULARITY - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + /* JBM: when granularity goes up, discard samples at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1084,6 +1079,22 @@ ivas_error IVAS_DEC_ReadFormat( return error; } } +#else + if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || + ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) + { + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv + render what still fits in the new granularity */ + int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + st_ivas->nchan_transport = nchan_transport_old; + + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + } #endif } } -- GitLab From efa4d76523bc00c4f1df432fad122e074d2ff46e Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 23 Mar 2025 10:06:48 +0100 Subject: [PATCH 16/42] add comments --- lib_dec/ivas_output_config.c | 2 +- lib_dec/lib_dec.c | 64 ++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 0476796816..305d99ef99 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -485,7 +485,7 @@ void ivas_renderer_select( /*-------------------------------------------------------------------------* * ivas_renderer_secondary_select() * - * Select and configure IVAS secondary binaural renderer (used in combine formats) + * Select IVAS secondary binaural renderer (used in combine formats) *-------------------------------------------------------------------------*/ /*! r: secondary binaural renderer type */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 831a65b101..e3e9176e7d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -896,6 +896,49 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return IVAS_ERR_OK; } +#ifdef NONBE_1303_REND_GRANULARITY + +/*---------------------------------------------------------------------* + * renderer_type_to_mode() + * + * Convert (codec library) renderer type to (API public) binaural renderer mode + *---------------------------------------------------------------------*/ + +/*! r: binaural renderer mode (API type) */ +static IVAS_BIN_RENDERER_TYPE renderer_type_to_mode( + const RENDERER_TYPE renderer_type /* i : renderer type (codec library type) */ +) +{ + IVAS_BIN_RENDERER_TYPE binaural_renderer; + + switch ( renderer_type ) + { + case RENDERER_BINAURAL_OBJECTS_TD: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_TDREND; + break; + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_CREND; + break; + case RENDERER_BINAURAL_FASTCONV: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; + break; + case RENDERER_BINAURAL_FASTCONV_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; + break; + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_PARAMBIN; + break; + default: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; + break; + } + + return binaural_renderer; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_ReadFormat( ) @@ -962,11 +1005,15 @@ ivas_error IVAS_DEC_ReadFormat( return ( IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "IVAS format switching is not allowed." ) ); } + /* Select binaural renderer */ ivas_renderer_select( st_ivas ); #ifdef NONBE_1303_REND_GRANULARITY - renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); -#endif + *binaural_renderer = renderer_type_to_mode( st_ivas->renderer_type ); + /* Select secondary binaural renderer (used in combine formats) */ + renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); + *binaural_renderer_sec = renderer_type_to_mode( renderer_type_sec_new ); +#else switch ( st_ivas->renderer_type ) { case RENDERER_BINAURAL_OBJECTS_TD: @@ -1002,8 +1049,10 @@ ivas_error IVAS_DEC_ReadFormat( { *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } +#endif #endif + /* select HRTF audio configuration to load the right HRTF set for the external binary file */ *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { @@ -1052,10 +1101,13 @@ ivas_error IVAS_DEC_ReadFormat( } #ifdef NONBE_1303_REND_GRANULARITY - if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( renderer_type_sec_old != renderer_type_sec_new && st_ivas->ini_active_frame > 0 ) ) + /* JBM: handle cases when binaural renderer granularity changes (happens in bitrate switching) */ + if ( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm && + ( ( renderer_type_old != st_ivas->renderer_type ) || + ( renderer_type_sec_old != renderer_type_sec_new ) ) ) { int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); + st_ivas->nchan_transport = nchan_transport_old; if ( st_ivas->hTcBuffer == NULL ) @@ -1063,7 +1115,7 @@ ivas_error IVAS_DEC_ReadFormat( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - /* JBM: when granularity goes down, render what still fits in the new granularity */ + /* when granularity goes down, render what still fits in the new granularity */ if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) @@ -1071,7 +1123,7 @@ ivas_error IVAS_DEC_ReadFormat( return error; } } - /* JBM: when granularity goes up, discard samples at the beginning of the frame */ + /* when granularity goes up, discard samples at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) -- GitLab From becf4c0d7b2fde8dea52f614ecd9cb628a8d296a Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 23 Mar 2025 12:25:23 +0100 Subject: [PATCH 17/42] cleaning --- lib_dec/ivas_ism_dec.c | 4 ---- lib_dec/ivas_masa_dec.c | 3 +-- lib_dec/ivas_mct_dec.c | 4 ---- lib_dec/lib_dec.c | 9 +-------- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 7752b2f96e..e7c793caf3 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -125,11 +125,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( #ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ -#ifdef NONBE_1303_REND_GRANULARITY - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); -#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); -#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2ab0291e73..62e711718a 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1505,9 +1505,8 @@ ivas_error ivas_masa_dec_reconfigure( #ifndef NONBE_1303_REND_GRANULARITY if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { -#ifndef NONBE_1303_REND_GRANULARITY n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ -#endif + if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index c1aa1870f4..0ec1514eaa 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -796,11 +796,7 @@ static ivas_error ivas_mc_dec_reconfig( #ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ -#ifdef NONBE_1303_REND_GRANULARITY - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); -#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); -#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e3e9176e7d..5bc5993ea2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1039,17 +1039,10 @@ ivas_error IVAS_DEC_ReadFormat( } *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; -#ifdef NONBE_1303_REND_GRANULARITY - if ( renderer_type_sec_new == RENDERER_BINAURAL_OBJECTS_TD ) - { - *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; - } -#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_BINAURAL ) { *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } -#endif #endif /* select HRTF audio configuration to load the right HRTF set for the external binary file */ @@ -1101,7 +1094,7 @@ ivas_error IVAS_DEC_ReadFormat( } #ifdef NONBE_1303_REND_GRANULARITY - /* JBM: handle cases when binaural renderer granularity changes (happens in bitrate switching) */ + /* JBM: compensate when binaural renderer granularity changes (happens in bitrate switching) */ if ( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm && ( ( renderer_type_old != st_ivas->renderer_type ) || ( renderer_type_sec_old != renderer_type_sec_new ) ) ) -- GitLab From ba12394a2263bf8fe4bbba6a32f5991b0f6cedb9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Mar 2025 13:51:35 +0100 Subject: [PATCH 18/42] remove ToDo commented temporary code; under NONBE_1303_REND_GRANULARITY --- lib_dec/ivas_objectRenderer_internal.c | 4 ++++ lib_dec/lib_dec.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index d20c793304..d64720c44a 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -61,9 +61,13 @@ ivas_error ivas_td_binaural_open( num_src = st_ivas->nchan_ism; } +#ifdef NONBE_1303_REND_GRANULARITY + if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary ) +#else if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary && ( st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 ) +#endif { return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5bc5993ea2..ddb88420cc 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2968,9 +2968,13 @@ ivas_error IVAS_DEC_HRTF_binary_close( if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && st_ivas->ini_frame > 0 ) { +#ifdef NONBE_1303_REND_GRANULARITY + if ( !( binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) +#else if ( !( binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && ( hIvasDec->st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 ) +#endif { ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); } -- GitLab From 0ace592b45aa66bbece12250ee6b33df4dbc70d4 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 1 Apr 2025 17:21:29 +1100 Subject: [PATCH 19/42] fix for split rendering and non-split rendering cases, output zeros for initial bad frames --- apps/isar_post_rend.c | 21 +++++++++++++++++++++ lib_dec/lib_dec.c | 19 ++++++++++++------- lib_isar/lib_isar_post_rend.c | 11 +++++++++++ lib_util/split_render_file_read_write.c | 16 ++++++++++++++++ lib_util/split_render_file_read_write.h | 9 +++++++++ 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index bcadc691fb..2aff9b6a3d 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -985,6 +985,9 @@ int main( while ( 1 ) { +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + int16_t bfi = 0; +#endif int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; @@ -993,7 +996,11 @@ int main( { ivas_error error_tmp; numSamplesRead = (int16_t) inBufferSize; +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten, &bfi ); +#else error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ); +#endif if ( error_tmp != IVAS_ERR_OK ) { if ( error_tmp == IVAS_ERR_END_OF_FILE ) @@ -1060,19 +1067,33 @@ int main( /* Read from split renderer bfi file if specified */ if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) { +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST int16_t bfi; +#endif if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } +#endif } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( splitBinNeedsNewFrame ) + { + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } +#endif for ( i = 0; i < args.inConfig.numBinBuses; ++i ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 50e00cc381..bfd7920c3d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1758,9 +1758,14 @@ ivas_error IVAS_DEC_GetSamplesRenderer( { *needNewFrame = false; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + *nOutSamples = nSamplesRendered; +#endif } +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST *nOutSamples = nSamplesRendered; +#endif return IVAS_ERR_OK; } @@ -1805,13 +1810,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - return IVAS_ERR_OK; - } -#endif - error = IVAS_ERR_OK; st_ivas = hIvasDec->st_ivas; output_config = st_ivas->hDecoderConfig->output_config; @@ -1871,6 +1869,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return error; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + /* change buffer layout */ for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) { diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 8709ce9b83..7e050abc06 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1539,6 +1539,17 @@ static ivas_error renderSplitBinauralWithPostRot( } else { +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( splitBinInput->numCachedSamples == 0 ) + { + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outAudio.config.numSamplesPerChannel; + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + } + else + { + splitBinInput->numCachedSamples -= outAudio.config.numSamplesPerChannel; + } +#endif if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index e0c7df92d6..9cc6e4bf7e 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -331,11 +331,20 @@ ivas_error split_rend_write_bitstream_to_file( * *-----------------------------------------------------------------------------------------*/ +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written, + int16_t *bfi ) +#else ivas_error split_rend_read_bits_from_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, int32_t *bits_read, int32_t *bits_written ) +#endif { char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; @@ -398,6 +407,13 @@ ivas_error split_rend_read_bits_from_file( *bits_read = 0; *bits_written = bit_len; +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + *bfi = 0; + if ( bit_len == 0 ) + { + *bfi = 1; + } +#endif return IVAS_ERR_OK; } diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 1362ce1226..4450eeded4 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -73,11 +73,20 @@ ivas_error split_rend_write_bitstream_to_file( int32_t *bits_written ); /* read split rend coded bits from file */ +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written, + int16_t *bfi ); +#else ivas_error split_rend_read_bits_from_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, int32_t *bits_read, int32_t *bits_written ); +#endif /* read split pre rend delay */ ivas_error split_rend_read_pre_rend_delay_ns( -- GitLab From 084a523e0d364f104fd1970a4ebf774eb76b4ab2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 10:38:22 +0200 Subject: [PATCH 20/42] correction and simplification of lib_dec.c; under LIB_DEC_REVISION --- apps/decoder.c | 4 ++ lib_com/options.h | 1 + lib_dec/lib_dec.c | 118 +++++++++++++++++++++++++++++++++++++++++----- lib_dec/lib_dec.h | 3 ++ 4 files changed, 113 insertions(+), 13 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f35d12fd0d..993150cee7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -259,7 +259,11 @@ int main( * Open decoder handle *------------------------------------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION + if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.output_Fs, arg.decMode ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_com/options.h b/lib_com/options.h index 92a2e7a0f8..e1cf3d987b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,6 +163,7 @@ #define FIX_1285_RENDER_CONFIG_PTR_COMPARE /* Philips: Warning about pointer comparison in the render config reader */ #define FIX_1298_MEMORY_OPT_IVAS_CORE_ENC /* VA: issue 1298: Memory saving in ivas_core_enc() */ #define SIMPLIFY_IVAS_CORE /* VA: simplify ivas core coder functions */ +#define LIB_DEC_REVISION /* VA: correction and simplification of lib_dec.c */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 52c50f0140..c9dbf21f20 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -55,7 +55,9 @@ struct IVAS_DEC_VOIP { +#ifndef LIB_DEC_REVISION uint16_t nSamplesFrame; /* Total number of samples in a frame (includes number of channels) */ +#endif JB4_HANDLE hJBM; uint16_t lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ @@ -90,7 +92,9 @@ struct IVAS_DEC bool hasBeenFedFrame; bool updateOrientation; uint16_t nSamplesAvailableNext; +#ifndef LIB_DEC_REVISION int16_t nSamplesRendered; +#endif int16_t nTransportChannelsOld; int16_t amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ int16_t sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ @@ -119,8 +123,10 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uin static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels ); static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); +#ifndef LIB_DEC_REVISION static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); +#endif static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType ); static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); @@ -141,7 +147,10 @@ static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nS /* may return an error but may still have allocated memory - thus run Close also in case of error to release memory */ ivas_error IVAS_DEC_Open( IVAS_DEC_HANDLE *phIvasDec, /* i/o: pointer to an IVAS decoder handle to be opened */ - const IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ +#ifdef LIB_DEC_REVISION + const int32_t output_Fs, /* i : output sampling frequency */ +#endif + const IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ ) { IVAS_DEC_HANDLE hIvasDec; @@ -171,8 +180,12 @@ ivas_error IVAS_DEC_Open( hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; +#ifdef LIB_DEC_REVISION + hIvasDec->nSamplesFrame = (uint16_t) ( output_Fs / FRAMES_PER_SEC ); +#else hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesFrame = 0; +#endif hIvasDec->hasBeenFedFrame = false; hIvasDec->hasBeenFedFirstGoodFrame = false; hIvasDec->hasDecodedFirstGoodFrame = false; @@ -522,6 +535,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; @@ -540,7 +554,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } - +#endif return IVAS_ERR_OK; } @@ -770,7 +784,9 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; +#ifndef LIB_DEC_REVISION hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -896,7 +912,9 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->needNewFrame = false; hIvasDec->hasBeenFedFrame = true; +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; +#endif hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; return IVAS_ERR_OK; @@ -1658,9 +1676,12 @@ ivas_error IVAS_DEC_GetSamplesRenderer( ) { ivas_error error; +#ifndef LIB_DEC_REVISION int16_t nSamplesToRender; +#endif uint16_t nSamplesRendered, nSamplesRendered_loop; uint8_t nOutChannels; + Decoder_Struct *st_ivas; nSamplesRendered = 0; nOutChannels = 0; @@ -1677,13 +1698,15 @@ ivas_error IVAS_DEC_GetSamplesRenderer( return IVAS_ERR_UNKNOWN; } + st_ivas = hIvasDec->st_ivas; + if ( hIvasDec->updateOrientation ) { /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ - if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) { return error; } @@ -1692,9 +1715,9 @@ ivas_error IVAS_DEC_GetSamplesRenderer( * Binaural split rendering setup *----------------------------------------------------------------*/ - if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( st_ivas->hCombinedOrientationData != NULL && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); + isar_set_split_rend_ht_setup( &st_ivas->hSplitBinRend->splitrend, st_ivas->hCombinedOrientationData->Quaternions, st_ivas->hCombinedOrientationData->Rmat ); } hIvasDec->updateOrientation = false; @@ -1710,38 +1733,59 @@ ivas_error IVAS_DEC_GetSamplesRenderer( } /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ - if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) + if ( !hIvasDec->isInitialized && st_ivas->bfi ) { hIvasDec->hasBeenFedFrame = false; - set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); + set_s( pcmBuf, 0, st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); +#ifdef LIB_DEC_REVISION + nSamplesRendered = nSamplesAsked; +#else hIvasDec->nSamplesRendered += nSamplesAsked; *nOutSamples = nSamplesAsked; +#endif hIvasDec->nSamplesAvailableNext -= nSamplesAsked; +#ifndef LIB_DEC_REVISION if ( hIvasDec->nSamplesAvailableNext == 0 ) { hIvasDec->needNewFrame = true; *needNewFrame = true; } +#endif } else { - nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; + nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; + /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { +#ifndef LIB_DEC_REVISION void *pPcmBuffer; +#endif #ifdef DEBUGGING assert( hIvasDec->pcmType == pcmType ); #endif +#ifdef LIB_DEC_REVISION + /* note: offset (rendered samples) is always 0 */ +#else pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); +#endif if ( pcmType == IVAS_DEC_PCM_INT16 ) { +#ifdef LIB_DEC_REVISION + mvs2s( (int16_t *) hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); +#else mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); +#endif } else if ( pcmType == IVAS_DEC_PCM_FLOAT ) { +#ifdef LIB_DEC_REVISION + mvr2r( (float *) hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); +#else mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); +#endif } #ifdef DEBUGGING else @@ -1749,18 +1793,27 @@ ivas_error IVAS_DEC_GetSamplesRenderer( assert( 0 && "wrong PCM type for the flush buffer!" ); } #endif +#ifdef LIB_DEC_REVISION + nSamplesRendered = hIvasDec->nSamplesFlushed; +#else nSamplesRendered += hIvasDec->nSamplesFlushed; +#endif hIvasDec->nSamplesFlushed = 0; } /* render IVAS frames directly to the output buffer */ +#ifdef LIB_DEC_REVISION + if ( ( error = ivas_jbm_dec_render( st_ivas, nSamplesAsked - nSamplesRendered, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#else nSamplesToRender = nSamplesAsked - nSamplesRendered; if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#endif { return error; } nSamplesRendered += nSamplesRendered_loop; +#ifndef LIB_DEC_REVISION nSamplesToRender -= nSamplesRendered_loop; if ( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -1773,11 +1826,26 @@ ivas_error IVAS_DEC_GetSamplesRenderer( } #ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST *nOutSamples = nSamplesRendered; +#endif #endif } +#ifdef LIB_DEC_REVISION + if ( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + } + else + { + *needNewFrame = false; + } + + *nOutSamples = nSamplesRendered; +#else #ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST *nOutSamples = nSamplesRendered; +#endif #endif return IVAS_ERR_OK; @@ -2146,7 +2214,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( return IVAS_ERR_OK; } - +#ifndef LIB_DEC_REVISION /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * @@ -2205,7 +2273,7 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * IVAS_DEC_GetNumObjects( ) @@ -3561,17 +3629,25 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesBuffered = 0; if ( hIvasDec->hasBeenFedFirstGoodFrame ) { +#ifdef LIB_DEC_REVISION + /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ + if ( st_ivas->hTcBuffer != NULL ) + { + nSamplesBuffered = st_ivas->hTcBuffer->n_samples_buffered - st_ivas->hTcBuffer->n_samples_rendered; + nSamplesBuffered += hVoIP->nSamplesRendered20ms; + } +#else if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) { return error; } +#endif } extBufferedSamples = nSamplesBuffered; extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; - /* pop one access unit from the jitter buffer */ result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); if ( result != 0 ) @@ -3671,7 +3747,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; +#endif } } @@ -3683,8 +3761,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); *nSamplesRendered += nSamplesToZero; - +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered += nSamplesToZero; +#endif hIvasDec->nSamplesAvailableNext -= nSamplesToZero; update_voip_rendered20ms( hIvasDec, nSamplesToZero ); } @@ -3741,7 +3820,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * - * Function to flush remaining audio in VoIP + * Return number of samples that have been rendered since the last 20ms render border *---------------------------------------------------------------------*/ static void update_voip_rendered20ms( @@ -3753,12 +3832,20 @@ static void update_voip_rendered20ms( nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; /* we have crossed a 20ms border, reset the time scaling done flag */ +#ifdef LIB_DEC_REVISION + if ( nSamplesRenderedTotal >= hIvasDec->nSamplesFrame ) +#else if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) +#endif { hIvasDec->timeScalingDone = 0; } +#ifdef LIB_DEC_REVISION + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->nSamplesFrame; +#else hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; +#endif return; } @@ -3795,12 +3882,17 @@ ivas_error IVAS_DEC_Flush( error = IVAS_ERR_OK; if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) { +#ifdef LIB_DEC_REVISION + error = ivas_jbm_dec_render( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); +#else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); +#endif } else { *nSamplesFlushed = 0; } + return error; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index bfe6dd6e0b..de74494d03 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -114,6 +114,9 @@ typedef ivas_error ( *JbmTraceFileWriterFn )( const void *data, void *writer ); /*! r: error code */ ivas_error IVAS_DEC_Open( IVAS_DEC_HANDLE *phIvasDec, /* i/o: pointer to an IVAS decoder handle to be opened */ +#ifdef LIB_DEC_REVISION + const int32_t output_Fs, /* i : output sampling frequency */ +#endif IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ ); -- GitLab From 437b101841ef793ebdb1519c676aa5b631755d3b Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 10:44:47 +0200 Subject: [PATCH 21/42] fix --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c9dbf21f20..f81dfe8785 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3883,7 +3883,7 @@ ivas_error IVAS_DEC_Flush( if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) { #ifdef LIB_DEC_REVISION - error = ivas_jbm_dec_render( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); + error = ivas_jbm_dec_render( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); #else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); #endif -- GitLab From 4ff7c9c28671e52320245013d66ce92fd39e29bd Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 15:20:19 +0200 Subject: [PATCH 22/42] more updates --- apps/decoder.c | 12 ++- lib_com/options.h | 4 +- lib_dec/lib_dec.c | 235 +++++++++++++++++++++++++++++++++++++++------- lib_dec/lib_dec.h | 3 + 4 files changed, 215 insertions(+), 39 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 993150cee7..1d5e4f9419 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -449,8 +449,14 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#ifdef LIB_DEC_REVISION + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.voipMode, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, + arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, + arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1055,18 +1061,18 @@ static bool parseCmdlIVAS_dec( if ( strcmp( argv_to_upper, "-VOIP" ) == 0 ) { - arg->voipMode = 1; + arg->voipMode = true; i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=0" ) == 0 ) { - arg->voipMode = 1; + arg->voipMode = true; arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP; i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=1" ) == 0 ) { - arg->voipMode = 1; + arg->voipMode = true; arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF; i++; } diff --git a/lib_com/options.h b/lib_com/options.h index e1cf3d987b..0eee0b8b5a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +#define DEBUGGING /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -132,7 +132,7 @@ /*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */ /*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ /*#define DEBUG_JBM_CMD_OPTION*/ /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ -/*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ +#define VARIABLE_SPEED_DECODING /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ /*#define DISABLE_LIMITER*/ /* disable the limiter */ /*Split Rendering Debug switches*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f81dfe8785..fe761cc023 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -116,14 +116,21 @@ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); #ifdef SUPPORT_JBM_TRACEFILE static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif +#ifdef LIB_DEC_REVISION +static ivas_error evs_dec_main( Decoder_Struct *st_ivas, float *floatBuf, int16_t *pcmBuf ); +#else static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); +#endif static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); +#ifdef LIB_DEC_REVISION +static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, uint8_t *nTransportChannels, const int16_t isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error apa_setup( IVAS_DEC_HANDLE hIvasDec, const bool isInitialized_voip, const uint16_t nTransportChannels ); +#else static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels ); static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); -#ifndef LIB_DEC_REVISION static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); #endif @@ -426,9 +433,12 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint32_t sampleRate, /* i : output sampling frequency */ - const AUDIO_CONFIG outputConfig, /* i : output configuration */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint32_t sampleRate, /* i : output sampling frequency */ + const AUDIO_CONFIG outputConfig, /* i : output configuration */ +#ifdef LIB_DEC_REVISION + const bool voipMode, /* i : enable VoIP mode with JBM */ +#endif const bool tsmEnabled, /* i : enable TSM */ const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ @@ -542,9 +552,14 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; - - /* init flush buffer if necessary (only needed for binaural)*/ +#endif +#ifdef LIB_DEC_REVISION + /* Create flush buffer - needed for binaural outputs with TSM or in VoIP mode */ + if ( ( tsmEnabled || voipMode ) && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#else + /* Init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); if ( hIvasDec->flushbuffer == NULL ) @@ -554,7 +569,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } -#endif + return IVAS_ERR_OK; } @@ -816,6 +831,7 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif +#ifndef LIB_DEC_REVISION /* init flush buffer if necessary (only needed for binaural)*/ if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { @@ -823,7 +839,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } - +#endif return IVAS_ERR_OK; } @@ -1096,7 +1112,7 @@ ivas_error IVAS_DEC_ReadFormat( /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesDecoder( ) * - * Main function to decode transport channels, do TSM and feed to renderer. + * Main function to run setup, decode transport channels, do TSM and feed to renderer. *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSamplesDecoder( @@ -1106,6 +1122,13 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ) { ivas_error error; + Decoder_Struct *st_ivas; +#ifdef LIB_DEC_REVISION + uint16_t nTimeScalerOutSamples; + uint8_t nTransportChannels; + int16_t nResidualSamples, nSamplesTcsScaled; + bool isInitialized_voip; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -1119,17 +1142,27 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } #endif - /* If TSM is generally enabled, we have to wait for the first good frame. - Otherwise, we directly decode the first frame in any case. */ - if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + st_ivas = hIvasDec->st_ivas; +#ifdef LIB_DEC_REVISION + isInitialized_voip = hIvasDec->isInitialized; +#endif + + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ { +#ifdef LIB_DEC_REVISION + /* Setup all decoder parts (IVAS decoder, ISAR) */ + if ( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } +#else uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels; int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; if ( isSplitRend ) { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + if ( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } @@ -1140,23 +1173,58 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return error; } - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) + if ( st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) { return error; } } +#endif /* IVAS TC decoder */ +#ifdef LIB_DEC_REVISION + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( ( error = evs_dec_main( st_ivas, hIvasDec->apaExecBuffer, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) + { + if ( ( error = ivas_jbm_dec_tc( st_ivas, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ + } + + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->hasDecodedFirstGoodFrame = true; + } +#else if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } +#endif /* JBM */ - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#ifdef LIB_DEC_REVISION + if ( nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( ( error = apa_setup( hIvasDec, isInitialized_voip, nTransportChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -1177,12 +1245,16 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* Feed decoded transport channels samples to the renderer */ +#ifdef LIB_DEC_REVISION + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ); +#else if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } +#endif - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) @@ -1195,15 +1267,16 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + /* set edited metadata */ + if ( st_ivas->hIsmMetaData[0] ) { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { int16_t obj; - ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + ISM_METADATA_HANDLE *hIsmMetaData = st_ivas->hIsmMetaData; + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; @@ -1213,21 +1286,21 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIsmMetaData[obj]->edited_gain = 1.0f; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + st_ivas->hSbaIsmData->gain_bed = 1.0f; } } } } - if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + if ( st_ivas->hParamIsmDec != NULL ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + PARAM_ISM_DEC_HANDLE hParamIsmDec = st_ivas->hParamIsmDec; + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; @@ -1339,7 +1412,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = st_ivas->hIsmMetaData[obj]->radius; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].gain = st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -1366,7 +1439,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = st_ivas->hIsmMetaData[obj]->radius; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].gain = st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -1915,8 +1988,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; @@ -2059,6 +2132,23 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } +#ifdef LIB_DEC_REVISION +/*---------------------------------------------------------------------* + * ivas_dec_setup_all() + * + * Set-up all decoder parts: IVAS decoder, ISAR + *---------------------------------------------------------------------*/ + +static ivas_error ivas_dec_setup_all( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifndef LIB_DEC_REVISION + uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ +#endif + uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +#else /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * @@ -2070,6 +2160,7 @@ static ivas_error IVAS_DEC_Setup( uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ uint8_t *nTransportChannels /* o : number of decoded transport PCM channels */ ) +#endif { ivas_error error; @@ -2090,6 +2181,16 @@ static ivas_error IVAS_DEC_Setup( st_ivas = hIvasDec->st_ivas; +#ifdef LIB_DEC_REVISION + /* Setup IVAS split rendering */ + if ( isSplitRend ) + { + if ( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling @@ -2107,14 +2208,40 @@ static ivas_error IVAS_DEC_Setup( } *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; +#ifndef LIB_DEC_REVISION *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; +#endif + +#ifdef LIB_DEC_REVISION + /* allocate/reallocte APA buffer */ + // ToDo: this memory should be harmonized with st_ivas->p_output_f[] and st_ivas->hTcBuffer->tc_buffer[] - see issue #104 + // ToDo: this part is also related to cleaning of NONBE_UNIFIED_DECODING_PATHS leftovers (see MR !1246) + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && *nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( hIvasDec->apaExecBuffer != NULL ) + { + free( hIvasDec->apaExecBuffer ); + } + + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * *nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } + set_zero( hIvasDec->apaExecBuffer, APA_BUF_PER_CHANNEL * *nTransportChannels ); + } +#endif /*-----------------------------------------------------------------* * ISAR: * - initialize ISAR handle at the first frame * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) *-----------------------------------------------------------------*/ + +#ifdef LIB_DEC_REVISION + if ( st_ivas->ini_frame == 0 && isSplitRend ) +#else if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) +#endif { if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) { @@ -2134,7 +2261,7 @@ static ivas_error IVAS_DEC_Setup( return IVAS_ERR_OK; } - +#ifndef LIB_DEC_REVISION /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -2214,7 +2341,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( return IVAS_ERR_OK; } -#ifndef LIB_DEC_REVISION + /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * @@ -3779,7 +3906,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; - if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -4341,7 +4468,9 @@ void IVAS_DEC_PrintDisclaimer( void ) static ivas_error evs_dec_main( Decoder_Struct *st_ivas, +#ifndef LIB_DEC_REVISION const int16_t nOutSamples, +#endif float *floatBuf, int16_t *pcmBuf ) { @@ -4349,6 +4478,9 @@ static ivas_error evs_dec_main( float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; int16_t ch; +#ifdef LIB_DEC_REVISION + int16_t nOutSamples; +#endif ivas_error error; hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; @@ -4405,6 +4537,10 @@ static ivas_error evs_dec_main( } st_ivas->BER_detect = hCoreCoder[0]->BER_detect; +#ifdef LIB_DEC_REVISION + + nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { @@ -4637,6 +4773,18 @@ static ivas_error input_format_API_to_internal( } +#ifdef LIB_DEC_REVISION +/*---------------------------------------------------------------------* + * apa_setup() + * + * Setup APA decoder + *---------------------------------------------------------------------*/ + +static ivas_error apa_setup( + IVAS_DEC_HANDLE hIvasDec, + const bool isInitialized_voip, + const uint16_t nTransportChannels ) +#else /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_reconfigure() * @@ -4647,22 +4795,35 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) +#endif { +#ifdef LIB_DEC_REVISION + uint16_t l_ts; + + l_ts = (uint16_t) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; + + if ( isInitialized_voip == false ) +#else int16_t apa_buffer_size; apa_buffer_size = hIvasDec->nSamplesFrame; if ( hIvasDec->apaExecBuffer == NULL ) +#endif { DECODER_CONFIG_HANDLE hDecoderConfig; +#ifndef LIB_DEC_REVISION if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { +#endif uint16_t wss, css; float startQuality; startQuality = hIvasDec->tsm_quality; +#ifndef LIB_DEC_REVISION apa_buffer_size = APA_BUF_PER_CHANNEL; +#endif /* get current renderer type*/ hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; @@ -4708,6 +4869,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERR_INIT_ERROR; } } +#ifndef LIB_DEC_REVISION if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) { @@ -4716,15 +4878,19 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); } +#endif } else { +#ifndef LIB_DEC_REVISION if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { +#endif if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) { return IVAS_ERR_INIT_ERROR; } +#ifndef LIB_DEC_REVISION apa_buffer_size = APA_BUF_PER_CHANNEL; free( hIvasDec->apaExecBuffer ); if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) @@ -4734,6 +4900,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); } /* realloc apa_exe_buffer */ +#endif } hIvasDec->nTransportChannelsOld = nTransportChannels; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index de74494d03..5f3e65f1d6 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -125,6 +125,9 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ +#ifdef LIB_DEC_REVISION + const bool voipMode, /* i : enable VoIP mode with JBM */ +#endif const bool tsmEnabled, /* i : enable TSM */ const IVAS_RENDER_FRAMESIZE renderFramesize,/* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ -- GitLab From ff871758d2e0435078c75e210e45ffb94958da5e Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 15:48:10 +0200 Subject: [PATCH 23/42] comments; fix EVS VoIP --- apps/decoder.c | 4 ++++ lib_com/options.h | 2 +- lib_dec/lib_dec.c | 47 ++++++++++++++++++++++------------------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 1d5e4f9419..84dffb01a6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1222,6 +1222,10 @@ static bool parseCmdlIVAS_dec( { if ( !is_digits_only( argv[i] ) ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error: Render frame size not specified!\n\n" ); + usage_dec(); +#endif return false; } diff --git a/lib_com/options.h b/lib_com/options.h index 0eee0b8b5a..d16b82ce80 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,7 +163,7 @@ #define FIX_1285_RENDER_CONFIG_PTR_COMPARE /* Philips: Warning about pointer comparison in the render config reader */ #define FIX_1298_MEMORY_OPT_IVAS_CORE_ENC /* VA: issue 1298: Memory saving in ivas_core_enc() */ #define SIMPLIFY_IVAS_CORE /* VA: simplify ivas core coder functions */ -#define LIB_DEC_REVISION /* VA: correction and simplification of lib_dec.c */ +#define LIB_DEC_REVISION /* VA: cleaning and simplification of lib_dec.c */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fe761cc023..2ba695e46c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1144,7 +1144,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( st_ivas = hIvasDec->st_ivas; #ifdef LIB_DEC_REVISION - isInitialized_voip = hIvasDec->isInitialized; + isInitialized_voip = hIvasDec->apaExecBuffer != NULL; #endif if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ @@ -2140,10 +2140,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *---------------------------------------------------------------------*/ static ivas_error ivas_dec_setup_all( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#ifndef LIB_DEC_REVISION - uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ -#endif + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ const int16_t isSplitRend, /* i : split rendering enabled flag */ ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ @@ -2212,25 +2209,6 @@ static ivas_error IVAS_DEC_Setup( *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; #endif -#ifdef LIB_DEC_REVISION - /* allocate/reallocte APA buffer */ - // ToDo: this memory should be harmonized with st_ivas->p_output_f[] and st_ivas->hTcBuffer->tc_buffer[] - see issue #104 - // ToDo: this part is also related to cleaning of NONBE_UNIFIED_DECODING_PATHS leftovers (see MR !1246) - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && *nTransportChannels != hIvasDec->nTransportChannelsOld ) - { - if ( hIvasDec->apaExecBuffer != NULL ) - { - free( hIvasDec->apaExecBuffer ); - } - - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * *nTransportChannels ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } - set_zero( hIvasDec->apaExecBuffer, APA_BUF_PER_CHANNEL * *nTransportChannels ); - } -#endif - /*-----------------------------------------------------------------* * ISAR: * - initialize ISAR handle at the first frame @@ -2258,6 +2236,25 @@ static ivas_error IVAS_DEC_Setup( } } +#ifdef LIB_DEC_REVISION + /* allocate/reallocate APA buffer */ + // ToDo: this memory should be harmonized with st_ivas->p_output_f[] and st_ivas->hTcBuffer->tc_buffer[] - see issue #916 + // ToDo: this part is also related to cleaning of NONBE_UNIFIED_DECODING_PATHS leftovers (see MR !1246) + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && *nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( hIvasDec->apaExecBuffer != NULL ) + { + free( hIvasDec->apaExecBuffer ); + } + + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * *nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } + set_zero( hIvasDec->apaExecBuffer, APA_BUF_PER_CHANNEL * *nTransportChannels ); + } + +#endif return IVAS_ERR_OK; } @@ -4812,8 +4809,8 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( #endif { DECODER_CONFIG_HANDLE hDecoderConfig; - #ifndef LIB_DEC_REVISION + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { #endif -- GitLab From d405b0003ddd3766930ff739bf2bb01f3db150f0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 16:10:42 +0200 Subject: [PATCH 24/42] Addition to NONBE_1293_CRASH_FIRST_FRAME_LOST to fix "-fr 5/10" outputs --- lib_dec/lib_dec.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 52c50f0140..f110f317fa 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1714,14 +1714,20 @@ ivas_error IVAS_DEC_GetSamplesRenderer( { hIvasDec->hasBeenFedFrame = false; set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + nSamplesRendered = nSamplesAsked; +#else hIvasDec->nSamplesRendered += nSamplesAsked; *nOutSamples = nSamplesAsked; +#endif hIvasDec->nSamplesAvailableNext -= nSamplesAsked; +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST if ( hIvasDec->nSamplesAvailableNext == 0 ) { hIvasDec->needNewFrame = true; *needNewFrame = true; } +#endif } else { @@ -1761,6 +1767,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( } nSamplesRendered += nSamplesRendered_loop; +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST nSamplesToRender -= nSamplesRendered_loop; if ( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -1771,15 +1778,23 @@ ivas_error IVAS_DEC_GetSamplesRenderer( { *needNewFrame = false; } -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - *nOutSamples = nSamplesRendered; #endif } -#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST - *nOutSamples = nSamplesRendered; +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + } + else + { + *needNewFrame = false; + } #endif + *nOutSamples = nSamplesRendered; + return IVAS_ERR_OK; } -- GitLab From 8807eab6f873dcb5119e44031923c4a26bc419bf Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 16:41:10 +0200 Subject: [PATCH 25/42] disable DEBUGGING --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d16b82ce80..bf154bfdd1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -#define DEBUGGING /* Activate debugging part of the code */ +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -132,7 +132,7 @@ /*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */ /*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ /*#define DEBUG_JBM_CMD_OPTION*/ /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ -#define VARIABLE_SPEED_DECODING /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ +/*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ /*#define DISABLE_LIMITER*/ /* disable the limiter */ /*Split Rendering Debug switches*/ -- GitLab From aafea5cc75917d07bc730b92f17688ef783277d6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Apr 2025 16:52:56 +0200 Subject: [PATCH 26/42] fix Object editing crash when DEBUGGING is activated --- lib_dec/lib_dec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 52c50f0140..45a3f4e0e6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1412,14 +1412,13 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); -#endif - if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -1441,6 +1440,9 @@ ivas_error IVAS_DEC_SetEditableParameters( } else if ( ism_mode == ISM_MODE_PARAM ) { +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -1498,6 +1500,9 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t id_th; float threshold_azi, threshold_ele; +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { if ( st_ivas->hMasaIsmData != NULL ) -- GitLab From 9cb5d2cee13668bd8596e085e77568cbf47379cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 11:27:53 +0200 Subject: [PATCH 27/42] replace IVAS_DEC_GetPcmFrameSize() by IVAS_DEC_GetOutputBufferSize(); revision of function description; formatting --- apps/decoder.c | 35 +++++++- lib_dec/lib_dec.c | 208 ++++++++++++++++++++++++++++------------------ lib_dec/lib_dec.h | 3 +- 3 files changed, 163 insertions(+), 83 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 84dffb01a6..5607d6a4ea 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -760,6 +760,13 @@ int main( } pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); +#ifdef LIB_DEC_REVISION + if ( pcmBuf == NULL ) + { + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + goto cleanup; + } +#endif /*-----------------------------------------------------------------* * Decoding @@ -1807,14 +1814,16 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifndef LIB_DEC_REVISION int32_t pcmFrameSize; if ( ( error = IVAS_DEC_GetPcmFrameSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) + { fprintf( stderr, "\nError in IVAS_DEC_GetPcmFrameSize, error code: %d\n", error ); return error; } - +#endif if ( isSplitRend ) { /* Open split rendering metadata writer */ @@ -1872,7 +1881,23 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef LIB_DEC_REVISION + int16_t pcmFrameSize; + if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetOutputBufferSize, error code: %d\n", error ); + return error; + } + +#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); +#ifdef LIB_DEC_REVISION + if ( zeroBuf == NULL ) + { + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + return IVAS_ERR_FAILED_ALLOC; + } +#endif memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) @@ -3400,7 +3425,12 @@ static ivas_error decodeVoIP( { if ( ( error = IVAS_DEC_HasDecodedFirstGoodFrame( hIvasDec, &decodedGoodFrame ) ) != IVAS_ERR_OK ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); +#else fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame, code: %d\n", error ); + +#endif goto cleanup; } @@ -3412,6 +3442,9 @@ static ivas_error decodeVoIP( if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error in initOnFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); +#endif goto cleanup; } } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2ba695e46c..6f7b69651c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -112,7 +112,11 @@ struct IVAS_DEC * Local function declarations *---------------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION +static void ivas_destroy_handle_VoIP( IVAS_DEC_VOIP *hVoIP ); +#else static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); +#endif #ifdef SUPPORT_JBM_TRACEFILE static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif @@ -145,6 +149,7 @@ static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplit static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesRendered ); + /*---------------------------------------------------------------------* * IVAS_DEC_Open() * @@ -176,6 +181,7 @@ ivas_error IVAS_DEC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); } + hIvasDec = *phIvasDec; hIvasDec->hVoIP = NULL; hIvasDec->apaExecBuffer = NULL; @@ -308,6 +314,7 @@ static ivas_error isar_set_split_rend_setup( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * init_decoder_config() * @@ -342,7 +349,7 @@ static void init_decoder_config( /*---------------------------------------------------------------------* * IVAS_DEC_Close( ) * - * + * Deallocate IVAS decoder memory handles *---------------------------------------------------------------------*/ void IVAS_DEC_Close( @@ -357,7 +364,11 @@ void IVAS_DEC_Close( if ( ( *phIvasDec )->hVoIP ) { +#ifdef LIB_DEC_REVISION + ivas_destroy_handle_VoIP( ( *phIvasDec )->hVoIP ); +#else IVAS_DEC_Close_VoIP( ( *phIvasDec )->hVoIP ); +#endif ( *phIvasDec )->hVoIP = NULL; } @@ -429,7 +440,7 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( * IVAS_DEC_Configure( ) * * Decoder configuration - * legacy code behavior: if no output format set, then it's EVS mono + * legacy behavior: if no output format set, then it's EVS mono *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( @@ -516,6 +527,7 @@ ivas_error IVAS_DEC_Configure( { return IVAS_ERR_WRONG_PARAMS; } + if ( outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -577,7 +589,7 @@ ivas_error IVAS_DEC_Configure( /*---------------------------------------------------------------------* * IVAS_DEC_EnableSplitRendering( ) * - * Intitialize Split rendering + * Update IVAS decoder config. if Split rendering is enabled *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableSplitRendering( @@ -603,7 +615,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( /*---------------------------------------------------------------------* * get_render_framesize_ms( ) * - * Get the 5ms flag + * Get render framesize in ms *---------------------------------------------------------------------*/ static int16_t get_render_frame_size_ms( @@ -616,7 +628,7 @@ static int16_t get_render_frame_size_ms( /*---------------------------------------------------------------------* * IVAS_DEC_SetRenderFramesize( ) * - * Get the 5ms flag + * Set render framesize *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetRenderFramesize( @@ -635,6 +647,7 @@ ivas_error IVAS_DEC_SetRenderFramesize( { hIvasDec->st_ivas->hExtOrientationData->num_subframes = (int16_t) render_framesize; } + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (int16_t) render_framesize; @@ -647,7 +660,7 @@ ivas_error IVAS_DEC_SetRenderFramesize( /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesize( ) * - * Get the 5ms flag + * Get render framesize *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderFramesize( @@ -665,6 +678,7 @@ ivas_error IVAS_DEC_GetRenderFramesize( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeSamples( ) * @@ -686,6 +700,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeMs( ) * @@ -707,6 +722,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetReferencesUpdateFrequency( ) * @@ -728,10 +744,11 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetNumOrientationSubframes( ) * - * Get the number of subframes for head/ecernal orientation per render frame + * Get the number of subframes for head/external orientation per render frame *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetNumOrientationSubframes( @@ -910,6 +927,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( bfi = 2; } } + if ( ( error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ) != IVAS_ERR_OK ) { return error; @@ -1150,7 +1168,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ { #ifdef LIB_DEC_REVISION - /* Setup all decoder parts (IVAS decoder, ISAR) */ + /*-----------------------------------------------------------------* + * Setup all decoder parts (IVAS decoder, ISAR) + *-----------------------------------------------------------------*/ + if ( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { return error; @@ -1182,8 +1203,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } #endif - /* IVAS TC decoder */ #ifdef LIB_DEC_REVISION + /*-----------------------------------------------------------------* + * IVAS decoder: decode transport channels and metadata + *-----------------------------------------------------------------*/ + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( ( error = evs_dec_main( st_ivas, hIvasDec->apaExecBuffer, NULL ) ) != IVAS_ERR_OK ) @@ -1206,13 +1230,17 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIvasDec->hasDecodedFirstGoodFrame = true; } #else + /* IVAS TC decoder */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } #endif - /* JBM */ + /*-----------------------------------------------------------------* + * JBM + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_tsm ) { #ifdef LIB_DEC_REVISION @@ -1244,7 +1272,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( nSamplesTcsScaled = hIvasDec->nSamplesFrame; } - /* Feed decoded transport channels samples to the renderer */ + /*-----------------------------------------------------------------* + * Feed decoded transport channels samples to the renderer + *-----------------------------------------------------------------*/ + #ifdef LIB_DEC_REVISION ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ); #else @@ -1267,7 +1298,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIvasDec->hasBeenPreparedRendering = false; - /* set edited metadata */ + /*-----------------------------------------------------------------* + * Set editable metadata + *-----------------------------------------------------------------*/ + if ( st_ivas->hIsmMetaData[0] ) { if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1315,7 +1349,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * - * + * Get editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetEditableParameters( @@ -1463,7 +1497,7 @@ ivas_error IVAS_DEC_GetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * - * Main function to decode to PCM data + * Set editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetEditableParameters( @@ -1928,7 +1962,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitBinauralBitstream( ) * - * + * Get split-rendering bitstream *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitBinauralBitstream( @@ -2187,6 +2221,7 @@ static ivas_error IVAS_DEC_Setup( return error; } } + #endif /*----------------------------------------------------------------* * IVAS decoder setup @@ -2425,6 +2460,7 @@ ivas_error IVAS_DEC_GetNumObjects( is_masa_ism = 1; } } + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) { *numObjects = hIvasDec->st_ivas->nchan_ism; @@ -2476,7 +2512,7 @@ ivas_error IVAS_DEC_GetFormat( /*---------------------------------------------------------------------* * getInputBufferSize() * - * + * Get size of output buffer in samples *---------------------------------------------------------------------*/ static int16_t getOutputBufferSize( @@ -2511,7 +2547,7 @@ static int16_t getOutputBufferSize( /*---------------------------------------------------------------------* * IVAS_DEC_GetOutputBufferSize() * - * + * Returns size of output buffer in samples *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetOutputBufferSize( @@ -2573,10 +2609,10 @@ ivas_error IVAS_DEC_GetNumOutputChannels( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetObjectMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ - const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ - const uint16_t objectIdx /* i : index of the queried object */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ + const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ + const uint16_t objectIdx /* i : index of the queried object */ ) { Decoder_Struct *st_ivas; @@ -2597,6 +2633,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( is_masa_ism = 1; } } + if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) { return IVAS_ERR_WRONG_MODE; @@ -2762,7 +2799,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefRotData( ) * - * Feed the decoder with the reference rotation + * Feed the decoder with the reference rotation data *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedRefRotData( @@ -3004,6 +3041,7 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * @@ -3111,13 +3149,13 @@ ivas_error IVAS_DEC_HRTF_binary_close( { Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && st_ivas->ini_frame > 0 ) { if ( !( binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && @@ -3205,7 +3243,7 @@ static ivas_error copyRendererConfigStruct( /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderConfig( ) * - * + * Return renderer configuration parameters handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderConfig( @@ -3225,12 +3263,12 @@ ivas_error IVAS_DEC_GetRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_GetDefaultRenderConfig( ) * - * + * Return default renderer configuration parameters *---------------------------------------------------------------------*/ /*! r: error code*/ ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ ) { RENDER_CONFIG_DATA RCin; @@ -3249,7 +3287,7 @@ ivas_error IVAS_DEC_GetDefaultRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_FeedRenderConfig( ) * - * + * Set renderer configuration (acoustic environment) parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedRenderConfig( @@ -3258,6 +3296,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; + Decoder_Struct *st_ivas; ivas_error error; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) @@ -3266,6 +3305,8 @@ ivas_error IVAS_DEC_FeedRenderConfig( } hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + st_ivas = hIvasDec->st_ivas; + #ifdef DEBUGGING hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) @@ -3299,53 +3340,42 @@ ivas_error IVAS_DEC_FeedRenderConfig( /* Re-initialize reverb instance if already available */ /* TD renderer Jot reverberator */ - if ( hIvasDec->st_ivas->hReverb != NULL ) + if ( st_ivas->hReverb != NULL ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } /* CREND Jot reverberator */ - if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + if ( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } - /* FB reverberator */ - if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) + /* Parametric renderer reverberator */ + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), - hIvasDec->st_ivas->hHrtfStatistics, - hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, - CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - &( hRenderConfig->roomAcoustics ), - hIvasDec->st_ivas->hDecoderConfig->output_Fs, - NULL, - NULL, - NULL ) ) != IVAS_ERR_OK ) + ivas_binaural_reverb_close( &( st_ivas->hDiracDecBin[0]->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hDiracDecBin[0]->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; } } - /* Fastconv CLDFB reverberator */ - if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) + + /* FastConv renderer reverberator */ + if ( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), - hIvasDec->st_ivas->hHrtfStatistics, - hIvasDec->st_ivas->hBinRenderer->conv_band, - hIvasDec->st_ivas->hBinRenderer->timeSlots, - &( hRenderConfig->roomAcoustics ), - hIvasDec->st_ivas->hDecoderConfig->output_Fs, - NULL, - NULL, - NULL ) ) != IVAS_ERR_OK ) + ivas_binaural_reverb_close( &( st_ivas->hBinRenderer->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hBinRenderer->conv_band, st_ivas->hBinRenderer->timeSlots, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -3362,9 +3392,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; } - if ( is_split_rendering_enabled( hIvasDec->st_ivas->hDecoderConfig, hRenderConfig ) ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, hRenderConfig ) ) { - if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -3377,7 +3407,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) * - * + * Return IVAS decoder delay in nanoseconds *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetDelay( @@ -3423,7 +3453,7 @@ ivas_error IVAS_DEC_GetDelay( /*---------------------------------------------------------------------* * IVAS_DEC_HasDecodedFirstGoodFrame( ) * - * + * Return flag indicating if the decoder has decoded a good frame *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( @@ -3441,7 +3471,7 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( return IVAS_ERR_OK; } - +#ifndef LIB_DEC_REVISION /*---------------------------------------------------------------------* * IVAS_DEC_GetPcmFrameSize( ) * @@ -3469,7 +3499,7 @@ ivas_error IVAS_DEC_GetPcmFrameSize( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * isSidFrame( ) @@ -3496,6 +3526,13 @@ static bool isSidFrame( return false; } + +/*---------------------------------------------------------------------* + * bsCompactToSerial( ) + * + * Bitstream conversion to Byte format + *---------------------------------------------------------------------*/ + static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, @@ -3786,7 +3823,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif - /* avoid time scaling multiple times within one 20ms frame*/ if ( scale != 100U ) { @@ -3941,6 +3977,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * @@ -3978,7 +4015,7 @@ static void update_voip_rendered20ms( /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * - * Function to flush remaining audio in VoIP + * Function to flush remaining audio samples in VoIP *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Flush( @@ -4028,8 +4065,9 @@ ivas_error IVAS_DEC_Flush( *---------------------------------------------------------------------*/ bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked /* i : number of output samples asked */ +) { if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL ) { @@ -4064,13 +4102,17 @@ ivas_error IVAS_DEC_VoIP_Get_CA_offset( /*---------------------------------------------------------------------* - * IVAS_DEC_Close_VoIP( ) - * + * ivas_destroy_handle_VoIP( ) * + * Deallocate VoIP handle *---------------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION +static void ivas_destroy_handle_VoIP( +#else static void IVAS_DEC_Close_VoIP( - IVAS_DEC_VOIP *hVoIP /* i/o: IVAS decoder handle */ +#endif + IVAS_DEC_VOIP *hVoIP /* i/o: VoIP decoder handle */ ) { JB4_Destroy( &hVoIP->hJBM ); @@ -4088,7 +4130,6 @@ static void IVAS_DEC_Close_VoIP( return; } - #ifdef SUPPORT_JBM_TRACEFILE /*---------------------------------------------------------------------* * store_JbmData() @@ -4151,10 +4192,8 @@ ivas_error IVAS_DEC_GetJbmData( return IVAS_ERR_OK; } - #endif - /*---------------------------------------------------------------------* * IVAS_DEC_GetErrorMessage( ) * @@ -4387,8 +4426,12 @@ ivas_error IVAS_DEC_PrintConfig( return IVAS_ERR_OK; } - #ifdef DEBUGGING +/*---------------------------------------------------------------------* + * IVAS_DEC_PrintConfigWithBitstream( ) + * + * + *---------------------------------------------------------------------*/ #define WMC_TOOL_SKIP void IVAS_DEC_PrintConfigWithBitstream( IVAS_DEC_HANDLE hIvasDec, @@ -4414,6 +4457,13 @@ void IVAS_DEC_PrintConfigWithBitstream( return; } + +/*---------------------------------------------------------------------* + * IVAS_DEC_PrintConfigWithVoipBitstream( ) + * + * + *---------------------------------------------------------------------*/ + void IVAS_DEC_PrintConfigWithVoipBitstream( IVAS_DEC_HANDLE hIvasDec, const bool quietModeEnabled, @@ -4442,7 +4492,6 @@ void IVAS_DEC_PrintConfigWithVoipBitstream( #undef WMC_TOOL_SKIP #endif - /*---------------------------------------------------------------------* * IVAS_DEC_PrintDisclaimer( ) * @@ -4575,7 +4624,6 @@ static ivas_error evs_dec_main( return IVAS_ERR_OK; } - #ifdef DEBUGGING /*---------------------------------------------------------------------* * IVAS_DEC_GetBer_detect_flag() @@ -4725,10 +4773,8 @@ ivas_error IVAS_DEC_GetSbaDebugParams( return IVAS_ERR_OK; } #endif /* DEBUG_SBA_AUDIO_DUMP */ - #endif /* DEBUGGING */ - /*---------------------------------------------------------------------* * input_format_API_to_internal() * @@ -5088,7 +5134,7 @@ PCM_RESOLUTION pcm_type_API_to_internal( /*-------------------------------------------------------------------* * ivas_create_handle_isar() * - * Initialize IVAS decoder split rend handle + * Initialize IVAS decoder split-rendering handle *-------------------------------------------------------------------*/ static ivas_error ivas_create_handle_isar( @@ -5302,7 +5348,7 @@ static ivas_error ivas_dec_reconfig_split_rend( /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * - * IVAS decoder split rend init + * IVAS decoder split rendering initialization *-------------------------------------------------------------------*/ static ivas_error ivas_dec_init_split_rend( @@ -5356,12 +5402,12 @@ static ivas_error ivas_dec_init_split_rend( /*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_coded_out() * - * + * Return flag to indicate if split rendering is enabled *---------------------------------------------------------------------*/ /*! r: decoder error code */ ivas_error IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 5f3e65f1d6..2f873d1856 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -503,12 +503,13 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ ); +#ifndef LIB_DEC_REVISION /*! r: error code */ ivas_error IVAS_DEC_GetPcmFrameSize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int32_t *pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ ); - +#endif /*! r: true if decoder has no data in VoIP jitter buffer */ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -- GitLab From aac0dde63413287a980bee4b21b40b649854ac87 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 14:51:20 +0200 Subject: [PATCH 28/42] correct merging issue --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 97b0c7fefb..407614837e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,7 +180,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ #define NONBE_1303_GRANULARITY_OSBA_REND /* VA: issue 1303: Correctly set the granularity in OSBA, Disc mode, and BINAURAL_ROOM_REVERB output */ -#define NONBE_1231_BASOP_819_THRESHOLD_MASA2TOTAL /* Nokia: add fix for precision limitation in comparison with masa2total energy ratio threshold to be aligned with BASOP*/ #define NONBE_1118_EVS_LR_HQ_BITERROR /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 1246130b58c1e9cdde29bdc242656ce156376705 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 19:11:07 +0200 Subject: [PATCH 29/42] simplify APA buffer handling --- lib_com/ivas_prot.h | 4 +++ lib_dec/ivas_jbm_dec.c | 9 +++++ lib_dec/lib_dec.c | 81 ++++++++++++++++++++++-------------------- 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4722f322d2..518712193f 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -806,8 +806,12 @@ void ivas_apply_non_diegetic_panning( *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : output synthesis signals */ +#endif ); ivas_error ivas_jbm_dec_render( diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 669fa5f43c..f4492948c3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -66,8 +66,12 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signals */ +#endif ) { int16_t n, output_frame, nchan_out; @@ -727,11 +731,16 @@ ivas_error ivas_jbm_dec_tc( * Write IVAS transport channels *----------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION + if ( st_ivas->hDecoderConfig->Opt_tsm == 0 ) +#else if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) { + ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } else +#endif { /* directly copy to tc buffers */ ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0d00257da6..ca8498f721 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -121,7 +121,7 @@ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif #ifdef LIB_DEC_REVISION -static ivas_error evs_dec_main( Decoder_Struct *st_ivas, float *floatBuf, int16_t *pcmBuf ); +static ivas_error evs_dec_main( Decoder_Struct *st_ivas ); #else static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); #endif @@ -1303,14 +1303,14 @@ ivas_error IVAS_DEC_GetSamplesDecoder( if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { - if ( ( error = evs_dec_main( st_ivas, hIvasDec->apaExecBuffer, NULL ) ) != IVAS_ERR_OK ) + if ( ( error = evs_dec_main( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) { - if ( ( error = ivas_jbm_dec_tc( st_ivas, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1351,6 +1351,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } +#ifdef LIB_DEC_REVISION + ivas_syn_output_f( hIvasDec->st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer ); + +#endif if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -2364,25 +2368,6 @@ static ivas_error IVAS_DEC_Setup( } } -#ifdef LIB_DEC_REVISION - /* allocate/reallocate APA buffer */ - // ToDo: this memory should be harmonized with st_ivas->p_output_f[] and st_ivas->hTcBuffer->tc_buffer[] - see issue #916 - // ToDo: this part is also related to cleaning of NONBE_UNIFIED_DECODING_PATHS leftovers (see MR !1246) - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && *nTransportChannels != hIvasDec->nTransportChannelsOld ) - { - if ( hIvasDec->apaExecBuffer != NULL ) - { - free( hIvasDec->apaExecBuffer ); - } - - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * *nTransportChannels ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } - set_zero( hIvasDec->apaExecBuffer, APA_BUF_PER_CHANNEL * *nTransportChannels ); - } - -#endif return IVAS_ERR_OK; } @@ -4610,24 +4595,32 @@ void IVAS_DEC_PrintDisclaimer( void ) *---------------------------------------------------------------------*/ static ivas_error evs_dec_main( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +#else Decoder_Struct *st_ivas, -#ifndef LIB_DEC_REVISION const int16_t nOutSamples, -#endif float *floatBuf, - int16_t *pcmBuf ) + int16_t *pcmBuf +#endif + +) { DEC_CORE_HANDLE *hCoreCoder; float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - int16_t ch; #ifdef LIB_DEC_REVISION - int16_t nOutSamples; + int16_t ch, nOutSamples; +#else + int16_t ch; #endif ivas_error error; hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifdef LIB_DEC_REVISION + nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif mdct_switching_dec( hCoreCoder[0] ); @@ -4680,10 +4673,6 @@ static ivas_error evs_dec_main( } st_ivas->BER_detect = hCoreCoder[0]->BER_detect; -#ifdef LIB_DEC_REVISION - - nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); -#endif if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { @@ -4693,6 +4682,23 @@ static ivas_error evs_dec_main( v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); } +#ifdef LIB_DEC_REVISION + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ + int16_t pcm_buf_local[L_FRAME48k]; + + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( &p_output[ch], nOutSamples, 1, pcm_buf_local ); + + mvs2r( pcm_buf_local, p_output[ch], nOutSamples ); + } + } +#else if ( !st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); @@ -4717,6 +4723,7 @@ static ivas_error evs_dec_main( #endif ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } +#endif return IVAS_ERR_OK; } @@ -4937,6 +4944,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( const uint16_t l_ts ) #endif { + int16_t apa_buffer_size; #ifdef LIB_DEC_REVISION uint16_t l_ts; @@ -4944,8 +4952,6 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( if ( isInitialized_voip == false ) #else - int16_t apa_buffer_size; - apa_buffer_size = hIvasDec->nSamplesFrame; if ( hIvasDec->apaExecBuffer == NULL ) @@ -4961,9 +4967,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( float startQuality; startQuality = hIvasDec->tsm_quality; -#ifndef LIB_DEC_REVISION apa_buffer_size = APA_BUF_PER_CHANNEL; -#endif /* get current renderer type*/ hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; @@ -5009,14 +5013,13 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERR_INIT_ERROR; } } -#ifndef LIB_DEC_REVISION if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } - set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#ifndef LIB_DEC_REVISION } #endif } @@ -5030,7 +5033,8 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( { return IVAS_ERR_INIT_ERROR; } -#ifndef LIB_DEC_REVISION + + /* realloc apa_exe_buffer */ apa_buffer_size = APA_BUF_PER_CHANNEL; free( hIvasDec->apaExecBuffer ); if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) @@ -5038,6 +5042,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#ifndef LIB_DEC_REVISION } /* realloc apa_exe_buffer */ #endif -- GitLab From 88b8fc8f50230c39e448d2a25676240e7863e1e1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 20:15:16 +0200 Subject: [PATCH 30/42] fix AMR-WB path --- lib_dec/lib_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index ca8498f721..05decb054e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4698,6 +4698,10 @@ static ivas_error evs_dec_main( mvs2r( pcm_buf_local, p_output[ch], nOutSamples ); } } + else // ToDo: the 'else' branch can be removed once UNIFIED_DECODING_PATHS_LEFTOVERS is merged + { + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + } #else if ( !st_ivas->hDecoderConfig->Opt_tsm ) { -- GitLab From 0c2086b55b5536742954d9e1eea3ea66b2a3ce13 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 21:56:34 +0200 Subject: [PATCH 31/42] update --- apps/decoder.c | 13 ++++++++++++- lib_dec/lib_dec.c | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 5607d6a4ea..94760fe1c7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1068,18 +1068,30 @@ static bool parseCmdlIVAS_dec( if ( strcmp( argv_to_upper, "-VOIP" ) == 0 ) { +#ifdef LIB_DEC_REVISION arg->voipMode = true; +#else + arg->voipMode = 1; +#endif i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=0" ) == 0 ) { +#ifdef LIB_DEC_REVISION arg->voipMode = true; +#else + arg->voipMode = 1; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP; i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=1" ) == 0 ) { +#ifdef LIB_DEC_REVISION arg->voipMode = true; +#else + arg->voipMode = 1; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF; i++; } @@ -1818,7 +1830,6 @@ static ivas_error initOnFirstGoodFrame( int32_t pcmFrameSize; if ( ( error = IVAS_DEC_GetPcmFrameSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) - { fprintf( stderr, "\nError in IVAS_DEC_GetPcmFrameSize, error code: %d\n", error ); return error; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 05decb054e..898d7c6590 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -181,7 +181,6 @@ ivas_error IVAS_DEC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); } - hIvasDec = *phIvasDec; hIvasDec->hVoIP = NULL; hIvasDec->apaExecBuffer = NULL; @@ -314,7 +313,6 @@ static ivas_error isar_set_split_rend_setup( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * init_decoder_config() * @@ -527,7 +525,6 @@ ivas_error IVAS_DEC_Configure( { return IVAS_ERR_WRONG_PARAMS; } - if ( outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -678,7 +675,6 @@ ivas_error IVAS_DEC_GetRenderFramesize( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeSamples( ) * @@ -700,7 +696,6 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeMs( ) * @@ -744,7 +739,6 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * IVAS_DEC_GetGetNumOrientationSubframes( ) * @@ -927,7 +921,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( bfi = 2; } } - if ( ( error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ) != IVAS_ERR_OK ) { return error; @@ -2538,7 +2531,6 @@ ivas_error IVAS_DEC_GetNumObjects( is_masa_ism = 1; } } - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) { *numObjects = hIvasDec->st_ivas->nchan_ism; @@ -2711,7 +2703,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( is_masa_ism = 1; } } - if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) { return IVAS_ERR_WRONG_MODE; @@ -3119,7 +3110,6 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * @@ -3891,6 +3881,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; + /* pop one access unit from the jitter buffer */ result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); if ( result != 0 ) @@ -3905,6 +3896,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif + /* avoid time scaling multiple times within one 20ms frame*/ if ( scale != 100U ) { @@ -4212,6 +4204,7 @@ static void IVAS_DEC_Close_VoIP( return; } + #ifdef SUPPORT_JBM_TRACEFILE /*---------------------------------------------------------------------* * store_JbmData() @@ -4274,8 +4267,10 @@ ivas_error IVAS_DEC_GetJbmData( return IVAS_ERR_OK; } + #endif + /*---------------------------------------------------------------------* * IVAS_DEC_GetErrorMessage( ) * @@ -4508,6 +4503,7 @@ ivas_error IVAS_DEC_PrintConfig( return IVAS_ERR_OK; } + #ifdef DEBUGGING /*---------------------------------------------------------------------* * IVAS_DEC_PrintConfigWithBitstream( ) @@ -4574,6 +4570,7 @@ void IVAS_DEC_PrintConfigWithVoipBitstream( #undef WMC_TOOL_SKIP #endif + /*---------------------------------------------------------------------* * IVAS_DEC_PrintDisclaimer( ) * @@ -4603,7 +4600,6 @@ static ivas_error evs_dec_main( float *floatBuf, int16_t *pcmBuf #endif - ) { DEC_CORE_HANDLE *hCoreCoder; @@ -4732,6 +4728,7 @@ static ivas_error evs_dec_main( return IVAS_ERR_OK; } + #ifdef DEBUGGING /*---------------------------------------------------------------------* * IVAS_DEC_GetBer_detect_flag() @@ -4881,8 +4878,10 @@ ivas_error IVAS_DEC_GetSbaDebugParams( return IVAS_ERR_OK; } #endif /* DEBUG_SBA_AUDIO_DUMP */ + #endif /* DEBUGGING */ + /*---------------------------------------------------------------------* * input_format_API_to_internal() * @@ -5022,6 +5021,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); #ifndef LIB_DEC_REVISION } -- GitLab From 1adf8e1a6ba4f11e34023ddd6fede581e5a795ed Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 22:26:01 +0200 Subject: [PATCH 32/42] removal of unnecessary temporary parameter --- lib_dec/lib_dec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 898d7c6590..587fa6ece7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4011,15 +4011,17 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { if ( hIvasDec->nSamplesAvailableNext == 0 || hIvasDec->nSamplesAvailableNext == hIvasDec->nSamplesFrame ) { +#ifndef LIB_DEC_REVISION uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; - +#endif if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, NULL ) ) != IVAS_ERR_OK ) { return error; } - +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesFlushed = nSamplesFlushed_ref; +#endif *bitstreamReadDone = false; *parametersAvailableForEditing = true; return IVAS_ERR_OK; -- GitLab From cd78b7a5b63741752e29dae9b5032d177f963872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Tue, 8 Apr 2025 12:09:52 +0200 Subject: [PATCH 33/42] Further increase sanitizer artifacts retention time Follow-up for 1ad9a8ee2346c97f128c1c282b93b272d1ad3c90. 4 weeks is too short to overlap for some sanitizer schedules, apparently, as there might be delays in the scheduling. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e8ebf8062a..018b273ae6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1818,7 +1818,7 @@ ltv-usan: - ivas-linux-fast artifacts: name: "$CI_JOB_NAME--main--sha-$CI_COMMIT_SHORT_SHA" - expire_in: 4 weeks + expire_in: 7 weeks when: always paths: - ep_015.g192 -- GitLab From c860fc69e548974f28486ea32478e8ce60c1933c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Apr 2025 12:44:56 +0200 Subject: [PATCH 34/42] accept FIX_1285_RENDER_CONFIG_PTR_COMPARE, FIX_1298_MEMORY_OPT_IVAS_CORE_ENC, SIMPLIFY_IVAS_CORE --- lib_com/options.h | 4 +-- lib_com/prot.h | 11 +++--- lib_dec/core_switching_dec.c | 15 +++------ lib_dec/evs_dec.c | 4 --- lib_dec/ivas_core_dec.c | 48 -------------------------- lib_dec/ivas_cpe_dec.c | 30 +---------------- lib_dec/ivas_mct_dec.c | 4 --- lib_enc/ivas_core_enc.c | 20 +---------- lib_enc/ivas_cpe_enc.c | 60 +-------------------------------- lib_enc/ivas_sce_enc.c | 5 +-- lib_util/render_config_reader.c | 5 +-- 11 files changed, 14 insertions(+), 192 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8c8a3c2aab..62a9a6ea57 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,9 +160,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ -#define FIX_1285_RENDER_CONFIG_PTR_COMPARE /* Philips: Warning about pointer comparison in the render config reader */ -#define FIX_1298_MEMORY_OPT_IVAS_CORE_ENC /* VA: issue 1298: Memory saving in ivas_core_enc() */ -#define SIMPLIFY_IVAS_CORE /* VA: simplify ivas core coder functions */ + /* #################### End BE switches ################################## */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 7fbc2b262a..18b6c30c5c 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5905,13 +5905,10 @@ void core_switching_post_enc( ); ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ -#ifndef SIMPLIFY_IVAS_CORE - const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#endif + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index af0fb30bee..6445970f2a 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -553,13 +553,10 @@ ivas_error core_switching_pre_dec( *---------------------------------------------------------------------*/ ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ -#ifndef SIMPLIFY_IVAS_CORE - const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#endif + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching flag */ @@ -681,11 +678,7 @@ ivas_error core_switching_post_dec( synth[i + delay_comp] = ( synth[i + delay_comp] * i + ( tmpDelta - i ) * st->previoussynth[i + delay_comp] ) / tmpDelta; } -#ifdef SIMPLIFY_IVAS_CORE if ( ( st->element_mode == IVAS_CPE_MDCT || ( st->is_ism_format && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) -#else - if ( ( st->element_mode == IVAS_CPE_MDCT || ( ivas_format == ISM_FORMAT && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) -#endif { /* smooth transitions to avoid pops in car noise items */ smoothTransitionDtxToTcx( synth, output_frame, delay_comp ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index b520c6a592..c5bbddd060 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -274,11 +274,7 @@ ivas_error evs_dec( * Postprocessing for ACELP/MDCT core switching *---------------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, MONO_FORMAT, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 2e46b11dfe..eb961c38dc 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -70,9 +70,7 @@ ivas_error ivas_core_dec( Decoder_State **sts, *st; STEREO_ICBWE_DEC_HANDLE hStereoICBWE; STEREO_TD_DEC_DATA_HANDLE hStereoTD; -#ifdef SIMPLIFY_IVAS_CORE STEREO_CNG_DEC_HANDLE hStereoCng; -#endif int16_t sharpFlag[CPE_CHANNELS]; float synth[CPE_CHANNELS][L_FRAME48k]; float tmp_buffer[L_FRAME48k]; @@ -118,9 +116,7 @@ ivas_error ivas_core_dec( last_element_brate = hSCE->last_element_brate; /* note: this parameter is unused */ last_element_mode = IVAS_SCE; hStereoTD = NULL; -#ifdef SIMPLIFY_IVAS_CORE hStereoCng = NULL; -#endif p_output_mem = NULL; nchan_out = 1; if ( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) @@ -139,9 +135,7 @@ ivas_error ivas_core_dec( last_element_mode = hCPE->last_element_mode; hStereoICBWE = hCPE->hStereoICBWE; hStereoTD = hCPE->hStereoTD; -#ifdef SIMPLIFY_IVAS_CORE hStereoCng = hCPE->hStereoCng; -#endif p_output_mem = hCPE->output_mem[1]; nchan_out = hCPE->nchan_out; @@ -235,11 +229,7 @@ ivas_error ivas_core_dec( } /* n_channels loop */ /* MDCT stereo -> DFT stereo switching */ -#ifdef SIMPLIFY_IVAS_CORE if ( last_element_mode == IVAS_CPE_MDCT && sts[0]->element_mode == IVAS_CPE_DFT ) -#else - if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) -#endif { int16_t ovl, fade_len; if ( sts[0]->L_frame != sts[0]->last_L_frame ) @@ -256,17 +246,10 @@ ivas_error ivas_core_dec( } } -#ifdef SIMPLIFY_IVAS_CORE if ( hStereoCng != NULL ) { hStereoCng->flag_cna_fade = 0; } -#else - if ( hCPE != NULL && hCPE->hStereoCng != NULL ) - { - hCPE->hStereoCng->flag_cna_fade = 0; - } -#endif save_hb_synth = NULL; if ( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) @@ -296,11 +279,7 @@ ivas_error ivas_core_dec( if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { -#ifdef SIMPLIFY_IVAS_CORE ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); -#else - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); -#endif } /*------------------------------------------------------------------* @@ -369,11 +348,7 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) -#else - if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -445,17 +420,10 @@ ivas_error ivas_core_dec( * Stereo CNG updates *---------------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( sts[0]->element_mode == IVAS_CPE_TD && hStereoCng != NULL ) { stereo_cng_compute_PScorr( output, &hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); } -#else - if ( sts[0]->element_mode == IVAS_CPE_TD && hCPE->hStereoCng != NULL ) - { - stereo_cng_compute_PScorr( output, &hCPE->hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); - } -#endif /*---------------------------------------------------------------------* * Postprocessing, BWEs and updates @@ -494,11 +462,7 @@ ivas_error ivas_core_dec( mvr2r( synth[n], hSCE->save_synth, output_frame ); } -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -510,11 +474,7 @@ ivas_error ivas_core_dec( } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ -#ifdef SIMPLIFY_IVAS_CORE if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) -#else - if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_DFT ) ) ) -#endif { mvr2r( sts[0]->previoussynth, sts[1]->previoussynth, st->hTcxDec->L_frameTCX ); } @@ -689,11 +649,7 @@ ivas_error ivas_core_dec( mvr2r( tmp_buffer, st->hb_prev_synth_buffer, tmps ); } -#ifdef SIMPLIFY_IVAS_CORE if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) -#else - if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) -#endif { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); @@ -746,11 +702,7 @@ ivas_error ivas_core_dec( } else /* IVAS_CPE_DFT */ { -#ifdef SIMPLIFY_IVAS_CORE if ( last_element_mode == IVAS_CPE_MDCT ) -#else - if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) -#endif { stereo_mdct2dft_update( hCPE, output[0], synth[0] ); } diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 59be959bd6..dea4a37211 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -77,9 +77,7 @@ ivas_error ivas_cpe_dec( float res_buf[STEREO_DFT_N_8k]; CPE_DEC_HANDLE hCPE; Decoder_State **sts; -#ifdef SIMPLIFY_IVAS_CORE STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; -#endif int32_t ivas_total_brate; ivas_error error; int32_t cpe_brate; @@ -119,14 +117,12 @@ ivas_error ivas_cpe_dec( return error; } -#ifdef SIMPLIFY_IVAS_CORE hConfigDft = NULL; - IF( hCPE->hStereoDft != NULL ) + if ( hCPE->hStereoDft != NULL ) { hConfigDft = hCPE->hStereoDft->hConfig; } -#endif /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -183,19 +179,11 @@ ivas_error ivas_cpe_dec( { if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } else @@ -203,19 +191,11 @@ ivas_error ivas_cpe_dec( /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ if ( ivas_total_brate <= IVAS_SID_5k2 ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } } @@ -442,11 +422,7 @@ ivas_error ivas_cpe_dec( * Core Decoder *----------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#else - if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#endif { if ( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { @@ -465,11 +441,7 @@ ivas_error ivas_cpe_dec( * Stereo decoder & upmixing *----------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#else - if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#endif { float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 0ec1514eaa..4c2ace3908 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -260,11 +260,7 @@ ivas_error ivas_mct_dec( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 8ec10ee28e..53669f7b65 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -90,14 +90,7 @@ ivas_error ivas_core_enc( float *inp[CPE_CHANNELS]; float new_inp_resamp16k[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC - float *shb_speech; - float *hb_speech; -#else - float shb_speech[L_FRAME16k]; - float hb_speech[L_FRAME16k / 4]; -#endif - float *new_swb_speech; + float *shb_speech, *hb_speech, *new_swb_speech; float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX]; float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; @@ -159,9 +152,6 @@ ivas_error ivas_core_enc( input_Fs = sts[0]->input_Fs; input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); -#ifndef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC - set_f( new_swb_speech_buffer, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); -#endif for ( n = 0; n < n_CoreChannels; n++ ) { @@ -202,11 +192,7 @@ ivas_error ivas_core_enc( diff_nBits = 0; if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { -#ifdef SIMPLIFY_IVAS_CORE ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); -#else - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); -#endif } /*---------------------------------------------------------------------* @@ -346,9 +332,7 @@ ivas_error ivas_core_enc( * WB BWE encoding *---------------------------------------------------------------------*/ -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC hb_speech = new_swb_speech_buffer; /* reuse existing buffer: hb_speech[L_FRAME16k/4]; */ -#endif if ( input_Fs >= 16000 && st->bwidth < SWB && st->hBWE_TD != NULL ) { @@ -373,10 +357,8 @@ ivas_error ivas_core_enc( *---------------------------------------------------------------------*/ new_swb_speech = new_swb_speech_buffer + STEREO_DFT_OVL_MAX; -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC set_f( new_swb_speech_buffer, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); shb_speech = new_inp_resamp16k[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */ -#endif if ( !st->Opt_SC_VBR && input_Fs >= 32000 && st->hBWE_TD != NULL ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 5dc7ded887..7c5b66cb8c 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -68,9 +68,7 @@ ivas_error ivas_cpe_enc( ) { CPE_ENC_HANDLE hCPE; -#ifdef SIMPLIFY_IVAS_CORE STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; -#endif Encoder_State **sts; int16_t n, n_CoreChannels; float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */ @@ -209,14 +207,12 @@ ivas_error ivas_cpe_enc( return error; } -#ifdef SIMPLIFY_IVAS_CORE hConfigDft = NULL; - IF( hCPE->hStereoDft != NULL ) + if ( hCPE->hStereoDft != NULL ) { hConfigDft = hCPE->hStereoDft->hConfig; } -#endif /*----------------------------------------------------------------* * Set TD stereo parameters *----------------------------------------------------------------*/ @@ -291,39 +287,23 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || -#ifdef SIMPLIFY_IVAS_CORE ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ -#else - ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ -#endif { if ( st_ivas->hQMetaData != NULL ) { if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } else { /* note; "bits_frame_nominal" needed in TD stereo as well */ -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } @@ -394,25 +374,13 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode == IVAS_CPE_DFT ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_hybrid_ITD_flag( hConfigDft, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); -#else - stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); -#endif /* Time Domain ITD compensation using extrapolation */ #ifdef DEBUG_MODE_DFT -#ifdef SIMPLIFY_IVAS_CORE stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hConfigDft->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); #else - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->hConfig->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#endif -#else -#ifdef SIMPLIFY_IVAS_CORE stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#else - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#endif #endif /* DFT on right and left input channels */ @@ -424,11 +392,7 @@ ivas_error ivas_cpe_enc( #endif /* Update DFT Stereo memories */ -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_enc_update( hCPE->hStereoDft, max_bwidth ); -#else - stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth ); -#endif /* DFT stereo processing */ stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); @@ -519,11 +483,7 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], -#ifdef SIMPLIFY_IVAS_CORE fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, hEncoderConfig->last_ivas_total_brate, ivas_total_brate ); -#else - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -574,11 +534,7 @@ ivas_error ivas_cpe_enc( set_bw_stereo( hCPE ); /* reconfiguration of MDCT stereo */ -#ifdef SIMPLIFY_IVAS_CORE if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) ) -#else - if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) ) -#endif { initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); @@ -601,15 +557,9 @@ ivas_error ivas_cpe_enc( int16_t igf; int16_t bw; -#ifdef SIMPLIFY_IVAS_CORE bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth; igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) -#else - bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; - igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); - if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -676,19 +626,11 @@ ivas_error ivas_cpe_enc( /* Reconfigure DFT Stereo for inactive frames */ if ( sts[0]->core_brate == SID_2k40 ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft->hConfig, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft->hConfig, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth ); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 68166262c3..913fe90754 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -166,11 +166,8 @@ ivas_error ivas_sce_enc( /* set flag for sampling rate of OL S/M classifier */ flag_16k_smc = 0; -#ifdef SIMPLIFY_IVAS_CORE if ( ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) -#else - if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) -#endif + { flag_16k_smc = 1; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 377c1b22ad..fed68002a7 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2369,11 +2369,8 @@ ivas_error RenderConfigReader_read( errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; } -#ifdef FIX_1285_RENDER_CONFIG_PTR_COMPARE + if ( i >= pRenderConfigReader->nFG || pRenderConfigReader->pFG[i].pFc == NULL ) -#else - if ( i > pRenderConfigReader->nFG || &pRenderConfigReader->pFG[i] == NULL ) -#endif { return IVAS_ERR_INVALID_RENDER_CONFIG; } -- GitLab From 959e3ae1237fd0e8458d97ea4eafdb0fa0851a5c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Apr 2025 12:49:22 +0200 Subject: [PATCH 35/42] accept NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING, NONBE_FIX_1297_SPAR_JBM_MEM_SAN, NONBE_1289_STEREO_SW_TO_MONO --- lib_com/options.h | 3 --- lib_dec/FEC_HQ_phase_ecu.c | 29 +++++++---------------------- lib_dec/ivas_jbm_dec.c | 20 ++++---------------- lib_dec/ivas_stereo_switching_dec.c | 4 ---- lib_dec/lib_dec.c | 5 ----- 5 files changed, 11 insertions(+), 50 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 62a9a6ea57..8beec85a4b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,10 +170,7 @@ /* all switches in this category should start with "NONBE_" */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ -#define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ #define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ -#define NONBE_FIX_1297_SPAR_JBM_MEM_SAN /*Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer*/ -#define NONBE_1289_STEREO_SW_TO_MONO /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */ #define NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX /* FhG: Avoid JBM ignoring safety margin and setting playout delay to 0 during DTX */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 7e7e5d2f07..9055f2b547 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -263,13 +263,11 @@ static void trans_ana( const int16_t time_offs, /* i : Time offset */ const float est_mus_content, /* i : 0.0=speech_like ... 1.0=Music (==st->env_stab ) */ const int16_t last_fec, /* i : signal that previous frame was concealed with fec_alg*/ -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING - const int16_t element_mode, /* i : element_mode req to handle EVS_MONO specific BE path */ -#endif - float *alpha, /* o : Magnitude modification factors for fade to average */ - float *beta, /* o : Magnitude modification factors for fade to average */ - float *beta_mute, /* o : Factor for long-term mute */ - float Xavg[LGW_MAX] /* o : Frequency group average gain to fade to */ + const int16_t element_mode, /* i : element_mode req to handle EVS_MONO specific BE path*/ + float *alpha, /* o : Magnitude modification factors for fade to average */ + float *beta, /* o : Magnitude modification factors for fade to average */ + float *beta_mute, /* o : Factor for long-term mute */ + float Xavg[LGW_MAX] /* o : Frequency group average gain to fade to */ ) { const float *w_hamm; @@ -419,7 +417,7 @@ static void trans_ana( { mag_chg[k] = 0; } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + if ( element_mode != EVS_MONO ) { if ( k == 0 && burst_len > BETA_MUTE_THR ) /* beta_mute final long term attenuation adjusted only once per frame in the first sub-band, Ref Eq(184) in 26.447 */ @@ -434,12 +432,7 @@ static void trans_ana( *beta_mute *= BETA_MUTE_FAC; } } -#else - if ( burst_len > BETA_MUTE_THR ) - { - *beta_mute *= BETA_MUTE_FAC; - } -#endif + alpha[k] = mag_chg[k]; beta[k] = (float) ( sqrt( 1.0f - SQR( alpha[k] ) ) * *beta_mute ); if ( k >= LGW32k - 1 ) @@ -2114,11 +2107,7 @@ static void hq_phase_ecu( *time_offs = 0; /* IVAS reset of offset time counter, timeoffset variable later also used to calculate burst length */ } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING trans_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, element_mode, alpha, beta, beta_mute, Xavg ); -#else - trans_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, alpha, beta, beta_mute, Xavg ); -#endif spec_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, plocs, plocsi, num_p, X_sav, output_frame, bwidth, element_mode, &noise_fac, pcorr ); if ( prev_bfi && *last_fec ) @@ -2146,11 +2135,7 @@ static void hq_phase_ecu( *time_offs = (int16_t) INT16_MAX; /* high value --> continued muting will ensure that the now saturated seed is not creating tones */ } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING trans_ana( prevsynth + 2 * output_frame - Lprot, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, element_mode, alpha, beta, beta_mute, Xavg ); /* 1.0 stable-music, 0.0 speech-like */ -#else - trans_ana( prevsynth + 2 * output_frame - Lprot, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, alpha, beta, beta_mute, Xavg ); /* 1.0 stable-music, 0.0 speech-like */ -#endif } mvr2r( X_sav, X, Lprot ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 669fa5f43c..0d8c06abc1 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1533,45 +1533,33 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN if ( ism_mode_old == ISM_SBA_MODE_DISC ) { -#endif float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t last_spar_md_idx; int16_t last_dirac_md_idx; uint16_t nSamplesAvailableNext; -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN ISM_MODE ism_mode_orig; RENDERER_TYPE renderer_type_orig; int32_t ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; renderer_type_orig = st_ivas->renderer_type; ism_mode_orig = st_ivas->ism_mode; st_ivas->ism_mode = ism_mode_old; st_ivas->renderer_type = renderer_type_old; st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#endif last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN #ifdef DEBUGGING assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); #endif -#else -#ifdef DEBUGGING - assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); -#endif -#endif + /* copy from ISM delay buffer to the correct place in tcs */ for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered]; -#else - tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; -#endif mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); } @@ -1596,17 +1584,17 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + st_ivas->ism_mode = ism_mode_orig; st_ivas->renderer_type = renderer_type_orig; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } -#endif } else { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } + hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a831a74d23..a0565824af 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1141,11 +1141,7 @@ void synchro_synthesis( /* handling of TD->DFT switching */ for ( n = 0; n < hCPE->nchan_out; n++ ) { -#ifdef NONBE_1289_STEREO_SW_TO_MONO if ( ( !use_cldfb_for_last_dft && hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 ) -#else - if ( ( hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 ) -#endif { float *pPrev_synth; float inv_fade_len = 1.f / delay_diff; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5a148ae82d..fc5bbc74d4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1131,15 +1131,10 @@ ivas_error IVAS_DEC_ReadFormat( } } #else -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) || ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode != ISM_SBA_MODE_DISC ) ) ) ) -#else - if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) -#endif { /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ -- GitLab From dd577b6b4207bdcc49d647d7576cf5753b703684 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Apr 2025 12:55:02 +0200 Subject: [PATCH 36/42] accept NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX, NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS, NONBE_1303_GRANULARITY_OSBA_REND --- lib_com/options.h | 4 +--- lib_dec/ivas_sba_dec.c | 4 ---- lib_dec/jbm_jb4sb.c | 7 ------- lib_rend/ivas_objectRenderer_sfx.c | 11 ++--------- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8beec85a4b..ebfc3519ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,13 +171,11 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ -#define NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX /* FhG: Avoid JBM ignoring safety margin and setting playout delay to 0 during DTX */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ -#define NONBE_1303_GRANULARITY_OSBA_REND /* VA: issue 1303: Correctly set the granularity in OSBA, Disc mode, and BINAURAL_ROOM_REVERB output */ #define NONBE_1118_EVS_LR_HQ_BITERROR /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */ #define NONBE_1303_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3ef82c883e..2164e490d4 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -184,11 +184,7 @@ ivas_error ivas_sba_dec_reconfigure( } else { -#ifdef NONBE_1303_GRANULARITY_OSBA_REND if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#else - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index ad3ba459a6..6f6844f3ab 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -683,7 +683,6 @@ static void JB4_targetPlayoutDelay( *targetStartUp = ( *targetMin + *targetMax ) / 2; } -#ifdef NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX #ifdef NONBE_1122_KEEP_EVS_MODE_UNCHANGED if ( !h->evsMode ) { @@ -693,12 +692,6 @@ static void JB4_targetPlayoutDelay( } #endif *targetStartUp = JB4_MAX( *targetStartUp, (uint32_t) h->safetyMargin ); -#else - if ( *targetStartUp < 60 ) - { - *targetStartUp = 60; - } -#endif return; } diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 2d09fd49a7..5873ebd96a 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -39,11 +39,6 @@ #include "wmc_auto.h" -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ @@ -56,6 +51,7 @@ static void sincResample( const float *input, float *output, const int16_t lengt * * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ + void TDREND_Apply_ITD( float *input, /* i : Input subframe to be time adjusted */ float *out_left, /* o : Output left channel with ITD applied */ @@ -163,6 +159,7 @@ void TDREND_Apply_ITD( * The sinc resampling reads SFX_SPAT_BIN_SINC_M (5) samples outside of * the target frame. *---------------------------------------------------------------------*/ + static void sincResample( const float *input, /*i : Input signal */ float *output, /*o : Output signal */ @@ -188,7 +185,6 @@ static void sincResample( return; } - /* Compute fractional time step */ t_step = (float) ( length_in ) / (float) ( length_out ); t_frac = 0; @@ -216,9 +212,6 @@ static void sincResample( p_forward++; p_backward--; } -#ifndef NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS - tmp += ( *p_forward ) * ( *p_sinc_forward ); /* Integer index always rounded down --> 4 steps backward, 5 steps forward */ -#endif output[i] = tmp; -- GitLab From bbc2aa81a08d2c6c942bec39d343cfac84bdd002 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 8 Apr 2025 16:40:05 +0300 Subject: [PATCH 37/42] Fix issue 1305. --- lib_com/ivas_prot.h | 9 +++++++++ lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 14 ++++++++++++++ lib_dec/ivas_objectRenderer_internal.c | 16 ++++++++++++++++ lib_dec/ivas_omasa_dec.c | 25 +++++++++++++++++++++++++ lib_dec/lib_dec.c | 11 +++++++++++ 6 files changed, 76 insertions(+) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4722f322d2..da8c856aa0 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5804,6 +5804,15 @@ void ivas_omasa_render_objects_from_mix( const int16_t output_frame /* i : output frame length per channel */ ); +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT +void ivas_omasa_gain_masa_tc( + float *output[], /* o : output synthesis signal */ + const float gainMasa, /* i : gain for MASA transport channels */ + const int16_t nchan_transport_ism, /* i : number of ISM TCs */ + const int16_t output_frame /* i : output frame length per channel */ +); +#endif + void ivas_omasa_dirac_rend_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ diff --git a/lib_com/options.h b/lib_com/options.h index ebfc3519ab..5bb6286cd0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,7 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define NONBE_1118_EVS_LR_HQ_BITERROR /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */ #define NONBE_1303_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ +#define NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT /* Nokia: issue 1305: Fix OMASA ext output in case of object editing */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 0d8c06abc1..bf9cb7bf54 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -925,6 +925,13 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + ivas_omasa_gain_masa_tc( p_output, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, *nSamplesRendered ); + } +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -1063,6 +1070,13 @@ ivas_error ivas_jbm_dec_render( { ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, *nSamplesRendered ); +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */ + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + ivas_omasa_gain_masa_tc( p_output, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, *nSamplesRendered ); + } +#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index d64720c44a..597480b8ea 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -185,7 +185,11 @@ ivas_error ivas_td_binaural_renderer_sf( if ( subframe_idx == ism_md_subframe_update_jbm ) { +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; @@ -198,7 +202,19 @@ ivas_error ivas_td_binaural_renderer_sf( ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + /* DISC OMASA ISM gaining with TDREND is done in ivas_dec_prepare_renderer()*/ + ismMetaData[nS].gain = 1; + } + else + { + ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; + } +#else ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; +#endif hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 497233122c..cb5c3129b7 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1321,3 +1321,28 @@ void ivas_omasa_render_objects_from_mix( return; } + +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT +/*--------------------------------------------------------------------------* + * ivas_omasa_gain_masa_channels() + * + * in case of external rendering with object editing, MASA transport channels + * need to be gained + *--------------------------------------------------------------------------*/ + +void ivas_omasa_gain_masa_tc( + float *output[], /* o : output synthesis signal */ + const float gainMasa, /* o : gain */ + const int16_t nchan_transport_ism, /* o : number of ISM TCs */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + /* Edited OMASA EXT MASA transport gaining */ + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( output[nchan_transport_ism + ch], gainMasa, output[nchan_transport_ism + ch], output_frame ); + } + + return; +} +#endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fc5bbc74d4..cc111b436a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1683,6 +1683,13 @@ ivas_error IVAS_DEC_SetEditableParameters( /* Copy edited values to hIsmMetaData struct */ if ( st_ivas->hIsmMetaData[obj] != NULL ) { +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; +#endif st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; @@ -2547,7 +2554,11 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#else else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) +#endif { metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; metadata->elevation = st_ivas->hIsmMetaData[objectIdx]->edited_elevation; -- GitLab From 6f534fffeb012d6659d76a5690cf24e2c9f1a328 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 8 Apr 2025 16:10:56 +0200 Subject: [PATCH 38/42] Fix channel number error in test_26444.py, and reversed order of test/ref in comparison --- tests/test_26444.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_26444.py b/tests/test_26444.py index 054242c4c9..4209fb9bab 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -165,9 +165,9 @@ def test_evs_26444( shutil.copy(ref, reffile) shutil.copy(test, testfile) output_differs, reason = cmp_pcm( - reffile, - testfile, - output_config, + testfile, # Setting testfile as reffile! Useful when comparing to float reference + reffile, # Setting reffile as testfile! Useful when comparing to float reference + 1, fs, get_mld=get_mld, mld_lim=get_mld_lim, -- GitLab From c20a7e415a76170a5b0c314b53661adb1276652c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 10 Apr 2025 15:49:42 +0200 Subject: [PATCH 39/42] address comments --- apps/decoder.c | 21 +++++--- lib_dec/lib_dec.c | 119 ++++++++++++++++++++++++++++++++++++---------- lib_dec/lib_dec.h | 19 ++++---- 3 files changed, 121 insertions(+), 38 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 94760fe1c7..dbd92244de 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -259,11 +259,7 @@ int main( * Open decoder handle *------------------------------------------------------------------------------------------*/ -#ifdef LIB_DEC_REVISION - if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.output_Fs, arg.decMode ) ) != IVAS_ERR_OK ) -#else if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -450,7 +446,7 @@ int main( uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; #ifdef LIB_DEC_REVISION - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.voipMode, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) #else @@ -1242,7 +1238,7 @@ static bool parseCmdlIVAS_dec( if ( !is_digits_only( argv[i] ) ) { #ifdef LIB_DEC_REVISION - fprintf( stderr, "Error: Render frame size not specified!\n\n" ); + fprintf( stderr, "Error: Render frame size is invalid or not specified!\n\n" ); usage_dec(); #endif return false; @@ -2122,6 +2118,19 @@ static ivas_error decodeG192( SplitFileReadWrite *splitRendWriter = NULL; int16_t isSplitRend, isSplitCoded; +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION + if ( arg.tsmEnabled ) + { + if ( ( error = IVAS_DEC_EnableTsm( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_EnableTsm, code: %d\n", error ); + return error; + } + } + +#endif +#endif if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 587fa6ece7..42718c0244 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -81,8 +81,10 @@ struct IVAS_DEC bool isInitialized; int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ - bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ - int16_t tsm_scale; /* scale for TSM operation */ +#ifdef DEBUGGING + bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ +#endif + int16_t tsm_scale; /* scale for TSM operation */ int16_t tsm_max_scaling; int16_t timeScalingDone; /* have we done already one TSM in a 20ms frame? */ float tsm_quality; @@ -159,10 +161,7 @@ static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nS /* may return an error but may still have allocated memory - thus run Close also in case of error to release memory */ ivas_error IVAS_DEC_Open( IVAS_DEC_HANDLE *phIvasDec, /* i/o: pointer to an IVAS decoder handle to be opened */ -#ifdef LIB_DEC_REVISION - const int32_t output_Fs, /* i : output sampling frequency */ -#endif - const IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ + const IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ ) { IVAS_DEC_HANDLE hIvasDec; @@ -192,12 +191,10 @@ ivas_error IVAS_DEC_Open( hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; -#ifdef LIB_DEC_REVISION - hIvasDec->nSamplesFrame = (uint16_t) ( output_Fs / FRAMES_PER_SEC ); -#else +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; - hIvasDec->nSamplesFrame = 0; #endif + hIvasDec->nSamplesFrame = 0; hIvasDec->hasBeenFedFrame = false; hIvasDec->hasBeenFedFirstGoodFrame = false; hIvasDec->hasDecodedFirstGoodFrame = false; @@ -211,7 +208,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->mode = mode; hIvasDec->bitstreamformat = G192; +#ifdef DEBUGGING hIvasDec->Opt_VOIP = 0; +#endif hIvasDec->amrwb_rfc4867_flag = -1; hIvasDec->prev_ft_speech = 1; /* RXDTX handler previous frametype flag for G.192 format AMRWB SID_FIRST detection */ hIvasDec->CNG = 0; /* RXDTX handler CNG = 1, no CNG = 0*/ @@ -433,6 +432,32 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( return IVAS_DEC_BS_UNKOWN; } +#ifdef LIB_DEC_REVISION + +/*---------------------------------------------------------------------* + * create_flush_buffer() + * + * Create flush buffer - needed for binaural outputs with TSM or in VoIP mode + *---------------------------------------------------------------------*/ + +static ivas_error create_flush_buffer( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate JBM flush buffer" ); + } + + hIvasDec->pcmType = IVAS_DEC_PCM_INT16; + set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + + return IVAS_ERR_OK; +} + +#endif + /*---------------------------------------------------------------------* * IVAS_DEC_Configure( ) @@ -445,10 +470,9 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const AUDIO_CONFIG outputConfig, /* i : output configuration */ -#ifdef LIB_DEC_REVISION - const bool voipMode, /* i : enable VoIP mode with JBM */ +#ifndef LIB_DEC_REVISION + const bool tsmEnabled, /* i : enable TSM */ #endif - const bool tsmEnabled, /* i : enable TSM */ const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -507,7 +531,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } +#ifndef LIB_DEC_REVISION hDecoderConfig->Opt_tsm = (int16_t) tsmEnabled; +#endif hDecoderConfig->Opt_LsCustom = (int16_t) customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = (int16_t) enableHeadRotation; hDecoderConfig->orientation_tracking = orientation_tracking; @@ -554,21 +580,16 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } -#ifndef LIB_DEC_REVISION hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; -#endif -#ifdef LIB_DEC_REVISION - /* Create flush buffer - needed for binaural outputs with TSM or in VoIP mode */ - if ( ( tsmEnabled || voipMode ) && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#else + /* Init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); if ( hIvasDec->flushbuffer == NULL ) @@ -578,6 +599,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } +#endif return IVAS_ERR_OK; } @@ -785,8 +807,11 @@ ivas_error IVAS_DEC_EnableVoIP( hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; +#ifdef DEBUGGING hIvasDec->Opt_VOIP = 1; +#endif hDecoderConfig->Opt_tsm = 1; + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); @@ -835,6 +860,7 @@ ivas_error IVAS_DEC_EnableVoIP( { return IVAS_ERR_FAILED_ALLOC; } + #ifdef NONBE_1122_KEEP_EVS_MODE_UNCHANGED if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -842,8 +868,14 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif -#ifndef LIB_DEC_REVISION - /* init flush buffer if necessary (only needed for binaural)*/ +#ifdef LIB_DEC_REVISION + /* init flush buffer (needed for binaural outputs) */ + if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in create_flush_buffer , code: %d\n", error ); + return error; + } +#else if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); @@ -851,6 +883,7 @@ ivas_error IVAS_DEC_EnableVoIP( set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif + return IVAS_ERR_OK; } @@ -3759,6 +3792,43 @@ ivas_error IVAS_DEC_VoIP_SetScale( return IVAS_ERR_OK; } +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION + +/*---------------------------------------------------------------------* + * IVAS_DEC_EnableTsm( ) + * + * Enable Time-Scale Modification (TSM) + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_EnableTsm( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + AUDIO_CONFIG output_config; + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasDec->st_ivas->hDecoderConfig->Opt_tsm = 1; + + /* init flush buffer if necessary (only needed for binaural) */ + output_config = hIvasDec->st_ivas->hDecoderConfig->output_config; + if ( hIvasDec->flushbuffer == NULL && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + return IVAS_ERR_OK; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_TSM_SetQuality( ) @@ -3797,6 +3867,7 @@ ivas_error IVAS_DEC_TSM_SetQuality( return IVAS_ERR_OK; } +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) @@ -4057,7 +4128,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * - * Return number of samples that have been rendered since the last 20ms render border + * Update the number of samples that have been rendered since the last 20ms render border *---------------------------------------------------------------------*/ static void update_voip_rendered20ms( @@ -4955,7 +5026,7 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( l_ts = (uint16_t) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; - if ( isInitialized_voip == false ) + if ( !isInitialized_voip ) #else apa_buffer_size = hIvasDec->nSamplesFrame; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 2f873d1856..2a02fd46ec 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -114,9 +114,6 @@ typedef ivas_error ( *JbmTraceFileWriterFn )( const void *data, void *writer ); /*! r: error code */ ivas_error IVAS_DEC_Open( IVAS_DEC_HANDLE *phIvasDec, /* i/o: pointer to an IVAS decoder handle to be opened */ -#ifdef LIB_DEC_REVISION - const int32_t output_Fs, /* i : output sampling frequency */ -#endif IVAS_DEC_MODE mode /* i : compatibility mode (EVS or IVAS) */ ); @@ -125,10 +122,9 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ -#ifdef LIB_DEC_REVISION - const bool voipMode, /* i : enable VoIP mode with JBM */ -#endif +#ifndef LIB_DEC_REVISION const bool tsmEnabled, /* i : enable TSM */ + #endif const IVAS_RENDER_FRAMESIZE renderFramesize,/* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -301,12 +297,19 @@ ivas_error IVAS_DEC_VoIP_SetScale( const int16_t scale /* i : TSM scale to set */ ); +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION +ivas_error IVAS_DEC_EnableTsm( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif + /*! r: error code */ ivas_error IVAS_DEC_TSM_SetQuality( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const float quality /* i : target TSM quality */ + const float quality /* i : target TSM quality */ ); - +#endif /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -- GitLab From 90e98b72dc871ab0b437b70ac6214abee425fa61 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 10 Apr 2025 19:03:14 +0200 Subject: [PATCH 40/42] Revert to correct ref/test order in test_26444.py --- tests/test_26444.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_26444.py b/tests/test_26444.py index 4209fb9bab..cdf065ef3e 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -165,8 +165,8 @@ def test_evs_26444( shutil.copy(ref, reffile) shutil.copy(test, testfile) output_differs, reason = cmp_pcm( - testfile, # Setting testfile as reffile! Useful when comparing to float reference - reffile, # Setting reffile as testfile! Useful when comparing to float reference + reffile, + testfile, 1, fs, get_mld=get_mld, -- GitLab From bbbb6b9a929cc12f79c3dc34525536b9f0f46c6c Mon Sep 17 00:00:00 2001 From: lintervo Date: Mon, 14 Apr 2025 09:24:28 +0300 Subject: [PATCH 41/42] Address MR comments --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_jbm_dec.c | 31 +++++++++++++++++-------------- lib_dec/ivas_omasa_dec.c | 8 ++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index da8c856aa0..dd07c2fafb 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5806,7 +5806,7 @@ void ivas_omasa_render_objects_from_mix( #ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT void ivas_omasa_gain_masa_tc( - float *output[], /* o : output synthesis signal */ + float *output[], /* i/o : output synthesis signal */ const float gainMasa, /* i : gain for MASA transport channels */ const int16_t nchan_transport_ism, /* i : number of ISM TCs */ const int16_t output_frame /* i : output frame length per channel */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index bf9cb7bf54..376bd00c4d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -925,13 +925,6 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); -#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT - /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */ - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) - { - ivas_omasa_gain_masa_tc( p_output, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, *nSamplesRendered ); - } -#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -1070,13 +1063,6 @@ ivas_error ivas_jbm_dec_render( { ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, *nSamplesRendered ); -#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT - /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */ - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) - { - ivas_omasa_gain_masa_tc( p_output, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, *nSamplesRendered ); - } -#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -2890,6 +2876,13 @@ void ivas_dec_prepare_renderer( { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + ivas_omasa_gain_masa_tc( st_ivas->hTcBuffer->tc, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available ); + } +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -2965,6 +2958,16 @@ void ivas_dec_prepare_renderer( { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */ + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + v_multc( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available ); + } + } +#endif } else { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index cb5c3129b7..b468df0439 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1324,16 +1324,16 @@ void ivas_omasa_render_objects_from_mix( #ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT /*--------------------------------------------------------------------------* - * ivas_omasa_gain_masa_channels() + * ivas_omasa_gain_masa_tc() * * in case of external rendering with object editing, MASA transport channels * need to be gained *--------------------------------------------------------------------------*/ void ivas_omasa_gain_masa_tc( - float *output[], /* o : output synthesis signal */ - const float gainMasa, /* o : gain */ - const int16_t nchan_transport_ism, /* o : number of ISM TCs */ + float *output[], /* i/o : output synthesis signal */ + const float gainMasa, /* i : gain */ + const int16_t nchan_transport_ism, /* i : number of ISM TCs */ const int16_t output_frame /* i : output frame length per channel */ ) { -- GitLab From eb5387c37434a53a119e7fcbdb8e8d6796c9c51d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 16 Apr 2025 13:04:38 +0200 Subject: [PATCH 42/42] fix ltv usage for renderer tests --- tests/renderer/utils.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index aac6a3d7c8..13b03edc0b 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -230,28 +230,29 @@ def run_renderer( # if in REF or CUT creation mode use the comparetestv if test_info.config.option.create_ref or test_info.config.option.create_cut: - FORMAT_TO_FILE = FORMAT_TO_FILE_COMPARETEST - elif test_info.config.option.use_ltv: + format_to_file = FORMAT_TO_FILE_COMPARETEST + else: + format_to_file = FORMAT_TO_FILE_SMOKETEST + + if test_info.config.option.use_ltv: if test_info.config.option.ltv_dir: - FORMAT_TO_FILE = dict() + format_to_file = dict() for k, v in FORMAT_TO_FILE_LTV.items(): - FORMAT_TO_FILE[k] = str(v).replace( + format_to_file[k] = str(v).replace( str(LTV_DIR), str(test_info.config.option.ltv_dir) ) else: - FORMAT_TO_FILE = FORMAT_TO_FILE_LTV - else: - FORMAT_TO_FILE = FORMAT_TO_FILE_SMOKETEST + format_to_file = FORMAT_TO_FILE_LTV if in_file is None: if metadata_input is not None: in_file = metadata_input in_name = metadata_input.stem elif not isinstance(in_fmt, str): - in_file = FORMAT_TO_FILE[in_fmt.stem] + in_file = format_to_file[in_fmt.stem] in_name = in_fmt.stem else: - in_file = FORMAT_TO_FILE[in_fmt] + in_file = format_to_file[in_fmt] in_name = in_fmt if out_file is None: -- GitLab