diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c796afaecc35ae1ada1f924ecb37078712e77c9f..594d00ee305a8d0908dc235ac0a1e6f5ebc0045b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -199,6 +199,9 @@ 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 IVAS_FORMAT ivas_format, /* i : IVAS format */ +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 524aef7aa85dc1547664979397d0c3ad3bad663b..a4eab8337dfab758df194f76df78ba08daffccdf 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -159,6 +159,8 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ + +#define NONBE_FIX_788_SBA_DTX_BR_SWITCHING /* VA: issue 787: fix Msan error in SBA BR switching with dtx in FOA encoding */ #define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #define NONBE_FIX_874_OMASA_BRSW_2TD /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/ diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c old mode 100644 new mode 100755 index b813a2730d27e98a7a7ce18af5cfa917880845c2..5833ee4ca6a19d88a568cba352d5611551e1715a --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -100,6 +100,9 @@ ivas_error init_encoder( st->low_rate_mode = 0; st->ini_frame = 0; st->inactive_coder_type_flag = 0; +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + st->sba_br_sw_while_no_data = 0; +#endif st->coder_type_raw = VOICED; st->last_coder_type_raw = st->coder_type_raw; diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 63b103086e5510542cf80c359f5b284c95af837e..59a1c769fea908653676ff4af07323828b1ae8ec 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -283,7 +283,12 @@ ivas_error pre_proc_ivas( } else if ( element_brate != last_element_brate ) { - SetModeIndex( st, st->bits_frame_nominal * FRAMES_PER_SEC, element_mode, MCT_flag ); +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + if ( st->core_brate != FRAME_NO_DATA ) +#endif + { + SetModeIndex( st, st->bits_frame_nominal * FRAMES_PER_SEC, element_mode, MCT_flag ); + } if ( st->extl != -1 && st->extl != IGF_BWE && st->igf == 1 ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index f643a3a54063fbad2cb3325b14f09f2bd985304c..65e1b4ddbaed4a8e91d68ed787a8e6e34d4dea61 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -108,7 +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 IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ +#endif + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ @@ -183,7 +186,11 @@ ivas_error pre_proc_front_ivas( st = hSCE->hCoreCoder[n]; signal_in = hSCE->hCoreCoder[n]->input; element_mode = IVAS_SCE; +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + last_element_brate = hSCE->last_element_brate; +#else last_element_brate = hSCE->element_brate; /* hack - the past parameter is not really needed */ +#endif hStereoClassif = NULL; lr_vad_enabled = 0; } @@ -780,6 +787,18 @@ ivas_error pre_proc_front_ivas( /* SNR-based speech/music classification */ if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= SCE_SMC_THR ) ) { +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + if ( ivas_format == SBA_FORMAT && st->core_brate != FRAME_NO_DATA && st->last_core_brate == FRAME_NO_DATA && st->sba_br_sw_while_no_data ) + { + SetModeIndex( st, st->bits_frame_nominal * FRAMES_PER_SEC, element_mode, MCT_flag ); + st->sba_br_sw_while_no_data = 0; + } + else if ( ivas_format == SBA_FORMAT && st->core_brate == FRAME_NO_DATA && element_brate != last_element_brate ) + { + st->sba_br_sw_while_no_data = 1; + } +#endif + if ( flag_16k_smc ) { /* Compute core-coder buffers at internal sampling rate */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index fc810042699ec3c9ed71de402695342e9b352a04..88d3b0b5bb157a2b8fb5cdabcb90db133e34a865 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -478,7 +478,11 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &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], +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + 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_format, st_ivas->hMCT != NULL, ivas_total_brate ); +#else 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_format, ivas_total_brate ); +#endif if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index a2289f3042f622b43695485282b03870cb60d16c..0c0e64d666c7ec6956fcdbf35d6a773d146d8317 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -175,7 +175,11 @@ ivas_error ivas_ism_enc( error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &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], +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + 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, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate ); +#else 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, ISM_FORMAT, st_ivas->hEncoderConfig->ivas_total_brate ); +#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 6f6aff95723ddc5e42396c7102a28ff11153cf68..b0184220ad4ed1cc87116d25a3d416acdc86ccb4 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -184,7 +184,11 @@ ivas_error ivas_sce_enc( &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &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, +#ifdef NONBE_FIX_788_SBA_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->ivas_total_brate ); +#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, st_ivas->hEncoderConfig->ivas_total_brate ); +#endif if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h old mode 100644 new mode 100755 index 9a1dd271359317017ca5defc198217e5f9de6673..b4dda7da7832e713b18731d977d586e065fb9d3b --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1556,6 +1556,10 @@ typedef struct enc_core_structure int16_t dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ +#ifdef NONBE_FIX_788_SBA_DTX_BR_SWITCHING + int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ +#endif + } Encoder_State, *ENC_CORE_HANDLE;