diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9182dd36282cc0652cc43986fb561b0be255385e..c88725ef0a7c34891cf22d6eaeffdddc1a237dab 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -319,6 +319,7 @@ + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 93a2b1c00c5b944283f3f7778ccbe44a5f1548ff..195d4deb1b9c6d4f5896ac00802e50b4ec695f51 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -501,6 +501,9 @@ common_h + + common_h + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 03bc3d6e5761cb47156dd15f849625fe99545cea..b9f3688ab14146d3209d46be73c88eb3951ff81e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -248,6 +248,9 @@ ivas_error pre_proc_front_ivas_fx( const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ Word16 *Q_new #ifdef DEBUG_MODE_INFO diff --git a/lib_com/options.h b/lib_com/options.h index 7e8d63c30df74c4041bf4e283990a334c244f1f8..ac88ba0fc9218d3e83311f4711df9f639a9f9ea7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -134,4 +134,5 @@ #define FIX_1010_OPT_GIVENS_INV /* FhG: SVD complexity optimizations (non-be) */ #define FIX_1010_OPT_NORM_NOSAT /* FhG: SVD complexity optimizations (non-be) */ #define FIX_1010_OPT_SEC_SINGLE_RESCALE /* FhG: SVD complexity optimizations (non-be) */ +#define NONBE_1211_DTX_BR_SWITCHING /* VA: port float issue 1211: fix crash in MASA DTX bitrate switching */ #endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index fde20ad7a1e679491be388d24f853b734f0ba5cf..17965e99eae9fa29ee8c2ad4db0cdc3347dc25f4 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -64,7 +64,10 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ void dtx_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ @@ -81,13 +84,21 @@ void dtx_ivas_fx( Flag Overflow = 0; move32(); #endif +#ifdef NONBE_1211_DTX_BR_SWITCHING + Word32 total_brate_ref; + + total_brate_ref = st_fx->total_brate; + move32(); +#endif IF( st_fx->dtx_sce_sba != 0 ) { last_br_cng_flag = 1; last_br_flag = 1; +#ifndef NONBE_1211_DTX_BR_SWITCHING br_dtx_flag = 1; move16(); +#endif move16(); move16(); } @@ -102,10 +113,18 @@ void dtx_ivas_fx( test(); test(); test(); + +#ifdef NONBE_1211_DTX_BR_SWITCHING + last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || + ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || + LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ); +#else last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, LP_NOISE_LV * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); br_dtx_flag = 0; move16(); +#endif } + /* Initialization */ IF( st_fx->ini_frame == 0 ) { @@ -199,6 +218,12 @@ void dtx_ivas_fx( /*------------------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX is enabled *------------------------------------------------------------------------*/ + +#ifdef NONBE_1211_DTX_BR_SWITCHING + br_dtx_flag = 1; + move16(); +#endif + IF( st_fx->dtx_sce_sba == 0 ) { test(); @@ -325,6 +350,13 @@ void dtx_ivas_fx( reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); } } +#ifdef NONBE_1211_DTX_BR_SWITCHING + ELSE IF( st_fx->element_mode != EVS_MONO ) + { + st_fx->total_brate = total_brate_ref; + move32(); + } +#endif /*------------------------------------------------------------------------* * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 38651b5be0d7c1c411135d7b8c3aa012aa6f9b32..e9d4c5f1b2579e7c4b471f50c5b084f621fe6be8 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -134,7 +134,10 @@ ivas_error pre_proc_front_ivas_fx( const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ Word16 *Q_new #ifdef DEBUG_MODE_INFO , @@ -1063,7 +1066,12 @@ ivas_error pre_proc_front_ivas_fx( st->cng_type = LP_CNG; move16(); } + +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#else dtx_ivas_fx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); +#endif test(); test(); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e5e3024a8d66d8b628e6b1358bb371716178cd07..852ffec7a704eca7d3d148583902757b89cf8277 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -913,11 +913,16 @@ ivas_error ivas_cpe_enc_fx( { front_vad_flag = 0; } + error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, +#ifdef NONBE_1211_DTX_BR_SWITCHING + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] +#else band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate, &Q_new[n] +#endif #ifdef DEBUG_MODE_INFO , ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index f5da32608b7d490a5bd0ee42c96af4c0bf76f58b..f52bdadb460c4bca9fedea4aab0ca732f65a2455 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -646,7 +646,12 @@ ivas_error front_vad_spar_fx( &hFrontVad->hNoiseEst->totalNoise_fx, Etot_fx[0], &hFrontVad->hNoiseEst->Etot_last_fx, &hFrontVad->hNoiseEst->Etot_v_h2_fx ); corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */ + +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#else dtx_ivas_fx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); +#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 6f8fb2b9f8b544950c3e55e3a7fc7d2c62e4a0bc..507c3e3f395bb8998b3e0d581dbc68ee214d4000 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -241,7 +241,11 @@ ivas_error ivas_ism_enc_fx( error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], +#ifdef NONBE_1211_DTX_BR_SWITCHING + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] +#else fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] +#endif #ifdef DEBUG_MODE_INFO , st->id_element diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index d43ed74385f381091a49b835836edf37ec8461fd..d7aeddbc8e78ebec5761780ff9de7b6d40ac9505 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -254,7 +254,11 @@ ivas_error ivas_sce_enc_fx( &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, +#ifdef NONBE_1211_DTX_BR_SWITCHING + st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] +#else st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] +#endif #ifdef DEBUG_MODE_INFO , st->id_element diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c80b502c46946fd6a77dd830e8c07a41d81d4f34..bc08aae244a8686c9681c6b2e2ed81b54fd4b2de 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -178,7 +178,10 @@ void dtx_fx( ); void dtx_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ + Encoder_State *st_fx, /* i/o: encoder state structure */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ const Word16 vad, /* i : vad flag for DTX Q0*/ const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/