diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5df57bb51114b0ff78d7c55cdfeee069d0c43744..88de3e85c438db83f10b04f1bd79e8845b97d3f5 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1055,8 +1055,12 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal */ Word32 *output_fx[], /* o : rendered time signal */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 subframes_rendered /* i : number of subframes rendered */ +#else const Word16 subframes_rendered, /* i : number of subframes rendered */ const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#endif ); void get_panning_gain_fx( @@ -4024,8 +4028,14 @@ ivas_error ivas_init_encoder_fx( ivas_error ivas_output_buff_dec_fx( Word32 *p_output_fx[], /* i/o: output audio buffers */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 nchan_out_buff, /* i : number of output channels */ + const Word16 Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ + #endif ); ivas_error ivas_dec_get_format_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index dc5c3b4e20429a90e2a4008c42e9af70fb88a79f..515a10cdb1195b2259ad19591e195199e13ba508 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -202,12 +202,25 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( ) { Word16 ch, m; +#ifdef FIX_1330_JBM_MEMORY + Word32 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++ ) + { + Copy32( 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 move32(); } } diff --git a/lib_com/options.h b/lib_com/options.h index 37fffd13ec20834422ff4e916401110da7d8c069..c967fd23313cf405c84fc2afebf1c25e4cc66026 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */ #define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ +#define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ // object-editing feature porting diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 743add2729206717059bfa5b5db180ea706b621f..cfb6c615b1b4941cb117e88e585208d78491e3c0 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1068,7 +1068,11 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#ifdef FIX_1330_JBM_MEMORY + Scale_sig32( output[n], output_frame, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#else + Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[n] = hCPE->hStereoDft->q_dft; move16(); @@ -1082,7 +1086,11 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#ifdef FIX_1330_JBM_MEMORY + Scale_sig32( output[n], output_frame, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#else + Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[n] = Q11; move16(); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5cf6a86e16e1d630b6b8448ebb42e182818309f8..fc3dbd85cb89cf33fe53c7732c5e74acc450302b 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1494,6 +1494,9 @@ ivas_error ivas_init_decoder_fx( Word16 sce_id, cpe_id; Word16 numCldfbAnalyses, numCldfbSyntheses; Word16 granularity, n_channels_transport_jbm; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#endif Word32 output_Fs, ivas_total_brate, tmp_br, tmp32; Word32 delay_ns; AUDIO_CONFIG output_config; @@ -2899,7 +2902,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); - IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && st_ivas->hDecoderConfig->Opt_tsm ) + IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && hDecoderConfig->Opt_tsm ) { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -2914,6 +2917,13 @@ ivas_error ivas_init_decoder_fx( * Allocate output audio buffers *-----------------------------------------------------------------*/ +#ifdef FIX_1330_JBM_MEMORY + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } +#else #ifdef FIX_NCHAN_BUFFERS k = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); FOR( n = 0; n < k; n++ ) @@ -2932,6 +2942,7 @@ ivas_error ivas_init_decoder_fx( { st_ivas->p_output_fx[n] = NULL; } +#endif return error; } @@ -3414,11 +3425,15 @@ void ivas_destroy_dec_fx( /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { +#ifdef FIX_1330_JBM_MEMORY + st_ivas->p_output_fx[i] = NULL; +#else IF( st_ivas->p_output_fx[i] != NULL ) { free( st_ivas->p_output_fx[i] ); st_ivas->p_output_fx[i] = NULL; } +#endif } /* main IVAS handle */ diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index bfdd038738cdb67f0b246adcd52d9061caa7fb43..5d8e1f7054a0567714f4466a7322e80cf69c4727 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -59,7 +59,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; +#endif nCPE_old = st_ivas->nCPE; move16(); @@ -74,7 +78,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; move16(); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif IF( NE_32( ( error = ivas_ism_config_fx( 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 ) ) { @@ -303,6 +309,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } +#ifndef FIX_1330_JBM_MEMORY /*-----------------------------------------------------------------* * output audio buffers *-----------------------------------------------------------------*/ @@ -313,7 +320,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } - +#endif /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ @@ -366,6 +373,18 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifdef FIX_1330_JBM_MEMORY + + /*-----------------------------------------------------------------* + * output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, 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_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 64c7f7b087a2d06e39e43acc017b9a7dd7d1d238..85d333c94ea8f504218d68e940f131902fe812d1 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -218,6 +218,7 @@ void ivas_ism_render_sf_fx( ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) { FOR( i = 0; i < num_objects; i++ ) @@ -227,12 +228,15 @@ void ivas_ism_render_sf_fx( } ELSE { +#endif FOR( i = 0; i < num_objects; i++ ) { Copy32( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render ); p_tc_fx[i] = tc_local_fx[i]; } +#ifndef FIX_1330_JBM_MEMORY } +#endif FOR( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -507,8 +511,12 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ Word32 *output_fx[], /* o : rendered time signal Q11*/ - const Word16 subframes_rendered, /* i : number of subframes rendered */ - const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 subframes_rendered /* i : number of subframes rendered */ +#else + const Word16 subframes_rendered, /* i : number of subframes rendered */ + const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#endif ) { VBAP_HANDLE hVBAPdata; @@ -557,13 +565,15 @@ void ivas_omasa_separate_object_render_jbm_fx( move16(); } +#ifndef FIX_1330_JBM_MEMORY offsetSamples = i_mult( slots_rendered, hSpatParamRendCom->slot_size ); - +#endif FOR( j = 0; j < nchan_out_woLFE + num_lfe; j++ ) { output_fx_local[j] = output_fx[j]; } +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) { FOR( obj = 0; obj < num_objects; obj++ ) @@ -574,12 +584,15 @@ void ivas_omasa_separate_object_render_jbm_fx( } ELSE { +#endif FOR( obj = 0; obj < num_objects; obj++ ) { input_fx[obj] = input_fx_in[obj]; move32(); } +#ifndef FIX_1330_JBM_MEMORY } +#endif slots_to_render = idiv1616( nSamplesRendered, hSpatParamRendCom->slot_size ); first_sf = subframes_rendered; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3d8fdda45734c500d71a4e5be581c0339bd4359f..eb287aefaa5ede330ba3e551b620983eb411e952 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1530,7 +1530,11 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Word32 *p_data_fx[MAX_CLDFB_DIGEST_CHANNELS]; #endif Word16 n, n_render_timeslots, n_ch_cldfb; +#ifdef FIX_1330_JBM_MEMORY + Word16 ch, offset, len_offset; +#else Word16 ch; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -1556,6 +1560,23 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( 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_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); + IF( LT_16( len_offset, L_FRAME48k ) ) + { + offset = 0; + move16(); + FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ ) + { + hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; + offset = add( offset, len_offset ); + } + } + +#endif FOR( ch = 0; ch < n_ch_full_copy; ch++ ) { Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); @@ -3365,6 +3386,9 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); +#ifdef FIX_1330_JBM_MEMORY + n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ +#endif #ifdef FIX_2174_JBM_BASOP_ALIGNMENT n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); #else @@ -3438,6 +3462,10 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( } } +#ifdef FIX_1330_JBM_MEMORY + hTcBuffer->tc_buffer2_fx = NULL; + +#endif return IVAS_ERR_OK; } @@ -3475,6 +3503,14 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; } } +#ifdef FIX_1330_JBM_MEMORY + + IF( hTcBuffer->tc_buffer2_fx != NULL ) + { + free( hTcBuffer->tc_buffer2_fx ); + hTcBuffer->tc_buffer2_fx = NULL; + } +#endif } return; @@ -3855,7 +3891,12 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { +#ifdef FIX_1330_JBM_MEMORY + output_fx[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered; + move32(); +#else Copy32( st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output_fx[ch_idx], *nSamplesRendered ); +#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index a26f64c8e5c1cd9c95f470f1d608454101359641..2b6ccf1efb578897cbea67f372004e34c2f05577 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1690,7 +1690,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( UWord32 ivas_total_brate, last_ivas_total_brate; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; #ifdef FIX_NCHAN_BUFFERS +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff_old, nchan_out_buff; +#endif #endif ivas_error error; Word32 ism_total_brate; @@ -1701,7 +1705,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; move32(); #ifdef FIX_NCHAN_BUFFERS +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif #endif test(); @@ -1940,6 +1946,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( ivas_masa_set_elements_fx( 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 + *-----------------------------------------------------------------*/ { Word16 tc_nchan_to_allocate; Word16 tc_nchan_transport; @@ -2054,7 +2063,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( 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_fx( st_ivas, -1, -1 ); +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 7881c2976d865b5f775efb7b9a4b2b14696a0ad4..f11cc8ac5084d040af6027368ce03a90ef9ae040 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -902,13 +902,19 @@ static ivas_error ivas_mc_dec_reconfig_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff_old, nchan_out_buff; +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); nchan_transport_old = st_ivas->nchan_transport; move16(); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( 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 @@ -1638,8 +1644,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 6727ec73f32cdbb9c2d529d293c5dee186c825a9..7fdbe3c884e107fea06abb9a5638322d9e144f3e 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -497,7 +497,11 @@ ivas_error ivas_omasa_dec_config_fx( Word32 brate_SCE, brate_CPE; ISM_MODE ism_mode_old; IVAS_FORMAT ivas_format_orig; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; +#endif ivas_error error; RENDERER_TYPE old_renderer_type; @@ -518,9 +522,10 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->ivas_format = st_ivas->last_ivas_format; move16(); ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); move16(); - +#endif st_ivas->ivas_format = ivas_format_orig; move16(); @@ -816,7 +821,11 @@ ivas_error ivas_omasa_dec_config_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -1093,20 +1102,29 @@ void ivas_omasa_dirac_rend_jbm_fx( ) { Word16 subframes_rendered; +#ifndef FIX_1330_JBM_MEMORY Word16 slots_rendered; +#endif Word16 n; Word32 data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; +#ifndef FIX_1330_JBM_MEMORY test(); IF( !st_ivas->hDecoderConfig->Opt_tsm ) { - *nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); +#endif + *nSamplesRendered = s_min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + +#ifdef FIX_1330_JBM_MEMORY + IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#else + IF( EQ_32( 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++ ) @@ -1127,7 +1145,11 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_fx[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_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 @@ -1135,7 +1157,11 @@ void ivas_omasa_dirac_rend_jbm_fx( } /* 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( n = 0; n < 2; n++ ) { @@ -1144,12 +1170,16 @@ void ivas_omasa_dirac_rend_jbm_fx( } } } +#ifndef FIX_1330_JBM_MEMORY } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); +#ifndef FIX_1330_JBM_MEMORY slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_fx ); @@ -1158,7 +1188,11 @@ void ivas_omasa_dirac_rend_jbm_fx( scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } +#ifdef FIX_1330_JBM_MEMORY + ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered ); +#else ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered, slots_rendered ); +#endif FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 67d60c65b2a8b332453d28bc88c35276ec67fb3a..52bc8da86cda3bc065a296006a027c45c5dcac2e 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -282,15 +282,25 @@ ivas_error ivas_osba_render_sf_fx( ) { Word16 n; +#ifdef FIX_1330_JBM_MEMORY + Word32 output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_sba[MAX_OUTPUT_CHANNELS]; +#else Word32 output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *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 ) { Word16 tc_offset; @@ -300,23 +310,41 @@ ivas_error ivas_osba_render_sf_fx( v_shr( &p_output[n][tc_offset], Q11 - Q11, &output_ism[n][tc_offset], nSamplesAsked ); // Q11 } } - +#endif +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ), IVAS_ERR_OK ) ) +#endif { return error; } IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef FIX_1330_JBM_MEMORY + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); +#else ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); +#endif } FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef FIX_1330_JBM_MEMORY + v_add_fx_no_hdrm( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered ); +#else v_add_fx_no_hdrm( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); +#endif + } +#ifdef FIX_1330_JBM_MEMORY + ELSE + { + Copy32( p_output_sba[n], p_output[n], *nSamplesRendered ); } +#endif } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 374547b7fcc3e7ac487749f79fb0202d3d7164bb..793ed74d41975a096287520710b216ab6d029ddc 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -118,8 +118,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( Word32 ivas_total_brate; Word32 last_ivas_total_brate; Word16 num_channels, num_md_sub_frames; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; Word16 sba_analysis_order_old_flush; +#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; @@ -132,16 +136,19 @@ ivas_error ivas_sba_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; move32(); +#ifndef FIX_1330_JBM_MEMORY sba_analysis_order_old_flush = st_ivas->sba_analysis_order; move16(); +#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); - +#endif ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -700,8 +707,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ - +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index cf8017fb5d87b73d48078b9d78e9d18efe48daf0..e02105fd8cb37463c0b362d26a4c6d7e51df75f8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1032,6 +1032,10 @@ typedef struct decoder_tc_buffer_structure Word16 num_slots; Word16 n_samples_discard; /* number of samples to discard from the beginning of the output */ +#ifdef FIX_1330_JBM_MEMORY + Word32 *tc_buffer2_fx; /* non-scaled buffer of output audio - needed only when '*tc_buffer* is not long enough */ + +#endif } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 0e2b264a83e9e1f4ded222a90137b981a9f83295..5969fac17a9c3759237d166a9b106069a66acc2b 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -566,11 +566,80 @@ Word16 ivas_get_nchan_buffers_dec_fx( *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec_fx( - Word32 *p_output_fx[], /* i/o: output audio buffers */ + Word32 *p_output_fx[], /* i/o: output audio buffers */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 nchan_out_buff, /* i : number of output channels */ + const Word16 Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ +#endif ) { +#ifdef FIX_1330_JBM_MEMORY + Word16 ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; + + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) + { + p_output_fx[ch] = NULL; + } + + IF( hTcBuffer->tc_buffer2_fx != NULL ) + { + free( hTcBuffer->tc_buffer2_fx ); + hTcBuffer->tc_buffer2_fx = NULL; + } + + nchan_tc_jbm = 0; + move16(); + if ( Opt_tsm ) + { + /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */ + nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + } + + test(); + IF( LE_16( nchan_out_buff, nchan_tc_jbm ) && !Opt_tsm ) + { + FOR( ch = 0; ch < nchan_out_buff; ch++ ) + { + p_output_fx[ch] = hTcBuffer->tc_fx[ch]; + } + } + ELSE + { + FOR( ch = 0; ch < nchan_tc_jbm; ch++ ) + { + p_output_fx[ch] = hTcBuffer->tc_fx[ch]; + } + + /* 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 ); + move16(); + nsamp_to_allocate = imult1616( sub( nchan_out_buff, nchan_tc_jbm ), n_samp_full ); + + IF( GT_16( nsamp_to_allocate, 0 ) ) + { + /* note: these are intra-frame heap memories */ + IF( ( hTcBuffer->tc_buffer2_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); + } + + set_zero_fx( hTcBuffer->tc_buffer2_fx, nsamp_to_allocate ); + } + + offset = 0; + move16(); + FOR( ; ch < nchan_out_buff; ch++ ) + { + p_output_fx[ch] = &hTcBuffer->tc_buffer2_fx[offset]; + offset = add( offset, n_samp_full ); + } + } +#else Word16 ch; IF( GT_16( nchan_out_buff, nchan_out_buff_old ) ) @@ -600,6 +669,7 @@ ivas_error ivas_output_buff_dec_fx( p_output_fx[ch] = NULL; } } +#endif return IVAS_ERR_OK; }