From 187699e595d513c292485347239f52fec791e0c0 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 28 Nov 2024 18:21:48 +0530 Subject: [PATCH] Encoder cleanup changes, ltv crash fixes for original, 10dB and -10dB inputs --- lib_com/ivas_prot.h | 26 +- lib_com/ivas_prot_fx.h | 2 +- lib_enc/analy_sp_fx.c | 41 +- lib_enc/cod_tcx_fx.c | 4 +- lib_enc/core_enc_init.c | 15 +- lib_enc/core_switching_enc.c | 6 +- lib_enc/igf_enc.c | 7 +- lib_enc/init_enc.c | 16 +- lib_enc/init_enc_fx.c | 1 + lib_enc/ivas_core_enc.c | 143 ++++-- lib_enc/ivas_core_pre_proc.c | 11 +- lib_enc/ivas_core_pre_proc_front.c | 157 +++--- lib_enc/ivas_cpe_enc.c | 63 +-- lib_enc/ivas_front_vad.c | 8 +- lib_enc/ivas_ism_enc.c | 17 +- lib_enc/ivas_mct_enc.c | 8 +- lib_enc/ivas_mdct_core_enc.c | 190 ++++---- lib_enc/ivas_sce_enc.c | 21 +- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/ivas_stereo_mdct_core_enc.c | 715 +++++++--------------------- lib_enc/ivas_stereo_switching_enc.c | 2 +- lib_enc/nois_est_fx.c | 4 +- lib_enc/prot_fx_enc.h | 6 +- lib_enc/stat_enc.h | 82 ++-- 24 files changed, 613 insertions(+), 934 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index caa307e44..743dc0a07 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -240,7 +240,8 @@ ivas_error pre_proc_front_ivas_fx( Word16 *relE_fx, /* o : frame relative energy Q8 */ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* o : LP prediction errors */ + Word32 epsP_fx[M + 1], /* o : LP prediction errors */ + Word16 *epsP_fx_q, Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */ Word16 *vad_hover_flag, /* o : VAD hangover flag */ @@ -262,11 +263,14 @@ ivas_error pre_proc_front_ivas_fx( const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */ const Word16 currFlatness_fx, /* i : flatness parameter Q7 */ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */ - float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */ + Word16 fr_bands_LR_fx_q, const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */ + Word16 lf_E_LR_fx_q, const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */ + Word16 band_energies_LR_fx_q, const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const Word16 force_front_vad, /* i : flag to force VAD decision */ @@ -289,7 +293,8 @@ ivas_error pre_proc_ivas( Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q6 */ Word16 A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* i/o: LP prediction errors */ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */ + Word16 *epsP_fx_q, /* i : LP prediction errors */ Word16 lsp_new[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid[M], /* i/o: LSPs in the middle of the frame */ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ @@ -529,14 +534,15 @@ ivas_error ivas_core_enc( Word32 ener_fx[], /* i : residual energy from Levinson-Durbin Q6*/ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes*/ - float epsP[][M + 1], /* i : LP prediction errors */ + Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */ + Word16 epsP_fx_q[], /* i : LP prediction errors */ Word16 lsp_new[][M], /* i : LSPs at the end of the frame Q15 */ Word16 lsp_mid[][M], /* i : LSPs in the middle of the frame Q15 */ const int16_t vad_hover_flag[], /* i : VAD hanglover flag */ int16_t attack_flag[], /* i : attack flag (GSC or TC) */ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - Word16 q_re_im_buf, + Word16 *q_re_im_buf, float old_wsp[][L_WSP], /* i : weighted input signal buffer */ const int16_t loc_harm[], /* i : harmonicity flag */ const Word16 cor_map_sum[], /* i : speech/music clasif. parameter Q8 */ @@ -2494,10 +2500,10 @@ void stereo_mdct_core_enc( float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ ); #else -void stereo_mdct_core_enc( +void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ - float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ + Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ ); #endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c477b0baf..5a71e41c7 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4495,7 +4495,7 @@ void EstimateStereoTCXNoiseLevel_fx( Encoder_State **sts, /* i : state handle */ Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */ Word16 gain_tcx[][NB_DIV], /* i : global gain */ - Word16 gain_tcx_e, /* i : global gain exponent */ + Word16 gain_tcx_e[][NB_DIV], /* i : global gain exponent */ Word16 L_frame[][NB_DIV], /* i : frame length */ Word16 noiseFillingBorder[][NB_DIV], /* i : noise filling border */ Word16 hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */ diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6215651cc..df9cddf22 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -216,7 +216,7 @@ static void find_enr_dft_fx( Word32 *Bin_E_fx, /* o : Per bin energy (Q7) */ Word32 *band_ener_fx, /* o : per band energy without E_MIN (Qout) */ Word16 Q_inp_dmx, - Word16 Qout ) + Word16 *Qout ) { Word16 i, cnt; Word32 tmp_fx; @@ -308,7 +308,7 @@ static void find_enr_dft_fx( ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q31 - gaurded_bits + ngmult_exp BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31 move32(); - BinE_fx[bin_cnt] = L_shl( BinE_fx[bin_cnt], sub( Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) ); + BinE_fx[bin_cnt] = L_shl( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) ); move32(); band_fx[i] = L_add( BinE_fx[bin_cnt], band_fx[i] ); move32(); @@ -324,9 +324,9 @@ static void find_enr_dft_fx( move32(); band_ener_fx[i] = band_fx[i]; /* per band energy without E_MIN */ move32(); - if ( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( Qout, Q11 ) ) ) ) + IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) ) { - band_fx[i] = L_shl( E_MIN_Q11_FX, sub( Qout, Q11 ) ); + band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ); move32(); } } @@ -370,7 +370,7 @@ static void find_enr_dft_fx( ngmult = W_shl( ngmult, ngmult_exp ); // Q31 + Q31 - gaurded_bits + ngmult_exp BinE_fx[bin_cnt] = Mpy_32_32( W_extract_h( ngmult ), BinE_fx[bin_cnt] ); //(Q31 + Q31 - gaurded_bits + ngmult_exp) - Q32 + (2 * Q_inp_dmx + te_exp - 32) - 31 move32(); - BinE_fx[bin_cnt] = L_shl( BinE_fx[bin_cnt], sub( Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) ); + BinE_fx[bin_cnt] = L_shl( BinE_fx[bin_cnt], sub( *Qout, sub( sub( add( add( shl( Q_inp_dmx, 1 ), te_exp ), ngmult_exp ), 34 ), guarded_bits ) ) ); move32(); band_fx[i] = L_add( BinE_fx[bin_cnt], band_fx[i] ); move32(); @@ -385,9 +385,9 @@ static void find_enr_dft_fx( move32(); band_ener_fx[i] = band_fx[i]; move32(); - if ( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( Qout, Q11 ) ) ) ) + IF( LT_32( band_fx[i], L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ) ) ) { - band_fx[i] = L_shl( E_MIN_Q11_FX, sub( Qout, Q11 ) ); + band_fx[i] = L_shl( E_MIN_Q11_FX, sub( *Qout, Q11 ) ); move32(); } } @@ -397,7 +397,7 @@ static void find_enr_dft_fx( assert( bin_cnt == ( STEREO_DFT_N_12k8_ENC / 2 - 1 ) ); BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 1] = BinE_fx[STEREO_DFT_N_12k8_ENC / 2 - 2]; move32(); - L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, &Qout ); + L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, Qout ); MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // Qout /* find the total log energy */ @@ -518,10 +518,8 @@ void ivas_analy_sp_fx( } ELSE { - Word16 Q_inp_dmx = Q_factor_arrL( hCPE->hStereoDft->DFT[0], STEREO_DFT_N_MAX_ENC ); - floatToFixed_arrL( hCPE->hStereoDft->DFT[0], hCPE->hStereoDft->DFT_fx[0], Q_inp_dmx, STEREO_DFT_N_MAX_ENC ); Word16 Qout = add( Q_new, QSCALE - 2 ); - find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, Q_inp_dmx, Qout ); + find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout ); MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); @@ -583,10 +581,10 @@ void ivas_analy_sp_fx_front( Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */ Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */ Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */ - Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */ + Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */ Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ - Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/ - Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */ + Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/ + Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */ ) { Word16 *pt; @@ -651,7 +649,9 @@ void ivas_analy_sp_fx_front( } ELSE { - find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), add( Q_new, QSCALE - 2 ) ); + Word16 Qout = add( Q_new, QSCALE - 2 ); + find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout ); + scale_sig32( lf_E, VOIC_BINS, sub( add( Q_new, QSCALE - 2 ), Qout ) ); MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); @@ -668,9 +668,10 @@ void ivas_analy_sp_fx_front( } ELSE { - temp32_log = BASOP_Util_Log10( L_shr( LEtot, 1 ), sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25 - temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 - *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8 + /* log10( LEtot / 2 ) = log10( LEtot ) - log10( 2 ) */ + temp32_log = L_sub( BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ), LOG10_2_Q31 >> Q6 ); // Q25 + temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 + *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8 move16(); } @@ -1050,7 +1051,7 @@ static void ivas_find_enr1( band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE move32(); - band_energies[i] = L_shl( band[i], Q2 ); /* per band energy without E_MIN */ // Q_new + QSCALE + 2 + band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE move32(); if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE @@ -1098,7 +1099,7 @@ static void ivas_find_enr1( band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE move32(); - band_energies[i] = L_shl( band[i], Q2 ); /* per band energy without E_MIN */ // Q_new + QSCALE + 2 + band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE move32(); if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 110e2a63c..1de9482c0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1714,7 +1714,7 @@ void EstimateStereoTCXNoiseLevel_fx( Encoder_State **sts, /* i : state handle */ Word32 *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */ Word16 gain_tcx[][NB_DIV], /* i : global gain */ - Word16 gain_tcx_e, /* i : global gain exponent */ + Word16 gain_tcx_e[][NB_DIV], /* i : global gain exponent */ Word16 L_frame[][NB_DIV], /* i : frame length */ Word16 noiseFillingBorder[][NB_DIV], /* i : noise filling border */ Word16 hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */ @@ -1821,7 +1821,7 @@ void EstimateStereoTCXNoiseLevel_fx( hTcxEnc->spectrum_e[n] = add( hTcxEnc->spectrum_e[n], Q1 ); move16(); } - tcx_noise_factor_ivas_fx( hTcxEnc->spectrum_fx[n], hTcxEnc->spectrum_e[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], gain_tcx_e, hTcxEnc->noiseTiltFactor, &fac_ns[ch][n], fac_ns_q, st->element_mode ); + tcx_noise_factor_ivas_fx( hTcxEnc->spectrum_fx[n], hTcxEnc->spectrum_e[n], combined_q_spectrum, iStart, maxNfCalcBw, noiseTransWidth, L_frame[ch][n], gain_tcx[ch][n], gain_tcx_e[ch][n], hTcxEnc->noiseTiltFactor, &fac_ns[ch][n], fac_ns_q, st->element_mode ); /* hysteresis for very tonal passages (more stationary noise filling level) */ IF( EQ_16( *fac_ns_q, 1 ) ) diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index 5c6a8e065..20587deed 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -826,7 +826,7 @@ static void init_sig_buffers( set_zero( st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); if ( hTcxEnc != NULL ) { - set_zero( hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // set_zero( hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } } else if ( st->L_frame != L_frame_old && !( ( total_brate >= ACELP_16k40 && total_brate <= ACELP_24k40 ) && @@ -836,7 +836,9 @@ static void init_sig_buffers( if ( ( st->last_core != TCX_20_CORE ) && ( st->last_core != TCX_10_CORE ) ) { - mvr2r( st->buf_speech_enc_flt, hTcxEnc->buf_speech_ltp_flt, st->L_frame ); +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arr( st->buf_speech_enc_flt, st->buf_speech_enc, 0, st->L_frame ); +#endif } mvr2r( st->old_wsp, st->buf_wspeech_enc_flt + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); @@ -875,7 +877,7 @@ static void init_sig_buffers( if ( hTcxEnc != NULL ) { - hTcxEnc->new_speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc + st->encoderLookahead_enc; + // hTcxEnc->new_speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc + st->encoderLookahead_enc; } if ( st->hTcxEnc != NULL ) @@ -889,7 +891,7 @@ static void init_sig_buffers( if ( hTcxEnc != NULL ) { - hTcxEnc->speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc; + // hTcxEnc->speech_ltp_flt = hTcxEnc->buf_speech_ltp_flt + st->encoderPastSamples_enc; } if ( st->element_mode > EVS_MONO ) @@ -900,12 +902,13 @@ static void init_sig_buffers( { st->wspeech_enc_flt = st->buf_wspeech_enc_flt + st->L_frame + L_subfr; } - +#ifndef IVAS_FLOAT_FIXED if ( st->ini_frame == 0 || st->L_frame != L_frame_old || st->last_codec_mode == MODE1 ) { set_zero( st->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); } st->synth_flt = st->buf_synth_flt + st->L_frame + L_subfr; +#endif return; } @@ -1299,7 +1302,7 @@ static void init_acelp( st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; /*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/ - set_f( st->hTcxEnc->old_out, 0, st->L_frame ); + // set_f( st->hTcxEnc->old_out, 0, st->L_frame ); } else { diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index ee73fd8b2..d3820e677 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -130,7 +130,7 @@ void core_switching_pre_enc( /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ if ( st->element_mode == EVS_MONO && st->hTcxEnc != NULL ) { - set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); } } if ( st->L_frame == L_FRAME16k && st->last_L_frame == L_FRAME ) @@ -174,7 +174,7 @@ void core_switching_pre_enc( if ( st->hTcxEnc != NULL ) { - set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); } } @@ -1193,7 +1193,7 @@ void core_switching_hq_prepare_enc( /* reset state of old_out if switching */ if ( st->hTcxEnc != NULL ) { - set_f( st->hTcxEnc->old_out, 0.0f, L_FRAME32k ); + // set_f( st->hTcxEnc->old_out, 0.0f, L_FRAME32k ); } return; diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 0cd4a48b9..58148b433 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1198,6 +1198,8 @@ static void IGF_CalculateEnvelope_ivas_fx( x = 1; mean_x_fx = mean_y_fx = 0; + Word32 mean_y_fx_tmp = 0; + move32(); mean_xy_fx = mean_x2_fx = 0; mean_x_e = mean_y_e = 15; mean_xy_e = mean_x2_e = 31; @@ -1227,12 +1229,13 @@ static void IGF_CalculateEnvelope_ivas_fx( { y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps, Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/ } - mean_y_fx = add( mean_y_fx, y ); /*Q0*/ + mean_y_fx_tmp = L_mac0( mean_y_fx_tmp, y, 1 ); /*Q0*/ mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/ x = add( x, 1 ); } - mean_y_fx = BASOP_Util_Divide1616_Scale( mean_y_fx, width, &tmp_e ); /* mean_y_e*/ + mean_y_fx = BASOP_Util_Divide3216_Scale( mean_y_fx_tmp, width, &tmp_e ); /* mean_y_e*/ + mean_y_e = add( mean_y_e, sub( tmp_e, 15 ) ); mean_x_fx = BASOP_Util_Divide1616_Scale( mean_x_fx, width, &tmp_e ); /* mean_x_e*/ mean_x_e = add( mean_x_e, sub( tmp_e, 15 ) ); diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 8f8541724..af572fda1 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -426,7 +426,9 @@ ivas_error init_encoder( st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; #endif st->buf_speech_enc_pe_flt = st->hSignalBuf->buf_speech_enc_pe_flt; +#ifndef IVAS_FLOAT_FIXED st->buf_synth_flt = st->hSignalBuf->buf_synth_flt; +#endif st->buf_speech_enc_flt = st->hSignalBuf->buf_speech_enc_flt; st->buf_wspeech_enc_flt = st->hSignalBuf->buf_wspeech_enc_flt; @@ -492,7 +494,9 @@ ivas_error init_encoder( st->old_inp_12k8 = NULL; st->old_inp_16k = NULL; st->buf_speech_enc_pe_flt = NULL; +#ifndef IVAS_FLOAT_FIXED st->buf_synth_flt = NULL; +#endif st->buf_speech_enc_flt = NULL; #ifdef IVAS_FLOAT_FIXED st->buf_speech_enc = NULL; @@ -1008,7 +1012,12 @@ ivas_error init_encoder( set32_fx( st->hTcxEnc->spectrum_fx[0], 0, N_TCX10_MAX ); set32_fx( st->hTcxEnc->spectrum_fx[1], 0, N_TCX10_MAX ); #endif +#ifdef IVAS_FLOAT_FIXED + set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st->hTcxEnc->Q_old_out = 0; +#else set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); +#endif /* MDCT selector */ #ifndef IVAS_FLOAT_FIXED @@ -1599,7 +1608,9 @@ ivas_error init_encoder_ivas_fx( st->old_inp_12k8 = st->hSignalBuf->old_inp_12k8_flt; st->old_inp_16k = st->hSignalBuf->old_inp_16k_flt; st->buf_speech_enc_pe_flt = st->hSignalBuf->buf_speech_enc_pe_flt; +#ifndef IVAS_FLOAT_FIXED st->buf_synth_flt = st->hSignalBuf->buf_synth_flt; +#endif st->buf_speech_enc_flt = st->hSignalBuf->buf_speech_enc_flt; st->buf_wspeech_enc_flt = st->hSignalBuf->buf_wspeech_enc_flt; set_f( st->mem_decim, 0, 2 * L_FILT_MAX ); @@ -1640,7 +1651,9 @@ ivas_error init_encoder_ivas_fx( st->old_inp_12k8 = NULL; st->old_inp_16k = NULL; st->buf_speech_enc_pe_flt = NULL; +#ifndef IVAS_FLOAT_FIXED st->buf_synth_flt = NULL; +#endif st->buf_speech_enc_flt = NULL; st->buf_wspeech_enc_flt = NULL; st->input_buff = NULL; @@ -2129,10 +2142,11 @@ ivas_error init_encoder_ivas_fx( set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long; st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX; - set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); #endif set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st->hTcxEnc->Q_old_out = 0; /* MDCT selector */ MDCT_selector_reset_fx( st->hTcxEnc ); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 3c1124e95..803dbe595 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -782,6 +782,7 @@ ivas_error init_encoder_fx( st_fx->hTcxEnc->spectrum[1] = st_fx->hTcxEnc->spectrum_long + N_TCX10_MAX;*/ set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st_fx->hTcxEnc->Q_old_out = 0; /* MDCT selector */ MDCT_selector_reset_fx( st_fx->hTcxEnc ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index e01a915e8..cb523675e 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -66,14 +66,15 @@ ivas_error ivas_core_enc( Word32 ener_fx[], /* i : residual energy from Levinson-Durbin Q6 */ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */ - float epsP[][M + 1], /* i : LP prediction errors */ + Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q */ + Word16 epsP_fx_q[], /* i : LP prediction errors */ Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15 */ const int16_t vad_hover_flag[], /* i : VAD hanglover flag */ int16_t attack_flag[], /* i : attack flag (GSC or TC) */ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - Word16 q_re_im_buf, + Word16 *q_re_im_buf, float old_wsp[][L_WSP], /* i : weighted input signal buffer */ const int16_t loc_harm[], /* i : harmonicity flag */ const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8 */ @@ -237,7 +238,7 @@ ivas_error ivas_core_enc( Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } if ( ( error = pre_proc_ivas( st, last_element_mode, element_brate, ivas_format == SBA_FORMAT ? last_element_brate : element_brate, input_frame, old_inp_12k8[n], old_inp_12k8_fx, old_inp_16k[n], - &inp[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp[n], loc_harm[n], + &inp[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp[n], loc_harm[n], #ifndef IVAS_FLOAT_FIXED cor_map_sum[n], #endif @@ -326,8 +327,6 @@ ivas_error ivas_core_enc( Word16 old_inp_16k_fx[L_INP]; Word16 old_inp_12k8_fx[L_INP_12k8]; Word16 Q_old_syn_12k8_16k; - Word32 epsP_fx[CPE_CHANNELS][M + 1]; - Word16 e_epsP; Word16 inp_buff[CPE_CHANNELS][L_FRAME16k + M + 1]; q_old_inp_12k8_fx = Q_factor_arr( old_inp_12k8[n], L_INP_12k8 ); @@ -336,7 +335,6 @@ ivas_error ivas_core_enc( floatToFixed_arr16( old_inp_12k8[n], old_inp_12k8_fx, q_old_inp_12k8_fx, L_INP_12k8 ); floatToFixed_arr16( old_inp_16k[n], old_inp_16k_fx, q_old_inp_16k_fx, L_INP ); - f2me_buf( epsP[n], epsP_fx[n], &e_epsP, M + 1 ); inp_fx[n] = &inp_buff[n][M + 1]; floatToFixed_arr( &inp[n][-M - 1], &inp_fx[n][-M - 1], Q_new[n] - 1, L_FRAME16k + M + 1 ); #endif @@ -368,8 +366,7 @@ ivas_error ivas_core_enc( Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTcxEnc->Q_old_out = Q_factor_arr( st->hTcxEnc->old_out, L_FRAME32k ) - 1; - floatToFixed_arr( st->hTcxEnc->old_out, st->hTcxEnc->old_out_fx, st->hTcxEnc->Q_old_out, L_FRAME32k ); + // floatToFixed_arr( st->hTcxEnc->old_out, st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); Word16 nSubframes; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) @@ -401,8 +398,10 @@ ivas_error ivas_core_enc( /* TCX core encoder */ stereo_tcx_core_enc( st, old_inp_12k8_fx + L_INP_MEM, old_inp_16k_fx + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], 0 ); + Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, -st->hTcxEnc->Q_old_out ); // scaling back to Q0 + st->hTcxEnc->Q_old_out = 0; #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arr( st->hTcxEnc->old_out_fx, st->hTcxEnc->old_out, st->hTcxEnc->Q_old_out, L_FRAME32k ); + // fixedToFloat_arr( st->hTcxEnc->old_out_fx, st->hTcxEnc->old_out, st->hTcxEnc->Q_old_out, L_FRAME32k ); for ( int k = 0; k < nSubframes; k++ ) { @@ -440,10 +439,10 @@ ivas_error ivas_core_enc( } ELSE { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - st->hTcxEnc->old_out_fx[i] = float_to_fix16_thrld( st->hTcxEnc->old_out[i], 0 ); - } + // FOR( i = 0; i < L_FRAME32k; i++ ) + //{ + // st->hTcxEnc->old_out_fx[i] = float_to_fix16_thrld( st->hTcxEnc->old_out[i], 0 ); + // } } floatToFixed_arr( st->input, st->input_fx, 0, 960 ); @@ -520,7 +519,7 @@ ivas_error ivas_core_enc( q_fac1 = Q_factor_arr( st1->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); floatToFixed_arr( st1->buf_speech_enc_flt, st1->buf_speech_enc, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); st1->exp_buf_speech_enc = 15 - q_fac1; - floatToFixed_arr( st1->hTcxEnc->buf_speech_ltp_flt, st1->hTcxEnc->buf_speech_ltp, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // floatToFixed_arr( st1->hTcxEnc->buf_speech_ltp_flt, st1->hTcxEnc->buf_speech_ltp, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); st1->hTcxEnc->exp_buf_speech_ltp = 15 - q_fac1; } floatToFixed_arr( st1->input_buff, st1->input_buff_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); @@ -539,7 +538,7 @@ ivas_error ivas_core_enc( } else if ( st1->element_mode != IVAS_CPE_MDCT ) { - fixedToFloat_arr( st1->hTcxEnc->buf_speech_ltp, st1->hTcxEnc->buf_speech_ltp_flt, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // fixedToFloat_arr( st1->hTcxEnc->buf_speech_ltp, st1->hTcxEnc->buf_speech_ltp_flt, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } fixedToFloat_arr( st1->input_buff_fx, st1->input_buff, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); @@ -558,7 +557,76 @@ ivas_error ivas_core_enc( } ELSE { - stereo_mdct_core_enc( hCPE, old_inp_16k, old_wsp, pitch_buf_fx ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + Word16 old_inp_16k_fx[CPE_CHANNELS][L_INP]; + Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], q_fac[CPE_CHANNELS]; + for ( i = 0; i < CPE_CHANNELS; i++ ) + { + floatToFixed_arr( old_inp_16k[i], old_inp_16k_fx[i], 0, L_INP ); + q_fac[i] = Q_factor_arr( old_wsp[i], L_WSP ); + floatToFixed_arr( old_wsp[i], old_wsp_fx[i], q_fac[i], L_WSP ); + } + Word16 q_fac1 = Q15; + for ( i = 0; i < CPE_CHANNELS; i++ ) + { + Word16 nSubframes; + Encoder_State *st1 = sts[i]; + TCX_ENC_HANDLE hTcxEncCh = st1->hTcxEnc; + nSubframes = ( st1->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; + for ( n = 0; n < nSubframes; n++ ) + { + Word16 nl = (Word16) ( (float) ( hTcxEncCh->L_frameTCX / nSubframes ) * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); + floatToFixed_arr( &hTcxEncCh->new_speech_TCX_flt[nl - ( hTcxEncCh->L_frameTCX / nSubframes )], + &hTcxEncCh->new_speech_TCX[nl - ( hTcxEncCh->L_frameTCX / nSubframes )], + 0, + 2 * hTcxEncCh->L_frameTCX / nSubframes ); + + IF( n == 0 ) + { + floatToFixed_arr( &hTcxEncCh->speech_TCX_flt[-( sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB - 0 )], + &hTcxEncCh->speech_TCX[-( sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB - 0 )], + 0, + sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB ); + } + } + if ( st1->element_mode == IVAS_CPE_DFT ) + { + q_fac1 = Q_factor_arr( st1->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + floatToFixed_arr( st1->buf_wspeech_enc_flt, st1->buf_wspeech_enc, q_fac1, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + st1->exp_buf_wspeech_enc = 15 - q_fac1; + } + else if ( st1->element_mode != IVAS_CPE_MDCT ) + { + q_fac1 = Q_factor_arr( st1->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + floatToFixed_arr( st1->buf_speech_enc_flt, st1->buf_speech_enc, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st1->exp_buf_speech_enc = 15 - q_fac1; + st1->hTcxEnc->exp_buf_speech_ltp = 15 - q_fac1; + } + floatToFixed_arr( st1->input_buff, st1->input_buff_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); + } +#endif + stereo_mdct_core_enc_fx( hCPE, old_inp_16k_fx, old_wsp_fx, pitch_buf_fx ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + Word16 k; + for ( i = 0; i < CPE_CHANNELS; i++ ) + { + fixedToFloat_arr( old_wsp_fx[i], old_wsp[i], q_fac[i], L_WSP ); + Word16 length = sts[i]->hTcxEnc->L_frameTCX / ( ( sts[i]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); + FOR( k = 0; k <= ( ( sts[i]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + { + fixedToFloat_arrL32( sts[i]->hTcxEnc->spectrum_fx[k], sts[i]->hTcxEnc->spectrum[k], 31 - sts[i]->hTcxEnc->spectrum_e[k], length ); + } + } + for ( i = 0; i < CPE_CHANNELS; i++ ) + { + Encoder_State *st1 = sts[i]; + if ( st1->element_mode == IVAS_CPE_DFT ) + { + fixedToFloat_arr( st1->buf_wspeech_enc, st1->buf_wspeech_enc_flt, q_fac1, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + } + fixedToFloat_arr( st1->input_buff_fx, st1->input_buff, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); + } +#endif } } ELSE IF( EQ_32( sts[0]->core_brate, SID_2k40 ) && EQ_32( sts[1]->core_brate, SID_2k40 ) ) @@ -588,30 +656,20 @@ ivas_error ivas_core_enc( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word32 shb_speech_fx32[L_FRAME16k]; Word16 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8], old_inp_16k_fx[CPE_CHANNELS][L_INP]; - if ( hCPE && hCPE->hStereoDft ) - { - f2me_buf( hCPE->hStereoDft->DFT[0], hCPE->hStereoDft->DFT_fx[0], &hCPE->hStereoDft->DFT_fx_e[0], STEREO_DFT_N_MAX_ENC ); - f2me_buf( hCPE->hStereoDft->DFT[1], hCPE->hStereoDft->DFT_fx[1], &hCPE->hStereoDft->DFT_fx_e[1], STEREO_DFT_N_MAX_ENC ); - } for ( n = 0; n < n_CoreChannels; n++ ) { st = sts[n]; floatToFixed_arr( st->old_input_signal, st->old_input_signal_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); // prev_lsp_wb_temp_fx, prev_lsp_wb_fx and prev_lpc_wb_fx in Q15. No float counterparts - if ( st->hBWE_FD != NULL ) - { - Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); - st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further - } floatToFixed_arr( st->input_buff, st->input_buff_fx, 0 /*Q_input*/, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); f2me_buf_16( st->buf_speech_enc_pe_flt, st->buf_speech_enc_pe, &st->exp_buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); f2me_buf_16( st->buf_speech_enc_flt, st->buf_speech_enc, &st->exp_buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - f2me_buf_16( st->buf_synth_flt, st->buf_synth, &st->exp_buf_synth, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); IF( st->hTcxEnc != NULL ) { + st->hTcxEnc->exp_buf_speech_ltp = 31; // Q0 f2me_buf_16( st->buf_wspeech_enc_flt, st->buf_wspeech_enc, &st->exp_buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); - f2me_buf_16( st->hTcxEnc->buf_speech_ltp_flt, st->hTcxEnc->buf_speech_ltp, &st->hTcxEnc->exp_buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // f2me_buf_16( st->hTcxEnc->buf_speech_ltp_flt, st->hTcxEnc->buf_speech_ltp, &st->hTcxEnc->exp_buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } floatToFixed_arr16( old_inp_12k8[n], old_inp_12k8_fx[n], Q_new[n] - 1, L_INP_12k8 ); @@ -633,6 +691,13 @@ ivas_error ivas_core_enc( { st = sts[n]; + IF( st->hBWE_FD != NULL ) + { + Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( -1, st->Q_old_wtda ) ); + st->Q_old_wtda = -1; // This reset is required for resolving crash issue. Needs to be looked into further + move16(); + } + /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ @@ -685,12 +750,12 @@ ivas_error ivas_core_enc( { /* Common pre-processing for SWB(FB) TBE and SWB(FB) BWE */ /* Scaling cldfb_state_fx */ - scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, sub( q_re_im_buf, st->cldfbSynTd->Q_cldfb_state ) ); // st->cldfbSynTd->Q_cldfb_state -> q_realImagBuffer + scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, sub( q_re_im_buf[n], st->cldfbSynTd->Q_cldfb_state ) ); // st->cldfbSynTd->Q_cldfb_state -> q_realImagBuffer - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf, hCPE ); + swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); /* Re-scaling cldfb_state_fx */ - scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, negate( sub( q_re_im_buf, st->cldfbSynTd->Q_cldfb_state ) ) ); // q_realImagBuffer -> st->cldfbSynTd->Q_cldfb_state + scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, negate( sub( q_re_im_buf[n], st->cldfbSynTd->Q_cldfb_state ) ) ); // q_realImagBuffer -> st->cldfbSynTd->Q_cldfb_state } ELSE IF( GE_32( input_Fs, 32000 ) ) { @@ -808,6 +873,12 @@ ivas_error ivas_core_enc( { updt_enc_common_ivas_fx( st ); } + + IF( st->hBWE_FD != NULL ) + { + st->hBWE_FD->prev_Q_input_lp = sub( Q_new[n], 1 ); + move16(); + } } /*------------------------------------------------------------------* @@ -829,20 +900,14 @@ ivas_error ivas_core_enc( { st = sts[n]; fixedToFloat_arr( st->old_input_signal_fx, st->old_input_signal, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - - if ( st->hBWE_FD != NULL ) - { - st->hBWE_FD->prev_Q_input_lp = Q_new[n] - 1; - // fixedToFloat_arr( st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, Q12, M + 1 ); - } fixedToFloat_arr( st->input_fx, st->input, 0 /* Q_input*/, L_FRAME48k ); me2f_buf_16( st->buf_speech_enc_pe, st->exp_buf_speech_enc_pe, st->buf_speech_enc_pe_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); me2f_buf_16( st->buf_speech_enc, st->exp_buf_speech_enc, st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - me2f_buf_16( st->buf_synth, st->exp_buf_synth, st->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); IF( st->hTcxEnc != NULL ) { me2f_buf_16( st->buf_wspeech_enc, st->exp_buf_wspeech_enc, st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); - me2f_buf_16( st->hTcxEnc->buf_speech_ltp, st->hTcxEnc->exp_buf_speech_ltp, st->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // me2f_buf_16( st->hTcxEnc->buf_speech_ltp, st->hTcxEnc->exp_buf_speech_ltp, st->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, -st->hTcxEnc->exp_buf_speech_ltp ); } } #endif diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 0b43fca8b..684e7b722 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -64,7 +64,8 @@ ivas_error pre_proc_ivas( Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q6 */ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* i/o: LP prediction errors */ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q */ + Word16 *epsP_fx_q, /* i : LP prediction errors */ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ @@ -547,7 +548,6 @@ ivas_error pre_proc_ivas( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 old_inp_16k_fx[L_INP], Q_old_inp_16k = -1; Word16 Q_r[2] = { 0 }, exp_wsp; - Word32 epsP_fx[M + 1] = { 0 }; Word16 old_wsp_fx[L_WSP], wsp_fx[L_FRAME + L_LOOK_12k8]; floatToFixed_arr16( st->input, st->input_fx, -1, 960 ); inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; @@ -585,6 +585,7 @@ ivas_error pre_proc_ivas( { return error; } + *epsP_fx_q = add( Q_r[0], 1 ); } test(); Scale_sig( old_inp_12k8_fx, L_INP_12k8, *Q_new ); // Q_new-1 @@ -645,12 +646,6 @@ ivas_error pre_proc_ivas( fixedToFloat_arr( st->buf_speech_enc, st->buf_speech_enc_flt, Q_old_inp_16k, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); fixedToFloat_arr( st->buf_speech_enc_pe, st->buf_speech_enc_pe_flt, *Q_new - 1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); // Should take care of st->speech_enc_pe as wel fixedToFloat_arr( st->buf_wspeech_enc, st->buf_wspeech_enc_flt, Q_old_inp_16k, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); // Should take care of st->wspeech_enc - - - if ( st->L_frame == L_FRAME16k && element_mode != IVAS_CPE_MDCT ) - { - fixedToFloat_arrL( epsP_fx, epsP, Q_r[0] + 1, M + 1 ); - } #endif /* set the pointer of the current frame for the ACELP core */ IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index bb9d4631a..5354e4113 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -876,20 +876,21 @@ ivas_error pre_proc_front_ivas( } #else ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate */ - const Word16 nb_bits_metadata, /* i : number of metadata bits */ - const Word16 input_frame, /* i : frame length */ - const Word16 n, /* i : channel number */ - Word16 old_inp_12k8_fx[], /* o : (Q-1) buffer of old input signal */ - float old_inp_12k8[], /* o : buffer of old input signal */ - float old_inp_16k[], /* o : buffer of old input signal @16kHz */ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */ - Word16 *relE_fx, /* o : frame relative energy Q8 */ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12 */ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12 */ - float epsP[M + 1], /* o : LP prediction errors */ + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 element_brate, /* i : SCE/CPE element bitrate */ + const Word16 nb_bits_metadata, /* i : number of metadata bits */ + const Word16 input_frame, /* i : frame length */ + const Word16 n, /* i : channel number */ + Word16 old_inp_12k8_fx[], /* o : (Q-1) buffer of old input signal */ + float old_inp_12k8[], /* o : buffer of old input signal */ + float old_inp_16k[], /* o : buffer of old input signal @16kHz */ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */ + Word16 *relE_fx, /* o : frame relative energy Q8 */ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12 */ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12 */ + Word32 epsP_fx[M + 1], /* o : LP prediction errors */ + Word16 *epsP_fx_q, Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15 */ Word16 *vad_hover_flag, /* o : VAD hangover flag */ @@ -911,18 +912,21 @@ ivas_error pre_proc_front_ivas_fx( const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15 */ const Word16 currFlatness_fx, /* i : flatness parameter Q7 */ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index */ - float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */ - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ - const Word16 force_front_vad, /* i : flag to force VAD decision */ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const Word32 ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) */ + Word16 fr_bands_LR_fx_q, + const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q) */ + Word16 lf_E_LR_fx_q, + const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q) */ + Word16 band_energies_LR_fx_q, + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ + const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ + const Word16 force_front_vad, /* i : flag to force VAD decision */ + const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const Word32 ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { #ifdef IVAS_FLOAT_FIXED_CONVERSIONS @@ -976,9 +980,8 @@ ivas_error pre_proc_front_ivas_fx( #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED Word16 old_wsp_fx[L_WSP]; - Word16 epsP_h[M + 1]; /* o : LP prediction errors */ - Word16 epsP_l[M + 1]; /* o : LP prediction errors */ - Word32 fr_bands_LR_fx[2][2 * NB_BANDS]; + Word16 epsP_h[M + 1]; /* o : LP prediction errors */ + Word16 epsP_l[M + 1]; /* o : LP prediction errors */ Word16 lr_vad_enabled; /* LR VAD indicator */ Word16 L_look; /* length of look-ahead */ Word16 flag_spitch; @@ -998,7 +1001,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; ivas_error error; - Word32 epsP_fx[17]; /*to be removed later*/ push_wmops( "pre_proc_front" ); @@ -1047,7 +1049,6 @@ ivas_error pre_proc_front_ivas_fx( Word32 ee_fx[2]; /* Spectral tilt */ Word32 fr_bands_fx[2 * NB_BANDS]; /* energy in frequency bands */ Word32 lf_E_fx[2 * VOIC_BINS]; /* per bin spectrum energy in lf */ - Word32 lf_E_LR_fx[2][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ Word32 hp_E_fx[2]; /* Energy in HF */ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -1557,12 +1558,6 @@ ivas_error pre_proc_front_ivas_fx( { lgBin_E_fx = &st->lgBin_E_fx[0]; } - if ( hCPE != NULL && hCPE->hStereoDft != NULL ) - { - Word16 Q_inp_dmx = Q_factor_arrL( hCPE->hStereoDft->DFT[0], STEREO_DFT_N_MAX_ENC ) - 1; - floatToFixed_arrL( hCPE->hStereoDft->DFT[0], hCPE->hStereoDft->DFT_fx[0], Q_inp_dmx, STEREO_DFT_N_MAX_ENC ); - hCPE->hStereoDft->DFT_fx_e[0] = 31 - Q_inp_dmx; - } Word16 Q_new; Word16 Scale_fac[2]; set16_fx( Scale_fac, 0, 2 ); @@ -1592,9 +1587,9 @@ ivas_error pre_proc_front_ivas_fx( } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arrL( fr_bands_fx, fr_bands, Q_new + QSCALE - 2, 40 ); - fixedToFloat_arrL( band_energies_fx, band_energies, Q_new + QSCALE + 2, 40 ); - fixedToFloat_arrL( lf_E_fx, lf_E, Q_new + QSCALE, 148 ); + fixedToFloat_arrL( fr_bands_fx, fr_bands, Q_new + QSCALE, 40 ); + fixedToFloat_arrL( band_energies_fx, band_energies, Q_new + QSCALE, 40 ); + fixedToFloat_arrL( lf_E_fx, lf_E, Q_new + QSCALE - 2, 148 ); fixedToFloat_arrL( PS_fx, PS, Q_new + QSCALE - 2, 128 ); Etot = fixedToFloat( Etot_fx, Q8 ); // fixedToFloat_arr( fft_buff_fx, fft_buff, Q_new + QSCALE + Scale_fac[0] - 14 -1, 512 ); @@ -1627,12 +1622,8 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_bands0 = 0, Q_bands1 = 0; IF( lr_vad_enabled && st->idchan == 0 ) { - Q_bands0 = Q_factor_arr( fr_bands_LR[0], 2 * NB_BANDS ); - Q_bands1 = Q_factor_arr( fr_bands_LR[1], 2 * NB_BANDS ); - floatToFixed_arrL( fr_bands_LR[0], fr_bands_LR_fx[0], Q_bands0 + QSCALE, 2 * NB_BANDS ); - floatToFixed_arrL( fr_bands_LR[1], fr_bands_LR_fx[1], Q_bands1 + QSCALE, 2 * NB_BANDS ); - floatToFixed_arrL( hCPE->hFrontVad[0]->hNoiseEst->bckr, hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, Q_bands0 + QSCALE, NB_BANDS ); - floatToFixed_arrL( hCPE->hFrontVad[1]->hNoiseEst->bckr, hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, Q_bands1 + QSCALE, NB_BANDS ); + floatToFixed_arrL( hCPE->hFrontVad[0]->hNoiseEst->bckr, hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, fr_bands_LR_fx_q + QSCALE, NB_BANDS ); + floatToFixed_arrL( hCPE->hFrontVad[1]->hNoiseEst->bckr, hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, fr_bands_LR_fx_q + QSCALE, NB_BANDS ); } #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED @@ -1809,16 +1800,9 @@ ivas_error pre_proc_front_ivas_fx( { test(); test(); - IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR != NULL ) + IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL ) { #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word32 band_energies_LR_fx[2 * NB_BANDS] = { 0 }; /* energy in critical bands without minimum noise floor E_MIN */ - Word16 band_energies_LR_fx_exp; /* energy in critical bands without minimum noise floor E_MIN */ - - Word16 q_band_energies_LR = Q_factor_arrL( band_energies_LR, 2 * NB_BANDS ); - band_energies_LR_fx_exp = 31 - q_band_energies_LR; - floatToFixed_arrL( band_energies_LR, band_energies_LR_fx, ( 31 - band_energies_LR_fx_exp ), 2 * NB_BANDS ); - Word16 normmsPeriodog_fx = Q31, zero_flag = 0; move16(); move16(); @@ -1846,7 +1830,7 @@ ivas_error pre_proc_front_ivas_fx( st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); move16(); #endif - perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, band_energies_LR_fx_exp, enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); + perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); } else { @@ -2016,8 +2000,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_new_loc; Word16 e_new_loc; Word16 Q_r[2] = { 0 }; - Word16 epsP_l_loc[M + 1]; - Word16 epsP_h_loc[M + 1]; Q_new_loc = ( Q_factor_arr( old_inp_12k8, L_INP_12k8 ) - 1 ); // 1 is the guard bit // Q_new_loc = 0; /* Dynamic Q_new used above causes overflow issues */ for ( int k = 0; k < L_INP_12k8; k++ ) @@ -2059,9 +2041,16 @@ ivas_error pre_proc_front_ivas_fx( move16(); } - analy_lp_ivas_fx( inp_12k8_loc_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h_loc, epsP_l_loc, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, + analy_lp_ivas_fx( inp_12k8_loc_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, i, Q_new_loc, Q_r ); + FOR( int idx = 0; idx < M + 1; idx++ ) + { + epsP_fx[idx] = L_Comp( epsP_h[idx], epsP_l[idx] ); // Q_r[0] + 1 + move32(); + } + *epsP_fx_q = add( Q_r[0], 1 ); + lsp2lsf_fx( lsp_new_fx, lsf_new_fx, M, INT_FS_12k8 ); stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old1_fx, 0, L_FRAME ); @@ -2069,17 +2058,7 @@ ivas_error pre_proc_front_ivas_fx( Copy( lsf_new_fx, st->lsf_old1_fx, M ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - float power_2 = powf( 2.0, (float) ( Q_r[0] + 1 ) ); - float check_float; - for ( int idx = 0; idx < M + 1; idx++ ) - { - Word32 check = L_Comp( epsP_h_loc[idx], epsP_l_loc[idx] ); - check_float = (float) check / power_2; - epsP[idx] = check_float; - } - free( old_inp_12k8_loc_fx ); - #endif if ( element_mode == IVAS_CPE_TD && st->idchan == 1 ) { @@ -2188,10 +2167,10 @@ ivas_error pre_proc_front_ivas_fx( { for ( int j = 0; j < 2; j++ ) { - q_fr_bands = min( q_fr_bands, Q_factor_arrL( lf_E_LR[j], 2 * VOIC_BINS ) + 2 ); + q_fr_bands = min( q_fr_bands, lf_E_LR_fx_q + 2 ); q_fr_bands = min( q_fr_bands, Q_factor_arrL( tmpN_LR[j], NB_BANDS ) ); q_fr_bands = min( q_fr_bands, Q_factor_arrL( tmpE_LR[j], NB_BANDS ) ); - q_fr_bands = min( q_fr_bands, Q_factor_arrL( fr_bands_LR[j], 2 * NB_BANDS ) ); + q_fr_bands = min( q_fr_bands, fr_bands_LR_fx_q ); q_fr_bands = min( q_fr_bands, Q_factor_arrL( hCPE->hFrontVad[j]->hNoiseEst->bckr, NB_BANDS ) ); q_fr_bands = min( q_fr_bands, Q_factor_arrL( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1, NB_BANDS ) ); q_fr_bands = min( q_fr_bands, Q_factor_arrL( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2, NB_BANDS ) ); @@ -2201,7 +2180,6 @@ ivas_error pre_proc_front_ivas_fx( for ( int j = 0; j < 2; j++ ) { - floatToFixed_arr32( fr_bands_LR[j], fr_bands_LR_fx[j], q_fr_bands, 2 * NB_BANDS ); floatToFixed_arr32( hCPE->hFrontVad[j]->hNoiseEst->bckr, hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, q_fr_bands, NB_BANDS ); floatToFixed_arr32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands1, hCPE->hFrontVad[j]->hNoiseEst->fr_bands1_fx, q_fr_bands, NB_BANDS ); floatToFixed_arr32( hCPE->hFrontVad[j]->hNoiseEst->fr_bands2, hCPE->hFrontVad[j]->hNoiseEst->fr_bands2_fx, q_fr_bands, NB_BANDS ); @@ -2214,7 +2192,6 @@ ivas_error pre_proc_front_ivas_fx( } floatToFixed_arr32( tmpN_LR[j], tmpN_LR_fx[j], q_fr_bands, NB_BANDS ); floatToFixed_arr32( tmpE_LR[j], tmpE_LR_fx[j], q_fr_bands, NB_BANDS ); - floatToFixed_arr32( lf_E_LR[j], lf_E_LR_fx[j], q_fr_bands - 2, 2 * VOIC_BINS ); } } floatToFixed_arr32( tmpN, tmpN_fx, q_fr_bands, NB_BANDS ); @@ -2237,12 +2214,6 @@ ivas_error pre_proc_front_ivas_fx( q_inp_12k8 = Q_factor_arr( old_inp_12k8, L_INP_12k8 ); // inp_12k8_fx floatToFixed_arr16( old_inp_12k8, old_inp_12k8_fx, q_inp_12k8, L_INP_12k8 ); - Word16 Q_epsp = Q_factor_arrL( epsP, M + 1 ); - floatToFixed_arr32( epsP, epsP_fx, Q_epsp, M + 1 ); - FOR( Word16 j = 0; j <= M; j++ ) - { - L_Extract( epsP_fx[j], &epsP_h[j], &epsP_l[j] ); - } #endif // IVAS_FLOAT_FIXED_CONVERSIONS Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); @@ -2375,8 +2346,7 @@ ivas_error pre_proc_front_ivas_fx( IF( hStereoClassif != NULL ) { #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 epsP_e, max_e_Etot; - f2me_buf( epsP, epsP_fx, &epsP_e, 17 ); + Word16 max_e_Etot; #endif // IVAS_FLOAT_FIXED_CONVERSIONS max_e_Etot = s_max( hStereoClassif->e_Etot_buf_fx, s_max( hStereoClassif->Etot_up_e, hStereoClassif->Etot_dn_e ) ); @@ -2386,7 +2356,7 @@ ivas_error pre_proc_front_ivas_fx( hStereoClassif->Etot_up_e = hStereoClassif->Etot_dn_e = hStereoClassif->e_Etot_buf_fx = max_e_Etot; stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx, st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx, - st->clas, epsP_e, ( 15 - Q8 ) /* exp of cor_map_sum */, ( 15 - Q8 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); + st->clas, sub( 31, *epsP_fx_q ), ( 15 - Q8 ) /* exp of cor_map_sum */, ( 15 - Q8 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); } /*----------------------------------------------------------------* @@ -2395,14 +2365,10 @@ ivas_error pre_proc_front_ivas_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; - Word16 Q_esp; Word16 Qfact_PS = Q_factor_arrL( PS, 128 ); floatToFixed_arr32( PS, PS_fx, Qfact_PS, 128 ); - Word16 e_esp; - f2me_buf( epsP, epsP_fx, &e_esp, M + 1 ); - Q_esp = sub( 31, e_esp ); #endif - smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q ); + smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, Etot_fx, lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /*----------------------------------------------------------------* * VAD energy updates @@ -2418,8 +2384,16 @@ ivas_error pre_proc_front_ivas_fx( { ivas_long_enr_fx( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx ); - mvr2r( fr_bands_LR[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO, NB_BANDS ); - mvr2r( fr_bands_LR[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO, NB_BANDS ); + Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS ); + hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q; + move16(); + Copy32( fr_bands_LR_fx[1] + NB_BANDS, hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, NB_BANDS ); + hCPE->hFrontVad[1]->hNoiseEst->q_enrO = fr_bands_LR_fx_q; + move16(); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arrL32( hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, hCPE->hFrontVad[0]->hNoiseEst->enrO, hCPE->hFrontVad[0]->hNoiseEst->q_enrO, 20 ); + fixedToFloat_arrL32( hCPE->hFrontVad[1]->hNoiseEst->enrO_fx, hCPE->hFrontVad[1]->hNoiseEst->enrO, hCPE->hFrontVad[1]->hNoiseEst->q_enrO, 20 ); +#endif } /*----------------------------------------------------------------* @@ -2513,6 +2487,7 @@ ivas_error pre_proc_front_ivas_fx( { return error; } + *epsP_fx_q = add( Q_r[0], 1 ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // No need to do fixed to float for signal_in_fx st->mem_preemph_enc_flt = fixedToFloat_16( st->mem_preemph_enc, Q_old_inp_16k ); @@ -2528,12 +2503,6 @@ ivas_error pre_proc_front_ivas_fx( fixedToFloat_arr( st->buf_speech_enc, st->buf_speech_enc_flt, Q_old_inp_16k, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); fixedToFloat_arr( st->buf_speech_enc_pe, st->buf_speech_enc_pe_flt, Q_old_inp_16k, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); // Should take care of st->speech_enc_pe as wel fixedToFloat_arr( st->buf_wspeech_enc, st->buf_wspeech_enc_flt, Q_old_inp_16k, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); // Should take care of st->wspeech_enc - - - if ( st->L_frame == L_FRAME16k && element_mode != IVAS_CPE_MDCT ) - { - fixedToFloat_arrL( epsP_fx, epsP, Q_r[0] + 1, M + 1 ); - } #endif #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 4c7b9bff2..629c23870 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -95,11 +95,12 @@ ivas_error ivas_cpe_enc_fx( Word16 fft_buff_fx_q[CPE_CHANNELS]; /* FFT buffer */ Word16 fft_buff_fx_final_q = MAX_16; #endif - Word32 ener_fx[CPE_CHANNELS]; /* residual energy from Levinson-Durbin Q6 */ - Word16 relE_fx[CPE_CHANNELS]; /* frame relative energy Q8 */ - Word16 A_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes Q12 */ - Word16 Aw_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* weighted A(z) unquantized for subframes Q12 */ - float epsP[CPE_CHANNELS][M + 1]; /* LP prediction errors */ + Word32 ener_fx[CPE_CHANNELS]; /* residual energy from Levinson-Durbin Q6 */ + Word16 relE_fx[CPE_CHANNELS]; /* frame relative energy Q8 */ + Word16 A_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes Q12 */ + Word16 Aw_fx[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* weighted A(z) unquantized for subframes Q12 */ + Word32 epsP_fx[CPE_CHANNELS][M + 1]; /* LP prediction errors */ + Word16 epsP_fx_q[CPE_CHANNELS]; Word16 lsp_new_fx[CPE_CHANNELS][M]; /* LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[CPE_CHANNELS][M]; /* ISPs in the middle of the frame Q15 */ Word16 vad_hover_flag[CPE_CHANNELS]; /* VAD hangover flag */ @@ -107,8 +108,6 @@ ivas_error ivas_cpe_enc_fx( Word32 realBuffer_fx[CPE_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* real buffer */ Word32 imagBuffer_fx[CPE_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* imag buffer */ Word16 q_re_im_buf[CPE_CHANNELS]; - Word16 q_re_im_min = Q15; - move16(); float old_wsp[CPE_CHANNELS][L_WSP]; /* old weighted input signal */ Word16 pitch_fr_fx[CPE_CHANNELS][NB_SUBFR]; /* Q6, fractional pitch values */ Word16 voicing_fr_fx[CPE_CHANNELS][NB_SUBFR]; /* Q15, fractional pitch gains */ @@ -123,12 +122,13 @@ ivas_error ivas_cpe_enc_fx( Word16 tdm_ratio_idx, tdm_ratio_idx_SM; /* temp. TD stereo parameters */ Word16 tdm_SM_or_LRTD_Pri; /* temp. TD stereo parameters */ - Word16 nb_bits; /* number of DFT stereo side bits */ - float fr_bands[CPE_CHANNELS][2 * NB_BANDS]; /* energy in frequency bands */ - Word16 Etot_LR_fx[CPE_CHANNELS]; /* total energy Q8 */ - float lf_E[CPE_CHANNELS][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ - Word16 localVAD_HE_SAD[CPE_CHANNELS]; /* HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN */ + Word16 nb_bits; /* number of DFT stereo side bits */ + Word32 fr_bands_fx[CPE_CHANNELS][2 * NB_BANDS]; /* energy in frequency bands (Q_buffer + QSCALE) */ + Word16 Etot_LR_fx[CPE_CHANNELS]; /* total energy Q8 */ + Word32 lf_E_fx[CPE_CHANNELS][2 * VOIC_BINS]; /* per bin spectrum energy in lf (Q_buffer + QSCALE - 2) */ + Word16 localVAD_HE_SAD[CPE_CHANNELS]; /* HE-SAD flag without hangover, LR channels */ + Word32 band_energies_LR_fx[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor E_MIN (Q_buffer + QSCALE - band_ener_guardbits) */ + Word16 Q_buffer[2]; float orig_input[CPE_CHANNELS][L_FRAME48k]; Word16 orig_input_fx[CPE_CHANNELS][L_FRAME48k]; Word16 Etot_last_fx[CPE_CHANNELS]; @@ -244,17 +244,13 @@ ivas_error ivas_cpe_enc_fx( #ifdef IVAS_FLOAT_FIXED Word16 Q_inp = 0; move16(); - Word16 Q_buffer[2]; - Word32 band_energies_LR_fx[2 * NB_BANDS]; - Word32 lf_E_fx[CPE_CHANNELS][2 * VOIC_BINS]; - Word32 fr_bands_fx[CPE_CHANNELS][2 * NB_BANDS]; Word16 band_ener_guardbits = find_guarded_bits_fx( 2 * NB_BANDS ); Word16 Q_add = 2; move16(); Word16 front_create_flag = 0; move16(); #ifdef MSAN_FIX - set_f( band_energies_LR, 0, 2 * NB_BANDS ); + set32_fx( band_energies_LR_fx, 0, 2 * NB_BANDS ); #endif #ifdef IVAS_FLOAT_FIXED_CONVERSIONS for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -276,7 +272,6 @@ ivas_error ivas_cpe_enc_fx( floatToFixed_arrL( hCPE->hFrontVad[n]->hNoiseEst->bckr, hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, Q_new_old + QSCALE, 20 ); floatToFixed_arrL( hCPE->hFrontVad[n]->hNoiseEst->enrO, hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, Q_new_old + QSCALE, 20 ); } - floatToFixed_arrL( &band_energies_LR[0], &band_energies_LR_fx[0], Q_new_old + QSCALE + 2, 40 ); } #endif @@ -293,10 +288,8 @@ ivas_error ivas_cpe_enc_fx( Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add ); for ( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig( hCPE->hFrontVad[n]->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub( Q_buffer[n], hCPE->hFrontVad[n]->q_buffer_12k8 ) ); + // Scale_sig( hCPE->hFrontVad[n]->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub( Q_buffer[n], hCPE->hFrontVad[n]->q_buffer_12k8 ) ); hCPE->hFrontVad[n]->q_buffer_12k8 = Q_buffer[n]; - fixedToFloat_arrL( fr_bands_fx[n], fr_bands[n], Q_buffer[n] + QSCALE, 40 ); - fixedToFloat_arrL( lf_E_fx[n], lf_E[n], Q_buffer[n] + QSCALE - 2, 148 ); fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, hCPE->hFrontVad[n]->hNoiseEst->bckr, Q_new_old + QSCALE, 20 ); fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->enrO_fx, hCPE->hFrontVad[n]->hNoiseEst->enrO, Q_new_old + QSCALE, 20 ); @@ -308,7 +301,6 @@ ivas_error ivas_cpe_enc_fx( fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->ave_enr2_fx, hCPE->hFrontVad[n]->hNoiseEst->ave_enr2, Q8, NB_BANDS ); } } - fixedToFloat_arrL( &band_energies_LR_fx[0], &band_energies_LR[0], Q_buffer[1] + QSCALE - band_ener_guardbits, 40 ); } #endif #else @@ -782,12 +774,6 @@ ivas_error ivas_cpe_enc_fx( } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 i; - - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - me2f_buf( hCPE->hStereoDft->DFT_fx[i], hCPE->hStereoDft->DFT_fx_e[i], hCPE->hStereoDft->DFT[i], STEREO_DFT_N_MAX_ENC ); - } /*local fix2flt*/ /*fix2flt: dft_synthesize*/ fixedToFloat_arrL( sts[0]->input32_fx + out_start_ind, sts[0]->input + out_start_ind, 16, out_end_ind - out_start_ind ); @@ -846,10 +832,10 @@ ivas_error ivas_cpe_enc_fx( Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_12k8[n], old_inp_16k[n], - &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], + &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp[n], pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], - fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands, Etot_LR_fx, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate ); - q_re_im_min = s_min( q_re_im_buf[n], q_re_im_min ); + fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, add( Q_buffer[n], QSCALE ), Etot_LR_fx, lf_E_fx, add( Q_buffer[n], QSCALE - 2 ), localVAD_HE_SAD, + band_energies_LR_fx, sub( add( Q_buffer[n], QSCALE ), band_ener_guardbits ), 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate ); #else error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], @@ -1165,18 +1151,7 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Core Encoder *----------------------------------------------------------------*/ - FOR( n = 0; n < n_CoreChannels; n++ ) - { - IF( NE_16( q_re_im_buf[n], q_re_im_min ) ) - { - FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[n][i], CLDFB_NO_CHANNELS_MAX, sub( q_re_im_min, q_re_im_buf[n] ) ); - scale_sig32( imagBuffer_fx[n][i], CLDFB_NO_CHANNELS_MAX, sub( q_re_im_min, q_re_im_buf[n] ) ); - } - } - } - if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8, old_inp_16k, ener_fx, A_fx, Aw_fx, epsP, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_min, old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8, old_inp_16k, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 697f97de1..9d768825b 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -839,8 +839,8 @@ ivas_error front_vad_spar_fx( Word16 Q_new_old = add( sub( Q_inp, Qband ), Q_add ); Scale_sig32( hFrontVad->hNoiseEst->bckr_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_bckr ) ); // Q_new_old +QSCALE +2 - Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enr ) ); - hFrontVad->hNoiseEst->q_enr = add( Q_new_old, QSCALE + 2 ); + Scale_sig32( hFrontVad->hNoiseEst->enrO_fx, 20, sub( add( Q_new_old, QSCALE + 2 ), hFrontVad->hNoiseEst->q_enrO ) ); + hFrontVad->hNoiseEst->q_enrO = add( Q_new_old, QSCALE + 2 ); move16(); st->flag_noisy_speech_snr_fx = (Word8) st->flag_noisy_speech_snr; Word16 Q_buffer = hFrontVad->q_buffer_12k8; @@ -852,7 +852,7 @@ ivas_error front_vad_spar_fx( { return error; } - Scale_sig( hFrontVad->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub( Q_buffer, hFrontVad->q_buffer_12k8 ) ); + // Scale_sig(hFrontVad->buffer_12k8_fx + 384, 3 * L_FRAME / 2 - 384, sub(Q_buffer, hFrontVad->q_buffer_12k8)); hFrontVad->q_buffer_12k8 = Q_buffer; move16(); Q_inp_12k8 = hFrontVad->q_buffer_12k8; @@ -886,7 +886,7 @@ ivas_error front_vad_spar_fx( Word16 Q_r[2] = { 0 }; move16(); move16(); - Scale_sig( inp_12k8_fx - 2 * L_FILT_MAX, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) ); + Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), hFrontVad->q_mem_decim ) ); Scale_sig( inp_12k8_fx, 3 * L_FRAME / 2, sub( s_min( Q_inp_12k8, hFrontVad->q_mem_decim ), Q_inp_12k8 ) ); Q_inp_12k8 = s_min( hFrontVad->q_mem_decim, hFrontVad->q_buffer_12k8 ); hFrontVad->q_mem_decim = Q_inp_12k8; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 7886ace65..dbb7b32db 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -443,9 +443,10 @@ ivas_error ivas_ism_enc_fx( Word32 ener_fx[MAX_NUM_OBJECTS][1]; /* residual energy from Levinson-Durbin Q6 */ Word16 relE_fx[MAX_NUM_OBJECTS][1]; /* frame relative energy, Q8 */ - Word16 A_fx[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes */ - Word16 Aw_fx[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* weighted A(z) unquantized for subframes */ - float epsP[MAX_NUM_OBJECTS][1][M + 1]; /* LP prediction errors */ + Word16 A_fx[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* A(z) unquantized for subframes */ + Word16 Aw_fx[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )] = { 0 }; /* weighted A(z) unquantized for subframes */ + Word32 epsP_fx[MAX_NUM_OBJECTS][1][M + 1]; /* LP prediction errors */ + Word16 epsP_fx_q[MAX_NUM_OBJECTS][1]; Word16 lsp_new_fx[MAX_NUM_OBJECTS][1][M]; /* LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[MAX_NUM_OBJECTS][1][M]; /* ISPs in the middle of the frame Q15 */ Word16 vad_hover_flag[MAX_NUM_OBJECTS][1]; /* VAD hangover flag */ @@ -464,9 +465,9 @@ ivas_error ivas_ism_enc_fx( Word16 currFlatness_fx[1]; /* flatness parameter */ Word16 fft_buff_fx[MAX_NUM_OBJECTS][1][2 * L_FFT]; /* FFT buffer */ Word16 fft_buff_fx_q[MAX_NUM_OBJECTS][1]; /* FFT buffer */ - float fr_bands[1][2 * NB_BANDS]; /* energy in frequency bands */ + Word32 fr_bands_fx[1][2 * NB_BANDS]; /* energy in frequency bands */ Word16 Etot_LR_fx[1]; /* total energy; correlation shift Q8 */ - float lf_E[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ + Word32 lf_E_fx[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ Word16 localVAD_HE_SAD[1]; /* local HE VAD */ Word16 nchan_ism, dtx_flag, sid_flag, flag_noisy_speech; Word16 md_diff_flag[MAX_NUM_OBJECTS]; @@ -586,9 +587,9 @@ ivas_error ivas_ism_enc_fx( Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], - &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], + &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp[sce_id][0], pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands, Etot_LR_fx, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate ); + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, 31, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate ); IF( NE_32( error, IVAS_ERR_OK ) ) { @@ -775,7 +776,7 @@ ivas_error ivas_ism_enc_fx( test(); IF( !dtx_flag || ( dtx_flag && EQ_16( sce_id, st_ivas->hISMDTX->sce_id_dtx ) ) ) { - IF( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], q_re_im_buf[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], ener_fx[sce_id], A_fx[sce_id], Aw_fx[sce_id], epsP_fx[sce_id], epsP_fx_q[sce_id], lsp_new_fx[sce_id], lsp_mid_fx[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer_fx[sce_id], imagBuffer_fx[sce_id], &q_re_im_buf[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum_fx[sce_id], vad_flag_dtx[sce_id], enerBuffer_fx[sce_id], enerBuffer_fx_exp[sce_id], fft_buff_fx[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index ed83eac99..5cabb53bf 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -661,11 +661,11 @@ ivas_error ivas_mct_enc_fx( st = hCPE->hCoreCoder[n]; f2me_buf_16( st->buf_speech_enc_pe_flt, st->buf_speech_enc_pe, &st->exp_buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); f2me_buf_16( st->buf_speech_enc_flt, st->buf_speech_enc, &st->exp_buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - f2me_buf_16( st->buf_synth_flt, st->buf_synth, &st->exp_buf_synth, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); IF( st->hTcxEnc != NULL ) { + st->hTcxEnc->exp_buf_speech_ltp = 31; /*Q0*/ f2me_buf_16( st->buf_wspeech_enc_flt, st->buf_wspeech_enc, &st->exp_buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); - f2me_buf_16( st->hTcxEnc->buf_speech_ltp_flt, st->hTcxEnc->buf_speech_ltp, &st->hTcxEnc->exp_buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // f2me_buf_16( st->hTcxEnc->buf_speech_ltp_flt, st->hTcxEnc->buf_speech_ltp, &st->hTcxEnc->exp_buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); } #endif @@ -674,11 +674,11 @@ ivas_error ivas_mct_enc_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS me2f_buf_16( st->buf_speech_enc_pe, st->exp_buf_speech_enc_pe, st->buf_speech_enc_pe_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); me2f_buf_16( st->buf_speech_enc, st->exp_buf_speech_enc, st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - me2f_buf_16( st->buf_synth, st->exp_buf_synth, st->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); IF( st->hTcxEnc != NULL ) { me2f_buf_16( st->buf_wspeech_enc, st->exp_buf_wspeech_enc, st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k ); - me2f_buf_16( st->hTcxEnc->buf_speech_ltp, st->hTcxEnc->exp_buf_speech_ltp, st->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + // me2f_buf_16( st->hTcxEnc->buf_speech_ltp, st->hTcxEnc->exp_buf_speech_ltp, st->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + Scale_sig( st->hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->hTcxEnc->exp_buf_speech_ltp ); } #endif #else diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 0bb673f6c..7394e92e0 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1777,9 +1777,15 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { Word16 spect_fx[L_FRAME48k]; - Word16 q_spectrum = L_norm_arr( st->hTcxEnc->spectrum_fx[n], shr( st->hTcxEnc->L_frameTCX, n ) ); - - Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, shr( st->hTcxEnc->L_frameTCX, n ), q_spectrum ); + Word16 q_spectrum, l_frame; + /*l_frame = (int16_t)(st->input_Fs / FRAMES_PER_SEC); 1 / FRAMES_PER_SEC = 0.2f */ + l_frame = extract_l( Mpy_32_32( st->input_Fs, 42949673 /* 0.2f in Q31 */ ) ); + if ( EQ_16( st->core, TCX_10_CORE ) ) + { + l_frame = shr( l_frame, 1 ); + } + q_spectrum = L_norm_arr( st->hTcxEnc->spectrum_fx[n], l_frame ); + Copy_Scale_sig32_16( st->hTcxEnc->spectrum_fx[n], spect_fx, l_frame, q_spectrum ); bw_detect_fx( st, NULL, spect_fx, NULL, NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on ); test(); @@ -1864,20 +1870,20 @@ void ivas_mdct_core_whitening_enc_fx( q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) ) ); + q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); const Word16 switchKernel = /* these 4 transform types can be applied: 0 = MDCT-IV, 1 = MDST-II, 2 = MDCT-II, 3 = MDST-IV */ kernel_switch_detect_fx( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], q_com, nSampCore / nSubframes, - shr( L_subframeTCX, shift ), hTcxEnc0->transform_type[n], &hTcxEnc0->kernel_switch_corr_past, L_shr( imult3216( totalRate, L_subframe ), shift ) ); + shr( L_subframeTCX, shift ), /*L_subframeTCX / nSubframes*/ hTcxEnc0->transform_type[n], &hTcxEnc0->kernel_switch_corr_past, L_shr( imult3216( totalRate, L_subframe ), shift ) /*( totalRate * L_subframe ) / nSubframes*/ ); mdst_spectrum_e[0][n] = sub( Q31, q_com ); mdst_spectrum_e[1][n] = sub( Q31, q_com ); @@ -1961,11 +1967,11 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[0][n], hTcxEnc0->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) ), L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); + q_com = s_min( L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc0->spectrum_e[n] ) ) ); + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /*hTcxEnc0->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[0][n] ) ) ); speech = NULL; if ( NE_16( n, 1 ) ) @@ -1973,7 +1979,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = hTcxEnc0->speech_TCX; } kernel_switch_update_transforms_fx( hTcxEnc0->spectrum_fx[n], mdst_spectrum_fx[0][n], &q_com, hTcxEnc0->transform_type[n], sts[0]->hTcxCfg, sts[0]->bwidth_sw_cnt, hTcxEnc0->kernel_type[n], - hTcxEnc0->new_speech_TCX, speech, windowedSignal_fx[0] + i_mult( n, L_FRAME48k ), &q_windowedSignal[0], shr( L_subframeTCX, shift ) ); + hTcxEnc0->new_speech_TCX, speech, windowedSignal_fx[0] + i_mult( n, L_FRAME48k ), &q_windowedSignal[0], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[0][n] = sub( Q31, q_com ); hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); move16(); @@ -1982,11 +1988,11 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[1][n], hTcxEnc1->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) ), L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) ) ); + q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ), L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc1->spectrum_e[n] ) ) ); + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /*hTcxEnc1->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[1][n] ) ) ); speech = NULL; if ( NE_16( n, 1 ) ) @@ -1994,7 +2000,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = hTcxEnc1->speech_TCX; } kernel_switch_update_transforms_fx( hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[1][n], &q_com, hTcxEnc1->transform_type[n], sts[1]->hTcxCfg, sts[1]->bwidth_sw_cnt, hTcxEnc1->kernel_type[n], - hTcxEnc1->new_speech_TCX, speech, windowedSignal_fx[1] + i_mult( n, L_FRAME48k ), &q_windowedSignal[1], shr( L_subframeTCX, shift ) ); + hTcxEnc1->new_speech_TCX, speech, windowedSignal_fx[1] + i_mult( n, L_FRAME48k ), &q_windowedSignal[1], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[1][n] = sub( Q31, q_com ); hTcxEnc1->spectrum_e[n] = sub( Q31, q_com ); move16(); @@ -2009,7 +2015,7 @@ void ivas_mdct_core_whitening_enc_fx( EQ_16( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) ) { // nrg > MAX_STE_PRE_NRG ? 1 : 0 - Word16 tmp = 0, exp_com; + Word16 tmp = 0, exp_com, exp_max; move16(); IF( GT_16( nrg_fx, MAX_STE_PRE_NRG_Q15 ) ) { @@ -2023,23 +2029,22 @@ void ivas_mdct_core_whitening_enc_fx( move16(); /* length = max(nSampCore / (2 * NB_DIV), L_subframeTCX / (2 * NB_DIV), NB_DIV = 2 */ length = shr( s_max( nSampCore, L_subframeTCX ), 2 ); - q_min = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); - q_min = s_max( q_min, mdst_spectrum_e[0][n] ); - q_min = s_max( q_min, mdst_spectrum_e[1][n] ); - q_min = sub( Q31, q_min ); + exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); + exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); + exp_max = s_max( exp_max, mdst_spectrum_e[1][n] ); // calculate the headroom available - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], length ), L_norm_arr( hTcxEnc0->spectrum_fx[n], length ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], length ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], length ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], length ), L_norm_arr( hTcxEnc0->spectrum_fx[n], length ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], length ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], length ) ); - q_com = sub( s_min( Q31, add( q_min, q_com ) ), 6 ); // 6 guarded bits + q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); // 6 guarded bits exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ), sub( hTcxEnc0->spectrum_e[n], exp_com ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ), sub( hTcxEnc1->spectrum_e[n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ), sub( mdst_spectrum_e[0][n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ), sub( mdst_spectrum_e[1][n], exp_com ) ); + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); Word16 q_com_orig = q_com; move16(); @@ -2047,8 +2052,8 @@ void ivas_mdct_core_whitening_enc_fx( Word16 offset2 = sub( idiv1616( hTcxEnc0->L_frameTCX, nSubframes ), length ); hTcxEnc0->enc_ste_pre_corr_past = - enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], &q_com, shr( nSampCore, NB_DIV ), - shr( L_subframeTCX, NB_DIV ), tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), NB_DIV ) ); // 2 * NB_DIV = 4 (shl(1, NB_DIV))*/ + enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], &q_com, shr( nSampCore, NB_DIV ) /*nSampCore / ( 2 * NB_DIV )*/, + shr( L_subframeTCX, NB_DIV ) /*L_subframeTCX / ( 2 * NB_DIV )*/, tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), NB_DIV ) /*( totalRate * L_subframe ) / ( 2 * NB_DIV )*/ ); move32(); IF( NE_16( q_com_orig, q_com ) ) @@ -2060,39 +2065,27 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale ); } - mdst_spectrum_e[0][n] = sub( Q31, q_com ); - mdst_spectrum_e[1][n] = sub( Q31, q_com ); - hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); - hTcxEnc1->spectrum_e[n] = sub( Q31, q_com ); - move16(); - move16(); - move16(); + exp_max = sub( Q31, q_com ); move16(); - q_min = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); - q_min = s_max( q_min, mdst_spectrum_e[0][n] ); - q_min = s_max( q_min, mdst_spectrum_e[1][n] ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); - q_min = sub( Q31, q_min ); - - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - - q_com = sub( s_min( Q31, add( q_min, q_com ) ), 6 ); + q_com = sub( s_min( Q31, add( q_com, exp_com ) ), 6 ); exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ), sub( hTcxEnc0->spectrum_e[n], exp_com ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ), sub( hTcxEnc1->spectrum_e[n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ), sub( mdst_spectrum_e[0][n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ), sub( mdst_spectrum_e[1][n], exp_com ) ); + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); q_com_orig = q_com; move16(); hTcxEnc0->enc_ste_pre_corr_past = - enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n] + tcx5SizeFB, hTcxEnc1->spectrum_fx[n] + tcx5SizeFB, mdst_spectrum_fx[0][n] + tcx5SizeFB, mdst_spectrum_fx[1][n] + tcx5SizeFB, &q_com, shr( nSampCore, NB_DIV ), - shr( L_subframeTCX, NB_DIV ), tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), NB_DIV ) ); + enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n] + tcx5SizeFB, hTcxEnc1->spectrum_fx[n] + tcx5SizeFB, mdst_spectrum_fx[0][n] + tcx5SizeFB, mdst_spectrum_fx[1][n] + tcx5SizeFB, &q_com, shr( nSampCore, NB_DIV ) /*nSampCore / ( 2 * NB_DIV )*/, + shr( L_subframeTCX, NB_DIV ) /*L_subframeTCX / ( 2 * NB_DIV )*/, tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), NB_DIV ) /*(totalRate * L_subframe) / (2 * NB_DIV)*/ ); move32(); IF( NE_16( q_com_orig, q_com ) ) { @@ -2119,31 +2112,29 @@ void ivas_mdct_core_whitening_enc_fx( ELSE { Word16 length; - length = shr( s_max( nSampCore, L_subframeTCX ), shift ); - Word16 offset2 = sub( shr( hTcxEnc0->L_frameTCX, shift ), length ); - q_min = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); - q_min = s_max( q_min, mdst_spectrum_e[0][n] ); - q_min = s_max( q_min, mdst_spectrum_e[1][n] ); - - q_min = sub( Q31, q_min ); + length = shr( s_max( nSampCore, L_subframeTCX ), shift ); // max(/* nSampCore/nSubframes, L_subframeTCX/nSubframes) */ + Word16 offset2 = sub( shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, length ); + exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); + exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); + exp_max = s_max( exp_max, mdst_spectrum_e[1][n] ); - q_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc0->L_frameTCX, shift ) ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); - q_com = sub( s_min( Q31, add( q_min, q_com ) ), 6 ); + q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ), sub( hTcxEnc0->spectrum_e[n], exp_com ) ); - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ), sub( hTcxEnc1->spectrum_e[n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ), sub( mdst_spectrum_e[0][n], exp_com ) ); - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ), sub( mdst_spectrum_e[1][n], exp_com ) ); + Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); + Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); + Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); + Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); Word16 q_com_orig = q_com; move16(); hTcxEnc0->enc_ste_pre_corr_past = - enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], &q_com, shr( nSampCore, shift ), - shr( L_subframeTCX, shift ), tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), shift ) ); + enc_ste_pre_mdct( hTcxEnc0->spectrum_fx[n], hTcxEnc1->spectrum_fx[n], mdst_spectrum_fx[0][n], mdst_spectrum_fx[1][n], &q_com, shr( nSampCore, shift ) /* nSampCore/nSubframes */, + shr( L_subframeTCX, shift ) /* L_subframeTCX/nSubframes */, tmp, hTcxEnc0->enc_ste_pre_corr_past, L_shr( imult3216( totalRate, L_subframe ), shift ) /*( totalRate * L_subframe ) / nSubframes*/ ); move32(); IF( NE_16( q_com_orig, q_com ) ) { @@ -2153,10 +2144,11 @@ void ivas_mdct_core_whitening_enc_fx( Scale_sig32( mdst_spectrum_fx[0][n] + length, offset2, scale ); Scale_sig32( mdst_spectrum_fx[1][n] + length, offset2, scale ); } - mdst_spectrum_e[0][n] = sub( Q31, q_com ); - hTcxEnc0->spectrum_e[n] = sub( Q31, q_com ); - mdst_spectrum_e[1][n] = sub( Q31, q_com ); - hTcxEnc1->spectrum_e[n] = sub( Q31, q_com ); + exp_com = sub( Q31, q_com ); + mdst_spectrum_e[0][n] = exp_com; + hTcxEnc0->spectrum_e[n] = exp_com; + mdst_spectrum_e[1][n] = exp_com; + hTcxEnc1->spectrum_e[n] = exp_com; move16(); move16(); move16(); @@ -2221,12 +2213,12 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( mdst_spectrum_e[ch][n], hTcxEncCh->spectrum_e[n] ); q_min = sub( Q31, q_min ); - q_com = s_min( L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) ), L_norm_arr( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) ) ); + q_com = s_min( L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ), L_norm_arr( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/ ) ); q_com = s_min( Q31, add( q_min, q_com ) ); - Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) ); - Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); + Scale_sig32( hTcxEncCh->spectrum_fx[n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEncCh->spectrum_e[n] ) ) ); + Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEncCh->L_frameTCX, shift ) /*hTcxEncCh->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); speech = hTcxEncCh->speech_TCX; if ( n != 0 ) @@ -2234,7 +2226,7 @@ void ivas_mdct_core_whitening_enc_fx( speech = NULL; } kernel_switch_update_transforms_fx( hTcxEncCh->spectrum_fx[n], mdst_spectrum_fx[ch][n], &q_com, hTcxEncCh->transform_type[n], sts[ch]->hTcxCfg, sts[ch]->bwidth_sw_cnt, hTcxEncCh->kernel_type[n], - hTcxEncCh->new_speech_TCX, speech, windowedSignal_fx[ch] + i_mult( n, L_FRAME48k ), &q_windowedSignal[ch], shr( L_subframeTCX, shift ) ); + hTcxEncCh->new_speech_TCX, speech, windowedSignal_fx[ch] + i_mult( n, L_FRAME48k ), &q_windowedSignal[ch], shr( L_subframeTCX, shift ) /*L_subframeTCX / nSubframes*/ ); mdst_spectrum_e[ch][n] = sub( Q31, q_com ); move16(); hTcxEncCh->spectrum_e[n] = sub( Q31, q_com ); @@ -2266,7 +2258,7 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -2288,7 +2280,7 @@ void ivas_mdct_core_whitening_enc_fx( } FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); hTcxEnc->spectrum_e[n] = sub( Q31, q_com ); move16(); } @@ -2322,8 +2314,8 @@ void ivas_mdct_core_whitening_enc_fx( q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); q_min = s_max( q_min, mdst_spectrum_e[ch][n] ); - q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) ) ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) ) ); + q_com = s_min( q_com, L_norm_arr( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -2346,8 +2338,8 @@ void ivas_mdct_core_whitening_enc_fx( } FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ), sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); - Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ), sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, hTcxEnc->spectrum_e[n] ) ) ); + Scale_sig32( mdst_spectrum_fx[ch][n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( Q31, mdst_spectrum_e[ch][n] ) ) ); hTcxEnc->spectrum_e[n] = sub( Q31, q_com ); move16(); mdst_spectrum_e[ch][n] = sub( Q31, q_com ); @@ -2380,17 +2372,17 @@ void ivas_mdct_core_whitening_enc_fx( init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); - L_subframe = shr( L_subframe, shift ); + L_subframe = shr( L_subframe, shift ); /*L_subframeTCX / nSubframes*/ IF( mct_on ) { - L_subframeTCX = shr( L_subframeTCX, shift ); + L_subframeTCX = shr( L_subframeTCX, shift ); /*L_subframeTCX / nSubframes*/ } ELSE { L_subframeTCX = L_subframe; move16(); } - tcx_subframe_coded_lines = shr( tcx_subframe_coded_lines, shift ); + tcx_subframe_coded_lines = shr( tcx_subframe_coded_lines, shift ); /*tcx_subframe_coded_lines / nSubframes*/ Word16 q_pow = 62, q_pow_tmp = sub( 63, shl( mdst_spectrum_e[0][0], 1 ) ); // add( shl( sub( Q31, mdst_spectrum_e[0][0] ), 1 ), 1 ); move16(); @@ -2642,7 +2634,7 @@ void ivas_mdct_core_whitening_enc_fx( { q_min = s_max( q_min, hTcxEnc->spectrum_e[n] ); - q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) ) ); + q_com = s_min( q_com, L_norm_arr( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/ ) ); } } q_min = sub( Q31, q_min ); @@ -2666,7 +2658,7 @@ void ivas_mdct_core_whitening_enc_fx( FOR( n = 0; n < nSubframes; n++ ) { - Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ), sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) ); + Scale_sig32( hTcxEnc->spectrum_fx[n], shr( hTcxEnc->L_frameTCX, shift ) /*hTcxEnc->L_frameTCX / nSubframes*/, sub( q_com, sub( 31, hTcxEnc->spectrum_e[n] ) ) ); hTcxEnc->spectrum_e[n] = sub( 31, q_com ); move16(); } @@ -3768,7 +3760,7 @@ void ivas_mdct_quant_coder_fx( Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word16 quantized_spectrum_e[CPE_CHANNELS][NB_DIV]; Word16 ener_e[CPE_CHANNELS][NB_DIV]; - Word16 gain_tcx_ee; + push_wmops( "mdct_core_Q" ); sts = hCPE->hCoreCoder; @@ -3912,15 +3904,7 @@ void ivas_mdct_quant_coder_fx( } } - gain_tcx_ee = s_max( gain_tcx_e[0][0], gain_tcx_e[0][1] ); - gain_tcx_ee = s_max( gain_tcx_ee, gain_tcx_e[1][0] ); - gain_tcx_ee = s_max( gain_tcx_ee, gain_tcx_e[1][1] ); - gain_tcx_fx[0][0] = shl( gain_tcx_fx[0][0], sub( gain_tcx_e[0][0], gain_tcx_ee ) ); - gain_tcx_fx[0][1] = shl( gain_tcx_fx[0][1], sub( gain_tcx_e[0][1], gain_tcx_ee ) ); - gain_tcx_fx[1][0] = shl( gain_tcx_fx[1][0], sub( gain_tcx_e[1][0], gain_tcx_ee ) ); - gain_tcx_fx[1][1] = shl( gain_tcx_fx[1][1], sub( gain_tcx_e[1][1], gain_tcx_ee ) ); - - EstimateStereoTCXNoiseLevel_fx( sts, quantized_spectrum_fx, gain_tcx_fx, gain_tcx_ee, L_frame, noiseFillingBorder, hm_active, ignore_chan, fac_ns_fx, param_core, MCT_flag ); + EstimateStereoTCXNoiseLevel_fx( sts, quantized_spectrum_fx, gain_tcx_fx, gain_tcx_e, L_frame, noiseFillingBorder, hm_active, ignore_chan, fac_ns_fx, param_core, MCT_flag ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index a2809bdf2..7acb55cde 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -71,14 +71,13 @@ ivas_error ivas_sce_enc_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // required for float to fix conversion float old_inp_12k8[1][L_INP_12k8] = { 0 }; /* buffer of input signal @ 12k8 */ float old_inp_16k[1][L_INP] = { 0 }; /* buffer of input signal @ 16kHz */ - float epsP[1][M + 1]; /* LP prediction errors */ float old_wsp[1][L_WSP]; /* old weighted input signal */ - float fr_bands[1][2 * NB_BANDS]; /* energy in frequency bands */ - float lf_E[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ #endif - Word32 ener_fx[1]; /* residual energy from Levinson-Durbin Q6 */ - Word32 enerBuffer_fx[1][CLDFB_NO_CHANNELS_MAX]; /* energy buffer */ - Word16 enerBuffer_fx_exp[1]; /* energy buffer */ + Word32 ener_fx[1]; /* residual energy from Levinson-Durbin Q6 */ + Word32 enerBuffer_fx[1][CLDFB_NO_CHANNELS_MAX]; /* energy buffer */ + Word16 enerBuffer_fx_exp[1]; /* energy buffer */ + Word32 epsP_fx[1][M + 1]; /* LP prediction errors */ + Word16 epsP_fx_q[1]; Word16 A_fx[1][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ Word16 Aw_fx[1][NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */ Word16 lsp_new_fx[1][M]; /* LSPs at the end of the frame Q15 */ @@ -92,7 +91,9 @@ ivas_error ivas_sce_enc_fx( Word32 imagBuffer_fx[1][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* imag buffer */ Word16 q_re_im_buf = Q31; move16(); - Word16 cor_map_sum_fx[1]; /* speech/music clasif. parameter Q8 */ + Word16 cor_map_sum_fx[1]; /* speech/music clasif. parameter Q8 */ + Word32 fr_bands_fx[1][2 * NB_BANDS]; /* energy in frequency bands */ + Word32 lf_E_fx[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ Word16 old_inp_12k8_fx[1][L_INP_12k8]; /* buffer of input signal @ 12k8 */ Word16 vad_hover_flag[1]; /* VAD hangover flag */ @@ -243,9 +244,9 @@ ivas_error ivas_sce_enc_fx( Scale_sig( &A_fx[0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_12k8[0], old_inp_16k[0], - &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], + &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp[0], pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], - fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands, Etot_LR_fx, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, + fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, 31, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate ); #else @@ -342,7 +343,7 @@ ivas_error ivas_sce_enc_fx( * Encoder *----------------------------------------------------------------*/ - IF( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8, old_inp_16k, ener_fx, A_fx, Aw_fx, epsP, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8, old_inp_16k, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 7a178771f..de3f77c9d 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -178,10 +178,10 @@ typedef struct stereo_dft_enc_data_struct Word16 DFT_fx_e[CPE_CHANNELS]; // Word16 DFT_q_fx[CLDFB_NO_CHANNELS_MAX]; #endif - float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC]; Word16 dft_ovl; /* Overlap size */ Word16 dft_zp; /* Zero padding */ #ifndef IVAS_FLOAT_FIXED + float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC]; const float *win; /* DFT window */ const float *win_8k; /* DFT window */ const float *win_12k8; /* DFT window */ diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index b8978bcff..b54ef3d1b 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -518,91 +518,60 @@ void stereo_mdct_core_enc( return; } #else -void stereo_mdct_core_enc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ - float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ -#ifndef IVAS_FLOAT_FIXED - float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ -#else +void stereo_mdct_core_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ + Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ -#endif ) { -#ifdef IVAS_FLOAT_FIXED -#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - Word32 *p_orig_spectrum_long_fx[CPE_CHANNELS]; -#endif Word32 orig_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* MDCT output (L/R). */ Word32 *orig_spectrum_fx[CPE_CHANNELS][NB_DIV]; /* Pointers to MDCT output for a short block (L/R) */ Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; Word32 *p_powerSpec_fx[CPE_CHANNELS]; -#ifdef MSAN_FIX /*To be removed later*/ - Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ -#else Word32 powerSpecMsInv_long_fx[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ -#endif // MSAN_FIX Word32 *powerSpecMsInv_fx[CPE_CHANNELS][NB_DIV]; Word32 quantized_spectrum_long_fx[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ Word32 *quantized_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV]; -#endif - int16_t i, ch, nSubframes, L_subframeTCX; - int16_t n, nAvailBits; - int16_t tnsSize[CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */ - float orig_spectrum_long[CPE_CHANNELS][N_MAX]; /* MDCT output (L/R). */ + Word16 i, ch, nSubframes, L_subframeTCX; + Word16 n, nAvailBits; + Word16 tnsSize[CPE_CHANNELS][NB_DIV]; /* number of tns parameters put into prm */ + Word16 tnsBits[CPE_CHANNELS][NB_DIV]; /* number of tns bits in the frame */ Word32 *p_orig_spectrum_long_fx[CPE_CHANNELS]; /* MDCT output (L/R). */ - float *p_orig_spectrum_long[CPE_CHANNELS]; /* MDCT output (L/R). */ - float *orig_spectrum[CPE_CHANNELS][NB_DIV]; /* Pointers to MDCT output for a short block (L/R) */ - float powerSpec[CPE_CHANNELS][N_MAX]; -#ifdef IVAS_FLOAT_FIXED - Word16 q_powerSpec; -#endif - float *p_powerSpec[CPE_CHANNELS]; - float powerSpecMsInv_long[CPE_CHANNELS][N_MAX]; /* MS inv power spectrum, also inverse MDST spectrum */ - float *powerSpecMsInv[CPE_CHANNELS][NB_DIV]; - float quantized_spectrum_long[CPE_CHANNELS][N_MAX]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ - float *quantized_spectrum[CPE_CHANNELS][NB_DIV]; - float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV]; - float *inv_spectrum[CPE_CHANNELS][NB_DIV]; - float *p_mdst_spectrum_long[CPE_CHANNELS], mdst_spectrum_long[CPE_CHANNELS][N_MAX]; Word32 *p_mdst_spectrum_long_fx[CPE_CHANNELS]; - float *mdst_spectrum[CPE_CHANNELS][NB_DIV]; -#ifdef IVAS_FLOAT_FIXED Word32 mdst_spectrum_long_fx[CPE_CHANNELS][N_MAX]; Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, tmp_s; Word16 tmp_q_powSpec[N_MAX], tmp_q_powSpecInv[N_MAX], *tmp_q_psi[2]; Word64 W_tmp; -#endif Encoder_State *st, **sts; STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; BSTR_ENC_HANDLE hBstr; - int16_t ms_mask[2][MAX_SFB]; - int16_t p_param[CPE_CHANNELS][NB_DIV]; - int16_t stereo_bits; - int16_t meta_bits, signal_bits; + Word16 ms_mask[2][MAX_SFB]; + Word16 p_param[CPE_CHANNELS][NB_DIV]; + Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV]; + Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV]; + Word16 stereo_bits; + Word16 meta_bits, signal_bits; + Word16 p_orig_spectrum_e[2]; push_wmops( "stereo_mdct_core_enc" ); L_subframeTCX = 0; /* to avoid compilation warning */ + move16(); /*--------------------------------------------------------------* * Set pointers *---------------------------------------------------------------*/ - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { p_mdst_spectrum_long_fx[ch] = mdst_spectrum_long_fx[ch]; p_orig_spectrum_long_fx[ch] = orig_spectrum_long_fx[ch]; - p_mdst_spectrum_long[ch] = mdst_spectrum_long[ch]; - p_orig_spectrum_long[ch] = orig_spectrum_long[ch]; -#ifdef IVAS_FLOAT_FIXED orig_spectrum_fx[ch][0] = orig_spectrum_long_fx[ch]; orig_spectrum_fx[ch][1] = orig_spectrum_long_fx[ch] + N_TCX10_MAX; -#endif } set16_fx( tmp_q_powSpecInv, 63, L_FRAME48k ); @@ -616,16 +585,13 @@ void stereo_mdct_core_enc( hBstr = sts[0]->hBstr; meta_bits = hCPE->hMetaData->nb_bits_tot; + move16(); signal_bits = hBstr->nb_bits_tot; + move16(); /*--------------------------------------------------------------* * Initialization *---------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED - sts[0]->hTcxEnc->tfm_mem = sts[1]->hTcxEnc->tfm_mem = sqrtf( 0.5f * ( sts[0]->hTcxEnc->tfm_mem * sts[0]->hTcxEnc->tfm_mem + sts[1]->hTcxEnc->tfm_mem * sts[1]->hTcxEnc->tfm_mem ) ); /* RMS */ - sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt = sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt = 0.5f * ( sts[0]->hTcxEnc->tcxltp_norm_corr_past_flt + sts[1]->hTcxEnc->tcxltp_norm_corr_past_flt ); -#else Word16 tmp_e = 0; move16(); Word32 L_tmp; @@ -636,63 +602,43 @@ void stereo_mdct_core_enc( sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); move16(); move16(); -#endif -#ifdef IVAS_FLOAT_FIXED FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; SetTCXModeInfo_ivas_fx( st, st->hTranDet, &st->hTcxCfg->tcx_curr_overlap_mode ); } -#else - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - SetTCXModeInfo( st, st->hTranDet, &st->hTcxCfg->tcx_curr_overlap_mode ); - } -#endif /* adaptively sync tcx modes*/ -#ifdef IVAS_FLOAT_FIXED + test(); + test(); + test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( GT_16( abs_s( sub( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) ), extract_l( 2 ) ) || EQ_16( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) || EQ_16( add( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ), extract_l( 5 ) ) ) ) /* disable syncing for stereo switching or large diff in last frame overlap */ { sync_tcx_mode( sts ); } -#else - if ( ( hCPE->last_element_mode == IVAS_CPE_MDCT ) && ( abs( sts[0]->hTcxCfg->tcx_last_overlap_mode - sts[1]->hTcxCfg->tcx_last_overlap_mode ) > 2 || - sts[0]->hTcxCfg->tcx_last_overlap_mode == sts[1]->hTcxCfg->tcx_last_overlap_mode || - sts[0]->hTcxCfg->tcx_last_overlap_mode + sts[1]->hTcxCfg->tcx_last_overlap_mode == 5 ) ) /* disable syncing for stereo switching or large diff in last frame overlap */ - { - sync_tcx_mode( sts ); - } -#endif - if ( hCPE->hCoreCoder[0]->igf ) + IF( hCPE->hCoreCoder[0]->igf ) { -#ifndef IVAS_FLOAT_FIXED - initMdctStereoEncData( hCPE->hStereoMdct, STEREO_FORMAT, IVAS_CPE_MDCT, hCPE->element_brate, hCPE->hCoreCoder[0]->bwidth, hCPE->hCoreCoder[0]->igf, hCPE->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid, 0 ); - - stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX20 ), 1.0f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); - stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX10 ), 0.5f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); - stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX20afterACELP ), 1.25f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); -#else initMdctStereoEncData_fx( hCPE->hStereoMdct, STEREO_FORMAT, IVAS_CPE_MDCT, hCPE->element_brate, hCPE->hCoreCoder[0]->bwidth, hCPE->hCoreCoder[0]->igf, hCPE->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid, 0 ); stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX20 ), 16384 /* 1.0f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX10 ), 8192 /* 0.5f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); stereo_mdct_init_igf_start_band_fx( &( hCPE->hStereoMdct->stbParamsTCX20afterACELP ), 20480 /* 1.25f in Q14 */, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); -#endif } - else + ELSE { hCPE->hStereoMdct->stbParamsTCX20.sfbIgfStart = -1; + move16(); hCPE->hStereoMdct->stbParamsTCX10.sfbIgfStart = -1; + move16(); hCPE->hStereoMdct->stbParamsTCX10.nBandsStereoCore = hCPE->hStereoMdct->stbParamsTCX10.sfbCnt; + move16(); hCPE->hStereoMdct->stbParamsTCX20.nBandsStereoCore = hCPE->hStereoMdct->stbParamsTCX20.sfbCnt; + move16(); } - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef IVAS_FLOAT_FIXED inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch]; inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch] + N_TCX10_MAX; quantized_spectrum_fx[ch][0] = quantized_spectrum_long_fx[ch]; @@ -706,26 +652,10 @@ void stereo_mdct_core_enc( set32_fx( mdst_spectrum_long_fx[ch], 0, N_MAX ); set32_fx( powerSpec_fx[ch], 0, N_MAX ); set32_fx( powerSpecMsInv_long_fx[ch], 0, N_MAX ); -#endif // IVAS_FLOAT_FIXED - orig_spectrum[ch][0] = orig_spectrum_long[ch]; - orig_spectrum[ch][1] = orig_spectrum_long[ch] + N_TCX10_MAX; - quantized_spectrum[ch][0] = quantized_spectrum_long[ch]; - quantized_spectrum[ch][1] = quantized_spectrum_long[ch] + N_TCX10_MAX; - inv_mdst_spectrum[ch][0] = powerSpecMsInv[ch][0] = powerSpecMsInv_long[ch]; - inv_mdst_spectrum[ch][1] = powerSpecMsInv[ch][1] = powerSpecMsInv_long[ch] + N_TCX10_MAX; - inv_spectrum[ch][0] = quantized_spectrum[ch][0]; - inv_spectrum[ch][1] = quantized_spectrum[ch][1]; - mdst_spectrum[ch][0] = mdst_spectrum_long[ch]; - mdst_spectrum[ch][1] = mdst_spectrum_long[ch] + N_TCX10_MAX; sts[ch]->hTcxEnc->tns_ms_flag[0] = 0; + move16(); sts[ch]->hTcxEnc->tns_ms_flag[1] = 0; - set_f( powerSpecMsInv_long[ch], 0.0, N_MAX ); - set_f( quantized_spectrum_long[ch], 0.0, N_MAX ); - set_f( mdst_spectrum_long[ch], 0.0, N_MAX ); - set_f( powerSpec[ch], 0.0, N_MAX ); -#ifdef MSAN_FIX - set_f( orig_spectrum_long[ch], 0.0, N_MAX ); -#endif + move16(); } /*--------------------------------------------------------------* @@ -735,95 +665,56 @@ void stereo_mdct_core_enc( * - Envelope Quantization and FDNS * - TNS *---------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV]; - Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV]; - Word16 new_samples_fx[CPE_CHANNELS][L_INP]; - Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], q_fac[CPE_CHANNELS], q_fac1 = Q15; - for ( i = 0; i < CPE_CHANNELS; i++ ) - { - Encoder_State *st1 = sts[i]; - TCX_ENC_HANDLE hTcxEncCh = st1->hTcxEnc; - nSubframes = ( st1->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - for ( n = 0; n < nSubframes; n++ ) - { - Word16 nl = (Word16) ( (float) ( hTcxEncCh->L_frameTCX / nSubframes ) * N_ZERO_MDCT_NS / FRAME_SIZE_NS ); - floatToFixed_arr( &hTcxEncCh->new_speech_TCX_flt[nl - ( hTcxEncCh->L_frameTCX / nSubframes )], - &hTcxEncCh->new_speech_TCX[nl - ( hTcxEncCh->L_frameTCX / nSubframes )], - 0, - 2 * hTcxEncCh->L_frameTCX / nSubframes ); - IF( n == 0 ) - { - floatToFixed_arr( &hTcxEncCh->speech_TCX_flt[-( sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB - 0 )], - &hTcxEncCh->speech_TCX[-( sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB - 0 )], - 0, - sts[0]->hTcxCfg->tcx_mdct_window_min_lengthFB ); - } - } - floatToFixed_arr( new_samples[i], new_samples_fx[i], 0, L_INP ); - q_fac[i] = Q_factor_arr( old_wsp[i], L_WSP ); - floatToFixed_arr( old_wsp[i], old_wsp_fx[i], q_fac[i], L_WSP ); - if ( st1->element_mode == IVAS_CPE_DFT ) - { - q_fac1 = Q_factor_arr( st1->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); - floatToFixed_arr( st1->buf_wspeech_enc_flt, st1->buf_wspeech_enc, q_fac1, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); - st1->exp_buf_wspeech_enc = 15 - q_fac1; - } - else if ( st1->element_mode != IVAS_CPE_MDCT ) - { - q_fac1 = Q_factor_arr( st1->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - floatToFixed_arr( st1->buf_speech_enc_flt, st1->buf_speech_enc, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st1->exp_buf_speech_enc = 15 - q_fac1; - floatToFixed_arr( st1->hTcxEnc->buf_speech_ltp_flt, st1->hTcxEnc->buf_speech_ltp, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st1->hTcxEnc->exp_buf_speech_ltp = 15 - q_fac1; - } - floatToFixed_arr( st1->input_buff, st1->input_buff_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - } -#endif - ivas_mdct_core_whitening_enc_fx( hCPE, new_samples_fx, old_wsp_fx, pitch_buf_fx, p_mdst_spectrum_long_fx, + ivas_mdct_core_whitening_enc_fx( hCPE, new_samples, old_wsp, pitch_buf_fx, p_mdst_spectrum_long_fx, tnsBits, p_orig_spectrum_long_fx, tnsSize, p_param, hBstr, 0, CPE_CHANNELS, mdst_spectrum_e, orig_spectrum_e ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < CPE_CHANNELS; i++ ) + + FOR( i = 0; i < CPE_CHANNELS; i++ ) { Encoder_State *st1 = sts[i]; - nSubframes = ( st1->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - if ( st1->element_mode == IVAS_CPE_DFT ) + nSubframes = NB_DIV; + move16(); + IF( EQ_16( st1->hTcxEnc->tcxMode, TCX_20 ) ) { - fixedToFloat_arr( st1->buf_wspeech_enc, st1->buf_wspeech_enc_flt, q_fac1, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + nSubframes = 1; + move16(); } - else if ( st1->element_mode != IVAS_CPE_MDCT ) + move16(); + IF( EQ_16( nSubframes, NB_DIV ) ) { - fixedToFloat_arr( st1->hTcxEnc->buf_speech_ltp, st1->hTcxEnc->buf_speech_ltp_flt, q_fac1, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + Word16 max_e = s_max( orig_spectrum_e[i][0], orig_spectrum_e[i][1] ); + Scale_sig32( orig_spectrum_fx[i][0], N_TCX10_MAX, sub( orig_spectrum_e[i][0], max_e ) ); + Scale_sig32( orig_spectrum_fx[i][1], N_TCX10_MAX, sub( orig_spectrum_e[i][1], max_e ) ); + p_orig_spectrum_e[i] = max_e; + move16(); } - fixedToFloat_arr( st1->input_buff_fx, st1->input_buff, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - - fixedToFloat_arrL( st1->hTcxEnc->spectrum_fx[0], st1->hTcxEnc->spectrum[0], 31 - st1->hTcxEnc->spectrum_e[0], st1->hTcxEnc->L_frameTCX / nSubframes ); - fixedToFloat_arrL( p_orig_spectrum_long_fx[i], p_orig_spectrum_long[i], 31 - orig_spectrum_e[i][0], N_TCX10_MAX ); - fixedToFloat_arrL( p_mdst_spectrum_long_fx[i], p_mdst_spectrum_long[i], 31 - mdst_spectrum_e[i][0], N_TCX10_MAX ); - if ( nSubframes == NB_DIV ) + ELSE { - fixedToFloat_arrL( st1->hTcxEnc->spectrum_fx[1], st1->hTcxEnc->spectrum[1], 31 - st1->hTcxEnc->spectrum_e[1], st1->hTcxEnc->L_frameTCX / nSubframes ); - fixedToFloat_arrL( p_orig_spectrum_long_fx[i] + N_TCX10_MAX, p_orig_spectrum_long[i] + N_TCX10_MAX, 31 - orig_spectrum_e[i][1], N_TCX10_MAX ); - fixedToFloat_arrL( p_mdst_spectrum_long_fx[i] + N_TCX10_MAX, p_mdst_spectrum_long[i] + N_TCX10_MAX, 31 - mdst_spectrum_e[i][1], N_TCX10_MAX ); + p_orig_spectrum_e[i] = orig_spectrum_e[i][0]; + move16(); } - fixedToFloat_arr( old_wsp_fx[i], old_wsp[i], q_fac[i], L_WSP ); } -#endif - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; - nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; + nSubframes = NB_DIV; + move16(); + if ( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + move16(); + } - for ( n = 0; n < nSubframes; n++ ) + FOR( n = 0; n < nSubframes; n++ ) { - st->side_bits_frame_channel += NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL; + st->side_bits_frame_channel = add( st->side_bits_frame_channel, NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); + move16(); } } - sts[0]->side_bits_frame_channel += SMDCT_NBBITS_SPLIT_RATIO; - + sts[0]->side_bits_frame_channel = add( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO ); + move16(); /*--------------------------------------------------------------* * Stereo Processing @@ -831,98 +722,46 @@ void stereo_mdct_core_enc( if ( !hStereoMdct->isSBAStereoMode ) { -#ifndef IVAS_FLOAT_FIXED - stereo_coder_tcx( hStereoMdct, sts, ms_mask, mdst_spectrum, inv_spectrum, inv_mdst_spectrum, 0 ); -#else -#if 1 + /* Common q for mdst_spectrum and spectrum */ Word16 k; - q_spec = Q31; + q_spec = 0; Word16 length; - Word32 *mdst_spectrum_fix[2][2]; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) { - mdst_spectrum_fix[ch][k] = (Word32 *) malloc( sizeof( Word32 ) * length ); - q_spec = s_min( q_spec, Q_factor_arrL( sts[ch]->hTcxEnc->spectrum[k], length ) - 1 ); - q_spec = s_min( q_spec, Q_factor_arrL( mdst_spectrum[ch][k], length ) - 1 ); + q_spec = s_max( q_spec, sts[ch]->hTcxEnc->spectrum_e[k] ); + q_spec = s_max( q_spec, mdst_spectrum_e[ch][k] ); } } + q_spec = sub( sub( Q31, q_spec ), 1 ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } - FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) + Word16 n_sb = NB_DIV; + move16(); + if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) { - floatToFixed_arrL32( sts[ch]->hTcxEnc->spectrum[k], sts[ch]->hTcxEnc->spectrum_fx[k], q_spec, length ); - sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec ); - floatToFixed_arrL32( mdst_spectrum[ch][k], mdst_spectrum_fix[ch][k], q_spec, length ); + n_sb = 1; + move16(); } - } + length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); -#endif - stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fix, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, q_spec ); -#if 1 - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } FOR( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) { - fixedToFloat_arrL32( sts[ch]->hTcxEnc->spectrum_fx[k], sts[ch]->hTcxEnc->spectrum[k], q_spec, length ); - fixedToFloat_arrL32( inv_spectrum_fx[ch][k], inv_spectrum[ch][k], q_spec, length ); - fixedToFloat_arrL32( inv_mdst_spectrum_fx[ch][k], inv_mdst_spectrum[ch][k], q_spec, length ); - fixedToFloat_arrL32( mdst_spectrum_fix[ch][k], mdst_spectrum[ch][k], q_spec, length ); - free( mdst_spectrum_fix[ch][k] ); + Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[k], length, sub( q_spec, sub( Q31, sts[ch]->hTcxEnc->spectrum_e[k] ) ) ); + sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec ); + Scale_sig32( mdst_spectrum_fx[ch][k], length, sub( q_spec, sub( Q31, mdst_spectrum_e[ch][k] ) ) ); + mdst_spectrum_e[ch][k] = sub( Q31, q_spec ); } } -#endif -#endif + stereo_coder_tcx_fx( hStereoMdct, sts, ms_mask, mdst_spectrum_fx, inv_spectrum_fx, inv_mdst_spectrum_fx, 0, q_spec ); } /*--------------------------------------------------------------* * Power spectrum calculation *---------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 length, k; - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - if ( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } - for ( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) - { - - q_spec = Q_factor_arrL( inv_mdst_spectrum[ch][k], length ); - q_spec = min( q_spec, Q_factor_arrL( inv_spectrum[ch][k], length ) ); - q_spec = min( q_spec, Q_factor_arrL( mdst_spectrum[ch][k], length ) ); - q_spec = min( q_spec, Q_factor_arrL( sts[ch]->hTcxEnc->spectrum[k], length ) ) - 1; - - floatToFixed_arrL32( inv_mdst_spectrum[ch][k], inv_mdst_spectrum_fx[ch][k], q_spec, length ); - floatToFixed_arrL32( inv_spectrum[ch][k], inv_spectrum_fx[ch][k], q_spec, length ); - floatToFixed_arrL32( mdst_spectrum[ch][k], mdst_spectrum_fx[ch][k], q_spec, length ); - - sts[ch]->hTcxEnc->spectrum_e[k] = sub( Q31, q_spec ); - floatToFixed_arrL32( sts[ch]->hTcxEnc->spectrum[k], sts[ch]->hTcxEnc->spectrum_fx[k], q_spec, length ); - } - } -#endif + Word16 length; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -958,8 +797,8 @@ void stereo_mdct_core_enc( W_tmp = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); tmp_s = sub( W_norm( W_tmp ), 1 ); W_tmp = W_shl( W_tmp, tmp_s ); - powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); - tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 move32(); move16(); @@ -1023,8 +862,8 @@ void stereo_mdct_core_enc( W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); tmp_s = sub( W_norm( W_tmp ), 1 ); W_tmp = W_shl( W_tmp, tmp_s ); - powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); - tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[( i + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 move32(); move16(); } @@ -1032,8 +871,8 @@ void stereo_mdct_core_enc( W_tmp = W_mult_32_32( sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1], sts[ch]->hTcxEnc->spectrum_fx[n][L_subframeTCX - 1] ); tmp_s = sub( W_norm( W_tmp ), 1 ); W_tmp = W_shl( W_tmp, tmp_s ); - powerSpec_fx[ch][add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); - tmp_q_powSpec[add( sub( L_subframeTCX, 1 ), imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 + powerSpec_fx[ch][( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = W_extract_h( W_tmp ); + tmp_q_powSpec[( ( L_subframeTCX - 1 ) + ( n * L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 move32(); move16(); } @@ -1064,7 +903,7 @@ void stereo_mdct_core_enc( FOR( i = 0; i < L_subframeTCX; i++ ) { powerSpecMsInv_fx[ch][n][i] = L_shr( powerSpecMsInv_fx[ch][n][i], sub( tmp_q_psi[n][i], q_powSpec[ch] ) ); - powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); + powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )] = L_shr( powerSpec_fx[ch][( i + ( n * L_subframeTCX ) )], sub( tmp_q_powSpec[i], q_powSpec[ch] ) ); move32(); move32(); } @@ -1072,93 +911,6 @@ void stereo_mdct_core_enc( } } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - q_spec = 31; - move16(); - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - length = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - if ( sts[ch]->last_core == ACELP_CORE ) - { - length += length / 4; - } - for ( k = 0; k <= ( ( sts[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) - { - if ( sts[ch]->hTcxEnc->spectrum[k] ) - { - q_spec = 31 - sts[ch]->hTcxEnc->spectrum_e[k]; - fixedToFloat_arrL32( sts[ch]->hTcxEnc->spectrum_fx[k], sts[ch]->hTcxEnc->spectrum[k], q_spec, length ); - fixedToFloat_arrL32( inv_spectrum_fx[ch][k], inv_spectrum[ch][k], q_spec, length ); - } - if ( mdst_spectrum[ch][k] ) - { - fixedToFloat_arrL32( inv_mdst_spectrum_fx[ch][k], inv_mdst_spectrum[ch][k], q_spec, length ); - fixedToFloat_arrL32( mdst_spectrum_fx[ch][k], mdst_spectrum[ch][k], q_spec, length ); - } - } - - fixedToFloat_arrL( powerSpecMsInv_fx[ch][0], powerSpecMsInv[ch][0], q_powSpec[ch], L_FRAME48k ); - fixedToFloat_arrL( powerSpec_fx[ch], powerSpec[ch], q_powSpec[ch], sts[ch]->hTcxEnc->L_frameTCX ); - } -#endif -#else - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - nSubframes = ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX / nSubframes; - if ( sts[ch]->last_core == ACELP_CORE ) - { - L_subframeTCX += L_subframeTCX / 4; - } - - for ( n = 0; n < nSubframes; n++ ) - { - if ( sts[ch]->hTcxEnc->tns_ms_flag[n] ) - { - /* power spectrum: MDCT^2 + MDST^2 */ - for ( i = 0; i < L_subframeTCX; i++ ) - { - powerSpecMsInv[ch][n][i] = inv_mdst_spectrum[ch][n][i] * inv_mdst_spectrum[ch][n][i] + inv_spectrum[ch][n][i] * inv_spectrum[ch][n][i]; - powerSpec[ch][i + n * L_subframeTCX] = mdst_spectrum[ch][n][i] * mdst_spectrum[ch][n][i] + sts[ch]->hTcxEnc->spectrum[n][i] * sts[ch]->hTcxEnc->spectrum[n][i]; - } - } - else - { - if ( hStereoMdct->mdct_stereo_mode[n] != SMDCT_DUAL_MONO ) - { - /* power spectrum: MDCT^2 + MDST^2 */ - powerSpecMsInv[ch][n][0] = inv_spectrum[ch][n][0] * inv_spectrum[ch][n][0]; - for ( i = 1; i < L_subframeTCX - 1; i++ ) - { - float mdst = ( inv_spectrum[ch][n][i + 1] - inv_spectrum[ch][n][i - 1] ); /* An MDST estimate */ - powerSpecMsInv[ch][n][i] = mdst * mdst + inv_spectrum[ch][n][i] * inv_spectrum[ch][n][i]; - } - powerSpecMsInv[ch][n][L_subframeTCX - 1] = inv_spectrum[ch][n][L_subframeTCX - 1] * inv_spectrum[ch][n][L_subframeTCX - 1]; - } - - /* power spectrum: MDCT^2 + MDST^2 */ - powerSpec[ch][n * L_subframeTCX] = sts[ch]->hTcxEnc->spectrum[n][0] * sts[ch]->hTcxEnc->spectrum[n][0]; - for ( i = 1; i < L_subframeTCX - 1; i++ ) - { - float mdst = ( sts[ch]->hTcxEnc->spectrum[n][i + 1] - sts[ch]->hTcxEnc->spectrum[n][i - 1] ); /* An MDST estimate */ - powerSpec[ch][i + n * L_subframeTCX] = mdst * mdst + sts[ch]->hTcxEnc->spectrum[n][i] * sts[ch]->hTcxEnc->spectrum[n][i]; - } - powerSpec[ch][L_subframeTCX - 1 + n * L_subframeTCX] = sts[ch]->hTcxEnc->spectrum[n][L_subframeTCX - 1] * sts[ch]->hTcxEnc->spectrum[n][L_subframeTCX - 1]; - } - } - } -#endif -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - q_powerSpec = Q_factor_arrL( powerSpec[0], L_subframeTCX ); - q_powerSpec = s_min( q_powerSpec, Q_factor_arrL( powerSpec[1], L_subframeTCX ) ); - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - floatToFixed_arrL32( powerSpec[ch], powerSpec_fx[ch], q_powerSpec, N_MAX ); - } -#endif - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -1193,231 +945,132 @@ void stereo_mdct_core_enc( } st->hTcxEnc->measuredBwRatio = ONE_IN_Q14; /* No bandwidth limit for the noise filling */ + move16(); } -#else - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - L_subframeTCX = st->hTcxEnc->L_frameTCX / nSubframes; - if ( st->last_core == ACELP_CORE ) - { - L_subframeTCX += L_subframeTCX / 4; - } - - if ( ( st->hTcxEnc->tcxMode == TCX_20 ) && ( st->element_brate < HQ_96k || st->igf ) ) - { - /*-----------------------------------------------------------* - * Compute noise-measure flags for spectrum filling * - * and quantization (0: tonal, 1: noise-like). * - * Detect low pass if present. * - *-----------------------------------------------------------*/ - ComputeSpectrumNoiseMeasure( powerSpec[ch], L_subframeTCX, st->hTcxEnc->nmStartLine * ( L_subframeTCX / st->hTcxEnc->L_frameTCX ), - ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), st->hTcxEnc->memQuantZeros, L_subframeTCX ); - } - st->hTcxEnc->measuredBwRatio_flt = 1.f; /* No bandwidth limit for the noise filling */ - } -#endif /*--------------------------------------------------------------* * IGF *---------------------------------------------------------------*/ - - if ( sts[0]->igf || sts[1]->igf ) + test(); + IF( sts[0]->igf || sts[1]->igf ) { - if ( sts[0]->hTcxEnc->tcxMode == sts[1]->hTcxEnc->tcxMode ) + IF( EQ_16( sts[0]->hTcxEnc->tcxMode, sts[1]->hTcxEnc->tcxMode ) ) { /* Band-wise M/S for MDST */ - nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 || sts[1]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - for ( n = 0; n < nSubframes; n++ ) + nSubframes = NB_DIV; + move16(); + + test(); + if ( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) || EQ_16( sts[1]->hTcxEnc->tcxMode, TCX_20 ) ) { - if ( ( hStereoMdct->mdct_stereo_mode[n] != hStereoMdct->IGFStereoMode[n] || hStereoMdct->mdct_stereo_mode[n] == SMDCT_BW_MS ) && !hStereoMdct->isSBAStereoMode ) + nSubframes = 1; + move16(); + } + L_subframeTCX = idiv1616( sts[0]->hTcxEnc->L_frameTCX, nSubframes ); + FOR( n = 0; n < nSubframes; n++ ) + { + test(); + test(); + IF( ( NE_16( hStereoMdct->mdct_stereo_mode[n], hStereoMdct->IGFStereoMode[n] ) || EQ_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) && !hStereoMdct->isSBAStereoMode ) { - p_powerSpec[0] = powerSpec[0]; - p_powerSpec[1] = powerSpec[1]; -#ifdef IVAS_FLOAT_FIXED + IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; p_powerSpec_fx[0] = powerSpec_fx[0]; p_powerSpec_fx[1] = powerSpec_fx[1]; - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; hIGFEnc[0] = sts[0]->hIGFEnc; hIGFEnc[1] = sts[1]->hIGFEnc; - Word16 p_orig_spectrum_e[2]; - Word16 igfGridIdx; - IF( sts[0]->last_core == ACELP_CORE && EQ_16( sts[0]->core, TCX_20_CORE ) ) - { - igfGridIdx = IGF_GRID_LB_TRAN; - } - ELSE IF( EQ_16( sts[0]->core, TCX_20_CORE ) ) - { - igfGridIdx = IGF_GRID_LB_NORM; - } - ELSE - { - /* It is short block */ - igfGridIdx = IGF_GRID_LB_SHORT; - } - f2me_buf( orig_spectrum[0][n], orig_spectrum_fx[0][n], &p_orig_spectrum_e[0], hIGFEnc[0]->infoStopLine ); - f2me_buf( orig_spectrum[1][n], orig_spectrum_fx[1][n], &p_orig_spectrum_e[1], hIGFEnc[1]->infoStopLine ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - H_IGF_GRID hGrid; - Word16 *swb_offset; - hPrivateData = &hIGFEnc[ch]->igfData; - hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx]; - swb_offset = hGrid->swb_offset; - // hIGFEnc[ch]->tns_predictionGain = float_to_fix16( hIGFEnc[ch]->tns_predictionGain_flt, Q23 ); - sts[ch]->hTcxEnc->spectrum_e[n] = 31 - Q_factor_arrL( sts[ch]->hTcxEnc->spectrum[n], hGrid->infoGranuleLen ); - sts[ch]->hTcxEnc->spectrum_e[n] = s_max( sts[ch]->hTcxEnc->spectrum_e[n], 31 - Q_factor_arrL( &p_powerSpec[ch][0], hGrid->infoGranuleLen ) ); - sts[ch]->hTcxEnc->spectrum_e[n] = s_max( sts[ch]->hTcxEnc->spectrum_e[n], 31 - Q_factor_arrL( inv_spectrum[ch][n], swb_offset[hGrid->sfbWrap[hGrid->nTiles]] ) ); - sts[ch]->hTcxEnc->spectrum_e[n] = s_max( sts[ch]->hTcxEnc->spectrum_e[n], 31 - Q_factor_arrL( powerSpecMsInv[ch][0], swb_offset[hGrid->sfbWrap[hGrid->nTiles]] ) ); - floatToFixed_arr32( sts[ch]->hTcxEnc->spectrum[n], sts[ch]->hTcxEnc->spectrum_fx[n], 31 - sts[ch]->hTcxEnc->spectrum_e[n], hGrid->infoGranuleLen ); - floatToFixed_arr32( &p_powerSpec[ch][0], &p_powerSpec_fx[ch][0], 31 - sts[ch]->hTcxEnc->spectrum_e[n], hGrid->infoGranuleLen ); - floatToFixed_arr32( inv_spectrum[ch][n], inv_spectrum_fx[ch][n], 31 - sts[ch]->hTcxEnc->spectrum_e[n], swb_offset[hGrid->sfbWrap[hGrid->nTiles]] ); - floatToFixed_arr32( powerSpecMsInv[ch][0], powerSpecMsInv_fx[ch][0], 31 - sts[ch]->hTcxEnc->spectrum_e[n], swb_offset[hGrid->sfbWrap[hGrid->nTiles]] ); + q_spec = sub( Q31, sts[ch]->hTcxEnc->spectrum_e[n] ); + Word16 n_sb = NB_DIV; + move16(); + if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + n_sb = 1; + move16(); + } + length = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); + IF( GT_16( q_spec, q_powSpec[ch] ) ) + { + Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], length, sub( q_powSpec[ch], q_spec ) ); + Scale_sig32( inv_spectrum_fx[ch][n], length, sub( q_powSpec[ch], q_spec ) ); + sts[ch]->hTcxEnc->spectrum_e[n] = sub( Q31, q_powSpec[ch] ); + move16(); + } + ELSE + { + Scale_sig32( &p_powerSpec_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); + Scale_sig32( powerSpecMsInv_fx[ch][0], L_subframeTCX, sub( q_spec, q_powSpec[ch] ) ); + } } -#endif /**********************************flt to fix ends here*******************************************************/ hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0]; + move16(); hIGFEnc[1]->spec_be_igf_e = p_orig_spectrum_e[1]; + move16(); ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, p_powerSpec_fx, powerSpecMsInv_fx, inv_spectrum_fx, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate ); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*************************************fix to flt conversion****************************************************/ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - H_IGF_GRID hGrid; - hPrivateData = &hIGFEnc[ch]->igfData; - hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx]; - me2f_buf( sts[ch]->hTcxEnc->spectrum_fx[n], sts[ch]->hTcxEnc->spectrum_e[n], sts[ch]->hTcxEnc->spectrum[n], hGrid->infoGranuleLen ); - me2f_buf( &p_powerSpec_fx[ch][0], sts[ch]->hTcxEnc->spectrum_e[n], &p_powerSpec[ch][0], hGrid->infoGranuleLen ); - } -#endif /**********************************fix to flt ends here*******************************************************/ -#else - ProcessStereoIGF( hStereoMdct, sts, ms_mask, orig_spectrum, p_powerSpec, powerSpecMsInv, inv_spectrum, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); -#endif // IVAS_FLOAT_FIXED } - else + ELSE { - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; /* update the pointer to the buffer of indices of the second channel */ - if ( ch == 1 ) + if ( EQ_16( ch, 1 ) ) { st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - - int igfGridIdx; - if ( st->last_core == ACELP_CORE && st->core == TCX_20_CORE ) - { - igfGridIdx = IGF_GRID_LB_TRAN; - } - else if ( st->core == TCX_20_CORE ) - { - igfGridIdx = IGF_GRID_LB_NORM; - } - else - { - /* It is short block */ - igfGridIdx = IGF_GRID_LB_SHORT; - } - - L_subframeTCX = st->hTcxEnc->L_frameTCX / nSubframes; + L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); Word16 q_spectrum; - q_spectrum = L_get_q_buf1( orig_spectrum[ch][n], hPrivateData->igfInfo.grid[igfGridIdx].stopLine ); - if ( st->hIGFEnc ) + q_spectrum = sub( Q31, p_orig_spectrum_e[ch] ); + IF( st->hIGFEnc ) { - q_spectrum = min( q_spectrum, 31 - st->hIGFEnc->spec_be_igf_e ); + q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); } - floatToFixed_arrL32( orig_spectrum[ch][n], orig_spectrum_fx[ch][n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].stopLine ); + Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); - q_spectrum = L_get_q_buf1( st->hTcxEnc->spectrum[n], hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - floatToFixed_arrL32( st->hTcxEnc->spectrum[n], st->hTcxEnc->spectrum_fx[n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - - q_powerSpec = L_get_q_buf1( &powerSpec[ch][n * L_subframeTCX], hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - floatToFixed_arrL32( &powerSpec[ch][n * L_subframeTCX], &powerSpec_fx[ch][n * L_subframeTCX], q_powerSpec, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - - -#endif - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powerSpec, st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arrL32( st->hTcxEnc->spectrum_fx[n], st->hTcxEnc->spectrum[n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - fixedToFloat_arrL32( &powerSpec_fx[ch][n * L_subframeTCX], &powerSpec[ch][n * L_subframeTCX], q_powerSpec, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); -#endif -#else - ProcessIGF( st, st->hTcxEnc->spectrum[n], orig_spectrum[ch][n], &powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif + q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); + ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); } } } } - else + ELSE { - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; /* update the pointer to the buffer of indices of the second channel */ - if ( ch == 1 ) + if ( EQ_16( ch, 1 ) ) { st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } - nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; - if ( st->igf ) + nSubframes = NB_DIV; + move16(); + + if ( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) { - for ( n = 0; n < nSubframes; n++ ) + nSubframes = 1; + move16(); + } + IF( st->igf ) + { + FOR( n = 0; n < nSubframes; n++ ) { -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData = &st->hIGFEnc->igfData; - - int igfGridIdx; - if ( st->last_core == ACELP_CORE && st->core == TCX_20_CORE ) - { - igfGridIdx = IGF_GRID_LB_TRAN; - } - else if ( st->core == TCX_20_CORE ) - { - igfGridIdx = IGF_GRID_LB_NORM; - } - else - { - /* It is short block */ - igfGridIdx = IGF_GRID_LB_SHORT; - } - - L_subframeTCX = st->hTcxEnc->L_frameTCX / nSubframes; Word16 q_spectrum; - q_spectrum = L_get_q_buf1( orig_spectrum[ch][n], hPrivateData->igfInfo.grid[igfGridIdx].stopLine ); - if ( st->hIGFEnc ) + L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); + q_spectrum = sub( Q31, p_orig_spectrum_e[ch] ); + IF( st->hIGFEnc ) { - q_spectrum = min( q_spectrum, 31 - st->hIGFEnc->spec_be_igf_e ); + q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); } - floatToFixed_arrL32( orig_spectrum[ch][n], orig_spectrum_fx[ch][n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].stopLine ); - - q_spectrum = L_get_q_buf1( st->hTcxEnc->spectrum[n], hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - floatToFixed_arrL32( st->hTcxEnc->spectrum[n], st->hTcxEnc->spectrum_fx[n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); + Scale_sig32( orig_spectrum_fx[ch][n], N_TCX10_MAX, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); - q_powerSpec = L_get_q_buf1( &powerSpec[ch][n * L_subframeTCX], hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - floatToFixed_arrL32( &powerSpec[ch][n * L_subframeTCX], &powerSpec_fx[ch][n * L_subframeTCX], q_powerSpec, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - -#endif - ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powerSpec, st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - fixedToFloat_arrL32( st->hTcxEnc->spectrum_fx[n], st->hTcxEnc->spectrum[n], q_spectrum, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); - fixedToFloat_arrL32( &powerSpec_fx[ch][n * L_subframeTCX], &powerSpec[ch][n * L_subframeTCX], q_powerSpec, hPrivateData->igfInfo.grid[igfGridIdx].infoGranuleLen ); -#endif -#else - ProcessIGF( st, st->hTcxEnc->spectrum[n], orig_spectrum[ch][n], &powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif + q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); + ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powSpec[ch], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); } } } @@ -1432,63 +1085,65 @@ void stereo_mdct_core_enc( } /* correct side bits per channel*/ - sts[0]->side_bits_frame_channel -= SMDCT_NBBITS_SPLIT_RATIO; - if ( !hStereoMdct->isSBAStereoMode ) + sts[0]->side_bits_frame_channel = sub( sts[0]->side_bits_frame_channel, SMDCT_NBBITS_SPLIT_RATIO ); + move16(); + IF( !hStereoMdct->isSBAStereoMode ) { stereo_bits = write_stereo_to_bitstream( hStereoMdct, sts, ms_mask, 0, hBstr ); } - else + ELSE { stereo_bits = 0; + move16(); } /*--------------------------------------------------------------* * Split available bits between channels *---------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED - FindSplitRatio( hCPE, sts ); -#else -#if 1 + Word16 q_com; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - L_subframeTCX = sts[ch]->hTcxEnc->L_frameTCX / ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ); - IF( sts[ch]->last_core == ACELP_CORE ) + Word16 n_sb = NB_DIV; + move16(); + if ( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) { - L_subframeTCX += L_subframeTCX / 4; + n_sb = 1; + move16(); } + L_subframeTCX = idiv1616( sts[ch]->hTcxEnc->L_frameTCX, n_sb ); FOR( n = 0; n <= ( ( sts[ch]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV ) - 1; n++ ) { - f2me_buf( sts[ch]->hTcxEnc->spectrum[n], sts[ch]->hTcxEnc->spectrum_fx[n], &sts[ch]->hTcxEnc->spectrum_e[n], L_subframeTCX ); + q_com = L_norm_arr( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX ); + Scale_sig32( sts[ch]->hTcxEnc->spectrum_fx[n], L_subframeTCX, q_com ); + sts[ch]->hTcxEnc->spectrum_e[n] = sub( sts[ch]->hTcxEnc->spectrum_e[n], q_com ); } } -#endif FindSplitRatio_fx( hCPE, sts ); -#endif assert( hStereoMdct->split_ratio > 0 && hStereoMdct->split_ratio < SMDCT_BITRATE_RATIO_RANGE ); /* Split available bits between channels */ - nAvailBits = sts[0]->bits_frame_channel + sts[1]->bits_frame_channel - hBstr->nb_bits_tot - sts[0]->core * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL + SMDCT_MINIMUM_ARITH_BITS ) - sts[1]->core * ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL + SMDCT_MINIMUM_ARITH_BITS ); + nAvailBits = sub( sub( sub( add( sts[0]->bits_frame_channel, sts[1]->bits_frame_channel ), hBstr->nb_bits_tot ), imult1616( sts[0]->core, ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL + SMDCT_MINIMUM_ARITH_BITS ) ) ), imult1616( sts[1]->core, ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL + SMDCT_MINIMUM_ARITH_BITS ) ) ); /* remove metadata bits */ - nAvailBits -= meta_bits; + nAvailBits = sub( nAvailBits, meta_bits ); + + nAvailBits = sub( nAvailBits, SMDCT_NBBITS_SPLIT_RATIO ); - nAvailBits -= SMDCT_NBBITS_SPLIT_RATIO; -#ifndef IVAS_FLOAT_FIXED - splitAvailableBits( nAvailBits, hStereoMdct->split_ratio, hStereoMdct->isSBAStereoMode, &sts[0]->bits_frame_channel, &sts[1]->bits_frame_channel ); -#else splitAvailableBits_fx( nAvailBits, hStereoMdct->split_ratio, hStereoMdct->isSBAStereoMode, &sts[0]->bits_frame_channel, &sts[1]->bits_frame_channel ); -#endif - sts[0]->bits_frame_channel += sts[0]->core * SMDCT_MINIMUM_ARITH_BITS; - sts[1]->bits_frame_channel += sts[1]->core * SMDCT_MINIMUM_ARITH_BITS; + sts[0]->bits_frame_channel = add( sts[0]->bits_frame_channel, imult1616( sts[0]->core, SMDCT_MINIMUM_ARITH_BITS ) ); + move16(); + sts[1]->bits_frame_channel = add( sts[1]->bits_frame_channel, imult1616( sts[1]->core, SMDCT_MINIMUM_ARITH_BITS ) ); + move16(); - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - sts[ch]->total_brate = ( sts[ch]->bits_frame_channel + sts[ch]->side_bits_frame_channel ) * FRAMES_PER_SEC; + sts[ch]->total_brate = imult3216( L_deposit_l( add( sts[ch]->bits_frame_channel, sts[ch]->side_bits_frame_channel ) ), FRAMES_PER_SEC ); + move32(); } - stereo_bits += SMDCT_NBBITS_SPLIT_RATIO; + stereo_bits = add( stereo_bits, SMDCT_NBBITS_SPLIT_RATIO ); assert( ( sts[0]->total_brate + sts[1]->total_brate + ( stereo_bits + signal_bits + meta_bits ) * FRAMES_PER_SEC ) == hCPE->element_brate + hCPE->brate_surplus ); assert( hStereoMdct->split_ratio > 0 && hStereoMdct->split_ratio < SMDCT_BITRATE_RATIO_RANGE ); diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index f8f460ff3..a0f699323 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -678,7 +678,7 @@ ivas_error stereo_memory_enc_fx( move16(); move16(); #endif - set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); #ifdef IVAS_FLOAT_FIXED set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index a4278601b..5e198f19f 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -178,7 +178,7 @@ void noise_est_init_fx( move32(); /*Q7//E_MIN; */ hNoiseEst->enrO_fx[i] = E_MIN_FX; move32(); - hNoiseEst->q_enr = Q7; + hNoiseEst->q_enrO = Q7; move16(); hNoiseEst->bckr_fx[i] = E_MIN_FX; move32(); @@ -299,7 +299,7 @@ void noise_est_init_ivas_fx( move32(); /*Q7//E_MIN; */ hNoiseEst->enrO_fx[i] = E_MIN_Q11_FX; move32(); - hNoiseEst->q_enr = Q11; + hNoiseEst->q_enrO = Q11; move16(); hNoiseEst->bckr_fx[i] = E_MIN_Q11_FX; move32(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 862712edf..d296e5692 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2200,10 +2200,10 @@ void ivas_analy_sp_fx_front( Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */ Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */ Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */ - Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE */ + Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */ Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */ - Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE + 2)*/ - Word16 *fft_buff /* o : FFT coefficients (Q_new + QSCALE + 2) */ + Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/ + Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */ ); #endif void find_wsp_fx( diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index de864cc30..1714bc0c4 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -111,7 +111,9 @@ typedef struct signal_buffers_enc_data_structure float old_inp_12k8_flt[L_INP_MEM]; /* memory of input signal at 12.8kHz */ float old_inp_16k_flt[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ float buf_speech_enc_pe_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; +#ifndef IVAS_FLOAT_FIXED float buf_synth_flt[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; /* can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching */ +#endif float buf_speech_enc_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; float buf_wspeech_enc_flt[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /* increased by 320 to avoid memory overlap in find_wsp() and also to accomodate for the wspeech_enc */ // Fixed @@ -730,7 +732,7 @@ typedef struct noise_estimation_structure Word16 act_pred_fx; /* Q15 Tonal detector - prediction of speech activity from 0 to 1 (0-inactive, 1-active) */ Word16 multi_harm_limit_fx; /* Q9 Tonal detector - adaptive threshold */ Word32 enrO_fx[NB_BANDS]; /* Noise estimator - previous energy per critical band */ - Word16 q_enr; + Word16 q_enrO; Word32 bckr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - background noise estimation per critical band */ Word16 q_bckr; Word32 ave_enr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - long-term average energy per critical band */ @@ -1840,13 +1842,13 @@ typedef struct tcx_enc_structure uint16_t enc_ste_pre_corr_past; #ifndef IVAS_FLOAT_FIXED float tfm_mem; /* state of IIR filtered temporal flatness measure */ + float buf_speech_ltp_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; #else Word32 tfm_mem_fx; /* state of IIR filtered temporal flatness measure Q31 */ + Word16 buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; #endif - float buf_speech_ltp_flt[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; float *speech_ltp_flt; float *new_speech_ltp_flt; - Word16 buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; #ifdef IVAS_FLOAT_FIXED Word16 exp_buf_speech_ltp; #endif @@ -1860,13 +1862,15 @@ typedef struct tcx_enc_structure #ifndef IVAS_FLOAT_FIXED float measuredBwRatio_flt; /* measured bw; used for TCX noise-filling */ #else - Word16 measuredBwRatio; /* measured bw; used for TCX noise-filling. 1Q14 */ + Word16 measuredBwRatio; /* measured bw; used for TCX noise-filling. 1Q14 */ #endif int16_t nmStartLine; /* Starting line for the noise measurement */ int16_t tcx_lpc_shaped_ari; +#ifndef IVAS_FLOAT_FIXED float old_out[L_FRAME32k]; +#endif Word16 old_out_fx[L_FRAME32k]; /* buffer for OLA; at the encoder, the maximum length is L_FRAME32k (corresponds to maximum internal L_frame length) */ Word16 Q_old_out; @@ -1874,21 +1878,21 @@ typedef struct tcx_enc_structure #ifndef IVAS_FLOAT_FIXED float prev_hi_ener_flt; #else - Word16 prev_hi_ener; /* Q8 */ + Word16 prev_hi_ener; /* Q8 */ #endif int16_t prev_hi_sparse; #ifndef IVAS_FLOAT_FIXED float clas_sec_old_flt; #else - Word16 clas_sec_old_fx; /* Q13 */ + Word16 clas_sec_old_fx; /* Q13 */ #endif int16_t clas_final_old; #ifndef IVAS_FLOAT_FIXED float last_gain1_flt; float last_gain2_flt; #else - Word32 last_gain1; /* Q(31 - st->last_enerBuffer_exp) */ - Word32 last_gain2; /* Q(31 - st->last_enerBuffer_exp) */ + Word32 last_gain1; /* Q(31 - st->last_enerBuffer_exp) */ + Word32 last_gain2; /* Q(31 - st->last_enerBuffer_exp) */ #endif /* TCX memory */ @@ -1900,7 +1904,7 @@ typedef struct tcx_enc_structure float *acelp_zir_flt; float tcx_target_bits_fac_flt; #else - Word16 tcx_target_bits_fac; /* Q14 */ + Word16 tcx_target_bits_fac; /* Q14 */ #endif int16_t tns_ms_flag[2]; @@ -2021,8 +2025,8 @@ typedef struct enc_core_structure float prev_fmerit_flt; /* previous signal classification score*/ float fmerit_dt_flt; /* signal classification score difference */ #else - Word16 prev_fmerit; /* previous signal classification score Q15 */ - Word16 fmerit_dt; /* signal classification score difference Q15 */ + Word16 prev_fmerit; /* previous signal classification score Q15 */ + Word16 fmerit_dt; /* signal classification score difference Q15 */ #endif int16_t Nb_ACELP_frames; @@ -2031,7 +2035,7 @@ typedef struct enc_core_structure #ifndef IVAS_FLOAT_FIXED float voicing[3]; /* open-loop normalized correlation values for three half-frames */ #else - Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ + Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ #endif LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ @@ -2047,20 +2051,20 @@ typedef struct enc_core_structure float lsp_old16k[M]; /* old LSP vector at the end of the frame @16kHz */ float lspold_enc[M]; /* old lsp (immittance spectral pairs) */ #else - 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 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 */ #endif int16_t pstreaklen; /* LSF quantizer */ #ifndef IVAS_FLOAT_FIXED float streaklimit; /* LSF quantizer */ float stab_fac; /* LSF stability factor */ #else - Word16 streaklimit_fx; /* LSF quantizer Q15 */ - Word16 stab_fac_fx; /* LSF stability factor Q15 */ + Word16 streaklimit_fx; /* LSF quantizer Q15 */ + Word16 stab_fac_fx; /* LSF stability factor Q15 */ #endif float mem_preemph; /* preemphasis filter memory */ float old_wsp[L_WSP_MEM]; /* old weighted signal vector */ @@ -2072,9 +2076,9 @@ typedef struct enc_core_structure float mem_AR[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ float mem_MA[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ #else - 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 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) */ #endif // Word16 pstreaklen_fx; /* LSF quantizer */ Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ @@ -2108,9 +2112,9 @@ typedef struct enc_core_structure float lsfoldbfi1[M]; /* FEC - LSF vector of the past previous frame */ float lsf_adaptive_mean[M]; /* FEC - adaptive mean LSF vector for FEC */ #else - Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame Qlog2(2.56) */ - 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 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame Qlog2(2.56) */ + 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) */ #endif int16_t 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 */ @@ -2121,15 +2125,15 @@ typedef struct enc_core_structure float ge_sm; /* Stationary noise UV modification - smoothed excitation gain */ float lspold_s[M]; /* Stationary noise UV modification - old LSP vector */ #else - Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT) */ - Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15 */ + Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT) */ + Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15 */ #endif int16_t noimix_seed; /* Stationary noise UV modification - mixture seed */ #ifndef IVAS_FLOAT_FIXED float min_alpha; /* Stationary noise UV modification - minimum alpha */ float exc_pe; /* Stationary noise UV modification - memory of the preemphasis filter */ #else - Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15 */ + Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15 */ #endif Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ @@ -2140,15 +2144,15 @@ typedef struct enc_core_structure float old_thres; /* normalized correlation weighting in open-loop pitch */ float old_corr; /* normalized correlation in previous frame (mean value) */ #else - Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ - Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ + Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ + Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ #endif int16_t old_pitch; /* previous pitch for open-loop pitch search */ int16_t delta_pit; /* open-loop pitch extrapolation correction */ #ifndef IVAS_FLOAT_FIXED float ee_old; /* previous frame low/high frequency energy ratio */ #else - Word32 ee_old_fx; /* previous frame low/high frequency energy ratio Q6 */ + Word32 ee_old_fx; /* previous frame low/high frequency energy ratio Q6 */ #endif int16_t min_band; /* minimum critical band of useful bandwidth */ int16_t max_band; /* maximum critical band of useful bandwidth */ @@ -2157,13 +2161,13 @@ typedef struct enc_core_structure #ifndef IVAS_FLOAT_FIXED float old_dE1; /* Maximum energy increase in previous frame */ #else - Word32 old_dE1_fx; /* Maximum energy increase in previous frame Q13 */ + Word32 old_dE1_fx; /* Maximum energy increase in previous frame Q13 */ #endif int16_t old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ #ifndef IVAS_FLOAT_FIXED float old_enr_ssf[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ #else - Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ + Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ #endif int16_t spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ int16_t last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ @@ -2172,7 +2176,7 @@ typedef struct enc_core_structure float old_Aq_12_8[M + 1]; /* old Aq[] for core switching */ float old_Es_pred; /* old Es_pred for core switching */ #else - Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ + Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ #endif Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ Word16 last_vad_spa_fx; @@ -2196,9 +2200,9 @@ typedef struct enc_core_structure float pst_mem_deemp_err; /* Bass post-filter - filter memory of noise LP filter */ float pst_lp_ener; /* Bass post-filter - long-term energy */ #else - Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values Q6 */ - Word16 pst_mem_deemp_err_fx; /* Bass post-filter - filter memory of noise LP filter */ - Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy */ + Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /* Bass post-filter - buffer of old subframe pitch values Q6 */ + Word16 pst_mem_deemp_err_fx; /* Bass post-filter - filter memory of noise LP filter */ + Word16 pst_lp_ener_fx; /* Bass post-filter - long-term energy */ #endif /* stable short pitch detection */ @@ -2255,7 +2259,9 @@ typedef struct enc_core_structure float *old_inp_12k8; /* memory of input signal at 12.8kHz */ float *old_inp_16k; /* ACELP@16kHz - memory of input signal @16 kHz */ float *buf_speech_enc_pe_flt; +#ifndef IVAS_FLOAT_FIXED float *buf_synth_flt; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ +#endif float *buf_speech_enc_flt; float *buf_wspeech_enc_flt; Word32 *Bin_E_old_fx; /* per bin energy of old 2nd frames */ -- GitLab