From 09e2678ea77e76e05ebebd49c7fd6381c8ca6cc4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 6 Aug 2023 20:40:46 +0200 Subject: [PATCH 01/19] issue 243: Move audio channels memory from stack to heap; under FIX_264_AUDIO_CHANNELS_TO_HEAP --- lib_com/ivas_fb_mixer.c | 10 +- lib_com/ivas_prot.h | 231 ++++++++++++++++++- lib_com/ivas_sba_config.c | 10 +- lib_com/options.h | 2 +- lib_dec/ivas_agc_dec.c | 13 +- lib_dec/ivas_core_dec.c | 16 +- lib_dec/ivas_cpe_dec.c | 12 +- lib_dec/ivas_dec.c | 29 ++- lib_dec/ivas_dirac_dec.c | 6 +- lib_dec/ivas_init_dec.c | 46 ++++ lib_dec/ivas_ism_param_dec.c | 6 +- lib_dec/ivas_ism_renderer.c | 10 +- lib_dec/ivas_jbm_dec.c | 32 ++- lib_dec/ivas_masa_dec.c | 8 +- lib_dec/ivas_mc_paramupmix_dec.c | 31 ++- lib_dec/ivas_mct_core_dec.c | 6 +- lib_dec/ivas_mct_dec.c | 25 +- lib_dec/ivas_mono_dmx_renderer.c | 16 +- lib_dec/ivas_omasa_dec.c | 81 ++++++- lib_dec/ivas_out_setup_conversion.c | 6 +- lib_dec/ivas_pca_dec.c | 14 +- lib_dec/ivas_post_proc.c | 16 +- lib_dec/ivas_sba_dec.c | 37 ++- lib_dec/ivas_sba_dirac_stereo_dec.c | 20 +- lib_dec/ivas_sba_rendering_internal.c | 24 +- lib_dec/ivas_sce_dec.c | 10 +- lib_dec/ivas_spar_decoder.c | 16 +- lib_dec/ivas_stat_dec.h | 4 + lib_dec/ivas_stereo_cng_dec.c | 30 ++- lib_dec/ivas_stereo_ica_dec.c | 16 +- lib_dec/ivas_stereo_icbwe_dec.c | 8 +- lib_dec/ivas_stereo_mdct_core_dec.c | 15 +- lib_dec/ivas_stereo_mdct_stereo_dec.c | 18 +- lib_dec/ivas_stereo_switching_dec.c | 20 +- lib_enc/ivas_dirac_enc.c | 22 +- lib_enc/ivas_enc.c | 21 +- lib_enc/ivas_init_enc.c | 45 +++- lib_enc/ivas_ism_enc.c | 10 +- lib_enc/ivas_ism_param_enc.c | 16 +- lib_enc/ivas_masa_enc.c | 13 +- lib_enc/ivas_mc_param_enc.c | 32 ++- lib_enc/ivas_mc_paramupmix_enc.c | 36 ++- lib_enc/ivas_mcmasa_enc.c | 45 +++- lib_enc/ivas_mct_enc.c | 20 +- lib_enc/ivas_omasa_enc.c | 52 ++++- lib_enc/ivas_sba_enc.c | 8 +- lib_enc/ivas_spar_encoder.c | 22 +- lib_enc/ivas_stat_enc.h | 4 + lib_enc/lib_enc.c | 4 + lib_rend/ivas_dirac_dec_binaural_functions.c | 22 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 202 ++++++++-------- lib_rend/ivas_objectRenderer.c | 8 +- lib_rend/ivas_output_init.c | 99 ++++++++ lib_rend/ivas_prot_rend.h | 26 ++- lib_rend/ivas_splitRendererPre.c | 24 +- lib_rend/lib_rend.c | 70 +++++- 56 files changed, 1356 insertions(+), 289 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index a94a92c548..e859e00000 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -474,9 +474,13 @@ void ivas_FB_mixer_close( void ivas_fb_mixer_pcm_ingest( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float pcm_in[][L_FRAME48k], /* i : input audio channels */ - float **ppOut_pcm, /* o : output audio channels */ - const int16_t frame_len, /* i : frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_in[], /* i : input audio channels */ +#else + float pcm_in[][L_FRAME48k], /* i : input audio channels */ +#endif + float **ppOut_pcm, /* o : output audio channels */ + const int16_t frame_len, /* i : frame length */ const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ) { int16_t i; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 46284eb325..649e83a2d0 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -163,7 +163,11 @@ ivas_error ivas_cpe_enc( ivas_error ivas_mct_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */ +#else float data[MCT_MAX_CHANNELS][L_FRAME48k], /* i : input signals */ +#endif const int16_t input_frame, /* i : input frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ); @@ -377,7 +381,11 @@ ivas_error ivas_hp20_dec_reconfig( ivas_error ivas_sce_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t sce_id, /* i : SCE # identifier */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[1], /* o : output synthesis signal */ +#else float output[1][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ); @@ -385,14 +393,22 @@ ivas_error ivas_sce_dec( ivas_error ivas_cpe_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t cpe_id, /* i : CPE # identifier */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* o : output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ); ivas_error ivas_mct_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else float output[][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ); @@ -453,7 +469,11 @@ ivas_error ivas_core_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ const int16_t n_channels, /* i : number of channels to be decoded */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* o : output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ +#endif float outputHB[CPE_CHANNELS][L_FRAME48k], /* o : output HB synthesis signal */ float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ @@ -492,7 +512,11 @@ void decod_gen_2sbfr( void synchro_synthesis( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ +#endif const int16_t output_frame, /* i : Number of samples */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); @@ -646,7 +670,11 @@ void ivas_post_proc( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ const int16_t n, /* i : channel number */ float synth[], /* i/o: output synthesis signal */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); @@ -689,7 +717,11 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( void smooth_dft2td_transition( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: synthesis @external Fs */ +#endif const int16_t output_frame /* i : output frame length */ ); @@ -970,7 +1002,11 @@ ivas_error ivas_ism_metadata_dec_create( ivas_error ivas_ism_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i : input signal */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i : input signal */ +#endif const int16_t input_frame, /* i : input frame length per channel */ int16_t *nb_bits_metadata /* i : number of metadata bits */ #ifdef MASA_AND_OBJECTS @@ -1035,7 +1071,11 @@ ivas_error ivas_param_ism_enc_open( void ivas_param_ism_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i : input signal */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i : input signal */ +#endif const int16_t input_frame /* i : input frame length per channel */ ); @@ -1054,7 +1094,11 @@ void ivas_ism_metadata_close( void ivas_param_ism_stereo_dmx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i/o: input signal/stereo dmx */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i/o: input signal/stereo dmx */ +#endif const int16_t input_frame /* i : Length of input frame */ ); @@ -1086,7 +1130,11 @@ void ivas_param_ism_dec_close( void ivas_param_ism_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif ); void ivas_ism_dec_digest_tc( @@ -1829,13 +1877,21 @@ void stereo_tca_init_dec( void stereo_tca_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *synth[CPE_CHANNELS], /* i/o: output synth */ +#else float synth[CPE_CHANNELS][L_FRAME48k], /* i/o: output synth */ +#endif const int16_t output_frame /* i : length of a frame per channel */ ); void stereo_tca_scale_R_channel( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output, /* i/o: output synthesis, R channel */ +#else float output[L_FRAME48k], /* i/o: output synthesis, R channel */ +#endif const int16_t output_frame /* i : frame length */ ); @@ -1891,7 +1947,11 @@ void stereo_icBWE_dec( void stereo_icBWE_decproc( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output symthesis */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output symthesis */ +#endif float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */ const int16_t last_core, /* i : last core, primary channel */ const int16_t last_bwidth, /* i : last bandwidth */ @@ -2539,7 +2599,11 @@ void stereo_decoder_tcx( void stereo_mdct_core_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ +#else float signal_out[CPE_CHANNELS][L_FRAME48k], /* o : synthesis @internal_FS */ +#endif float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ ); @@ -2707,13 +2771,21 @@ void synchonize_channels_mdct_sid( void updateBuffersForDmxMdctStereo( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ const int16_t output_frame, /* i : output frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: decoder output */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: decoder output */ +#endif float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ ); void applyDmxMdctStereo( const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* o : output from core decoder */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* o : output from core decoder */ +#endif const int16_t output_frame /* i : output frame length */ ); @@ -2780,7 +2852,11 @@ void stereo_cng_init_dec( ); void stereo_cng_compute_PScorr( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i : Output signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i : Output signal */ +#endif float *c_PS_LT, /* i/o: Correlation */ const int16_t L_frame_0, /* i : L_frame channel 0 */ const int16_t L_frame_1 /* i : L_frame channel 1 */ @@ -2793,7 +2869,11 @@ void stereo_cng_dec_update( void stereo_cna_update_params( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i : Output signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i : Output signal */ +#endif const int16_t output_frame, /* i : Output frame length */ const int16_t tdm_ratio_idx /* i : TDM ratio index */ ); @@ -3111,7 +3191,11 @@ void ivas_mct_core_dec( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ const int16_t nCPE, /* i : number of CPEs */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *signal_out[] /* o : synthesis @internal_FS */ +#else float signal_out[][L_FRAME48k] /* o : synthesis @internal_FS */ +#endif ); void ivas_mct_dec_mct( @@ -3426,13 +3510,17 @@ void ivas_dirac_param_est_enc( DIRAC_ENC_HANDLE hDirAC, IVAS_QDIRECTION *q_direction, const uint8_t useLowerRes, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif float **pp_fr_real, float **pp_fr_imag, const int16_t input_frame, const IVAS_FORMAT ivas_format , - const int16_t hodirac_flag, - const int16_t nchan_fb_in + const int16_t hodirac_flag, + const int16_t nchan_fb_in ); @@ -3515,27 +3603,43 @@ void ivas_sba_get_spar_hoa_md_flag( ); void ivas_sba_zero_vert_comp( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i : SBA signals */ +#else float sba_data[][L_FRAME48k], /* i/o: SBA data frame */ + #endif const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t sba_planar, /* i : SBA planar flag */ const int16_t input_frame /* i : input frame length */ ); void ivas_sba_getTCs( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i : SBA signals */ +#else float sba_data[][L_FRAME48k], /* i : SBA signals */ +#endif Encoder_Struct *st_ivas, /* i/o: Encoder struct */ const int16_t input_frame /* i : frame length */ ); int16_t ivas_sba_remapTCs( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i/o: SBA signals */ +#else float sba_data[][L_FRAME48k], /* i/o: SBA signals */ +#endif Decoder_Struct *st_ivas, /* i/o: decoder struct */ const int16_t output_frame /* i : frame length */ ); void ivas_sba_dirac_stereo_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* o : output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t mcmasa /* i : McMASA flag */ ); @@ -3594,7 +3698,11 @@ void ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: SBA channels */ +#else float data_f[][L_FRAME48k], /* i/o: SBA channels */ +#endif float **ppIn_FR_real, /* o : real freq domain values */ float **ppIn_FR_imag, /* o : imag freq domain values */ const int16_t input_frame, /* i : input frame length */ @@ -3602,6 +3710,7 @@ void ivas_dirac_enc( const IVAS_FORMAT ivas_format, /* i : ivas format */ int16_t hodirac_flag /* i : hodirac flag */ ); + ivas_error ivas_dirac_config( void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ const int16_t enc_dec /* i : encoder or decoder flag */ @@ -3667,7 +3776,11 @@ void ivas_dirac_dec_set_md_map( void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif const int16_t nchan_transport /* i : number of transport channels */ ); @@ -3748,7 +3861,11 @@ void calculate_hodirac_sector_parameters( void ivas_mc_paramupmix_enc( Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport MC data */ +#else float data_f[][L_FRAME48k], /* i/o: input: MC data */ +#endif const int16_t input_frame /* i : input frame length */ ); @@ -3763,7 +3880,11 @@ void ivas_mc_paramupmix_enc_close( void ivas_mc_paramupmix_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif ); ivas_error ivas_mc_paramupmix_dec_open( @@ -3842,7 +3963,11 @@ void ivas_param_mc_enc_close( void ivas_param_mc_enc( Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport MC data */ +#else float data_f[][L_FRAME48k], /* i/o: input: MC data */ +#endif const int16_t input_frame /* i : input frame length */ ); @@ -4095,7 +4220,11 @@ void ivas_spar_enc_close( ivas_error ivas_spar_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport audio channels */ +#else float data_f[][L_FRAME48k], /* i/o: input/transport audio channels */ +#endif const int16_t input_frame, /* i : input frame length */ int16_t *nb_bits_metadata, /* i : number of MD bits written */ BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ @@ -4129,7 +4258,11 @@ void ivas_spar_config( void ivas_sba_upmixer_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: transport/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: transport/output audio channels */ +#endif const int16_t output_frame /* i : output frame length */ ); @@ -4144,7 +4277,11 @@ ivas_error ivas_sba_linear_renderer( void ivas_sba_mix_matrix_determiner( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: transport/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: transport/output audio channels */ +#endif const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ @@ -4193,8 +4330,13 @@ void ivas_spar_agc_dec_close( void ivas_agc_dec_process( ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_in[], /* i : input audio channels */ + float *pcm_out[], /* o : output audio channels */ +#else float pcm_in[][L_FRAME48k], /* i : input audio channels */ float pcm_out[][L_FRAME48k], /* o : output audio channels */ +#endif const int16_t n_channels, /* i : number of channels */ const int16_t output_Fs /* i : output sampling rate */ ); @@ -4316,7 +4458,11 @@ int16_t ivas_is_res_channel( void ivas_spar_dec_agc_pca( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: input/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: input/output audio channels */ +#endif const int16_t output_frame /* i : output frame length */ ); @@ -4359,7 +4505,11 @@ void ivas_spar_dec_upmixer_sf( void ivas_spar_dec_upmixer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: input/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: input/output audio channels */ +#endif const int16_t nchan_internal, /* i : number of internal channels */ const int16_t output_frame /* i : output frame length */ ); @@ -4702,7 +4852,11 @@ void ivas_pca_dec( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ const int16_t bfi, /* i : bad frame indicator */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_out[] /* o : output audio channels */ +#else float pcm_out[][L_FRAME48k] /* o : output audio channels */ +#endif ); /* PCA utilities */ @@ -4997,7 +5151,11 @@ ivas_error ivas_masa_encode( void ivas_masa_estimate_energy( MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input audio channels */ +#else float data_f[][L_FRAME48k], /* i : Input audio channels */ +#endif const int16_t input_frame, /* i : frame length */ const int16_t nchan_transport /* i : number of MASA input/transport channels */ ); @@ -5169,7 +5327,11 @@ void update_bits_next_block( void ivas_masa_prerender( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: synthesized core-coder transport channels */ +#else float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels */ +#endif const int16_t output_frame /* i : output frame length per channel */ #ifdef CR_FIX_585_MASA_2TC_DTX_EXT , @@ -5395,7 +5557,11 @@ void ivas_ls_setup_conversion( void ivas_ls_setup_conversion_process_mdct( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[] /* i/o: output synthesis signal */ +#else float output[][L_FRAME48k] /* i/o: output synthesis signal */ +#endif ); void ivas_ls_setup_conversion_process_mdct_param_mc( @@ -5476,7 +5642,11 @@ void ivas_mcmasa_enc( MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */ IVAS_QMETADATA_HANDLE hQMeta, /* o : Qmetadata handle */ MASA_ENCODER_HANDLE hMasa, /* i/o: Encoder MASA handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame of audio */ +#else float data_f[][L_FRAME48k], /* i : Input frame of audio */ +#endif const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_transport, /* i : Number of transport channels */ const int16_t nchan_inp /* i : Number of input channels */ @@ -5485,7 +5655,11 @@ void ivas_mcmasa_enc( void ivas_mcmasa_param_est_enc( MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */ MASA_ENCODER_HANDLE hMasa, /* i/o: Encoder MASA handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame of audio */ +#else float data_f[][L_FRAME48k], /* i : Input frame of audio */ +#endif float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation */ float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth */ float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio*/ @@ -5535,19 +5709,31 @@ ivas_error ivas_mono_dmx_renderer_open( void ivas_mono_downmix_render_passive( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/mono output */ +#endif const int16_t output_frame /* i : output frame length */ ); void ivas_mono_stereo_downmix_mcmasa( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/mono or stereo output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/mono or stereo output */ +#endif int16_t output_frame /* i : output frame length per channel */ ); void ivas_lfe_synth_with_filters( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* o : output signals */ +#else float data_f[][L_FRAME48k], /* o : output signals */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t separateChannelIndex, /* i : separate channel index */ const int16_t lfeChannelIndex /* i : LFE channel index */ @@ -5676,12 +5862,20 @@ void ivas_omasa_enc( OMASA_ENC_HANDLE hOMasa, /* i/o: OMASA encoder handle */ MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder handle */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_in_f[], /* i/o: Input / transport audio signals */ +#else float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ +#endif const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_transport, /* i : Number of transport channels */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis*/ const ISM_MODE ism_mode, /* i : ISM mode */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_separated_object, /* o : Separated object audio signal */ +#else float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ +#endif int16_t* idx_separated_object /* o : Index of the separated object */ ); @@ -5711,7 +5905,11 @@ void ivas_set_ism_importance_interformat( int16_t ivas_omasa_ener_brate( const int16_t nchan_ism, /* i : number of ISMs */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input / transport audio signals */ +#else float data_f[][L_FRAME48k], /* i : Input / transport audio signals */ +#endif const int16_t input_frame /* i : Input frame size */ ); @@ -5745,8 +5943,13 @@ void ivas_set_omasa_TC( void ivas_merge_masa_transports( float data_in_f1[][L_FRAME48k], /* i : Transport audio signals 1 */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_in_f2[], /* i : Transport audio signals 2 */ + float *data_out_f[], /* o : Merged transport audio signals */ +#else float data_in_f2[][L_FRAME48k], /* i : Transport audio signals 2 */ float data_out_f[][L_FRAME48k], /* o : Merged transport audio signals */ +#endif const int16_t input_frame, /* i : Input frame size */ const int16_t num_transport_channels /* i : Number of transport audio signals */ ); @@ -5770,15 +5973,31 @@ ivas_error ivas_omasa_ism_metadata_dec( ivas_error ivas_omasa_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else float output[][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame /* i : output frame length per channel */ ); void ivas_omasa_dirac_rend( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else float output[][L_FRAME48k], /* o : output synthesis signal */ +#endif + const int16_t output_frame /* i : output frame length per channel */ +); + +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +void ivas_omasa_rearrange_channels( + float *output[], /* o : output synthesis signal */ + const int16_t nchan_transport_ism, /* i : number of ISM TCs */ const int16_t output_frame /* i : output frame length per channel */ ); +#endif void ivas_omasa_preProcessStereoTransportsForMovedObjects( Decoder_Struct *st_ivas, @@ -5799,7 +6018,11 @@ void ivas_omasa_separate_object_renderer_close( void ivas_omasa_separate_object_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float input_f[][L_FRAME48k], /* i : separated object signal */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: output signals */ +#else float output_f[][L_FRAME48k], /* i/o: output signals */ +#endif const int16_t output_frame /* i : output frame length per channel */ ); @@ -5878,7 +6101,11 @@ void ivas_FB_mixer_close( void ivas_fb_mixer_pcm_ingest( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_in[], /* i : input audio channels */ +#else float pcm_in[][L_FRAME48k], /* i : input audio channels */ + #endif float **ppOut_pcm, /* o : output audio channels */ const int16_t frame_length, /* i : frame length */ const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 9ae9858413..90d36a0917 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -316,10 +316,14 @@ void ivas_sba_get_spar_hoa_md_flag( *-------------------------------------------------------------------*/ void ivas_sba_zero_vert_comp( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i : SBA signals */ +#else float sba_data[][L_FRAME48k], /* i : SBA signals */ - const int16_t sba_order, /* i : SBA order */ - const int16_t sba_planar, /* i : SBA planar flag */ - const int16_t input_frame /* i : frame length */ +#endif + const int16_t sba_order, /* i : SBA order */ + const int16_t sba_planar, /* i : SBA planar flag */ + const int16_t input_frame /* i : frame length */ ) { int16_t i, j; diff --git a/lib_com/options.h b/lib_com/options.h index 07d9d40355..7364988014 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -217,7 +217,7 @@ #define FIX_613_DIRAC_NULL_PTR_USAN /* Nokia: Issue #613: USAN in DirAC decoder setup */ #define MASA_AND_OBJECTS /* Nokia: Combination of MASA and objects */ - +#define FIX_264_AUDIO_CHANNELS_TO_HEAP /* VA: issue 243: Move audio channels memory from stack to heap */ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 72ae68a57b..476ff0be1c 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -173,10 +173,15 @@ void ivas_spar_agc_dec_close( void ivas_agc_dec_process( ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - float pcm_in[][L_FRAME48k], /* i : input audio channels */ - float pcm_out[][L_FRAME48k], /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const int16_t output_frame /* i : output frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_in[], /* i : input audio channels */ + float *pcm_out[], /* o : output audio channels */ +#else + float pcm_in[][L_FRAME48k], /* i : input audio channels */ + float pcm_out[][L_FRAME48k], /* o : output audio channels */ +#endif + const int16_t n_channels, /* i : number of channels */ + const int16_t output_frame /* i : output frame length */ ) { int16_t i, idx; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index bb0268e980..938d75b103 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -55,12 +55,16 @@ *-------------------------------------------------------------------*/ ivas_error ivas_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - const int16_t n_channels, /* i : number of channels to be decoded */ - float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + const int16_t n_channels, /* i : number of channels to be decoded */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[L_FRAME48k], /* o : output synthesis signal */ +#else + float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ +#endif float hb_synth[CPE_CHANNELS][L_FRAME48k], /* o : output HB synthesis signal */ float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 96542eb104..c85dfd3344 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -64,11 +64,15 @@ static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_ *--------------------------------------------------------------------------*/ ivas_error ivas_cpe_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t cpe_id, /* i : CPE # identifier */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* o : output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ +#endif + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t nb_bits_metadata /* i : number of metadata bits */ ) { int16_t i, n, n_channels; diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 70136e9592..79ee5a92ef 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -61,10 +61,16 @@ ivas_error ivas_dec( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ + Decoder_State *st; /* used for bitstream handling */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ +#else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#endif int16_t nchan_remapped; +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP float output_lfe_ch[L_FRAME48k]; +#endif #ifdef MASA_AND_OBJECTS int16_t nb_bits_metadata[MAX_SCE + 1]; #else @@ -115,6 +121,9 @@ ivas_error ivas_dec( for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + output[n] = st_ivas->p_output_f[n]; +#endif p_output[n] = &output[n][0]; } @@ -633,6 +642,9 @@ ivas_error ivas_dec( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + ivas_omasa_rearrange_channels( output, nchan_transport_ism, output_frame ); +#else /* in case of external rendering, rearrange the channels order */ mvr2r( output[0], output[MAX_OUTPUT_CHANNELS - 2], output_frame ); mvr2r( output[1], output[MAX_OUTPUT_CHANNELS - 1], output_frame ); @@ -643,6 +655,7 @@ ivas_error ivas_dec( } mvr2r( output[MAX_OUTPUT_CHANNELS - 2], output[n], output_frame ); mvr2r( output[MAX_OUTPUT_CHANNELS - 1], output[++n], output_frame ); +#endif } } #endif @@ -653,7 +666,11 @@ ivas_error ivas_dec( /* LFE channel decoder */ if ( st_ivas->mc_mode == MC_MODE_MCT ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); +#else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); +#endif } if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -663,8 +680,9 @@ ivas_error ivas_dec( return error; } +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); - +#endif /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -750,7 +768,11 @@ ivas_error ivas_dec( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); +#else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); +#endif ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -759,8 +781,9 @@ ivas_error ivas_dec( return error; } +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); - +#endif ivas_mc_paramupmix_dec( st_ivas, output ); /* HP filtering */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 491d2f48b6..1644ad040d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1624,8 +1624,12 @@ void ivas_dirac_dec_set_md_map( *------------------------------------------------------------------------*/ void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif const int16_t nchan_transport /* i : number of transport channels */ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 73c66b5379..5b4892d7b2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1907,6 +1907,32 @@ ivas_error ivas_init_decoder( } #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /*-----------------------------------------------------------------* + * Allocate floating-point output audio buffers + *-----------------------------------------------------------------*/ + + int32_t output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) + { + /* ivas_mct_dec() is based on L_FRAME_48k instead of output_frame */ + output_Fs_buffers = 48000; + } + + for ( n = 0; n < ivas_get_nchan_buffers( st_ivas ); n++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( output_Fs_buffers / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + } + } + for ( ; n < MAX_OUTPUT_CHANNELS; n++ ) + { + st_ivas->p_output_f[n] = NULL; + } +#endif + return error; } @@ -2153,6 +2179,14 @@ void ivas_initialize_handles_dec( st_ivas->hJbmMetadata = NULL; #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* floating-point output audio buffers */ + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + st_ivas->p_output_f[i] = NULL; + } +#endif + return; } @@ -2391,6 +2425,18 @@ void ivas_destroy_dec( } #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* floating-point output audio buffers */ + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + if ( st_ivas->p_output_f[i] != NULL ) + { + free( st_ivas->p_output_f[i] ); + st_ivas->p_output_f[i] = NULL; + } + } +#endif + /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index b64c52bc71..22ee9f11e4 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -732,8 +732,12 @@ void ivas_param_ism_dec_close( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output*/ +#else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output*/ +#endif ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 33d3598e0e..99c6e87351 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -466,10 +466,14 @@ void ivas_omasa_separate_object_renderer_close( // Todo OMASA JBM: This might need adjustments void ivas_omasa_separate_object_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float input_f[][L_FRAME48k], /* i : separated object signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float input_f[][L_FRAME48k], /* i : separated object signal */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: output signals */ +#else float output_f[][L_FRAME48k], /* i/o: output signals */ - const int16_t output_frame /* i : output frame length per channel */ +#endif + const int16_t output_frame /* i : output frame length per channel */ ) { VBAP_HANDLE hVBAPdata; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 276fdff4e3..9ab763b53f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -73,10 +73,16 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ + Decoder_State *st; /* used for bitstream handling */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ +#else float output[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* 'float' buffer for transport channels, MAX_TRANSPORT_CHANNELS channels */ +#endif int16_t nchan_remapped; +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP float output_lfe_ch[L_FRAME48k]; +#endif int16_t nb_bits_metadata[MAX_SCE]; int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; @@ -103,6 +109,9 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + output[n] = st_ivas->p_output_f[n]; +#endif p_output[n] = &output[n][0]; } @@ -343,7 +352,11 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg; } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); +#else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); +#endif } if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -353,8 +366,9 @@ ivas_error ivas_jbm_dec_tc( return error; } +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); - +#endif /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -387,7 +401,11 @@ ivas_error ivas_jbm_dec_tc( #ifdef JBM_PARAMUPMIX else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output[LFE_CHANNEL] ); +#else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch ); +#endif ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -396,8 +414,9 @@ ivas_error ivas_jbm_dec_tc( return error; } +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); - +#endif /* Rendering */ if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -686,7 +705,11 @@ ivas_error ivas_jbm_dec_render( { int16_t n, nchan_out; int16_t nchan_transport; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAPaa + float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ +#else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#endif int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -714,6 +737,9 @@ ivas_error ivas_jbm_dec_render( for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAPaa + output[n] = st_ivas->p_output_f[n]; +#endif p_output[n] = &output[n][0]; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 7027d49250..22d5585a3c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -872,9 +872,13 @@ static ivas_error ivas_masa_dec_config( *-------------------------------------------------------------------*/ void ivas_masa_prerender( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: synthesized core-coder transport channels */ +#else float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels */ - const int16_t output_frame /* i : output frame length per channel */ +#endif + const int16_t output_frame /* i : output frame length per channel */ #ifdef CR_FIX_585_MASA_2TC_DTX_EXT , const int16_t nchan_remapped /* i : number of transports used in core */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 9ae580ae3a..a0382960f1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -36,6 +36,9 @@ #include "cnst.h" #include "prot.h" #include "ivas_prot.h" +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +#include "ivas_prot_rend.h" +#endif #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" @@ -63,7 +66,11 @@ static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[ static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering ); #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], float *pcm_in[], float **pp_out_pcm, const int16_t output_frame ); +#else static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], float pcm_in[][L_FRAME48k], float **pp_out_pcm, const int16_t output_frame ); +#endif static int huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); @@ -162,8 +169,12 @@ void ivas_mc_paramupmix_dec_read_BS( *------------------------------------------------------------------------*/ void ivas_mc_paramupmix_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[] /* i/o: synthesized core-coder transport channels */ +#else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels */ +#endif ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; @@ -305,10 +316,18 @@ void ivas_mc_paramupmix_dec( } } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers( st_ivas ); ch++ ) + { + set_f( output_f[ch], 0.0f, output_frame ); + } +#else for ( ch = first_empty_channel; ch < MAX_OUTPUT_CHANNELS; ch++ ) { set_f( output_f[ch], 0.0, L_FRAME48k ); } +#endif + pop_wmops(); return; @@ -939,9 +958,13 @@ static void ivas_mc_paramupmix_dec_sf( static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */ - float pcm_in[][L_FRAME48k], /* i : input audio channels */ - float **pp_out_pcm, /* o : output audio channels */ - const int16_t output_frame /* i : output frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_in[], /* i : input audio channels */ +#else + float pcm_in[][L_FRAME48k], /* i : input audio channels */ +#endif + float **pp_out_pcm, /* o : output audio channels */ + const int16_t output_frame /* i : output frame length */ ) { int16_t j, k; diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 8309c9874d..de3a096512 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -165,7 +165,11 @@ void ivas_mct_core_dec( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ const int16_t nCPE, /* i : number of CPEs */ - float signal_out[][L_FRAME48k] /* o : synthesis @internal_FS */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *signal_out[] /* o : synthesis @internal_FS */ +#else + float signal_out[][L_FRAME48k] /* o : synthesis @internal_FS */ +#endif ) { int16_t i, k, ch, cpe_id, nChannels; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index ed5bd79d7a..40fa43f1da 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -63,8 +63,12 @@ static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamp *--------------------------------------------------------------------------*/ ivas_error ivas_mct_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output[][L_FRAME48k], /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else + float output[][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ) @@ -82,6 +86,9 @@ ivas_error ivas_mct_dec( STnsData tnsData[MCT_MAX_BLOCKS][CPE_CHANNELS][2]; Decoder_State **sts; float synth[CPE_CHANNELS][L_FRAME_PLUS]; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float output_lfe_ch[L_FRAME48k]; +#endif int32_t ivas_total_brate; ivas_error error; @@ -93,6 +100,14 @@ ivas_error ivas_mct_dec( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + if ( st_ivas->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + { + /* save LFE channel */ + mvr2r( output[LFE_CHANNEL], output_lfe_ch, output_frame ); + } +#endif + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && !st_ivas->bfi ) { /* get the number of channels from the signalled MC LS setup */ @@ -267,6 +282,7 @@ ivas_error ivas_mct_dec( } #endif } + /* move channels after LFE to correct output for multi-channel MCT */ if ( st_ivas->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { @@ -281,6 +297,11 @@ ivas_error ivas_mct_dec( } mvr2r( tmp, output[LFE_CHANNEL - 1], output_frame ); set_zero( output[LFE_CHANNEL], output_frame ); + +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* save LFE channel */ + mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); +#endif } #ifdef DEBUG_MODE_INFO diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 61d8c68094..5427b19524 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -84,9 +84,13 @@ ivas_error ivas_mono_dmx_renderer_open( *------------------------------------------------------------------------*/ void ivas_mono_downmix_render_passive( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/mono output */ - const int16_t output_frame /* i : output frame length */ +#endif + const int16_t output_frame /* i : output frame length */ ) { int16_t i, j, numInputChannels; @@ -147,9 +151,13 @@ void ivas_mono_downmix_render_passive( *------------------------------------------------------------------------*/ void ivas_mono_stereo_downmix_mcmasa( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/mono or stereo output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/mono or stereo output */ - int16_t output_frame /* i : output frame length per channel */ +#endif + int16_t output_frame /* i : output frame length per channel */ ) { int16_t i; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 7cff26a856..f1b9217dc1 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -151,6 +151,9 @@ 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_264_AUDIO_CHANNELS_TO_HEAP + int16_t nchan_out_buff, nchan_out_buff_old; +#endif ivas_error error; RENDERER_TYPE old_renderer_type; @@ -165,6 +168,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 ); +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); +#endif st_ivas->ivas_format = ivas_format_orig; nSCE_old = st_ivas->nSCE; @@ -386,6 +392,34 @@ ivas_error ivas_omasa_dec_config( { return error; } + +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + } + } + } + else + { + for ( k = nchan_out_buff; k < nchan_out_buff_old; k++ ) + { + free( st_ivas->p_output_f[k] ); + st_ivas->p_output_f[k] = NULL; + } + } +#endif } return IVAS_ERR_OK; @@ -561,9 +595,13 @@ ivas_error ivas_omasa_ism_metadata_dec( // Todo OMASA JBM: This might need adjustments void ivas_omasa_dirac_rend( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else float output[][L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ +#endif + const int16_t output_frame /* i : output frame length per channel */ ) { int16_t n, dirac_read_idx; @@ -600,9 +638,13 @@ void ivas_omasa_dirac_rend( *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dirac_td_binaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* o : output synthesis signal */ +#else float output[][L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ +#endif + const int16_t output_frame /* i : output frame length per channel */ ) { int16_t n; @@ -641,4 +683,35 @@ ivas_error ivas_omasa_dirac_td_binaural( return IVAS_ERR_OK; } + + +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +/*--------------------------------------------------------------------------* + * ivas_omasa_rearrange_channels() + * + * in case of external rendering, rearrange the channels order + *--------------------------------------------------------------------------*/ + +void ivas_omasa_rearrange_channels( + float *output[], /* o : output synthesis signal */ + const int16_t nchan_transport_ism, /* o : number of ISM TCs */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + int16_t n; + float tmp_buff[CPE_CHANNELS][L_FRAME48k]; + + mvr2r( output[0], tmp_buff[0], output_frame ); + mvr2r( output[1], tmp_buff[1], output_frame ); + + for ( n = 0; n < nchan_transport_ism; n++ ) + { + mvr2r( output[CPE_CHANNELS + n], output[n], output_frame ); + } + mvr2r( tmp_buff[0], output[n], output_frame ); + mvr2r( tmp_buff[1], output[++n], output_frame ); + + return; +} +#endif #endif diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 153764c98a..eae9b2e83b 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -559,8 +559,12 @@ void ivas_ls_setup_conversion( *-------------------------------------------------------------------------*/ void ivas_ls_setup_conversion_process_mdct( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[] /* i/o: output synthesis signal */ +#else float output[][L_FRAME48k] /* i/o: output synthesis signal */ +#endif ) { /* Declaration of all required variables */ diff --git a/lib_dec/ivas_pca_dec.c b/lib_dec/ivas_pca_dec.c index e73b3aa1d6..9e5cb01991 100644 --- a/lib_dec/ivas_pca_dec.c +++ b/lib_dec/ivas_pca_dec.c @@ -92,7 +92,11 @@ static void pca_dec_reset_mem_eigvec( static void pca_inv_transform_sub( float *eigVec, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *transformed_data[], /* i : input/transformed audio channels */ +#else float transformed_data[][L_FRAME48k], /* i : input/transformed audio channels */ +#endif const int16_t start, const int16_t len, const int16_t n_channels ) @@ -129,7 +133,11 @@ static void pca_dec_inv_transform( float *qr, const int16_t n_samples, const int16_t n_channels, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *decoded_data[] ) +#else float decoded_data[][L_FRAME48k] ) +#endif { int16_t j; int16_t slot_len; @@ -224,7 +232,11 @@ void ivas_pca_dec( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ const int16_t bfi, /* i : bad frame indicator */ - float pcm_out[][L_FRAME48k] /* o : output audio channels */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *pcm_out[] /* o : output audio channels */ +#else + float pcm_out[][L_FRAME48k] /* o : output audio channels */ +#endif ) { float ql[IVAS_PCA_INTERP], qr[IVAS_PCA_INTERP]; diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index b63bc6af9d..23c8a5a09e 100755 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -53,13 +53,17 @@ *-------------------------------------------------------------------------*/ void ivas_post_proc( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float synth[], /* i/o: output synthesis signal */ + SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const int16_t n, /* i : channel number */ + float synth[], /* i/o: output synthesis signal */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +#endif + const int16_t output_frame, /* i : output frame length */ + const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { #ifndef DEBUG_STEREO_DFT_NOCORE diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e1c95812ac..e3499f7a28 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -113,7 +113,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef VLBR_20MS_MD int16_t num_channels, num_md_sub_frames; #endif - +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch, nchan_out_buff, nchan_out_buff_old; +#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; error = IVAS_ERR_OK; @@ -133,11 +135,14 @@ ivas_error ivas_sba_dec_reconfigure( nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); +#endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); /* save old */ - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) + if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) // ToDo; this never happens { st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; @@ -400,6 +405,34 @@ ivas_error ivas_sba_dec_reconfigure( } } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + } + } + } + else + { + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) + { + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; + } + } +#endif + return error; } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index f743f2072b..d3118a10de 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -600,10 +600,14 @@ static void ivas_sba_dirac_stereo_upmix_hb( *-------------------------------------------------------------------*/ static void ivas_sba_dirac_stereo_apply_td_stefi( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t spar_flag /* i : SPAR flag */ +#endif + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t spar_flag /* i : SPAR flag */ ) { int16_t i; @@ -812,10 +816,14 @@ void ivas_sba_dirac_stereo_smooth_parameters( *-------------------------------------------------------------------*/ void ivas_sba_dirac_stereo_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t mcmasa /* i : McMASA flag */ +#endif + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t mcmasa /* i : McMASA flag */ ) { int16_t dtx_flag, fd_cng_flag; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 643c7b5a6c..79c69456b8 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -220,9 +220,13 @@ void ivas_mc2sba( *-------------------------------------------------------------------*/ int16_t ivas_sba_remapTCs( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i/o: SBA signals */ +#else float sba_data[][L_FRAME48k], /* i/o: SBA signals */ - Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const int16_t output_frame /* i : frame length */ +#endif + Decoder_Struct *st_ivas, /* i/o: decoder struct */ + const int16_t output_frame /* i : frame length */ ) { int16_t nchan_remapped; @@ -388,9 +392,13 @@ void ivas_ism2sba_sf( *-------------------------------------------------------------------*/ void ivas_sba_upmixer_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float output[][L_FRAME48k], /* i/o: transport/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: transport/output audio channels */ +#else + float output[][L_FRAME48k], /* i/o: transport/output audio channels */ +#endif + const int16_t output_frame /* i : output frame length */ ) { int16_t nchan_internal; @@ -573,8 +581,12 @@ ivas_error ivas_sba_linear_renderer( *-------------------------------------------------------------------*/ void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: transport/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: transport/output audio channels */ +#endif const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 3f8d8052e4..a32be8789d 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -52,9 +52,13 @@ *--------------------------------------------------------------------------*/ ivas_error ivas_sce_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - float output[1][L_FRAME48k], /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t sce_id, /* i : SCE # identifier */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[1], /* o : output synthesis signal */ +#else + float output[1][L_FRAME48k], /* o : output synthesis signal */ +#endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t nb_bits_metadata /* i : number of metadata bits */ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 5712d9d603..202bf0f544 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1102,9 +1102,13 @@ static void ivas_spar_calc_smooth_facs( *-------------------------------------------------------------------*/ void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: input/output audio channels */ +#else float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ +#endif + const int16_t output_frame /* i : output frame length */ ) { int16_t nchan_transport; @@ -1314,8 +1318,12 @@ void ivas_spar_dec_digest_tc( *-------------------------------------------------------------------*/ void ivas_spar_dec_upmixer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: input/output audio channels */ +#else + float output[][L_FRAME48k], /* i/o: input/output audio channels */ +#endif const int16_t nchan_internal, /* i : number of internal channels */ const int16_t output_frame /* i : output frame length */ ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 89a2bb07a8..5ec8ead2cb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1013,6 +1013,10 @@ typedef struct Decoder_Struct float **mem_hp20_out; /* output signals HP filter memories */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *p_output_f[MAX_OUTPUT_CHANNELS]; /* floating-point output audio buffers */ +#endif + /* core-decoder modules */ int16_t nSCE; /* number of total SCEs */ int16_t nCPE; /* number of total CPEs */ diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index c674f8bec9..c823c7e28b 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -759,10 +759,14 @@ void stereo_cng_dec_update( *-------------------------------------------------------------------*/ void stereo_cng_compute_PScorr( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i : Output signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i : Output signal */ - float *c_PS_LT, /* i/o: Correlation */ - const int16_t L_frame_0, /* i : L_frame channel 0 */ - const int16_t L_frame_1 /* i : L_frame channel 1 */ +#endif + float *c_PS_LT, /* i/o: Correlation */ + const int16_t L_frame_0, /* i : L_frame channel 0 */ + const int16_t L_frame_1 /* i : L_frame channel 1 */ ) { int16_t i; @@ -815,10 +819,14 @@ void stereo_cng_compute_PScorr( *-------------------------------------------------------------------*/ static void stereo_cng_compute_LRcorr( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i : Output signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i : Output signal */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ +#endif + const int16_t output_frame, /* i : Output frame length */ + const int16_t tdm_ratio_idx /* i : TDM ratio index */ ) { int16_t i; @@ -904,10 +912,14 @@ static void FindEmEs( *-------------------------------------------------------------------*/ void stereo_cna_update_params( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i : Output signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i : Output signal */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ +#endif + const int16_t output_frame, /* i : Output frame length */ + const int16_t tdm_ratio_idx /* i : TDM ratio index */ ) { int16_t i; diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index 02b81a8c26..461611c87c 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -54,9 +54,13 @@ * ---------------------------------------------------------------*/ void stereo_tca_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *synth[CPE_CHANNELS], /* i/o: output synth */ +#else float synth[CPE_CHANNELS][L_FRAME48k], /* i/o: output synth */ - const int16_t output_frame /* i : length of a frame per channel */ +#endif + const int16_t output_frame /* i : length of a frame per channel */ ) { /* Buffers, input Left and right channels @ input_Fs*/ @@ -266,8 +270,12 @@ void stereo_tca_dec( *-------------------------------------------------------------------*/ void stereo_tca_scale_R_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[L_FRAME48k], /* i/o: output synthesis, R channel */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output, /* i/o: output synthesis, R channel */ +#else + float output[L_FRAME48k], /* i/o: output synthesis, R channel */ +#endif const int16_t output_frame /* i : frame length */ ) { diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index ae952d237e..d60dcef17c 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -515,8 +515,12 @@ void stereo_icBWE_dec( *-------------------------------------------------------------------*/ void stereo_icBWE_decproc( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis */ +#else + float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis */ +#endif float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */ const int16_t last_core, /* i : last core, primary channel */ const int16_t last_bwidth, /* i : last bandwidth */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 1019868229..a3079173ef 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -139,9 +139,13 @@ static void stereo_mdct_dec_stereo( *--------------------------------------------------------------------*/ void stereo_mdct_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float signal_out[CPE_CHANNELS][L_FRAME48k], /* o : synthesis @internal_FS */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ +#else + float signal_out[CPE_CHANNELS][L_FRAME48k], /* o : synthesis @internal_FS */ +#endif float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ ) { @@ -360,8 +364,13 @@ void stereo_mdct_core_dec( ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, fUseTns, 0 ); +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + mvr2r( signal_out_tmp[0], signal_out[0], (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ); + mvr2r( signal_out_tmp[1], signal_out[1], (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ); +#else mvr2r( signal_out_tmp[0], signal_out[0], L_FRAME48k ); mvr2r( signal_out_tmp[1], signal_out[1], L_FRAME48k ); +#endif mvr2r( signal_outFB_tmp[0], signal_outFB[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); mvr2r( signal_outFB_tmp[1], signal_outFB[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX ); diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 76f740d6c6..650cb827ce 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -552,10 +552,14 @@ void synchonize_channels_mdct_sid( *-------------------------------------------------------------------*/ void updateBuffersForDmxMdctStereo( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - const int16_t output_frame, /* i : output frame length */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ + const int16_t output_frame, /* i : output frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: decoder output */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: decoder output */ - float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ +#endif + float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ ) { int16_t delay_buf_out_len, tcxltp_mem_in_len, delta, i; @@ -634,9 +638,13 @@ void updateBuffersForDmxMdctStereo( *-------------------------------------------------------------------*/ void applyDmxMdctStereo( - const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ + const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: core decoder output */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: core decoder output */ - const int16_t output_frame /* i : output frame length */ +#endif + const int16_t output_frame /* i : output frame length */ ) { int16_t crossfade_len, i; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 4a4bb5ad14..8b8a9b89de 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1016,11 +1016,15 @@ ivas_error stereo_memory_dec( *-------------------------------------------------------------------*/ void synchro_synthesis( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +#endif + const int16_t output_frame, /* i : Number of samples */ + const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { int16_t n, delay_comp_TD, delay_comp_DFT; @@ -1794,9 +1798,13 @@ static float ncross_corr_self( #define DFT2TD_CORR_THRESH 0.9f void smooth_dft2td_transition( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ +#else float output[CPE_CHANNELS][L_FRAME48k], /* i/o: synthesis @external Fs */ - const int16_t output_frame /* i : output frame lenght */ +#endif + const int16_t output_frame /* i : output frame lenght */ ) { Decoder_State **sts; diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 1a25541d31..4855978fe2 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -285,13 +285,17 @@ void ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - float data_f[][L_FRAME48k], /* i/o: SBA channels */ - float **ppIn_FR_real, /* o : real freq domain values */ - float **ppIn_FR_imag, /* o : imag freq domain values */ - const int16_t input_frame, /* i : input frame length */ - const int16_t dtx_vad, /* i : DTX vad flag */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - int16_t hodirac_flag ) /* i : hodirac flag */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: SBA channels */ +#else + float data_f[][L_FRAME48k], /* i/o: SBA channels */ +#endif + float **ppIn_FR_real, /* o : real freq domain values */ + float **ppIn_FR_imag, /* o : imag freq domain values */ + const int16_t input_frame, /* i : input frame length */ + const int16_t dtx_vad, /* i : DTX vad flag */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + int16_t hodirac_flag ) /* i : hodirac flag */ { int16_t orig_dirac_bands; float dir[3], avg_dir[3]; @@ -457,7 +461,11 @@ void ivas_dirac_param_est_enc( DIRAC_ENC_HANDLE hDirAC, IVAS_QDIRECTION *q_direction, const uint8_t useLowerRes, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif float **pp_fr_real, float **pp_fr_imag, const int16_t input_frame, diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 4a54136079..6eaf00b0e5 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -66,7 +66,11 @@ ivas_error ivas_enc( #else int16_t nb_bits_metadata[MAX_SCE]; #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[MAX_INPUT_CHANNELS]; +#else float data_f[MAX_INPUT_CHANNELS][L_FRAME48k]; +#endif int32_t ivas_total_brate; ivas_error error; error = IVAS_ERR_OK; @@ -97,6 +101,13 @@ ivas_error ivas_enc( * convert 'short' input data to 'float' *----------------------------------------------------------------*/ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + for ( n = 0; n < MAX_INPUT_CHANNELS; n++ ) + { + data_f[n] = st_ivas->p_data_f[n]; + } +#endif + n = 0; while ( n < nchan_inp ) { @@ -238,6 +249,7 @@ ivas_error ivas_enc( if ( st_ivas->hQMetaData != NULL && ivas_format != SBA_FORMAT ) { ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ + if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -292,7 +304,11 @@ ivas_error ivas_enc( #ifdef MASA_AND_OBJECTS else if ( ivas_format == MASA_ISM_FORMAT ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_separated_object; +#else float data_separated_object[L_FRAME48k]; +#endif int16_t idx_separated_object; int16_t flag_omasa_ener_brate; @@ -305,7 +321,6 @@ ivas_error ivas_enc( mvr2r( data_f[hEncoderConfig->nchan_ism], data_f[hEncoderConfig->nchan_ism + 1], input_frame ); } - /* Estimate TF-tile energy for the input MASA stream */ ivas_masa_estimate_energy( st_ivas->hMasa, &( data_f[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport ); @@ -316,7 +331,9 @@ ivas_error ivas_enc( set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); idx_separated_object = 0; - +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; +#endif /* put audio object data in SCE's */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 330046a5cd..f15d135a62 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -383,6 +383,36 @@ ivas_error ivas_init_encoder( st_ivas->nchan_transport = -1; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /*-----------------------------------------------------------------* + * Allocate floating-point input audio buffers + *-----------------------------------------------------------------*/ + + int16_t nchan_inp_buff = hEncoderConfig->nchan_inp; + if ( ivas_format == MASA_ISM_FORMAT ) + { + if ( hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism == 1 ) /* mono is duplicated in monoMASA */ + { + nchan_inp_buff++; + } + + nchan_inp_buff++; /* for *data_separated_object */ + } + + for ( n = 0; n < nchan_inp_buff; n++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_data_f[n] = (float *) malloc( ( input_Fs / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + } + } + for ( ; n < MAX_INPUT_CHANNELS; n++ ) + { + st_ivas->p_data_f[n] = NULL; + } +#endif + /*-----------------------------------------------------------------* * Allocate and initialize buffer of indices *-----------------------------------------------------------------*/ @@ -639,8 +669,9 @@ ivas_error ivas_init_encoder( { st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); - +#endif if ( ( error = ivas_create_lfe_lpf_enc( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) { return error; @@ -1089,6 +1120,18 @@ void ivas_destroy_enc( free( st_ivas->ind_list_metadata ); } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* floating-point input audio buffers */ + for ( n = 0; n < MAX_INPUT_CHANNELS; n++ ) + { + if ( st_ivas->p_data_f[n] != NULL ) + { + free( st_ivas->p_data_f[n] ); + st_ivas->p_data_f[n] = NULL; + } + } +#endif + /* main IVAS handle */ free( st_ivas ); diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 6dbc40f1b4..7aa3f04ca2 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -49,10 +49,14 @@ *-------------------------------------------------------------------*/ ivas_error ivas_ism_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i : input signal */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i : input signal */ - const int16_t input_frame, /* i : input frame length per channel */ - int16_t *nb_bits_metadata /* i : number of metadata bits */ +#endif + const int16_t input_frame, /* i : input frame length per channel */ + int16_t *nb_bits_metadata /* i : number of metadata bits */ #ifdef MASA_AND_OBJECTS , const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 7c99c49184..75b6628300 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -213,9 +213,13 @@ static void ivas_param_ism_enc_quantize_DOA( *-------------------------------------------------------------------------*/ void ivas_param_ism_stereo_dmx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i/o: input signal/stereo dmx */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i/o: input signal/stereo dmx */ - const int16_t input_frame /* i : Length of input frame */ +#endif + const int16_t input_frame /* i : Length of input frame */ ) { int16_t i, j; @@ -440,9 +444,13 @@ void ivas_param_ism_enc_close( *-------------------------------------------------------------------------*/ void ivas_param_ism_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MAX_NUM_OBJECTS], /* i : input signal */ +#else float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i : input signal */ - const int16_t input_frame /* i : input frame length per channel */ +#endif + const int16_t input_frame /* i : input frame length per channel */ ) { int16_t i, j, ts, l_ts; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 461a43f80e..37babae1fa 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -684,8 +684,12 @@ ivas_error ivas_masa_encode( *-----------------------------------------------------------------------*/ void ivas_masa_estimate_energy( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - float data_f[][L_FRAME48k], /* i : Input audio channels */ + MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input audio channels */ +#else + float data_f[][L_FRAME48k], /* i : Input audio channels */ +#endif const int16_t input_frame, /* i : frame length */ const int16_t nchan_transport /* i : number of MASA input/transport channels */ ) @@ -3807,8 +3811,13 @@ static void ivas_encode_masaism_metadata( void ivas_merge_masa_transports( float data_in_f1[][L_FRAME48k], +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_in_f2[], + float *data_out_f[], +#else float data_in_f2[][L_FRAME48k], float data_out_f[][L_FRAME48k], +#endif const int16_t input_frame, const int16_t num_transport_channels ) { diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 2979a9bdb5..94dc7ea08a 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -54,9 +54,15 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); + +static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); +#else static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float data_f[][L_FRAME48k], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float input_frame_t[][L_FRAME48k], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); +#endif static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, const int16_t sz_quantizer, const float *quantizer, int16_t *quant_idx, float *y ); @@ -393,10 +399,14 @@ void ivas_param_mc_enc_close( *------------------------------------------------------------------------*/ void ivas_param_mc_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport MC data */ +#else float data_f[][L_FRAME48k], /* i/o: input: MC data */ - const int16_t input_frame /* i : input frame length */ +#endif + const int16_t input_frame /* i : input frame length */ ) { int16_t k; @@ -574,7 +584,11 @@ void ivas_param_mc_enc( static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ - float data_f[][L_FRAME48k], /* i : Input frame */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame */ +#else + float data_f[][L_FRAME48k], /* i : Input frame */ +#endif float data_dmx[][L_FRAME48k], /* o : Down mixed frame */ const int16_t input_frame, /* i : Input frame length */ const int16_t nchan_input, /* i : number of input channels */ @@ -614,8 +628,12 @@ static void ivas_param_mc_dmx( *------------------------------------------------------------------------*/ static void ivas_param_mc_param_est_enc( - PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ - float input_frame_t[][L_FRAME48k], /* i : Input frame in the time domain */ + PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame in the time domain */ +#else + float data_f[][L_FRAME48k], /* i : Input frame in the time domain */ +#endif float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ const int16_t input_frame, /* i : Input frame length */ @@ -673,7 +691,7 @@ static void ivas_param_mc_param_est_enc( for ( i = 0; i < nchan_input; i++ ) { idx_ls = map_ls[i]; - pcm_in[i] = &input_frame_t[idx_ls][0]; + pcm_in[i] = &data_f[idx_ls][0]; p_slot_frame_f_real[i] = &slot_frame_f_real[i][0]; p_slot_frame_f_imag[i] = &slot_frame_f_imag[i][0]; } diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 5c50c3d6bd..60908a6961 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -53,9 +53,15 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *data_f[], const int16_t input_frame ); + +static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *input_frame_t[], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); +#else static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float data_f[][L_FRAME48k], const int16_t input_frame ); static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float input_frame_t[][L_FRAME48k], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); +#endif static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); @@ -79,10 +85,14 @@ static void quantize_pars( const int16_t nv, const float *v, const int16_t nq, c *------------------------------------------------------------------------*/ void ivas_mc_paramupmix_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hBStr, /* i/o: IVAS Metadata bitstream handle */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hBStr, /* i/o: IVAS Metadata bitstream handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport MC data */ +#else float data_f[][L_FRAME48k], /* i/o: input: MC data */ - const int16_t input_frame /* i : input frame length */ +#endif + const int16_t input_frame /* i : input frame length */ ) { MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix; @@ -680,8 +690,12 @@ static void put_ec_data( static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, /* i/o: MC ParamUpmix encoder handle */ - float data_f[][L_FRAME48k], /* i/o: Input, downmix out */ - const int16_t input_frame /* i : Input frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: Input, downmix out */ +#else + float data_f[][L_FRAME48k], /* i/o: Input, downmix out */ +#endif + const int16_t input_frame /* i : Input frame length */ ) { int16_t i, l; @@ -725,8 +739,12 @@ static void ivas_mc_paramupmix_dmx( static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ - float input_frame_t[][L_FRAME48k], /* i : Input frame in the time domain */ - const int16_t input_frame, /* i : Input frame length */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame in the time domain */ +#else + float data_f[][L_FRAME48k], /* i : Input frame in the time domain */ +#endif + const int16_t input_frame, /* i : Input frame length */ float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ) { @@ -753,8 +771,8 @@ static void ivas_mc_paramupmix_param_est_enc( for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { - pcm_in[2 * i] = input_frame_t[chan1s[i]]; - pcm_in[2 * i + 1] = input_frame_t[chan2s[i]]; + pcm_in[2 * i] = data_f[chan1s[i]]; + pcm_in[2 * i + 1] = data_f[chan2s[i]]; } /*-----------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 9dbdbcab15..63140660c4 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -65,7 +65,11 @@ typedef struct float xi[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; } CovarianceMatrix; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void ivas_mcmasa_dmx( MCMASA_ENC_HANDLE hMcMasa, float *data_f[], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_inp ); +#else static void ivas_mcmasa_dmx( MCMASA_ENC_HANDLE hMcMasa, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_inp ); +#endif static void compute_cov_mtx( float sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], const int16_t freq, const int16_t N, CovarianceMatrix *COVls ); @@ -75,7 +79,11 @@ static void computeVerticalDiffuseness( float **buffer_intensity, const float *b static void computeEvenLayout( const float *ls_azimuth, float *ls_azimuth_even, const int16_t numChannels ); +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void computeLfeEnergy( MCMASA_ENC_HANDLE hMcMasa, float *data_f[], const int16_t input_frame ); +#else static void computeLfeEnergy( MCMASA_ENC_HANDLE hMcMasa, float data_f[][L_FRAME48k], const int16_t input_frame ); +#endif /*--------------------------------------------------------------------------* @@ -555,13 +563,18 @@ void ivas_mcmasa_enc_close( *--------------------------------------------------------------------------*/ void ivas_mcmasa_enc( - MCMASA_ENC_HANDLE hMcMasa, - IVAS_QMETADATA_HANDLE hQMeta, - MASA_ENCODER_HANDLE hMasa, - float data_f[][L_FRAME48k], - const int16_t input_frame, - const int16_t nchan_transport, - const int16_t nchan_inp ) + MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */ + IVAS_QMETADATA_HANDLE hQMeta, /* o : Qmetadata handle */ + MASA_ENCODER_HANDLE hMasa, /* i/o: Encoder MASA handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input frame of audio */ +#else + float data_f[][L_FRAME48k], /* i : Input frame of audio */ +#endif + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_transport, /* i : Number of transport channels */ + const int16_t nchan_inp /* i : Number of input channels */ +) { int16_t i, j, k; int16_t nBands = hMcMasa->nbands; @@ -723,9 +736,13 @@ void ivas_mcmasa_enc( *--------------------------------------------------------------------------*/ void ivas_mcmasa_param_est_enc( - MCMASA_ENC_HANDLE hMcMasa, /* i : McMASA encoder structure */ - MASA_ENCODER_HANDLE hMasa, /* i : MASA encoder structure */ - float data_f[][L_FRAME48k], /* i : Audio frame in MC-format */ + MCMASA_ENC_HANDLE hMcMasa, /* i : McMASA encoder structure */ + MASA_ENCODER_HANDLE hMasa, /* i : MASA encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Audio frame in MC-format */ +#else + float data_f[][L_FRAME48k], /* i : Audio frame in MC-format */ +#endif float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation */ float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth */ float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio */ @@ -1321,7 +1338,11 @@ void ivas_mcmasa_dmx_modify( /* Compute downmix */ static void ivas_mcmasa_dmx( MCMASA_ENC_HANDLE hMcMasa, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_inp ) @@ -1615,7 +1636,11 @@ static void computeEvenLayout( static void computeLfeEnergy( MCMASA_ENC_HANDLE hMcMasa, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif const int16_t input_frame ) { int16_t l_ts; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 42ce327a4c..f322fe94ea 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -103,9 +103,13 @@ static void set_mct_enc_params( *-------------------------------------------------------------------*/ static void map_input_to_cpe_channels( - const Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *pdata[MAX_INPUT_CHANNELS], /* o : mapped input pointers */ - float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ + const Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + float *pdata[MAX_INPUT_CHANNELS], /* o : mapped input pointers */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MCT_MAX_CHANNELS] /* i : input channel data */ +#else + float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ +#endif ) { int16_t i, n; @@ -152,10 +156,14 @@ static void map_input_to_cpe_channels( *-------------------------------------------------------------------*/ ivas_error ivas_mct_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */ +#else float data[MCT_MAX_CHANNELS][L_FRAME48k], /* i : input signal */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ +#endif + const int16_t input_frame, /* i : input frame length per channel */ + const int16_t nb_bits_metadata /* i : number of metadata bits */ ) { int16_t n, cpe_id; diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index ea782115bb..6fa47f409d 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -50,11 +50,19 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static void ivas_omasa_param_est_enc( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, ISM_METADATA_HANDLE hIsmMeta[], float *data_f[], float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float energyRatio[MASA_FREQUENCY_BANDS], float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float surroundingCoherence[MASA_FREQUENCY_BANDS], float diffuseness_m[MASA_FREQUENCY_BANDS], const int16_t input_frame, const int16_t nchan_inp ); + +static void ivas_omasa_energy_and_ratio_est( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, float *data_f[], const int16_t input_frame, const int16_t nchan_inp ); + +static void ivas_omasa_dmx( float *data_in_f[], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MASA_MAX_TRANSPORT_CHANNELS], const float interpolator[L_FRAME48k] ); +#else static void ivas_omasa_param_est_enc( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, ISM_METADATA_HANDLE hIsmMeta[], float data_f[][L_FRAME48k], float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float energyRatio[MASA_FREQUENCY_BANDS], float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float surroundingCoherence[MASA_FREQUENCY_BANDS], float diffuseness_m[MASA_FREQUENCY_BANDS], const int16_t input_frame, const int16_t nchan_inp ); static void ivas_omasa_energy_and_ratio_est( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_inp ); static void ivas_omasa_dmx( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MASA_MAX_TRANSPORT_CHANNELS], const float interpolator[L_FRAME48k] ); +#endif static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], const int16_t num_frequency_bands, float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ); @@ -375,16 +383,24 @@ void ivas_omasa_set_config( *--------------------------------------------------------------------------*/ void ivas_omasa_enc( - OMASA_ENC_HANDLE hOMasa, /* i/o: OMASA encoder handle */ - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + OMASA_ENC_HANDLE hOMasa, /* i/o: OMASA encoder handle */ + MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_in_f[], /* i/o: Input / transport audio signals */ +#else float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport, /* i : Number of transport channels */ - const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ - const ISM_MODE ism_mode, /* i : ISM mode */ +#endif + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_transport, /* i : Number of transport channels */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ + const ISM_MODE ism_mode, /* i : ISM mode */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_separated_object, /* o : Separated object audio signal */ +#else float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ - int16_t *idx_separated_object /* o : Index of the separated object */ +#endif + int16_t *idx_separated_object /* o : Index of the separated object */ ) { int16_t i, j; @@ -721,8 +737,12 @@ void ivas_set_surplus_brate_enc( int16_t ivas_omasa_ener_brate( const int16_t nchan_ism, /* i : number of ISMs */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - float data_f[][L_FRAME48k], /* i : Input / transport audio signals */ - const int16_t input_frame /* i : Input frame size */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i : Input / transport audio signals */ +#else + float data_f[][L_FRAME48k], /* i : Input / transport audio signals */ +#endif + const int16_t input_frame /* i : Input frame size */ ) { int16_t i, flag_omasa_ener_brate; @@ -765,7 +785,11 @@ static void ivas_omasa_param_est_enc( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, ISM_METADATA_HANDLE hIsmMeta[], +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float energyRatio[MASA_FREQUENCY_BANDS], @@ -955,7 +979,11 @@ static void ivas_omasa_param_est_enc( static void ivas_omasa_energy_and_ratio_est( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], +#else float data_f[][L_FRAME48k], +#endif const int16_t input_frame, const int16_t nchan_ism ) { @@ -1037,7 +1065,11 @@ static void ivas_omasa_energy_and_ratio_est( /* Compute downmix */ static void ivas_omasa_dmx( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_in_f[], +#else float data_in_f[][L_FRAME48k], +#endif float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_transport, diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 53e2a62a14..3d5be7e13e 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -53,9 +53,13 @@ *-------------------------------------------------------------------*/ void ivas_sba_getTCs( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *sba_data[], /* i : SBA signals */ +#else float sba_data[][L_FRAME48k], /* i : SBA signals */ - Encoder_Struct *st_ivas, /* i/o: Encoder struct */ - const int16_t input_frame /* i : frame length */ +#endif + Encoder_Struct *st_ivas, /* i/o: Encoder struct */ + const int16_t input_frame /* i : frame length */ ) { if ( st_ivas->hEncoderConfig->sba_planar ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b7b5480952..1bff2b9d31 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -48,7 +48,11 @@ * Local function prototypes *--------------------------------------------------------------------*/ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_CONFIG_HANDLE hEncoderConfig, BSTR_ENC_HANDLE hMetaData, const int16_t front_vad_flag, float *data_f[] ); +#else static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_CONFIG_HANDLE hEncoderConfig, BSTR_ENC_HANDLE hMetaData, const int16_t front_vad_flag, float data_f[][L_FRAME48k] ); +#endif /*------------------------------------------------------------------------- @@ -326,11 +330,15 @@ void ivas_spar_enc_close( *-------------------------------------------------------------------*/ ivas_error ivas_spar_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* i/o: input/transport audio channels */ +#else float data_f[][L_FRAME48k], /* i/o: input/transport audio channels */ - const int16_t input_frame, /* i : input frame length */ - int16_t *nb_bits_metadata, /* i : number of MD bits written */ - BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ +#endif + const int16_t input_frame, /* i : input frame length */ + int16_t *nb_bits_metadata, /* i : number of MD bits written */ + BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ ) { ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -518,7 +526,11 @@ static ivas_error ivas_spar_enc_process( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const int16_t front_vad_flag, /* i : front-VAD decision */ - float data_f[][L_FRAME48k] /* i/o: input/transport audio channels */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[] /* i/o: input/transport audio channels */ +#else + float data_f[][L_FRAME48k] /* i/o: input/transport audio channels */ +#endif ) { float pcm_tmp[DIRAC_MAX_ANA_CHANS][L_FRAME48k * 2]; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index d5aec62a0d..6ae54b6e72 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1192,6 +1192,10 @@ typedef struct { ENCODER_CONFIG_HANDLE hEncoderConfig; /* Encoder configuration structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *p_data_f[MAX_INPUT_CHANNELS]; /* floating-point input audio buffers */ +#endif + Indice *ind_list; /* List of indices */ int16_t ivas_max_num_indices; /* Maximum allowed number of indices in the list */ Indice *ind_list_metadata; /* List of indices for metadata */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 1d80309090..d8c553e378 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -680,6 +680,10 @@ ivas_error IVAS_ENC_ConfigureForMultichannel( break; } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup ); +#endif + hIvasEnc->maxBandwidthUser = max_bwidth_user; error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c729f964ad..02ee77ee03 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -533,7 +533,11 @@ void ivas_dirac_dec_binaural_render( *------------------------------------------------------------------------*/ void ivas_dirac_dec_binaural_sba_gain( - float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else + float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ ) @@ -569,8 +573,12 @@ void ivas_dirac_dec_binaural_sba_gain( void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif + const int16_t nchan_transport /* i : number of transport channels */ ) { int16_t subframe; @@ -620,12 +628,20 @@ void ivas_dirac_dec_binaural( if ( st_ivas->hDiracDecBin->useTdDecorr ) #endif { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *decorr_signal[BINAURAL_CHANNELS], decorr_signal_buff[BINAURAL_CHANNELS][L_FRAME48k]; +#else float *decorr_signal[BINAURAL_CHANNELS]; +#endif int16_t output_frame; for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + decorr_signal[ch] = decorr_signal_buff[ch]; +#else decorr_signal[ch] = (float *) &( output_f[ch + BINAURAL_CHANNELS][0] ); +#endif st_ivas->hTcBuffer->tc[ch + BINAURAL_CHANNELS] = decorr_signal[ch]; } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index b4b9f71e01..036f1d31c4 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -630,120 +630,120 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( dec_param_estim == TRUE ) if ( dec_param_estim == TRUE ) - { + { - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - hVBAPdata, - NULL, + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + hVBAPdata, + NULL, #ifdef MASA_AND_OBJECTS - NULL, + NULL, #endif - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); + + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + { + int16_t k; + if ( ch_idx != 0 ) { - int16_t k; - if ( ch_idx != 0 ) - { - float a, b, c; + float a, b, c; - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } - else + for ( ; k < num_freq_bands; k++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } } - - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } - - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirACRend->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } + } - return; + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) + { + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - else + + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirACRend->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); } + + return; + } + else + { + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } + } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) @@ -2157,10 +2157,14 @@ void ivas_dirac_dec_compute_power_factors( void ivas_lfe_synth_with_filters( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ - float data_f[][L_FRAME48k], /* o : output signals */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t separateChannelIndex, /* i : separate channel index */ - const int16_t lfeChannelIndex /* i : LFE channel index */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *data_f[], /* o : output signals */ +#else + float data_f[][L_FRAME48k], /* o : output signals */ +#endif + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t separateChannelIndex, /* i : separate channel index */ + const int16_t lfeChannelIndex /* i : LFE channel index */ ) { float lowpassCoef; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 3aa9e6d80b..5c255e4be6 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -787,9 +787,13 @@ ivas_error ivas_td_binaural_renderer_ext( * Render to multiple binaural pairs based on relative head positions for split rendering. *---------------------------------------------------------------------*/ void ObjRenderIvasFrame_splitBinaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: SCE channels / Binaural synthesis */ +#else float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ +#endif + const int16_t output_frame /* i : output frame length */ ) { int32_t i; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 9459023565..0caec80a10 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -253,3 +253,102 @@ void ivas_output_init( return; } + + +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +/*-----------------------------------------------------------------* + * ivas_get_nchan_buffers() + * + * Return number of decoder audio buffers + *-----------------------------------------------------------------*/ + +/*! r: number of decoder buffers */ +int16_t ivas_get_nchan_buffers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t nchan_out_buff; + AUDIO_CONFIG output_config; + + output_config = st_ivas->hDecoderConfig->output_config; + + nchan_out_buff = MAX_OUTPUT_CHANNELS; + + if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS ); + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + nchan_out_buff = st_ivas->nchan_ism; + + if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + } + else if ( output_config != AUDIO_CONFIG_EXTERNAL ) + { + nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + + if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + } + else + { + nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT ) + { + nchan_out_buff = CPE_CHANNELS; + + if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + } + else if ( output_config != AUDIO_CONFIG_EXTERNAL ) + { + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS; + + if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + } + else if ( output_config != AUDIO_CONFIG_EXTERNAL ) + { + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + + if ( output_config == AUDIO_CONFIG_LS_CUSTOM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); + } + else + { + nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + + return nchan_out_buff; +} +#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 50b363f192..05910012ee 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -76,6 +76,14 @@ void ivas_output_init( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP +/*! r: number of decoder buffers */ +int16_t ivas_get_nchan_buffers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + + /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ @@ -153,7 +161,11 @@ ivas_error ivas_sba_get_hoa_dec_matrix( #ifdef FIX_564 void ivas_dirac_dec_binaural_sba_gain( +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ const int16_t output_frame /* i : output frame length */ ); @@ -162,7 +174,11 @@ void ivas_dirac_dec_binaural_sba_gain( void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ +#endif const int16_t nchan_transport /* i : number of transport channels */ ); @@ -554,7 +570,11 @@ void ivas_HRTF_CRend_binary_close( /* TODO(sgi): Rework interface */ void ObjRenderIvasFrame_splitBinaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], /* i/o: SCE channels / Binaural synthesis */ +#else float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ +#endif const int16_t output_frame /* i : output frame length */ ); #endif @@ -1495,7 +1515,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural( float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t max_bands, - float out[][L_FRAME48k], +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], +#else + float output[][L_FRAME48k], +#endif const int16_t low_res_pre_rend_rot, int16_t td_input, const int16_t pcm_out diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 0d7e1ed19e..be0b34ab09 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -2049,7 +2049,11 @@ static ivas_error splitRendLc3plusEncodeAndWrite( SPLIT_REND_WRAPPER *hSplitBin, ivas_split_rend_bits_t *pBits, const int32_t SplitRendBitRate, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *in[] ) +#else float in[][L_FRAME48k] ) +#endif { ivas_error error; int16_t i; @@ -2092,7 +2096,11 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( const int32_t SplitRendBitRate, ivas_split_rend_bits_t *pBits, const int16_t max_bands, +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *in[], +#else float in[][L_FRAME48k], +#endif const int16_t low_res_pre_rend_rot, const int16_t pcm_out ) { @@ -2293,7 +2301,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural( float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t max_bands, - float out[][L_FRAME48k], +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *output[], +#else + float output[][L_FRAME48k], +#endif const int16_t low_res_pre_rend_rot, int16_t td_input, const int16_t pcm_out ) @@ -2318,8 +2330,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( if ( td_input ) { /*TD input*/ - /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPositions, SplitRendBitRate, pBits, max_bands, out, + /*if CLDFB handles have been allocated then assume valid multi binaural input in output[][] buffer and perform CLDFB analysis*/ + error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPositions, SplitRendBitRate, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out ); pop_wmops(); return error; @@ -2379,10 +2391,10 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } - cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); } - if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, out ) ) != IVAS_ERR_OK ) + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, output ) ) != IVAS_ERR_OK ) { return error; } @@ -2402,7 +2414,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } - cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); } pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8a023a1087..be78160c38 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7989,9 +7989,21 @@ static void renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch; + float *tmpBuffer[MAX_OUTPUT_CHANNELS], tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBuffer[ch] = tmpBuffer_buff[ch]; + } + + copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); +#else float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer ); +#endif copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->decDummy->hSpatParamRendCom ); if ( masaInput->decDummy->renderer_type == RENDERER_STEREO_PARAMETRIC ) @@ -8003,7 +8015,11 @@ static void renderMasaToMc( ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels ); } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); +#else accumulate2dArrayToBuffer( tmpBuffer, &outAudio ); +#endif return; } @@ -8012,14 +8028,30 @@ static void renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch; + float *tmpBuffer[MAX_OUTPUT_CHANNELS], tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBuffer[ch] = tmpBuffer_buff[ch]; + } + + copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); +#else float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer ); +#endif copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->decDummy->hSpatParamRendCom ); ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels ); +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); +#else accumulate2dArrayToBuffer( tmpBuffer, &outAudio ); +#endif return; } @@ -8033,9 +8065,21 @@ static void renderMasaToBinaural( #endif ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch; + float *tmpBuffer[MAX_OUTPUT_CHANNELS], tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBuffer[ch] = tmpBuffer_buff[ch]; + } + + copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); +#else float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer ); +#endif copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->decDummy->hSpatParamRendCom ); ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels ); @@ -8048,7 +8092,11 @@ static void renderMasaToBinaural( } else { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); +#else accumulate2dArrayToBuffer( tmpBuffer, &outAudio ); +#endif } return; @@ -8649,7 +8697,17 @@ ivas_error IVAS_REND_GetSamples( int16_t td_input; float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch; + float *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBinaural[ch] = tmpBinaural_buff[ch]; + } +#else float tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; +#endif if ( outAudio.config.is_cldfb == 1 ) { @@ -8659,7 +8717,11 @@ ivas_error IVAS_REND_GetSamples( else { td_input = 1; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + copyBufferTo2dArray( outAudio, tmpBinaural_buff ); +#else copyBufferTo2dArray( outAudio, tmpBinaural ); +#endif } /* Encode split rendering bitstream */ @@ -8671,7 +8733,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, @@ -8680,11 +8742,17 @@ ivas_error IVAS_REND_GetSamples( { return error; } + convertInternalBitsBuffToBitsBuffer( hBits, bits ); outAudio = outAudioOrig; + if ( hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); +#else accumulate2dArrayToBuffer( tmpBinaural, &outAudio ); +#endif } } #endif /* SPLIT_REND_WITH_HEAD_ROT */ -- GitLab From f67e0db8d27dfaa920c90de2166e61b7c0f0c127 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Aug 2023 09:20:46 +0200 Subject: [PATCH 02/19] fix build warnings --- lib_dec/ivas_init_dec.c | 5 ++++- lib_enc/ivas_init_enc.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5b4892d7b2..8b416c0878 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -934,6 +934,9 @@ ivas_error ivas_init_decoder( #ifdef MASA_AND_OBJECTS int32_t ism_total_brate; #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int32_t output_Fs_buffers; +#endif error = IVAS_ERR_OK; @@ -1912,7 +1915,7 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - int32_t output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ + output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) { /* ivas_mct_dec() is based on L_FRAME_48k instead of output_frame */ diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index f15d135a62..16a8dc4bb4 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -358,6 +358,9 @@ ivas_error ivas_init_encoder( ) { int16_t i, n; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t nchan_inp_buff; +#endif int16_t sce_id, cpe_id; IVAS_FORMAT ivas_format; int32_t input_Fs, ivas_total_brate; @@ -388,7 +391,7 @@ ivas_error ivas_init_encoder( * Allocate floating-point input audio buffers *-----------------------------------------------------------------*/ - int16_t nchan_inp_buff = hEncoderConfig->nchan_inp; + nchan_inp_buff = hEncoderConfig->nchan_inp; if ( ivas_format == MASA_ISM_FORMAT ) { if ( hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism == 1 ) /* mono is duplicated in monoMASA */ -- GitLab From f15ff12f573f1dd6142fd2d675470100499b0f35 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Aug 2023 10:49:29 +0200 Subject: [PATCH 03/19] address comments in the issue --- lib_dec/ivas_init_dec.c | 4 ++-- lib_dec/ivas_mct_dec.c | 5 +++-- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8b416c0878..8f2cc554a5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1918,7 +1918,7 @@ ivas_error ivas_init_decoder( output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) { - /* ivas_mct_dec() is based on L_FRAME_48k instead of output_frame */ + /* ivas_mct_dec() is based on L_FRAME48k instead of output_frame */ output_Fs_buffers = 48000; } @@ -1927,7 +1927,7 @@ ivas_error ivas_init_decoder( /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( output_Fs_buffers / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } for ( ; n < MAX_OUTPUT_CHANNELS; n++ ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 40fa43f1da..a1b650476d 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -296,11 +296,12 @@ ivas_error ivas_mct_dec( mvr2r( output[n - 1], output[n + 1], output_frame ); } mvr2r( tmp, output[LFE_CHANNEL - 1], output_frame ); - set_zero( output[LFE_CHANNEL], output_frame ); - #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* save LFE channel */ mvr2r( output_lfe_ch, output[LFE_CHANNEL], output_frame ); +#else + set_zero( output[LFE_CHANNEL], output_frame ); #endif } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index f1b9217dc1..01604688e2 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -407,7 +407,7 @@ ivas_error ivas_omasa_dec_config( /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e3499f7a28..97a8a00a4f 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -419,7 +419,7 @@ ivas_error ivas_sba_dec_reconfigure( /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } } -- GitLab From db6c971eda55950d510834fc23f64ded6b9d990d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 8 Aug 2023 10:37:29 +0200 Subject: [PATCH 04/19] revert dynamic allocation in JBM path due to a non-BE output for ParamISM FOA output --- lib_dec/ivas_init_dec.c | 28 ++++++++++++++++++---------- lib_dec/ivas_jbm_dec.c | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8f2cc554a5..d64df4b1c6 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1915,21 +1915,29 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) + if ( !st_ivas->hDecoderConfig->voip_active ) { - /* ivas_mct_dec() is based on L_FRAME48k instead of output_frame */ - output_Fs_buffers = 48000; - } + output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) + { + /* ivas_mct_dec() is based on L_FRAME48k instead of output_frame */ + output_Fs_buffers = 48000; + } - for ( n = 0; n < ivas_get_nchan_buffers( st_ivas ); n++ ) - { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( output_Fs_buffers / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + for ( n = 0; n < ivas_get_nchan_buffers( st_ivas ); n++ ) { - 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 ( ( st_ivas->p_output_f[n] = (float *) malloc( ( output_Fs_buffers / 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 + { + n = 0; + } + for ( ; n < MAX_OUTPUT_CHANNELS; n++ ) { st_ivas->p_output_f[n] = NULL; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9ab763b53f..38e85b243c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -75,7 +75,8 @@ ivas_error ivas_jbm_dec_tc( int16_t n, output_frame, nchan_out; Decoder_State *st; /* used for bitstream handling */ #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ + float *output[MAX_OUTPUT_CHANNELS]; /* 'float' buffer for output synthesis */ /* TODO: can be allocated dynamically using st_ivas->p_output_f */ + float p_output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; #else float output[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* 'float' buffer for transport channels, MAX_TRANSPORT_CHANNELS channels */ #endif @@ -110,7 +111,7 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - output[n] = st_ivas->p_output_f[n]; + output[n] = p_output_f[n]; #endif p_output[n] = &output[n][0]; } -- GitLab From 3a15900eb6e3a569a7a63bca7c90754b8cb5fb7f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Aug 2023 18:17:31 +0200 Subject: [PATCH 05/19] clang-format --- lib_rend/ivas_dirac_output_synthesis_dec.c | 190 ++++++++++----------- lib_rend/lib_rend.c | 2 +- 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 036f1d31c4..248dbbcb9b 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -630,120 +630,120 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( dec_param_estim == TRUE ) if ( dec_param_estim == TRUE ) - { + { - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - hVBAPdata, - NULL, + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + hVBAPdata, + NULL, #ifdef MASA_AND_OBJECTS - NULL, + NULL, #endif - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) - { - int16_t k; - if ( ch_idx != 0 ) + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) { - float a, b, c; - - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) + int16_t k; + if ( ch_idx != 0 ) { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + float a, b, c; + + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } } - for ( ; k < num_freq_bands; k++ ) + else { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } } - else + + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - } - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + { + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirACRend->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); + } - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + return; + } + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirACRend->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } - - return; - } - else - { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); } - } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 297f2cf267..e5ec888b6d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8771,7 +8771,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, -- GitLab From 83d86954f83932a7f62948cafeea7809bf32d3d6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Aug 2023 21:41:49 +0200 Subject: [PATCH 06/19] fix ISM BRSW crash + fix USAN warning --- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 4 +++- lib_dec/ivas_ism_dec.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index e70904332d..5deaf021d8 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -221,6 +221,7 @@ #define FIX_653_BUG_IN_SKIP_MATRIX /* Dlb: fix for issue #653, bug in the ivas_spar_get_skip_mat function*/ #define FIX_663_PARAM_ISM_EXT /* FhG: Issue 663: ParamISM EXT output improvement */ #define FIX_673_OMASA_OBJ_MD_SYNC /* Nokia: Fix issue 673 by updating metadata in the third subframe to account for audio delay. */ + #define FIX_264_AUDIO_CHANNELS_TO_HEAP /* VA: issue 243: Move audio channels memory from stack to heap */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 79ee5a92ef..51965e05d0 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -123,8 +123,10 @@ ivas_error ivas_dec( { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP output[n] = st_ivas->p_output_f[n]; -#endif + p_output[n] = output[n]; +#else p_output[n] = &output[n][0]; +#endif } /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 50d1a91de6..decded23c6 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -62,6 +62,9 @@ static ivas_error ivas_ism_bitrate_switching( int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; int16_t tc_granularity_new; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t ch, nchan_out_buff, nchan_out_buff_old; +#endif AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; RENDERER_TYPE renderer_type_old; @@ -75,6 +78,9 @@ static ivas_error ivas_ism_bitrate_switching( 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; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); +#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 #ifdef MASA_AND_OBJECTS @@ -336,6 +342,34 @@ static ivas_error ivas_ism_bitrate_switching( return error; } +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + 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++ ) + { + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; + } + } +#endif + /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ -- GitLab From ceab7721a99a8365922249972779da3fa110dc21 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Aug 2023 22:19:37 +0200 Subject: [PATCH 07/19] fix ASAN issue in TD decorrelator --- lib_rend/ivas_dirac_dec_binaural_functions.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 5273d46bd3..1f7a96913c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -591,12 +591,20 @@ void ivas_dirac_dec_binaural( int16_t ch; int16_t slot_size; int16_t numInChannels; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + float *decorr_signal[BINAURAL_CHANNELS], decorr_signal_buff[BINAURAL_CHANNELS][L_FRAME48k]; +#endif + hSpatParamRendCom = st_ivas->hSpatParamRendCom; slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + p_output[ch] = output_f[ch]; +#else p_output[ch] = &output_f[ch][0]; +#endif } numInChannels = nchan_transport; #ifdef MASA_AND_OBJECTS @@ -631,9 +639,7 @@ void ivas_dirac_dec_binaural( if ( st_ivas->hDiracDecBin->useTdDecorr ) #endif { -#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - float *decorr_signal[BINAURAL_CHANNELS], decorr_signal_buff[BINAURAL_CHANNELS][L_FRAME48k]; -#else +#ifndef FIX_264_AUDIO_CHANNELS_TO_HEAP float *decorr_signal[BINAURAL_CHANNELS]; #endif int16_t output_frame; -- GitLab From 92566d46b868a70f5e5ad145e76d982eaca0893e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 9 Aug 2023 23:20:49 +0200 Subject: [PATCH 08/19] fix split rendering + UBAN errors --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_dirac_dec.c | 4 ++++ lib_dec/ivas_mct_core_dec.c | 5 +++++ lib_dec/ivas_mct_dec.c | 20 ++++++++++++++++++ lib_dec/ivas_out_setup_conversion.c | 5 +++++ lib_dec/ivas_spar_decoder.c | 4 ++++ lib_enc/ivas_dirac_enc.c | 4 ++++ lib_enc/ivas_ism_param_enc.c | 4 ++++ lib_enc/ivas_mc_param_enc.c | 4 ++++ lib_enc/ivas_mcmasa_enc.c | 22 ++++++++++++++++++++ lib_enc/ivas_spar_encoder.c | 4 ++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 1 + lib_rend/ivas_output_init.c | 5 +++++ 13 files changed, 83 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 649e83a2d0..ce56d90956 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3607,7 +3607,7 @@ void ivas_sba_zero_vert_comp( float *sba_data[], /* i : SBA signals */ #else float sba_data[][L_FRAME48k], /* i/o: SBA data frame */ - #endif +#endif const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t sba_planar, /* i : SBA planar flag */ const int16_t input_frame /* i : input frame length */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 1644ad040d..127271d5ff 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1646,7 +1646,11 @@ void ivas_dirac_dec( for ( n = 0; n < nchan_out; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + output_f_local[n] = output_f[n]; +#else output_f_local[n] = &output_f[n][0]; +#endif } for ( n = 0; n < nchan_transport; n++ ) diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index de3a096512..57ed6c7d1c 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -221,8 +221,13 @@ void ivas_mct_core_dec( { /* Initialization or re-configuration of Stereo TCX */ sts[ch]->enablePlcWaveadjust = 0; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x[ch][0] = signal_out[ch]; + x[ch][1] = signal_out[ch] + ( L_FRAME48k / 2 ); +#else x[ch][0] = &signal_out[ch][0]; x[ch][1] = &signal_out[ch][0] + L_FRAME48k / 2; +#endif } /*--------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a1b650476d..e206423a01 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -158,8 +158,13 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x[n][0] = output[n + cpe_id * CPE_CHANNELS]; + x[n][1] = output[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); +#else x[n][0] = &output[n + cpe_id * CPE_CHANNELS][0]; x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; +#endif set_zero( x[n][0], L_FRAME48k / 2 ); set_zero( x[n][1], L_FRAME48k / 2 ); } @@ -193,8 +198,13 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x[n][0] = output[n + cpe_id * CPE_CHANNELS]; + x[n][1] = output[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); +#else x[n][0] = &output[n + cpe_id * CPE_CHANNELS][0]; x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; +#endif } ivas_mdct_core_tns_ns( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x, Aq[cpe_id], 1 ); @@ -214,8 +224,13 @@ ivas_error ivas_mct_dec( { for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x_all[n + cpe_id * CPE_CHANNELS][0] = output[n + cpe_id * CPE_CHANNELS]; + x_all[n + cpe_id * CPE_CHANNELS][1] = output[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); +#else x_all[n + cpe_id * CPE_CHANNELS][0] = &output[n + cpe_id * CPE_CHANNELS][0]; x_all[n + cpe_id * CPE_CHANNELS][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; +#endif } } @@ -229,8 +244,13 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x[n][0] = output[n + cpe_id * CPE_CHANNELS]; + x[n][1] = output[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); +#else x[n][0] = &output[n + cpe_id * CPE_CHANNELS][0]; x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; +#endif } ivas_mdct_core_reconstruct( hCPE, x, synth, fUseTns[cpe_id], 1 ); diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index eae9b2e83b..f93f6fb2f5 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -596,8 +596,13 @@ void ivas_ls_setup_conversion_process_mdct( /* Assign output pointer to variable x */ for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + x[chInIdx][0] = output[chInIdx]; + x[chInIdx][1] = output[chInIdx] + ( L_FRAME48k / 2 ); +#else x[chInIdx][0] = &output[chInIdx][0]; x[chInIdx][1] = &output[chInIdx][0] + L_FRAME48k / 2; +#endif } /* Assign all the declared handles*/ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7d02bc09a3..aee175a9d4 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1348,7 +1348,11 @@ void ivas_spar_dec_upmixer( for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + output_f_local[n] = output[n]; +#else output_f_local[n] = &output[n][0]; +#endif } for ( n = 0; n < nchan_internal; n++ ) diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 4855978fe2..fbeed1f0a3 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -524,7 +524,11 @@ void ivas_dirac_param_est_enc( /* Copy current frame to memory for delay compensation */ for ( i = 0; i < nchan_fb_in; i++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + pcm_in[i] = data_f[i]; +#else pcm_in[i] = &data_f[i][0]; +#endif p_Cldfb_RealBuffer[i] = &Cldfb_RealBuffer[i][0]; p_Cldfb_ImagBuffer[i] = &Cldfb_ImagBuffer[i][0]; } diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 75b6628300..b6d0d4b3fe 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -476,7 +476,11 @@ void ivas_param_ism_enc( for ( i = 0; i < nchan_ism; i++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + pcm_in[i] = data[i]; +#else pcm_in[i] = &data[i][0]; +#endif set_zero( fb_RealBuffer[i], DIRAC_NO_FB_BANDS_MAX ); set_zero( fb_ImagBuffer[i], DIRAC_NO_FB_BANDS_MAX ); diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 94dc7ea08a..8722b67ab3 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -691,7 +691,11 @@ static void ivas_param_mc_param_est_enc( for ( i = 0; i < nchan_input; i++ ) { idx_ls = map_ls[i]; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + pcm_in[i] = data_f[idx_ls]; +#else pcm_in[i] = &data_f[idx_ls][0]; +#endif p_slot_frame_f_real[i] = &slot_frame_f_real[i][0]; p_slot_frame_f_imag[i] = &slot_frame_f_imag[i][0]; } diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 63140660c4..9c2ab2e9a4 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -818,7 +818,11 @@ void ivas_mcmasa_param_est_enc( /* Copy current frame to memory for delay compensation */ for ( i = 0; i < numAnalysisChannels; i++ ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + pcm_in[i] = data_f[i]; +#else pcm_in[i] = &data_f[i][0]; +#endif p_Chnl_RealBuffer[i] = &Chnl_RealBuffer[i][0]; p_Chnl_ImagBuffer[i] = &Chnl_ImagBuffer[i][0]; } @@ -1657,13 +1661,19 @@ static void computeLfeEnergy( if ( hMcMasa->separateChannelEnabled ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + mvr2r( data_f[lfeChannelIndex], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); + mvr2r( data_f[separateChannelIndex], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); +#else mvr2r( &data_f[lfeChannelIndex][0], &( hMcMasa->delay_buffer_lfe[0][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); mvr2r( &data_f[separateChannelIndex][0], &( hMcMasa->delay_buffer_lfe[1][hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp] ), hMcMasa->offset_comp ); +#endif } else { pcm_in[0] = &data_f[lfeChannelIndex][0]; } + /* Reset variables */ set_zero( hMcMasa->lfeLfEne, MAX_PARAM_SPATIAL_SUBFRAMES ); set_zero( hMcMasa->totalLfEne, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1676,10 +1686,17 @@ static void computeLfeEnergy( float delayedInputSignal[2][L_FRAME48k]; float lowPassSignal[2][L_FRAME48k]; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + mvr2r( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts ); + mvr2r( data_f[lfeChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); + mvr2r( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts ); + mvr2r( data_f[separateChannelIndex] + hMcMasa->offset_comp, &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); +#else mvr2r( &( hMcMasa->delay_buffer_lfe[0][0] ), &( delayedInputSignal[0][0] ), hMcMasa->num_slots_delay_comp * l_ts ); mvr2r( &( data_f[lfeChannelIndex][hMcMasa->offset_comp] ), &( delayedInputSignal[0][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); mvr2r( &( hMcMasa->delay_buffer_lfe[1][0] ), &( delayedInputSignal[1][0] ), hMcMasa->num_slots_delay_comp * l_ts ); mvr2r( &( data_f[separateChannelIndex][hMcMasa->offset_comp] ), &( delayedInputSignal[1][hMcMasa->num_slots_delay_comp * l_ts] ), ( MDFT_NO_COL_MAX - hMcMasa->num_slots_delay_comp ) * l_ts ); +#endif lowpassCoef = 1.0f / ( (float) hMcMasa->ringBufferSize ); @@ -1750,8 +1767,13 @@ static void computeLfeEnergy( if ( hMcMasa->separateChannelEnabled ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + mvr2r( data_f[lfeChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[0][0] ), ( hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp ) ); + mvr2r( data_f[separateChannelIndex] + ( input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp ), &( hMcMasa->delay_buffer_lfe[1][0] ), ( hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp ) ); +#else mvr2r( &data_f[lfeChannelIndex][input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp], &( hMcMasa->delay_buffer_lfe[0][0] ), ( hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp ) ); mvr2r( &data_f[separateChannelIndex][input_frame - hMcMasa->num_samples_delay_comp + hMcMasa->offset_comp], &( hMcMasa->delay_buffer_lfe[1][0] ), ( hMcMasa->num_samples_delay_comp - hMcMasa->offset_comp ) ); +#endif } return; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 1bff2b9d31..ae4ae9e5e5 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -635,7 +635,11 @@ static ivas_error ivas_spar_enc_process( { ppIn_FR_real[i] = p_pcm_tmp[i]; ppIn_FR_imag[i] = p_pcm_tmp[i] + input_frame; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + p_pcm_tmp[i] = data_f[i]; +#else p_pcm_tmp[i] = &data_f[i][0]; +#endif } l_ts = input_frame / MAX_PARAM_SPATIAL_SUBFRAMES; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 1f7a96913c..f316493c0d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -648,6 +648,7 @@ void ivas_dirac_dec_binaural( { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP decorr_signal[ch] = decorr_signal_buff[ch]; + p_output[ch + BINAURAL_CHANNELS] = output_f[ch + BINAURAL_CHANNELS]; #else decorr_signal[ch] = (float *) &( output_f[ch + BINAURAL_CHANNELS][0] ); #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 0caec80a10..9a13b07ff0 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -349,6 +349,11 @@ int16_t ivas_get_nchan_buffers( } } + if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_buff = st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; + } + return nchan_out_buff; } #endif -- GitLab From dcc907b6ede68d5cb68a62b3cf688073fa6c9dec Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 10 Aug 2023 08:49:07 +0200 Subject: [PATCH 09/19] fix split-rendering cases --- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- lib_rend/ivas_output_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f316493c0d..35bddf21d9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -648,7 +648,7 @@ void ivas_dirac_dec_binaural( { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP decorr_signal[ch] = decorr_signal_buff[ch]; - p_output[ch + BINAURAL_CHANNELS] = output_f[ch + BINAURAL_CHANNELS]; + p_output[ch + BINAURAL_CHANNELS] = decorr_signal[ch]; #else decorr_signal[ch] = (float *) &( output_f[ch + BINAURAL_CHANNELS][0] ); #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 9a13b07ff0..827b1dca75 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -351,7 +351,7 @@ int16_t ivas_get_nchan_buffers( if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - nchan_out_buff = st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; + nchan_out_buff = max( nchan_out_buff, st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); } return nchan_out_buff; -- GitLab From fcd5f672f16d09b72ab0a8b8025627b1e4488775 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 10 Aug 2023 10:22:05 +0200 Subject: [PATCH 10/19] fix remaining USAN error --- lib_rend/ivas_dirac_dec_binaural_functions.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 35bddf21d9..ea0ad048ba 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -598,14 +598,18 @@ void ivas_dirac_dec_binaural( hSpatParamRendCom = st_ivas->hSpatParamRendCom; slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) - { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { p_output[ch] = output_f[ch]; + p_output[ch + BINAURAL_CHANNELS] = decorr_signal_buff[ch]; + } #else + for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) + { p_output[ch] = &output_f[ch][0]; -#endif } +#endif numInChannels = nchan_transport; #ifdef MASA_AND_OBJECTS if ( st_ivas->hOutSetup.separateChannelEnabled || ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) @@ -648,7 +652,6 @@ void ivas_dirac_dec_binaural( { #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP decorr_signal[ch] = decorr_signal_buff[ch]; - p_output[ch + BINAURAL_CHANNELS] = decorr_signal[ch]; #else decorr_signal[ch] = (float *) &( output_f[ch + BINAURAL_CHANNELS][0] ); #endif -- GitLab From c0d8e56fde7befe8e69ba9905cbbb389d75c4497 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 20:59:57 +0200 Subject: [PATCH 11/19] fix OSBA EXT output + clan-format --- lib_dec/ivas_jbm_dec.c | 6 +++--- lib_dec/ivas_sba_rendering_internal.c | 2 +- lib_enc/ivas_mct_enc.c | 2 +- lib_rend/ivas_output_init.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b9a89523aa..12fd1ba693 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1408,8 +1408,8 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } } - else - { + else + { for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); @@ -1617,7 +1617,7 @@ void ivas_jbm_dec_get_md_map( *--------------------------------------------------------------------------*/ void ivas_jbm_dec_get_md_map_even_spacing( #ifndef FIX_634_MASA_JBM_UNUSED_PARAMETER - const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t default_len, /* i : default frame length in metadata slots */ #endif const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 32cfaf216c..679f911d66 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -619,7 +619,7 @@ void ivas_sba_mix_matrix_determiner( #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP float *output[], /* i/o: transport/output audio channels */ #else - float output[][L_FRAME48k], /* i/o: transport/output audio channels */ + float output[][L_FRAME48k], /* i/o: transport/output audio channels */ #endif const int16_t bfi, /* i : BFI flag */ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 17470c8941..6e86ecdd14 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -108,7 +108,7 @@ static void map_input_to_cpe_channels( #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP float *data[MCT_MAX_CHANNELS] /* i : input channel data */ #else - float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ + float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ #endif ) { diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 352ebb60ec..45799401a6 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -336,7 +336,7 @@ int16_t ivas_get_nchan_buffers( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - nchan_out_buff = st_ivas->nchan_ism + st_ivas->nchan_transport; + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; if ( st_ivas->hMCT != NULL ) { -- GitLab From 55426bb8e6df31653dfa95c37d1a067abc95a141 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 21:06:06 +0200 Subject: [PATCH 12/19] fix OSBA EXT output --- lib_rend/ivas_output_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 45799401a6..3a6e69f68e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -336,7 +336,7 @@ int16_t ivas_get_nchan_buffers( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + nchan_out_buff = st_ivas->nchan_ism + st_ivas->nchan_transport; if ( st_ivas->hMCT != NULL ) { @@ -357,6 +357,10 @@ int16_t ivas_get_nchan_buffers( nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ } } + else if ( output_config == AUDIO_CONFIG_EXTERNAL ) + { + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + } } else if ( st_ivas->ivas_format == MC_FORMAT ) { -- GitLab From 5a52efece49f1a08d23822f88cb5af4435655283 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 21:22:29 +0200 Subject: [PATCH 13/19] fix OSBA EXT output --- lib_rend/ivas_output_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 3a6e69f68e..68a93f7a6e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -359,7 +359,7 @@ int16_t ivas_get_nchan_buffers( } else if ( output_config == AUDIO_CONFIG_EXTERNAL ) { - nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */ } } else if ( st_ivas->ivas_format == MC_FORMAT ) -- GitLab From 03059ea8df0bc0eae8ccaeb855b01a3f79e873e3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 22:32:28 +0200 Subject: [PATCH 14/19] fix USAN --- lib_dec/ivas_ism_dec.c | 29 ++++++++++++++++------------- lib_dec/ivas_omasa_dec.c | 29 ++++++++++++++++------------- lib_dec/ivas_sba_dec.c | 29 ++++++++++++++++------------- lib_rend/ivas_output_init.c | 6 ++++++ 4 files changed, 54 insertions(+), 39 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 1ee36cf987..997f4aeeec 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -351,25 +351,28 @@ static ivas_error ivas_ism_bitrate_switching( * floating-point output audio buffers *-----------------------------------------------------------------*/ - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); - - if ( nchan_out_buff > nchan_out_buff_old ) + if ( !st_ivas->hDecoderConfig->voip_active ) { - for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { - 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 ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + 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++ ) + else { - free( st_ivas->p_output_f[ch] ); - st_ivas->p_output_f[ch] = NULL; + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) + { + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; + } } } #endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 362cdcc081..15a49423fa 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -417,25 +417,28 @@ ivas_error ivas_omasa_dec_config( * floating-point output audio buffers *-----------------------------------------------------------------*/ - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); - - if ( nchan_out_buff > nchan_out_buff_old ) + if ( !st_ivas->hDecoderConfig->voip_active ) { - for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) { - 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 ( ( st_ivas->p_output_f[k] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + } } } - } - else - { - for ( k = nchan_out_buff; k < nchan_out_buff_old; k++ ) + else { - free( st_ivas->p_output_f[k] ); - st_ivas->p_output_f[k] = NULL; + for ( k = nchan_out_buff; k < nchan_out_buff_old; k++ ) + { + free( st_ivas->p_output_f[k] ); + st_ivas->p_output_f[k] = NULL; + } } } #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8a4043342d..18819c7a16 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -532,25 +532,28 @@ ivas_error ivas_sba_dec_reconfigure( * floating-point output audio buffers *-----------------------------------------------------------------*/ - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); - - if ( nchan_out_buff > nchan_out_buff_old ) + if ( !st_ivas->hDecoderConfig->voip_active ) { - for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + + if ( nchan_out_buff > nchan_out_buff_old ) { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { - 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 ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + { + 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++ ) + else { - free( st_ivas->p_output_f[ch] ); - st_ivas->p_output_f[ch] = NULL; + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) + { + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; + } } } #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 68a93f7a6e..22bf8604f2 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -356,11 +356,17 @@ int16_t ivas_get_nchan_buffers( { nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ } + else + { + nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for iivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */ + } } else if ( output_config == AUDIO_CONFIG_EXTERNAL ) { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */ } + + nchan_out_buff = min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); } else if ( st_ivas->ivas_format == MC_FORMAT ) { -- GitLab From 0250becb98415f2f81bb06ba4d6a0d5c57d4348c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 23:11:36 +0200 Subject: [PATCH 15/19] fix MASA MSAN errors --- lib_dec/ivas_init_dec.c | 9 +-------- lib_dec/ivas_ism_dec.c | 2 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec.c | 5 ----- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6f6874585c..dae0de0668 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2246,17 +2246,10 @@ ivas_error ivas_init_decoder( if ( !st_ivas->hDecoderConfig->voip_active ) { - output_Fs_buffers = max( output_Fs, 32000 ); /* note: 32000 == max internal sampling rate in TCX core */ - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) - { - /* ivas_mct_dec() is based on L_FRAME48k instead of output_frame */ - output_Fs_buffers = 48000; - } - for ( n = 0; n < ivas_get_nchan_buffers( st_ivas ); n++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( output_Fs_buffers / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + if ( ( st_ivas->p_output_f[n] = (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" ) ); } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 997f4aeeec..ec5df12570 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -360,7 +360,7 @@ static ivas_error ivas_ism_bitrate_switching( for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 15a49423fa..abbe112770 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -426,7 +426,7 @@ ivas_error ivas_omasa_dec_config( for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 18819c7a16..3166302f52 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -541,7 +541,7 @@ ivas_error ivas_sba_dec_reconfigure( for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( max( st_ivas->hDecoderConfig->output_Fs, 32000 ) / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 85f1d0396c..2c541768e9 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -366,13 +366,8 @@ void stereo_mdct_core_dec( ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, fUseTns, 0 ); -#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - mvr2r( signal_out_tmp[0], signal_out[0], (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ); - mvr2r( signal_out_tmp[1], signal_out[1], (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ); -#else mvr2r( signal_out_tmp[0], signal_out[0], L_FRAME48k ); mvr2r( signal_out_tmp[1], signal_out[1], L_FRAME48k ); -#endif mvr2r( signal_outFB_tmp[0], signal_outFB[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); mvr2r( signal_outFB_tmp[1], signal_outFB[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX ); -- GitLab From 6353be0bda977cf1b9c8f59f769f2043a19db931 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 23:26:58 +0200 Subject: [PATCH 16/19] fix remaining OSBA ASAN errors --- lib_dec/ivas_init_dec.c | 5 +---- lib_dec/ivas_ism_dec.c | 4 ++-- lib_dec/ivas_mc_paramupmix_dec.c | 2 +- lib_dec/ivas_omasa_dec.c | 4 ++-- lib_dec/ivas_sba_dec.c | 4 ++-- lib_dec/ivas_sba_rendering_internal.c | 5 +++++ lib_rend/ivas_output_init.c | 4 ++-- lib_rend/ivas_prot_rend.h | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index dae0de0668..3919b7de70 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1081,9 +1081,6 @@ ivas_error ivas_init_decoder( #ifdef MASA_AND_OBJECTS int32_t ism_total_brate; #endif -#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - int32_t output_Fs_buffers; -#endif error = IVAS_ERR_OK; @@ -2246,7 +2243,7 @@ ivas_error ivas_init_decoder( if ( !st_ivas->hDecoderConfig->voip_active ) { - for ( n = 0; n < ivas_get_nchan_buffers( st_ivas ); n++ ) + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas ); n++ ) { /* 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_ism_dec.c b/lib_dec/ivas_ism_dec.c index ec5df12570..0375bd07e7 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -79,7 +79,7 @@ static ivas_error ivas_ism_bitrate_switching( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); #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 @@ -353,7 +353,7 @@ static ivas_error ivas_ism_bitrate_switching( if ( !st_ivas->hDecoderConfig->voip_active ) { - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); if ( nchan_out_buff > nchan_out_buff_old ) { diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index d6a874a250..d9d348c167 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -494,7 +494,7 @@ void ivas_mc_paramupmix_dec( } #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers( st_ivas ); ch++ ) + for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas ); ch++ ) { set_f( output_f[ch], 0.0f, output_frame ); } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index abbe112770..9ae1ff1cb3 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -188,7 +188,7 @@ ivas_error ivas_omasa_dec_config( st_ivas->ivas_format = st_ivas->last_ivas_format; ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); #endif st_ivas->ivas_format = ivas_format_orig; @@ -419,7 +419,7 @@ ivas_error ivas_omasa_dec_config( if ( !st_ivas->hDecoderConfig->voip_active ) { - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); if ( nchan_out_buff > nchan_out_buff_old ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3166302f52..52135acfb5 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -159,7 +159,7 @@ ivas_error ivas_sba_dec_reconfigure( nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - nchan_out_buff_old = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); #endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); @@ -534,7 +534,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( !st_ivas->hDecoderConfig->voip_active ) { - nchan_out_buff = ivas_get_nchan_buffers( st_ivas ); + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas ); if ( nchan_out_buff > nchan_out_buff_old ) { diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 679f911d66..ed9aa5ff61 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -424,13 +424,18 @@ void ivas_sba_upmixer_renderer( output_config = ( st_ivas->ivas_format == SBA_ISM_FORMAT ? st_ivas->hOutSetup.output_config : st_ivas->hDecoderConfig->output_config ); #endif #ifdef SBA_AND_OBJECTS +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ); ch++ ) +#else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) +#endif #else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) #endif { output_f[ch] = output[ch]; } + #ifdef SBA_AND_OBJECTS ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, #ifdef SBA_AND_OBJECTS diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 22bf8604f2..990d36c8f0 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -257,13 +257,13 @@ void ivas_output_init( #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP /*-----------------------------------------------------------------* - * ivas_get_nchan_buffers() + * ivas_get_nchan_buffers_dec() * * Return number of decoder audio buffers *-----------------------------------------------------------------*/ /*! r: number of decoder buffers */ -int16_t ivas_get_nchan_buffers( +int16_t ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 71ec5ee005..b2a3a8cdf5 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -78,7 +78,7 @@ void ivas_output_init( #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP /*! r: number of decoder buffers */ -int16_t ivas_get_nchan_buffers( +int16_t ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif -- GitLab From fc28ebbe1f63140d3d2da712c078ec4883fa16d1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 12 Aug 2023 00:26:28 +0200 Subject: [PATCH 17/19] fix OSBA MSAN error --- lib_dec/ivas_sba_rendering_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index ed9aa5ff61..e1139fb1ff 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -425,7 +425,7 @@ void ivas_sba_upmixer_renderer( #endif #ifdef SBA_AND_OBJECTS #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ); ch++ ) + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ) - st_ivas->nchan_ism; ch++ ) #else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) #endif -- GitLab From 8d1f86171a386590df91af62698fb71c97b9e8e7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 12 Aug 2023 00:53:02 +0200 Subject: [PATCH 18/19] fix OSBA MSAN error --- lib_dec/ivas_sba_rendering_internal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index e1139fb1ff..ecb7352168 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -402,6 +402,9 @@ void ivas_sba_upmixer_renderer( ) { int16_t nchan_internal; +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + int16_t sba_ch_idx; +#endif push_wmops( "ivas_sba_upmixer_renderer" ); @@ -425,7 +428,13 @@ void ivas_sba_upmixer_renderer( #endif #ifdef SBA_AND_OBJECTS #ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP - for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ) - st_ivas->nchan_ism; ch++ ) + sba_ch_idx = 0; + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_ism; + } + + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ) - sba_ch_idx; ch++ ) #else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) #endif -- GitLab From 8af0f501b0347e44ae259efade129da2c4d13310 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 12 Aug 2023 01:03:45 +0200 Subject: [PATCH 19/19] fix OSBA MSAN error --- lib_dec/ivas_sba_rendering_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index ecb7352168..84f5df812e 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -431,7 +431,7 @@ void ivas_sba_upmixer_renderer( sba_ch_idx = 0; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - st_ivas->nchan_ism; + sba_ch_idx = st_ivas->nchan_ism; } for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas ) - sba_ch_idx; ch++ ) -- GitLab