diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index 5880de97d4b9fc4a308049a4f606b60c6b4fc033..f4c7d5b8d77d6e2f25bd404ebd49afec18908d51 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_prot.h b/lib_com/ivas_prot.h index d4991054f0929aebd5d08ee90f00da2b4def8faf..9d2384043c00faae0de4fc20bfb3b190d9ab87f3 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2111,7 +2111,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 */ diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index fd712b5097ba6ce05ca9164c663cbbcc88874110..26d410b2232a4408fc97db4e401367222f3da2f0 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,17 +458,55 @@ 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 +#ifdef FIX_1111_TDM_LSP_BUFFER + if ( tdm_lspQ_PCh != NULL ) + { + lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); + } +#else lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); +#endif +#endif } else if ( flag_ACELP16k == 1 ) { +#ifdef FIX_1111_TDM_LSP_BUFFER +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + if ( tdm_lspQ_PCh != NULL ) + { + mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); + lsp_convert_poly( tdm_lspQ_PCh, L_FRAME, 0 ); + lsp2lsf( tdm_lspQ_PCh, tdm_lsfQ_PCh, M, INT_FS_12k8 ); + } + 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 mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); lsp_convert_poly( tdm_lspQ_PCh, L_FRAME, 0 ); lsp2lsf( tdm_lspQ_PCh, tdm_lsfQ_PCh, M, INT_FS_12k8 ); +#endif } else { +#ifndef NONBE_1325_TD_STEREO_QUANT_LSF_SEC +#ifdef FIX_1111_TDM_LSP_BUFFER + if ( tdm_lspQ_PCh != NULL ) + { + mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); + } +#else mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); +#endif +#endif mvr2r( lsf_old_PCh, tdm_lsfQ_PCh, M ); } diff --git a/lib_com/options.h b/lib_com/options.h index 31f71296348e310beebb3da531ac8b7f550545f7..f137d099e3460b4d53cd3c5e4dae77ea70d54ed8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -189,15 +189,16 @@ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ #define FIX_1052_EXT_OUTPUT /* VA: issue 1052: define EXT decoder output configuration for stereo and MC formats */ - #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ - #define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/ #define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ #define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ #define FIX_1082_INSTRUM_FAILED_LC3PLUS /* VoiceAge: issue 1082: fix ambiguous syntax in LC3Plus code leading to fails of instrumented builds */ #define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */ #define FIX_1222_OMASA_DEC_CHANNEL_BUFFERS /* VA: issue 1222: Reduction of the number of channel buffers in OMASA decoder */ +#define FIX_1111_TDM_LSP_BUFFER /* VA: issue 1111: remove unused buffer `tdm_lspQ_PCh[]' */ +#define NONBE_1325_TD_STEREO_QUANT_LSF_SEC /* Nokia: issue 1325: fix for usage of active_cnt variable in TD stereo LSFQ */ + /* #################### End BASOP porting switches ############################ */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 98c6b8464f7aad36a60e81c97b3c8708951325b6..2ccfbbe683766d615111498392e2881a9599347c 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4504,15 +4504,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( @@ -9066,10 +9068,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 26a0bcff49c76537db982fd61ec733d974ede1fc..8a0cc3c13b40c4ff3f8c45067dbc3423bfac2dd8 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,19 +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 ) { 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 cbd50dd1e48a4c24fbffbe2795d12c1ba56ac8a4..e3bdde2f501749ffbe6cc1729be12a15e392b8d7 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..7d0ca6dac4a26b17e498071b56c0b891b2d283d4 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -293,8 +293,11 @@ ivas_error init_decoder( st->last_vad = 0; 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 86a4ef71ac27132e733647a1c30b597f952033a8..9a63526b93e0bb80f1f61b2d912a514301932702 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 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; @@ -348,7 +352,11 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifdef NONBE_1325_TD_STEREO_QUANT_LSF_SEC + 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, read_sid_info ) ) != 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, read_sid_info ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -372,7 +380,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 97b59b1bad1e8dcb734d4b91c6500e432d81cac9..87c4804022aabba72330fd618c5919c811d9063a 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -375,13 +375,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_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 41a729dce4fd3a06d01e0a4262a5c1d2d0bc04a3..2958cf9205f0800bdfb851b1ca56206c7563d6e6 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 } /*-----------------------------------------------------------------* @@ -415,21 +419,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 ) @@ -494,7 +498,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 } /*---------------------------------------------------------------* @@ -552,7 +560,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 0a54b475cb030a71d45aa4bc96e9cf7f8872324d..1b5f2f86082f8607d932727310bf11757acfddac 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -132,7 +132,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 ef58b618016619f3263a13885ed50c986ecd9eb7..211a76f187e201310ba592e62c529ca05f3d55e6 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -99,7 +99,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 FIX_1111_TDM_LSP_BUFFER + 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; int32_t element_brate, last_element_brate, input_Fs; int16_t diff_nBits; @@ -270,7 +274,15 @@ ivas_error ivas_core_enc( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef FIX_1111_TDM_LSP_BUFFER +#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 +#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 } } 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 } /*-----------------------------------------------------------------*