From 399f1cb9da3902029da0c2b9bd40675d04d7a6d3 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Fri, 28 Apr 2023 18:22:57 +0530 Subject: [PATCH 1/4] Fix for issue#368 in SBA --- lib_com/ivas_prot.h | 4 ++++ lib_com/options.h | 2 +- lib_com/prot.h | 4 ++++ lib_enc/amr_wb_enc.c | 4 ++++ lib_enc/dtx.c | 29 +++++++++++++++++++++++++++-- lib_enc/ivas_core_pre_proc_front.c | 10 ++++++++-- lib_enc/ivas_cpe_enc.c | 15 ++++++++++++--- lib_enc/ivas_front_vad.c | 6 ++++-- lib_enc/ivas_ism_enc.c | 7 ++++++- lib_enc/ivas_sce_enc.c | 15 ++++++++++++--- lib_enc/pre_proc.c | 5 ++++- 11 files changed, 86 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 63e80cd8be..dfc53bdc3b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -203,6 +203,10 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef FIX_368_SBA_MODE + , + const int16_t sba_mode_flag +#endif ); ivas_error pre_proc_ivas( diff --git a/lib_com/options.h b/lib_com/options.h index 0a37aa0fe3..f356edfaef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,7 +163,7 @@ #define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ #define FIX_413_SBA_DTX /* Dlb: Fix for issue 413, SBA DTX CNG in 2TC mode*/ #define FIX_417_TD_DECORR_BRATE_SW /* VA: Issue 417: fix incorrect use of TD decorrelator in bitrate switching */ - +#define FIX_368_SBA_MODE /* Issue 368: Fix for the SBA mode*/ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/prot.h b/lib_com/prot.h index c63a8d93de..07c2b7403c 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3866,6 +3866,10 @@ void dtx( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ +#ifdef FIX_368_SBA_MODE + , + const int16_t sba_mode_flag +#endif ); void dtx_hangover_control( diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index c0c0b4f18e..84c17ac784 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -310,7 +310,11 @@ void amr_wb_enc( { st->fd_cng_reset_flag = 0; } +#ifndef FIX_368_SBA_MODE dtx( st, -1, vad_flag_dtx, inp ); +#else + dtx( st, -1, vad_flag_dtx, inp, 0 ); +#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index c99a8faf28..72add60eef 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -65,7 +65,9 @@ #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ #define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ - +#ifdef FIX_368_SBA_MODE +#define MAX_BRATE_DTX_IVAS_SBA IVAS_80k +#endif /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ @@ -83,10 +85,17 @@ void dtx( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ +#ifdef FIX_368_SBA_MODE + , + const int16_t sba_mode_flag +#endif ) { float alpha; - +#ifdef FIX_368_SBA_MODE + int32_t max_brate_dtx_ivas; + max_brate_dtx_ivas = ( sba_mode_flag ) ? MAX_BRATE_DTX_IVAS_SBA : MAX_BRATE_DTX_IVAS; +#endif DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; int16_t last_br_cng_flag, last_br_flag, br_dtx_flag; @@ -98,9 +107,15 @@ void dtx( } else { +#ifdef FIX_368_SBA_MODE + last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= max_brate_dtx_ivas ); + + last_br_flag = st->last_total_brate <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate <= max_brate_dtx_ivas ); +#else last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= MAX_BRATE_DTX_IVAS ); last_br_flag = st->last_total_brate <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate <= MAX_BRATE_DTX_IVAS ); +#endif br_dtx_flag = 0; } @@ -176,9 +191,15 @@ void dtx( if ( st->dtx_sce_sba == 0 ) { +#ifdef FIX_368_SBA_MODE + br_dtx_flag = ( st->element_mode == EVS_MONO && st->total_brate <= max_brate_dtx_ivas ) || + ( st->element_mode != EVS_MONO && ivas_total_brate <= max_brate_dtx_ivas ) || + st->lp_noise < 15; +#else br_dtx_flag = ( st->element_mode == EVS_MONO && st->total_brate <= MAX_BRATE_DTX_EVS ) || ( st->element_mode != EVS_MONO && ivas_total_brate <= MAX_BRATE_DTX_IVAS ) || st->lp_noise < 15; +#endif } if ( st->Opt_DTX_ON && vad == 0 && @@ -238,7 +259,11 @@ void dtx( } else { +#ifdef FIX_368_SBA_MODE + if ( ( st->cng_type == FD_CNG && ( st->total_brate <= MAX_BRATE_DTX_EVS || ( st->element_mode == IVAS_SCE && ivas_total_brate <= max_brate_dtx_ivas ) ) ) || ( st->element_mode == IVAS_CPE_MDCT ) ) /* at highest bitrates, use exclusively LP_CNG */ +#else if ( ( st->cng_type == FD_CNG && ( st->total_brate <= MAX_BRATE_DTX_EVS || ( st->element_mode == IVAS_SCE && ivas_total_brate <= MAX_BRATE_DTX_IVAS ) ) ) || ( st->element_mode == IVAS_CPE_MDCT ) ) /* at highest bitrates, use exclusively LP_CNG */ +#endif { if ( st->element_mode == EVS_MONO && ( st->total_brate == ACELP_9k60 || st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index cf23ddef53..ef664f572f 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -108,6 +108,10 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef FIX_368_SBA_MODE + , + const int16_t sba_mode_flag +#endif ) { @@ -548,9 +552,11 @@ ivas_error pre_proc_front_ivas( { st->cng_type = LP_CNG; } - +#ifdef FIX_368_SBA_MODE + dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8, sba_mode_flag ); +#else dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8 ); - +#endif if ( hCPE != NULL && hCPE->hStereoDft != NULL && st->core_brate == SID_2k40 ) { /* Add another period of expected xcorr updates */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 72a737e64b..2b64756f1c 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -101,7 +101,9 @@ ivas_error ivas_cpe_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; int32_t ivas_total_brate; ivas_error error; - +#ifdef FIX_368_SBA_MODE + int16_t sba_mode_flag; +#endif error = IVAS_ERR_OK; push_wmops( "ivas_cpe_enc" ); @@ -109,7 +111,9 @@ ivas_error ivas_cpe_enc( hCPE = st_ivas->hCPE[cpe_id]; sts = hCPE->hCoreCoder; hEncoderConfig = st_ivas->hEncoderConfig; - +#ifdef FIX_368_SBA_MODE + sba_mode_flag = ( hEncoderConfig->ivas_format == SBA_FORMAT ) ? 1 : 0; +#endif max_bwidth = hEncoderConfig->max_bwidth; ivas_format = hEncoderConfig->ivas_format; input_Fs = hEncoderConfig->input_Fs; @@ -438,7 +442,12 @@ ivas_error ivas_cpe_enc( &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate ); + ivas_total_brate +#ifdef FIX_368_SBA_MODE + , + sba_mode_flag +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index be476b1244..8d2bf126b9 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -430,9 +430,11 @@ ivas_error front_vad_spar( noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 ); corr_shift = correlation_shift( hFrontVad->hNoiseEst->totalNoise ); - +#ifdef FIX_368_SBA_MODE + dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8, 1 ); +#else dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); - +#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; alw_pitch_lag_12k8[1] = st->old_pitch_la; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 4a56252be8..e8fd1b10b8 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -162,7 +162,12 @@ ivas_error ivas_ism_enc( &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate ); + st_ivas->hEncoderConfig->ivas_total_brate +#ifdef FIX_368_SBA_MODE + , + 0 +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index c8577a85ba..6ae3fdca13 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -89,7 +89,9 @@ ivas_error ivas_sce_enc( IVAS_FORMAT ivas_format; ivas_error error; int16_t flag_16k_smc; - +#ifdef FIX_368_SBA_MODE + int16_t sba_mode_flag; +#endif push_wmops( "ivas_sce_enc" ); error = IVAS_ERR_OK; @@ -97,7 +99,9 @@ ivas_error ivas_sce_enc( hSCE = st_ivas->hSCE[sce_id]; st = hSCE->hCoreCoder[0]; ivas_format = st_ivas->hEncoderConfig->ivas_format; - +#ifdef FIX_368_SBA_MODE + sba_mode_flag = ( ivas_format == SBA_FORMAT ) ? 1 : 0; +#endif /*------------------------------------------------------------------* * Initialization - general *-----------------------------------------------------------------*/ @@ -185,7 +189,12 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, 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, - st_ivas->hEncoderConfig->ivas_total_brate ); + st_ivas->hEncoderConfig->ivas_total_brate +#ifdef FIX_368_SBA_MODE + , + sba_mode_flag +#endif + ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 4c4bf68674..e07f8cbb43 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -253,8 +253,11 @@ void pre_proc( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ +#ifdef FIX_368_SBA_MODE + dtx( st, -1, vad_flag_dtx, inp_12k8, 0 ); +#else dtx( st, -1, vad_flag_dtx, inp_12k8 ); - +#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ -- GitLab From e41c3fb167d3411263e3802b84a5c0d33bc44d08 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Tue, 2 May 2023 12:39:01 +0530 Subject: [PATCH 2/4] Instrumentation build error fix --- lib_enc/dtx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 72add60eef..7f470f78ac 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -94,10 +94,12 @@ void dtx( float alpha; #ifdef FIX_368_SBA_MODE int32_t max_brate_dtx_ivas; + DTX_ENC_HANDLE hDtxEnc; max_brate_dtx_ivas = ( sba_mode_flag ) ? MAX_BRATE_DTX_IVAS_SBA : MAX_BRATE_DTX_IVAS; -#endif + hDtxEnc = st->hDtxEnc; +#else DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; - +#endif int16_t last_br_cng_flag, last_br_flag, br_dtx_flag; if ( st->dtx_sce_sba != 0 ) { -- GitLab From f71d1e640ae93d7cfece199743d79537062f6d58 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 8 May 2023 10:47:11 +0530 Subject: [PATCH 3/4] Made the fix generic --- lib_com/ivas_prot.h | 4 ---- lib_com/options.h | 2 +- lib_com/prot.h | 4 ---- lib_enc/amr_wb_enc.c | 4 ---- lib_enc/dtx.c | 33 +++--------------------------- lib_enc/ivas_core_pre_proc_front.c | 10 ++------- lib_enc/ivas_cpe_enc.c | 14 ++----------- lib_enc/ivas_front_vad.c | 4 ---- lib_enc/ivas_ism_enc.c | 7 +------ lib_enc/ivas_sce_enc.c | 15 +++----------- lib_enc/pre_proc.c | 4 ---- 11 files changed, 12 insertions(+), 89 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 213d1f185b..297db65f78 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -203,10 +203,6 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#ifdef FIX_368_SBA_MODE - , - const int16_t sba_mode_flag -#endif ); ivas_error pre_proc_ivas( diff --git a/lib_com/options.h b/lib_com/options.h index 0014d7d91f..79d22daa91 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,7 +164,7 @@ #define FIX_SP2A /* VA: Issue 412: Adjust threshold for the S_p2a feature in the tonal detector */ #define FIX_413_SBA_DTX /* Dlb: Fix for issue 413, SBA DTX CNG in 2TC mode*/ #define FIX_417_TD_DECORR_BRATE_SW /* VA: Issue 417: fix incorrect use of TD decorrelator in bitrate switching */ -#define FIX_368_SBA_MODE /* Issue 368: Fix for the SBA mode*/ +#define FIX_368_SBA_MODE /* Dlb: Fix for issue 368 */ #define LBR_SBA /* Contribution 47: Master macro for low bitrate SBA (SPAR+DirAC) */ #ifdef LBR_SBA diff --git a/lib_com/prot.h b/lib_com/prot.h index 07c2b7403c..c63a8d93de 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3866,10 +3866,6 @@ void dtx( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ -#ifdef FIX_368_SBA_MODE - , - const int16_t sba_mode_flag -#endif ); void dtx_hangover_control( diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index 84c17ac784..c0c0b4f18e 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -310,11 +310,7 @@ void amr_wb_enc( { st->fd_cng_reset_flag = 0; } -#ifndef FIX_368_SBA_MODE dtx( st, -1, vad_flag_dtx, inp ); -#else - dtx( st, -1, vad_flag_dtx, inp, 0 ); -#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 7f470f78ac..c4d1693dfc 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -64,9 +64,10 @@ #define LTE_VAR -4.0f #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ +#ifndef FIX_368_SBA_MODE #define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ -#ifdef FIX_368_SBA_MODE -#define MAX_BRATE_DTX_IVAS_SBA IVAS_80k +#else +#define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ #endif /*-------------------------------------------------------------------* * Local function prototypes @@ -85,21 +86,10 @@ void dtx( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ -#ifdef FIX_368_SBA_MODE - , - const int16_t sba_mode_flag -#endif ) { float alpha; -#ifdef FIX_368_SBA_MODE - int32_t max_brate_dtx_ivas; - DTX_ENC_HANDLE hDtxEnc; - max_brate_dtx_ivas = ( sba_mode_flag ) ? MAX_BRATE_DTX_IVAS_SBA : MAX_BRATE_DTX_IVAS; - hDtxEnc = st->hDtxEnc; -#else DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; -#endif int16_t last_br_cng_flag, last_br_flag, br_dtx_flag; if ( st->dtx_sce_sba != 0 ) { @@ -109,15 +99,8 @@ void dtx( } else { -#ifdef FIX_368_SBA_MODE - last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= max_brate_dtx_ivas ); - - last_br_flag = st->last_total_brate <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate <= max_brate_dtx_ivas ); -#else last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= MAX_BRATE_DTX_IVAS ); - last_br_flag = st->last_total_brate <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate <= MAX_BRATE_DTX_IVAS ); -#endif br_dtx_flag = 0; } @@ -193,15 +176,9 @@ void dtx( if ( st->dtx_sce_sba == 0 ) { -#ifdef FIX_368_SBA_MODE - br_dtx_flag = ( st->element_mode == EVS_MONO && st->total_brate <= max_brate_dtx_ivas ) || - ( st->element_mode != EVS_MONO && ivas_total_brate <= max_brate_dtx_ivas ) || - st->lp_noise < 15; -#else br_dtx_flag = ( st->element_mode == EVS_MONO && st->total_brate <= MAX_BRATE_DTX_EVS ) || ( st->element_mode != EVS_MONO && ivas_total_brate <= MAX_BRATE_DTX_IVAS ) || st->lp_noise < 15; -#endif } if ( st->Opt_DTX_ON && vad == 0 && @@ -261,11 +238,7 @@ void dtx( } else { -#ifdef FIX_368_SBA_MODE - if ( ( st->cng_type == FD_CNG && ( st->total_brate <= MAX_BRATE_DTX_EVS || ( st->element_mode == IVAS_SCE && ivas_total_brate <= max_brate_dtx_ivas ) ) ) || ( st->element_mode == IVAS_CPE_MDCT ) ) /* at highest bitrates, use exclusively LP_CNG */ -#else if ( ( st->cng_type == FD_CNG && ( st->total_brate <= MAX_BRATE_DTX_EVS || ( st->element_mode == IVAS_SCE && ivas_total_brate <= MAX_BRATE_DTX_IVAS ) ) ) || ( st->element_mode == IVAS_CPE_MDCT ) ) /* at highest bitrates, use exclusively LP_CNG */ -#endif { if ( st->element_mode == EVS_MONO && ( st->total_brate == ACELP_9k60 || st->total_brate == ACELP_16k40 || st->total_brate == ACELP_24k40 ) ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index ef664f572f..cf23ddef53 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -108,10 +108,6 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#ifdef FIX_368_SBA_MODE - , - const int16_t sba_mode_flag -#endif ) { @@ -552,11 +548,9 @@ ivas_error pre_proc_front_ivas( { st->cng_type = LP_CNG; } -#ifdef FIX_368_SBA_MODE - dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8, sba_mode_flag ); -#else + dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8 ); -#endif + if ( hCPE != NULL && hCPE->hStereoDft != NULL && st->core_brate == SID_2k40 ) { /* Add another period of expected xcorr updates */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 2b64756f1c..b60f8be45b 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -101,9 +101,7 @@ ivas_error ivas_cpe_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; int32_t ivas_total_brate; ivas_error error; -#ifdef FIX_368_SBA_MODE - int16_t sba_mode_flag; -#endif + error = IVAS_ERR_OK; push_wmops( "ivas_cpe_enc" ); @@ -111,9 +109,6 @@ ivas_error ivas_cpe_enc( hCPE = st_ivas->hCPE[cpe_id]; sts = hCPE->hCoreCoder; hEncoderConfig = st_ivas->hEncoderConfig; -#ifdef FIX_368_SBA_MODE - sba_mode_flag = ( hEncoderConfig->ivas_format == SBA_FORMAT ) ? 1 : 0; -#endif max_bwidth = hEncoderConfig->max_bwidth; ivas_format = hEncoderConfig->ivas_format; input_Fs = hEncoderConfig->input_Fs; @@ -442,12 +437,7 @@ ivas_error ivas_cpe_enc( &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate -#ifdef FIX_368_SBA_MODE - , - sba_mode_flag -#endif - ); + ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 8d2bf126b9..3810df1de9 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -430,11 +430,7 @@ ivas_error front_vad_spar( noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 ); corr_shift = correlation_shift( hFrontVad->hNoiseEst->totalNoise ); -#ifdef FIX_368_SBA_MODE - dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8, 1 ); -#else dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); -#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; alw_pitch_lag_12k8[1] = st->old_pitch_la; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index e8fd1b10b8..4a56252be8 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -162,12 +162,7 @@ ivas_error ivas_ism_enc( &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate -#ifdef FIX_368_SBA_MODE - , - 0 -#endif - ); + st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 6ae3fdca13..c8577a85ba 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -89,9 +89,7 @@ ivas_error ivas_sce_enc( IVAS_FORMAT ivas_format; ivas_error error; int16_t flag_16k_smc; -#ifdef FIX_368_SBA_MODE - int16_t sba_mode_flag; -#endif + push_wmops( "ivas_sce_enc" ); error = IVAS_ERR_OK; @@ -99,9 +97,7 @@ ivas_error ivas_sce_enc( hSCE = st_ivas->hSCE[sce_id]; st = hSCE->hCoreCoder[0]; ivas_format = st_ivas->hEncoderConfig->ivas_format; -#ifdef FIX_368_SBA_MODE - sba_mode_flag = ( ivas_format == SBA_FORMAT ) ? 1 : 0; -#endif + /*------------------------------------------------------------------* * Initialization - general *-----------------------------------------------------------------*/ @@ -189,12 +185,7 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, 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, - st_ivas->hEncoderConfig->ivas_total_brate -#ifdef FIX_368_SBA_MODE - , - sba_mode_flag -#endif - ); + st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index e07f8cbb43..82436a7dfc 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -253,11 +253,7 @@ void pre_proc( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ -#ifdef FIX_368_SBA_MODE - dtx( st, -1, vad_flag_dtx, inp_12k8, 0 ); -#else dtx( st, -1, vad_flag_dtx, inp_12k8 ); -#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ -- GitLab From e00e7de3bdfb52a3e8d1c11ab648f35f0f344347 Mon Sep 17 00:00:00 2001 From: Vidhya V P <100825@ittiam.com> Date: Mon, 8 May 2023 10:57:08 +0530 Subject: [PATCH 4/4] Clang formatting --- lib_enc/dtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index c4d1693dfc..b414347dcb 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -63,11 +63,11 @@ #define LTE_VAR -4.0f -#define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ +#define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ #ifndef FIX_368_SBA_MODE -#define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ +#define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ #else -#define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ +#define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ #endif /*-------------------------------------------------------------------* * Local function prototypes -- GitLab