diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e51fc7b4e13f216a6c7d7c6cb4324cce65cbdbf1..884708ec4fe3f4992b8e77e977abfe09589f3d49 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -356,6 +356,13 @@ build-codec-instrumented-linux: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - ./scripts/prepare_instrumentation.sh - make -j -C scripts/c-code_instrument + artifacts: + when: always + access: all + expire_in: "30 days" + paths: + - wmc_tool_output.txt + # make sure that the codec builds with msan, asan and usan build-codec-sanitizers-linux: diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index 7f7e34b3f510d1ad02a8f6f34642ce3e9bb25093..718b8a240e01a3216d67581a6d3a9e2dc56910c1 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -552,10 +552,12 @@ ivas_error config_acelp1( const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const int16_t idchan, /* i : stereo channel ID */ - const int16_t active_cnt, /* i : Active frame counter */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + const int16_t active_cnt, /* i : Active frame counter */ +#endif + const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ + const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ ) { int16_t i, bits, nb_subfr; @@ -770,7 +772,11 @@ ivas_error config_acelp1( bits -= acelp_cfg->mid_lsf_bits; } +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + else if ( tdm_lp_reuse_flag == 1 && idchan == 1 ) +#else else if ( tdm_lp_reuse_flag == 1 && idchan == 1 && active_cnt != 1 ) +#endif { bits -= TDM_IC_LSF_PRED_BITS; } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e2d40e74dfd96fc57f96c0ef0675fa5824e5026f..6efd67fd39296832300d1f205b8d900dcd7da9e6 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -172,8 +172,13 @@ typedef enum #define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 #define MAX_JBM_CLDFB_TIMESLOTS 32 #define DEFAULT_JBM_CLDFB_TIMESLOTS 16 +#ifdef JBM_MEMORY_OPT +#define MAX_JBM_L_FRAME48k ( IVAS_MAX_FRAME_SIZE * 2 ) /* 1920: max. time-scaled frame buffer length (per channel) in samples */ +#define MAX_JBM_L_FRAME_NS 40000000L /* 40 ms: time-scaled frame size in ns, proportional to MAX_JBM_L_FRAME48k */ +#else #define MAX_JBM_L_FRAME48k 1920 #define MAX_JBM_L_FRAME_NS 40000000L +#endif #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f3366e08a8255cffd095db3d4ed886a2de457bf2..0a804a5815e6021210c8a6cd709609450bee7ed0 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -259,12 +259,28 @@ uint32_t ivas_syn_output( int16_t *synth_out /* o : integer 16 bits synthesis signal */ ); +#ifdef JBM_MEMORY_OPT +void ivas_buffer_interleaved_to_deinterleaved( + float *audio, /* i/o: audio buffer */ + const int16_t n_channels, /* i : number of channels */ + const int16_t frame_length, /* i : frame length (one channel) */ + const int16_t n_samp_full /* i : full frame length (one channel) */ +); + +void ivas_buffer_deinterleaved_to_interleaved( + float *audio[], /* i : deinterleaved audio buffer */ + const int16_t n_channels, /* i : number of channels */ + const int16_t frame_length, /* i : frame length (one channel) */ + float *audio_out /* o : interleaved audio buffer */ +); +#else void ivas_syn_output_f( float *synth[], /* i/o: float synthesis signal */ const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ float *synth_out /* o : integer 16 bits synthesis signal */ ); +#endif void ivas_initialize_handles_enc( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ @@ -832,8 +848,11 @@ ivas_error ivas_jbm_dec_flush_renderer( void ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ + int16_t *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ +#ifndef JBM_MEMORY_OPT + , + float *data /* i/o: time-scaled transport channels */ +#endif ); void ivas_dec_prepare_renderer( @@ -2103,7 +2122,9 @@ void td_stereo_param_updt( const float lsp_old_PCh[], /* i : primary channel old LSPs */ const float lsf_old_PCh[], /* i : primary channel old LSFs */ const float pitch_buf_PCh[], /* i : primary channel pitch buffer */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC float tdm_lspQ_PCh[], /* o : Q LSPs for primary channel */ +#endif float tdm_lsfQ_PCh[], /* o : Q LSFs for primary channel */ float tdm_Pri_pitch_buf[], /* o : pitch values for primary channel */ const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ @@ -3706,8 +3727,13 @@ void ivas_dirac_dec_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t nchan_transport, /* i : number of transport channels */ +#ifdef FIX_1319_STACK_SBA_DECODER + float *pppQMfFrame_ts_re[HOA3_CHANNELS][CLDFB_NO_COL_MAX], + float *pppQMfFrame_ts_im[HOA3_CHANNELS][CLDFB_NO_COL_MAX] +#else float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] +#endif ); void computeDiffuseness_mdft( diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index c96ff4db3067200d2dbcf630e8a3a161452bc754..65f3f4d0991b4c8177f338be50c0d48744b38526 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -440,10 +440,12 @@ void tdm_bit_alloc( *-------------------------------------------------------------------*/ void td_stereo_param_updt( - const float lsp_old_PCh[], /* i : primary channel old LSPs */ - const float lsf_old_PCh[], /* i : primary channel old LSFs */ - const float pitch_buf_PCh[], /* i : primary channel pitch buffer */ - float tdm_lspQ_PCh[], /* o : Q LSPs for primary channel */ + const float lsp_old_PCh[], /* i : primary channel old LSPs */ + const float lsf_old_PCh[], /* i : primary channel old LSFs */ + const float pitch_buf_PCh[], /* i : primary channel pitch buffer */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + float tdm_lspQ_PCh[], /* o : Q LSPs for primary channel */ +#endif float tdm_lsfQ_PCh[], /* o : Q LSFs for primary channel */ float tdm_Pri_pitch_buf[], /* o : pitch values for primary channel */ const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ @@ -456,14 +458,17 @@ void td_stereo_param_updt( if ( tdm_use_IAWB_Ave_lpc == 1 ) { mvr2r( IAWB_Ave, tdm_lsfQ_PCh, M ); +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC if ( tdm_lspQ_PCh != NULL ) { lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); } +#endif } else if ( flag_ACELP16k == 1 ) { +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC if ( tdm_lspQ_PCh != NULL ) { mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); @@ -472,18 +477,23 @@ void td_stereo_param_updt( } else { +#endif float lsp_temp[M]; mvr2r( lsp_old_PCh, lsp_temp, M ); lsp_convert_poly( lsp_temp, L_FRAME, 0 ); lsp2lsf( lsp_temp, tdm_lsfQ_PCh, M, INT_FS_12k8 ); +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC } +#endif } else { +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC if ( tdm_lspQ_PCh != NULL ) { mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); } +#endif mvr2r( lsf_old_PCh, tdm_lsfQ_PCh, M ); } diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 36c626daa74a4f5b7d9338bc76f34ec45f1662c9..a4b414b96da03fc7cb5fa3c8bde64e733db93c91 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -148,6 +148,70 @@ uint32_t ivas_syn_output( return noClipping; } +#ifdef JBM_MEMORY_OPT + +/*-------------------------------------------------------------------* + * ivas_buffer_interleaved_to_deinterleaved() + * + * Convert an interleaved buffer of audio channels to deinterleaved one + *-------------------------------------------------------------------*/ + +void ivas_buffer_interleaved_to_deinterleaved( + float *audio, /* i/o: audio buffer */ + const int16_t n_channels, /* i : number of channels */ + const int16_t frame_length, /* i : frame length (one channel) */ + const int16_t n_samp_full /* i : full frame length (one channel) */ +) +{ + int16_t offset, ch, m; + float buffer[MAX_TRANSPORT_CHANNELS][MAX_JBM_L_FRAME48k]; + + for ( ch = 0; ch < n_channels; ch++ ) + { + for ( m = 0; m < frame_length; m++ ) + { + buffer[ch][m] = audio[m * n_channels + ch]; + } + } + + offset = 0; + for ( ch = 0; ch < n_channels; ch++ ) + { + mvr2r( buffer[ch], audio + offset, frame_length ); + offset += n_samp_full; + } + + return; +} + + +/*-------------------------------------------------------------------* + * ivas_buffer_deinterleaved_to_interleaved() + * + * Convert a deinterleaved buffer of audio channels to interleaved one + *-------------------------------------------------------------------*/ + +void ivas_buffer_deinterleaved_to_interleaved( + float *audio[], /* i/o: deinterleaved audio buffer */ + const int16_t n_channels, /* i : number of channels */ + const int16_t frame_length, /* i : frame length (one channel) */ + float *audio_out /* o : interleaved audio buffer */ +) +{ + int16_t ch, m; + + for ( ch = 0; ch < n_channels; ch++ ) + { + for ( m = 0; m < frame_length; m++ ) + { + audio_out[m * n_channels + ch] = audio[ch][m]; + } + } + + return; +} + +#else /*-------------------------------------------------------------------* * ivas_syn_output_f() @@ -181,6 +245,7 @@ void ivas_syn_output_f( return; } +#endif /*-------------------------------------------------------------------* * mvr2r_inc() diff --git a/lib_com/options.h b/lib_com/options.h index 9e2a3806b794093360a6d7bb4614e6b98b569898..aec5a9e67239729ece0eeed61dc81faf7f7dad6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,8 @@ #define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ #define FIX_NCHAN_BUFFERS /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */ #define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ +#define FIX_1319_STACK_SBA_DECODER /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */ +#define JBM_MEMORY_OPT /* VA: issue 916: optimization of RAM in the JBM decoder */ /* #################### End BE switches ################################## */ @@ -175,6 +177,8 @@ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define NONBE_FIX_1326_MASA_EXTREND_CUSTOMLS_OUT /* FhG: Fix crash for external renderer MASA to custom LS rendering, number of output channels not set correctly */ +#define NONBE_1325_TD_STEREO_QUANT_LSF_SEC /* Nokia: issue 1325: fix for usage of active_cnt variable in TD stereo LSFQ */ +#define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 18b6c30c5c8e96896c5cdd24b425549b85eb75e0..fe842760096ea095e82d3c4d582df4b6f26d28b7 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4551,15 +4551,17 @@ ivas_error acelp_core_dec( int16_t *unbits, /* o : number of unused bits */ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t last_element_mode, /* i : last element mode */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ +#endif + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const int16_t last_element_mode, /* i : last element mode */ + const int32_t last_element_brate, /* i : last element bitrate */ + const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ + const int16_t nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const int16_t read_sid_info /* i : read SID info flag */ ); void bass_psfilter_init( @@ -9113,10 +9115,12 @@ ivas_error config_acelp1( const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel*/ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/ const int16_t idchan, /* i : channel id */ - const int16_t active_cnt, /* i : Active frame counter */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + const int16_t active_cnt, /* i : Active frame counter */ +#endif + const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ ); /*! r: ACELP16k flag */ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 46a3ec30142fe5b653d1fdd4109129df8df1c79f..a5f6b0d7849a09e4e83be7f77549db9fbc1d057d 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -67,15 +67,17 @@ ivas_error acelp_core_dec( int16_t *unbits, /* o : number of unused bits */ int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t last_element_mode, /* i : last element mode */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ +#endif + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const int16_t last_element_mode, /* i : last element mode */ + const int32_t last_element_brate, /* i : last element bitrate */ + const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ + const int16_t nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const int16_t read_sid_info /* i : read SID info flag */ ) { float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ @@ -613,11 +615,19 @@ ivas_error acelp_core_dec( nb_bits = -1; } +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) { +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } } @@ -654,20 +664,22 @@ ivas_error acelp_core_dec( else { const float *pt_interp_2; - +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC if ( st->active_cnt != 1 ) { +#endif int16_t beta_index; beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index ); +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC } else { mvr2r( tdm_lspQ_PCh, lsp_new, M ); mvr2r( tdm_lsfQ_PCh, lsf_new, M ); } - +#endif if ( st->rate_switching_reset ) { /* extrapolation in case of unstable LSF convert */ diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index cedc755794b31f49007bbf96e6b590901b2b811c..762de6e65eca6182b99ba19b33a6eb2c02c8cab5 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -158,7 +158,11 @@ ivas_error acelp_core_switch_dec( * Excitation decoding *----------------------------------------------------------------*/ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, st->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, 0, 0, 0 /*st->GSC_IVAS_mode*/ ); +#else config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, st->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, st->active_cnt, 0, 0, 0 /*st->GSC_IVAS_mode*/ ); +#endif decod_gen_voic_core_switch( st, L_frame_for_cs, 0, Aq, exc, cbrate ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index c5bbddd0606e6859fa229a291c38db4fd2a67cb3..a1b790df81c9ca6399c8221f92e68e9b3759eadf 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -259,7 +259,11 @@ ivas_error evs_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + if ( ( error = acelp_core_dec( st, NULL, synth, NULL, bwe_exc_extended, voice_factors, old_syn_12k8_16k, sharpFlag, pitch_buf, &unbits, &sid_bw, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = acelp_core_dec( st, NULL, synth, NULL, bwe_exc_extended, voice_factors, old_syn_12k8_16k, sharpFlag, pitch_buf, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/gs_dec.c b/lib_dec/gs_dec.c index a04a8c6837f196f0d06fea3cb2bf330b8904361f..2902b4daba537a1cfe983aae52a537f8587c2e63 100644 --- a/lib_dec/gs_dec.c +++ b/lib_dec/gs_dec.c @@ -111,7 +111,11 @@ void decod_audio( } /* set bit-allocation */ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, -1, 1, &nb_bits, NULL, st->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, -1, 1, &nb_bits, NULL, st->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif /*---------------------------------------------------------------* * Decode energy dynamics diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 1a37f7e02ce893548d60c2b050c6decddd9616c3..9451b41653cf36913f87a1f7ec15594fdb2f3e11 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -294,7 +294,11 @@ ivas_error init_decoder( st->last_active_brate = ACELP_7k20; st->last_CNG_L_frame = L_FRAME; +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + st->active_cnt = CNG_TYPE_HO; +#else st->active_cnt = 20; +#endif if ( idchan == 0 && ( st->element_mode == EVS_MONO || st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) ) { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 7b6e5770e1a7b4a25c501d9b85e41228d8d46705..f460c574cf49ab89538c2d2a2651836195255213 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -89,7 +89,11 @@ ivas_error ivas_core_dec( int16_t unbits[CPE_CHANNELS]; int16_t sid_bw[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS]; +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + float tdm_lsfQ_PCh[M]; +#else float tdm_lspQ_PCh[M], tdm_lsfQ_PCh[M]; +#endif int16_t tdm_LRTD_flag; int32_t element_brate, output_Fs; int32_t last_element_brate; @@ -356,7 +360,11 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ - if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) + if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + tdm_lspQ_PCh, +#endif + tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) { return error; } @@ -380,7 +388,11 @@ ivas_error ivas_core_dec( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + td_stereo_param_updt( st->lsp_old, st->lsf_old, st->old_pitch_buf + st->nb_subfr, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#else td_stereo_param_updt( st->lsp_old, st->lsf_old, st->old_pitch_buf + st->nb_subfr, tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#endif } } /* n_channels loop */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index e9d9a62384da447235c60aed2466f969b69fc2a7..344b1f4357579421f02ec765d99553cc85e8282a 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -394,13 +394,23 @@ ivas_error ivas_cpe_dec( if ( sts[1] != NULL ) { sts[1]->active_cnt = 0; +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + if ( sts[1]->ini_frame == 0 ) + { + sts[1]->active_cnt = CNG_TYPE_HO; + } +#endif } } else { sts[n]->VAD = 1; sts[n]->active_cnt++; +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + sts[n]->active_cnt = min( sts[n]->active_cnt, 200 ); +#else sts[n]->active_cnt = min( sts[n]->active_cnt, 100 ); +#endif } /* set CNA flag */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index d7ee741ca92779ce12569c703cd48c2df3dbef41..53c8d8ccd5c03e794fc80c1ff1ece0a0d5865662 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1644,6 +1644,80 @@ void ivas_dirac_dec_render( return; } +#ifdef FIX_1319_STACK_SBA_DECODER +/*------------------------------------------------------------------------- + * Local functions to perform binaural rendering with optimized stack + *------------------------------------------------------------------------*/ + +static void binRenderer_split( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend, /* i/o: ISAR split binaural rendering handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ + const int16_t numTimeSlots, /* i : number of time slots to render */ + float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + const int16_t slot_idx_start, + const int16_t num_freq_bands, + const int16_t nchan_out ) +{ + int16_t pos_idx, slot_idx, ch; + float Cldfb_RealBuffer_Binaural_loc[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural_loc[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + + /* Perform binaural rendering */ + ivas_binRenderer( hBinRenderer, &hSplitBinRend->splitrend.multiBinPoseData, hCombinedOrientationData, numTimeSlots, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, +#endif + Cldfb_RealBuffer_Binaural_loc, Cldfb_ImagBuffer_Binaural_loc, RealBuffer, ImagBuffer ); + + for ( slot_idx = 0; slot_idx < numTimeSlots; slot_idx++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural_loc[0][ch][slot_idx], Cldfb_RealBuffer_Binaural[0][ch][slot_idx], num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Binaural_loc[0][ch][slot_idx], Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], num_freq_bands ); + } + } + + for ( pos_idx = 0; pos_idx < hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < numTimeSlots; slot_idx++ ) + { + for ( ch = 0; ch < nchan_out; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); + } + } + } + + return; +} + + +static void binRenderer( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ + const int16_t numTimeSlots, /* i : number of time slots to render */ + float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ +) +{ + /* Perform binaural rendering */ + ivas_binRenderer( hBinRenderer, NULL, hCombinedOrientationData, numTimeSlots, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, +#endif + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, RealBuffer, ImagBuffer ); + + return; +} +#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_render_sf() @@ -1655,8 +1729,14 @@ void ivas_dirac_dec_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t nchan_transport, /* i : number of transport channels */ +#ifdef FIX_1319_STACK_SBA_DECODER + float *pppQMfFrame_ts_re[HOA3_CHANNELS][CLDFB_NO_COL_MAX], + float *pppQMfFrame_ts_im[HOA3_CHANNELS][CLDFB_NO_COL_MAX] +#else float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) + float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] +#endif +) { int16_t i, ch, idx_in, idx_lfe; DIRAC_DEC_HANDLE hDirAC; @@ -1670,13 +1750,20 @@ void ivas_dirac_dec_render_sf( float *p_Rmat; int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx; - /*CLDFB: last output channels reserved to LFT for CICPx*/ + /*CLDFB: last output channels reserved to LFE for CICPx*/ +#ifdef FIX_1319_STACK_SBA_DECODER + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_RealBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif int16_t index, num_freq_bands; /* local copies of azi, ele, diffuseness */ @@ -1853,17 +1940,29 @@ void ivas_dirac_dec_render_sf( /* CLDFB Analysis*/ for ( ch = 0; ch < nchan_transport; ch++ ) { +#ifdef FIX_1319_STACK_SBA_DECODER + cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), + Cldfb_RealBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */ + Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */ + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch] ); +#else cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer_Temp[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); +#endif } } if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { +#ifdef FIX_1319_STACK_SBA_DECODER + ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_Binaural[0], Cldfb_ImagBuffer_Binaural[0], hSpatParamRendCom->num_freq_bands, subframe_idx ); +#else ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); +#endif } } @@ -1890,8 +1989,13 @@ void ivas_dirac_dec_render_sf( { for ( ch = 0; ch < nchan_transport; ch++ ) { +#ifdef FIX_1319_STACK_SBA_DECODER + mvr2r( Cldfb_RealBuffer_Binaural[0][ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Binaural[0][ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); +#else mvr2r( Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); mvr2r( Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); +#endif } } else @@ -2334,6 +2438,20 @@ void ivas_dirac_dec_render_sf( } } +#ifdef FIX_1319_STACK_SBA_DECODER + /* Perform binaural rendering */ + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + binRenderer_split( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer, slot_idx_start, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); + } + else + { + binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + } + +#else /* Perform binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -2356,13 +2474,19 @@ void ivas_dirac_dec_render_sf( } } } +#endif /* Inverse CLDFB*/ for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ +#ifdef FIX_1319_STACK_SBA_DECODER + float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME]; + float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME]; +#else float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { @@ -2386,8 +2510,13 @@ void ivas_dirac_dec_render_sf( } else { +#ifdef FIX_1319_STACK_SBA_DECODER + float *RealBuffer[CLDFB_SLOTS_PER_SUBFRAME]; + float *ImagBuffer[CLDFB_SLOTS_PER_SUBFRAME]; +#else float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif int16_t outchannels; idx_in = 0; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 649cb15bbb728f44030211f2d3037b037063f539..31e6178c48c0a4043c03e49bfdef613ee911c3c2 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -757,12 +757,20 @@ ivas_error ivas_jbm_dec_tc( void ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : transport channels */ + int16_t *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ +#ifndef JBM_MEMORY_OPT + , + float *data /* i : transport channels */ +#endif ) { +#ifdef JBM_MEMORY_OPT + float tmp_buf[MAX_JBM_L_FRAME48k]; + float *p_data_f[FOA_CHANNELS + MAX_NUM_OBJECTS]; +#else float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; +#endif int16_t n, n_render_timeslots, n_ch_cldfb; int16_t ch; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -772,6 +780,38 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#ifdef JBM_MEMORY_OPT + int16_t n_samples_still_available; + int16_t n_ch_full_copy, n_ch_res_copy; + + n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; + hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; + hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity ); + *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available; + n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + + for ( ch = 0; ch < n_ch_full_copy; ch++ ) + { + mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering ); + set_zero( hTcBuffer->tc[ch], hTcBuffer->n_samples_discard ); + mvr2r( hTcBuffer->tc_buffer_old[ch], hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); + mvr2r( tmp_buf, hTcBuffer->tc[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual ); + mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual ); + } + + if ( n_ch_res_copy > 0 ) + { + for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) + { + p_data_f[ch] = hTcBuffer->tc[ch]; + mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering ); + mvr2r( hTcBuffer->tc_buffer_old[ch], p_data_f[ch], n_samples_still_available ); + mvr2r( tmp_buf, p_data_f[ch] + n_samples_still_available, nSamplesForRendering - *nSamplesResidual ); + mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual ); + } + } +#else int16_t n_samples_still_available, m; int16_t n_ch_full_copy; int16_t n_ch_res_copy; @@ -811,6 +851,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( mvr2r( p_data_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } } +#endif n_render_timeslots = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; } @@ -822,7 +863,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( } #ifdef FIX_NCHAN_BUFFERS +#ifdef JBM_MEMORY_OPT + ch = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); +#else ch = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif for ( n = 0; n < ch; n++ ) #else for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) @@ -899,7 +944,11 @@ ivas_error ivas_jbm_dec_render( if ( !st_ivas->hDecoderConfig->Opt_tsm ) { +#ifdef JBM_MEMORY_OPT + for ( n = 0; n < MAX_INTERN_CHANNELS; n++ ) +#else for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) +#endif { st_ivas->hTcBuffer->tc[n] = p_output[n]; } @@ -1352,7 +1401,11 @@ ivas_error ivas_jbm_dec_render( break; case PCM_FLOAT32: +#ifdef JBM_MEMORY_OPT + ivas_buffer_deinterleaved_to_interleaved( p_output, nchan_out_syn_output, *nSamplesRendered, (float *) data ); +#else ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); +#endif break; default: error = IVAS_ERR_UNKNOWN; @@ -1415,6 +1468,15 @@ ivas_error ivas_jbm_dec_flush_renderer( { int16_t ch_idx; +#ifdef JBM_MEMORY_OPT + /* render available full slots (with new lower granularity) */ + for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + { + /* move it at the beginning of the TC buffer with zero padding */ + mvr2r( hTcBuffer->tc_buffer_old[ch_idx], hTcBuffer->tc[ch_idx], n_samples_to_render ); + set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); + } +#else /* render what is still there with zero padding */ for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1423,6 +1485,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); } +#endif /* simple change of the slot info */ hTcBuffer->num_slots = 1; @@ -1624,7 +1687,11 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data ); break; case PCM_FLOAT32: +#ifdef JBM_MEMORY_OPT + ivas_buffer_deinterleaved_to_interleaved( p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, (float *) data ); +#else ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); +#endif break; default: error = IVAS_ERR_UNKNOWN; @@ -2045,6 +2112,127 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } +#ifdef JBM_MEMORY_OPT + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_audio_allocate() + * + * allocate and initialize TC audio buffer + *--------------------------------------------------------------------------*/ + +static ivas_error ivas_jbm_dec_tc_audio_allocate( + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t Opt_tsm /* i : TSM option flag */ +) +{ + int16_t nsamp_to_allocate; + int16_t ch_idx, n_samp_full, n_samp_residual, offset; + + if ( Opt_tsm ) + { + n_samp_full = ( NS2SA( output_Fs, MAX_JBM_L_FRAME_NS ) ); + n_samp_residual = hTcBuffer->n_samples_granularity - 1; + } + else + { + n_samp_full = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + n_samp_residual = 0; + } + + nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; + + if ( Opt_tsm ) + { + /* note: this is stack memory buffer for time-scale modified audio signals */ + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + + offset = 0; + for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + + /* memory buffer for TC audio samples not rendered in the previous frame */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + if ( ( hTcBuffer->tc_buffer_old[ch_idx] = (float *) malloc( n_samp_residual * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer_old[ch_idx], n_samp_residual ); + } + for ( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_buffer_old[ch_idx] = NULL; + } + } + else + { + hTcBuffer->tc_buffer = NULL; + + for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + + for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc_buffer_old[ch_idx] = NULL; + } + } + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_audio_deallocate() + * + * deallocate TC audio buffer + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_audio_deallocate( + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */ +) +{ + int16_t ch_idx; + + if ( hTcBuffer != NULL ) + { + if ( hTcBuffer->tc_buffer != NULL ) + { + for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + + free( hTcBuffer->tc_buffer ); + hTcBuffer->tc_buffer = NULL; + } + + for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ ) + { + if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL ) + { + free( hTcBuffer->tc_buffer_old[ch_idx] ); + hTcBuffer->tc_buffer_old[ch_idx] = NULL; + } + } + } + + return; +} +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() @@ -2061,11 +2249,17 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { +#ifndef JBM_MEMORY_OPT int16_t nsamp_to_allocate; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; int16_t nMaxSlotsPerSubframe; +#ifdef JBM_MEMORY_OPT + ivas_error error; +#else int16_t nchan_residual; int16_t ch_idx; +#endif /*-----------------------------------------------------------------* * prepare library opening @@ -2080,7 +2274,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; hTcBuffer->nchan_buffer_full = nchan_full; +#ifndef JBM_MEMORY_OPT nchan_residual = nchan_transport_internal - nchan_full; +#endif hTcBuffer->n_samples_granularity = n_samples_granularity; hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_buffered = 0; @@ -2090,12 +2286,20 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->n_samples_discard = 0; hTcBuffer->n_samples_flushed = 0; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; +#ifndef JBM_MEMORY_OPT nsamp_to_allocate = 0; +#endif nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef JBM_MEMORY_OPT + if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + { + return error; + } +#else { int16_t n_samp_full, n_samp_residual; int32_t offset; @@ -2155,6 +2359,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } } } +#endif st_ivas->hTcBuffer = hTcBuffer; @@ -2177,8 +2382,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { +#ifdef JBM_MEMORY_OPT + ivas_error error; +#else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -2220,13 +2429,26 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; hTcBuffer->nchan_buffer_full = nchan_full; +#ifndef JBM_MEMORY_OPT nchan_residual = nchan_transport_internal - nchan_full; +#endif hTcBuffer->n_samples_granularity = n_samples_granularity; #ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif + +#ifdef JBM_MEMORY_OPT + /* reallocate TC audio buffers */ + + ivas_jbm_dec_tc_audio_deallocate( hTcBuffer ); + + if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + { + return error; + } +#else /* realloc buffers */ if ( hTcBuffer->tc_buffer != NULL ) { @@ -2286,6 +2508,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->tc_buffer = NULL; } } +#endif return IVAS_ERR_OK; } @@ -2344,10 +2567,15 @@ void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { +#ifndef JBM_MEMORY_OPT int16_t i; +#endif if ( *phTcBuffer != NULL ) { +#ifdef JBM_MEMORY_OPT + ivas_jbm_dec_tc_audio_deallocate( *phTcBuffer ); +#else for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { ( *phTcBuffer )->tc[i] = NULL; @@ -2358,6 +2586,7 @@ void ivas_jbm_dec_tc_buffer_close( free( ( *phTcBuffer )->tc_buffer ); ( *phTcBuffer )->tc_buffer = NULL; } +#endif free( *phTcBuffer ); *phTcBuffer = NULL; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 98dc1ad3fa7e31c6b606e448b48887915d8725c1..bdcf15e2d8ed3dec74d9422cf4c365d7651d30ff 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1367,15 +1367,28 @@ void ivas_spar_dec_upmixer_sf( ) { int16_t cldfb_band, num_cldfb_bands, numch_in, numch_out; +#ifdef FIX_1319_STACK_SBA_DECODER + float *cldfb_in_ts_re[HOA3_CHANNELS][CLDFB_NO_COL_MAX]; + float *cldfb_in_ts_im[HOA3_CHANNELS][CLDFB_NO_COL_MAX]; +#else float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; +#endif int16_t i, b, ts, out_ch, in_ch; int16_t num_spar_bands, spar_band, nchan_transport; int16_t num_in_ingest, split_band; int16_t slot_size, slot_idx_start; +#ifdef FIX_1319_STACK_SBA_DECODER + float *p_tc[HOA3_CHANNELS]; +#else float *p_tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#endif int16_t md_idx; +#ifdef FIX_1319_STACK_SBA_DECODER + float Pcm_tmp[HOA3_CHANNELS][2 /* Re, Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#else float Pcm_tmp[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; +#endif int16_t numch_out_dirac; float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -1490,7 +1503,11 @@ void ivas_spar_dec_upmixer_sf( if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ +#ifdef FIX_1319_STACK_SBA_DECODER + for ( in_ch = 0; in_ch < HOA3_CHANNELS; in_ch++ ) +#else for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ ) +#endif { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 89d53452bb5c449e2577ccf17c2a48ee2fcddae3..28de5d73400e33af41ed14c216474e1ee7b22d1a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -944,16 +944,23 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { - float *tc_buffer; /* the buffer itself */ - float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ +#ifdef JBM_MEMORY_OPT + float *tc_buffer_old[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ +#endif + float *tc_buffer; /* the buffer itself */ +#ifdef JBM_MEMORY_OPT + float *tc[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ +#else + float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ // VE2SB: TBV +#endif + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ + int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + int16_t nchan_buffer_full; /* number of channels to be fully buffered */ + int16_t n_samples_available; /* samples still available for rendering in the current frame */ + int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + int16_t n_samples_rendered; /* samples already rendered in the current frame */ + int16_t n_samples_granularity; /* render granularity */ int16_t n_samples_flushed; int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; int16_t nb_subframes; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 3305a1e48d6601bb5489d3f38a23c27e0ba00f66..fdb41a3cb23bf8a46847710e8e2366cd65fc7c68 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -562,7 +562,11 @@ uint8_t apa_exec( ) { uint16_t i; +#ifdef JBM_MEMORY_OPT + float frm_in[APA_BUF]; /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ +#else float frm_in[APA_BUF]; /* TODO(mcjbm): this buffer could be smaller - always allocates space for 16 channels */ +#endif uint16_t l_frm_out; int16_t l_rem; int32_t dl_scaled, dl_copied, l_frm_out_target; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index a728cb53d346366279f716c756017a71eda89711..6d35fa8b505e1641a631ff6708aa4a01fd06cdd1 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -50,9 +50,14 @@ */ /* size of IO buffers (a_in[], a_out[]) for apa_exec() */ +#ifdef JBM_MEMORY_OPT +#define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 2 ) /* == twice the max. frame length */ +#define APA_MAX_NUM_CHANNELS ( 12 ) /* == MAX_TRANSPORT_CHANNELS */ +#else #define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 3 ) #define APA_MAX_NUM_CHANNELS 16 -#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) +#endif +#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) /* min/max sampling rate [Hz] */ #define APA_MIN_RATE 1000 diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3c9ffad205707f9737b452d689538d61e049e0ee..7750bc70fc7bcb72203922a154d80d23b99ea42f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -85,7 +85,9 @@ struct IVAS_DEC int16_t tsm_max_scaling; int16_t timeScalingDone; /* have we done already one TSM in a 20ms frame? */ float tsm_quality; +#ifndef JBM_MEMORY_OPT float *apaExecBuffer; /* Buffer for APA scaling */ +#endif PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; @@ -159,7 +161,9 @@ ivas_error IVAS_DEC_Open( } hIvasDec = *phIvasDec; hIvasDec->hVoIP = NULL; +#ifndef JBM_MEMORY_OPT hIvasDec->apaExecBuffer = NULL; +#endif hIvasDec->hTimeScaler = NULL; hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; @@ -350,11 +354,12 @@ void IVAS_DEC_Close( apa_exit( &( *phIvasDec )->hTimeScaler ); +#ifndef JBM_MEMORY_OPT if ( ( *phIvasDec )->apaExecBuffer != NULL ) { free( ( *phIvasDec )->apaExecBuffer ); } - +#endif if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); @@ -953,8 +958,9 @@ static IVAS_BIN_RENDERER_TYPE renderer_type_to_mode( * IVAS_DEC_ReadFormat( ) * * Read main parameters from the bitstream to set-up the decoder: - * - IVAS fromat + * - IVAS format * - IVAS format specific signaling + * - compensate for renderer granularity change in JBM *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_ReadFormat( @@ -1137,7 +1143,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } st_ivas = hIvasDec->st_ivas; +#ifdef JBM_MEMORY_OPT + isInitialized_voip = hIvasDec->hTimeScaler != NULL; +#else isInitialized_voip = hIvasDec->apaExecBuffer != NULL; +#endif if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ { @@ -1195,9 +1205,17 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } - ivas_syn_output_f( hIvasDec->st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer ); +#ifdef JBM_MEMORY_OPT + /* convert deinterleaved decoded TC audio channels buffer to an interleaved one */ + ivas_buffer_deinterleaved_to_interleaved( st_ivas->p_output_f, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_buffer ); + + /* time-scale modification */ + if ( apa_exec( hIvasDec->hTimeScaler, st_ivas->hTcBuffer->tc_buffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, st_ivas->hTcBuffer->tc_buffer, &nTimeScalerOutSamples ) != 0 ) +#else + ivas_syn_output_f( st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer ); if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) +#endif { return IVAS_ERR_UNKNOWN; } @@ -1205,6 +1223,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( assert( nTimeScalerOutSamples <= APA_BUF ); nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; hIvasDec->timeScalingDone = 1; +#ifdef JBM_MEMORY_OPT + + /* convert interleaved time-scaled TC audio channels buffer to deinterleaved one */ + ivas_buffer_interleaved_to_deinterleaved( st_ivas->hTcBuffer->tc_buffer, nTransportChannels, nSamplesTcsScaled, NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); +#endif } else { @@ -1215,7 +1238,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * Feed decoded transport channels samples to the renderer *-----------------------------------------------------------------*/ +#ifdef JBM_MEMORY_OPT + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesTcsScaled, &nResidualSamples ); +#else ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ); +#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -1225,6 +1252,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; } @@ -1477,12 +1505,9 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; - - st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; - st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; - + st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } @@ -1618,7 +1643,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } else { - /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ + /* detect editing in ISM_MASA_MODE_DISC mode */ if ( fabsf( st_ivas->hIsmMetaData[obj]->azimuth - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || fabsf( st_ivas->hIsmMetaData[obj]->elevation - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) { @@ -1653,12 +1678,13 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; - +#ifndef NONBE_FIX_1172_OBJ_EDIT_JBM st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; st_ivas->hIsmMetaData[obj]->pitch = hIvasEditableParameters.ism_metadata[obj].pitch; st_ivas->hIsmMetaData[obj]->radius = hIvasEditableParameters.ism_metadata[obj].radius; +#endif st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } @@ -4481,7 +4507,9 @@ static ivas_error apa_setup( const bool isInitialized_voip, const uint16_t nTransportChannels ) { +#ifndef JBM_MEMORY_OPT int16_t apa_buffer_size; +#endif uint16_t l_ts; l_ts = (uint16_t) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; @@ -4493,9 +4521,11 @@ static ivas_error apa_setup( float startQuality; startQuality = hIvasDec->tsm_quality; +#ifndef JBM_MEMORY_OPT apa_buffer_size = APA_BUF_PER_CHANNEL; - /* get current renderer type*/ + +#endif hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; if ( hDecoderConfig->output_Fs == 8000 ) @@ -4539,6 +4569,7 @@ static ivas_error apa_setup( return IVAS_ERR_INIT_ERROR; } } +#ifndef JBM_MEMORY_OPT if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) { @@ -4546,6 +4577,7 @@ static ivas_error apa_setup( } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#endif } else { @@ -4553,15 +4585,15 @@ static ivas_error apa_setup( { return IVAS_ERR_INIT_ERROR; } - +#ifndef JBM_MEMORY_OPT /* realloc apa_exe_buffer */ - apa_buffer_size = APA_BUF_PER_CHANNEL; free( hIvasDec->apaExecBuffer ); if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#endif } hIvasDec->nTransportChannelsOld = nTransportChannels; @@ -4800,6 +4832,11 @@ static void ivas_destroy_handle_isar( free( ( *hSplitBinRend )->hCldfbDataOut ); ( *hSplitBinRend )->hCldfbDataOut = NULL; } +#ifdef FIX_1319_STACK_SBA_DECODER + + free( ( *hSplitBinRend ) ); + ( *hSplitBinRend ) = NULL; +#endif } return; diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index cf43042ce0088936e8529e9e0857e51eef3d49f9..e0e7b1be037e1adcb409cd14714fbccfb8bae881 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -375,7 +375,11 @@ ivas_error acelp_core_enc( if ( !nelp_mode && !ppp_mode ) { +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } /*-----------------------------------------------------------------* @@ -416,21 +420,21 @@ ivas_error acelp_core_enc( else { const float *pt_interp_2; - +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC if ( st->active_cnt != 1 ) { +#endif int16_t beta_index; float lsf_wgts[M]; /* intra_frame prediction for the LSFs */ lsp2lsf( lsp_new, lsf_new, M, 12800 ); - Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M ); - tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index ); - push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS ); +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC } +#endif pt_interp_2 = interpol_frac_12k8; if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) @@ -495,7 +499,11 @@ ivas_error acelp_core_enc( { tc_classif_enc( st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res ); +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } /*---------------------------------------------------------------* @@ -553,7 +561,11 @@ ivas_error acelp_core_enc( lsf_syn_mem_restore( st, tilt_code_bck, gc_threshold_bck, clip_var_bck, next_force_sf_bck, lsp_new, lsp_mid, clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, mem_w0_bck, streaklimit, pstreaklen ); /* Configure ACELP bit allocation */ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif /* redo LSF quantization */ lsf_enc( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL ); diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index b169adc8fb11f9f39e5a74217385f73831f2a6f2..ce178ac43e38db4a82ad2e0e3b8cd99a3f5cb763 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -153,7 +153,11 @@ void acelp_core_switch_enc( * Excitation encoding *----------------------------------------------------------------*/ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st->inactive_coder_type_flag, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st->inactive_coder_type_flag, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#endif encod_gen_voic_core_switch( st, st->last_L_frame, inp, Aq, A, T_op, st->voicing, exc, cbrate ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 53669f7b65db36fa94ab15c1422cc01c82da9132..afc9b7ca28ed4b4e8bb2b6dca55669e45c49cb1d 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -266,7 +266,11 @@ ivas_error ivas_core_enc( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + td_stereo_param_updt( st->lsp_old, st->lsf_old, pitch_buf[0], tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#else td_stereo_param_updt( st->lsp_old, st->lsf_old, pitch_buf[0], NULL, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#endif } } diff --git a/lib_enc/transition_enc.c b/lib_enc/transition_enc.c index 016f5ba0fa970a193b91f59be5016f43b16dd019..804e9c0a48eb61f019d52b7dd268e8fd2da92403 100644 --- a/lib_enc/transition_enc.c +++ b/lib_enc/transition_enc.c @@ -178,7 +178,11 @@ void transition_enc( if ( *tc_subfr == TC_0_0 ) { /* this is called only to compute unused bits */ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, L_FRAME, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, L_FRAME, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } *clip_gain = gp_clip( st->element_mode, st->core_brate, st->voicing, i_subfr, TRANSITION, xn, gp_cl ); @@ -274,7 +278,11 @@ void transition_enc( if ( i_subfr - *tc_subfr <= L_SUBFR ) { +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } /*-----------------------------------------------------------------* diff --git a/scripts/basop_create_ignorelist_for_ubsan.py b/scripts/basop_create_ignorelist_for_ubsan.py index d13c0d5f5b7054ed73e37fa1aa8339153bc77590..d34efff36347955a2f2e2c9a453eea7427cd746d 100644 --- a/scripts/basop_create_ignorelist_for_ubsan.py +++ b/scripts/basop_create_ignorelist_for_ubsan.py @@ -9,6 +9,10 @@ basop_files = here.glob("lib_*/basop*.[ch]") ignorefiles = sorted(set(non_ivas_files) - set(basop_files)) +ignorefunctions = ["L_add_o", "L_add_co", "L_sub_o", "shl_o", "L_deposit_h"] + with open("ubsan_ignorelist.txt", "w") as f: for cfile in ignorefiles: print(f"src:{cfile}", file=f) + for fun in ignorefunctions: + print(f"fun:*{fun}*", file=f) diff --git a/scripts/prepare_instrumentation.sh b/scripts/prepare_instrumentation.sh index c52c5658466b3d0f4d7c6f7a07d8dfd2faca6d70..52549c77898b75a3a1a028eb4599f518a8aa92e2 100755 --- a/scripts/prepare_instrumentation.sh +++ b/scripts/prepare_instrumentation.sh @@ -227,6 +227,8 @@ find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(u # run wmc_tool, exit if the command fails set -e +touch wmc_tool_output.txt +trap 'echo "Error calling WMC tool: $?"; cat wmc_tool_output.txt' ERR "$scriptdir/tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c" >>wmc_tool_output.txt 2>&1 "$scriptdir/tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >>wmc_tool_output.txt 2>&1 for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool @@ -241,6 +243,7 @@ else # ISAR post rend "$scriptdir/tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$lc3plus_fftdir" >>wmc_tool_output.txt 2>&1 fi +trap - ERR set +e # automatically enable #define WMOPS in options.h diff --git a/scripts/tools/Darwin/wmc_tool b/scripts/tools/Darwin/wmc_tool index 855bc1a4a77ee747cc9e7b754bd1598ad1b43b7d..7f6c185f4bdb89bfe622fa4251233ca042d66abc 100755 Binary files a/scripts/tools/Darwin/wmc_tool and b/scripts/tools/Darwin/wmc_tool differ diff --git a/scripts/tools/Linux/wmc_tool b/scripts/tools/Linux/wmc_tool index 5b58206b9ef08e2c8920817a0591f1e4ae89f2c9..5a9f27c86daba0b795aad9b7881ef2718d3e333d 100755 Binary files a/scripts/tools/Linux/wmc_tool and b/scripts/tools/Linux/wmc_tool differ diff --git a/scripts/tools/Win32/wmc_tool.exe b/scripts/tools/Win32/wmc_tool.exe index 87414242c34379b4a2776389e5fba5ed1cbcb649..c5a4aabe7242a9b30d591c146124028942bc0a95 100755 --- a/scripts/tools/Win32/wmc_tool.exe +++ b/scripts/tools/Win32/wmc_tool.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69b3382c94f1c83864d216b7e9b4c102c0266d29bf27cb09da2b1c56e106292b -size 276480 +oid sha256:a029f90c6f95aa75773466795ea2ae16847799d7feca408318ecd1265f517a41 +size 275968 diff --git a/tests/conftest.py b/tests/conftest.py index 5d3632a762c2818b21363114c83a964b5b5ece90..117eee835a263eea1c461daa88325939d32a6217 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -47,6 +47,7 @@ from shutil import move import tempfile from typing import Optional, Union, List import numpy as np +from _pytest.outcomes import Skipped, Failed from .constants import ( DMX_DIFF, DMX_MLD, @@ -446,6 +447,20 @@ def test_info(request): if hasattr(request, "error"): pytest.fail(request.error) +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_makereport(item, call): + # Use hook to catch exceptions + outcome = yield + report = outcome.get_result() + test_info = item.funcargs.get("test_info", None) + + if call.excinfo is not None and report.when == "call": + # Make sure exception is not due to a skipped or failed test (allowed exceptions) + type = call.excinfo.type + xfail = hasattr(report, "wasxfail") + if type not in [Skipped, Failed] and not xfail: + # Capture exception in test_info + test_info.error = str(call.excinfo.value) @pytest.fixture(scope="session") def split_comparison(request):