From b4ddc74dc6ff4a2d32435a1814624cd33f3e1baf Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 21 Oct 2022 11:43:59 +0200 Subject: [PATCH 1/2] activate LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1c21e85d2d..05d7b4b7f2 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -137,7 +137,7 @@ #define LSF_RE_USE_SECONDARY_CHANNEL /* TD stereo Secondary channel LSF Q improvement */ #ifdef LSF_RE_USE_SECONDARY_CHANNEL -/*#define LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE */ /* switch to isolate the reuse mode case */ +#define LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE /* switch to isolate the reuse mode case */ #endif #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ @@ -149,7 +149,7 @@ #define CORECODER_BITRATE_SWITCHING /* Issue 133: support bitrate switching in core-coder */ #define ISM_BITRATE_SWITCHING /* Issue 115: Support for Bitrate Switching in ISM */ #define SBA_SPAR_HARM /* Issue 92: maintenance of the SBA SPAR functions */ -#define FIX_155_HP20_ISSUE /* Issue 155: apply hp20 on all input channels instead of just 2 channels */ +#define FIX_155_HP20_ISSUE /* Issue 155: apply hp20 on all input ParamISM channels instead of just 2 channels */ #define EFAP_FIX_POLY /* Issue 167: fix bug in EFAP polygon selection */ -- GitLab From 875f062d8c5d8a16d35cdc65c51d1203555106ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 21 Oct 2022 11:59:20 +0200 Subject: [PATCH 2/2] resolve compilation warnings --- lib_com/ivas_prot.h | 2 ++ lib_com/ivas_stereo_td_bit_alloc.c | 18 ++++++++++--- lib_com/prot.h | 42 ++++++++++++++---------------- lib_dec/acelp_core_dec.c | 18 +++++++------ lib_dec/evs_dec.c | 4 +++ lib_dec/ivas_core_dec.c | 16 ++++++++++-- lib_enc/acelp_core_enc.c | 8 +++--- lib_enc/evs_enc.c | 4 +++ lib_enc/ivas_core_enc.c | 12 +++++++++ 9 files changed, 85 insertions(+), 39 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8e3558bbad..da873d82ae 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1727,7 +1727,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 LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE 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 */ diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 7d5b0afb55..087933e847 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -430,10 +430,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 LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 */ @@ -441,12 +443,17 @@ void td_stereo_param_updt( ) { int16_t i; +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + float tdm_lspQ_PCh[M]; +#endif /* Copy some primary channel information into the secondary channel structure for later usage */ if ( tdm_use_IAWB_Ave_lpc == 1 ) { mvr2r( IAWB_Ave, tdm_lsfQ_PCh, M ); +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); +#endif } else if ( flag_ACELP16k == 1 ) { @@ -456,7 +463,9 @@ void td_stereo_param_updt( } else { +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); +#endif mvr2r( lsf_old_PCh, tdm_lsfQ_PCh, M ); } @@ -553,6 +562,7 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat( return; } + /*-------------------------------------------------------------------* * tdm_SCh_LSF_intra_pred() * diff --git a/lib_com/prot.h b/lib_com/prot.h index 5bc1e39753..16a1b47632 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2361,8 +2361,10 @@ ivas_error acelp_core_enc( float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ int16_t *unbits, /* o : number of unused bits */ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder 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 */ +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 */ ); ivas_error acelp_core_switch_dec_bfi( @@ -4521,14 +4523,16 @@ 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 */ +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 */ ); void bass_psfilter_init( @@ -6775,8 +6779,7 @@ void getTCXMode( Decoder_State *st, /* i/o: decoder memory state */ Decoder_State *st0 /* i : bitstream */ , - const int16_t MCT_flag -); + const int16_t MCT_flag ); void getTCXWindowing( const int16_t core, /* i : current frame mode */ @@ -7888,10 +7891,8 @@ void decoder_tcx_post( float *synth, float *synthFB, float *A, - const int16_t bfi - , - const int16_t isMCT -); + const int16_t bfi, + const int16_t isMCT ); void coder_acelp( Encoder_State *st, /* i/o: coder memory state */ @@ -8133,8 +8134,7 @@ void con_tcx( int16_t *noise_seed, /* i/o: noise seed for stereo */ const int16_t only_left /* i : TD-PLC only in left channel */ , - const float *A_cng -); + const float *A_cng ); /*! r: codebook index */ int16_t tcxlpc_get_cdk( @@ -9510,10 +9510,8 @@ void TonalMDCTConceal_SaveFreqSignal( const float *mdctSpectrum, const uint16_t numSamples, const uint16_t nNewSamplesCore, - const float *scaleFactors - , - const int16_t infoIGFStartLine -); + const float *scaleFactors, + const int16_t infoIGFStartLine ); void TonalMDCTConceal_UpdateState( TonalMDCTConcealPtr hTonalMDCTConc, diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 4c52cdb811..10960fe54e 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -69,14 +69,16 @@ 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 */ +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 */ ) { float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 299e6a31ce..30f973437c 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -261,7 +261,11 @@ ivas_error evs_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 ) ) != 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 ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index fd5d5b3c1e..e67e9fc925 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -83,7 +83,11 @@ ivas_error ivas_core_dec( int16_t unbits[CPE_CHANNELS]; int16_t sid_bw[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS]; +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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; @@ -186,8 +190,8 @@ ivas_error ivas_core_dec( { float gain; - gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : - ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain : 0.0f; + gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain + : 0.0f; if ( ( st->element_mode == IVAS_CPE_MDCT && hMCT == NULL ) || ( st->hPlcInfo != NULL ) ) { @@ -347,7 +351,11 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng ) ) != IVAS_ERR_OK ) +#else 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, hCPE == NULL ? NULL : hCPE->hStereoCng ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -371,7 +379,11 @@ ivas_error ivas_core_dec( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 857099ed92..17fcb18c08 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -75,8 +75,10 @@ ivas_error acelp_core_enc( float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ int16_t *unbits, /* o : number of unused bits */ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder 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 */ +#ifndef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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 */ ) { int16_t i, nBits; /* reserved bits */ @@ -690,7 +692,7 @@ ivas_error acelp_core_enc( #ifdef DEBUGGING if ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) { - printf( "Issue with unused bits at Ln 653 in acelp_core_enc channel 1 at frame %d\n", frame ); + printf( "Issue with unused bits at Ln 695 in acelp_core_enc channel 1 at frame %d\n", frame ); } #endif } diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index 29b610db79..b07512b452 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -253,7 +253,11 @@ ivas_error evs_enc( if ( st->core == ACELP_CORE ) { +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + if ( ( error = acelp_core_enc( st, inp, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = acelp_core_enc( st, inp, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 3f9cb84b51..a0e3907aba 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -102,7 +102,11 @@ ivas_error ivas_core_enc( int16_t Voicing_flag[CPE_CHANNELS]; float pitch_buf[CPE_CHANNELS][NB_SUBFR16k]; int16_t unbits[CPE_CHANNELS]; +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + float tdm_lsfQ_PCh[M]; +#else float tdm_lspQ_PCh[M], tdm_lsfQ_PCh[M]; +#endif int16_t last_element_mode, tdm_Pitch_reuse_flag; #ifdef CORECODER_BITRATE_SWITCHING int32_t element_brate, last_element_brate, input_Fs; @@ -234,7 +238,11 @@ ivas_error ivas_core_enc( if ( st->core == ACELP_CORE ) { /* ACELP core encoder */ +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + if ( ( error = acelp_core_enc( st, inp[n], ener[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], pitch_buf[n], &unbits[n], hStereoTD, tdm_lsfQ_PCh ) ) != IVAS_ERR_OK ) +#else if ( ( error = acelp_core_enc( st, inp[n], ener[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], vad_hover_flag[0], attack_flag[n], bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], pitch_buf[n], &unbits[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -258,7 +266,11 @@ ivas_error ivas_core_enc( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef LSF_RE_USE_SECONDARY_CHANNEL_REUSEMODE + 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], tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#endif } } -- GitLab