From f2aaa722e9beb03588169cdbc7d7fd4f901e00f5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 21 Oct 2025 22:25:42 +0200 Subject: [PATCH 1/2] port FIX_NCHAN_BUFFERS andFIX_RENDERER_STACK --- Workspace_msvc/lib_com.vcxproj.filters | 8 +- lib_com/options.h | 2 + lib_dec/ivas_dirac_dec.c | 24 +++++- lib_dec/ivas_init_dec.c | 7 +- lib_dec/ivas_jbm_dec.c | 1 - lib_dec/ivas_masa_dec.c | 30 +++++++ lib_dec/ivas_mct_dec.c | 12 +++ lib_dec/ivas_sba_dec.c | 14 ++++ lib_rend/ivas_crend.c | 5 ++ lib_rend/ivas_dirac_dec_binaural_functions.c | 29 ++++++- lib_rend/ivas_output_init.c | 84 +++++++++++++++++++- 11 files changed, 207 insertions(+), 9 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 1f950d731..e07468982 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -469,11 +469,15 @@ common_ivas_c - - common_ivas_c + + common_ivas_c + + + common_ivas_c + diff --git a/lib_com/options.h b/lib_com/options.h index e77fa5b8f..518ef1046 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -189,6 +189,8 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ #define LIB_DEC_REVISION /* VA: cleaning and simplification of lib_dec.c */ +#define FIX_NCHAN_BUFFERS /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */ +#define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index b5173e70d..a129cb4dd 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1552,7 +1552,12 @@ void ivas_dirac_dec_render( uint16_t slot_size, n_samples_sf, ch, nchan_intern; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; +#ifdef FIX_RENDERER_STACK + float *p_output_f[MAX_OUTPUT_CHANNELS]; + float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#else float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // VE2SB: TBV +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1563,7 +1568,11 @@ void ivas_dirac_dec_render( for ( ch = 0; ch < nchan_intern; ch++ ) { output_f_local[ch] = output_f_local_buff[ch]; +#ifdef FIX_RENDERER_STACK + p_output_f[ch] = output_f[ch]; +#else set_zero( output_f_local_buff[ch], nSamplesAsked ); +#endif } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -1585,16 +1594,29 @@ void ivas_dirac_dec_render( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); + n_samples_sf = hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->slot_size; + for ( ch = 0; ch < nchan_intern; ch++ ) { +#ifdef FIX_RENDERER_STACK + /* move to output */ + if ( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( st_ivas->hDirACRend->hOutSetup.separateChannelIndex == ch || st_ivas->hDirACRend->hOutSetup.separateChannelIndex + 1 == ch ) ) ) + { + mvr2r( output_f_local_buff[ch], p_output_f[ch], n_samples_sf ); + } + + p_output_f[ch] += n_samples_sf; +#else output_f_local[ch] += n_samples_sf; +#endif } /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } +#ifndef FIX_RENDERER_STACK for ( ch = 0; ch < nchan_intern; ch++ ) { if ( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( st_ivas->hDirACRend->hOutSetup.separateChannelIndex == ch || st_ivas->hDirACRend->hOutSetup.separateChannelIndex + 1 == ch ) ) ) @@ -1602,7 +1624,7 @@ void ivas_dirac_dec_render( mvr2r( output_f_local_buff[ch], output_f[ch], *nSamplesRendered ); } } - +#endif if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8aced209a..697eaa0c5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -489,7 +489,7 @@ ivas_error ivas_dec_setup( } /*-------------------------------------------------------------------* - * Read other signling (ISM/MC mode, number of channels, etc.) + * Read other signaling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ if ( is_DTXrate( ivas_total_brate ) == 0 ) @@ -2428,7 +2428,12 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifdef FIX_NCHAN_BUFFERS + k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + for ( n = 0; n < k; n++ ) +#else for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) +#endif { /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4a18112f1..6ce00de85 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2313,7 +2313,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer = st_ivas->hTcBuffer; - /* if granularity changes, adapt subframe_nb_slots */ if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 7bd25aa0c..636739017 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1326,13 +1326,19 @@ ivas_error ivas_masa_dec_reconfigure( Decoder_State **sts; int32_t ivas_total_brate, last_ivas_total_brate; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; +#ifdef FIX_NCHAN_BUFFERS + int16_t nchan_out_buff_old, nchan_out_buff; +#endif ivas_error error; int16_t pos_idx; int32_t ism_total_brate; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif /* Copy state to TC buffer if granularity matches and we are not in OMASA EXT rendering mode */ if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -1500,8 +1506,17 @@ ivas_error ivas_masa_dec_reconfigure( } else { +#ifdef FIX_NCHAN_BUFFERS + tc_nchan_to_allocate = BINAURAL_CHANNELS; + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; + } +#else tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; +#endif } + 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 @@ -1560,6 +1575,21 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef FIX_NCHAN_BUFFERS + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT ) /* note: switching with OMASA is addressed in ivas_omasa_dec_config() */ + { + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index dc58121f1..b10c47dd5 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1318,7 +1318,19 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifdef FIX_NCHAN_BUFFERS + tc_nchan_allocate_new = BINAURAL_CHANNELS; + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; + } + else if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + tc_nchan_allocate_new++; + } +#else tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; +#endif tc_nchan_full_new = tc_nchan_allocate_new; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 276265ba3..eaa4c4e3c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -751,6 +751,20 @@ ivas_error ivas_sba_dec_render( nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; +#ifdef FIX_NCHAN_BUFFERS + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_out = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + nchan_out = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out - st_ivas->nchan_ism ); + } + } + + nchan_out = min( nchan_out, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + +#endif #ifdef DEBUGGING assert( hSpar ); #endif diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 46f01c2cf..c153f3669 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1513,8 +1513,13 @@ static ivas_error ivas_rend_crendConvolver( const float *pFreq_filt_re, *pFreq_filt_im; float *pFreq_buf_re = NULL, *pFreq_buf_im = NULL; float *pFreq_buf2_re = NULL, *pFreq_buf2_im = NULL; +#ifdef FIX_RENDERER_STACK float pOut[2 /*Re,Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; float tmp_out_re[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp_out_im[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#else + float pOut[2 /*Re,Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + float tmp_out_re[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp_out_im[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif CREND_HANDLE hCrend; ivas_error error; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index de384f2ae..7193f78d2 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -200,7 +200,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - for ( bin = 0; bin < nBins; bin++ ) { binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); @@ -322,7 +321,20 @@ ivas_error ivas_dirac_dec_init_binaural_data( int16_t nchan_to_allocate; int16_t n_samples_granularity; +#ifdef FIX_NCHAN_BUFFERS + nchan_to_allocate = BINAURAL_CHANNELS; + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_to_allocate = 2 * BINAURAL_CHANNELS; + } + else if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + nchan_to_allocate++; + } +#else nchan_to_allocate = 2 * BINAURAL_CHANNELS; +#endif + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { nchan_to_allocate = BINAURAL_CHANNELS + st_ivas->nchan_ism; @@ -455,17 +467,24 @@ void ivas_dirac_dec_binaural_render( uint16_t nchan_out; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; +#ifndef FIX_RENDERER_STACK float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; int16_t output_length; +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_out = BINAURAL_CHANNELS; #ifdef DEBUGGING assert( hSpatParamRendCom ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { +#ifdef FIX_RENDERER_STACK + output_f_local[ch] = output_f[ch]; +#else output_f_local[ch] = output_f_local_buff[ch]; +#endif } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -484,7 +503,9 @@ void ivas_dirac_dec_binaural_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif +#ifndef FIX_RENDERER_STACK output_length = 0; +#endif for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hSpatParamRendCom->subframe_nbslots[subframe_idx]; @@ -495,17 +516,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } +#ifndef FIX_RENDERER_STACK output_length += n_samples_sf; - +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } +#ifndef FIX_RENDERER_STACK for ( ch = 0; ch < nchan_out; ch++ ) { mvr2r( output_f_local_buff[ch], output_f[ch], output_length ); } - +#endif if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) { hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 0e3abb08e..93a4a17d7 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -271,7 +271,11 @@ int16_t ivas_get_nchan_buffers_dec( output_config = st_ivas->hDecoderConfig->output_config; +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = st_ivas->nchan_transport; +#else nchan_out_buff = MAX_OUTPUT_CHANNELS; +#endif if ( st_ivas->ivas_format == MONO_FORMAT ) { @@ -283,6 +287,14 @@ int16_t ivas_get_nchan_buffers_dec( } else if ( st_ivas->ivas_format == ISM_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); + + if ( st_ivas->ism_mode == ISM_MODE_PARAM || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else nchan_out_buff = st_ivas->nchan_ism; if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) @@ -294,9 +306,16 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + int16_t nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + + nchan_out_buff = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); +#else int16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; @@ -311,9 +330,18 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); } nchan_out_buff = max( nchan_out_buff, nchan_internal ); +#endif } else if ( st_ivas->ivas_format == MASA_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_out_buff = 2 * BINAURAL_CHANNELS; + } +#else nchan_out_buff = CPE_CHANNELS; if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) @@ -333,9 +361,13 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS; } +#endif } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport + st_ivas->nchan_ism ); +#else nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS; if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) @@ -351,9 +383,32 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + int16_t nchan_internal; + + nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_internal += st_ivas->nchan_ism; + } + + if ( st_ivas->hMCT != NULL ) + { + nchan_internal = ( ( nchan_internal + 1 ) >> 1 ) << 1; /* ensure odd number of channels in MCT */ + } + + nchan_out_buff = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); + + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else int16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->nchan_ism + st_ivas->nchan_transport; @@ -391,9 +446,27 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = max( nchan_out_buff, nchan_internal + st_ivas->nchan_ism ); } nchan_out_buff = min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->nchan_transport + 1 ); + } + + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_out_buff = 2 * BINAURAL_CHANNELS; + } + else + { + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) @@ -405,6 +478,7 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -434,8 +508,16 @@ ivas_error ivas_output_buff_dec( { for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { +#ifdef FIX_NCHAN_BUFFERS +#ifdef DEBUGGING + if ( p_output_f[ch] != NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); + } +#endif +#endif /* note: these are intra-frame heap memories */ - if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } -- GitLab From 9981ea8226030442ddaebe2583a0b12aae40f724 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 22 Oct 2025 19:08:31 +0200 Subject: [PATCH 2/2] port FIX_1372_OSBA_OBJECT_EDITING --- lib_com/options.h | 2 +- lib_dec/ivas_sba_dec.c | 6 ++++++ lib_dec/ivas_spar_decoder.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 88e2ba83b..3f26635f1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -201,7 +201,7 @@ #define FIX_1217_OBJECT_EDIT_FILE_INTERFACE /* Nokia: issue #1217: add decoder functionality to read object edit instructions from a file */ #define NONBE_1217_OBJ_EDIT_FOA /* VA/Nokia: isse 1217: fix crash in object editing to FOA output in ParamISM */ #define NONBE_FIX_1255_OBJ_EDIT_JBM /* VA: issue 1255: restore object editing in JBM */ - +#define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index eaa4c4e3c..a2e58a826 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -760,6 +760,12 @@ ivas_error ivas_sba_dec_render( { nchan_out = max( nchan_internal, st_ivas->hDecoderConfig->nchan_out - st_ivas->nchan_ism ); } +#ifdef FIX_1372_OSBA_OBJECT_EDITING + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out = BINAURAL_CHANNELS; + } +#endif } nchan_out = min( nchan_out, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 001e4ab17..e5ce8503f 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1435,7 +1435,11 @@ void ivas_spar_dec_upmixer_sf( p_tc[i] = st_ivas->hTcBuffer->tc[i + nchan_ism] + slot_idx_start * slot_size; } +#ifdef FIX_1372_OSBA_OBJECT_EDITING + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) +#else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif { for ( i = 0; i < nchan_ism; i++ ) { -- GitLab