From d3015a847ccca5f3e24b324998812431d51d2fd0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 10 Sep 2025 17:37:46 +0200 Subject: [PATCH 1/3] revision of core-coder struct members: remove obsolete ones, merge duplicates (hTranDet, hp20 memory), move TD BWE ones under the related sub-struct --- lib_enc/acelp_core_enc_fx.c | 4 +- lib_enc/amr_wb_enc_fx.c | 11 +- lib_enc/core_enc_ol_fx.c | 6 +- lib_enc/core_enc_switch_fx.c | 4 +- lib_enc/core_switching_enc_fx.c | 11 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/ext_sig_ana_fx.c | 4 +- lib_enc/gs_enc_fx.c | 2 +- lib_enc/igf_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 99 ++++---------- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 3 +- lib_enc/ivas_ism_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 6 +- lib_enc/ivas_stereo_switching_enc_fx.c | 6 +- lib_enc/ivas_stereo_td_enc_fx.c | 4 +- lib_enc/lib_enc_fx.c | 6 +- lib_enc/mdct_selector_fx.c | 4 +- lib_enc/pre_proc_fx.c | 8 +- lib_enc/prot_fx_enc.h | 133 ++++++++++-------- lib_enc/stat_enc.h | 132 +++++------------- lib_enc/swb_tbe_enc_fx.c | 178 +++++++++++-------------- lib_enc/tcx_ltp_enc_fx.c | 73 +++++----- lib_enc/transient_detection_fx.c | 128 +++++++++++------- 24 files changed, 364 insertions(+), 466 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index eec55c1c7..0b3d95a7c 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1509,9 +1509,9 @@ ivas_error acelp_core_enc_ivas_fx( IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { /* Apply a non linearity to the SHB excitation */ - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } test(); diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 1580a7818..25364e865 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -24,9 +24,10 @@ *--------------------------------------------------------------------*/ void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : input signal Q0*/ - const Word16 n_samples /* i : number of input samples Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ ) { Word16 i, delay; @@ -109,7 +110,7 @@ void amr_wb_enc_fx( move16(); st->coder_type = GENERIC; move16(); - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); /* frame length of the input signal */ st->extl = -1; move16(); @@ -183,7 +184,7 @@ void amr_wb_enc_fx( st->input_fx[i] = 0; move16(); } - hp20( st->input_fx, 1, input_frame, st->mem_hp20_in_fx, st->input_Fs ); + hp20( st->input_fx, 1, input_frame, mem_hp20_in_fx, st->input_Fs ); /*-----------------------------------------------------------------* * switching from ACELP@16k core to AMR-WB IO mode diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 020af121c..7313a9db7 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -256,7 +256,7 @@ void core_encode_openloop_fx( /* reset TBE buffers previous frame frame wasn't ACELP*/ IF( st->last_core != ACELP_CORE ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } @@ -700,7 +700,7 @@ void core_encode_openloop_fx( test(); test(); IF( rf_PLC_Mode == 0 && hRF->rf_gain_tcx[1] != 0 && - ( ( st->transientDetection.transientDetector.bIsAttackPresent != 0 && LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 31785 /*0.97f Q15*/ ) ) ) || + ( ( st->hTranDet->transientDetector.bIsAttackPresent != 0 && LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 31785 /*0.97f Q15*/ ) ) ) || LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 29491 /*0.90f Q15*/ ) ) ) ) { TD_mode = 0; @@ -900,7 +900,7 @@ void core_acelp_tcx20_switching_fx( st->pit_fr2, st->pit_max, st->pit_res_max, - &st->transientDetection, + st->hTranDet, 0, A_q_tcx, M ); diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index fb5fd037a..8dafd3b04 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -173,7 +173,7 @@ void core_coder_mode_switch_fx( ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) { /* reset TBE buffers as previous frame wasn't using TBE */ - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } ELSE { @@ -418,7 +418,7 @@ void core_coder_mode_switch_ivas_fx( ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } ELSE { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 5b657e9c5..e0878969c 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -45,8 +45,6 @@ void core_switching_pre_enc_fx( { IF( hLPDmem != NULL ) { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /*hLPDmem->q_mem_syn*/ } @@ -200,7 +198,6 @@ void core_switching_pre_enc_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } - st_fx->mem_deemph_fx = 0; /* Reset ACELP parameters */ IF( hLPDmem != NULL ) { @@ -485,7 +482,7 @@ void core_switching_post_enc_fx( } ELSE IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) { - TBEreset_enc_fx( st_fx, st_fx->bwidth ); + TBEreset_enc_fx( st_fx->hBWE_TD, st_fx->last_core, st_fx->bwidth ); } test(); test(); @@ -660,8 +657,6 @@ void core_switching_pre_enc_ivas_fx( { IF( hLPDmem != NULL ) { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); } @@ -818,8 +813,6 @@ void core_switching_pre_enc_ivas_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } - st_fx->mem_deemph_fx = 0; - move16(); /* Reset ACELP parameters */ IF( hLPDmem != NULL ) { @@ -1159,7 +1152,7 @@ void core_switching_post_enc_ivas_fx( } ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } test(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 8e9a82378..90d5a7b4b 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -100,7 +100,7 @@ ivas_error evs_enc_fx( * Initializiation *-----------------------------------------------------------------*/ - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); st->core = -1; move16(); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 87fa6a451..42f6dc487 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -118,7 +118,7 @@ void core_signal_analysis_high_bitrate_fx( &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &hTcxEnc->tcxltp_gain, &hTcxEnc->tcxltp_pitch_int_past, &hTcxEnc->tcxltp_pitch_fr_past, &hTcxEnc->tcxltp_gain_past, &hTcxEnc->tcxltp_norm_corr_past, st->last_core, st->pit_min, st->pit_fr1, - st->pit_fr2, st->pit_max, st->pit_res_max, &st->transientDetection, + st->pit_fr2, st->pit_max, st->pit_res_max, st->hTranDet, tmp8, NULL, M ); } ELSE @@ -130,7 +130,7 @@ void core_signal_analysis_high_bitrate_fx( &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &hTcxEnc->tcxltp_gain, &hTcxEnc->tcxltp_pitch_int_past, &hTcxEnc->tcxltp_pitch_fr_past, &hTcxEnc->tcxltp_gain_past, &hTcxEnc->tcxltp_norm_corr_past, st->last_core, st->pit_min, st->pit_fr1, - st->pit_fr2, st->pit_max, st->pit_res_max, &st->transientDetection, + st->pit_fr2, st->pit_max, st->pit_res_max, st->hTranDet, tmp8, NULL, M ); } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index c666840df..30e4385bf 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1000,7 +1000,7 @@ void gsc_enc_fx( highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &st_fx->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); exc_dct_in[0] = 0; diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index b6a1c66c2..7481c4c86 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -1802,7 +1802,7 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in pPowerSpectrumParameterWhitening, /* i: MDCT^2 + MDST^2 spectrum, or estimate */ PowerSpectrum_e, /* i: exponent of powerSpectrum */ igfGridIdx, /* i: IGF grid index */ - ( st->transientDetection.transientDetector.bIsAttackPresent == 1 ), + ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), last_core_acelp ); /* i: last frame was acelp indicator */ pPowerSpectrumParameter = NULL; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0ee479a7c..6d11af682 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -27,7 +27,7 @@ ivas_error init_encoder_fx( const int16_t interval_SID /* i : interval for SID update */ ) { - Word16 i; + Word16 i, input_frame; Word32 L_tmp; @@ -40,6 +40,8 @@ ivas_error init_encoder_fx( error = IVAS_ERR_OK; + input_frame = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); + /*-----------------------------------------------------------------* * General signal buffers *-----------------------------------------------------------------*/ @@ -183,8 +185,6 @@ ivas_error init_encoder_fx( move16(); set16_fx( st_fx->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); set16_fx( st_fx->old_wsp_fx, 0, L_WSP_MEM ); - st_fx->mem_deemph_fx = 0; - move16(); st_fx->mem_preemph_fx = 0; move16(); st_fx->mem_preemph16k_fx = 0; @@ -230,7 +230,6 @@ ivas_error init_encoder_fx( move16(); st_fx->old_voicing_la = 0; move16(); - set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); st_fx->old_hpfilt_in_fx = 0; move16(); @@ -309,9 +308,6 @@ ivas_error init_encoder_fx( st_fx->hGSCEnc = NULL; } - st_fx->last_ener_fx = 0; - move16(); - st_fx->old_dE1_fx = 0; move16(); st_fx->old_ind_deltaMax = 0; @@ -576,7 +572,7 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ /* open analysis for input SR */ - if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st_fx->input_Fs ), st_fx->input_frame_fx ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st_fx->input_Fs ), input_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -688,8 +684,8 @@ ivas_error init_encoder_fx( // return error; // } - InitSWBencBuffer_fx( st_fx /*st_fx->hBWE_TD*/ ); - ResetSHBbuffer_Enc_fx( st_fx /*st_fx->hBWE_TD*/ ); + InitSWBencBuffer_fx( st_fx->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st_fx->hBWE_TD ); } ELSE { @@ -720,7 +716,7 @@ ivas_error init_encoder_fx( st_fx->input_fx = st_fx->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); set16_fx( st_fx->input_buff_fx + L_FRAME48k, 0, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->input_frame_fx ); + st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), input_frame ); st_fx->Energy_Old_fx = 0; @@ -882,10 +878,15 @@ ivas_error init_encoder_fx( st_fx->totalNoise_increase_len = 0; move16(); init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); - // PMT("Transient detector init needs review, handle hTranDet is missing") + + IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); + } + InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), - &st_fx->transientDetection ); + st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); @@ -904,40 +905,30 @@ ivas_error init_encoder_fx( st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ move16(); st_fx->element_mode = EVS_MONO; /* element mode */ move16(); - st_fx->last_element_mode = st_fx->element_mode; /* element mode */ - move16(); st_fx->element_brate = -1; /* element bitrate */ move32(); - // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") st_fx->low_rate_mode = 0; /* low-rate mode flag */ move16(); // st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx( st_fx->pitch, L_SUBFR, 3 ); set16_fx( st_fx->voicing_fx, 0, 3 ); - - #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif - st_fx->extl_orig = -1; /* extension layer */ - move16(); - st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - move32(); + return error; } /*-----------------------------------------------------------------------* - * LPDmem_enc_init_fx() + * LPDmem_enc_init() * * Initialization of ACELP LPDmem state variables *-----------------------------------------------------------------------*/ @@ -956,44 +947,13 @@ void LPDmem_enc_init_fx( set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); set16_fx( hLPDmem->mem_syn3, 0, M ); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - - FOR( i = 2; i < 8; i++ ) - { - hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - return; -} - -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -) -{ - Word16 i; - - set16_fx( hLPDmem->syn, 0, 1 + M ); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - set16_fx( hLPDmem->mem_syn3, 0, M ); hLPDmem->q_lpd_old_exc = Q15; move16(); hLPDmem->q_lpd_syn = Q15; move16(); hLPDmem->q_mem_syn = Q15; move16(); + hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -1043,13 +1003,15 @@ ivas_error init_encoder_ivas_fx( const Word32 element_brate /* i : element bitrate */ ) { - Word16 i; + Word16 i, input_frame; ivas_error error; Word32 igf_brate; error = IVAS_ERR_OK; move32(); + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + /*-----------------------------------------------------------------* * General parameters *-----------------------------------------------------------------*/ @@ -1666,9 +1628,7 @@ ivas_error init_encoder_ivas_fx( IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* open analysis for input SR */ - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); - - if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), st->input_frame_fx ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), input_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -1747,7 +1707,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { @@ -1805,8 +1765,8 @@ ivas_error init_encoder_ivas_fx( return error; } } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); } ELSE { @@ -2144,19 +2104,14 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - Word16 temp; - Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); - frame_length = shr( frame_length, sub( 15, temp ) ); IF( GT_16( st->element_mode, EVS_MONO ) ) { - InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); + InitTransientDetection_ivas_fx( input_frame, 0, st->hTranDet, 1 ); } ELSE { - InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), - NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), - &st->transientDetection ); + InitTransientDetection_fx( input_frame, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet ); } /*-----------------------------------------------------------------* @@ -2183,8 +2138,6 @@ ivas_error init_encoder_ivas_fx( move16(); st->old_wsp_shift = 0; move16(); - st->sharpFlag = 0; - move16(); return error; } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index c9c54c2c6..b73702d21 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -493,7 +493,7 @@ ivas_error ivas_cpe_enc_fx( RunTransientDetection_ivas_fx( sts[n]->input_fx, input_frame, sts[n]->hTranDet, sts[n]->q_inp ); // Note q of sts[n]->input_fx changes inside function } - currFlatness_fx[n] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) sts[n]->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[n] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( sts[n]->hTranDet, NSUBBLOCKS, 0 ); // Q21 move32(); } diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 5a3592ad2..f4e88f41c 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -1244,8 +1244,7 @@ void destroy_evs_core_enc_fx( IF( hCoreCoder->hVAD_CLDFB != NULL ) { - /* This is not required as we are not allocating memory dynamically */ - // free( hCoreCoder->hVAD_CLDFB ); + free( hCoreCoder->hVAD_CLDFB ); hCoreCoder->hVAD_CLDFB = NULL; } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index dc41c784d..6b75a6be7 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -217,7 +217,7 @@ ivas_error ivas_ism_enc_fx( RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, st->q_inp ); - currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, 0 ); // Q21 move16(); /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 180e175ec..841f4bea2 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -184,7 +184,7 @@ ivas_error ivas_sce_enc_fx( RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, q_input ); } - currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, 0 ); // Q21 move32(); /*----------------------------------------------------------------* @@ -472,7 +472,6 @@ ivas_error create_sce_enc_fx( move32(); st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; st->input_Fs = st_ivas->hEncoderConfig->input_Fs; - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { @@ -556,9 +555,6 @@ ivas_error create_evs_sce_enc_fx( st_fx->total_brate = st_ivas->hEncoderConfig->ivas_total_brate; move32(); - st_fx->input_frame_fx = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); - move16(); - IF( NE_32( ( error = init_encoder_fx( st_fx, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 469bf211a..9e1649eb2 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -58,7 +58,7 @@ static ivas_error allocate_CoreCoder_enc_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + LPDmem_enc_init_fx( st->hLPDmem ); } IF( st->hGSCEnc == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -435,8 +435,8 @@ ivas_error stereo_memory_enc_fx( } } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 8f1d2d9c9..1c9a5511e 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -327,8 +327,8 @@ ivas_error stereo_set_tdm_fx( return error; } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 295608d6f..f64bdfd1e 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1489,16 +1489,14 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( IF( hEncoderConfig->Opt_AMR_WB ) { - amr_wb_enc_fx( hCoreCoder, inputBuffer, inputBufferSize ); + amr_wb_enc_fx( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in_fx[0], inputBufferSize ); } ELSE { #ifdef DEBUG_MODE_INFO dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); #endif - hCoreCoder->input_frame_fx = inputBufferSize; - move32(); - IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, hCoreCoder->mem_hp20_in_fx, inputBufferSize ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in_fx[0], inputBufferSize ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/mdct_selector_fx.c b/lib_enc/mdct_selector_fx.c index c4cc7d0db..8799806e4 100644 --- a/lib_enc/mdct_selector_fx.c +++ b/lib_enc/mdct_selector_fx.c @@ -315,11 +315,11 @@ void MDCT_selector_fx( test(); prefer_hq_core = ( LT_16( sub( Etot, sp_floor ), sig_lo_level_thr ) ) || /* noise floor is very high */ ( LT_16( cor_map_sum, cor_thr2 ) && LT_16( frame_voicing, voicing_thr2 ) && LT_16( sparseness, sparseness_thr2 ) ) || /* too weak tonal components */ - ( EQ_16( st->mdct_sw_enable, MODE1 ) && prefer_tcx == 0 && EQ_16( st->transientDetection.transientDetector.bIsAttackPresent, 1 ) ); + ( EQ_16( st->mdct_sw_enable, MODE1 ) && prefer_tcx == 0 && EQ_16( st->hTranDet->transientDetector.bIsAttackPresent, 1 ) ); /* Prefer HQ_CORE on transients */ test(); - IF( EQ_16( st->mdct_sw_enable, MODE2 ) && EQ_16( st->transientDetection.transientDetector.bIsAttackPresent, 1 ) ) + IF( EQ_16( st->mdct_sw_enable, MODE2 ) && EQ_16( st->hTranDet->transientDetector.bIsAttackPresent, 1 ) ) { prefer_tcx = 0; move16(); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 55e7437ee..ea94e6236 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -209,7 +209,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -393,8 +393,8 @@ void pre_proc_fx( test(); IF( st->tcx10Enabled || st->tcx20Enabled ) { - RunTransientDetection_fx( signal_in, input_frame, &st->transientDetection ); - currFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( &st->transientDetection, NSUBBLOCKS, 0 ); + RunTransientDetection_fx( signal_in, input_frame, st->hTranDet ); + currFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( st->hTranDet, NSUBBLOCKS, 0 ); } /*----------------------------------------------------------------* @@ -1261,7 +1261,7 @@ void pre_proc_fx( * TCX mode decision *---------------------------------------------------------------*/ - SetTCXModeInfo_fx( st, &st->transientDetection, &st->hTcxCfg->tcx_curr_overlap_mode ); + SetTCXModeInfo_fx( st, st->hTranDet, &st->hTcxCfg->tcx_curr_overlap_mode ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 28389e9e0..9d916f13a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -863,10 +863,6 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -); - void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ @@ -1044,14 +1040,16 @@ void calculate_hangover_attenuation_gain_fx( * Don't include the delay of the MDCT overlap. * @param pTransientDetection Structure to be initialized. It contains all transient detectors to be used. */ -void InitTransientDetection_fx( Word16 nFrameLength, - Word16 nTCXDelay, - struct TransientDetection *pTransientDetection ); +void InitTransientDetection_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet ); -void InitTransientDetection_ivas_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TRAN_DET_HANDLE pTransientDetection, - const Word16 ext_mem_flag ); +void InitTransientDetection_ivas_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet, + const Word16 ext_mem_flag ); /** Runs transient detection. * Runs all transient detectors defined in pTransientDetection @@ -1060,7 +1058,10 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, * @param nSamplesAvailable Number of new i samples available. * @param pTransientDetection Structure that contains transient detectors to be run. */ -void RunTransientDetection_fx( Word16 const *i, Word16 nSamplesAvailable, struct TransientDetection *pTransientDetection ); +void RunTransientDetection_fx( + Word16 const *i, + const Word16 nSamplesAvailable, + TRAN_DET_HANDLE hTranDet ); void RunTransientDetection_ivas_fx( @@ -1077,8 +1078,15 @@ void RunTransientDetection_ivas_fx( * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation. * @return average temporal flatness measure with exponent AVG_FLAT_E */ -Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ); -Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ); +Word16 GetTCXAvgTemporalFlatnessMeasure_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); + +Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); /** Get the maximum energy change using subblock energies aligned with the TCX. * @param pTransientDetection Structure that contains transient detectors to be run. @@ -1087,16 +1095,18 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation. * @param maximum energy change with exponent NRG_CHANGE_E */ -Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDetection, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); -Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); /** Set TCX window length and overlap configuration * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. @@ -1112,9 +1122,10 @@ void SetTCXModeInfo_ivas_fx( * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. * @param currEnergyHF current HF energy. Exponent must be the same as for prevEnergyHF. */ -void SetTCXModeInfo_fx( Encoder_State *st, - struct TransientDetection const *pTransientDetection, - Word16 *tcxModeOverlap ); +void SetTCXModeInfo_fx( + Encoder_State *st, + TRAN_DET_HANDLE hTranDet, + Word16 *tcxModeOverlap ); void GSC_enc_init_fx( GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */ @@ -2645,34 +2656,35 @@ Word16 vlpc_1st_cod_fx( const Word16 *lsf, /* i : vector to quantize , Word16 rf_mode ); -void tcx_ltp_encode_fx( Word16 tcxltp_on, - Word8 tcxOnly, - Word16 tcxMode, - Word16 L_frame, - Word16 L_subfr, - Word16 *speech, - Word16 *speech_ltp, - Word16 *wsp, - Word16 Top, - Word16 *ltp_param, - Word16 *ltp_bits, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *gain, - Word16 *pitch_int_past, - Word16 *pitch_fr_past, - Word16 *gain_past, - Word16 *norm_corr_past, - Word16 last_core, - Word16 pitmin, - Word16 pitfr1, - Word16 pitfr2, - Word16 pitmax, - Word16 pitres, - struct TransientDetection const *pTransientDetection, - Word8 SideInfoOnly, - Word16 *A, - Word16 lpcorder ); +void tcx_ltp_encode_fx( + Word16 tcxltp_on, + Word8 tcxOnly, + Word16 tcxMode, + Word16 L_frame, + Word16 L_subfr, + Word16 *speech, + Word16 *speech_ltp, + Word16 *wsp, + Word16 Top, + Word16 *ltp_param, + Word16 *ltp_bits, + Word16 *pitch_int, + Word16 *pitch_fr, + Word16 *gain, + Word16 *pitch_int_past, + Word16 *pitch_fr_past, + Word16 *gain_past, + Word16 *norm_corr_past, + Word16 last_core, + Word16 pitmin, + Word16 pitfr1, + Word16 pitfr2, + Word16 pitmax, + Word16 pitres, + TRAN_DET_HANDLE hTranDet, + Word8 SideInfoOnly, + Word16 *A, + Word16 lpcorder ); void tcx_ltp_encode_ivas_fx( Encoder_State *st, @@ -3513,8 +3525,9 @@ void re8_cod_fx( ); void TBEreset_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 bandwidth /* i : bandwidth mode */ + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const int16_t last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ ); void acelp_core_switch_enc_fx( @@ -4228,16 +4241,17 @@ void noise_est_init_ivas_fx( ); void InitSWBencBuffer_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); void InitSWBencBuffer_ivas_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); void ResetSHBbuffer_Enc_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); + Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); void acelp_1t64_fx( @@ -4588,8 +4602,9 @@ void destroy_encoder_fx( ); void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ + Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ const Word16 n_samples /* i : number of i samples Q0*/ ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index fdcff722c..760bbcb87 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -708,8 +708,6 @@ typedef struct sp_mus_clas_structure typedef struct lpd_state_structure { - - /* signal memory */ Word16 syn[1 + M]; /* Synthesis memory (non-pe) */ Word16 q_lpd_syn; @@ -803,7 +801,6 @@ typedef struct hq_enc_structure Word16 last_env_fx[BANDS_MAX]; /* Q1 */ Word16 last_max_pos_pulse; - } HQ_ENC_DATA, *HQ_ENC_HANDLE; /* PVQ range coder state */ @@ -1007,6 +1004,13 @@ typedef struct td_bwe_enc_structure Word16 gain_prec_swb_fx; /* Q14 */ Word16 mem_zero_swb_fx[LPC_SHB_ORDER]; + Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; + + Word16 prev_Q_bwe_exc; + Word16 prev_Q_bwe_syn; + } TD_BWE_ENC_DATA, *TD_BWE_ENC_HANDLE; @@ -1152,20 +1156,17 @@ typedef struct tcx_enc_structure Word16 transform_type[2]; /* TCX20/10/5 mode in each subframe */ /* Core Signal Analysis Outputs */ - Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling Q15 */ Word16 noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ Word16 ltpGainMemory_fx[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth Q15 */ STnsData tnsData[2]; - // Word16 fUseTns[2]; + Word8 fUseTns[2]; Word16 bTnsOnWhithenedSpectra[2]; - // Word16 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word8 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word16 *speech_TCX; Word16 *new_speech_TCX; - // Word16 q_speech_TCX; Word16 tcxltp; Word16 tcxltp_pitch_int; @@ -1219,17 +1220,9 @@ typedef struct tcx_enc_structure Word16 spectrum_long_e; /* MDCT output for a long block. Points to spectrum */ Word16 q_spectrum_long_fx; Word16 spectrum_length; /* corresponds to L_frameTCX, used for scaling of MDCT/MDST buffers */ + } TCX_ENC_DATA, *TCX_ENC_HANDLE; -typedef struct TransientDetection -{ - /** Transient detector. */ - TransientDetector transientDetector; - /** Delay buffer used by the transient detectors. */ - DelayBuffer delayBuffer; - /** Subblock energies used by the transient detector. */ - SubblockEnergies subblockEnergies; -} TransientDetection; /*----------------------------------------------------------------------------------* * @@ -1246,10 +1239,7 @@ typedef struct enc_core_structure Word16 idchan; /* channel ID (audio channel number) */ Word16 id_element; /* element ID */ Word16 element_mode; /* element mode */ - Word16 last_element_mode; /* element mode */ Word32 element_brate; /* element bitrate */ - Word16 extl_orig; /* extension layer */ - Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ Word16 last_codec_mode; /* previous frame Mode 1 or 2 */ Word16 last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ @@ -1258,9 +1248,7 @@ typedef struct enc_core_structure Word16 mdct_sw_enable; /* MDCT switching enable flag */ Word16 mdct_sw; /* MDCT switching indicator */ - BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ - Word16 last_enerBuffer_exp; - + BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ @@ -1299,34 +1287,8 @@ typedef struct enc_core_structure char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif #endif - Word16 nTimeSlots; /* for CLDFB */ - Word16 ini_frame; /* initialization frames counter */ - // Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ - // Word32 total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ - // Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - // Word32 core_brate_fx; /* core bitrate */ - // Word32 last_core_brate_fx; /* previous frame core bitrate */ - Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ - // Word16 extl_fx; /* extension layer */ - // Word16 last_extl_fx; /* previous extension layer */ - // Word32 extl_brate_fx; /* extension layer bitrate */ - // Word16 input_bwidth_fx; /* input signal bandwidth */ - // Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ - // Word16 max_bwidth_fx; /* maximum encoded bandwidth */ - // Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ - // Word16 L_frame_fx; /* ACELP core internal frame length */ - // Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - // Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ - // Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - // Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ - // Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ - /*----------------------------------------------------------------------------------* * ACELP core parameters *----------------------------------------------------------------------------------*/ @@ -1337,27 +1299,25 @@ typedef struct enc_core_structure Word16 fmerit_dt; /* signal classification score difference Q15 */ Word16 Nb_ACELP_frames; - Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ - // Word16 pitch_fx[3]; + Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ - Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ - Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 pstreaklen; /* LSF quantizer */ - Word16 streaklimit_fx; /* LSF quantizer Q15 */ - Word16 stab_fac_fx; /* LSF stability factor Q15 */ - Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ - Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ - Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ - // Word16 pstreaklen_fx; /* LSF quantizer */ + Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ + Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 pstreaklen; /* LSF quantizer */ + Word16 streaklimit_fx; /* LSF quantizer Q15 */ + Word16 stab_fac_fx; /* LSF stability factor Q15 */ + Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ + Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ + Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ @@ -1373,15 +1333,12 @@ typedef struct enc_core_structure Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ Word16 exp_old_wsp; Word16 Q_old_wsp2; - /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ Word16 old_wsp2_fx[( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ Word16 mem_wsp_fx; /* weighted signal vector memory */ Word16 mem_wsp_q; - Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ - Word16 mem_deemph_fx; /* deemphasis filter memory */ - Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ - Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ - Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ + Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ + Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ + Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ Word16 GSC_IVAS_mode; GSC_ENC_HANDLE hGSCEnc; @@ -1390,7 +1347,6 @@ typedef struct enc_core_structure Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame Qlog2(2.56) */ Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC Qlog2(2.56) */ Word16 next_force_safety_net; /* FEC - flag to force safety net in next frame */ - // Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ Word16 uv_count; /* Stationary noise UV modification - unvoiced counter */ Word16 act_count; /* Stationary noise UV modification - activation counter */ @@ -1476,7 +1432,7 @@ typedef struct enc_core_structure Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16 *buf_synth; /* can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ Word16 *buf_speech_enc; // exp_buf_speech_enc Word16 *buf_wspeech_enc; // exp_buf_wspeech_enc @@ -1487,6 +1443,8 @@ typedef struct enc_core_structure Word16 exp_buf_wspeech_enc; Word16 exp_buf_synth; + Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ + /*----------------------------------------------------------------------------------* * Noise estimation *----------------------------------------------------------------------------------*/ @@ -1499,8 +1457,6 @@ typedef struct enc_core_structure SP_MUS_CLAS_HANDLE hSpMusClas; - Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ - Word16 sp_aud_decision0; /* 1st stage speech/music decision flag */ Word16 sp_aud_decision1; /* 1st stage speech/music classification flag */ Word16 sp_aud_decision2; /* 2nd stage speech/music classification flag */ @@ -1539,9 +1495,6 @@ typedef struct enc_core_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc; /* main analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSynTd; /* synthesis filterbank - used for HB signal generation */ - // HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; - - // HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; /*----------------------------------------------------------------------------------* * FD CNG handle @@ -1572,7 +1525,6 @@ typedef struct enc_core_structure HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ - PVQ_ENC_HANDLE hPVQ; /*----------------------------------------------------------------------------------* * TD BWE parameters *----------------------------------------------------------------------------------*/ @@ -1671,13 +1623,11 @@ typedef struct enc_core_structure Word16 inv_gamma; /* Q14 */ TRAN_DET_HANDLE hTranDet; - TransientDetection transientDetection; - Word16 transient_info[3]; + Word16 acelpFramesCount; Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ Word32 prevTempFlatness_32fx; /* Q21 in IVAS */ - // float currEnergyLookAhead; Word32 currEnergyLookAhead_fx; // Q31 Word32 prevEnergyHF_fx; Word32 currEnergyHF_fx; @@ -1696,7 +1646,6 @@ typedef struct enc_core_structure Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ @@ -1773,8 +1722,7 @@ typedef struct enc_core_structure * IVAS parameters *---------------------------------------------------------------*/ - Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ - Word16 cna_dirac_flag; /* CNA in DirAC flag */ + Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ /* stereo switching memories */ Word16 mem_preemph_DFT_fx; /* Q(-1) */ @@ -1790,16 +1738,13 @@ typedef struct enc_core_structure Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ + Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + /*----------------------------------------------------------------------------------* * Fixed point only variables *----------------------------------------------------------------------------------*/ - Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ - Word16 Q_exc; - - Word16 prev_Q_bwe_exc; - Word16 prev_Q_bwe_syn; Word16 Q_stat_noise_ge; Word16 Q_stat_noise; Word16 Q_syn2; @@ -1813,13 +1758,8 @@ typedef struct enc_core_structure Word16 prev_Q_new; Word16 prev_Q_shb; Word16 Q_max_enc[2]; - Word16 EnergyLT_fx_exp; - Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; - Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; - Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; - - Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + Word16 last_enerBuffer_exp; } Encoder_State, *ENC_CORE_HANDLE; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 490d80aae..cd38203e9 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -417,12 +417,12 @@ void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ) * * Initialize SWB buffers *-------------------------------------------------------------------*/ + void InitSWBencBuffer_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { Word16 i; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; set16_fx( hBWE_TD->old_bwe_exc_fx, 0, ( PIT16k_MAX * 2 ) ); hBWE_TD->bwe_seed[0] = 23; @@ -446,15 +446,8 @@ void InitSWBencBuffer_fx( set16_fx( hBWE_TD->old_input_fhb_fx, 0, NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2 ); // IVAS_CODE - // set_f(hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER); - // set_f(hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k); - // hBWE_TD->old_mean_EnvSHBres = 0.0f; - // hBWE_TD->prev_enr_EnvSHBres = 1.0f; - // hBWE_TD->prev_shb_env_tilt = 0.0f; - // hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - // hBWE_TD->prev_mix_factor = 1.0f; - // hBWE_TD->prev_Env_error = 0.0f; - set16_fx( hBWE_TD->prev_lsp_shb_fx, 0, 10 ); + // InitSWBencBufferStates_fx(hBWE_TD, NULL ); + set16_fx( hBWE_TD->prev_lsp_shb_fx, 0, LPC_SHB_ORDER ); hBWE_TD->cldfbHBLT = 8192 /*1.0f Q13*/; move16(); @@ -504,25 +497,29 @@ void InitSWBencBuffer_fx( hBWE_TD->prev_fb_energy_fx_Q = 0; move16(); - - // TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD - st_fx->prev_Q_bwe_exc = 31; + hBWE_TD->prev_Q_bwe_exc = 31; move16(); - st_fx->prev_Q_bwe_syn = 31; + hBWE_TD->prev_Q_bwe_syn = 31; move16(); - set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 ); - set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 ); - set16_fx( st_fx->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); + set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); return; } + +/*-------------------------------------------------------------------* + * InitSWBencBufferStates() + * + * Initialize SWB buffer states + *-------------------------------------------------------------------*/ + void InitSWBencBuffer_ivas_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { Word16 i; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; set16_fx( hBWE_TD->old_bwe_exc_fx, 0, ( PIT16k_MAX * 2 ) ); hBWE_TD->bwe_seed[0] = 23; @@ -599,33 +596,30 @@ void InitSWBencBuffer_ivas_fx( set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, 12 ); set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); - hBWE_TD->prev_fb_energy_fx_Q = 0; move16(); - - // TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD - st_fx->prev_Q_bwe_exc = 15; + hBWE_TD->prev_Q_bwe_exc = 15; move16(); - st_fx->prev_Q_bwe_syn = 15; + hBWE_TD->prev_Q_bwe_syn = 15; move16(); - set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 ); - set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 ); - set16_fx( st_fx->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); + set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); return; } + /*-------------------------------------------------------------------* * ResetSHBbuffer_Enc() * *-------------------------------------------------------------------*/ + void ResetSHBbuffer_Enc_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - /* states for the filters used in generating SHB excitation from WB excitation*/ set16_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); @@ -656,7 +650,6 @@ void ResetSHBbuffer_Enc_fx( hBWE_TD->tbe_premph_fx = 0; move16(); - return; } @@ -804,11 +797,11 @@ void wb_tbe_enc_fx( move32(); } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; + hBWE_TD->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; move16(); } @@ -857,11 +850,11 @@ void wb_tbe_enc_fx( lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb[i] ), 1 ) ); move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); FOR( i = 0; i < LPC_SHB_ORDER_LBR_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -881,12 +874,12 @@ void wb_tbe_enc_fx( Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i * LPC_SHB_ORDER_LBR_WB, lsp_wb, LPC_SHB_ORDER_LBR_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, ( LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB ) ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } @@ -917,12 +910,11 @@ void wb_tbe_enc_fx( move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); - + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -942,12 +934,11 @@ void wb_tbe_enc_fx( } Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); - + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } FOR( i = 1; i < LPC_SHB_ORDER_WB + 1; i++ ) @@ -1000,9 +991,9 @@ void wb_tbe_enc_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ), n_mem ) ) { - Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); + Q_bwe_exc = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); } IF( uv_flag ) @@ -1018,7 +1009,7 @@ void wb_tbe_enc_fx( move32(); IF( st_fx->element_mode > EVS_MONO ) { - tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); + tmp = sub( shl( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) @@ -1026,7 +1017,7 @@ void wb_tbe_enc_fx( prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */ } - rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); + rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); @@ -1037,11 +1028,9 @@ void wb_tbe_enc_fx( } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, @@ -1064,8 +1053,7 @@ void wb_tbe_enc_fx( curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } - Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); - + Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), &exp ); FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { @@ -1146,7 +1134,6 @@ void wb_tbe_enc_fx( move16(); /* Q15 */ } - temp_wb_fac_fx = hBWE_TD->prev_wb_GainShape; move16(); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) @@ -1185,7 +1172,6 @@ void wb_tbe_enc_fx( EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); - /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ @@ -1239,7 +1225,6 @@ void wb_tbe_enc_fx( /*wbbwe_em_factor = add( mult_r( 29491, st_fx->prev_wbbwe_em_factor_fx ), mult_r( 3277, wbbwe_em_factor ) ); */ /* Q15 */ } - /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 ); FOR( i = 1; i < NB_SUBFR; i++ ) @@ -1271,7 +1256,7 @@ void wb_tbe_enc_fx( ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); return; @@ -1416,11 +1401,11 @@ void wb_tbe_enc_ivas_fx( move32(); } - lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; + hBWE_TD->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; move16(); } @@ -1469,11 +1454,11 @@ void wb_tbe_enc_ivas_fx( lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb[i] ), 1 ) ); move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); FOR( i = 0; i < LPC_SHB_ORDER_LBR_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -1493,12 +1478,12 @@ void wb_tbe_enc_ivas_fx( Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i * LPC_SHB_ORDER_LBR_WB, lsp_wb, LPC_SHB_ORDER_LBR_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, ( LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB ) ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } @@ -1529,12 +1514,11 @@ void wb_tbe_enc_ivas_fx( move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); - + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -1546,11 +1530,11 @@ void wb_tbe_enc_ivas_fx( push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } FOR( i = 1; i < LPC_SHB_ORDER_WB + 1; i++ ) @@ -1605,9 +1589,9 @@ void wb_tbe_enc_ivas_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ), n_mem ) ) { - Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); + Q_bwe_exc = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); } IF( uv_flag ) @@ -1632,7 +1616,7 @@ void wb_tbe_enc_ivas_fx( shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 ); move16(); } - Q_prev_pow = shl_r( sub( sub( st_fx->prev_Q_bwe_exc, 16 ), 3 ), 1 ); + Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 ); move16(); } ELSE @@ -1642,7 +1626,7 @@ void wb_tbe_enc_ivas_fx( shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i]; move16(); } - Q_prev_pow = shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ); + Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ); move16(); } @@ -1656,7 +1640,7 @@ void wb_tbe_enc_ivas_fx( prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */ } - rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); + rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); FOR( i = 0; i < L_FRAME32k; i++ ) @@ -1795,7 +1779,6 @@ void wb_tbe_enc_ivas_fx( move16(); /* Q15 */ } - temp_wb_fac_fx = hBWE_TD->prev_wb_GainShape; move16(); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) @@ -1930,7 +1913,6 @@ void wb_tbe_enc_ivas_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ - scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 ); scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 ); Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 ); @@ -1938,7 +1920,7 @@ void wb_tbe_enc_ivas_fx( &Q_bwe_exc_ext, &dummy, dummy, dummy ); Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 ); - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); return; @@ -2437,7 +2419,7 @@ void swb_tbe_enc_fx( /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_enc( st_fx, &n_mem, &n_mem2 ); - tmp2 = add( st_fx->prev_Q_bwe_exc, n_mem ); + tmp2 = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); if ( GT_16( Q_bwe_exc, tmp2 ) ) { Q_bwe_exc = tmp2; @@ -2445,7 +2427,7 @@ void swb_tbe_enc_fx( } /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ); + sc = sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ); IF( sc != 0 ) { rescale_genSHB_mem_enc( st_fx, sc ); @@ -2466,7 +2448,7 @@ void swb_tbe_enc_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); /* save the previous Q factor of the buffer */ - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ @@ -2487,7 +2469,7 @@ void swb_tbe_enc_fx( coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0 ); + &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, 0 ); *Q_white_exc = Q_bwe_exc_fb; move16(); @@ -2520,7 +2502,7 @@ void swb_tbe_enc_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) ); + hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_syn ) ); move16(); } @@ -2528,12 +2510,9 @@ void swb_tbe_enc_fx( { PostShortTerm_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); - /* i: shaped_shb_excitation_fx in Q_bwe_exc */ - /* i: lpc_shb_fx in Q12 */ } Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); - tmp = sub( shl( Q_bwe_exc, 1 ), 31 ); prev_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ @@ -2909,7 +2888,7 @@ void swb_tbe_enc_fx( } /* *Q_white_exc = Q_bwe_exc_mod; move16(); output Qwhiteexc_FB from the GenShapedSHB function*/ - st_fx->prev_Q_bwe_syn = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_syn = Q_bwe_exc; move16(); return; @@ -3744,7 +3723,7 @@ void swb_tbe_enc_ivas_fx( /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_enc( st_fx, &n_mem, &n_mem2 ); - tmp2 = add( st_fx->prev_Q_bwe_exc, n_mem ); + tmp2 = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); if ( GT_16( Q_bwe_exc, tmp2 ) ) { Q_bwe_exc = tmp2; @@ -3752,7 +3731,7 @@ void swb_tbe_enc_ivas_fx( } /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ); + sc = sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ); IF( sc != 0 ) { rescale_genSHB_mem_enc( st_fx, sc ); @@ -3770,7 +3749,7 @@ void swb_tbe_enc_ivas_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); /* save the previous Q factor of the buffer */ - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ @@ -3783,7 +3762,7 @@ void swb_tbe_enc_ivas_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, - &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, + &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag, EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); @@ -3835,7 +3814,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) ); + hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_syn ) ); move16(); } @@ -4184,7 +4163,6 @@ void swb_tbe_enc_ivas_fx( } } - hBWE_TD->prev_swb_GainShape_fx = GainShape_fx[3]; move16(); @@ -4200,7 +4178,6 @@ void swb_tbe_enc_ivas_fx( /* Quantization of the gain shape parameter */ QuantizeSHBsubgains_ivas_fx( st_fx, GainShape_fx, st_fx->extl ); - /* o: GainShape_fx in Q15 */ /* Compute the power of gains away from the peak gain after quantization */ IF( st_fx->element_mode > EVS_MONO ) @@ -4568,7 +4545,7 @@ void swb_tbe_enc_ivas_fx( move16(); /* *Q_white_exc = Q_bwe_exc_mod; move16(); output Qwhiteexc_FB from the GenShapedSHB function*/ - st_fx->prev_Q_bwe_syn = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_syn = Q_bwe_exc; move16(); return; @@ -7051,7 +7028,7 @@ static void first_VQstages_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -7902,22 +7879,23 @@ void tbe_write_bitstream_fx( { push_next_indice( hBstr, hBWE_TD->idxGain, 4 ); } + + return; } void TBEreset_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 bandwidth /* i : bandwidth mode */ + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const int16_t last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ ) { - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - - IF( NE_16( st_fx->last_core, ACELP_CORE ) ) + IF( NE_16( last_core, ACELP_CORE ) ) { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); move32(); - st_fx->prev_Q_bwe_exc = 31; + hBWE_TD->prev_Q_bwe_exc = 31; move16(); } @@ -7947,6 +7925,8 @@ void TBEreset_enc_fx( fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } } + + return; } /*-------------------------------------------------------------------* diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index a3d8620a4..48067948b 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -606,34 +606,35 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec move16(); } -void tcx_ltp_encode_fx( Word16 tcxltp_on, - Word8 tcxOnly, - Word16 tcxMode, - Word16 L_frame, - Word16 L_subfr, - Word16 *speech, - Word16 *speech_ltp, - Word16 *wsp, - Word16 Top, - Word16 *ltp_param, - Word16 *ltp_bits, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *gain, - Word16 *pitch_int_past, - Word16 *pitch_fr_past, - Word16 *gain_past, - Word16 *norm_corr_past, - Word16 last_core, - Word16 pitmin, - Word16 pitfr1, - Word16 pitfr2, - Word16 pitmax, - Word16 pitres, - struct TransientDetection const *pTransientDetection, - Word8 SideInfoOnly, - Word16 *A, - Word16 lpcorder ) +void tcx_ltp_encode_fx( + Word16 tcxltp_on, + Word8 tcxOnly, + Word16 tcxMode, + Word16 L_frame, + Word16 L_subfr, + Word16 *speech, + Word16 *speech_ltp, + Word16 *wsp, + Word16 Top, + Word16 *ltp_param, + Word16 *ltp_bits, + Word16 *pitch_int, + Word16 *pitch_fr, + Word16 *gain, + Word16 *pitch_int_past, + Word16 *pitch_fr_past, + Word16 *gain_past, + Word16 *norm_corr_past, + Word16 last_core, + Word16 pitmin, + Word16 pitfr1, + Word16 pitfr2, + Word16 pitmax, + Word16 pitres, + TRAN_DET_HANDLE hTranDet, + Word8 SideInfoOnly, + Word16 *A, + Word16 lpcorder ) { Word16 n; Word16 norm_corr; @@ -687,11 +688,9 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) ); nPrevSubblocks = add( s_min( nPrevSubblocks, NSUBBLOCKS ), 1 ); - tempFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( pTransientDetection, NSUBBLOCKS, nPrevSubblocks ); + tempFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( hTranDet, NSUBBLOCKS, nPrevSubblocks ); - maxEnergyChange = GetTCXMaxenergyChange_fx( pTransientDetection, - (const Word8) isTCX10, - NSUBBLOCKS, nPrevSubblocks ); + maxEnergyChange = GetTCXMaxenergyChange_fx( hTranDet, (const Word8) isTCX10, NSUBBLOCKS, nPrevSubblocks ); /* Switch LTP on */ test(); @@ -1059,15 +1058,13 @@ void tcx_ltp_encode_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { - tempFlatness_fx = extract_l( L_shr( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ), 14 ) ); // Q7 - maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, - NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ); // Q3 + tempFlatness_fx = extract_l( L_shr( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ), 14 ) ); // Q7 + maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ); // Q3 } ELSE { - tempFlatness_fx = extract_l( L_shr( ( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, nPrevSubblocks ) ), 14 ) ); // Q7 - maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, - NSUBBLOCKS, nPrevSubblocks ); // Q3 + tempFlatness_fx = extract_l( L_shr( ( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, nPrevSubblocks ) ), 14 ) ); // Q7 + maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, NSUBBLOCKS, nPrevSubblocks ); // Q3 } /* Switch LTP on */ diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 1ad69a330..e0fff2da5 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -333,52 +333,68 @@ static void InitTCXTransientDetector( Word16 nDelay, SubblockEnergies *pSubblock /* */ /************************************************/ -void InitTransientDetection_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TransientDetection *pTransientDetection ) +void InitTransientDetection_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet ) { /* Init the delay buffer. */ - InitDelayBuffer( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer ); + InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer ); + /* Init a subblock energies buffer used for the TCX Short/Long decision. */ - InitSubblockEnergies( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); + InitSubblockEnergies( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies ); + /* Init the TCX Short/Long transient detector. */ - InitTCXTransientDetector( nTCXDelay, &pTransientDetection->subblockEnergies, &pTransientDetection->transientDetector ); + InitTCXTransientDetector( nTCXDelay, &hTranDet->subblockEnergies, &hTranDet->transientDetector ); + /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + + return; } -void InitTransientDetection_ivas_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TRAN_DET_HANDLE pTransientDetection, - const Word16 ext_mem_flag ) + +void InitTransientDetection_ivas_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet, + const Word16 ext_mem_flag ) { /* Init the delay buffer. */ - InitDelayBuffer( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer ); + InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer ); + /* Init a subblock energies buffer used for the TCX Short/Long decision. */ - InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); + InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies ); + /* Init the TCX Short/Long transient detector. */ - InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<transientDetector ); + InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<transientDetector ); + /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ IF( ext_mem_flag ) { - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) ); move16(); } ELSE { - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); move16(); } + + return; } /** * \brief Calculate average of temporal energy change. * \return average temporal energy change with exponent = 8 */ -Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ) +Word16 GetTCXAvgTemporalFlatnessMeasure_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -389,9 +405,8 @@ Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTr Word32 sumTempFlatness; Word16 nTotBlocks; - /* Initialization */ - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); nDelay = pTransientDetector->nDelay; @@ -419,7 +434,11 @@ Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTr return i; } -Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ) + +Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word32 i; TransientDetector const *pTransientDetector; @@ -432,7 +451,7 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const Word16 nTotBlocks, sumTempFlatness_exp, exp; /* Initialization */ - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; nDelay = pTransientDetector->nDelay; move16(); @@ -464,10 +483,11 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const return i; } -Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDetection, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ) +Word16 GetTCXMaxenergyChange_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -478,8 +498,7 @@ Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDete Word16 maxEnergyChange; Word16 nTotBlocks; - - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); nDelay = pTransientDetector->nDelay; @@ -543,10 +562,11 @@ Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDete } -Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ) +Word16 GetTCXMaxenergyChange_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -558,7 +578,6 @@ Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, Word16 maxEnergyChange; Word16 nTotBlocks; - pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); @@ -620,13 +639,17 @@ Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, return i; } -void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, TransientDetection *pTransientDetection ) + +void RunTransientDetection_fx( + Word16 const *input, + const Word16 nSamplesAvailable, + TRAN_DET_HANDLE hTranDet ) { Word16 filteredInput[L_FRAME48k]; - SubblockEnergies *pSubblockEnergies = &pTransientDetection->subblockEnergies; - TransientDetector *pTransientDetector = &pTransientDetection->transientDetector; + SubblockEnergies *pSubblockEnergies = &hTranDet->subblockEnergies; + TransientDetector *pTransientDetector = &hTranDet->transientDetector; - assert( ( input != NULL ) && ( pTransientDetection != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); + assert( ( input != NULL ) && ( hTranDet != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); HighPassFilter_fx( input, nSamplesAvailable, &pSubblockEnergies->firState1, &pSubblockEnergies->firState2, filteredInput ); @@ -637,7 +660,9 @@ void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, Tr RunTransientDetector_fx( pTransientDetector ); /* Update the delay buffer. */ - UpdateDelayBuffer( filteredInput, nSamplesAvailable, &pTransientDetection->delayBuffer ); + UpdateDelayBuffer( filteredInput, nSamplesAvailable, &hTranDet->delayBuffer ); + + return; } @@ -865,7 +890,7 @@ void SetTCXModeInfo_ivas_fx( move16(); } } - tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); + tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); tmp = shl_sat( tmp, exp_diff ); // Q15 test(); IF( isLongTermTransient_fx( L_deposit_h( tmp ), &hTcxEnc->tfm_mem_fx ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -895,7 +920,7 @@ void SetTCXModeInfo_ivas_fx( *tcxModeOverlap = ALDO_WINDOW; move16(); } - tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); + tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); tmp = shl_sat( tmp, exp_diff ); // Q15 test(); IF( isLongTermTransient_fx( L_deposit_h( tmp ), &hTcxEnc->tfm_mem_fx ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -933,13 +958,14 @@ void SetTCXModeInfo_ivas_fx( } -void SetTCXModeInfo_fx( Encoder_State *st, - TransientDetection const *pTransientDetection, - Word16 *tcxModeOverlap ) +void SetTCXModeInfo_fx( + Encoder_State *st, + TRAN_DET_HANDLE hTranDet, + Word16 *tcxModeOverlap ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - assert( pTransientDetection != NULL ); + assert( hTranDet != NULL ); IF( EQ_16( st->codec_mode, MODE2 ) ) { @@ -953,7 +979,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, test(); test(); test(); - IF( ( ( pTransientDetection->transientDetector.bIsAttackPresent != 0 ) || ( GT_32( Mpy_32_16_1( st->currEnergyHF_fx, 840 /*1.0f/39.0f Q15*/ ), st->prevEnergyHF_fx ) ) ) && ( ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) ) + IF( ( ( hTranDet->transientDetector.bIsAttackPresent != 0 ) || ( GT_32( Mpy_32_16_1( st->currEnergyHF_fx, 840 /*1.0f/39.0f Q15*/ ), st->prevEnergyHF_fx ) ) ) && ( ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) ) { move16(); hTcxEnc->tcxMode = TCX_10; @@ -1005,7 +1031,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) ) { - IF( pTransientDetection->transientDetector.attackIndex < 0 ) + IF( hTranDet->transientDetector.attackIndex < 0 ) { move16(); *tcxModeOverlap = HALF_OVERLAP; @@ -1013,7 +1039,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, ELSE { move16(); - *tcxModeOverlap = s_and( pTransientDetection->transientDetector.attackIndex, 3 ); + *tcxModeOverlap = s_and( hTranDet->transientDetector.attackIndex, 3 ); if ( EQ_16( *tcxModeOverlap, 1 ) ) { move16(); @@ -1023,12 +1049,12 @@ void SetTCXModeInfo_fx( Encoder_State *st, } ELSE IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) { - IF( EQ_16( pTransientDetection->transientDetector.attackIndex, 7 ) ) + IF( EQ_16( hTranDet->transientDetector.attackIndex, 7 ) ) { move16(); *tcxModeOverlap = HALF_OVERLAP; } - ELSE IF( EQ_16( pTransientDetection->transientDetector.attackIndex, 6 ) ) + ELSE IF( EQ_16( hTranDet->transientDetector.attackIndex, 6 ) ) { move16(); *tcxModeOverlap = MIN_OVERLAP; -- GitLab From 683b9958baf962a5d718d9d463da2d7bb11552f3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 21 Sep 2025 22:26:11 +0200 Subject: [PATCH 2/3] clang-format --- lib_enc/pre_proc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 08d225f98..29a0aa229 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -209,7 +209,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 734f09e41..927120771 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -6998,7 +6998,7 @@ static void first_VQstages_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ -- GitLab From dc58f48f0005838b3b6e5ce8403852634d0b59d5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 1 Oct 2025 23:33:58 +0200 Subject: [PATCH 3/3] number -> macro --- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 7159b507d..787e5f701 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -108,7 +108,7 @@ void amr_wb_enc_fx( move16(); st->coder_type = GENERIC; move16(); - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); move16(); /* frame length of the input signal */ st->extl = -1; move16(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 90d5a7b4b..3380583c0 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -100,7 +100,7 @@ ivas_error evs_enc_fx( * Initializiation *-----------------------------------------------------------------*/ - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); move16(); st->core = -1; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0439a4720..487b42bf7 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -36,7 +36,7 @@ ivas_error init_encoder_fx( error = IVAS_ERR_OK; - input_frame = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st_fx->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*-----------------------------------------------------------------* * General signal buffers @@ -1004,7 +1004,7 @@ ivas_error init_encoder_ivas_fx( error = IVAS_ERR_OK; move32(); - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*-----------------------------------------------------------------* * General parameters -- GitLab