diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c index e2f617a62a9f4d972d44dadfe4c6934a5d42402f..969dbfea61b16208802093e649ab90cb7f7bb4f6 100644 --- a/lib_com/core_com_config_fx.c +++ b/lib_com/core_com_config_fx.c @@ -825,7 +825,11 @@ Word16 getTcxLpcShapedAri( * Initialization of TCX *-----------------------------------------------------------------------*/ +#ifdef HARMONIZE_2567_init_functions +void init_tcx_cfg_fx( +#else void init_tcx_cfg_ivas_fx( +#endif TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ const Word32 sr_core, /*Q0*/ @@ -841,7 +845,12 @@ void init_tcx_cfg_ivas_fx( const Word16 infoIGFStopFreq, /*Q0*/ const Word16 element_mode, /*Q0*/ const Word16 ini_frame, /*Q0*/ +#ifdef HARMONIZE_2567_init_functions + const Word16 MCT_flag, /*Q0*/ + const Word16 fscaleFB /*Q0*/ ) +#else const Word16 MCT_flag /*Q0*/ ) +#endif { Word16 i; Word16 mdctWindowLength; @@ -859,7 +868,18 @@ void init_tcx_cfg_ivas_fx( hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/ +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( element_mode, EVS_MONO ) ) + { + mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ + } + ELSE + { + mdctWindowLengthFB = (Word16) ( mdctWindowLength * input_Fs / sr_core ); + } +#else mdctWindowLengthFB = (Word16) ( mdctWindowLength * input_Fs / sr_core ); +#endif init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ @@ -1080,6 +1100,7 @@ void init_tcx_window_cfg_fx( return; } +#ifndef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ @@ -1227,3 +1248,4 @@ void init_tcx_cfg_fx( return; } +#endif diff --git a/lib_com/options.h b/lib_com/options.h index 1e23c1a8b6684ab81fb60985c5576568b08c061d..aca5469612ecdbc1f1981e32d5006ee3af968739 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,8 @@ #define FIX_1585_ASAN_FORMAT_SW_ALT /* VA,FhG: float issues 1585,1593: alternative fix memory leaks with format switching */ #define FIX_BASOP_2573_RF_MODE_UPDATE /* FhG: BASOP issue 2573: remove duplicated update of rf_mode parameters from evs_enc_fx(); was already done in updt_enc_common_fx() */ +#define HARMONIZE_2567_init_functions /* FhG: harmonize derivates for evs/ivas regarding functions init_acelp*(),init_tcx_cfg*(), init_tcx*(), init_coder_ace_plus*(), init_core_sig_ana*() and init_modes*() */ + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7d541d076f4dd6b8b77823483077bf91514954b8..cb2aa343a0177b1e1d7f93dabdf18563f254e22a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5758,6 +5758,7 @@ void init_tcx_window_cfg_fx( const Word16 element_mode /* i : mode of CPE/SCE */ ); +#ifndef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, @@ -5776,6 +5777,7 @@ void init_tcx_cfg_fx( const Word16 ini_frame, const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, const Word16 fscaleFB ); +#endif void syn_output_fx( const Word16 codec_mode, /* i : MODE1 or MODE2 */ @@ -9585,11 +9587,20 @@ void writeTCXparam_fx( const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); +#ifdef HARMONIZE_2567_init_functions +void init_coder_ace_plus_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 shift, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#else void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ - const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#endif ); void core_coder_reconfig_ivas_fx( @@ -9610,23 +9621,32 @@ void SetModeIndex_ivas_fx( const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ ); +#ifdef HARMONIZE_2567_init_functions +void init_tcx_cfg_fx( +#else void init_tcx_cfg_ivas_fx( +#endif TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag ); + const Word32 total_brate, /*Q0*/ + const Word32 sr_core, /*Q0*/ + const Word32 input_Fs, /*Q0*/ + const Word16 L_frame, /*Q0*/ + const Word16 bwidth, /*Q0*/ + const Word16 L_frameTCX, /*Q0*/ + const Word16 fscale, /*Q0*/ + const Word16 preemph_fac, /*Q15*/ + const Word16 tcxonly, /*Q0*/ + const Word16 rf_mode, /*Q0*/ + const Word16 igf, /*Q0*/ + const Word16 infoIGFStopFreq, /*Q0*/ + const Word16 element_mode, /*Q0*/ + const Word16 ini_frame, /*Q0*/ +#ifdef HARMONIZE_2567_init_functions + const Word16 MCT_flag, /*Q0*/ + const Word16 fscaleFB /*Q0*/ ); +#else + const Word16 MCT_flag /*Q0*/ ); +#endif Word16 msvq_stage1_dct_search_fx( const Word32 *u_fx, /* i : target exp : u_e */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 7efe8a9ff28578122718235c8d76ca5239c7f991..88270349aa17be140b3c60d352cc782a5d21a6d7 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -19,21 +19,42 @@ * Local functions *-----------------------------------------------------------------------*/ +#ifndef HARMONIZE_2567_init_functions static void init_tcx_fx( Encoder_State *st, Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); +#endif static void init_core_sig_ana_fx( Encoder_State *st ); +#ifdef HARMONIZE_2567_init_functions +static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift, const Word32 last_total_brate ); +#else static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift ); +#endif +#ifndef HARMONIZE_2567_init_functions static void init_modes_fx( Encoder_State *st, const Word32 Last_total_brate ); +#endif static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ); +#ifdef HARMONIZE_2567_init_functions +static void init_tcx_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); +#else static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); +#endif +#ifndef HARMONIZE_2567_init_functions static void init_core_sig_ana_ivas_fx( Encoder_State *st ); +#endif +#ifdef HARMONIZE_2567_init_functions +static void init_modes_fx( Encoder_State *st, const Word32 last_total_brate ); +#else static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); +#endif static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ); +#ifndef HARMONIZE_2567_init_functions #ifdef NONBE_FIX_ISSUE_2518 static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, const Word32 last_total_brate ); #else static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ); #endif +#endif +#ifndef HARMONIZE_2567_init_functions /*-----------------------------------------------------------------------* * init_coder_ace_plus_fx() * @@ -277,7 +298,9 @@ void init_coder_ace_plus_fx( return; } +#endif +#ifndef HARMONIZE_2567_init_functions static void init_tcx_fx( Encoder_State *st, Word16 L_frame_old, @@ -437,6 +460,7 @@ static void init_tcx_fx( hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); move16(); } +#endif void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ) { @@ -538,6 +562,7 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor return; } +#ifndef HARMONIZE_2567_init_functions static void init_core_sig_ana_fx( Encoder_State *st ) { @@ -588,7 +613,9 @@ static void init_core_sig_ana_fx( Encoder_State *st ) return; } +#endif +#ifndef HARMONIZE_2567_init_functions static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift ) { Word16 mem_syn_r_size_old; @@ -833,7 +860,9 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s return; } +#endif +#ifndef HARMONIZE_2567_init_functions static void init_modes_fx( Encoder_State *st, const Word32 last_total_brate ) @@ -922,17 +951,27 @@ static void init_modes_fx( return; } +#endif /*-----------------------------------------------------------------------* * init_coder_ace_plus() * * Initialization of state variables *-----------------------------------------------------------------------*/ +#ifdef HARMONIZE_2567_init_functions +void init_coder_ace_plus_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 shift, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#else void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ const Word32 igf_brate, /* i : IGF configuration bitrate */ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#endif ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; @@ -973,8 +1012,11 @@ void init_coder_ace_plus_ivas_fx( { hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, INV_FRAME_PER_SEC_Q15 ) ); move16(); - +#ifdef HARMONIZE_2567_init_functions + IF( ( st->ini_frame == 0 ) && GT_16( st->element_mode, EVS_MONO ) ) +#else IF( st->ini_frame == 0 ) +#endif { set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; @@ -990,7 +1032,11 @@ void init_coder_ace_plus_ivas_fx( test(); test(); test(); - IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) +#ifdef HARMONIZE_2567_init_functions + IF( ( ( st->element_mode == EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) +#else + IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( GT_16( st->element_mode, EVS_MONO ) && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) +#endif { st->nb_subfr = NB_SUBFR16k; move16(); @@ -1012,8 +1058,20 @@ void init_coder_ace_plus_ivas_fx( { st->acelpFramesCount = 0; move16(); - st->prevTempFlatness_32fx = ONE_IN_Q21 /*1.0f Q21*/; - move32(); +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + st->prevTempFlatness_fx = 128 /*1.0f Q7*/; + move16(); + } + ELSE + { +#endif + st->prevTempFlatness_32fx = ONE_IN_Q21 /*1.0f Q21*/; + move32(); +#ifdef HARMONIZE_2567_init_functions + } +#endif } /* Initialize TBE */ @@ -1031,6 +1089,14 @@ void init_coder_ace_plus_ivas_fx( move32(); st->currEnergyHF_e_fx = 0; move16(); + +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + st->energyCoreLookahead_Fx = 0; + move16(); + } +#endif test(); /* Initialize LPC analysis/quantization */ IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) @@ -1064,37 +1130,91 @@ void init_coder_ace_plus_ivas_fx( test(); IF( st->igf && st->hIGFEnc != NULL ) { +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); + } + ELSE + { + IGFEncSetMode_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); + } +#else IGFEncSetMode_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif } ELSE IF( st->hIGFEnc != NULL ) { st->hIGFEnc->infoTotalBitsWritten = 0; move16(); - st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; - move16(); +#ifdef HARMONIZE_2567_init_functions + if ( ( GT_16( st->element_mode, EVS_MONO ) ) || ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( MCT_flag, -10 ) ) ) + { +#endif + st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif } +#ifdef HARMONIZE_2567_init_functions + /* Initialize Core Signal Analysis Module */ + init_core_sig_ana_fx( st ); +#else /* Initialize Core Signal Analysis Module */ init_core_sig_ana_ivas_fx( st ); - +#endif /*HARMONIZE_2567_init_functions*/ /* Initialize TCX */ IF( hTcxEnc != NULL ) { - init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); +#ifdef HARMONIZE_2567_init_functions + init_tcx_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); +#else + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); + } + ELSE + { + init_tcx_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); + } +#endif } /* Initialize Signal Buffers */ - init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + init_sig_buffers_fx( st, L_frame_old, L_subfr ); + } + ELSE + { +#endif + init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); +#ifdef HARMONIZE_2567_init_functions + } +#endif - /* Initialize ACELP */ + /* Initialize ACELP */ +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + init_acelp_fx( st, L_frame_old, shift, 0 ); + } + ELSE + { +#endif #ifdef NONBE_FIX_ISSUE_2518 - init_acelp_ivas_fx( st, L_frame_old, last_total_brate ); + init_acelp_fx( st, L_frame_old, 0, last_total_brate ); + } #else - init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); + init_acelp_fx( st, L_frame_old, 0, last_total_brate ); #endif + if ( st->ini_frame == 0 ) { st->tec_tfa = 0; @@ -1106,6 +1226,18 @@ void init_coder_ace_plus_ivas_fx( resetTecEnc_Fx( st->hTECEnc, st->tec_tfa ); } +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + if ( st->hTECEnc == NULL ) + { + resetTecEnc_Fx( st->hTECEnc, 0 ); + } + st->tec_tfa = 0; + move16(); + } +#endif + test(); test(); test(); @@ -1128,7 +1260,13 @@ void init_coder_ace_plus_ivas_fx( test(); test(); test(); +#ifdef HARMONIZE_2567_init_functions + test(); + if ( EQ_16( st->element_mode, EVS_MONO ) && ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || + EQ_32( st->total_brate, ACELP_24k40 ) || EQ_32( st->total_brate, ACELP_32k ) ) ) +#else IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) +#endif { st->glr = 1; move16(); @@ -1143,11 +1281,36 @@ void init_coder_ace_plus_ivas_fx( move16(); /* Initialize ACELP/TCX Modes */ +#ifdef HARMONIZE_2567_init_functions + init_modes_fx( st, last_total_brate ); +#else init_modes_ivas_fx( st, last_total_brate ); +#endif /*HARMONIZE_2567_init_functions*/ + /* Adaptive BPF */ - set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); - set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + set16_fx( st->mem_bpf_fx.noise_buf, 0, 2 * L_FILT16k ); + set16_fx( st->mem_bpf_fx.error_buf, 0, L_FILT16k ); + set16_fx( st->bpf_gainT, 0, NB_SUBFR16k ); + + set16_fx( st->bpf_T, PIT_MIN_12k8, NB_SUBFR16k ); + + st->mem_bpf_fx.lp_error = 0; + move16(); + st->mem_bpf_fx.noise_shift_old = 0; + move16(); + } + ELSE + { +#endif + set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); + set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); +#ifdef HARMONIZE_2567_init_functions + } +#endif IF( st->ini_frame == 0 ) { @@ -1196,7 +1359,11 @@ void init_coder_ace_plus_ivas_fx( *-----------------------------------------------------------------------*/ +#ifdef HARMONIZE_2567_init_functions +static void init_tcx_fx( +#else static void init_tcx_ivas_fx( +#endif Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, @@ -1204,17 +1371,56 @@ static void init_tcx_ivas_fx( const Word16 MCT_flag ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; +#ifdef HARMONIZE_2567_init_functions + Word16 i; + Word16 fscaleFB; - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; - hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + fscaleFB = div_l( L_shl( st->input_Fs, LD_FSCALE_DENOM + 1 ), 12800 ); + + init_TCX_config( st->hTcxCfg, st->L_frame, st->fscale, hTcxEnc->L_frameTCX, fscaleFB ); + + st->hTcxCfg->tcx_mdct_window_length_old = st->hTcxCfg->tcx_mdct_window_length; + move16(); + + /* TCX Offset */ + st->hTcxCfg->tcx_offset = shr( st->hTcxCfg->tcx_mdct_window_delay, 1 ); + move16(); + st->hTcxCfg->tcx_offsetFB = shr( st->hTcxCfg->tcx_mdct_window_delayFB, 1 ); + move16(); - init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, - st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, - st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); + /*<0 rectangular transition with optimized window size = L_frame+L_frame/4*/ + st->hTcxCfg->lfacNext = sub( st->hTcxCfg->tcx_offset, shr( st->L_frame, 2 ) ); + move16(); + st->hTcxCfg->lfacNextFB = sub( st->hTcxCfg->tcx_offsetFB, shr( hTcxEnc->L_frameTCX, 2 ) ); + move16(); + IF( st->ini_frame == 0 ) + { + st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + move16(); + move16(); + } + } + ELSE +#endif + { + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ + hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; + hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); +#ifdef HARMONIZE_2567_init_functions + init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, + st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, + st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag, 0 ); +#else + init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, + st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, + st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); +#endif + } /* Init TCX target bits correction factor */ hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/ @@ -1225,9 +1431,59 @@ static void init_tcx_ivas_fx( move16(); hTcxEnc->noiseLevelMemory_cnt = 0; move16(); +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /*SQ deadzone & memory quantization*/ + + /*0.375f: deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ + st->hTcxCfg->sq_rounding = 12288 /*0.375f Q15*/; + move16(); + + FOR( i = 0; i < L_FRAME_PLUS; i++ ) + { + hTcxEnc->memQuantZeros[i] = 0; + move16(); + } + + /* TCX rate loop */ + st->hTcxCfg->tcxRateLoopOpt = 0; + move16(); + + if ( st->tcxonly != 0 ) + { + st->hTcxCfg->tcxRateLoopOpt = 2; + move16(); + } + + /* TCX bandwidth */ + move16(); + st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); - set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); - set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); + + /* set number of coded lines */ + st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); + + /* TNS in TCX */ + move16(); + move16(); + st->hTcxCfg->fIsTNSAllowed = (Word8) getTnsAllowed( st->total_brate, st->igf, st->element_mode ); + + st->hTcxCfg->pCurrentTnsConfig = NULL; + + IF( st->hTcxCfg->fIsTNSAllowed != 0 ) + { + InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, 0 /*is_mct*/ ); + } + } + ELSE + { +#endif + set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); + set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); +#ifdef HARMONIZE_2567_init_functions + } +#endif /* TCX-LTP */ hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); @@ -1243,21 +1499,28 @@ static void init_tcx_ivas_fx( hTcxEnc->tcxltp_pitch_fr_past = 0; hTcxEnc->tcxltp_gain_past = 0; hTcxEnc->tcxltp_norm_corr_past = 0; - hTcxEnc->tcxltp_norm_corr_mem = 0; - hTcxEnc->kernel_switch_corr_past = 0; - hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ - hTcxEnc->enc_ste_pre_corr_past = 0; - hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ - hTcxEnc->tcxltp_on_mem = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); move16(); +#ifdef HARMONIZE_2567_init_functions + IF( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + hTcxEnc->tcxltp_norm_corr_mem = 0; + hTcxEnc->kernel_switch_corr_past = 0; + hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ + hTcxEnc->enc_ste_pre_corr_past = 0; + hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ + hTcxEnc->tcxltp_on_mem = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif move16(); } ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && @@ -1296,6 +1559,24 @@ static void init_tcx_ivas_fx( move16(); } +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* Residual Coding*/ + st->hTcxCfg->resq = getResq( st->total_brate ); + move16(); + + test(); + if ( st->hTcxCfg->resq != 0 && st->tcxonly == 0 ) + { + st->hTcxCfg->tcxRateLoopOpt = 1; + move16(); + } + + st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); + move16(); + } +#endif hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); move16(); @@ -1494,7 +1775,11 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol * * *-----------------------------------------------------------------------*/ +#ifdef HARMONIZE_2567_init_functions +static void init_core_sig_ana_fx( Encoder_State *st ) +#else static void init_core_sig_ana_ivas_fx( Encoder_State *st ) +#endif { /* Pre-emphasis factor and memory */ @@ -1511,6 +1796,13 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ move16(); } +#ifdef HARMONIZE_2567_init_functions + if ( EQ_16( st->element_mode, EVS_MONO ) ) + { + st->hTcxCfg->preemph_fac = st->preemph_fac; + move16(); + } +#endif st->gamma = GAMMA1; move16(); @@ -1541,16 +1833,25 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) return; } + /*-----------------------------------------------------------------------* * init_acelp() * * *-----------------------------------------------------------------------*/ #ifdef NONBE_FIX_ISSUE_2518 +#ifdef HARMONIZE_2567_init_functions +static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift, const Word32 last_total_brate ) +#else static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, const Word32 last_total_brate ) +#endif +#else +#ifdef HARMONIZE_2567_init_functions +static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift, const Word32 last_total_brate ) #else static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ) #endif +#endif { Word16 mem_syn_r_size_old; Word16 mem_syn_r_size_new; @@ -1577,10 +1878,17 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh { set16_fx( hLPDmem->syn, 0, 1 + M ); set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - hLPDmem->q_lpd_syn = Q15; - hLPDmem->q_mem_syn = Q15; - move16(); - move16(); +#ifdef HARMONIZE_2567_init_functions + IF( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->q_lpd_syn = Q15; + hLPDmem->q_mem_syn = Q15; + move16(); + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif } IF( st->hTcxEnc != NULL ) @@ -1610,10 +1918,12 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh { Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); set16_fx( hLPDmem->syn, 0, M ); +#ifndef HARMONIZE_2567_init_functions hLPDmem->q_lpd_syn = Q15; hLPDmem->q_mem_syn = Q15; move16(); move16(); +#endif } IF( st->hTcxEnc != NULL ) { @@ -1646,23 +1956,50 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh move16(); set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); set16_fx( hLPDmem->syn, 0, 1 + M ); - hLPDmem->q_lpd_syn = Q15; - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); +#ifdef HARMONIZE_2567_init_functions + IF( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->q_lpd_syn = Q15; + move16(); + hLPDmem->q_lpd_old_exc = Q15; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif hLPDmem->mem_w0 = 0; move16(); set16_fx( hLPDmem->mem_syn, 0, M ); set16_fx( hLPDmem->mem_syn2, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); +#ifdef HARMONIZE_2567_init_functions + IF( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->q_mem_syn = Q15; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif } /* unquantized LPC*/ test(); test(); test(); +#ifdef HARMONIZE_2567_init_functions + Word16 condition; + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + condition = !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, st->last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ); + } + ELSE + { + condition = !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ); + } + IF( condition ) +#else IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) +#endif { Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ IF( EQ_16( st->L_frame, L_FRAME16k ) ) @@ -1734,12 +2071,25 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); #ifdef NONBE_FIX_ISSUE_2518 +#ifdef HARMONIZE_2567_init_functions + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); + hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); + } + ELSE + { + Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 0 ); + hLPDmem->mem_w0 = sub_sat( shl_sat( st->wspeech_enc[-1], sub( hLPDmem->q_mem_syn, sub( Q15, st->exp_buf_wspeech_enc ) ) ), tmp ); + } +#else Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 0 ); hLPDmem->mem_w0 = sub_sat( shl_sat( st->wspeech_enc[-1], sub( hLPDmem->q_mem_syn, sub( Q15, st->exp_buf_wspeech_enc ) ) ), tmp ); +#endif /*HARMONIZE_2567_init_functions*/ #else Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); -#endif +#endif /*NONBE_FIX_ISSUE_2518*/ move16(); } } @@ -1758,8 +2108,15 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh move16(); set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); +#ifdef HARMONIZE_2567_init_functions + IF( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->q_lpd_old_exc = Q15; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif /*Resamp others memories*/ /*Size of LPC syn memory*/ /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ @@ -1847,26 +2204,45 @@ static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 sh { st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); move32(); - st->pst_lp_ener_fx = 0; - move16(); +#ifdef HARMONIZE_2567_init_functions + if ( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + st->pst_lp_ener_fx = 0; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif IF( EQ_16( st->last_codec_mode, MODE1 ) ) { st->mem_bpf_fx.lp_error = 0; move32(); - st->pst_mem_deemp_err_fx = 0; - move16(); +#ifdef HARMONIZE_2567_init_functions + if ( GT_16( st->element_mode, EVS_MONO ) ) + { +#endif + st->pst_mem_deemp_err_fx = 0; + move16(); +#ifdef HARMONIZE_2567_init_functions + } +#endif } } return; } + /*-----------------------------------------------------------------------* * init_modes() * * *-----------------------------------------------------------------------*/ +#ifdef HARMONIZE_2567_init_functions +static void init_modes_fx( +#else static void init_modes_ivas_fx( +#endif Encoder_State *st, const Word32 last_total_brate ) { @@ -1914,6 +2290,13 @@ static void init_modes_ivas_fx( /* st->bits_frame_nominal = extract_h(L_add(L_mult(div_l(L_mult(shl(st->L_frame,2),st->bitrate),st->fscale),328),16056)); */ /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ); */ +#ifdef HARMONIZE_2567_init_functions + if ( EQ_16( st->element_mode, EVS_MONO ) ) + { + assert( FSCALE_DENOM == 512 ); + assert( st->fscale == 2 * st->L_frame ); /* this assumption is true if operated in 20ms frames with FSCALE_DENOM == 512, which is the current default */ + } +#endif tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ move16(); @@ -1931,6 +2314,41 @@ static void init_modes_ivas_fx( { FOR( n = 0; n < FRAME_SIZE_NB; n++ ) { +#ifdef HARMONIZE_2567_init_functions + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = FrameSizeConfig[n].frame_bits; + move16(); + st->bits_frame_core = FrameSizeConfig[n].frame_net_bits; + move16(); + BREAK; + } + ELSE IF( GT_16( st->element_mode, EVS_MONO ) && ( ( + ( LT_32( n, FRAME_SIZE_NB - 1 ) ) && + ( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) ) || + ( !( LT_32( n, FRAME_SIZE_NB - 1 ) ) && + ( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) ) + + ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); + move16(); + BREAK; + } +#else IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) { test(); @@ -1958,11 +2376,30 @@ static void init_modes_ivas_fx( BREAK; } } +#endif } +#ifdef HARMONIZE_2567_init_functions + test(); + if ( EQ_16( (Word16) n, FRAME_SIZE_NB ) && ( EQ_16( st->element_mode, EVS_MONO ) ) ) + { + assert( !"Bitrate not supported: not part of EVS" ); + } +#endif } /* Reconfigure core */ - core_coder_reconfig_ivas_fx( st, last_total_brate ); +#ifdef HARMONIZE_2567_init_functions + if ( EQ_16( st->element_mode, EVS_MONO ) ) + { + core_coder_reconfig_fx( st, last_total_brate ); + } + ELSE + { +#endif + core_coder_reconfig_ivas_fx( st, last_total_brate ); +#ifdef HARMONIZE_2567_init_functions + } +#endif return; diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index 3bea33c1228bb5293ae6bd52acca6f1f7c148435..b67a20d22149c4232da59f1e5acd8204339a3214 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -157,7 +157,12 @@ void core_coder_mode_switch_fx( { st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); move16(); +#ifdef HARMONIZE_2567_init_functions + assert( st->element_mode == EVS_MONO ); + init_coder_ace_plus_fx( st, last_total_bitrate, 0, shift, MCT_flag ); +#else init_coder_ace_plus_fx( st, last_total_bitrate, shift, MCT_flag ); +#endif } test(); @@ -396,7 +401,14 @@ void core_coder_mode_switch_ivas_fx( st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); #endif + +#ifdef HARMONIZE_2567_init_functions + assert( st->element_mode != EVS_MONO ); + init_coder_ace_plus_fx( st, last_total_brate, st->total_brate, 0, MCT_flag ); +#else init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); +#endif + #ifndef NONBE_FIX_ISSUE_2518 if ( st->hLPDmem != NULL ) { diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 52fb9b6252e45c2fcab9025193443c7955e0bef6..6b3770893b06e6f59b3827084cd5ba8e14fc2c6f 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1134,7 +1134,12 @@ ivas_error init_encoder_fx( IF( st->element_mode == EVS_MONO ) { +#ifdef HARMONIZE_2567_init_functions + assert( st->element_mode == EVS_MONO ); + init_coder_ace_plus_fx( st, st->last_total_brate, 0, 0, -10 /*hack*/ ); +#else init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); +#endif } ELSE { @@ -1148,7 +1153,13 @@ ivas_error init_encoder_fx( st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); + +#ifdef HARMONIZE_2567_init_functions + assert( st->element_mode != EVS_MONO ); + init_coder_ace_plus_fx( st, st->last_total_brate, igf_brate, 0, 0 ); +#else init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); +#endif } #ifndef NONBE_FIX_ISSUE_2518 diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 046f1521137ce63d5eebba1e83b235e10d516a32..13dad77c0fa8fb1ae38b1c0abc3d23ca3b86db77 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2342,12 +2342,14 @@ void tcx_ltp_encode_ivas_fx( const Word16 disable_ltp, const Word16 element_mode ); +#ifndef HARMONIZE_2567_init_functions void init_coder_ace_plus_fx( Encoder_State *st, const Word32 last_total_brate, /* i : last total bitrate */ const Word16 shift, const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ); +#endif void enc_prm_rf_fx( Encoder_State *st,