From 5970ca8d4e65c5f4057ef888ee68f5feedb96f51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 13:36:23 +0200 Subject: [PATCH 1/8] port NONBE_1303_REND_GRANULARITY --- lib_com/ivas_prot_fx.h | 11 ++++- lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 15 ++++-- lib_dec/ivas_ism_dec_fx.c | 7 ++- lib_dec/ivas_ism_param_dec_fx.c | 16 ++++++- lib_dec/ivas_jbm_dec_fx.c | 30 ++++++++++++ lib_dec/ivas_masa_dec_fx.c | 15 ++++++ lib_dec/ivas_mc_param_dec_fx.c | 9 ++++ lib_dec/ivas_mc_paramupmix_dec_fx.c | 9 ++++ lib_dec/ivas_mct_dec_fx.c | 6 ++- lib_dec/ivas_objectRenderer_internal_fx.c | 5 ++ lib_dec/ivas_output_config_fx.c | 2 +- lib_dec/ivas_sba_dec_fx.c | 7 ++- lib_dec/ivas_spar_decoder_fx.c | 6 +++ lib_dec/lib_dec_fx.c | 47 ++++++++++++++++++- .../ivas_dirac_dec_binaural_functions_fx.c | 21 +++++++-- 16 files changed, 192 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7c3354dba..c111b6578 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -999,11 +999,18 @@ Word16 IGF_MapBitRateToIndex( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -Word16 ivas_jbm_dec_get_render_granularity( +#ifdef NONBE_1303_REND_GRANULARITY +Word16 ivas_jbm_dec_get_render_granularity_fx( + 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 +Word16 ivas_jbm_dec_get_render_granularity const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const Word32 output_Fs /* i : sampling rate */ + #endif ); // ivas_stereo_dft_com.c @@ -6221,7 +6228,7 @@ void ivas_renderer_select( #ifdef FIX_CREND_SIMPLIFY_CODE /*! r: secondary binaural renderer type */ -RENDERER_TYPE ivas_renderer_secondary_select( +RENDERER_TYPE ivas_renderer_secondary_select_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif diff --git a/lib_com/options.h b/lib_com/options.h index ef687f30e..00200921b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -146,6 +146,7 @@ #define FIX_1385_INIT_IGF_STOP_FREQ /* FhG: Initialize infoIGFStopFreq in init_igf_dec() */ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #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_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 21db1c479..a0d31cd19 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2645,7 +2645,7 @@ ivas_error ivas_init_decoder_fx( return error; } } - +#ifndef NONBE_1303_REND_GRANULARITY granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2655,6 +2655,7 @@ ivas_error ivas_init_decoder_fx( { return error; } +#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { @@ -2704,7 +2705,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; move32(); - +#ifndef NONBE_1303_REND_GRANULARITY test(); IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { @@ -2727,6 +2728,7 @@ ivas_error ivas_init_decoder_fx( return error; } } +#endif } IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) @@ -2765,7 +2767,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -3013,9 +3015,16 @@ ivas_error ivas_init_decoder_fx( 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_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( 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_fx( st_ivas ); IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index d7caec1ac..f49a6b054 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -169,7 +169,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* 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_fx( 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( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ #ifdef FIX_HRTF_LOAD @@ -181,8 +185,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 53c25b4d5..8c588272b 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -584,7 +584,11 @@ ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef NONBE_1303_REND_GRANULARITY + Word16 i, granularity; +#else Word16 i; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; IVAS_OUTPUT_SETUP hOutSetup; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -747,6 +751,9 @@ ivas_error ivas_param_ism_dec_open_fx( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); +#endif test(); IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) @@ -793,8 +800,11 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) - +#endif { return error; } @@ -807,8 +817,12 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; +#ifdef NONBE_1303_REND_GRANULARITY + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else move16(); // NS2SA IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a1988168c..aa1680d21 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3491,8 +3491,37 @@ static void ivas_jbm_dec_copy_tc( *--------------------------------------------------------------------------*/ /*! r: render granularity */ +#ifdef NONBE_1303_REND_GRANULARITY +Word16 ivas_jbm_dec_get_render_granularity_fx( + 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 */ +) +{ + Word16 render_granularity; + test(); + test(); + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */ + EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */ + EQ_32( 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_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); + } + ELSE + { + /* 1.25 ms granularity */ + render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); + move16(); + } + return render_granularity; +} +#else Word16 ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ @@ -3523,6 +3552,7 @@ Word16 ivas_jbm_dec_get_render_granularity( return render_granularity; } +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index c333cc21e..064cffa21 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -907,6 +907,9 @@ ivas_error ivas_masa_dec_open_fx( IF( st_ivas->hTcBuffer == NULL && NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { Word16 nchan_to_allocate, nchan_transport; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -951,7 +954,13 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, 1 ); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + + IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( 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_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1986,8 +1995,12 @@ ivas_error ivas_masa_dec_reconfigure_fx( TC_BUFFER_MODE buffer_mode_new; Word16 n_samples_granularity; +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); +#endif buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2015,7 +2028,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { +#ifndef NONBE_1303_REND_GRANULARITY n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ +#endif IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 243377a49..44a00fa2c 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -508,6 +508,9 @@ ivas_error ivas_param_mc_dec_open_fx( IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { Word16 n_cldfb_slots; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; move16(); @@ -537,7 +540,13 @@ ivas_error ivas_param_mc_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index fa36c4f34..6088abe19 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -408,6 +408,9 @@ ivas_error ivas_mc_paramupmix_dec_open( { Word16 nchan_to_allocate; Word16 nchan_tc; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -434,7 +437,13 @@ ivas_error ivas_mc_paramupmix_dec_open( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cb533bb5a..4087758da 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1019,8 +1019,12 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* 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_fx( 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 ); move16(); +#endif IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ #ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ @@ -1032,7 +1036,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 5e898d236..cc28eba22 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -63,9 +63,14 @@ ivas_error ivas_td_binaural_open_fx( } #ifdef FIX_HRTF_LOAD +#ifdef NONBE_1303_REND_GRANULARITY + test(); + 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/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 9832cd8a6..3b5d4ecef 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -611,7 +611,7 @@ void ivas_renderer_select( *-------------------------------------------------------------------------*/ /*! r: secondary binaural renderer type */ -RENDERER_TYPE ivas_renderer_secondary_select( +RENDERER_TYPE ivas_renderer_secondary_select_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 6a77c5c0e..9d6cb2192 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -192,6 +192,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { +#ifndef NONBE_1303_REND_GRANULARITY RENDERER_TYPE renderer_type_new; Word16 sba_order_internal; @@ -226,8 +227,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( move16(); } } - +#endif /* determine new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else granularity_new = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); @@ -237,6 +241,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( { granularity_new = i_mult( granularity_new, JBM_CLDFB_SLOTS_IN_SUBFRAME ); /*Q0*/ } +#endif /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index d0c22e7b6..475b6c88e 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -292,6 +292,11 @@ ivas_error ivas_spar_dec_open_fx( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else test(); test(); @@ -303,6 +308,7 @@ ivas_error ivas_spar_dec_open_fx( } IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( 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_fx.c b/lib_dec/lib_dec_fx.c index 4a929f97e..30a3734b8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3459,7 +3459,11 @@ ivas_error IVAS_DEC_ReadFormat( MC_MODE mc_mode_old; Word16 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, renderer_type_sec_new; +#endif test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -3475,6 +3479,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_fx( st_ivas ); +#endif move32(); move32(); move32(); @@ -3483,6 +3490,9 @@ ivas_error IVAS_DEC_ReadFormat( move32(); move32(); move32(); +#ifdef NONBE_1303_REND_GRANULARITY + move32(); +#endif output_config = st_ivas->hDecoderConfig->output_config; move32(); @@ -3512,7 +3522,7 @@ ivas_error IVAS_DEC_ReadFormat( *binaural_renderer = renderer_type_to_mode( st_ivas->renderer_type ); /* Select secondary binaural renderer (used in combined formats) */ - renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); + renderer_type_sec_new = ivas_renderer_secondary_select_fx( st_ivas ); *binaural_renderer_sec = renderer_type_to_mode( renderer_type_sec_new ); /* select HRTF audio configuration to load the right HRTF set for the external binary file */ @@ -3574,6 +3584,40 @@ ivas_error IVAS_DEC_ReadFormat( } } +#ifdef NONBE_1303_REND_GRANULARITY + test(); + test(); + test(); + test(); + /* JBM: compensate when binaural renderer granularity changes (happens in bitrate switching) */ + IF( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm && + ( NE_32( renderer_type_old, st_ivas->renderer_type ) || + NE_32( renderer_type_sec_old, renderer_type_sec_new ) ) ) + { + Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); + + // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 + + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + st_ivas->nchan_ism = 0; // ToDo: temporary hack to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1199 + } + + IF( st_ivas->hTcBuffer == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* when granularity goes down, render what still fits in the new granularity */ + IF( LT_32( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + { + IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + } +#else #ifdef FIX_HRTF_LOAD test(); test(); @@ -3603,6 +3647,7 @@ ivas_error IVAS_DEC_ReadFormat( } } } +#endif #endif } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index e2bb6efb0..4867bac31 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -181,6 +181,15 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + move16(); + renderer_type = st_ivas->renderer_type; + move32(); +#endif + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; @@ -200,13 +209,14 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( hDiracDecBin->phHrtfParambin = NULL; } +#ifndef NONBE_1303_REND_GRANULARITY output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); nBins = st_ivas->hSpatParamRendCom->num_freq_bands; move16(); renderer_type = st_ivas->renderer_type; move32(); - +#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) @@ -346,7 +356,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } - if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + IF( pos_idx == 0 ) /* open decorrelator only for the main direction */ { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { @@ -375,9 +385,10 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( } } } - else + ELSE { hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ + move16(); } hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ @@ -401,6 +412,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism ); } +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); +#else n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); test(); test(); @@ -408,6 +422,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( { n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } +#endif IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) { -- GitLab From 8132e633befc8a6251d1818fd4105c8ed761fdd9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 14:24:49 +0200 Subject: [PATCH 2/8] clang-format --- lib_dec/ivas_ism_dec_fx.c | 3 ++- lib_dec/ivas_mct_dec_fx.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index f49a6b054..59c5866fb 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -185,7 +185,8 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + ELSE + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 4087758da..bd8abb635 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1036,7 +1036,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { -- GitLab From 6a8d918db884d41bd77078069b906a376e564d54 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 18:56:55 +0200 Subject: [PATCH 3/8] clang-format --- lib_dec/ivas_mct_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index bd8abb635..12cf0402f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1028,6 +1028,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ #ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ + #else IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) ){ return error; -- GitLab From 45f42163303ca2697f88e1f8265ed6a56a95167e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 19:03:43 +0200 Subject: [PATCH 4/8] ivas_jbm_dec_set_discard_samples() -> ivas_jbm_dec_set_discard_samples_fx --- lib_com/ivas_prot_fx.h | 6 +++--- lib_dec/ivas_init_dec_fx.c | 6 +++--- lib_dec/ivas_ism_dec_fx.c | 6 +++--- lib_dec/ivas_jbm_dec_fx.c | 6 +++--- lib_dec/ivas_masa_dec_fx.c | 4 ++-- lib_dec/ivas_mct_dec_fx.c | 6 +++--- lib_dec/ivas_sba_dec_fx.c | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c111b6578..9471571d8 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6251,15 +6251,15 @@ int16_t is_DTXrate( * JBM prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -void ivas_jbm_dec_tc_buffer_close( +void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a0d31cd19..9b47652c1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3019,11 +3019,11 @@ ivas_error ivas_init_decoder_fx( granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( 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 ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( 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_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) #endif { return error; @@ -3544,7 +3544,7 @@ void ivas_destroy_dec_fx( st_ivas->hDecoderConfig = NULL; } - ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer ); IF( st_ivas->hJbmMetadata != NULL ) { diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 59c5866fb..1543371c1 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -186,9 +186,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -354,7 +354,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index aa1680d21..f754e2cf3 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2977,7 +2977,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) { @@ -3878,7 +3878,7 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( * Close JBM transport channel buffer *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_tc_buffer_close( +void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { @@ -3981,7 +3981,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( * *--------------------------------------------------------------------------*/ -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 064cffa21..bc1845014 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -2001,7 +2001,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); #endif - buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; @@ -2033,7 +2033,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( #endif IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 12cf0402f..72af54701 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1037,9 +1037,9 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1605,7 +1605,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 9d6cb2192..12338d1f4 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -269,7 +269,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 3eb0cd2e382c776872caedea70bc3c1f2e1215dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 20:58:44 +0200 Subject: [PATCH 5/8] clang-format --- lib_dec/ivas_ism_dec_fx.c | 2 +- lib_dec/ivas_mct_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 1543371c1..ab7bf6aff 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -186,7 +186,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 72af54701..5afb5fc9a 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1037,7 +1037,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE - IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { -- GitLab From ef35f2aa26e20e5dddcaee3c9f64469093db332f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Oct 2025 16:56:03 +0200 Subject: [PATCH 6/8] clang-format --- lib_dec/ivas_ism_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 6032e102a..a9dec850d 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -174,7 +174,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef NONBE_1303_REND_GRANULARITY tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( 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 ); + 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( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) -- GitLab From c1d71e3d7fec7361e4a2b74eaf98798bded184a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Oct 2025 17:28:05 +0200 Subject: [PATCH 7/8] fix porting NONBE_1200_ISM_JBM_BRATE_SW_FLUSH into NONBE_1303_REND_GRANULARITY --- lib_dec/lib_dec_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 754b7662c..1b6c177e0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3731,7 +3731,12 @@ ivas_error IVAS_DEC_ReadFormat( { Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); +#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH + st_ivas->nchan_transport = nchan_transport_old; + move16(); +#else // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 +#endif if ( st_ivas->ivas_format == MASA_FORMAT ) { -- GitLab From 8abc3e76b6b96681182433b0043b2180c06a03c4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Oct 2025 18:59:16 +0200 Subject: [PATCH 8/8] fix wrt. NONBE_1199_OMASA_JBM_BRATE_SW_FLUSH and NONBE_1303_REND_GRANULARITY dependency --- lib_com/ivas_prot_fx.h | 7 ++++--- lib_dec/lib_dec_fx.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 06bfe2e52..d829fa95d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1010,14 +1010,15 @@ Word16 ivas_jbm_dec_get_render_granularity_fx( 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 -Word16 ivas_jbm_dec_get_render_granularity +Word16 ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const Word32 output_Fs /* i : sampling rate */ - #endif -); +); +#endif // ivas_stereo_dft_com.c void stereo_dft_config_fx( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e3541a20c..bb49a02a4 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3768,11 +3768,12 @@ ivas_error IVAS_DEC_ReadFormat( // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 #endif +#ifndef NONBE_1199_OMASA_JBM_BRATE_SW_FLUSH if ( st_ivas->ivas_format == MASA_FORMAT ) { st_ivas->nchan_ism = 0; // ToDo: temporary hack to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1199 } - +#endif IF( st_ivas->hTcBuffer == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; -- GitLab