From f2d2780d51c7b6c08031bf9057183a89be3e6302 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Oct 2025 12:58:17 +0100 Subject: [PATCH] align ivas-float-update 312fc7744 to float-main 4fb9f6517 --- lib_enc/acelp_core_enc.c | 8 +- lib_enc/acelp_core_switch_enc.c | 21 +++++ lib_enc/amr_wb_enc.c | 4 - lib_enc/cod_tcx.c | 2 - lib_enc/dtx.c | 2 +- lib_enc/enc_acelp_tcx_main.c | 7 +- lib_enc/evs_enc.c | 12 ++- lib_enc/fd_cng_enc.c | 99 +++++++++++++++++++++- lib_enc/hq_classifier_enc.c | 2 - lib_enc/hq_lr_enc.c | 72 ++++++++++++++-- lib_enc/ivas_core_enc.c | 6 +- lib_enc/ivas_core_pre_proc_front.c | 78 ++--------------- lib_enc/ivas_corecoder_enc_reconfig.c | 2 +- lib_enc/ivas_cpe_enc.c | 116 ++++++++++---------------- lib_enc/ivas_decision_matrix_enc.c | 52 +----------- lib_enc/ivas_dirac_enc.c | 2 +- lib_enc/ivas_front_vad.c | 2 - lib_enc/ivas_init_enc.c | 10 +-- lib_enc/ivas_ism_enc.c | 28 +------ lib_enc/ivas_ism_metadata_enc.c | 12 --- lib_enc/ivas_masa_enc.c | 6 +- lib_enc/ivas_mc_param_enc.c | 3 +- lib_enc/ivas_mct_core_enc.c | 3 + lib_enc/ivas_omasa_enc.c | 1 - lib_enc/ivas_osba_enc.c | 7 +- lib_enc/ivas_qmetadata_enc.c | 9 +- lib_enc/ivas_sce_enc.c | 12 +-- lib_enc/ivas_spar_md_enc.c | 4 +- lib_enc/ivas_stat_enc.h | 8 -- lib_enc/ivas_stereo_classifier.c | 82 +++++------------- lib_enc/ivas_stereo_dft_enc.c | 14 +++- lib_enc/ivas_stereo_dmx_evs.c | 3 - lib_enc/ivas_stereo_mdct_core_enc.c | 8 ++ lib_enc/ivas_stereo_mdct_stereo_enc.c | 15 ++++ lib_enc/ivas_tcx_core_enc.c | 3 - lib_enc/lib_enc.c | 37 +------- lib_enc/lib_enc.h | 10 +-- lib_enc/pre_proc.c | 20 +++-- lib_enc/pvq_core_enc.c | 6 ++ lib_enc/stat_enc.h | 7 +- lib_enc/swb_bwe_enc.c | 6 ++ lib_enc/transient_detection.c | 12 --- 42 files changed, 366 insertions(+), 447 deletions(-) diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index dfa6766d4..ccc96242b 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -381,6 +381,7 @@ ivas_error acelp_core_enc( /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ + if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); @@ -694,12 +695,7 @@ ivas_error acelp_core_enc( if ( !st->Opt_SC_VBR && ( st->idchan == 0 || st->element_mode != IVAS_CPE_TD || ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) ) { /* Apply a non linearity to the SHB excitation */ - non_linearity( bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame -#ifdef NONBE_1328_FIX_NON_LINEARITY - , - st->element_mode -#endif - ); + non_linearity( bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame, st->element_mode ); } if ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index 07717c609..f5742b373 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -123,11 +123,32 @@ void acelp_core_switch_enc( } } +#ifdef FIX_I4_OL_PITCH + if ( st->last_codec_mode == MODE1 ) + { + /* in MODE1 T_op is at 12.8 kHz */ + if ( st->last_L_frame != L_FRAME ) /* ACELP@16k core -> convert T_op to 16 kHz */ + { + T_op[0] = (short) ( 1.25f * T_op[0] + 0.5f ); + T_op[1] = (short) ( 1.25f * T_op[1] + 0.5f ); + } + } + else + { + /* in MODE2 T_op is at 16 kHz */ + if ( st->last_L_frame == L_FRAME ) /* ACELP@12.8k core -> convert T_op to 12.8 kHz */ + { + T_op[0] = (short) ( 0.8f * T_op[0] + 0.5f ); + T_op[1] = (short) ( 0.8f * T_op[1] + 0.5f ); + } + } +#else if ( st->last_L_frame != L_FRAME ) /* ACELP@16k core */ { T_op[0] = (short) ( 1.25f * T_op[0] + 0.5f ); T_op[1] = (short) ( 1.25f * T_op[1] + 0.5f ); } +#endif /*----------------------------------------------------------------* * Excitation encoding *----------------------------------------------------------------*/ diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index df5e82f8b..1a507f473 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -108,8 +108,6 @@ void amr_wb_enc( LPD_state_HANDLE hLPDmem = st->hLPDmem; - push_wmops( "amr_wb_enc" ); - /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -552,8 +550,6 @@ void amr_wb_enc( dbgwrite( snr_[0], sizeof( float ), 320, 1, "res/snr" ); #endif - pop_wmops(); - return; } diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 9a890ae3c..87e703d16 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -332,7 +332,6 @@ void TNSAnalysisStereo( pFilter[0]->order = pFilter[1]->order = maxOrder; } -#ifdef FIX_1349_TNS_CRASH else { pFilter[0]->filterType = TNS_FILTER_OFF; @@ -340,7 +339,6 @@ void TNSAnalysisStereo( sts[0]->hTcxEnc->tnsData[k].nFilters = 0; sts[1]->hTcxEnc->tnsData[k].nFilters = 0; } -#endif } } } diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index c553fe2f8..8c2ec5f7a 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -142,7 +142,6 @@ void dtx( last_br_cng_flag ) { st->total_brate = st->last_total_brate_cng; - if ( !( st->total_brate == ACELP_7k20 && st->Opt_SC_VBR ) ) { st->Opt_SC_VBR = 0; @@ -158,6 +157,7 @@ void dtx( last_br_flag ) { st->total_brate = st->last_total_brate; + if ( !( st->total_brate == ACELP_7k20 && st->Opt_SC_VBR ) ) { st->Opt_SC_VBR = 0; diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c index 8851d9be5..f2dc342a0 100644 --- a/lib_enc/enc_acelp_tcx_main.c +++ b/lib_enc/enc_acelp_tcx_main.c @@ -99,12 +99,7 @@ void enc_acelp_tcx_main( /* Apply non linearity to the SHB excitation */ if ( st->core == ACELP_CORE && st->igf ) { - non_linearity( ptr_bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame -#ifdef NONBE_1328_FIX_NON_LINEARITY - , - st->element_mode -#endif - ); + non_linearity( ptr_bwe_exc, bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale, st->coder_type, voice_factors, st->L_frame, st->element_mode ); /* update the old_BWE_exc memory */ mvr2r( &old_bwe_exc[L_FRAME32k], st->hBWE_TD->old_bwe_exc, PIT16k_MAX * 2 ); diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index d22e3d3fd..576462cd7 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -95,7 +95,9 @@ ivas_error evs_enc( int16_t padBits; float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* real buffer */ float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* imag buffer */ - int16_t pitch_orig[3]; /* original open-loop pitch values that might be altered in core_acelp_tcx20_switching() within MODE2 */ +#ifndef FIX_I4_OL_PITCH + int16_t pitch_orig[3]; /* original open-loop pitch values that might be altered in core_acelp_tcx20_switching() within MODE2 */ +#endif ivas_error error; error = IVAS_ERR_OK; @@ -168,7 +170,11 @@ ivas_error evs_enc( * Pre-processing *---------------------------------------------------------------------*/ +#ifdef FIX_I4_OL_PITCH + pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); +#else pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &ener, pitch_orig, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); +#endif if ( st->mdct_sw == MODE2 ) { @@ -257,10 +263,12 @@ ivas_error evs_enc( core_switching_post_enc( st, old_inp_12k8, old_inp_16k, A ); +#ifndef FIX_I4_OL_PITCH if ( st->core == HQ_CORE ) { mvs2s( pitch_orig, st->pitch, 3 ); /* original open-loop pitch values might be altered in core_acelp_tcx20_switching() */ } +#endif } else /* MODE2 */ @@ -285,7 +293,9 @@ ivas_error evs_enc( /* Call main encoding function */ enc_acelp_tcx_main( st, old_inp_16k + L_INP_MEM, Aw, lsp_new, lsp_mid, bwe_exc_extended, voice_factors, pitch_buf, vad_hover_flag ); +#ifndef FIX_I4_OL_PITCH mvs2s( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back */ +#endif /*---------------------------------------------------------------------* * Postprocessing for Mode 1/2 switching diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index da13d3deb..84282281a 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -34,6 +34,8 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ +#include "cnst.h" +#include "ivas_cnst.h" #include #include #include "options.h" @@ -43,6 +45,9 @@ #include #include "rom_enc.h" #include "rom_com.h" +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG +#include "ivas_rom_com.h" +#endif #include "prot.h" #include "ivas_prot.h" #include "stat_enc.h" @@ -154,7 +159,14 @@ void initFdCngEnc( set_f( hFdCngEnc->msLogPeriodog, 0.0f, NPART ); set_f( hFdCngEnc->msLogNoiseEst, 0.0f, NPART ); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + for ( int16_t i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + set_f( hFdCngEnc->mem_coherence[i], EPSILON, 4 ); + } +#else set_f( hFdCngEnc->mem_coherence, EPSILON, 4 ); +#endif return; } @@ -891,7 +903,14 @@ void stereoFdCngCoherence( if ( last_element_mode != IVAS_CPE_MDCT ) { +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + for ( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + set_f( sts[0]->hFdCngEnc->mem_coherence[i], EPSILON, 4 ); + } +#else set_f( sts[0]->hFdCngEnc->mem_coherence, EPSILON, 4 ); +#endif } if ( sts[0]->core_brate == -1 || sts[1]->core_brate == -1 ) @@ -941,8 +960,65 @@ void stereoFdCngCoherence( pt_fftL = fft_buff[0]; pt_fftR = fft_buff[1]; +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG mem = sts[0]->hFdCngEnc->mem_coherence; +#endif + + /* only estimate coherence in inactive frames (or in the first 50 frames to build an initial value) */ + if ( !( sts[0]->ini_frame <= 50 || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) ) + { + return; + } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + for ( i_subfr = 0; i_subfr < 2; i_subfr++ ) + { + int16_t band_len_cum; + + band_len_cum = 0; + i = MDCT_ST_DTX_FIRST_BAND_OFFSET; + + for ( int16_t b = 0; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + band_len_cum += mdct_stereo_dtx_coherence_bandlengths[b]; + cr = ci = eL = eR = EPSILON; + mem = sts[0]->hFdCngEnc->mem_coherence[b]; + + /* for last band, we need to make adjustments to fit with the FFT buffer layout */ + /* do the calculations for fftbin 0 (not anymore as it is skipped - we only calculate coherence above the 2nd bin) and L_FFT/2 outside the loop - imaginary part is always zero there, but not part of the buffer */ + if ( b == MDCT_ST_DTX_NUM_COHERENCE_BANDS - 1 ) + { + /* this calculates values for fft bin at L_FFT/2 - no imaginary value there, not even part of the array */ + cr += pt_fftL[L_FFT / 2] * pt_fftR[L_FFT / 2]; + eL += pt_fftL[L_FFT / 2] * pt_fftL[L_FFT / 2]; + eR += pt_fftR[L_FFT / 2] * pt_fftR[L_FFT / 2]; + + /* skip last fft bin (fs/2 Hz) bin in the loop later */ + --band_len_cum; + } + + for ( ; i < band_len_cum; i++ ) + { + cr += pt_fftL[i] * pt_fftR[i] + pt_fftL[L_FFT - i] * pt_fftR[L_FFT - i]; + ci += -pt_fftL[i] * pt_fftR[L_FFT - i] + pt_fftR[i] * pt_fftL[L_FFT - i]; + eL += pt_fftL[i] * pt_fftL[i] + pt_fftL[L_FFT - i] * pt_fftL[L_FFT - i]; + eR += pt_fftR[i] * pt_fftR[i] + pt_fftR[L_FFT - i] * pt_fftR[L_FFT - i]; + } + + mem[0] = 0.95f * mem[0] + 0.05f * cr; + mem[1] = 0.95f * mem[1] + 0.05f * ci; + mem[2] = 0.95f * mem[2] + 0.05f * eL; + mem[3] = 0.95f * mem[3] + 0.05f * eR; + + /* could be done outside the loop, as the second assignment overwrites the first, but this would mean a second loop over bands */ + sts[0]->hFdCngEnc->hFdCngCom->coherence[b] = sqrtf( ( mem[0] * mem[0] + mem[1] * mem[1] ) / ( mem[2] * mem[3] ) ); + } + + pt_fftL += L_FFT; + pt_fftR += L_FFT; + } + +#else for ( i_subfr = 0; i_subfr < 2; i_subfr++ ) { cr = ci = eL = eR = EPSILON; @@ -970,8 +1046,10 @@ void stereoFdCngCoherence( pt_fftL += L_FFT; pt_fftR += L_FFT; } - +#endif +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG sts[0]->hFdCngEnc->hFdCngCom->coherence = sqrtf( ( mem[0] * mem[0] + mem[1] * mem[1] ) / ( mem[2] * mem[3] ) ); +#endif return; } @@ -1172,7 +1250,11 @@ void FdCngEncodeMDCTStereoSID( } /* quantize channel coherence */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + coh_idx = (int16_t) floor( sts[0]->hFdCngEnc->hFdCngCom->coherence[0] * 15.f + 0.5f ); +#else coh_idx = (int16_t) floor( sts[0]->hFdCngEnc->hFdCngCom->coherence * 15.f + 0.5f ); +#endif coh_idx = max( 0, min( coh_idx, 15 ) ); /* ---- Write SID bitstream ---- */ @@ -1206,8 +1288,18 @@ void FdCngEncodeMDCTStereoSID( push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + /* write the four additional coherence values */ + for ( int16_t b = 1; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + coh_idx = (int16_t) floor( sts[0]->hFdCngEnc->hFdCngCom->coherence[b] * 15.f + 0.5f ); + coh_idx = max( 0, min( coh_idx, 15 ) ); + push_indice( sts[1]->hBstr, IND_ENERGY, coh_idx, 4 ); + } +#else /* pad with zeros to reach common SID frame size */ push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); +#endif return; @@ -1348,8 +1440,13 @@ void FdCngEncodeDiracMDCTStereoSID( sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + sts[0]->hFdCngEnc->hFdCngCom->coherence[0] = 0.0f; + sts[1]->hFdCngEnc->hFdCngCom->coherence[0] = 0.0f; +#else sts[0]->hFdCngEnc->hFdCngCom->coherence = 0.0f; sts[1]->hFdCngEnc->hFdCngCom->coherence = 0.0f; +#endif /* ---- Write SID bitstream ---- */ diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c index 7d5efe2e4..aa2512901 100644 --- a/lib_enc/hq_classifier_enc.c +++ b/lib_enc/hq_classifier_enc.c @@ -573,7 +573,6 @@ static int16_t hf_spectrum_sparseness( inv_rms = 0.0f; crest_mod = 0.0f; maximum( A, L_SPEC_HB, &Amax ); - if ( Amax == 0 ) { /* For all-zero input the crest is 1.0 */ @@ -626,7 +625,6 @@ static int16_t hf_spectrum_sparseness( crest = Amax * inv_rms; crest_mod = crest_mod * inv_rms; } - *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest; *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod; diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c index a66fa37d0..13637fdbd 100644 --- a/lib_enc/hq_lr_enc.c +++ b/lib_enc/hq_lr_enc.c @@ -195,7 +195,9 @@ void hq_lr_enc( Word32 L_band_energy[BANDS_MAX], L_band_energy_tmp[BANDS_MAX]; UWord16 lo; Word16 Q_band_energy; +#ifdef BASOP_NOGLOB Flag Overflow; +#endif /* BASOP_NOGLOB */ BSTR_ENC_HANDLE hBstr = st->hBstr; HQ_ENC_HANDLE hHQ_core = st->hHQ_core; @@ -337,7 +339,7 @@ void hq_lr_enc( #ifdef BASOP_NOGLOB Ep_fx[i] = L_shl_o( L_tmp, s_max( sub( exp, 6 ), -31 ), &Overflow ); /* Q -6 */ #else - Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ + Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ #endif Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); } @@ -412,7 +414,11 @@ void hq_lr_enc( } ELSE { +#ifdef BASOP_NOGLOB Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#else + Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ +#endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; @@ -531,10 +537,17 @@ void hq_lr_enc( move16(); } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); +#ifndef BASOP_NOGLOB + L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_max( L_tmp, 16384 ); /*14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ +#else /* BASOP_NOGLOB */ L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ L_tmp = L_max( L_tmp, 16384 ); /*14 */ tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ +#endif /* BASOP_NOGLOB */ } ELSE { @@ -577,7 +590,11 @@ void hq_lr_enc( { IF( sub( i, lowband ) >= 0 ) { +#ifdef BASOP_NOGLOB Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#else + Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#endif } ELSE { @@ -616,8 +633,13 @@ void hq_lr_enc( Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); - L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ +#ifndef BASOP_NOGLOB + L_tmp = L_shl( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ + tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ +#else /* BASOP_NOGLOB */ + L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ + tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ +#endif /* BASOP_NOGLOB */ Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ } @@ -643,7 +665,11 @@ void hq_lr_enc( bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */ FOR( i = 0; i < bands; i++ ) { +#ifndef BASOP_NOGLOB + Ep_tmp_fx[i] = L_shl( Ep_tmp_fx[i], 2 ); +#else /* BASOP_NOGLOB */ Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); +#endif /* BASOP_NOGLOB */ } IF( st->core_brate == ACELP_13k20 ) { @@ -677,7 +703,11 @@ void hq_lr_enc( IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 ) { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#ifndef BASOP_NOGLOB + Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else /* BASOP_NOGLOB */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif /* BASOP_NOGLOB */ } IF( sub( i, highband ) >= 0 ) @@ -710,7 +740,11 @@ void hq_lr_enc( tmp = sub( bands, p2a_bands ); tmp = sub( tmp, lowband ); /*Q0 */ - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#ifndef BASOP_NOGLOB + tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ +#else + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -749,7 +783,11 @@ void hq_lr_enc( { tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); - tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ +#ifndef BASOP_NOGLOB + tmp = extract_h( L_shl( L_tmp, 16 ) ); /*Q0 */ +#else /* BASOP_NOGLOB */ + tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ +#endif /* BASOP_NOGLOB */ IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -774,7 +812,11 @@ void hq_lr_enc( { tmp = sub( tmp, lowband ); - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#ifndef BASOP_NOGLOB + tmp1 = extract_h( L_shl( Ep_avrg_fx, 1 ) ); /*Q0 */ +#else + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -812,11 +854,19 @@ void hq_lr_enc( { IF( sub( i, lowband ) >= 0 ) { - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#ifndef BASOP_NOGLOB + Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else /* BASOP_NOGLOB */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif /* BASOP_NOGLOB */ } ELSE { +#ifndef BASOP_NOGLOB + Ep_avrgL_fx = L_add( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ +#else /* BASOP_NOGLOB */ Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif /* BASOP_NOGLOB */ IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; @@ -836,7 +886,11 @@ void hq_lr_enc( move16(); FOR( i = 0; i < lowband; i++ ) { - tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ +#ifndef BASOP_NOGLOB + tmp = extract_h( L_shl( Ep_avrgL_fx, 1 ) ); /*Q0 */ +#else + tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp != 0 ) { exp = norm_s( tmp ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index cdf012b3f..35ac987a0 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -90,9 +90,7 @@ ivas_error ivas_core_enc( float *inp[CPE_CHANNELS]; float new_inp_resamp16k[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ - float *shb_speech; - float *hb_speech; - float *new_swb_speech; + float *shb_speech, *hb_speech, *new_swb_speech; float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX]; float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; @@ -272,7 +270,6 @@ ivas_error ivas_core_enc( } } - /*---------------------------------------------------------------------* * MDCT stereo: joint TCX Core Encoding *---------------------------------------------------------------------*/ @@ -314,7 +311,6 @@ ivas_error ivas_core_enc( } } - /*---------------------------------------------------------------------* * Postprocessing, BWEs and Updates *---------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b24fab48e..597275de1 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -34,6 +34,7 @@ #include "options.h" #ifdef DEBUGGING #include "debug.h" +#include #endif #include "cnst.h" #include "ivas_cnst.h" @@ -43,9 +44,6 @@ #include "ivas_prot.h" #include "wmc_auto.h" #include -#ifdef DEBUG_MODE_INFO -#include "string.h" -#endif /*---------------------------------------------------------------* @@ -111,13 +109,9 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#ifdef DEBUG_MODE_INFO - , - const int16_t ch_idx -#endif ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ @@ -228,12 +222,12 @@ ivas_error pre_proc_front_ivas( } #ifdef DEBUG_MODE_INFO - if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) + if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && n > 0 ) ) { /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */ int16_t tmp_dmx_in[L_FRAME48k]; mvr2s( signal_in - NS2SA( st->input_Fs, ACELP_LOOK_NS ), tmp_dmx_in, input_frame ); - dbgwrite( tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); + dbgwrite( tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, n + 1, ENC ), ".pcm" ) ); } #endif @@ -459,16 +453,6 @@ ivas_error pre_proc_front_ivas( st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f ); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); - } -#endif if ( force_front_vad == 1 || front_vad_flag == 1 ) { @@ -517,17 +501,6 @@ ivas_error pre_proc_front_ivas( st->bwidth = hCPE->hCoreCoder[0]->bwidth; } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); - } -#endif - /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates @@ -728,19 +701,6 @@ ivas_error pre_proc_front_ivas( st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, &dE1X, corr_shift, *relE, Etot, hp_E, &flag_spitch, last_core_orig, hStereoClassif ); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) ); - dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" ); - dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" ); - } -#endif - /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ @@ -777,17 +737,6 @@ ivas_error pre_proc_front_ivas( smc_dec = ivas_smc_gmm( st, hStereoClassif, localVAD_HE_SAD, Etot, lsp_new, *cor_map_sum, epsP, PS, non_staX, *relE, &high_lpn_flag, flag_spitch ); -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); - } -#endif - #ifdef DEBUGGING if ( st->idchan == 0 ) { @@ -896,23 +845,6 @@ ivas_error pre_proc_front_ivas( ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch ); } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); - dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); - dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); - dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); - dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); - } -#endif - /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index dcab60608..08cac66ff 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -173,6 +173,7 @@ ivas_error ivas_corecoder_enc_reconfig( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( temp_ind_list[i].function_name, hBstr->ind_list[i].function_name, 100 ); #endif + hBstr->ind_list[i].nb_bits = -1; } @@ -458,7 +459,6 @@ ivas_error ivas_corecoder_enc_reconfig( } else if ( st_ivas->hMCT != NULL && st_ivas->nCPE > 1 ) { - if ( ( error = mct_enc_reconfigure( st_ivas, nchan_transport_old_real != nchan_transport_real ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 130feca42..188ea1ea3 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -161,9 +161,6 @@ ivas_error ivas_cpe_enc( #ifdef DEBUGGING sts[n]->force = hEncoderConfig->force; sts[n]->id_element = cpe_id + st_ivas->nSCE; -#ifdef DEBUG_FORCE_DIR - sts[n]->force_dir = hEncoderConfig->force_dir; -#endif #endif } @@ -182,19 +179,6 @@ ivas_error ivas_cpe_enc( { hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); } -#ifdef DEBUG_FORCE_DIR - else - { - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &hCPE->element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); - } - } -#endif stereo_mode_combined_format_enc( st_ivas, hCPE ); @@ -301,6 +285,7 @@ ivas_error ivas_cpe_enc( sts[n]->element_mode = hCPE->element_mode; } + if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { @@ -376,21 +361,6 @@ ivas_error ivas_cpe_enc( { #ifdef DEBUGGING hCPE->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->mdct_stereo_mode_cmdl; -#ifdef DEBUG_FORCE_MDCT_STEREO_MODE - /*set all other members to defined states */ - hCPE->hStereoMdct->fDualMono = 0; - hCPE->hStereoMdct->fMSstereo = 0; - - if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_LR ) - { - hCPE->hStereoMdct->fDualMono = 1; - } - else if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_MS ) - { - hCPE->hStereoMdct->fMSstereo = 1; - } -#endif - #endif initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 0 ); hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); @@ -420,6 +390,7 @@ ivas_error ivas_cpe_enc( #ifdef DEBUG_MODE_DFT hCPE->hStereoDft->res_cod_bits = (int16_t) ( ( hCPE->element_brate ) / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal ); #endif + /* Update DFT Stereo memories */ stereo_dft_enc_update( hCPE->hStereoDft, max_bwidth ); @@ -492,6 +463,10 @@ ivas_error ivas_cpe_enc( } #ifdef DEBUG_MODE_INFO + for ( n = 0; n < n_CoreChannels; n++ ) + { + dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) ); + } dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) ); #endif @@ -508,12 +483,7 @@ ivas_error ivas_cpe_enc( 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], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, 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, hEncoderConfig->last_ivas_total_brate, ivas_total_brate -#ifdef DEBUG_MODE_INFO - , - ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) -#endif - ); + fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, 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, hEncoderConfig->last_ivas_total_brate, ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; @@ -558,47 +528,59 @@ ivas_error ivas_cpe_enc( * Core codec configuration *----------------------------------------------------------------*/ - if ( hCPE->element_mode == IVAS_CPE_MDCT && st_ivas->hMCT == NULL ) +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING + if ( !( sts[0]->core_brate == SID_2k40 || sts[0]->core_brate == FRAME_NO_DATA ) ) /* Reconfigurations not needed with DTX*/ { - /* set coded BW for MDCT stereo */ - set_bw_stereo( hCPE ); - - /* reconfiguration of MDCT stereo */ - if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) ) +#endif + if ( hCPE->element_mode == IVAS_CPE_MDCT && st_ivas->hMCT == NULL ) { - initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); - hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); + /* set coded BW for MDCT stereo */ + set_bw_stereo( hCPE ); - if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT ) + /* reconfiguration of MDCT stereo */ + if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) ) { - if ( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); + hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); + + if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT ) { - return error; + if ( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } } } - } - /* IGF reconfiguration */ - for ( n = 0; n < n_CoreChannels; n++ ) - { - if ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->element_mode != hCPE->last_element_mode || ( hCPE->element_mode == IVAS_CPE_TD && sts[0]->bits_frame_nominal != last_bits_frame_nominal ) || sts[n]->last_bwidth != sts[n]->bwidth ) && ( n == 0 || hCPE->element_mode == IVAS_CPE_MDCT ) ) + /* IGF reconfiguration */ + for ( n = 0; n < n_CoreChannels; n++ ) { - int16_t igf; - int16_t bw; + if ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->element_mode != hCPE->last_element_mode || ( hCPE->element_mode == IVAS_CPE_TD && sts[0]->bits_frame_nominal != last_bits_frame_nominal ) || sts[n]->last_bwidth != sts[n]->bwidth +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING + || ( sts[n]->last_core_brate == SID_2k40 || sts[n]->last_core_brate == FRAME_NO_DATA ) +#endif + ) && + ( n == 0 || hCPE->element_mode == IVAS_CPE_MDCT ) ) + { + int16_t igf; + int16_t bw; - bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth; - igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); + bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth; + igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); #ifdef FIX_1413_IGF_INIT_PRINTOUT - if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) #else if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) #endif - { - return error; + { + return error; + } } } +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING } +#endif /* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */ for ( n = 0; n < n_CoreChannels; n++ ) @@ -1082,20 +1064,6 @@ ivas_error create_cpe_enc( #ifdef DEBUGGING hCPE->hStereoMdct->mdct_stereo_mode_cmdl = st_ivas->hEncoderConfig->mdct_stereo_mode_cmdl; -#ifdef DEBUG_FORCE_MDCT_STEREO_MODE - /*set all other members to defined states */ - hCPE->hStereoMdct->fDualMono = 0; - hCPE->hStereoMdct->fMSstereo = 0; - - if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_LR ) - { - hCPE->hStereoMdct->fDualMono = 1; - } - else if ( hCPE->hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_MS ) - { - hCPE->hStereoMdct->fMSstereo = 1; - } -#endif #endif initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 1 ); hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 65a98f87d..d9898c51b 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -166,17 +166,6 @@ void ivas_decision_matrix_enc( } } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc1.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc1.enf" ); - } -#endif - /* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */ if ( ( ( st->last_core == ACELP_CORE && last_element_mode == IVAS_CPE_TD && st->element_mode == IVAS_CPE_DFT ) || ( st->tdm_LRTD_flag == 1 && st->total_brate <= IVAS_16k4 ) ) && st->core == TCX_20_CORE && st->total_brate <= MAX_ACELP_BRATE ) /* Override TCX in case of LRTD && primary channel has low bitrate*/ { @@ -212,7 +201,7 @@ void ivas_decision_matrix_enc( { st->core = ACELP_CORE; } - else if ( st->force == FORCE_TCX20 || st->force == FORCE_TCX10 ) /* Initalizations should always happen with TCX20*/ + else if ( st->force == FORCE_TCX ) { st->core = TCX_20_CORE; } @@ -227,12 +216,14 @@ void ivas_decision_matrix_enc( if ( st->core == TCX_20_CORE && st->total_brate < STEREO_TCX_MIN_RATE ) { st->core = ACELP_CORE; + /* In TD stereo below 24.4 kbps we cannot overwrite the `coder_type` when it is set to TRANSITION, */ /* as it is used for TD stereo bit allocation. To ensure consistent bit allocation, it must remain unchanged on the decoder side. */ if ( st->idchan == 0 && !( element_brate < IVAS_24k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) ) { st->coder_type = AUDIO; } + st->sp_aud_decision2 = 0; if ( st->low_rate_mode ) @@ -247,17 +238,6 @@ void ivas_decision_matrix_enc( st->core = TCX_20_CORE; } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc2.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc2.enf" ); - } -#endif - /*---------------------------------------------------------------------* * Select ACELP and GSC extension layer *---------------------------------------------------------------------*/ @@ -292,19 +272,6 @@ void ivas_decision_matrix_enc( } } } - -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); - dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); - dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); - } -#endif } /* SWB and FB */ @@ -367,19 +334,6 @@ void ivas_decision_matrix_enc( st->extl_brate = 0; } -#ifdef DEBUG_FORCE_DIR - if ( st->force_dir[0] != '\0' ) - { - dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); - dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); - dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); - } -#endif - /* set IC-BWE bitrate */ if ( st->element_mode == IVAS_CPE_TD && ( st->idchan == 0 ) && !st->tdm_LRTD_flag ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 1a6290580..fc74cfeb0 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -291,7 +291,7 @@ ivas_error ivas_dirac_enc( const int16_t input_frame, /* i : input frame length */ const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ const int16_t hodirac_flag /* i : hodirac flag */ ) { diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index cb355ef4a..bfe47d07a 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -422,9 +422,7 @@ ivas_error front_vad_spar( } noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 ); - corr_shift = correlation_shift( hFrontVad->hNoiseEst->totalNoise ); - dtx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); /* linear prediction analysis */ diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 2143af94d..336e5fcbf 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -287,9 +287,6 @@ void copy_encoder_config( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; -#ifdef DEBUG_FORCE_DIR - st->force_dir = st_ivas->hEncoderConfig->force_dir; -#endif #endif st->element_mode = st_ivas->hEncoderConfig->element_mode_init; @@ -468,7 +465,8 @@ ivas_error ivas_init_encoder( { st_ivas->ind_list[i].nb_bits = -1; } -#ifdef BITSTERAM_ANALYSIS + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) { memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) ); @@ -754,13 +752,13 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ + { int16_t n_all; n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; st_ivas->nCPE = ( n_all + 1 ) >> 1; } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) @@ -784,7 +782,7 @@ ivas_error ivas_init_encoder( { st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); - if ( ( error = ivas_create_lfe_lpf_enc( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_create_lfe_lpf_enc( &st_ivas->hLfeLpf, input_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index e2df76f1c..d3db3490f 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -150,9 +150,6 @@ ivas_error ivas_ism_enc( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; -#ifdef DEBUG_FORCE_DIR - st->force_dir = st_ivas->hEncoderConfig->force_dir; -#endif #endif /*---------------------------------------------------------------* @@ -171,10 +168,6 @@ ivas_error ivas_ism_enc( st->bits_frame_nominal = (int16_t) ( ( hSCE->element_brate / FRAMES_PER_SEC ) - ISM_NB_BITS_METADATA_NOMINAL ); -#ifdef DEBUG_MODE_INFO - dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); -#endif - /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ @@ -186,12 +179,7 @@ ivas_error ivas_ism_enc( error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], - fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); + fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; @@ -431,21 +419,7 @@ ivas_error ivas_ism_enc( } } } - - for ( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ ) - { - float tmpF; - int16_t id; - - st = st_ivas->hSCE[sce_id]->hCoreCoder[0]; - id = st->id_element; - - tmpF = st->element_brate / 1000.0f; - dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, id, ENC ) ); - } - #endif - pop_wmops(); return error; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 06b0e4b99..a8c224d17 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -296,18 +296,6 @@ ivas_error ivas_ism_metadata_enc( } } -#ifdef DEBUG_FORCE_DIR - if ( hSCE[0]->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( ism_imp, sizeof( int16_t ), nchan_ism, fname( hSCE[0]->hCoreCoder[0]->force_dir, "force_ism_imp.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( ism_imp, sizeof( int16_t ), nchan_ism, 1, "res/force_ism_imp.enf" ); - } -#endif - - /*----------------------------------------------------------------* * Write ISM common signaling *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 7a4a250fe..0da38f8e2 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -482,7 +482,6 @@ ivas_error ivas_masa_encode( push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 ); hQMetaData->metadata_max_bits -= 1; } - /* write subframe mode */ push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS ); hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS; @@ -2637,7 +2636,6 @@ void ivas_merge_masa_metadata( float total_diff_nrg; float eneBand; float energyMerged[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy = hMasa->data.hOmasaData->hOmasaEnergy; numCodingBands = hMasa->config.numCodingBands; @@ -2680,7 +2678,7 @@ void ivas_merge_masa_metadata( total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band]; /* criterion is mean of ISM ratio and new ratio */ - energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ) ) ) / 2.0f * hOmasaEnergy->energy_ism[sf][band]; + energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->hOmasaEnergy->energy_ism[sf][band]; /* Determine combined metadata based on the weights */ merge_dest = -1; @@ -3451,7 +3449,6 @@ static void ivas_encode_masaism_metadata( for ( band = 0; band < omasa_nbands; band++ ) { energy_ism += hOmasaEnergy->energy_ism[sf][band]; - for ( obj = 0; obj < nchan_ism; obj++ ) { energy_ism_ind[obj] += hOmasaEnergy->energy_ism[sf][band] * hOmasaEnergy->energy_ratio_ism[sf][band][obj]; @@ -3669,7 +3666,6 @@ static void ivas_encode_masaism_metadata( } } - calculate_nbits_meta( nchan_ism, hOmasaEnergy->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); /* quantize directions */ diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 26cf981ca..25314cd89 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -62,7 +62,6 @@ static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, static void ivas_param_mc_transient_detection( PARAM_MC_ENC_HANDLE hParamMC, TRAN_DET_HANDLE hTranDet, int16_t *bAttackPresent, int16_t *attackIdx ); - static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_LS_CHANNELS][MAX_LS_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_LS_CHANNELS][MAX_LS_CHANNELS], float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); @@ -940,7 +939,7 @@ static void ivas_param_mc_quantize_ilds( const int16_t freq_idx, /* i : frequency index being processed */ const int16_t nchan_input, /* i : number of input channels */ const int16_t nchan_transport, /* i : number of transport channels */ - int16_t *ILD_idx_out, /* o : ILD indices */ + int16_t *ILD_idx_out, /* o : ILD indices */ float ILD_q[PARAM_MC_SZ_ILD_MAP] /* o : Quanzited ILD matrix */ ) { diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 59e04c5cb..4a46bd7b2 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -524,6 +524,7 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; + /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ if ( ivas_format == SBA_ISM_FORMAT ) { @@ -602,7 +603,9 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); + format_bits += ( ivas_format == SBA_ISM_FORMAT ); + mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index d38980016..660b4d2a0 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -1029,7 +1029,6 @@ static void ivas_omasa_energy_and_ratio_est( /* Reset variable */ for ( i = 0; i < hOMasa->nbands; i++ ) { - set_zero( hOmasaEnergy->energy_ratio_ism[block_m_idx][i], nchan_ism ); } set_zero( hOmasaEnergy->energy_ism[block_m_idx], num_freq_bands ); diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 438edc41c..993954560 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -182,12 +182,12 @@ ivas_error ivas_osba_enc_reconfig( ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; + error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; int16_t nchan_transport; - if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; @@ -329,8 +329,8 @@ ivas_error ivas_osba_enc_reconfig( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ - nchan_transport = st_ivas->nchan_transport; + nchan_transport = st_ivas->nchan_transport; if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { { @@ -342,7 +342,6 @@ ivas_error ivas_osba_enc_reconfig( { nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; - nchan_transport = st_ivas->nchan_transport; } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -478,5 +477,7 @@ static void ivas_osba_render_ism_to_sba( } } + /* Gain with loudness-matching gains */ + return; } diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 09a209840..6f436f8ad 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -46,6 +46,7 @@ #include #endif + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ @@ -958,7 +959,7 @@ void ivas_qmetadata_enc_sid_encode( BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */ - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ const int16_t ivas_format /* i : IVAS format */ ) { @@ -1293,7 +1294,7 @@ void reset_metadata_spatial( #endif hMetaData->nb_bits_tot += hMetaData->ind_list[j].nb_bits; hMetaData->ind_list[i].nb_bits = -1; -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +#ifdef DBG_BISTREAM_ANALYSIS sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" ); #endif } @@ -5755,6 +5756,7 @@ static float direction_distance( } #endif + static int16_t divide_GR_orders( const int16_t *q_idx, const int16_t GR1, @@ -6047,11 +6049,14 @@ void ivas_omasa_encode_masa_to_total( float data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; float q_dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; float step = STEP_M2T; + int16_t q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; float dct_data_tmp[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; float dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; + int16_t bits_pos, nb_bits; int16_t n_streams, len_stream; + Word32 q_dct_data_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 0f7e80cc1..5d1f56ab3 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -120,9 +120,6 @@ ivas_error ivas_sce_enc( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; -#ifdef DEBUG_FORCE_DIR - st->force_dir = st_ivas->hEncoderConfig->force_dir; -#endif #endif /*---------------------------------------------------------------* @@ -170,11 +167,13 @@ ivas_error ivas_sce_enc( /* set flag for sampling rate of OL S/M classifier */ flag_16k_smc = 0; if ( ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) + { flag_16k_smc = 1; } #ifdef DEBUG_MODE_INFO + dbgwrite( st->input - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, "res/input_DMX" ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); #endif @@ -190,12 +189,7 @@ ivas_error ivas_sce_enc( &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 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->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate -#ifdef DEBUG_MODE_INFO - , - st->id_element -#endif - ); + 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->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index ca9dfdea0..55902edde 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -424,7 +424,6 @@ static void ivas_band_mixing( } } } - return; } @@ -894,6 +893,7 @@ ivas_error ivas_spar_md_enc_process( hMdEnc->mixer_mat[i][j][b + 1] = prior_mixer[i][j][b + 1]; } } + mvr2r( P_quant_re_prior[b], hMdEnc->spar_md.band_coeffs[b].P_quant_re, FOA_CHANNELS - 1 ); mvr2r( P_quant_re_prior[b + 1], hMdEnc->spar_md.band_coeffs[b + 1].P_quant_re, FOA_CHANNELS - 1 ); } @@ -1721,6 +1721,7 @@ static void ivas_write_parameter_bitstream_dtx( float pr_min_max[2]; int16_t zero_pad_bits, sid_bits_len; int16_t sba_spar_bitlen; + sid_bits_len = hMetaData->nb_bits_tot; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -1778,6 +1779,7 @@ static void ivas_write_parameter_bitstream_dtx( sid_bits_len = hMetaData->nb_bits_tot - sid_bits_len; sba_spar_bitlen = ivas_sba_spar_sid_bitlen( num_dmx[0] ); zero_pad_bits = sba_spar_bitlen - sid_bits_len; + assert( zero_pad_bits >= 0 ); if ( num_dmx[0] == 2 ) { diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index e5ca0102a..2620fb3e9 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -39,10 +39,6 @@ #include "ivas_cnst.h" #include "stat_enc.h" #include "ivas_stat_com.h" -#ifdef DEBUG_FORCE_DIR -#include "debug.h" -#endif - /*----------------------------------------------------------------------------------* * DFT Stereo encoder structures @@ -806,7 +802,6 @@ typedef struct ivas_omasa_encoder_energy_struct } OMASA_ENCODER_ENERGY_STATE, *OMASA_ENCODER_ENERGY_HANDLE; - typedef struct ivas_omasa_encoder_data_struct { OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy; @@ -1213,9 +1208,6 @@ typedef struct encoder_config_structure int16_t stereo_mode_cmdl; /* stereo mode forced from the command-line */ int16_t force; /* parameter to force specific "core" of the Core-Coder*/ int16_t mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */ -#ifdef DEBUG_FORCE_DIR - char force_dir[FORCE_DIR_MAX_LENGTH]; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ -#endif #ifdef DEBUG_AGC_ENCODER_CMD_OPTION int16_t Opt_AGC_ON; /* flag indicating AGC operation in SBA */ #endif diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index e992ed790..597341d00 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -190,17 +190,6 @@ int16_t select_stereo_mode( } } -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); - } -#endif - if ( hCPE->last_element_mode != element_mode ) { if ( hCPE->last_element_mode != IVAS_CPE_DFT && hCPE->last_element_mode != IVAS_CPE_TD ) @@ -633,17 +622,6 @@ void unclr_classifier_td( dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/unclr_dec_hyst.x" ); #endif -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); - } -#endif - return; } @@ -734,17 +712,6 @@ void unclr_classifier_dft( dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/unclr_dec_hyst.x" ); #endif -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); - } -#endif - return; } @@ -835,6 +802,14 @@ void xtalk_classifier_td( minimum( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, &scr_min ); maximum( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, &scr_max ); +#ifdef DEBUG_MODE_TD + edge_type = 0; + edge_detect( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, -0.2f, 1.0f, &edge, &edge_type ); + edge_0_1 = lin_interp( 1 - edge, 1.0f, 1.0f, 0.6f, 0.0f, 1 ); + dbgwrite( &score, sizeof( float ), 1, 1, "res/score.x" ); + dbgwrite( &edge_0_1, sizeof( float ), 1, 1, "res/edge_0_1.x" ); +#endif + if ( ( ( scr_min < 0.0f && scr_max > 0.2f ) || ( scr_max - scr_min > 0.5f ) ) ) { /* test rising edge (use 0 as edge_type because of newer->older buffer samples ordering) */ @@ -856,6 +831,7 @@ void xtalk_classifier_td( edge_0_1 = 0.0f; } + /* weight raw score based on rising edge detector */ wedge = lin_interp( edge_0_1, 0.0f, 0.9f, 1.0f, 0.5f, 1 ); @@ -879,17 +855,6 @@ void xtalk_classifier_td( dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/xtalk_dec_hyst.x" ); #endif -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); - } -#endif - return; } @@ -1018,6 +983,13 @@ void xtalk_classifier_dft( minimum( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, &scr_min ); maximum( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, &scr_max ); +#ifdef DEBUG_MODE_TD + edge = redge_detect( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, -0.2f, 1.0f ); + edge_0_1 = lin_interp( 1 - edge, 1.0f, 1.0f, 0.83f, 0.0f, 1 ); + dbgwrite( &score, sizeof( float ), 1, 1, "res/score.x" ); + dbgwrite( &edge_0_1, sizeof( float ), 1, 1, "res/edge_0_1.x" ); +#endif + if ( scr_min < 0.2f && scr_max > 0.0f ) { edge = redge_detect( hStereoClassif->xtalk_score_buf, XTALK_SCORE_BUF_LEN, -0.2f, 1.0f ); @@ -1028,6 +1000,7 @@ void xtalk_classifier_dft( edge_0_1 = 0.0f; } + /* weight raw score based on rising edge detector */ wedge = lin_interp( edge_0_1, 0.0f, 0.95f, 1.0f, 0.3f, 1 ); hStereoClassif->xtalk_wscore = wedge * hStereoClassif->xtalk_wscore + ( 1 - wedge ) * score; @@ -1050,28 +1023,17 @@ void xtalk_classifier_dft( hStereoClassif->xtalk_decision = 1; } - /* updates */ - hItd->prev_m1 = m1; - hItd->prev_m2 = m2; - hItd->prev_itd1 = itd; - hItd->prev_itd2 = itd2; - #ifdef DEBUG_MODE_TD dbgwrite( &hStereoClassif->xtalk_wscore, sizeof( float ), 1, 1, "res/xtalk_wscore.x" ); dbgwrite( &dec, sizeof( int16_t ), 1, 1, "res/xtalk_dec.x" ); dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/xtalk_dec_hyst.x" ); #endif -#ifdef DEBUG_FORCE_DIR - if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) - { - dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); - } - else - { - dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); - } -#endif + /* updates */ + hItd->prev_m1 = m1; + hItd->prev_m2 = m2; + hItd->prev_itd1 = itd; + hItd->prev_itd2 = itd2; return; } diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index f3800d0c6..b583690cf 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -140,11 +140,9 @@ void stereo_dft_quantize_res_gains( } #ifdef DEBUGGING -#ifndef DISABLE_DFT_STEREO_ASSERT /* the following assertions should be satisfied by the input data: */ assert( 1 - gg * gg + EPSILON >= rr * rr / 2 ); assert( gg <= 1 ); -#endif #endif gg = min( gg, 1 - EPSILON ); @@ -1318,12 +1316,24 @@ void stereo_dft_enc_process( if ( hStereoDft->hItd->deltaItd[k_offset] != 0 && hStereoDft->hConfig->dmx_active ) { +#ifdef NONBE_FIX_NONBE_BETWEEN_OPTIMIZATION_LEVELS + /* Note: this variable is used as an in-between step when passing the angle to the trig functions. + * this keeps the compilter from applying optimizations at higher optimizaton levels which can break bit-exactness */ + volatile float alpha_tmp; +#endif /*time shift channels*/ alpha = -2.0f * EVS_PI * hStereoDft->hItd->deltaItd[k_offset] / hStereoDft->NFFT; c = 1.f; /*cos(0)*/ s = 0.f; /*sin(0)*/ +#ifdef NONBE_FIX_NONBE_BETWEEN_OPTIMIZATION_LEVELS + + alpha_tmp = alpha; + c1 = cosf( alpha_tmp ); + s1 = sinf( alpha_tmp ); +#else c1 = cosf( alpha ); s1 = sinf( alpha ); +#endif if ( alpha >= 0 ) { diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index edcc9f5fb..bf516cb97 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -1366,8 +1366,6 @@ void stereo_dmx_evs_enc( STEREO_DMX_EVS_PRC prev_prc; STEREO_DMX_EVS_PHA_HANDLE hPHA; - push_wmops( "stereo_dmx_evs_enc" ); - if ( is_binaural ) { /* use of is_binaural flag is to be considered */ @@ -1679,7 +1677,6 @@ void stereo_dmx_evs_enc( mvr2s( p_dmx_data, data, n_samples ); - pop_wmops(); return; } diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 1332dbbfc..5a0c175db 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -189,7 +189,15 @@ void stereo_mdct_core_enc( if ( hCPE->hCoreCoder[0]->igf ) { +#ifdef DEBUGGING + int16_t orig_mdct_stereo_mode_cmdl = hCPE->hStereoMdct->mdct_stereo_mode_cmdl; + hCPE->hStereoMdct->mdct_stereo_mode_cmdl = SMDCT_MS_DECISION; +#endif 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 ); +#ifdef DEBUGGING + hCPE->hStereoMdct->mdct_stereo_mode_cmdl = orig_mdct_stereo_mode_cmdl; +#endif + 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 ); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index e3ff04f86..d97697434 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -1154,6 +1154,21 @@ void initMdctStereoEncData( set_s( hStereoMdct->IGFStereoMode, -1, 2 ); +#ifdef DEBUG_FORCE_MDCT_STEREO_MODE + /*set all other members to defined states */ + hStereoMdct->fDualMono = 0; + hStereoMdct->fMSstereo = 0; + + if ( hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_LR ) + { + hStereoMdct->fDualMono = 1; + } + else if ( hStereoMdct->mdct_stereo_mode_cmdl == SMDCT_FORCE_MS ) + { + hStereoMdct->fMSstereo = 1; + } +#endif + hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; set_s( hStereoMdct->global_ild, SMDCT_ILD_RANGE >> 1, 2 ); diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 175dedd08..60a79ea77 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -336,10 +336,7 @@ void stereo_tcx_core_enc( } } - -#ifdef FIX_1384_MSAN_stereo_tcx_core_enc st->acelp_cfg.midLpc = 0; -#endif last_core_orig = st->last_core; for ( n = 0; n < n_subframes; n++ ) { diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 157b8ce7a..7088abc51 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1240,6 +1240,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( { st_ivas->ind_list[i].nb_bits = -1; } + #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) { @@ -1330,9 +1331,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } else { -#ifdef DEBUG_MODE_INFO - dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); -#endif if ( ( error = evs_enc( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in[0], inputBufferSize ) ) != IVAS_ERR_OK ) { return error; @@ -1468,10 +1466,6 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ -#ifdef DEBUG_FORCE_DIR - , - const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ -#endif ) { int16_t newForced; @@ -1483,27 +1477,6 @@ ivas_error IVAS_ENC_SetForcedMode( return error; } -#ifdef DEBUG_FORCE_DIR - hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; - if ( forcedMode < IVAS_ENC_FORCE_FILE ) - { - if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( hIvasEnc->st_ivas->hEncoderConfig->force != newForced ) - { - hIvasEnc->st_ivas->hEncoderConfig->force = newForced; - hIvasEnc->switchingActive = true; - } - } - else if ( forcedMode == IVAS_ENC_FORCE_DIR ) - { - strcpy( hIvasEnc->st_ivas->hEncoderConfig->force_dir, forcedModeDir ); - hIvasEnc->st_ivas->hEncoderConfig->force = IVAS_ENC_FORCE_UNFORCED; - } -#else if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) { return error; @@ -1514,7 +1487,6 @@ ivas_error IVAS_ENC_SetForcedMode( hIvasEnc->st_ivas->hEncoderConfig->force = newForced; hIvasEnc->switchingActive = true; } -#endif return IVAS_ERR_OK; } @@ -2360,11 +2332,8 @@ static ivas_error forcedModeApiToInternal( case IVAS_ENC_FORCE_GSC: *forcedModeInternal = FORCE_GSC; break; - case IVAS_ENC_FORCE_TCX10: - *forcedModeInternal = FORCE_TCX10; - break; - case IVAS_ENC_FORCE_TCX20: - *forcedModeInternal = FORCE_TCX20; + case IVAS_ENC_FORCE_TCX: + *forcedModeInternal = FORCE_TCX; break; case IVAS_ENC_FORCE_HQ: *forcedModeInternal = FORCE_HQ; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 567db4a97..af9f68e07 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -127,13 +127,8 @@ typedef enum _IVAS_ENC_FORCED_MODE IVAS_ENC_FORCE_MUSIC, IVAS_ENC_FORCE_ACELP, IVAS_ENC_FORCE_GSC, - IVAS_ENC_FORCE_TCX10, - IVAS_ENC_FORCE_TCX20, + IVAS_ENC_FORCE_TCX, IVAS_ENC_FORCE_HQ, -#ifdef DEBUG_FORCE_DIR - IVAS_ENC_FORCE_FILE, - IVAS_ENC_FORCE_DIR, -#endif IVAS_ENC_FORCE_UNFORCED, IVAS_ENC_FORCE_UNDEFINED = 0xffff } IVAS_ENC_FORCED_MODE; @@ -334,9 +329,6 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ -#ifdef DEBUG_FORCE_DIR - ,const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ -#endif ); #endif diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 09f126c59..919c2b590 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -53,14 +53,16 @@ *--------------------------------------------------------------------*/ void pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t input_frame, /* i : frame length */ - float old_inp_12k8[], /* i/o: buffer of old input signal */ - float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */ - float **inp, /* o : ptr. to inp. signal in the current frame*/ - float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */ - float *ener, /* o : residual energy from Levinson-Durbin */ - int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */ + Encoder_State *st, /* i/o: encoder state structure */ + const int16_t input_frame, /* i : frame length */ + float old_inp_12k8[], /* i/o: buffer of old input signal */ + float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */ + float **inp, /* o : ptr. to inp. signal in the current frame*/ + float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */ + float *ener, /* o : residual energy from Levinson-Durbin */ +#ifndef FIX_I4_OL_PITCH + int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */ +#endif float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ float epsP[M + 1], /* i/o: LP prediction errors */ @@ -849,7 +851,9 @@ void pre_proc( * ACELP/TCX20 Switching Decision *-----------------------------------------------------------------*/ +#ifndef FIX_I4_OL_PITCH mvs2s( st->pitch, pitch_orig, 3 ); +#endif if ( st->codec_mode == MODE2 ) { diff --git a/lib_enc/pvq_core_enc.c b/lib_enc/pvq_core_enc.c index 17d4dab1e..fa2bf2b1a 100644 --- a/lib_enc/pvq_core_enc.c +++ b/lib_enc/pvq_core_enc.c @@ -419,12 +419,18 @@ static void densityIndexSymbolEncode( int32_t cum_freq, tot; int16_t densityPlOne, densitySubC; int16_t densitySubIndex, nearFlag; +#ifdef BASOP_NOGLOB Flag Overflow; +#endif /* BASOP_NOGLOB */ if ( ( 0xFFFE & density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[opp_sz], SQRT_DIM_fx[near_sz] ); +#ifndef BASOP_NOGLOB + angle = shl( angle, 1 ); +#else /* BASOP_NOGLOB */ angle = shl_o( angle, 1, &Overflow ); +#endif /* BASOP_NOGLOB */ angle = mult_r( angle, 20861 ); c = mult_r( density, angle ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 05e56ef4a..4d6fe1134 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -359,7 +359,11 @@ typedef struct fd_cng_enc_structure int16_t nFFTpartDec; int16_t partDec[NPART]; +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + float mem_coherence[MDCT_ST_DTX_NUM_COHERENCE_BANDS][4]; +#else float mem_coherence[4]; +#endif } FD_CNG_ENC, *HANDLE_FD_CNG_ENC; @@ -1173,9 +1177,6 @@ typedef struct enc_core_structure int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ -#ifdef DEBUG_FORCE_DIR - char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ -#endif #endif int16_t ini_frame; /* initialization frames counter */ diff --git a/lib_enc/swb_bwe_enc.c b/lib_enc/swb_bwe_enc.c index b35fcd97d..8157f8337 100644 --- a/lib_enc/swb_bwe_enc.c +++ b/lib_enc/swb_bwe_enc.c @@ -1795,9 +1795,11 @@ void hq_generic_hf_encoding( { Word16 tmp, frac, exp; Word32 L_tmp; +#ifdef BASOP_NOGLOB Flag Overflow; Overflow = 0; +#endif tmp = add( (int16_t) ( hq_generic_fenv[n_band] * 256 ), (int16_t) ( Mean_env[n_band] * 256 ) ); /*Q8 */ L_tmp = L_mult( tmp, 21771 ); /* 0.166096 in Q17 -> Q26 */ @@ -1808,7 +1810,11 @@ void hq_generic_hf_encoding( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 13 ); +#ifdef BASOP_NOGLOB tmp = shl_o( tmp, add( exp, 1 ), &Overflow ); /*Q1 */ +#else + tmp = shl( tmp, add( exp, 1 ) ); /*Q1 */ +#endif hq_generic_fenv[n_band] = (float) tmp * 0.5f; /*Q1 */ } diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 7c169d901..8195edc37 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -324,18 +324,6 @@ void SetTCXModeInfo( hTcxEnc->tcxMode = NO_TCX; } } - -#ifdef DEBUGGING - if ( st->force == FORCE_TCX10 ) - { - hTcxEnc->tcxMode = TCX_10; - } - else if ( st->force == FORCE_TCX20 ) - { - hTcxEnc->tcxMode = TCX_20; - } -#endif - /* set the left window overlap */ if ( st->last_core == ACELP_CORE || st->last_core == AMR_WB_CORE ) { -- GitLab