diff --git a/lib_com/options.h b/lib_com/options.h index 6857712c5dcc017caf34bbca7bb271d112e80720..d910792b7f64d5a17b61aa42c68e28dfafd5aba3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,6 +94,26 @@ #define FIX_2402_SIGNED_VERSION /* FhG: basop issue 2402: use signed operator instead of unsigned, better match for hardware */ #define HARMONIZE_2583_open_decoder_LPD /* FhG: harmonize open_decoder_LPD between EVS and IVAS versions */ +#define HARMONIZE_2644_SOME_INITS_Stage1 /* FhG: Harmonize with float: init_acelp, init_tcx, init_coder_ace_plus, init_core_sig_ana, init_modes, init_sig_buffers, init_tcx_cfg*/ +#define HARMONIZE_2644_SOME_INITS_Stage2 +#define HARMONIZE_2644_SOME_INITS_Stage3 +#define HARMONIZE_2644_SOME_INITS_Stage4 +#define HARMONIZE_2644_SOME_INITS_Stage5 +#define HARMONIZE_2644_SOME_INITS_Stage6 + +#define HARMONIZE_2644_SOME_INITS_Stage7 +#define HARMONIZE_2644_SOME_INITS_Stage8 +#define HARMONIZE_2644_SOME_INITS_Stage9 + +#define HARMONIZE_2644_SOME_INITS_Stage10 +#define HARMONIZE_2644_SOME_INITS_Stage11 +//#define HARMONIZE_2644_SOME_INITS_Stage12 //mul-question "check, why in BASOP we can't reset st->hIGFEnc->infoTotalBitsPerFrameWritten w/o affecting bit-exactness" !3004 +#define HARMONIZE_2644_SOME_INITS_Stage13 + +#define HARMONIZE_2644_SOME_INITS_Stage14 +#define HARMONIZE_2644_SOME_INITS_Stage15 + + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 23d58603de54fc5b5e8b8bf5d374956926cf0207..3f58cad9835ba7ba59ef6e9b4f03beaea390f53e 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -26,7 +26,6 @@ static void init_tcx_fx( Encoder_State *st, const Word16 L_frame_old, const Word static void init_modes_fx( Encoder_State *st, const Word32 last_total_brate ); static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ); - void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ) { @@ -217,16 +216,22 @@ void init_coder_ace_plus_fx( { st->acelpFramesCount = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage10 IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#endif st->prevTempFlatness_fx = 128 /*1.0f Q7*/; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage10 } ELSE { +#endif st->prevTempFlatness_32fx = ONE_IN_Q21 /*1.0f Q21*/; move32(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage10 } +#endif } /* Initialize TBE */ @@ -245,11 +250,14 @@ void init_coder_ace_plus_fx( st->currEnergyHF_e_fx = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage11 IF( EQ_16( st->element_mode, EVS_MONO ) ) { + /*Basop obviously uses different variables for this - float inits it in another place */ st->energyCoreLookahead_Fx = 0; move16(); } +#endif /* Initialize LPC analysis/quantization */ test(); @@ -290,12 +298,16 @@ void init_coder_ace_plus_fx( { st->hIGFEnc->infoTotalBitsWritten = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage12 /* TODO mul: check, why in BASOP we can't reset st->hIGFEnc->infoTotalBitsPerFrameWritten w/o affecting bit-exactness */ if ( GT_16( st->element_mode, EVS_MONO ) ) { +#endif st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage12 } +#endif } /* Initialize Core Signal Analysis Module */ @@ -393,11 +405,16 @@ void init_coder_ace_plus_fx( st->mem_bpf_fx.noise_shift_old = 0; move16(); } +#ifndef HARMONIZE_2644_SOME_INITS_Stage13 ELSE { +#ifdef HARMONIZE_2644_SOME_INITS_Stage13 + // Not needed anymore? +#endif set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); } +#endif IF( st->ini_frame == 0 ) { @@ -464,6 +481,7 @@ static void init_tcx_fx( st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; move16(); move16(); + 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, fscaleFB ); @@ -477,6 +495,7 @@ static void init_tcx_fx( move16(); hTcxEnc->noiseLevelMemory_cnt = 0; move16(); + set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); @@ -491,28 +510,33 @@ static void init_tcx_fx( IF( st->ini_frame == 0 ) { hTcxEnc->tcxltp_pitch_int_past = st->L_frame; + move16(); hTcxEnc->tcxltp_pitch_fr_past = 0; + move16(); hTcxEnc->tcxltp_gain_past = 0; + move16(); hTcxEnc->tcxltp_norm_corr_past = 0; move16(); + +#ifndef HARMONIZE_2644_SOME_INITS_Stage7 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(); + hTcxEnc->kernel_switch_corr_past = 0; move16(); + hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ move16(); + hTcxEnc->enc_ste_pre_corr_past = 0; move16(); + hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ move16(); + hTcxEnc->tcxltp_on_mem = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage7 } - move16(); +#endif } ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && ( EQ_32( total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) @@ -520,6 +544,18 @@ static void init_tcx_fx( Word16 pitres, pitres_old; Word16 pit, pit_old; +#ifdef HARMONIZE_2644_SOME_INITS_Stage8 + if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ + { + pitres_old = 6; + move16(); + } + ELSE + { + pitres_old = 4; + move16(); + } +#else pitres_old = 4; move16(); if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ @@ -527,10 +563,24 @@ static void init_tcx_fx( pitres_old = 6; move16(); } +#endif /*pit_old = (float)st->tcxltp_pitch_int_past + (float)st->tcxltp_pitch_fr_past/(float)pitres_old;*/ pit_old = add( hTcxEnc->tcxltp_pitch_int_past, mult_r( hTcxEnc->tcxltp_pitch_fr_past, div_s( 1, pitres_old ) ) ); +#ifdef HARMONIZE_2644_SOME_INITS_Stage8 + if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ + { + pitres = 6; + move16(); + } + ELSE + { + pitres = 4; + move16(); + } + +#else pitres = 4; move16(); if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ @@ -538,7 +588,7 @@ static void init_tcx_fx( pitres = 6; move16(); } - +#endif /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); /* Note : the saturation here that can happens when FS == 32kHz*/ @@ -734,8 +784,11 @@ static void init_core_sig_ana_fx( Encoder_State *st ) /* Pre-emphasis factor and memory */ +#ifndef HARMONIZE_2644_SOME_INITS_Stage14 st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ move16(); +#endif + IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / 12800 ) ) { st->preemph_fac = PREEMPH_FAC; /*WB*/ @@ -746,16 +799,28 @@ static void init_core_sig_ana_fx( Encoder_State *st ) st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ move16(); } +#ifdef HARMONIZE_2644_SOME_INITS_Stage14 + ELSE + { + st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + move16(); + } +#endif + +#ifndef HARMONIZE_2644_SOME_INITS_Stage15 if ( EQ_16( st->element_mode, EVS_MONO ) ) { st->hTcxCfg->preemph_fac = st->preemph_fac; move16(); } +#endif +#ifndef HARMONIZE_2644_SOME_INITS_Stage14 st->gamma = GAMMA1; move16(); st->inv_gamma = GAMMA1_INV; move16(); +#endif IF( EQ_32( st->sr_core, 16000 ) ) { st->gamma = GAMMA16k; @@ -763,8 +828,17 @@ static void init_core_sig_ana_fx( Encoder_State *st ) st->inv_gamma = GAMMA16k_INV; move16(); } +#ifdef HARMONIZE_2644_SOME_INITS_Stage14 + ELSE + { + st->gamma = GAMMA1; + move16(); + st->inv_gamma = GAMMA1_INV; + move16(); + } +#endif - +#ifndef HARMONIZE_2644_SOME_INITS_Stage14 st->min_band = 1; move16(); st->max_band = 16; @@ -777,7 +851,24 @@ static void init_core_sig_ana_fx( Encoder_State *st ) st->max_band = 19; move16(); } +#endif +#ifdef HARMONIZE_2644_SOME_INITS_Stage14 + IF( NE_16( st->narrowBand, 0 ) ) + { + st->min_band = 1; + move16(); + st->max_band = 16; + move16(); + } + ELSE + { + st->min_band = 0; + move16(); + st->max_band = 19; + move16(); + } +#endif return; } @@ -814,13 +905,18 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s { set16_fx( hLPDmem->syn, 0, 1 + M ); set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); + +#ifndef HARMONIZE_2644_SOME_INITS_Stage1 IF( GT_16( st->element_mode, EVS_MONO ) ) { +#endif hLPDmem->q_lpd_syn = Q15; hLPDmem->q_mem_syn = Q15; move16(); move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage1 } +#endif } IF( st->hTcxEnc != NULL ) @@ -833,15 +929,23 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s } ELSE /*Rate switching*/ { - IF( st->last_core == ACELP_CORE ) - { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); - } - ELSE +#ifdef HARMONIZE_2644_SOME_INITS_Stage2 + IF( st->hTcxEnc != NULL ) { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); +#endif + IF( st->last_core == ACELP_CORE ) + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); + } + ELSE + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); + } + hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); +#ifdef HARMONIZE_2644_SOME_INITS_Stage2 } - hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); +#endif + /* Rate switching */ IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) @@ -882,22 +986,30 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s move16(); set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); set16_fx( hLPDmem->syn, 0, 1 + M ); +#ifndef HARMONIZE_2644_SOME_INITS_Stage3 IF( GT_16( st->element_mode, EVS_MONO ) ) { +#endif hLPDmem->q_lpd_syn = Q15; move16(); hLPDmem->q_lpd_old_exc = Q15; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage3 } +#endif hLPDmem->mem_w0 = 0; move16(); set16_fx( hLPDmem->mem_syn, 0, M ); set16_fx( hLPDmem->mem_syn2, 0, M ); +#ifndef HARMONIZE_2644_SOME_INITS_Stage3 IF( GT_16( st->element_mode, EVS_MONO ) ) { +#endif hLPDmem->q_mem_syn = Q15; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage3 } +#endif } /* unquantized LPC*/ @@ -1003,11 +1115,16 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s move16(); set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage4 IF( GT_16( st->element_mode, EVS_MONO ) ) { +#endif hLPDmem->q_lpd_old_exc = Q15; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage4 } +#endif + /*Resamp others memories*/ /*Size of LPC syn memory*/ /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ @@ -1040,6 +1157,7 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s } ELSE IF( !st->tcxonly && EQ_16( st->L_frame, L_FRAME16k ) && GT_32( st->last_total_brate, ACELP_32k ) ) { + /* necessary in BASOP only, due to different representations of st->lsf_old */ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); } } @@ -1062,8 +1180,9 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s if ( hLPDmem != NULL ) { + /* struct dispMem_fx dm_fx is member in basop, float[8] array in float */ hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ + move16(); hLPDmem->dm_fx.prev_gain_code = 0; move32(); @@ -1093,22 +1212,32 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s /*BPF parameters for adjusting gain in function of background noise*/ IF( EQ_16( st->codec_mode, MODE2 ) ) { + /* in floating point implementation, different buffers are used: lp_error_ener <-> pst_lp_ener, mem_error <-> pst_mem_deemp_err */ + st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); move32(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage5 if ( GT_16( st->element_mode, EVS_MONO ) ) { +#endif st->pst_lp_ener_fx = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage5 } +#endif IF( EQ_16( st->last_codec_mode, MODE1 ) ) { st->mem_bpf_fx.lp_error = 0; move32(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage6 if ( GT_16( st->element_mode, EVS_MONO ) ) { +#endif st->pst_mem_deemp_err_fx = 0; move16(); +#ifndef HARMONIZE_2644_SOME_INITS_Stage6 } +#endif } } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 57f1c4faca2c11e35129aa398ffb27768dc58e40..dbc095839fbe8604cd8c3a72219fc8b7db08a3d5 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -813,8 +813,11 @@ void stereo_switching_enc_fx( IF( sts[0]->cldfbSynTd != NULL ) { cldfb_reset_memory_fx( sts[0]->cldfbSynTd ); +#ifndef HARMONIZE_2644_SOME_INITS_Stage9 + /*basop uses another variable - */ sts[0]->currEnergyLookAhead_fx = 130996; /* Q31 */ move32(); +#endif } test(); @@ -843,8 +846,11 @@ void stereo_switching_enc_fx( IF( sts[1]->cldfbSynTd != NULL ) { cldfb_reset_memory_fx( sts[1]->cldfbSynTd ); +#ifndef HARMONIZE_2644_SOME_INITS_Stage9 + /*basop uses another variable - */ sts[1]->currEnergyLookAhead_fx = 130996; /* Q31 */ move32(); +#endif } } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 34f3c56bc60c4213bad7dff4acbf9554d4420b3b..9cc4386cb04080aca820d8fc7ea7c0155a83125b 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1631,7 +1631,10 @@ typedef struct enc_core_structure Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ Word32 prevTempFlatness_32fx; /* Q21 in IVAS */ +#ifndef HARMONIZE_2644_SOME_INITS_Stage9 + /*basop uses another variable - */ Word32 currEnergyLookAhead_fx; // Q31 +#endif Word32 prevEnergyHF_fx; Word32 currEnergyHF_fx; Word16 currEnergyHF_e_fx; /* exponent of currEnergyHF and prevEnergyHF */ @@ -1669,8 +1672,13 @@ typedef struct enc_core_structure /*Adaptive BPF*/ Word16 bpf_gain_param; +#ifndef HARMONIZE_2644_SOME_INITS_Stage13 +#ifdef HARMONIZE_2644_SOME_INITS_Stage13 + // Not needed anymore? +#endif Word32 mem_bpf_fx1[2 * L_FILT16k]; Word32 mem_error_bpf_fx[2 * L_FILT16k]; +#endif Word16 bpf_T[NB_SUBFR16k]; Word16 bpf_gainT[NB_SUBFR16k];