diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 1f950d7318ef8d5571306b550060041a6d62ac68..e07468982b796c350f0649c1baf686bf56bbc0e2 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 f1b70cbb44e6c63d707612fb07cd8c5920cc0304..3f26635f13947d1e6198991785fab4d685110ecd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,6 +190,8 @@ #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 UNIFIED_DECODING_PATHS_LEFTOVERS /* VA: issue 880: remove leftovers after NONBE_UNIFIED_DECODING_PATHS */ +#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 FIX_HRTF_LOAD_API // solves API conflicts between HRTF and object-editing features @@ -199,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_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 180560e0106e5a60a8f2e219cf1e57a6ba08aaf6..7d1336f45d563c2dfeaecb6d57253ffde298f288 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]; +#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 8aced209a4c338e996d2e00c81f80f6a951410b1..697eaa0c50bcb1ac17dc64149c365074158af156 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 d44bf3996d06a837cc002768ee17784a1fb57586..eac2e526ff0e06d8c5b54cd8a7fb4a0fc10a1bfe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -859,7 +859,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &st_ivas->p_output_f[n][0]; } +#ifdef FIX_NCHAN_BUFFERS + ch = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + for ( n = 0; n < ch; 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 { hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */ } @@ -2464,7 +2469,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 7bd25aa0cd9e746f0b8d56829fb238736348d095..636739017a167515be50bdaed6e4c4234ba0959b 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 dc58121f14c9775e362e8abeb767b0e4ae0bac39..b10c47dd5d637236c8eef6570b181bd283c7d134 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 276265ba36d207555d47a35eb8aedfa0ba02c744..a2e58a826c000304840e693272e158a58abb115b 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -751,6 +751,26 @@ 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 ); + } +#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 ) ); + +#endif #ifdef DEBUGGING assert( hSpar ); #endif diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 001e4ab170b5b3a521582ad787f71cf1911d3650..e5ce8503f09d9ff53b0d6475c4c175fbd6b87cef 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++ ) { diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 46f01c2cf4e9faa613db32d91955a5503234e71e..c153f3669c11de767eea8d9e8e086e481f7c3c9d 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 de384f2aeac3ada437ebabbd49e808f3e233333b..7193f78d27d361b684d645f77395233dd546d752 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 0e3abb08ee77023a39f1a6cce349969f00b0164b..93a4a17d79e86aca9f04b07117f8bddc805d4a34 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" ) ); }