diff --git a/lib_com/options.h b/lib_com/options.h index 77dd463ca37473e8502ede856974584019952c9d..5ce08d7ec124f75233f22e285fd31313fc7bb998 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -140,6 +140,7 @@ #endif #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ +#define FIX_ISM_DTX_CNG_BWIDTH_ALT /* VA: issue 396 - alternative fix for bw changes on CNG frames in ISM DTX for objects that use the decoder-side noise estimation */ #define FIX_398_MASA_DIRECTION_ALIGNMENT /* Nokia: Issue 398: in 2dir MASA, dynamically adjust directions to be consistent */ #define REND_DEBUGGING_REVISION /* VA: encapsulate rendering debugging options with DEBUGGING */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 65f821e5fb362754de317f4fec5c3618c1aa4c3e..1ac7f5c3bca822f79cd7f9b126301a37c88feaaa 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4500,6 +4500,10 @@ ivas_error acelp_core_dec( 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 */ +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + , + const int16_t read_sid_info /* i : read SID info flag */ +#endif ); void bass_psfilter_init( diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index eb53379d6683c5d05f178ae3f0d2b4aef0dac910..922510efed1201241c70a141cd37e8a5ec512063 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -77,6 +77,10 @@ ivas_error acelp_core_dec( 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 */ +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + , + const int16_t read_sid_info /* i : read SID info flag */ +#endif ) { float old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ @@ -512,7 +516,11 @@ ivas_error acelp_core_dec( } else { +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT ) +#else if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT && st->read_sid_info ) +#endif { FdCng_decodeSID( st ); *sid_bw = 0; @@ -528,8 +536,13 @@ ivas_error acelp_core_dec( } ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } + +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + if ( !read_sid_info ) +#else if ( !st->read_sid_info ) // if (!st->read_sid_info && st->cng_ism_flag) /* read_sid_info can only be 0 in ParamISM mode */ +#endif { float noise_lvl_highest; diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index a2f1f8504c339a5ee4c8c06c612f53b175c1487e..8ea2d71159fd155c3219b3e6ed165ed887d736cb 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 FIX_ISM_DTX_CNG_BWIDTH_ALT + 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 ) +#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/init_dec.c b/lib_dec/init_dec.c index 7deed8ca38354a949090fb923a10cc55adcf7190..20bc7a0b845325f2517e94c9af43d36e0cf7a5c9 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -732,7 +732,9 @@ ivas_error init_decoder( st->cna_dirac_flag = 0; st->cng_sba_flag = 0; st->cng_ism_flag = 0; +#ifndef FIX_ISM_DTX_CNG_BWIDTH_ALT st->read_sid_info = 1; /* by default read the sid info from bitstream */ +#endif st->is_ism_format = 0; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 86442b8261ad28675a43aca615e9042aa463c834..516e027f90db764e863ccec371bbb212e532b0c2 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -90,6 +90,9 @@ ivas_error ivas_core_dec( int16_t use_cldfb_for_dft; float *p_output_mem; int16_t flag_sec_CNA; +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + int16_t read_sid_info; +#endif int16_t last_element_mode; int16_t nchan_out; float *save_hb_synth; @@ -105,6 +108,9 @@ ivas_error ivas_core_dec( use_cldfb_for_dft = 0; tdm_LRTD_flag = -1; +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + read_sid_info = 1; /* read SID by default */ +#endif if ( hSCE != NULL ) { @@ -116,6 +122,15 @@ ivas_error ivas_core_dec( hStereoTD = NULL; p_output_mem = NULL; nchan_out = 1; +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + if ( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) + { + if ( st_ivas->hISMDTX.sce_id_dtx != hSCE->sce_id ) + { + read_sid_info = 0; + } + } +#endif } else { @@ -332,7 +347,11 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + 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 ) +#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; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3f3080c8f8f10a825e15a1168a4bee8acb840e27..58c945b19096f0fde9c387b00bde7a670eb1845e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -864,6 +864,10 @@ ivas_error ivas_init_decoder( st_ivas->hSCE[sce_id]->hCoreCoder[0]->is_ism_format = 1; } +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + st_ivas->hISMDTX.sce_id_dtx = 0; +#endif + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2; diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 4e987c2920ff57cc97cd11f942bb756801ed81df..7eb6c115ea3d7b28c6c3952f0f2b9c8701113c39 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -39,7 +39,7 @@ #endif #include "wmc_auto.h" - +#ifndef FIX_ISM_DTX_CNG_BWIDTH_ALT /*-------------------------------------------------------------------* * ivas_ism_preprocessing() * @@ -74,7 +74,7 @@ static void ivas_ism_preprocessing( return; } - +#endif /*-------------------------------------------------------------------* * ivas_ism_dtx_dec() @@ -93,6 +93,9 @@ ivas_error ivas_ism_dtx_dec( int16_t idx, flag_noisy_speech, sce_id_dtx; ISM_MODE last_ism_mode, ism_mode_bstr; ivas_error error; +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + Decoder_State *st; +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -182,7 +185,14 @@ ivas_error ivas_ism_dtx_dec( { for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + st = st_ivas->hSCE[ch]->hCoreCoder[0]; + st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream; + st->next_bit_pos = 0; /* note: needed in paramISM -> discISM switching */ + st->cng_ism_flag = 1; +#else ivas_ism_preprocessing( st_ivas, ch ); // VE: after the acceptance of switches, replace the function call by its content +#endif } } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index d6bd362ef7ec4927b12188c7168bfd19f35319b7..0135ec06f053f1bd22cf1c284c46ce1d0237fb8e 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -855,7 +855,7 @@ void ivas_ism_metadata_sid_dec( *flag_noisy_speech = 0; *sce_id_dtx = 0; - /* write ISM mode flag to explicitly signal number of spatial parameters */ + /* read ISM mode flag to explicitly signal number of spatial parameters */ if ( nchan_ism > 2 ) { idx = get_next_indice( st0, 1 ); @@ -888,10 +888,12 @@ void ivas_ism_metadata_sid_dec( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence = (float) ( idx ) / (float) ( ( 1 << nBits_coh ) - 1 ); } } +#ifndef FIX_ISM_DTX_CNG_BWIDTH_ALT else { *sce_id_dtx = 0; } +#endif if ( ism_mode == ISM_MODE_PARAM ) { diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ed172f414110d0d9bff9eda0521cd0b2b673ffef..9a940b9b6da17e326145e2d9ba39c49e63931ff1 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -87,14 +87,25 @@ ivas_error ivas_sce_dec( *-----------------------------------------------------------------*/ /* set total_brate - needed in DTX */ - if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_5k2 ) ) + if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { st->total_brate = ivas_total_brate - nb_bits_metadata * FRAMES_PER_SEC; assert( st->total_brate == SID_2k40 && "SCE SID must be 2.4kbps!" ); + +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.sce_id_dtx != sce_id ) + { + st->total_brate = FRAME_NO_DATA; + } +#endif } +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + else if ( !st_ivas->bfi && ivas_total_brate == FRAME_NO_DATA ) +#else else if ( !st_ivas->bfi && ivas_total_brate <= SID_2k40 ) +#endif { - st->total_brate = ivas_total_brate; + st->total_brate = FRAME_NO_DATA; } else if ( !st_ivas->bfi && st_ivas->ivas_format != ISM_FORMAT && last_ivas_total_brate <= IVAS_SID_5k2 ) { @@ -166,11 +177,22 @@ ivas_error ivas_sce_dec( } /* set "total_brate" */ - if ( !st_ivas->bfi && ( ivas_total_brate == IVAS_SID_5k2 ) ) + if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { st->total_brate = ivas_total_brate - nb_bits_metadata * FRAMES_PER_SEC; + +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.sce_id_dtx != sce_id ) + { + st->total_brate = FRAME_NO_DATA; + } +#endif } +#ifdef FIX_ISM_DTX_CNG_BWIDTH_ALT + else if ( !st_ivas->bfi && ivas_total_brate == FRAME_NO_DATA ) +#else else if ( !st_ivas->bfi && ivas_total_brate <= SID_2k40 ) +#endif { st->total_brate = ivas_total_brate; } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 7331693ad72faf4b1862b5066d0cae282af78535..13fed9573b4368d84ebb555c061e07bc69fb8c29 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1345,8 +1345,10 @@ typedef struct Decoder_State /* MCT Channel mode indication: LFE, ignore channel? */ MCT_CHAN_MODE mct_chan_mode; - int16_t cng_ism_flag; /* CNG in Param-ISM flag */ + int16_t cng_ism_flag; /* CNG in ISM format flag */ +#ifndef FIX_ISM_DTX_CNG_BWIDTH_ALT int16_t read_sid_info; /* For ParamISM, use the transmitted noise */ +#endif int16_t is_ism_format; /* Indication whether the codec operates in ISM format */ } Decoder_State, *DEC_CORE_HANDLE;