From 5f95717bbffc48107a30a41dfb2fe8980ce74bc8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 11:58:23 +0200 Subject: [PATCH 01/13] issue 1330: memory savings in the JBM decoder; under FIX_1330_JBM_MEMORY --- lib_com/ivas_prot.h | 10 +++++ lib_com/ivas_tools.c | 12 +++++ lib_com/options.h | 2 + lib_dec/ivas_init_dec.c | 34 +++++++++++++-- lib_dec/ivas_ism_dec.c | 16 ++++++- lib_dec/ivas_ism_renderer.c | 22 ++++++++-- lib_dec/ivas_jbm_dec.c | 27 ++++++++++++ lib_dec/ivas_masa_dec.c | 8 ++++ lib_dec/ivas_mct_dec.c | 6 ++- lib_dec/ivas_omasa_dec.c | 34 +++++++++++++-- lib_dec/ivas_osba_dec.c | 8 ++++ lib_dec/ivas_sba_dec.c | 5 ++- lib_rend/ivas_output_init.c | 87 +++++++++++++++++++++++++++++++------ 13 files changed, 243 insertions(+), 28 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8121030b1c..c4ef05e123 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -309,7 +309,13 @@ ivas_error ivas_init_decoder( ivas_error ivas_output_buff_dec( float *p_output_f[], /* i/o: output audio buffers */ const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ +#ifdef FIX_1330_JBM_MEMORY + const int16_t nchan_out_buff, /* i : number of output channels */ + const int16_t Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else const int16_t nchan_out_buff /* i : number of output channels */ +#endif ); ivas_error stereo_dmx_evs_init_encoder( @@ -5823,8 +5829,12 @@ void ivas_omasa_separate_object_render_jbm( const uint16_t nSamplesRendered, /* i : number of samples rendered */ float input_f[][L_FRAME48k], /* i : separated object signal */ float *output_f[], /* o : rendered time signal */ +#ifdef FIX_1330_JBM_MEMORY + const int16_t subframes_rendered /* i : number of subframes rendered */ +#else const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ +#endif ); void ivas_omasa_encode_masa_to_total( diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index baa98da6b7..d2dde26fb5 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -198,12 +198,24 @@ void ivas_buffer_deinterleaved_to_interleaved( ) { int16_t ch, m; +#ifdef FIX_1330_JBM_MEMORY + float buffer[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < n_channels; ch++ ) + { + mvr2r( audio[ch], buffer[ch], frame_length ); + } +#endif for ( ch = 0; ch < n_channels; ch++ ) { for ( m = 0; m < frame_length; m++ ) { +#ifdef FIX_1330_JBM_MEMORY + audio_out[m * n_channels + ch] = buffer[ch][m]; +#else audio_out[m * n_channels + ch] = audio[ch][m]; +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index 88467e1090..df668e606c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,8 @@ /*#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_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ + /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a303c6d65b..0424ced917 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2363,7 +2363,7 @@ ivas_error ivas_init_decoder( } } - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->Opt_tsm ) + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && hDecoderConfig->Opt_tsm ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -2378,7 +2378,18 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); +#ifdef FIX_1330_JBM_MEMORY + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + { + st_ivas->p_output_f[n] = NULL; + } + + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, 0, k, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } +#else for ( n = 0; n < k; n++ ) { /* note: these are intra-frame heap memories */ @@ -2392,7 +2403,7 @@ ivas_error ivas_init_decoder( { st_ivas->p_output_f[n] = NULL; } - +#endif return error; } @@ -2849,12 +2860,27 @@ void ivas_destroy_dec( /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); +#ifdef FIX_1330_JBM_MEMORY + /* JBM decoding: floating-point output audio buffers are shared with bufeers from 'hTcBuffer' */ + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + int16_t nchan_tc_jbm = max( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); + + for ( i = 0; i < nchan_tc_jbm; i++ ) + { + st_ivas->p_output_f[i] = NULL; + } + } + + /* Decoder configuration structure */ +#endif if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); st_ivas->hDecoderConfig = NULL; } + /* JBM TC buffer structure */ ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); if ( st_ivas->hJbmMetadata != NULL ) @@ -2863,7 +2889,7 @@ void ivas_destroy_dec( st_ivas->hJbmMetadata = NULL; } - /* floating-point output audio buffers */ + /* floating-point output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { if ( st_ivas->p_output_f[i] != NULL ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index a76db36306..64f8d15dab 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -266,17 +266,17 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } +#ifndef FIX_1330_JBM_MEMORY /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ 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 /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ @@ -316,6 +316,18 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifdef FIX_1330_JBM_MEMORY + + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + 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, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 3d18fea93b..55a77e0ba8 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -193,6 +193,7 @@ void ivas_ism_render_sf( ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2; } +#ifndef FIX_1330_JBM_MEMORY if ( st_ivas->hDecoderConfig->Opt_tsm ) { for ( i = 0; i < num_objects; i++ ) @@ -202,12 +203,15 @@ void ivas_ism_render_sf( } else { +#endif for ( i = 0; i < num_objects; i++ ) { mvr2r( &output_f[i][tc_offset], tc_local[i], n_samples_to_render ); p_tc[i] = tc_local[i]; } +#ifndef FIX_1330_JBM_MEMORY } +#endif for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -428,12 +432,16 @@ void ivas_omasa_separate_object_renderer_close( *-------------------------------------------------------------------------*/ void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float input_f_in[][L_FRAME48k], /* i : separated object signal */ - float *output_f[], /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ + float input_f_in[][L_FRAME48k], /* i : separated object signal */ + float *output_f[], /* o : rendered time signal */ +#ifdef FIX_1330_JBM_MEMORY + const int16_t subframes_rendered /* i : number of subframes rendered */ +#else const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ +#endif ) { VBAP_HANDLE hVBAPdata; @@ -474,13 +482,16 @@ void ivas_omasa_separate_object_render_jbm( num_objects = st_ivas->nchan_ism; } +#ifndef FIX_1330_JBM_MEMORY offsetSamples = slots_rendered * hSpatParamRendCom->slot_size; +#endif for ( j = 0; j < nchan_out_woLFE + num_lfe; j++ ) { output_f_local[j] = output_f[j]; } +#ifndef FIX_1330_JBM_MEMORY if ( st_ivas->hDecoderConfig->Opt_tsm ) { for ( obj = 0; obj < num_objects; obj++ ) @@ -490,11 +501,14 @@ void ivas_omasa_separate_object_render_jbm( } else { +#endif for ( obj = 0; obj < num_objects; obj++ ) { input_f[obj] = input_f_in[obj]; } +#ifndef FIX_1330_JBM_MEMORY } +#endif slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; first_sf = subframes_rendered; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 173d031628..9aeb4f38fe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -763,7 +763,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( float tmp_buf[MAX_JBM_L_FRAME48k]; float *p_data_f[FOA_CHANNELS + MAX_NUM_OBJECTS]; int16_t n, n_render_timeslots, n_ch_cldfb; +#ifdef FIX_1330_JBM_MEMORY + int16_t ch, offset, len_offset; +#else int16_t ch; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -781,6 +785,22 @@ void ivas_jbm_dec_feed_tc_to_renderer( n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; +#ifdef FIX_1330_JBM_MEMORY + /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': + in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers + pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ + len_offset = NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); + if ( len_offset < L_FRAME48k ) + { + offset = 0; + for ( ch = 0; ch < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ ) + { + hTcBuffer->tc[ch] = &hTcBuffer->tc_buffer[offset]; + offset += len_offset; + } + } + +#endif for ( ch = 0; ch < n_ch_full_copy; ch++ ) { mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering ); @@ -2084,6 +2104,9 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate( if ( Opt_tsm ) { n_samp_full = ( NS2SA( output_Fs, MAX_JBM_L_FRAME_NS ) ); +#ifdef FIX_1330_JBM_MEMORY + n_samp_full = max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ +#endif n_samp_residual = hTcBuffer->n_samples_granularity - 1; } else @@ -2376,7 +2399,11 @@ static void ivas_jbm_dec_tc_buffer_playout( for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { +#ifdef FIX_1330_JBM_MEMORY + output[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered; +#else mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); +#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b698395d75..3d7d78d55d 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1474,6 +1474,10 @@ ivas_error ivas_masa_dec_reconfigure( ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + /*-----------------------------------------------------------------* + * JBM TC buffers + *-----------------------------------------------------------------*/ + { int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; @@ -1544,7 +1548,11 @@ ivas_error ivas_masa_dec_reconfigure( 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 ); +#ifdef FIX_1330_JBM_MEMORY + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 8fb966c365..b495f594c7 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1320,6 +1320,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) { @@ -1344,8 +1345,11 @@ static ivas_error ivas_mc_dec_reconfig( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - +#ifdef FIX_1330_JBM_MEMORY + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index beaf645fa0..d6e0060a57 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -470,7 +470,11 @@ ivas_error ivas_omasa_dec_config( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#ifdef FIX_1330_JBM_MEMORY + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -673,19 +677,27 @@ void ivas_omasa_dirac_rend_jbm( ) { int16_t subframes_rendered; +#ifndef FIX_1330_JBM_MEMORY int16_t slots_rendered; +#endif int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; +#ifndef FIX_1330_JBM_MEMORY if ( !st_ivas->hDecoderConfig->Opt_tsm ) { +#endif *nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { mvr2r( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#ifdef FIX_1330_JBM_MEMORY + if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#else + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#endif { /* Gain separated object, if edited */ for ( n = 0; n < st_ivas->nchan_ism; n++ ) @@ -704,14 +716,22 @@ void ivas_omasa_dirac_rend_jbm( mvr2r( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); /* Gain discrete objects, if edited */ - if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#ifdef FIX_1330_JBM_MEMORY + if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#else + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#endif { v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); } } /* Gain MASA part, if edited */ - if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) +#ifdef FIX_1330_JBM_MEMORY + if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) +#else + if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) +#endif { for ( int16_t ch = 0; ch < 2; ch++ ) { @@ -719,14 +739,22 @@ void ivas_omasa_dirac_rend_jbm( } } } +#ifndef FIX_1330_JBM_MEMORY } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; +#ifndef FIX_1330_JBM_MEMORY slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; +#endif ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#ifdef FIX_1330_JBM_MEMORY + ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered ); +#else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); +#endif return; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index afa273fdbb..f697fe3632 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -258,7 +258,11 @@ ivas_error ivas_osba_render_sf( float *p_output[] /* o : rendered time signal */ ) { +#ifdef FIX_1330_JBM_MEMORY + int16_t n, tc_offset; +#else int16_t n; +#endif float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output_ism[MAX_OUTPUT_CHANNELS]; ivas_error error; @@ -268,15 +272,19 @@ ivas_error ivas_osba_render_sf( p_output_ism[n] = &output_ism[n][0]; } +#ifndef FIX_1330_JBM_MEMORY if ( !st_ivas->hDecoderConfig->Opt_tsm ) { int16_t tc_offset; +#endif tc_offset = st_ivas->hTcBuffer->n_samples_rendered; for ( n = 0; n < st_ivas->nchan_ism; n++ ) { mvr2r( &p_output[n][tc_offset], &output_ism[n][tc_offset], nSamplesAsked ); } +#ifndef FIX_1330_JBM_MEMORY } +#endif if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8ddc7f0406..4e00d948ee 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -591,8 +591,11 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - +#ifdef FIX_1330_JBM_MEMORY + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 560f9f6661..be4af1b714 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -370,36 +370,97 @@ int16_t ivas_get_nchan_buffers_dec( ivas_error ivas_output_buff_dec( float *p_output_f[], /* i/o: output audio buffers */ const int16_t nchan_out_buff_old, /* i : previous frame number of output channels */ - const int16_t nchan_out_buff /* i : number of output channels */ +#ifdef FIX_1330_JBM_MEMORY + const int16_t nchan_out_buff, /* i : number of output channels */ + const int16_t Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else + const int16_t nchan_out_buff /* i : number of output channels */ +#endif ) { int16_t ch; - if ( nchan_out_buff > nchan_out_buff_old ) +#ifdef FIX_1330_JBM_MEMORY + if ( !Opt_tsm ) { - for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + /* non-JBM decoding: allocate output audio buffers here; audio buffers from 'hTcBuffer' are set to NULL */ + +#endif + if ( nchan_out_buff > nchan_out_buff_old ) { -#ifdef DEBUGGING - if ( p_output_f[ch] != NULL ) + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); - } +#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 - /* note: these are intra-frame heap memories */ - if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + /* note: these are intra-frame heap memories */ + 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" ) ); + } + } + } + else + { + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + free( p_output_f[ch] ); + p_output_f[ch] = NULL; } } +#ifdef FIX_1330_JBM_MEMORY } else { - for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) + /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */ + int16_t nchan_tc_jbm; + nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + + if ( nchan_out_buff <= nchan_tc_jbm ) + { + for ( ch = 0; ch < nchan_out_buff; ch++ ) + { + p_output_f[ch] = hTcBuffer->tc[ch]; + } + + for ( ; ch < nchan_out_buff_old; ch++ ) + { + p_output_f[ch] = NULL; + } + } + else { - free( p_output_f[ch] ); - p_output_f[ch] = NULL; + for ( ch = 0; ch < nchan_tc_jbm; ch++ ) + { + p_output_f[ch] = hTcBuffer->tc[ch]; + } + + /* when not enough audio buffers in 'hTcBuffer', allocate remaining output audio buffers here */ + for ( ; ch < nchan_out_buff; ch++ ) + { + /* note: these are intra-frame heap memories */ + 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" ) ); + } + + if ( ch < MAX_INTERN_CHANNELS ) + { + hTcBuffer->tc[ch] = p_output_f[ch]; + } + } + + for ( ; ch < nchan_out_buff_old; ch++ ) + { + p_output_f[ch] = NULL; + } } } +#endif return IVAS_ERR_OK; } -- GitLab From 6f654ffeae292175067abfffc4d1d6929944107a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 14:00:41 +0200 Subject: [PATCH 02/13] introduce buffer *tc_buffer2 --- lib_dec/ivas_init_dec.c | 20 ++++++++++++++++---- lib_dec/ivas_jbm_dec.c | 17 +++++++++++++++++ lib_dec/ivas_stat_dec.h | 4 ++++ lib_rend/ivas_output_init.c | 34 +++++++++++++++++++++++----------- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0424ced917..d273e41128 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2861,16 +2861,26 @@ void ivas_destroy_dec( ivas_limiter_close( &( st_ivas->hLimiter ) ); #ifdef FIX_1330_JBM_MEMORY - /* JBM decoding: floating-point output audio buffers are shared with bufeers from 'hTcBuffer' */ + /* floating-point output audio buffers */ if ( st_ivas->hDecoderConfig->Opt_tsm ) { - int16_t nchan_tc_jbm = max( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); - - for ( i = 0; i < nchan_tc_jbm; i++ ) + /* JBM decoding: floating-point output audio buffers are shared with buffers from 'hTcBuffer' */ + for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { st_ivas->p_output_f[i] = NULL; } } + else + { + for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { + if ( st_ivas->p_output_f[i] != NULL ) + { + free( st_ivas->p_output_f[i] ); + st_ivas->p_output_f[i] = NULL; + } + } + } /* Decoder configuration structure */ #endif @@ -2889,6 +2899,7 @@ void ivas_destroy_dec( st_ivas->hJbmMetadata = NULL; } +#ifndef FIX_1330_JBM_MEMORY /* floating-point output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { @@ -2899,6 +2910,7 @@ void ivas_destroy_dec( } } +#endif /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9aeb4f38fe..b1d6488b2b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2166,6 +2166,10 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate( } } +#ifdef FIX_1330_JBM_MEMORY + hTcBuffer->tc_buffer2 = NULL; + +#endif return IVAS_ERR_OK; } @@ -2203,6 +2207,19 @@ static void ivas_jbm_dec_tc_audio_deallocate( hTcBuffer->tc_buffer_old[ch_idx] = NULL; } } +#ifdef FIX_1330_JBM_MEMORY + + if ( hTcBuffer->tc_buffer2 != NULL ) + { + for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + //hTcBuffer->tc[ch_idx] = NULL; + } + + free( hTcBuffer->tc_buffer2 ); + hTcBuffer->tc_buffer2 = NULL; + } +#endif } return; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 282d798e4d..2ea2ced388 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -963,6 +963,10 @@ typedef struct decoder_tc_buffer_structure int16_t num_slots; int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ +#ifdef FIX_1330_JBM_MEMORY + float *tc_buffer2; + +#endif } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index be4af1b714..fb85cacb66 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -417,7 +417,14 @@ ivas_error ivas_output_buff_dec( else { /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */ - int16_t nchan_tc_jbm; + int16_t nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; + + if ( hTcBuffer->tc_buffer2 != NULL ) + { + free( hTcBuffer->tc_buffer2 ); + hTcBuffer->tc_buffer2 = NULL; + } + nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); if ( nchan_out_buff <= nchan_tc_jbm ) @@ -440,18 +447,23 @@ ivas_error ivas_output_buff_dec( } /* when not enough audio buffers in 'hTcBuffer', allocate remaining output audio buffers here */ - for ( ; ch < nchan_out_buff; ch++ ) + + n_samp_full = ( 48000 / FRAMES_PER_SEC ); + nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full; + + /* note: these are intra-frame heap memories */ + if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { - /* note: these are intra-frame heap memories */ - 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" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + } - if ( ch < MAX_INTERN_CHANNELS ) - { - hTcBuffer->tc[ch] = p_output_f[ch]; - } + set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate ); + + offset = 0; + for ( ; ch < nchan_out_buff; ch++ ) + { + p_output_f[ch] = &hTcBuffer->tc_buffer2[offset]; + offset += n_samp_full; } for ( ; ch < nchan_out_buff_old; ch++ ) -- GitLab From 8c6ce00b2f77d6df12239d39723ad119a82155a5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 14:04:44 +0200 Subject: [PATCH 03/13] clang-format --- lib_dec/ivas_jbm_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b1d6488b2b..34dd4167b4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2213,7 +2213,7 @@ static void ivas_jbm_dec_tc_audio_deallocate( { for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) { - //hTcBuffer->tc[ch_idx] = NULL; + // hTcBuffer->tc[ch_idx] = NULL; } free( hTcBuffer->tc_buffer2 ); -- GitLab From c2616a263dc9b92f597faeecb9ab24fab644b3d0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 15:03:43 +0200 Subject: [PATCH 04/13] fixes --- lib_dec/ivas_init_dec.c | 5 ----- lib_dec/ivas_osba_dec.c | 4 ++++ lib_rend/ivas_output_init.c | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d273e41128..3e2dd4a9df 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2380,11 +2380,6 @@ ivas_error ivas_init_decoder( k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); #ifdef FIX_1330_JBM_MEMORY - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - st_ivas->p_output_f[n] = NULL; - } - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, 0, k, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index f697fe3632..9711cb6844 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -263,7 +263,11 @@ ivas_error ivas_osba_render_sf( #else int16_t n; #endif +#ifdef FIX_1330_JBM_MEMORY + float output_ism[MAX_OUTPUT_CHANNELS][2 * L_FRAME48k]; // VE: TBV!!! +#else float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; +#endif float *p_output_ism[MAX_OUTPUT_CHANNELS]; ivas_error error; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index fb85cacb66..8ed254ac7c 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -419,6 +419,11 @@ ivas_error ivas_output_buff_dec( /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */ int16_t nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) + { + p_output_f[ch] = NULL; + } + if ( hTcBuffer->tc_buffer2 != NULL ) { free( hTcBuffer->tc_buffer2 ); -- GitLab From cab8264e455c4b53d2f9ff23bc6bd3c8eef8d473 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 15:53:30 +0200 Subject: [PATCH 05/13] fix --- lib_com/ivas_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index d2dde26fb5..9c5aae966e 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -199,7 +199,7 @@ void ivas_buffer_deinterleaved_to_interleaved( { int16_t ch, m; #ifdef FIX_1330_JBM_MEMORY - float buffer[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; + float buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; for ( ch = 0; ch < n_channels; ch++ ) { -- GitLab From f520a0fc23eca579269469d82e5799a686bd430d Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 16:59:30 +0200 Subject: [PATCH 06/13] simplifications --- lib_dec/ivas_init_dec.c | 29 ++------ lib_dec/ivas_jbm_dec.c | 5 -- lib_dec/ivas_osba_dec.c | 33 ++++++--- lib_dec/ivas_stat_dec.h | 2 +- lib_rend/ivas_output_init.c | 129 ++++++++++++++++-------------------- 5 files changed, 87 insertions(+), 111 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3e2dd4a9df..1e344f88fd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2855,30 +2855,7 @@ void ivas_destroy_dec( /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); -#ifdef FIX_1330_JBM_MEMORY - /* floating-point output audio buffers */ - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - /* JBM decoding: floating-point output audio buffers are shared with buffers from 'hTcBuffer' */ - for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) - { - st_ivas->p_output_f[i] = NULL; - } - } - else - { - for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) - { - if ( st_ivas->p_output_f[i] != NULL ) - { - free( st_ivas->p_output_f[i] ); - st_ivas->p_output_f[i] = NULL; - } - } - } - /* Decoder configuration structure */ -#endif if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); @@ -2894,18 +2871,20 @@ void ivas_destroy_dec( st_ivas->hJbmMetadata = NULL; } -#ifndef FIX_1330_JBM_MEMORY /* floating-point output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { +#ifdef FIX_1330_JBM_MEMORY + st_ivas->p_output_f[i] = NULL; +#else if ( st_ivas->p_output_f[i] != NULL ) { free( st_ivas->p_output_f[i] ); st_ivas->p_output_f[i] = NULL; } +#endif } -#endif /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 34dd4167b4..2b4241b861 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2211,11 +2211,6 @@ static void ivas_jbm_dec_tc_audio_deallocate( if ( hTcBuffer->tc_buffer2 != NULL ) { - for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) - { - // hTcBuffer->tc[ch_idx] = NULL; - } - free( hTcBuffer->tc_buffer2 ); hTcBuffer->tc_buffer2 = NULL; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 9711cb6844..332ea51b19 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -258,54 +258,71 @@ ivas_error ivas_osba_render_sf( float *p_output[] /* o : rendered time signal */ ) { -#ifdef FIX_1330_JBM_MEMORY - int16_t n, tc_offset; -#else int16_t n; -#endif #ifdef FIX_1330_JBM_MEMORY - float output_ism[MAX_OUTPUT_CHANNELS][2 * L_FRAME48k]; // VE: TBV!!! + float output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_output_sba[MAX_OUTPUT_CHANNELS]; #else float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif float *p_output_ism[MAX_OUTPUT_CHANNELS]; +#endif ivas_error error; for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef FIX_1330_JBM_MEMORY + p_output_sba[n] = output_sba[n]; +#else p_output_ism[n] = &output_ism[n][0]; +#endif } #ifndef FIX_1330_JBM_MEMORY if ( !st_ivas->hDecoderConfig->Opt_tsm ) { int16_t tc_offset; -#endif tc_offset = st_ivas->hTcBuffer->n_samples_rendered; for ( n = 0; n < st_ivas->nchan_ism; n++ ) { mvr2r( &p_output[n][tc_offset], &output_ism[n][tc_offset], nSamplesAsked ); } -#ifndef FIX_1330_JBM_MEMORY } #endif +#ifdef FIX_1330_JBM_MEMORY + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) +#endif { return error; } if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef FIX_1330_JBM_MEMORY + ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); +#else ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); +#endif } for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef FIX_1330_JBM_MEMORY + v_add( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered ); +#else v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); +#endif } +#ifdef FIX_1330_JBM_MEMORY + else + { + mvr2r( p_output_sba[n], p_output[n], *nSamplesRendered ); + } +#endif v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered ); } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2ea2ced388..8c08e8dbaa 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -964,7 +964,7 @@ typedef struct decoder_tc_buffer_structure int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ #ifdef FIX_1330_JBM_MEMORY - float *tc_buffer2; + float *tc_buffer2; /* non-scaled buffer of output audio - needed only when '*tc_buffer* is not long enough */ #endif } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 8ed254ac7c..36ef1ee6df 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -379,102 +379,87 @@ ivas_error ivas_output_buff_dec( #endif ) { - int16_t ch; - #ifdef FIX_1330_JBM_MEMORY - if ( !Opt_tsm ) + int16_t ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; + + for ( ch = 0; ch < nchan_out_buff_old; ch++ ) { - /* non-JBM decoding: allocate output audio buffers here; audio buffers from 'hTcBuffer' are set to NULL */ + p_output_f[ch] = NULL; + } -#endif - if ( nchan_out_buff > nchan_out_buff_old ) - { - for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) - { -#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 - /* note: these are intra-frame heap memories */ - 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" ) ); - } - } - } - else + if ( hTcBuffer->tc_buffer2 != NULL ) + { + free( hTcBuffer->tc_buffer2 ); + hTcBuffer->tc_buffer2 = NULL; + } + + nchan_tc_jbm = 0; + if ( Opt_tsm ) + { + /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */ + nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + } + + if ( nchan_out_buff <= nchan_tc_jbm && !Opt_tsm ) + { + for ( ch = 0; ch < nchan_out_buff; ch++ ) { - for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) - { - free( p_output_f[ch] ); - p_output_f[ch] = NULL; - } + p_output_f[ch] = hTcBuffer->tc[ch]; } -#ifdef FIX_1330_JBM_MEMORY } else { - /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */ - int16_t nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; - - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) + for ( ch = 0; ch < nchan_tc_jbm; ch++ ) { - p_output_f[ch] = NULL; + p_output_f[ch] = hTcBuffer->tc[ch]; } - if ( hTcBuffer->tc_buffer2 != NULL ) + /* non-JBM decoding: allocate output audio buffers + JBM decoding: when not enough audio buffers 'hTcBuffer->tc[]', allocate additional buffers */ + n_samp_full = ( 48000 / FRAMES_PER_SEC ); + nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full; + + /* note: these are intra-frame heap memories */ + if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { - free( hTcBuffer->tc_buffer2 ); - hTcBuffer->tc_buffer2 = NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } - nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate ); - if ( nchan_out_buff <= nchan_tc_jbm ) + offset = 0; + for ( ; ch < nchan_out_buff; ch++ ) { - for ( ch = 0; ch < nchan_out_buff; ch++ ) - { - p_output_f[ch] = hTcBuffer->tc[ch]; - } - - for ( ; ch < nchan_out_buff_old; ch++ ) - { - p_output_f[ch] = NULL; - } + p_output_f[ch] = &hTcBuffer->tc_buffer2[offset]; + offset += n_samp_full; } - else + } +#else + int16_t ch; + + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { - for ( ch = 0; ch < nchan_tc_jbm; ch++ ) +#ifdef DEBUGGING + if ( p_output_f[ch] != NULL ) { - p_output_f[ch] = hTcBuffer->tc[ch]; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); } - - /* when not enough audio buffers in 'hTcBuffer', allocate remaining output audio buffers here */ - - n_samp_full = ( 48000 / FRAMES_PER_SEC ); - nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full; - +#endif /* note: these are intra-frame heap memories */ - if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + 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" ) ); } - - set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate ); - - offset = 0; - for ( ; ch < nchan_out_buff; ch++ ) - { - p_output_f[ch] = &hTcBuffer->tc_buffer2[offset]; - offset += n_samp_full; - } - - for ( ; ch < nchan_out_buff_old; ch++ ) - { - p_output_f[ch] = NULL; - } + } + } + else + { + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) + { + free( p_output_f[ch] ); + p_output_f[ch] = NULL; } } #endif -- GitLab From cc809c9f981e2ccf259b6293a0569bfe85459f6b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 17:02:10 +0200 Subject: [PATCH 07/13] clang-format --- lib_rend/ivas_output_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 36ef1ee6df..c90b9e7990 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -414,8 +414,8 @@ ivas_error ivas_output_buff_dec( p_output_f[ch] = hTcBuffer->tc[ch]; } - /* non-JBM decoding: allocate output audio buffers - JBM decoding: when not enough audio buffers 'hTcBuffer->tc[]', allocate additional buffers */ + /* non-JBM decoding: allocate output audio buffers */ + /* JBM decoding: when not enough audio buffers 'hTcBuffer->tc[]', allocate additional buffers */ n_samp_full = ( 48000 / FRAMES_PER_SEC ); nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full; -- GitLab From d971738a71cde1c142323156de1357002d99d06b Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 17:32:14 +0200 Subject: [PATCH 08/13] fix crash + simplification --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_init_dec.c | 8 ++++++-- lib_dec/ivas_ism_dec.c | 8 +++++++- lib_dec/ivas_masa_dec.c | 8 +++++++- lib_dec/ivas_mct_dec.c | 8 +++++++- lib_dec/ivas_omasa_dec.c | 9 +++++++-- lib_dec/ivas_sba_dec.c | 9 +++++++-- lib_rend/ivas_output_init.c | 8 ++++---- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c4ef05e123..01bbfe7754 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -308,12 +308,12 @@ ivas_error ivas_init_decoder( ivas_error ivas_output_buff_dec( float *p_output_f[], /* i/o: output audio buffers */ - const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ #ifdef FIX_1330_JBM_MEMORY const int16_t nchan_out_buff, /* i : number of output channels */ const int16_t Opt_tsm, /* i : TSM option flag */ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ #else + const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ const int16_t nchan_out_buff /* i : number of output channels */ #endif ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1e344f88fd..e3e0e42d03 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1252,6 +1252,9 @@ ivas_error ivas_init_decoder( int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; int16_t granularity, n_channels_transport_jbm; +#ifdef FIX_1330_JBM_MEMORY + int16_t nchan_out_buff; +#endif int32_t output_Fs, ivas_total_brate; int32_t delay_ns; AUDIO_CONFIG output_config; @@ -2378,13 +2381,14 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); #ifdef FIX_1330_JBM_MEMORY - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, 0, k, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) { return error; } #else + k = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); for ( n = 0; n < k; n++ ) { /* note: these are intra-frame heap memories */ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 64f8d15dab..6e46c4b89d 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -60,7 +60,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + int16_t nchan_out_buff; +#else int16_t nchan_out_buff, nchan_out_buff_old; +#endif nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -70,7 +74,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = last_ism_mode; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { @@ -323,7 +329,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( *-----------------------------------------------------------------*/ 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, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 3d7d78d55d..6886d550a8 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1320,7 +1320,11 @@ 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_1330_JBM_MEMORY + int16_t nchan_out_buff; +#else int16_t nchan_out_buff_old, nchan_out_buff; +#endif ivas_error error; int16_t pos_idx; int32_t ism_total_brate; @@ -1328,8 +1332,10 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#ifndef FIX_1330_JBM_MEMORY 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 ) { @@ -1549,7 +1555,7 @@ ivas_error ivas_masa_dec_reconfigure( { nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); #ifdef FIX_1330_JBM_MEMORY - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index b495f594c7..f410a0bb0e 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -732,11 +732,17 @@ static ivas_error ivas_mc_dec_reconfig( int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + int16_t nchan_out_buff; +#else int16_t nchan_out_buff_old, nchan_out_buff; +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; nchan_transport_old = st_ivas->nchan_transport; +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ /* temporally set the current mc_mode back to the previous one to make sure the following call to @@ -1346,7 +1352,7 @@ static ivas_error ivas_mc_dec_reconfig( nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); #ifdef FIX_1330_JBM_MEMORY - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index d6e0060a57..628d6b4d24 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -200,7 +200,11 @@ ivas_error ivas_omasa_dec_config( int32_t ivas_total_brate, ism_total_brate, cpe_brate; ISM_MODE ism_mode_old; IVAS_FORMAT ivas_format_orig; +#ifdef FIX_1330_JBM_MEMORY + int16_t nchan_out_buff; +#else int16_t nchan_out_buff, nchan_out_buff_old; +#endif ivas_error error; RENDERER_TYPE old_renderer_type; @@ -215,8 +219,9 @@ ivas_error ivas_omasa_dec_config( ivas_format_orig = st_ivas->ivas_format; st_ivas->ivas_format = st_ivas->last_ivas_format; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - +#endif st_ivas->ivas_format = ivas_format_orig; nSCE_old = st_ivas->nSCE; @@ -471,7 +476,7 @@ ivas_error ivas_omasa_dec_config( nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); #ifdef FIX_1330_JBM_MEMORY - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 4e00d948ee..53a0faf148 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -111,7 +111,11 @@ ivas_error ivas_sba_dec_reconfigure( int32_t ivas_total_brate; int32_t last_ivas_total_brate; int16_t num_channels, num_md_sub_frames; +#ifdef FIX_1330_JBM_MEMORY + int16_t nchan_out_buff; +#else int16_t nchan_out_buff, nchan_out_buff_old; +#endif int16_t sba_analysis_order_old_flush; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; @@ -130,8 +134,9 @@ ivas_error ivas_sba_dec_reconfigure( * Save old SBA high-level parameters *-----------------------------------------------------------------*/ +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); - +#endif ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -592,7 +597,7 @@ ivas_error ivas_sba_dec_reconfigure( nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #ifdef FIX_1330_JBM_MEMORY - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index c90b9e7990..3ceb2eb352 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -368,21 +368,21 @@ int16_t ivas_get_nchan_buffers_dec( *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec( - float *p_output_f[], /* i/o: output audio buffers */ - const int16_t nchan_out_buff_old, /* i : previous frame number of output channels */ + float *p_output_f[], /* i/o: output audio buffers */ #ifdef FIX_1330_JBM_MEMORY const int16_t nchan_out_buff, /* i : number of output channels */ const int16_t Opt_tsm, /* i : TSM option flag */ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ #else - const int16_t nchan_out_buff /* i : number of output channels */ + const int16_t nchan_out_buff_old, /* i : previous frame number of output channels */ + const int16_t nchan_out_buff /* i : number of output channels */ #endif ) { #ifdef FIX_1330_JBM_MEMORY int16_t ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; - for ( ch = 0; ch < nchan_out_buff_old; ch++ ) + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) { p_output_f[ch] = NULL; } -- GitLab From 683053faa4eed29c063f354211f80a0bd073b716 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 18:07:53 +0200 Subject: [PATCH 09/13] remove unused variable --- lib_dec/ivas_sba_dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 53a0faf148..abeb19243d 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -115,8 +115,8 @@ ivas_error ivas_sba_dec_reconfigure( int16_t nchan_out_buff; #else int16_t nchan_out_buff, nchan_out_buff_old; -#endif int16_t sba_analysis_order_old_flush; +#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; @@ -127,7 +127,9 @@ ivas_error ivas_sba_dec_reconfigure( hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; +#ifndef FIX_1330_JBM_MEMORY sba_analysis_order_old_flush = st_ivas->sba_analysis_order; +#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters -- GitLab From 4da816930f33329f3538398b23c5569202e44446 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Jul 2025 20:25:35 +0200 Subject: [PATCH 10/13] update --- 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 e3e0e42d03..85c5b0070a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2404,7 +2404,7 @@ ivas_error ivas_init_decoder( } #endif - return error; + return IVAS_ERR_OK; } -- GitLab From 28b252d4190b1848f847b6142ce55903995ea420 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 26 Jul 2025 14:57:40 +0200 Subject: [PATCH 11/13] fix --- lib_rend/ivas_output_init.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 3ceb2eb352..460bf182a3 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -419,13 +419,16 @@ ivas_error ivas_output_buff_dec( n_samp_full = ( 48000 / FRAMES_PER_SEC ); nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full; - /* note: these are intra-frame heap memories */ - if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + if ( nsamp_to_allocate > 0 ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); - } + /* note: these are intra-frame heap memories */ + if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + } - set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate ); + set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate ); + } offset = 0; for ( ; ch < nchan_out_buff; ch++ ) -- GitLab From 25323eae6f4e091721e89147f8e859fddd9b40e0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Aug 2025 12:16:59 +0200 Subject: [PATCH 12/13] add comment --- lib_com/ivas_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 9c5aae966e..b63a923a1b 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -199,7 +199,7 @@ void ivas_buffer_deinterleaved_to_interleaved( { int16_t ch, m; #ifdef FIX_1330_JBM_MEMORY - float buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; + float buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio[]" and "*audio_out[]" are the same */ for ( ch = 0; ch < n_channels; ch++ ) { -- GitLab From 1d82582d17cfcdad38b4ab29db89a5c473de8672 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Aug 2025 16:44:57 +0200 Subject: [PATCH 13/13] fix OSBA RENDERER_ROOM_IR output --- lib_dec/ivas_osba_dec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 75afa5bd5f..a3ff4aa5df 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -316,6 +316,12 @@ ivas_error ivas_osba_render_sf( v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); #endif } +#ifdef FIX_1330_JBM_MEMORY + else + { + mvr2r( p_output_sba[n], p_output[n], *nSamplesRendered ); + } +#endif } return IVAS_ERR_OK; -- GitLab