From a31e69292e04cd10d687bb9dfdd8c505758e7c2d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 20 Aug 2024 20:31:50 +0530 Subject: [PATCH] LTV multichannel stream high mld fixes --- lib_com/ivas_prot_fx.h | 28 +++++++++++++------------- lib_com/prot_fx.h | 3 ++- lib_com/tcx_ltp_fx.c | 10 +++++++-- lib_dec/core_dec_init_fx.c | 4 ++++ lib_dec/ivas_core_dec.c | 2 +- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_jbm_dec.c | 1 + lib_dec/ivas_mct_dec.c | 4 ++-- lib_dec/ivas_post_proc.c | 24 +++++++++++----------- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec.c | 16 +++++++-------- 11 files changed, 54 insertions(+), 42 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 14300beac..ddb6e0741 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -792,14 +792,14 @@ ivas_error ivas_cpe_dec_fx( ); void ivas_post_proc_fx( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word16 n, /* i : channel number */ - Word32 synth[], /* i/o: output synthesis signal */ - Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); + SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word16 n, /* i : channel number */ + Word32 synth[], /* i/o: output synthesis signal */ + Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ + const Word16 output_frame, /* i : output frame length */ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + Word16 output_q ); #endif // ivas_lfe_dec_fx.c @@ -1699,12 +1699,12 @@ void ivas_hq_pred_hb_bws_fx( ); void synchro_synthesis_fx( - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *output_fx[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : Number of samples */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *output_fx[CPE_CHANNELS], /* i/o: output synthesis signal */ + const Word16 output_frame, /* i : Number of samples */ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + Word16 output_fx_q ); // ivas_dirac_output_synthesis_cov void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 88085ab79..b6e161351 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5273,7 +5273,8 @@ void tcx_ltp_post32( Word16 output_frame, Word16 delay, Word32 *sig, - Word32 *tcx_buf ); + Word32 *tcx_buf, + Word16 sig_q ); // gs_inact_switching_fx.c void Inac_swtch_ematch_fx( diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index 35884afaf..89965f8de 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -1669,7 +1669,8 @@ void tcx_ltp_post32( Word16 output_frame, Word16 delay, Word32 *sig, - Word32 *tcx_buf ) + Word32 *tcx_buf, + Word16 sig_q ) { Word16 tmp, L_transition, lpcorder, filtIdx; Word16 gain, gain2; @@ -1744,16 +1745,19 @@ void tcx_ltp_post32( /* Input buffer */ sig_in = buf_in + tcx_buf_len; Copy32( hTcxLtpDec->tcxltp_mem_in_32, buf_in, tcx_buf_len ); + scale_sig32( buf_in, tcx_buf_len, sub( hTcxLtpDec->exp_tcxltp_mem_in, sub( 31, sig_q ) ) ); Copy32( sig, buf_in + tcx_buf_len, output_frame ); IF( core > ACELP_CORE ) { Copy32( tcx_buf, sig_in + output_frame, tcx_buf_len ); } Copy32( sig + output_frame - tcx_buf_len, hTcxLtpDec->tcxltp_mem_in_32, tcx_buf_len ); - + hTcxLtpDec->exp_tcxltp_mem_in = sub( 31, sig_q ); + move16(); /* Output buffer */ sig_out = buf_out + output_frame; Copy32( hTcxLtpDec->tcxltp_mem_out_32, buf_out, output_frame ); + scale_sig32( buf_out, output_frame, sub( hTcxLtpDec->exp_tcxltp_mem_out, sub( 31, sig_q ) ) ); /* TCX-LTP parameters: integer pitch, fractional pitch, gain */ test(); @@ -2015,4 +2019,6 @@ void tcx_ltp_post32( move16(); st->pit_res_max_past = st->pit_res_max; Copy32( sig_out, hTcxLtpDec->tcxltp_mem_out_32, output_frame ); + hTcxLtpDec->exp_tcxltp_mem_out = sub( 31, sig_q ); + move16(); } diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index da0cfec0d..d85ad5481 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1144,6 +1144,10 @@ void tcxltp_dec_init_fx( set16_fx( hTcxLtpDec->tcxltp_mem_out, 0, L_FRAME48k ); set32_fx( hTcxLtpDec->tcxltp_mem_in_32, 0, TCXLTP_MAX_DELAY ); set32_fx( hTcxLtpDec->tcxltp_mem_out_32, 0, L_FRAME48k ); + hTcxLtpDec->exp_tcxltp_mem_in = 0; + move16(); + hTcxLtpDec->exp_tcxltp_mem_out = 0; + move16(); hTcxLtpDec->tcxltp_pitch_int_post_prev = 0; move16(); hTcxLtpDec->tcxltp_pitch_fr_post_prev = 0; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index bcaffed63..42df90a6b 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1536,7 +1536,7 @@ ivas_error ivas_core_dec_fx( test(); IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) || sba_dirac_stereo_flag ) { - ivas_post_proc_fx( hSCE, hCPE, n, synth_32_fx[n], NULL, output_frame, sba_dirac_stereo_flag ); + ivas_post_proc_fx( hSCE, hCPE, n, synth_32_fx[n], NULL, output_frame, sba_dirac_stereo_flag, Q11 ); } /* update OLA buffers - needed for switching to DFT stereo */ diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 1cf15b1d2..1911b3c4d 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -826,7 +826,7 @@ ivas_error ivas_cpe_dec_fx( IF( !st_ivas->sba_dirac_stereo_flag ) { - synchro_synthesis_fx( ivas_total_brate, hCPE, output, output_frame, 0 ); + synchro_synthesis_fx( ivas_total_brate, hCPE, output, output_frame, 0, Q11 ); } test(); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 70a353c7c..709d38169 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1453,6 +1453,7 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } + hCPE->hStereoDft->q_dft = add( Q11, s ); move16(); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index b2fdf5add..97799ebba 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -635,7 +635,7 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, Q11 - 0 ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->oldOut_fx, output_frame, Q11 ); - ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1 ); + ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 ); #ifdef MSAN_FIX Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, 0 - Q11 ); #else @@ -702,7 +702,7 @@ ivas_error ivas_mct_dec_fx( test(); IF( ( st_ivas->sba_dirac_stereo_flag == 0 ) || ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && LT_16( cpe_id, sub( nCPE, 2 ) ) ) ) { - synchro_synthesis_fx( ivas_total_brate, hCPE, output_fx + imult1616( cpe_id, CPE_CHANNELS ), output_frame, 0 ); + synchro_synthesis_fx( ivas_total_brate, hCPE, output_fx + imult1616( cpe_id, CPE_CHANNELS ), output_frame, 0, Q11 ); } } diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index e5f6f4db0..912c94193 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -151,14 +151,14 @@ void ivas_post_proc( } #else void ivas_post_proc_fx( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word16 n, /* i : channel number */ - Word32 synth[], /* i/o: output synthesis signal */ - Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -) + SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word16 n, /* i : channel number */ + Word32 synth[], /* i/o: output synthesis signal */ + Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ + const Word16 output_frame, /* i : output frame length */ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + Word16 output_q ) { Word16 k; Word16 delay_comp; @@ -193,7 +193,7 @@ void ivas_post_proc_fx( IF( NE_16( sts[n]->core, TCX_20_CORE ) && NE_16( sts[n]->core, TCX_10_CORE ) ) { /* TCX-LTP Postfilter: used in Mode 1 to update memories and to avoid discontinuities when the past frame was TCX */ - tcx_ltp_post32( sts[n], hTcxLtpDec, ACELP_CORE, output_frame, 0, synth, NULL ); + tcx_ltp_post32( sts[n], hTcxLtpDec, ACELP_CORE, output_frame, 0, synth, NULL, output_q ); } ELSE { @@ -216,7 +216,7 @@ void ivas_post_proc_fx( Copy32( sts[n]->hHQ_core->oldOut_fx + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); } - tcx_ltp_post32( sts[n], hTcxLtpDec, sts[n]->core, output_frame, add( NS2SA_FX2( output_Fs, ACELP_LOOK_NS ), delay_comp ), synth, sts[n]->hTcxDec->FBTCXdelayBuf_32 ); + tcx_ltp_post32( sts[n], hTcxLtpDec, sts[n]->core, output_frame, add( NS2SA_FX2( output_Fs, ACELP_LOOK_NS ), delay_comp ), synth, sts[n]->hTcxDec->FBTCXdelayBuf_32, output_q ); } } } @@ -253,12 +253,12 @@ void ivas_post_proc_fx( IF( NE_16( sts[0]->core, TCX_20_CORE ) && NE_16( sts[0]->core, TCX_10_CORE ) ) { /* update memories and to avoid discontinuities when the past frame was TCX */ - tcx_ltp_post32( sts[0], hTcxLtpDec, ACELP_CORE, output_frame, 0, output[k], NULL ); + tcx_ltp_post32( sts[0], hTcxLtpDec, ACELP_CORE, output_frame, 0, output[k], NULL, output_q ); } ELSE { /*Use channel 0 side info.*/ - tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k] ); + tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q ); } } } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index faf5711c2..ae190e428 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1342,7 +1342,7 @@ void ivas_sba_dirac_stereo_dec_fx( stereo_dft_dec_synthesize_fx( hCPE, DFT, 1, output[1], output_frame ); } - synchro_synthesis_fx( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); + synchro_synthesis_fx( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/, q_dft[0] ); /* output scaling */ IF( !sba_mono_flag ) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 4caadd0fd..dd44d2091 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -2377,12 +2377,12 @@ void synchro_synthesis( } #else void synchro_synthesis_fx( - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *output_fx[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : Number of samples */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output FOR SBA DirAC */ -) + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *output_fx[CPE_CHANNELS], /* i/o: output synthesis signal */ + const Word16 output_frame, /* i : Number of samples */ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output FOR SBA DirAC */ + Word16 output_fx_q ) { Word16 n, delay_comp_TD, delay_comp_DFT; Word32 output_Fs; @@ -2516,7 +2516,7 @@ void synchro_synthesis_fx( IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { - ivas_post_proc_fx( NULL, hCPE, 0, output_fx[0], output_fx, output_frame, sba_dirac_stereo_flag ); + ivas_post_proc_fx( NULL, hCPE, 0, output_fx[0], output_fx, output_frame, sba_dirac_stereo_flag, output_fx_q ); } /* zero padding in order to synchronize the upmixed DFT stereo synthesis with the TD/MDCT stereo synthesis */ @@ -2850,7 +2850,7 @@ void synchro_synthesis_fx( { Copy32( sts[n]->prev_synth_buffer32_fx + delay_comp_DFT, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, delay_diff ); delay_signal_fx( output_fx[n], output_frame, hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, delay_diff ); - ivas_post_proc_fx( NULL, hCPE, n, output_fx[n], output_fx, output_frame, 0 ); + ivas_post_proc_fx( NULL, hCPE, n, output_fx[n], output_fx, output_frame, 0, output_fx_q ); delay_signal_fx( output_fx[n], output_frame, sts[n]->prev_synth_buffer32_fx, delay_comp_DFT ); Copy32( hCPE->hCoreCoder[n]->hTcxDec->FBTCXdelayBuf_32, sts[n]->prev_synth_buffer32_fx + delay_comp_DFT, delay_diff ); -- GitLab