diff --git a/lib_com/options.h b/lib_com/options.h index b124f8bc1c36a4bdb2ece1f1202391d91436d725..1bd5013abdd7ac97168a74424aa2257fb59d7667 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,8 @@ #define HARMONIZE_2446_CON_TCX_FX /* FhG: basop issue: 2446 harmonization of function con_tcx_fx() */ #define FIX_BASOP_2478_HARM_ENC_PRM_HM /* FhG: basop issue 2478: harmonize enc_prm_hm() and enc_prm_hm_ivas_fx() */ #define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ +#define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ +#define FIX_2455_HARMONIZE_configureFdCngEnc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fb70f1932f97b5ca5cb33be9874cf4429d9f2d7d..00c0cd9ab79f16f2f2dbaff94b4d1fd9a26558dd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10051,11 +10051,13 @@ void core_coder_mode_switch_ivas_fx( const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ ); +#ifndef FIX_2455_HARMONIZE_configureFdCngEnc void configureFdCngEnc_ivas_fx( HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ const Word16 bwidth, /* Q0 */ const Word32 total_brate /* Q0 */ ); +#endif void SetModeIndex_ivas_fx( Encoder_State *st, /* i : Encoder state */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 2df22bdc8b97a6e1bc2d4f2e6bececc80e06423e..45c285ead4d88db272373fba0c1a07eaa160ce2f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -366,8 +366,11 @@ ivas_error acelp_core_enc_fx( st->hDtxEnc->last_CNG_L_frame = st->L_frame; move16(); } - +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc + generate_comfort_noise_enc_fx( st, Q_new, 1, st->element_mode ); +#else generate_comfort_noise_enc_fx( st, Q_new, 1 ); +#endif FdCng_exc( st->hFdCngEnc->hFdCngCom, &st->hDtxEnc->CNG_mode, st->L_frame, st->lsp_old_fx, st->hDtxEnc->first_CNG, st->hDtxEnc->lspCNG_fx, Aq, lsp_new, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -423,7 +426,11 @@ ivas_error acelp_core_enc_fx( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp = sub( st->hFdCngEnc->hFdCngCom->cngNoiseLevelExp, Q_cngNoise ); move16(); +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc + generate_comfort_noise_enc_fx( st, Q_new, 1, st->element_mode ); +#else generate_comfort_noise_enc_ivas_fx( st, Q_new, 1 ); +#endif st->hTcxEnc->q_Txnq = Q_new; move16(); diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c index 44108f56c4753f1e3951837d82f1b9f62414dd60..7814aadba1aa76947e59faafbdbd1500ddb61748 100644 --- a/lib_enc/enc_acelp_tcx_main_fx.c +++ b/lib_enc/enc_acelp_tcx_main_fx.c @@ -92,7 +92,11 @@ void enc_acelp_tcx_main_fx( } /* Generate Comfort Noise */ +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc + generate_comfort_noise_enc_fx( st, *Q_new, 1, EVS_MONO ); +#else generate_comfort_noise_enc_fx( st, *Q_new, 1 ); +#endif /* Update Core Encoder */ core_encode_update_cng_fx( st, st->hFdCngEnc->hFdCngCom->timeDomainBuffer, st->hFdCngEnc->hFdCngCom->A_cng, Aw, *Q_new, *shift ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index b7fed0e62684243fb91a202b3d81b981395320db..2dbb0ac905b5333b806c01d8afb6018dc9e480f5 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -159,11 +159,20 @@ void initFdCngEnc_fx( * Configure FD_CNG * ************************************/ +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc +void configureFdCngEnc_fx( + HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bandwidth, /* i : bandwidth Q0 */ + const Word32 bitrate, /* i : bitrate Q0 */ + const Word16 element_mode /* i : element mode Q0 */ +) +#else void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ const Word16 bandwidth, /* i : bandwidth Q0*/ const Word32 bitrate /* Q0 */ ) +#endif { HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom; Word16 psizeDec[NPART]; @@ -265,12 +274,28 @@ void configureFdCngEnc_fx( SWITCH( hsCom->fftlen ) { case 512: +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + if ( GT_16( element_mode, EVS_MONO ) ) + { + hsCom->fftSineTab_fx = NULL; + hsCom->olapWinAna_fx = olapWinAna512_fx; /* Q30 */ + hsCom->olapWinSyn_fx = olapWinSyn256_fx; /* Q15 */ + } +#endif hsCom->fftlenShift = 8; move16(); hsCom->fftlenFac = 32767 /*1.0 Q15*/; move16(); BREAK; case 640: +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + if ( GT_16( element_mode, EVS_MONO ) ) + { + hsCom->fftSineTab_fx = fftSineTab640_fx; /* Q15 */ + hsCom->olapWinAna_fx = olapWinAna640_fx; /* Q30 */ + hsCom->olapWinSyn_fx = olapWinSyn320_fx; /* Q15 */ + } +#endif hsCom->fftlenShift = 9; move16(); hsCom->fftlenFac = 20480 /*0.625 Q15*/; @@ -288,6 +313,7 @@ void configureFdCngEnc_fx( return; } +#ifndef FIX_2455_HARMONIZE_configureFdCngEnc void configureFdCngEnc_ivas_fx( HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ const Word16 bwidth, /* Q0 */ @@ -422,7 +448,7 @@ void configureFdCngEnc_ivas_fx( return; } - +#endif /*FIX_2455_HARMONIZE_configureFdCngEnc*/ /************************************** * Delete the instance of type FD_CNG * @@ -1268,7 +1294,7 @@ void FdCng_encodeSID_fx( return; } - +#ifndef FIX_2455_HARMONIZE_generate_comfort_noise_enc void generate_comfort_noise_enc_fx( Encoder_State *stcod, Word16 Q_new, @@ -1651,12 +1677,20 @@ void generate_comfort_noise_enc_fx( return; } +#endif - +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc +void generate_comfort_noise_enc_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc, + Word16 element_mode ) +#else void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, Word16 Q_new, Word16 gen_exc ) +#endif { Word16 i, s, sn, cnt; Word16 startBand2; @@ -1779,9 +1813,23 @@ void generate_comfort_noise_enc_ivas_fx( } /* Perform STFT synthesis */ +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc + IF( EQ_16( element_mode, EVS_MONO ) ) + { + SynthesisSTFT( fftBuffer, fftBufferExp, timeDomainOutput, st->olapBufferSynth, st->olapWinSyn, + tcx_transition, st, gen_exc, &Q_new, -1, -1 ); + } + ELSE + { + SynthesisSTFT_enc_ivas_fx( fftBuffer, fftBufferExp, timeDomainOutput, st->olapBufferSynth, st->olapWinSyn, + tcx_transition, st, gen_exc, &Q_new, -1, -1 ); + } + IF( ( ( hTdCngEnc != NULL ) && ( NE_16( element_mode, EVS_MONO ) ) ) || EQ_16( element_mode, EVS_MONO ) ) +#else SynthesisSTFT_enc_ivas_fx( fftBuffer, fftBufferExp, timeDomainOutput, st->olapBufferSynth, st->olapWinSyn, tcx_transition, st, gen_exc, &Q_new, -1, -1 ); IF( hTdCngEnc != NULL ) +#endif { Word32 Lener, att; Word16 exp; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index f042b4a10c8bb0da3a7bd9dc934dec3b7acb70e8..2e96187c8d79582b2303ba5f8b4636f03875ca5d 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1177,8 +1177,11 @@ ivas_error init_encoder_fx( total_brate = st->total_brate; move32(); } - +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate, st->element_mode ); +#else configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); +#endif } } ELSE diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 21a9da678693a19fa867ec8c4902cc450f0d757d..2308d8d65a42ab221759ae6eaed9ce8b45b9b236 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -567,6 +567,16 @@ ivas_error ivas_core_enc_fx( test(); IF( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->bwidth ) ) ) { +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + configureFdCngEnc_fx( st->hFdCngEnc, s_max( st->bwidth, WB ), ACELP_16k40, st->element_mode ); + } + ELSE + { + configureFdCngEnc_fx( st->hFdCngEnc, s_max( st->bwidth, WB ), ACELP_9k60, st->element_mode ); + } +#else IF( EQ_16( st->L_frame, L_FRAME16k ) ) { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->bwidth, WB ), ACELP_16k40 ); @@ -575,6 +585,7 @@ ivas_error ivas_core_enc_fx( { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->bwidth, WB ), ACELP_9k60 ); } +#endif } } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index cfcf16338e628f5781741d069bad8c775f84b315..0afc640bf681832230e6ff606ff0457f5b1778fd 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -930,8 +930,11 @@ void pre_proc_front_ivas_fx( { total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */ } - +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + configureFdCngEnc_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate, element_mode ); +#else configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate ); +#endif IF( hCPE != NULL ) { diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index fce2b3e92038ddade3188f3225051906021a097d..de8970d09506e6f3971b75e7bd8a2a0c61278029 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -178,7 +178,11 @@ void pre_proc_ivas_fx( test(); IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) { +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + configureFdCngEnc_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp, st->element_mode ); +#else configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp ); +#endif } if ( st->ini_frame == 0 ) diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 573edd197dee70778997c035f9de0d4f00bc25fe..7ab3c8fbbad0b3fddc751d5561496a36d29ffb49 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -608,7 +608,11 @@ ivas_error stereo_memory_enc_fx( } initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, st->rf_mode && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate, hCPE->element_mode ); +#else configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, st->rf_mode && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate ); +#endif } } } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 1ffbd25612cb467a29b4ee789a45cf3a76004d43..0f0cbddff753561aad9058477f52d0017dab48f3 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -346,7 +346,11 @@ void pre_proc_fx( L_tmp = ACELP_9k60; move32(); } +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc + configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, L_tmp, 0 /*EVS_MONO*/ ); +#else configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, L_tmp ); +#endif } test(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a1dba490eaefadbb1f4b8257668b84d1a13694c6..2b644e164ca480079fc9be8cefe98fb22dfa0e4c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1532,11 +1532,20 @@ void FdCng_encodeSID_fx( Word16 preemph_fac /* i : preemphase factor */ ); +#ifdef FIX_2455_HARMONIZE_generate_comfort_noise_enc +/* Generate the comfort noise based on the target noise level */ +void generate_comfort_noise_enc_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc, + Word16 element_mode ); +#else /* Generate the comfort noise based on the target noise level */ void generate_comfort_noise_enc_fx( Encoder_State *stcod, Word16 Q_new, Word16 gen_exc ); +#endif Word16 cng_energy_fx( const Word16 element_mode, /* i : element mode Q0*/ @@ -1642,11 +1651,20 @@ void initFdCngEnc_fx( const Word32 input_Fs, /* Q0 */ const Word16 scale ); +#ifdef FIX_2455_HARMONIZE_configureFdCngEnc +void configureFdCngEnc_fx( + HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bandwidth, /* i : bandwidth Q0 */ + const Word32 bitrate, /* i : bitrate Q0 */ + const Word16 element_mode /* i : element mode Q0 */ +); +#else void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */ const Word16 bandwidth, /* i : bandwidth Q0*/ const Word32 bitrate /* Q0 */ ); +#endif /* Perform noise estimation */ void perform_noise_estimation_enc_fx( @@ -4040,10 +4058,12 @@ Word16 cng_energy_ivas_fx( const Word16 Q_new /* i : Input scaling */ ); +#ifndef FIX_2455_HARMONIZE_generate_comfort_noise_enc void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, Word16 Q_new, Word16 gen_exc ); +#endif void SynthesisSTFT_enc_ivas_fx( Word32 *fftBuffer, /* i : pointer to FFT bins */