diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 695cf01ff5de6643b812887ec15fc83d2cef9ec9..93ebd862a9b5a1c6dc63d1ce220ede26c7455503 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -51,16 +51,11 @@ /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ -#ifndef FIX_I59_LFE_TD_DELAY - RENDERER_TYPE renderer_type, /* i : IVAS rendering type */ - const int32_t binaural_latency_ns /* i : binaural renderer HRTF delay in ns */ -#else + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ const int32_t binaural_latency_ns /* i : binauralization delay in ns */ -#endif ) { int32_t delay = 0; @@ -99,7 +94,6 @@ int32_t get_delay( { delay = IVAS_DEC_DELAY_NS; -#ifdef FIX_I59_LFE_TD_DELAY if ( hCldfb != NULL ) { /* compensate for filterbank delay */ @@ -108,16 +102,8 @@ int32_t get_delay( /* compensate for binauralization delay */ delay += binaural_latency_ns; -#else - if ( hCldfb != NULL || renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) - { - delay += IVAS_FB_DEC_DELAY_NS; - } - - /* compensate for Binaural renderer HRTF delay */ - delay += binaural_latency_ns; -#endif } } + return delay; } diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c index 45bad10eb011673251ad6b1c78a64347abec90dc..ed3a54a19929247723804672f0903d98b7dabfea 100644 --- a/lib_com/hq2_bit_alloc.c +++ b/lib_com/hq2_bit_alloc.c @@ -375,11 +375,9 @@ void hq2_bit_alloc_har( Word32 L_y[BANDS_MAX]; -#ifdef FIX_150 #ifdef BASOP_NOGLOB Flag Overflow; Overflow = 0; -#endif #endif grp_rngmax_fx[0] = 0; @@ -646,13 +644,9 @@ void hq2_bit_alloc_har( L_temp = Mpy_32_16( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */ L_temp = Mpy_32_16( L_temp, Inv_norm_sum_fx ); /* Qbe+1+QIpb+1 */ -#ifdef FIX_150 #ifdef BASOP_NOGLOB lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow ); Overflow = 0; /* reset BASOP Overflow */ -#else - lf_hf_ge_r_fx = round_fx( L_shl( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) ); -#endif #else lf_hf_ge_r_fx = round_fx( L_shl( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) ); #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 598014a742616edd21e326a4fdcc386bd3df49b1..f94e1e4ceb295ed1cd13b1028ba389faac50224a 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -168,9 +168,6 @@ ivas_error pre_proc_front_ivas( const int16_t n, /* i : channel number */ float old_inp_12k8[], /* o : buffer of old input signal */ float old_inp_16k[], /* o : buffer of old input signal @16kHz */ -#ifndef REMOVE_ETOT_PROPAGATION - float *Etot, /* o : total energy */ -#endif float *ener, /* o : residual energy from Levinson-Durbin */ float *relE, /* o : frame relative energy */ float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ @@ -202,14 +199,9 @@ ivas_error pre_proc_front_ivas( const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ -#ifdef LOW_RATE_TRANS const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t ivas_format /* i : IVAS format */ -#else - const int16_t front_vad_dtx_flag /* i : front-VAD DTX flag to overwrite VAD decision*/ - ,const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#endif ); ivas_error pre_proc_ivas( @@ -416,9 +408,6 @@ ivas_error ivas_core_enc( const int16_t n_CoreChannels, /* i : number of core channels to be coded */ float old_inp_12k8[CPE_CHANNELS][L_INP_12k8], /* i : buffer of old input signal */ float old_inp_16k[CPE_CHANNELS][L_INP], /* i : buffer of old input signal */ -#ifndef REMOVE_ETOT_PROPAGATION - const float Etot[CPE_CHANNELS], /* i : total energy */ -#endif float ener[CPE_CHANNELS], /* i : residual energy from Levinson-Durbin */ float A[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */ float Aw[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */ @@ -626,13 +615,12 @@ void set_transient_stereo( float currFlatness[] /* i/o: current flatness */ ); -#ifdef LOW_RATE_TRANS +/*! r: preliminary flag to force ACELP */ int16_t transient_analysis( TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ const float cor_map_LT[], /* i : LT correlation map */ const float multi_harm_limit /* i : multi harminic threshold */ ); -#endif void ivas_post_proc( SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ @@ -1758,9 +1746,7 @@ void tdm_ol_pitch_comparison( void tdm_configure_enc( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ -#ifdef REMOVE_ETOT_PROPAGATION const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ -#endif const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ const int16_t tdm_ratio_idx, /* i : ratio index */ const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ @@ -3181,11 +3167,6 @@ int16_t ivas_sba_get_analysis_order( const int16_t sba_order /* i : Ambisonic (SBA) order */ ); -#ifndef SBA_DIRAC_RENDERER_TYPE_CLEANUP -int16_t ivas_sba_get_order_transport( - const int16_t nchan_transport /* i : Number of transport channels */ -); -#endif /*! r: number of Ambisonic channels */ int16_t ivas_sba_get_nchan( const int16_t sba_order, /* i : Ambisonic (SBA) order */ @@ -5034,11 +5015,7 @@ void ivas_lfe_enc( ivas_error ivas_create_lfe_dec( LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ const int32_t output_Fs, /* i : output sampling rate */ -#ifdef FIX_I59_LFE_TD_DELAY const int32_t binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */ -#else - const float add_delay_s /* i : additional LFE delay to sync with binaural filter */ -#endif ); void ivas_lfe_dec_close( diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 64a8d94bd8709a8fdc1cfd5027c88b71b2b07767..f9a8c2b6eff8eb9ab3dc3c909c1a3f434cae591f 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -246,33 +246,6 @@ int16_t ivas_sba_get_analysis_order( return sba_analysis_order; } -#ifndef SBA_DIRAC_RENDERER_TYPE_CLEANUP -/*-------------------------------------------------------------------* - * ivas_sba_get_order_transport() - * - * Get effective Ambisonic order from number of transport channels - *-------------------------------------------------------------------*/ - -int16_t ivas_sba_get_order_transport( - const int16_t nchan_transport /* i : Number of transport channels */ -) -{ - int16_t sba_order; - - sba_order = SBA_FOA_ORDER; - - if ( nchan_transport > 6 ) - { - sba_order = SBA_HOA3_ORDER; - } - else if ( nchan_transport > 4 ) - { - sba_order = SBA_HOA2_ORDER; - } - - return ( sba_order ); -} -#endif /*-------------------------------------------------------------------* * ivas_sba_get_nchan() diff --git a/lib_com/options.h b/lib_com/options.h index 5bf0435c0c5a16156c2e74409bc84309b8597b21..503146f4a67bd0929699ce90a2752323d0d5fbeb 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,18 +144,9 @@ #define SBA_BR_SWITCHING_2 /* Issue 114: Changes for sba bit rate switching with reconfigurations*/ #define SBA_BR_SWITCHING /* Issue 114: Changes for sba bit rate switching*/ #define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ -#define FIX_150 /* Issue 150: Crash in EVS mono, HQ_HARMONIC mode, related to BASOP_NOGLOB */ -#define FIX_VBR_COMPLEXITY /* Issue 234: fix extremely high complexity numbers for IVAS EVS mode */ -#define SBA_DIRAC_RENDERER_TYPE_CLEANUP /* Remove leftovers in renderer_type logic in SBA DirAC decoder */ -#define FIX_I59_LFE_TD_DELAY /* Issue 59: correcting delay of LFE for TD renderer */ -#define FIX_I59_LFE_CLDFB /* Issue 59: correcting LFE handling for fastconv binaural rendering */ #define FIX_I59_DELAY_ROUNDING /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */ #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define FIX_I59_CREND /* Issue 59: Fixes for gcc compiler warnings in ivas_crend_utest_utils.c */ -#define LOW_RATE_TRANS /* Eri: Contribution 20: low rate encoding of transients */ #define MC_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format */ -#define SIMPLIFY_TD_BWE_RESET /* Issue 250: Resolve "TB-BWE state memories reset simplification" */ -#define REMOVE_ETOT_PROPAGATION /* Issue 251: Do not propagate Etot parameter */ #define MC_JBM /* FhG: extend JBM beyond mono for running IVAS in VoIP mode (contribution 19) */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 24a74a72c44a80ad2301ad6012230a62aa42d8d8..1e77780ed4f4d81e81f5eacfdcc8d8c6b8a4ab5d 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -692,16 +692,11 @@ int16_t lev_dur( /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ -#ifndef FIX_I59_LFE_TD_DELAY - RENDERER_TYPE renderer_type, /* i : IVAS rendering type */ - const int32_t binaural_latency_ns /* i : binaural renderer HRTF delay in ns */ -#else - const int32_t binaural_latency_ns /* i : binauralization delay in ns */ -#endif + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int32_t binaural_latency_ns /* i : binauralization delay in ns */ ); void decision_matrix_enc( @@ -2283,10 +2278,7 @@ void pre_proc( 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 */ -#ifndef REMOVE_ETOT_PROPAGATION - float *Etot, /* i : total energy */ -#endif - float *ener, /* o : residual energy from Levinson-Durbin */ + 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 @@ -2604,12 +2596,10 @@ void InitSWBencBuffer( TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); -#ifdef SIMPLIFY_TD_BWE_RESET void InitSWBencBufferStates( TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */ ); -#endif void swb_tbe_enc( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_com/wi.c b/lib_com/wi.c index 6cfc018aadb53e47ae7713ff5f493ddff5970e63..2f23024b3a595af4bc79f49fcb41c9e0f20cccbe 100644 --- a/lib_com/wi.c +++ b/lib_com/wi.c @@ -80,7 +80,6 @@ ivas_error DTFS_new( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTFS (SC-VBR) structure\n" ) ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MOVE( 2 ); LOOP( 1 ); @@ -100,22 +99,6 @@ ivas_error DTFS_new( *dtfs_out = dtfs; #undef WMC_TOOL_SKIP -#else - dtfs->lag = 0; - dtfs->nH = 0; - dtfs->nH_4kHz = 0; - dtfs->upper_cut_off_freq_of_interest = 3300.0; - dtfs->upper_cut_off_freq = 4000.0; - - for ( i = 0; i < MAXLAG_WI; i++ ) - { - dtfs->a[i] = dtfs->b[i] = 0.0; - } - - dtfs->sampling_rate = -1; - - *dtfs_out = dtfs; -#endif return IVAS_ERR_OK; } @@ -133,7 +116,7 @@ void DTFS_copy( ) { int16_t k; -#ifdef FIX_VBR_COMPLEXITY + #define WMC_TOOL_SKIP LOOP( 1 ); for ( k = 0; k < MAXLAG_WI; k++ ) @@ -154,21 +137,6 @@ void DTFS_copy( Xout->upper_cut_off_freq_of_interest = Xinp.upper_cut_off_freq_of_interest; Xout->upper_cut_off_freq = Xinp.upper_cut_off_freq; #undef WMC_TOOL_SKIP -#else - for ( k = 0; k < MAXLAG_WI; k++ ) - { - Xout->a[k] = Xinp.a[k]; - } - for ( k = 0; k < MAXLAG_WI; k++ ) - { - Xout->b[k] = Xinp.b[k]; - } - Xout->lag = Xinp.lag; - Xout->nH = Xinp.nH; - Xout->nH_4kHz = Xinp.nH_4kHz; - Xout->upper_cut_off_freq_of_interest = Xinp.upper_cut_off_freq_of_interest; - Xout->upper_cut_off_freq = Xinp.upper_cut_off_freq; -#endif return; } @@ -189,7 +157,6 @@ void DTFS_sub( { int16_t i; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MULT( 1 ); LOOP( 1 ); @@ -217,23 +184,6 @@ void DTFS_sub( tmp->upper_cut_off_freq_of_interest = X1.upper_cut_off_freq_of_interest; tmp->upper_cut_off_freq = X1.upper_cut_off_freq; #undef WMC_TOOL_SKIP -#else - for ( i = 0; i <= X1.lag / 2; i++ ) - { - tmp->a[i] = X1.a[i]; - tmp->b[i] = X1.b[i]; - } - for ( i = 0; i <= X2.lag / 2; i++ ) - { - tmp->a[i] -= X2.a[i]; - tmp->b[i] -= X2.b[i]; - } - tmp->lag = max( X1.lag, X2.lag ); - tmp->nH = max( X1.nH, X2.nH ); - tmp->nH_4kHz = max( X1.nH_4kHz, X2.nH_4kHz ); - tmp->upper_cut_off_freq_of_interest = X1.upper_cut_off_freq_of_interest; - tmp->upper_cut_off_freq = X1.upper_cut_off_freq; -#endif return; } @@ -258,7 +208,6 @@ static void DTFS_fast_fs_inv( N = X1_DTFS->lag; } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP /* Populate the dbuf array */ dbuf[1] = X1_DTFS->a[0]; @@ -296,36 +245,6 @@ static void DTFS_fast_fs_inv( out[i - 1] = dbuf[i] / N_2; } #undef WMC_TOOL_SKIP -#else - /* Populate the dbuf array */ - dbuf[1] = X1_DTFS->a[0]; - dbuf[2] = 0.0; - for ( i = 1; i < M_2; i++ ) - { - dbuf[2 * i + 1] = X1_DTFS->a[i] * N_2; - dbuf[2 * i + 2] = X1_DTFS->b[i] * N_2; - } - - if ( N_2 != M_2 ) - { - dbuf[2 * i + 1] = X1_DTFS->a[i] * N_2; - dbuf[2 * i + 2] = X1_DTFS->b[i] * N_2; - i++; - } - - /* Zero-padding in the frequency domain */ - for ( ; i < N_2; i++ ) - { - dbuf[2 * i + 1] = dbuf[2 * i + 2] = 0.0; - } - - realft( dbuf, N_2, -1 ); - - for ( i = 1; i <= N; i++ ) - { - out[i - 1] = dbuf[i] / N_2; - } -#endif return; } @@ -353,7 +272,6 @@ static float DTFS_alignment_weight( float pwf = 0.7f, tmplpc[M + 1]; DTFS_STRUCTURE X1_DTFS; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 2 ); DTFS_copy( &X1_DTFS, refX1_DTFS ); @@ -442,55 +360,6 @@ static float DTFS_alignment_weight( } } #undef WMC_TOOL_SKIP -#else - DTFS_copy( &X1_DTFS, refX1_DTFS ); - DTFS_adjustLag( &X1_DTFS, X2_DTFS.lag ); - DTFS_poleFilter( &X1_DTFS, LPC1, M + 1 ); - tmp = 1.0; - for ( k = 0, tmp = 1.0; k < M + 1; k++ ) - { - tmplpc[k] = LPC1[k] * ( tmp *= pwf ); - } - - - DTFS_zeroFilter( &X1_DTFS, tmplpc, M + 1 ); - DTFS_poleFilter( &X2_DTFS, LPC2, M + 1 ); - for ( k = 0, tmp = 1.0; k < M + 1; k++ ) - { - /* can be stored as a table */ - tmplpc[k] = LPC2[k] * ( tmp *= pwf ); - } - DTFS_zeroFilter( &X2_DTFS, tmplpc, M + 1 ); - maxcorr = (float) -HUGE_VAL; - fshift = Eshift; - Adiff = max( 6, 0.15f * X2_DTFS.lag ); - if ( X2_DTFS.lag < 60 ) - { - diff = 0.25; - } - else - { - diff = 0.5; - } - for ( n = Eshift - Adiff; n <= Eshift + Adiff; n += diff ) - { - corr = tmp = 0.0f; - /* bit-exact optimization - PI2/X2_DTFS.lag should be counted as a single divide */ - tmp1 = (float) ( PI2 * n / X2_DTFS.lag ); - for ( k = 0; k <= min( X2_DTFS.lag >> 1, X2_DTFS.nH_4kHz ); k++, tmp += tmp1 ) - { - /* Not counting math function cos and sin since they will be implemented as look-up tables */ - corr += (float) ( ( X1_DTFS.a[k] * X2_DTFS.a[k] + X1_DTFS.b[k] * X2_DTFS.b[k] ) * cos( tmp ) ); - corr += (float) ( ( X1_DTFS.b[k] * X2_DTFS.a[k] - X1_DTFS.a[k] * X2_DTFS.b[k] ) * sin( tmp ) ); - } - wcorr = (float) ( corr * ( 1.0f - 0.01f * fabs( n - Eshift ) ) ); - if ( wcorr > maxcorr ) - { - fshift = n; - maxcorr = wcorr; - } - } -#endif return fshift; } @@ -511,7 +380,6 @@ float DTFS_alignment_full( int16_t k; float maxcorr, corr, tmp, tmp1, fshift, n, diff; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOGIC( 1 ); if ( X1_DTFS.lag < X2_DTFS.lag ) @@ -559,34 +427,6 @@ float DTFS_alignment_full( } } #undef WMC_TOOL_SKIP -#else - if ( X1_DTFS.lag < X2_DTFS.lag ) - { - DTFS_zeroPadd( X2_DTFS.lag, &X1_DTFS ); - } - - maxcorr = (float) -HUGE_VAL; - /* bit-exact optimization - 1/num_steps can be constant => should be counted as a multiply */ - diff = (float) X2_DTFS.lag / num_steps; - - for ( fshift = n = 0.0; n < (float) X2_DTFS.lag; n += diff ) - { - corr = tmp = 0.0f; - tmp1 = (float) ( PI2 * n / X2_DTFS.lag ); - - for ( k = 0; k <= min( X2_DTFS.lag >> 1, X2_DTFS.nH_4kHz ); k++, tmp += tmp1 ) - - { - corr += (float) ( ( X1_DTFS.a[k] * X2_DTFS.a[k] + X1_DTFS.b[k] * X2_DTFS.b[k] ) * cos( tmp ) ); - corr += (float) ( ( X1_DTFS.b[k] * X2_DTFS.a[k] - X1_DTFS.a[k] * X2_DTFS.b[k] ) * sin( tmp ) ); - } - if ( corr > maxcorr ) - { - fshift = n; - maxcorr = corr; - } - } -#endif return fshift; } @@ -609,7 +449,6 @@ void DTFS_phaseShift( int16_t k; float tmp, tmp2 = 0.0f; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP ADD( 1 ); LOOP( 1 ); @@ -626,14 +465,6 @@ void DTFS_phaseShift( X->b[k] = (float) ( tmp * sin( tmp2 ) + X->b[k] * cos( tmp2 ) ); } #undef WMC_TOOL_SKIP -#else - for ( k = 0; k <= min( X->lag >> 1, X->nH ); k++, tmp2 += ph ) - { - tmp = X->a[k]; - X->a[k] = (float) ( tmp * cos( tmp2 ) - X->b[k] * sin( tmp2 ) ); - X->b[k] = (float) ( tmp * sin( tmp2 ) + X->b[k] * cos( tmp2 ) ); - } -#endif return; } @@ -653,7 +484,6 @@ void DTFS_zeroPadd( int16_t i; float diff; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOGIC( 1 ); if ( N == X->lag ) @@ -684,24 +514,6 @@ void DTFS_zeroPadd( X->nH++; } #undef WMC_TOOL_SKIP -#else - if ( N == X->lag ) - { - return; - } - for ( i = ( X->lag >> 1 ) + 1; i <= N >> 1; i++ ) - { - X->a[i] = X->b[i] = 0.0; - } - X->lag = N; - /* recompute nH for new lag */ - X->nH = (int16_t) floor( X->upper_cut_off_freq / ( 12800.0 / X->lag ) ); - diff = 12800.0f / X->lag; - if ( X->upper_cut_off_freq - ( diff * X->nH ) >= diff ) - { - X->nH++; - } -#endif return; } @@ -747,7 +559,6 @@ void DTFS_to_fs( X->sampling_rate = INT_FS_16k; } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP X->lag = N; MOVE( 1 ); @@ -844,69 +655,6 @@ void DTFS_to_fs( X->nH = nH_band; X->nH_4kHz = nH_4kHz; #undef WMC_TOOL_SKIP -#else - X->lag = N; - nH_band = (int16_t) floor( X->upper_cut_off_freq / ( 12800.0 / X->lag ) ); - - nH_4kHz = (int16_t) floor( 4000 / ( 12800.0 / X->lag ) ); - diff = 12800.0f / X->lag; - if ( X->upper_cut_off_freq - ( diff * nH_band ) >= diff ) - { - nH_band++; - } - if ( 4000 - ( diff * nH_4kHz ) >= diff ) - { - nH_4kHz++; - } - /* Number of harmonics excluding the ones at 0 and at pi */ - nH = ( N - 1 ) >> 1; - /* The DC component */ - X->a[0] = 0.0; - X->b[0] = 0.0; - for ( n = 0; n < N; n++ ) - { - X->a[0] += x[n]; - } - X->a[0] /= N; - - /* Strictly set the DC componet to zero */ - X->a[0] = 0.0; - - /* The harmonics excluding the one at pi */ - for ( k = 1; k <= nH; k++ ) - { - X->a[k] = x[0]; - X->b[k] = 0.0; - sum = tmp = (float) ( PI2 * k / N ); - for ( n = 1; n < N; n++, sum += tmp ) - { - X->a[k] += (float) ( x[n] * cos( sum ) ); - X->b[k] += (float) ( x[n] * sin( sum ) ); - } - X->a[k] *= ( 2.0f / N ); - X->b[k] *= ( 2.0f / N ); - } - - /* The harmonic at 'pi' */ - if ( N % 2 == 0 ) - { - X->a[k] = 0.0; - tmp = 1.0; - for ( n = 0; n < N; n++, tmp *= -1.0 ) - { - X->a[k] += x[n] * tmp; - } - X->a[k] /= N; - X->b[k] = 0.0; - } - for ( k = nH_band + 1; k <= min( ( X->lag >> 1 ), ( MAXLAG_WI - 1 ) ); k++ ) - { - X->a[k] = 0.0; - X->b[k] = 0.0; - } - X->nH = nH_band; - X->nH_4kHz = nH_4kHz; -#endif return; } @@ -928,7 +676,6 @@ void DTFS_fs_inv( float phase, tmp; int16_t k, n; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( n = 0; n < N; n++ ) @@ -948,17 +695,6 @@ void DTFS_fs_inv( } } #undef WMC_TOOL_SKIP -#else - for ( n = 0; n < N; n++ ) - { - x[n] = X->a[0]; - tmp = phase = (float) ( PI2 * n / X->lag + ph0 ); - for ( k = 1; k <= min( X->lag >> 1, X->nH ); k++, tmp += phase ) - { - x[n] += (float) ( X->a[k] * cos( tmp ) + X->b[k] * sin( tmp ) ); - } - } -#endif return; } @@ -1009,7 +745,6 @@ static void DTFS_transform( IVAS_ERROR( error, "Error creating DTFS structure 3" ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 2 ); DTFS_copy( tmp1_dtfs, X ); @@ -1122,98 +857,6 @@ static void DTFS_transform( out[i] = sum1; } #undef WMC_TOOL_SKIP -#else - DTFS_copy( tmp1_dtfs, X ); - DTFS_copy( tmp2_dtfs, X2 ); - DTFS_fast_fs_inv( tmp1_dtfs, x1_256, 256 ); - DTFS_fast_fs_inv( tmp2_dtfs, x2_256, 256 ); - - tmp = (float) ( log( 1.0 - WI_THRESHLD ) / ( X.lag - N ) ); - for ( i = 0; i < N; i++ ) - { - if ( FR_flag == 0 ) - { - /* should not be counted inside the loop */ - if ( N - WI_SAMPLE_THLD > X.lag ) - { - /* pre-computed and stored in a table */ - w = (float) ( 1.0 - exp( -( i + 1 ) * tmp ) ); - } - else - { - /* can be a look-up table */ - w = (float) ( i + 1 ) / N; - } - } - else - { - if ( nrg_flag ) - { - w = (float) ( i + 1 ) / N; - } - else - { - if ( N <= tmp2_dtfs->lag ) - { - N = tmp2_dtfs->lag + 1; - } - - N1 = N - tmp2_dtfs->lag; - if ( i < N1 ) - { - w = (float) ( i + 1 ) / N1; - } - else - { - w = 1.0; - } - } - } - - /* add sinc interpolation of two time domain waveforms at - appropriate phase position */ - j = ( LL_OS * 10 + (int16_t) rint_new( phase[i] * LL_OS / PI2 ) ) % LL_OS; - - if ( j < 0 ) - { - j = 0; - } - - k = j % WARP_OS_RATE; - l1 = j / WARP_OS_RATE; - - set_f( x_r_fx, 0.0f, L_FRAME ); - - temp_w = ( 1 - w ); - - for ( j1 = 0; j1 < 12; j1++ ) - { - m = ( 1000 * LL + l1 - OSLENGTH / 2 + j1 ) % LL; - - if ( m < 0 ) - { - m = 0; - } - - x_r_fx[m] = x1_256[m] * temp_w + x2_256[m] * w; - } - - for ( j1 = 0, sum1 = sum2 = 0.0; j1 < OSLENGTH; j1++ ) - { - /* mult or div by constants should be done once outside the loop */ - m = ( 1000 * LL + l1 - OSLENGTH / 2 + j1 ) % LL; - - if ( m < 0 ) - { - m = 0; - } - - sum1 += x_r_fx[m] * sinc[k][j1]; - } - - out[i] = sum1; - } -#endif free( tmp1_dtfs ); free( tmp2_dtfs ); @@ -1238,7 +881,6 @@ void DTFS_zeroFilter( float tmp, tmp1, tmp2, sum1, sum2; int16_t k, n; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MOVE( 1 ); MULT( 1 ); @@ -1276,25 +918,6 @@ void DTFS_zeroFilter( X->b[k] = X->b[k] * sum1 + tmp * sum2; } #undef WMC_TOOL_SKIP -#else - tmp1 = (float) ( PI2 / X->lag ); - for ( k = 0; k <= min( X->lag >> 1, X->nH ); k++ ) - { - tmp = tmp2 = k * tmp1; - /* Calculate sum1 and sum2 */ - sum1 = 1.0; - sum2 = 0.0; - for ( n = 0; n < N; n++, tmp2 += tmp ) - { - sum1 += (float) ( LPC[n] * cos( tmp2 ) ); - sum2 += (float) ( LPC[n] * sin( tmp2 ) ); - } - /* Calculate the circular convolution */ - tmp = X->a[k]; - X->a[k] = tmp * sum1 - X->b[k] * sum2; - X->b[k] = X->b[k] * sum1 + tmp * sum2; - } -#endif return; } @@ -1315,7 +938,6 @@ void DTFS_poleFilter( float tmp, tmp1, tmp2, sum1, sum2; int16_t k, n; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MOVE( 1 ); MULT( 1 ); @@ -1355,26 +977,6 @@ void DTFS_poleFilter( X->b[k] = ( -tmp * sum2 + X->b[k] * sum1 ) / tmp2; } #undef WMC_TOOL_SKIP -#else - tmp1 = (float) ( PI2 / X->lag ); - for ( k = 0; k <= min( X->lag >> 1, X->nH ); k++ ) - { - tmp = tmp2 = k * tmp1; - /* Calculate sum1 and sum2 */ - sum1 = 1.0; - sum2 = 0.0; - for ( n = 0; n < N; n++, tmp2 += tmp ) - { - sum1 += (float) ( LPC[n] * cos( tmp2 ) ); - sum2 += (float) ( LPC[n] * sin( tmp2 ) ); - } - /* Calculate the circular convolution */ - tmp = X->a[k]; - tmp2 = sum1 * sum1 + sum2 * sum2; - X->a[k] = ( tmp * sum1 + X->b[k] * sum2 ) / tmp2; - X->b[k] = ( -tmp * sum2 + X->b[k] * sum1 ) / tmp2; - } -#endif return; } @@ -1394,7 +996,6 @@ static float DTFS_setEngy( int16_t k; float en1, tmp; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 1 ); MOVE( 1 ); @@ -1419,19 +1020,6 @@ static float DTFS_setEngy( X_DTFS->b[k] *= tmp; } #undef WMC_TOOL_SKIP -#else - en1 = DTFS_getEngy( *X_DTFS ); - if ( en1 == 0.0 ) - { - return 0.0; - } - tmp = (float) sqrt( en2 / en1 ); - for ( k = 0; k <= min( X_DTFS->lag >> 1, X_DTFS->nH ); k++ ) - { - X_DTFS->a[k] *= tmp; - X_DTFS->b[k] *= tmp; - } -#endif return en1; } @@ -1451,7 +1039,6 @@ void DTFS_adjustLag( int16_t k; float en, diff; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOGIC( 1 ); if ( N == X_DTFS->lag ) @@ -1506,41 +1093,6 @@ void DTFS_adjustLag( } } #undef WMC_TOOL_SKIP -#else - if ( N == X_DTFS->lag ) - { - return; - } - - if ( N > X_DTFS->lag ) - { - DTFS_zeroPadd( N, X_DTFS ); - } - else - { - en = DTFS_getEngy( *X_DTFS ); - for ( k = ( N >> 1 ) + 1; k <= min( X_DTFS->lag >> 1, X_DTFS->nH ); k++ ) - { - X_DTFS->a[k] = 0.0; - X_DTFS->b[k] = 0.0; - } - DTFS_setEngy( X_DTFS, en ); - X_DTFS->lag = N; - /* recompute nH for new lag */ - X_DTFS->nH = (int16_t) floor( X_DTFS->upper_cut_off_freq / ( 12800.0 / X_DTFS->lag ) ); - - X_DTFS->nH_4kHz = (int16_t) floor( 4000.0 / ( 12800.0 / X_DTFS->lag ) ); - diff = 12800.0f / X_DTFS->lag; - if ( X_DTFS->upper_cut_off_freq - ( diff * X_DTFS->nH ) >= diff ) - { - X_DTFS->nH++; - } - if ( 4000.0 - ( diff * X_DTFS->nH_4kHz ) >= diff ) - { - X_DTFS->nH_4kHz++; - } - } -#endif return; } @@ -1560,7 +1112,6 @@ float DTFS_getEngy( float en; en = 0.0f; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( k = 1; k <= min( ( X.lag - 1 ) >> 1, X.nH ); k++ ) @@ -1582,18 +1133,6 @@ float DTFS_getEngy( en += X.a[k] * X.a[k] + X.b[k] * X.b[k]; } #undef WMC_TOOL_SKIP -#else - for ( k = 1; k <= min( ( X.lag - 1 ) >> 1, X.nH ); k++ ) - { - en += X.a[k] * X.a[k] + X.b[k] * X.b[k]; - } - en /= 2.0; - en += X.a[0] * X.a[0]; - if ( X.lag % 2 == 0 ) - { - en += X.a[k] * X.a[k] + X.b[k] * X.b[k]; - } -#endif return en; } @@ -1612,7 +1151,6 @@ void DTFS_car2pol( int16_t k; float tmp; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( k = 1; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++ ) @@ -1638,21 +1176,6 @@ void DTFS_car2pol( X->b[k] = (float) atan2( X->b[k], tmp ); } #undef WMC_TOOL_SKIP -#else - for ( k = 1; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++ ) - { - tmp = X->a[k]; - X->a[k] = (float) ( 0.5f * sqrt( tmp * tmp + X->b[k] * X->b[k] ) ); - X->b[k] = (float) atan2( X->b[k], tmp ); - } - - if ( X->lag % 2 == 0 ) - { - tmp = X->a[k]; - X->a[k] = (float) sqrt( tmp * tmp + X->b[k] * X->b[k] ); - X->b[k] = (float) atan2( X->b[k], tmp ); - } -#endif return; } @@ -1671,7 +1194,6 @@ void DTFS_pol2car( int16_t k; float tmp; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( k = 1; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++ ) @@ -1698,21 +1220,6 @@ void DTFS_pol2car( X->a[k] = (float) ( X->a[k] * cos( tmp ) ); } #undef WMC_TOOL_SKIP -#else - for ( k = 1; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++ ) - { - tmp = X->b[k]; - X->b[k] = (float) ( 2.0f * X->a[k] * sin( tmp ) ); - X->a[k] = (float) ( 2.0f * X->a[k] * cos( tmp ) ); - } - - if ( X->lag % 2 == 0 ) - { - tmp = X->b[k]; - X->b[k] = (float) ( X->a[k] * sin( tmp ) ); - X->a[k] = (float) ( X->a[k] * cos( tmp ) ); - } -#endif return; } @@ -1742,7 +1249,6 @@ float DTFS_setEngyHarm( en1 = 0.0f; count = 0; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOGIC( 1 ); if ( f1 == 0.0 ) @@ -1822,58 +1328,6 @@ float DTFS_setEngyHarm( } } #undef WMC_TOOL_SKIP -#else - if ( f1 == 0.0 ) - { - en1 += X->a[0] * X->a[0]; - count++; - } - for ( k = 1, tmp = diff; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++, tmp += diff ) - { - if ( X->a[k] < EPSILON ) - { - X->a[k] = 0; - } - - if ( tmp > f1 && tmp <= f2 ) - { - en1 += X->a[k] * X->a[k]; - count++; - } - } - - if ( count <= 0.0 ) - { - count = 1; - } - - en1 /= count; - - if ( en2 < 0.0 ) - { - en2 = 0.0; - } - - if ( en1 > 0.0 ) - { - factor = (float) sqrt( en2 / en1 ); - } - else - { - factor = 0.0f; - } - if ( g1 == 0.0 ) - { - X->a[k] *= factor; - } - for ( k = 1, tmp = diff; k <= min( ( X->lag - 1 ) >> 1, X->nH ); k++, tmp += diff ) - { - if ( tmp > g1 && tmp <= g2 ) - { - X->a[k] *= factor; - } - } -#endif return (float) ( en1 + 1e-20 ); } @@ -1898,7 +1352,6 @@ static void cubicPhase( int16_t n; double diff; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP ADD( 1 ); N -= (int16_t) L2; @@ -1968,42 +1421,9 @@ static void cubicPhase( phOut[n] = (float) ( phOut[n - 1] + diff ); } #undef WMC_TOOL_SKIP -#else - N -= (int16_t) L2; - if ( N <= 0 ) - { - N = 1; - } - - /* Computation of the coefficients of the cubic phase function */ - f1 = (float) ( PI2 / L1 ); - f2 = (float) ( PI2 / L2 ); - ph1 = (float) fmod( (double) ( ph1 ), PI2 ); - ph2 = (float) fmod( (double) ( ph2 ), PI2 ); - coef[3] = ph1; - coef[2] = f1; - factor = (float) ( anint( ( ph1 - ph2 + 0.5 * N * ( f2 + f1 ) ) / PI2 ) ); - c1 = f2 - f1; - c2 = (float) ( ph2 - ph1 - N * f1 + PI2 * factor ); - coef[0] = ( N * c1 - 2 * c2 ) / ( N * N * N ); - coef[1] = ( c1 - 3 * N * N * coef[0] ) / ( 2 * N ); - - /* Computation of the phase value at each sample point */ - phOut[0] = ph1; - for ( n = 1; n < N; n++ ) - { - phOut[n] = _POLY3( n, coef ); - } - diff = (float) ( PI2 / L2 ); - for ( ; n < N + (int16_t) L2; n++ ) - { - phOut[n] = (float) ( phOut[n - 1] + diff ); - } -#endif - - return; -} + return; +} /*-------------------------------------------------------------------* @@ -2034,7 +1454,6 @@ void DTFS_to_erb( erb = &( erb_WB[0] ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( i = 0; i < num_erb; i++ ) @@ -2086,43 +1505,6 @@ void DTFS_to_erb( } } #undef WMC_TOOL_SKIP -#else - for ( i = 0; i < num_erb; i++ ) - { - count[i] = 0; - out[i] = 0.0; - } - diff = 12800.0f / X.lag; - for ( i = j = 0, freq = 0.0; i <= min( X.lag >> 1, X.nH ); i++, freq += diff ) - { - if ( !( freq <= erb[num_erb] ) ) - { - freq = erb[num_erb]; - } - - for ( ; j < num_erb; j++ ) - { - if ( freq < erb[j + 1] ) - { - if ( X.a[i] < 0.0f ) - { - X.a[i] = 0.0f; - } - - out[j] += X.a[i]; - count[j]++; - break; - } - } - } - for ( i = 0; i < num_erb; i++ ) - { - if ( count[i] > 1 ) - { - out[i] /= count[i]; - } - } -#endif return; } @@ -2159,7 +1541,6 @@ void erb_slot( erb = &( erb_WB[0] ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MOVE( 1 ); MULT( 1 ); @@ -2221,48 +1602,6 @@ void erb_slot( } } #undef WMC_TOOL_SKIP -#else - nH_band = (int16_t) floor( upper_cut_off_freq / ( 12800.0 / lag ) ); - - for ( i = 0; i < num_erb; i++ ) - { - out[i] = 0; - mfreq[i] = 0.0; - } - diff = 12800.0f / lag; - if ( upper_cut_off_freq - ( diff * nH_band ) >= diff ) - { - nH_band++; - } - for ( i = j = 0, freq = 0.0; i <= min( lag >> 1, nH_band ); i++, freq += diff ) - { - - if ( !( freq <= erb[num_erb] ) ) - { - freq = erb[num_erb]; - } - - freq = min( freq, upper_cut_off_freq ); - - for ( ; j < num_erb; j++ ) - { - if ( freq < erb[j + 1] ) - { - mfreq[j] += freq; - out[j]++; - break; - } - } - } - - for ( j = 0; j < num_erb; j++ ) - { - if ( out[j] > 1 ) - { - mfreq[j] /= out[j]; - } - } -#endif return; } @@ -2300,7 +1639,6 @@ void DTFS_erb_inv( erb = &( erb_WB[0] ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP MOVE( 1 ); f[m] = 0.0; @@ -2375,57 +1713,6 @@ void DTFS_erb_inv( X->a[0] = 0.0f; } #undef WMC_TOOL_SKIP -#else - f[m] = 0.0; - amp[m] = 0.0; - m++; - for ( i = 0; i < num_erb; i++ ) - { - if ( slot[i] != 0 ) - { - f[m] = mfreq[i]; - amp[m] = in[i]; - m++; - } - } - f[m] = upper_cut_off_freq; - amp[m] = 0.0; - m++; - - diff = 12800.0f / X->lag; - - for ( i = 0, j = 1, freq = 0.0; i <= min( X->lag >> 1, X->nH ); i++, freq += diff ) - { - if ( !( freq <= erb[num_erb] ) ) - { - freq = erb[num_erb]; - } - - if ( !( m <= num_erb + 2 ) ) - { - m = num_erb + 2; - } - - if ( freq > upper_cut_off_freq ) - { - freq = upper_cut_off_freq; - } - for ( ; j < m; j++ ) - { - if ( freq <= f[j] ) - { - X->a[i] = amp[j] * ( freq - f[j - 1] ) + amp[j - 1] * ( f[j] - freq ); - if ( f[j] != f[j - 1] ) - { - X->a[i] /= ( f[j] - f[j - 1] ); - } - break; - } - } - - X->a[0] = 0.0f; - } -#endif return; } @@ -2448,7 +1735,6 @@ static void LPCPowSpect( float w, tmp, Re, Im; int16_t i, k; -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP LOOP( 1 ); for ( k = 0; k < Nf; k++ ) @@ -2479,21 +1765,6 @@ static void LPCPowSpect( out[k] = 1.0f / ( Re * Re + Im * Im ); } #undef WMC_TOOL_SKIP -#else - for ( k = 0; k < Nf; k++ ) - { - Re = 1.0; - Im = 0.0; - /* Note that freq ranges between [0 UPPER_CUT_OFF_FREQ] */ - tmp = (float) ( freq[k] / 12800.0f * PI2 ); - for ( i = 0, w = tmp; i < Np; i++, w += tmp ) - { - Re += (float) ( LPC[i] * cos( w ) ); - Im -= (float) ( LPC[i] * sin( w ) ); - } - out[k] = 1.0f / ( Re * Re + Im * Im ); - } -#endif return; } @@ -2530,7 +1801,6 @@ void erb_diff( AmpCB1 = AmpCB1_WB; } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 3 ); erb_slot( l, cslot, mfreq, num_erb ); @@ -2769,165 +2039,6 @@ void erb_diff( MOVE( 1 ); index[1] = mmseindex; #undef WMC_TOOL_SKIP -#else - erb_slot( l, cslot, mfreq, num_erb ); - erb_slot( pl, pslot, t_prev_erb, num_erb ); - for ( i = 0, tmp = 1.0f; i < M + 1; i++ ) - { - LPC[i] = curr_lsp[i] * ( tmp *= 0.78f ); - } - LPCPowSpect( mfreq, num_erb, LPC, M + 1, PowSpect ); - - for ( i = 0; i < num_erb; i++ ) - { - t_prev_erb[i] = prev_erb[i]; - } - - if ( pl > l ) - { - tmp = t_prev_erb[0]; - for ( i = 0; i < num_erb; i++ ) - { - if ( pslot[i] < 0 ) - { - pslot[i] = 0; - } - - if ( pslot[i] != 0 ) - { - tmp = t_prev_erb[i]; - } - else - { - t_prev_erb[i] = tmp; - } - } - } - else if ( l > pl ) - { - tmp = t_prev_erb[num_erb - 1]; - for ( i = num_erb - 1; i >= 0; i-- ) - { - if ( pslot[i] != 0 ) - { - tmp = t_prev_erb[i]; - } - else - { - t_prev_erb[i] = tmp; - } - } - } - - for ( i = 0; i < num_erb; i++ ) - { - out[i] = curr_erb[i] - t_prev_erb[i]; - } - - /* First Band Amplitude Search */ - mmse = (float) HUGE_VAL; - mmseindex = -1; - for ( j = 0; j < ERB_CBSIZE1; j++ ) - { - tmp = 0.0; - for ( i = 1; i < 11; i++ ) - { - if ( cslot[i] != 0 ) - { - if ( AmpCB1[j][i - 1] < -t_prev_erb[i] ) - { - tmp1 = PowSpect[i] * SQR( curr_erb[i] ); - } - else - { - tmp1 = (float) ( PowSpect[i] * SQR( out[i] - AmpCB1[j][i - 1] ) ); - } - if ( AmpCB1[j][i - 1] < out[i] ) - { - tmp1 *= 0.9f; - } - tmp += tmp1; - } - } - - if ( tmp < mmse ) - { - mmse = tmp; - mmseindex = j; - } - } - - if ( !( mmseindex < ERB_CBSIZE1 && mmseindex >= 0 ) ) - { - mmseindex = 0; - } - - index[0] = mmseindex; - - /* Second Band Amplitude Search */ - mmse = (float) HUGE_VAL; - mmseindex = -1; - for ( j = 0; j < ERB_CBSIZE2; j++ ) - { - tmp = 0.0; - for ( i = 11; i < num_erb; i++ ) - { - if ( num_erb == NUM_ERB_NB ) - { - if ( cslot[i] != 0 ) - { - if ( AmpCB2_NB[j][i - 11] < -t_prev_erb[i] ) - { - tmp1 = PowSpect[i] * SQR( curr_erb[i] ); - } - else - { - tmp1 = (float) ( PowSpect[i] * SQR( out[i] - AmpCB2_NB[j][i - 11] ) ); - } - - if ( AmpCB2_NB[j][i - 11] < out[i] ) - { - tmp1 *= 0.9f; - } - tmp += tmp1; - } - } - else if ( num_erb == NUM_ERB_WB ) - { - if ( cslot[i] != 0 ) - { - if ( AmpCB2_WB[j][i - 11] < -t_prev_erb[i] ) - { - tmp1 = PowSpect[i] * SQR( curr_erb[i] ); - } - else - { - tmp1 = (float) ( PowSpect[i] * SQR( out[i] - AmpCB2_WB[j][i - 11] ) ); - } - - if ( AmpCB2_WB[j][i - 11] < out[i] ) - { - tmp1 *= 0.9f; - } - tmp += tmp1; - } - } - } - - if ( tmp < mmse ) - { - mmse = tmp; - mmseindex = j; - } - } - - if ( !( mmseindex < ERB_CBSIZE2 && mmseindex >= 0 ) ) - { - mmseindex = 0; - } - - index[1] = mmseindex; -#endif return; } @@ -2960,7 +2071,6 @@ void erb_add( AmpCB1 = AmpCB1_WB; } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 3 ); erb_slot( l, cslot, t_prev_erb, num_erb ); @@ -3069,84 +2179,6 @@ void erb_add( } } #undef WMC_TOOL_SKIP -#else - erb_slot( l, cslot, t_prev_erb, num_erb ); - erb_slot( pl, pslot, t_prev_erb, num_erb ); - - for ( i = 0; i < num_erb; i++ ) - { - t_prev_erb[i] = prev_erb[i]; - } - - if ( pl > l ) - { - tmp = t_prev_erb[0]; - for ( i = 0; i < num_erb; i++ ) - { - if ( !( pslot[i] >= 0 ) ) - { - pslot[i] = 0; - } - - if ( pslot[i] != 0 ) - { - tmp = t_prev_erb[i]; - } - else - { - t_prev_erb[i] = tmp; - } - } - } - else if ( l > pl ) - { - tmp = t_prev_erb[num_erb - 1]; - for ( i = num_erb - 1; i >= 0; i-- ) - { - if ( pslot[i] != 0 ) - { - tmp = t_prev_erb[i]; - } - else - { - t_prev_erb[i] = tmp; - } - } - } - - for ( i = 1; i < 11; i++ ) - { - if ( cslot[i] != 0 ) - { - curr_erb[i] = (float) ( AmpCB1[index[0]][i - 1] + t_prev_erb[i] ); - curr_erb[i] = max( 0.0f, curr_erb[i] ); - } - else - { - curr_erb[i] = 0.0; - } - } - for ( i = 11; i < ( num_erb - 2 ); i++ ) - { - if ( cslot[i] != 0 ) - { - if ( num_erb == NUM_ERB_NB ) - { - curr_erb[i] = (float) ( AmpCB2_NB[index[1]][i - 11] + t_prev_erb[i] ); - curr_erb[i] = max( 0.0f, curr_erb[i] ); - } - else if ( num_erb == NUM_ERB_WB ) - { - curr_erb[i] = (float) ( AmpCB2_WB[index[1]][i - 11] + t_prev_erb[i] ); - curr_erb[i] = max( 0.0f, curr_erb[i] ); - } - } - else - { - curr_erb[i] = 0.0f; - } - } -#endif return; } @@ -3185,7 +2217,6 @@ ivas_error WIsyn( return IVAS_ERROR( error, "Error creating new DTFS structure\n" ); } -#ifdef FIX_VBR_COMPLEXITY #define WMC_TOOL_SKIP FUNC( 2 ); DTFS_copy( CURRCW_DTFS, *CURRCW_DTFS_out ); @@ -3258,51 +2289,6 @@ ivas_error WIsyn( DIV( 1 ); *ph_offset = (float) fmod( (double) ( tmp ), PI2 ); #undef WMC_TOOL_SKIP -#else - DTFS_copy( CURRCW_DTFS, *CURRCW_DTFS_out ); - - /* Calculating the expected alignment shift */ - alignment = (float) ( *ph_offset / PI2 * PREVCW.lag ); - if ( flag == 1 ) - { - alignment *= I; - } - /* Calculating the expected alignment shift */ - tmp = (float) fmod( ( N % ( ( PREVCW.lag + CURRCW_DTFS->lag ) >> 1 ) + alignment ), CURRCW_DTFS->lag ); - - /* Compute the alignment shift */ - if ( FR_flag == 0 ) - { - alignment = DTFS_alignment_weight( PREVCW, *CURRCW_DTFS, tmp, curr_lpc, curr_lpc ); - } - else /* FR case */ - { - alignment = DTFS_alignment_full( PREVCW, *CURRCW_DTFS, CURRCW_DTFS->lag * 2 ); - } - - tmp = (float) ( PI2 * alignment / CURRCW_DTFS->lag ); - DTFS_phaseShift( CURRCW_DTFS, tmp ); - DTFS_phaseShift( CURRCW_DTFS_out, (float) ( PI2 * alignment / CURRCW_DTFS_out->lag ) ); - - /* Compute the cubic phase track and transform to 1-D signal */ - cubicPhase( *ph_offset, tmp, (float) PREVCW.lag, (float) CURRCW_DTFS->lag, N, phase ); - - if ( FR_flag == 0 ) - { - DTFS_transform( PREVCW, *CURRCW_DTFS, phase, out, N, 0 ); - } - else - { - DTFS_transform( PREVCW, *CURRCW_DTFS, phase, out, N, 1 ); - } - - /* Adjust the phase offset and wrap it between 0 and 2pi */ - if ( flag == 2 ) - { - tmp *= I; - } - *ph_offset = (float) fmod( (double) ( tmp ), PI2 ); -#endif free( phase ); free( CURRCW_DTFS ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index c68c1b64903c9fbddf494e203ff16469ed3f236f..7176a008862d2e391224e205028633b38d87edbe 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -394,15 +394,10 @@ ivas_error ivas_dec( ivas_crend_process( st_ivas, output ); ivas_binaural_add_LFE( st_ivas, output_frame, output ); } - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef FIX_I59_LFE_CLDFB ivas_binaural_cldfb( st_ivas, output ); ivas_binaural_add_LFE( st_ivas, output_frame, output ); -#else - ivas_binaural_add_LFE( st_ivas, output_frame, output ); - ivas_binaural_cldfb( st_ivas, output ); -#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index dae674f2866ae7093b33ddd24d5ca2f0232215d2..604953777f77b242c1e99ec9c6ea253bc125c7da 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -619,15 +619,12 @@ ivas_error ivas_init_decoder( { int16_t i, k, n; int16_t sce_id, cpe_id; - int16_t numCldfbAnalyses; - int16_t numCldfbSyntheses; + int16_t numCldfbAnalyses, numCldfbSyntheses; int32_t output_Fs, ivas_total_brate; + int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; -#ifdef FIX_I59_LFE_TD_DELAY - int32_t binauralization_delay_ns; -#endif error = IVAS_ERR_OK; @@ -850,30 +847,6 @@ ivas_error ivas_init_decoder( } st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO ); - -#ifndef SBA_DIRAC_RENDERER_TYPE_CLEANUP - if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup ) - { - int16_t ambisonics_order; - - ambisonics_order = ivas_sba_get_order_transport( st_ivas->nchan_transport ); // VE: is it needed ? - - if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, ambisonics_order ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && !st_ivas->hIntSetup.is_loudspeaker_setup ) - { - IVAS_OUTPUT_SETUP out_setup; - - ivas_output_init( &out_setup, AUDIO_CONFIG_7_1_4 ); - if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif } } @@ -1263,11 +1236,9 @@ ivas_error ivas_init_decoder( if ( st_ivas->mc_mode == MC_MODE_MCT ) { -#ifdef FIX_I59_LFE_TD_DELAY binauralization_delay_ns = st_ivas->binaural_latency_ns; if ( st_ivas->hBinRenderer != NULL ) { -#ifdef FIX_I59_LFE_CLDFB if ( st_ivas->hBinRenderer->render_lfe ) { /* Account for filterbank delay */ @@ -1277,14 +1248,9 @@ ivas_error ivas_init_decoder( { binauralization_delay_ns = 0; } -#else - binauralization_delay_ns = 0; -#endif } + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, st_ivas->hHrtf != NULL ? st_ivas->hHrtf->latency_s : 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index d7ca800afef0847a83990d944ca0364a64134e44..57b962f76bf7e89c6f8e5839ff598dc30d855583 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -350,13 +350,9 @@ void ivas_lfe_dec( *-------------------------------------------------------------------------*/ ivas_error ivas_create_lfe_dec( - LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ - const int32_t output_Fs, /* i : output sampling rate */ -#ifdef FIX_I59_LFE_TD_DELAY - const int32_t binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */ -#else - const float add_delay_s /* i : additional LFE delay to sync with binaural filter */ -#endif + LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ + const int32_t output_Fs, /* i : output sampling rate */ + const int32_t binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */ ) { float low_pass_delay_dec_out, block_offset_s; @@ -365,9 +361,7 @@ ivas_error ivas_create_lfe_dec( LFE_DEC_HANDLE hLFE; float lfe_addl_delay_s; int16_t i, j; -#ifdef FIX_I59_LFE_TD_DELAY int16_t add_delay_sa; -#endif low_pass_delay_dec_out = 0; block_offset_s = 0; @@ -443,7 +437,6 @@ ivas_error ivas_create_lfe_dec( lfe_addl_delay_s = block_offset_s - hLFE->lfe_block_delay_s; lfe_addl_delay_s = max( 0.0f, lfe_addl_delay_s ); -#ifdef FIX_I59_LFE_TD_DELAY #ifdef FIX_FIX_I59 add_delay_sa = (int16_t) roundf( (float) binauralization_delay_ns * output_Fs / 1000000000.f ); #else @@ -451,10 +444,6 @@ ivas_error ivas_create_lfe_dec( #endif hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs ) + add_delay_sa; hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_sa / output_Fs; -#else - hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs ) + (int16_t) roundf( add_delay_s * output_Fs ); - hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_s; -#endif if ( hLFE->lfe_addl_delay > 0 ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a9d4a559d44dcd0e3142f8a18178832de86ed8ca..1616fa7c1b87dd5ba9497923701e3954b8c92ff0 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1035,12 +1035,9 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL ) { -#ifdef FIX_I59_LFE_TD_DELAY int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns; - if ( st_ivas->hBinRenderer != NULL ) { -#ifdef FIX_I59_LFE_CLDFB if ( st_ivas->hBinRenderer->render_lfe ) { /* Account for filterbank delay */ @@ -1050,14 +1047,9 @@ static ivas_error ivas_mc_dec_reconfig( { binauralization_delay_ns = 0; } -#else - binauralization_delay_ns = 0; -#endif } + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtf != NULL ? st_ivas->hHrtf->latency_s : 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 1bc71650f8ff1918d1c462d051103c2ca52a3859..c2997eefc57d1d723a98000cebab9b15acee7f8b 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -333,30 +333,6 @@ ivas_error ivas_sba_dec_reinit( } st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO ); - -#ifndef SBA_DIRAC_RENDERER_TYPE_CLEANUP - if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup ) - { - int16_t ambisonics_order; - - ambisonics_order = ivas_sba_get_order_transport( st_ivas->nchan_transport ); // VE: is it needed ? - - if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, ambisonics_order ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && !st_ivas->hIntSetup.is_loudspeaker_setup ) - { - IVAS_OUTPUT_SETUP out_setup; - - ivas_output_init( &out_setup, AUDIO_CONFIG_7_1_4 ); - if ( ( error = ivas_sba_get_hoa_dec_matrix( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif } if ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index bef074b3e10b73774ce753bcc374024b567f3ddf..4cfbc98ad60a8e4242ccf8bc21ff0ab1bad26198 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1895,11 +1895,7 @@ typedef struct Decoder_Struct float *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ -#ifdef FIX_I59_LFE_TD_DELAY int32_t binaural_latency_ns; /* Binauralization latency in ns */ -#else - int32_t binaural_latency_ns; /* HRTF binauralization latency in ns */ -#endif #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b42abb75ac5a05547d61c43f85da7822244a6962..73343af1f24b2ad10c79adebde0552c149abef1e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1157,18 +1157,10 @@ ivas_error IVAS_DEC_GetDelay( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; -#ifdef FIX_I59_LFE_TD_DELAY #ifdef FIX_I59_DELAY_ROUNDING *nSamples = (int16_t) roundf( (float) get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->binaural_latency_ns ) * hDecoderConfig->output_Fs / 1000000000.f ); #else *nSamples = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->binaural_latency_ns ) ); -#endif -#else -#ifdef FIX_I59_DELAY_ROUNDING - *nSamples = (int16_t) roundf( get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->renderer_type, st_ivas->binaural_latency_ns ) * hDecoderConfig->output_Fs / 1000000000.f ); -#else - *nSamples = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->renderer_type, st_ivas->binaural_latency_ns ) ); -#endif #endif *timeScale = hDecoderConfig->output_Fs; diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index ee15cee32c5125fda9cb0ca46321ee031ebad50d..b40be98fc28dca7ec09ff6820bf4f7be1ccc5bf1 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -532,9 +532,6 @@ void amr_wb_enc( /* update main codec paramaters */ #ifdef MC_BITRATE_SWITCHING -#ifndef REMOVE_ETOT_PROPAGATION - st->hNoiseEst->Etot_last = Etot; -#endif updt_enc_common( st ); #else updt_enc_common( st, Etot ); diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 397965e9748eac3ce820c1ebbd57ca0c3418e9d5..d6b6220d91c6826d0e5aad226a63d99d7a2f4108 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -401,22 +401,8 @@ void core_switching_post_enc( ( st->last_core == HQ_CORE || st->L_frame != st->last_L_frame || ( st->last_extl != SWB_TBE && st->last_extl != FB_TBE && st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE ) ) ) { set_f( st->hBWE_TD->state_ana_filt_shb, 0.0f, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( st->hBWE_TD, NULL ); -#else - set_f( st->hBWE_TD->old_speech_shb, 0.0f, L_LOOK_16k + L_SUBFR16k ); - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_shb_env_tilt = 0.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif - swb_tbe_reset( st->hBWE_TD->mem_csfilt, st->hBWE_TD->mem_genSHBexc_filt_down_shb, st->hBWE_TD->state_lpc_syn, st->hBWE_TD->syn_overlap, st->hBWE_TD->state_syn_shbexc, &( st->hBWE_TD->tbe_demph ), &( st->hBWE_TD->tbe_premph ), st->hBWE_TD->mem_stp_swb, &( st->hBWE_TD->gain_prec_swb ) ); - set_f( st->hBWE_TD->dec_2_over_3_mem, 0.0f, L_FILT_2OVER3 ); set_f( st->hBWE_TD->dec_2_over_3_mem_lp, 0.0f, L_FILT_2OVER3_LP ); } diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index 9489742b4c112bfbf2bf8f0c3a30e169403876f7..54e639923ecbb3991a3085d9be88140380d9a9c5 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -72,20 +72,17 @@ ivas_error evs_enc( float old_inp_12k8[L_INP_12k8], *inp; /* buffer of input signal @ 12k8 */ float old_inp_16k[L_INP]; /* buffer of input signal @ 16kHz */ float fr_bands[2 * NB_BANDS]; /* energy in frequency bands */ -#ifndef REMOVE_ETOT_PROPAGATION - float Etot; /* total energy; correlation shift */ -#endif - float ener; /* residual energy from Levinson-Durbin */ - float A[NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */ - float epsP[M + 1]; /* LP prediction errors */ - float lsp_new[M]; /* LSPs at the end of the frame */ - float lsp_mid[M]; /* ISPs in the middle of the frame */ - int16_t vad_hover_flag; /* VAD hangover flag */ - int16_t hq_core_type; /* HQ core type (HQ, or LR-MDCT) */ - int16_t attack_flag; /* attack flag (GSC or TC) */ - float new_inp_resamp16k[L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - float old_syn_12k8_16k[L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ + float ener; /* residual energy from Levinson-Durbin */ + float A[NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ + float Aw[NB_SUBFR16k * ( M + 1 )]; /* weighted A(z) unquantized for subframes */ + float epsP[M + 1]; /* LP prediction errors */ + float lsp_new[M]; /* LSPs at the end of the frame */ + float lsp_mid[M]; /* ISPs in the middle of the frame */ + int16_t vad_hover_flag; /* VAD hangover flag */ + int16_t hq_core_type; /* HQ core type (HQ, or LR-MDCT) */ + int16_t attack_flag; /* attack flag (GSC or TC) */ + float new_inp_resamp16k[L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + float old_syn_12k8_16k[L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ float shb_speech[L_FRAME16k]; float hb_speech[L_FRAME16k / 4]; float new_swb_speech[L_FRAME48k]; @@ -165,17 +162,6 @@ ivas_error evs_enc( if ( st->last_core == AMR_WB_CORE ) { updt_IO_switch_enc( st, input_frame ); -#ifndef SIMPLIFY_TD_BWE_RESET - set_f( st->hBWE_TD->old_speech_shb, 0, L_LOOK_16k + L_SUBFR16k ); - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_shb_env_tilt = 0.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif cldfb_reset_memory( st->cldfbAnaEnc ); cldfb_reset_memory( st->cldfbSynTd ); } @@ -185,19 +171,10 @@ ivas_error evs_enc( *---------------------------------------------------------------------*/ #ifdef FIX_I4_OL_PITCH -#ifdef REMOVE_ETOT_PROPAGATION 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, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type ); -#endif -#else -#ifdef REMOVE_ETOT_PROPAGATION 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 ); -#else - pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &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 -#endif - if ( st->mdct_sw == MODE2 ) { @@ -438,20 +415,7 @@ ivas_error evs_enc( } else if ( st->input_Fs >= 32000 ) { -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( st->hBWE_TD, shb_speech ); -#else - set_f( st->hBWE_TD->old_speech_shb, 0.0f, L_LOOK_16k + L_SUBFR16k ); - set_f( shb_speech, 0.0f, L_FRAME16k ); - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_shb_env_tilt = 0.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif } /* SWB TBE encoder */ @@ -526,9 +490,6 @@ ivas_error evs_enc( *---------------------------------------------------------------------*/ #ifdef MC_BITRATE_SWITCHING -#ifndef REMOVE_ETOT_PROPAGATION - st->hNoiseEst->Etot_last = Etot; -#endif updt_enc_common( st ); #else updt_enc_common( st, Etot ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 4e1478b65341170d0512343bdd6aa45f868cfb7b..0d1bcf6381a993b2fbe962975779ad94a9fda32b 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -55,15 +55,12 @@ extern float snr_[2][320]; *-------------------------------------------------------------------*/ ivas_error ivas_core_enc( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const int16_t n_CoreChannels, /* i : number of core channels to be coded */ - float old_inp_12k8[CPE_CHANNELS][L_INP_12k8], /* i : buffer of old input signal */ - float old_inp_16k[CPE_CHANNELS][L_INP], /* i : buffer of old input signal */ -#ifndef REMOVE_ETOT_PROPAGATION - const float Etot[CPE_CHANNELS], /* i : total energy */ -#endif + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + const int16_t n_CoreChannels, /* i : number of core channels to be coded */ + float old_inp_12k8[CPE_CHANNELS][L_INP_12k8], /* i : buffer of old input signal */ + float old_inp_16k[CPE_CHANNELS][L_INP], /* i : buffer of old input signal */ float ener[CPE_CHANNELS], /* i : residual energy from Levinson-Durbin */ float A[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes */ float Aw[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes */ @@ -345,20 +342,7 @@ ivas_error ivas_core_enc( { if ( st->hBWE_TD != NULL ) { -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( st->hBWE_TD, shb_speech ); -#else - set_f( st->hBWE_TD->old_speech_shb, 0.0f, L_LOOK_16k + L_SUBFR16k ); - set_f( shb_speech, 0.0f, L_FRAME16k ); - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_shb_env_tilt = 0.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif } } @@ -416,9 +400,6 @@ ivas_error ivas_core_enc( *---------------------------------------------------------------------*/ #ifdef MC_BITRATE_SWITCHING -#ifndef REMOVE_ETOT_PROPAGATION - st->hNoiseEst->Etot_last = Etot[n]; -#endif if ( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */ { updt_enc_common( st ); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index ad70c7a4529c11e0873c5ef9ba5ef94388bbf212..08b9ef7b07e620a7ccba9b010f88e92f1f40c3ef 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -45,13 +45,12 @@ #include -#ifdef LOW_RATE_TRANS /*---------------------------------------------------------------* * Local constants *---------------------------------------------------------------*/ #define SCE_SMC_THR 16000 -#endif + /*-------------------------------------------------------------------* * Local function prototypes @@ -68,17 +67,14 @@ static void calculate_energy_buffer( CPE_ENC_HANDLE hCPE, float enerBuffer_dft[] *--------------------------------------------------------------------*/ ivas_error pre_proc_front_ivas( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t element_brate, /* i : SCE/CPE element bitrate */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int16_t input_frame, /* i : frame length */ - const int16_t n, /* i : channel number */ - float old_inp_12k8[], /* o : buffer of old input signal */ - float old_inp_16k[], /* o : buffer of old input signal @16kHz */ -#ifndef REMOVE_ETOT_PROPAGATION - float *Etot, /* o : total energy */ -#endif + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const int32_t element_brate, /* i : SCE/CPE element bitrate */ + const int16_t nb_bits_metadata, /* i : number of metadata bits */ + const int16_t input_frame, /* i : frame length */ + const int16_t n, /* i : channel number */ + float old_inp_12k8[], /* o : buffer of old input signal */ + float old_inp_16k[], /* o : buffer of old input signal @16kHz */ float *ener, /* o : residual energy from Levinson-Durbin */ float *relE, /* o : frame relative energy */ float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ @@ -110,21 +106,14 @@ ivas_error pre_proc_front_ivas( const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ -#ifdef LOW_RATE_TRANS - const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const int32_t ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */ - const int16_t ivas_format /* i : IVAS format */ -#else - const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#endif + const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ + const int32_t ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */ + const int16_t ivas_format /* i : IVAS format */ ) { - float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ - float *wsp; /* weighted input signal buffer */ -#ifdef REMOVE_ETOT_PROPAGATION - float Etot; /* total energy */ -#endif + float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ + float *wsp; /* weighted input signal buffer */ + float Etot; /* total energy */ float fr_bands[2 * NB_BANDS]; /* energy in frequency bands */ float lf_E[2 * VOIC_BINS]; /* per bin spectrum energy in lf */ float tmpN[NB_BANDS]; /* Temporary noise update */ @@ -426,19 +415,11 @@ ivas_error pre_proc_front_ivas( * Spectral analysis *--------------------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION analy_sp( element_mode, hCPE, input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, &Etot, st->min_band, st->max_band, band_energies, PS, fft_buff ); -#else - analy_sp( element_mode, hCPE, input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, Etot, st->min_band, st->max_band, band_energies, PS, fft_buff ); -#endif if ( hStereoClassif != NULL ) { -#ifdef REMOVE_ETOT_PROPAGATION if ( st->lp_speech - Etot > 25 ) -#else - if ( st->lp_speech - *Etot > 25 ) -#endif { hStereoClassif->silence_flag = 2; } @@ -453,11 +434,7 @@ ivas_error pre_proc_front_ivas( * SAD (1-signal, 0-noise) *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est_pre( Etot, st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE != NULL ? hCPE->last_element_mode : element_mode ); -#else - noise_est_pre( *Etot, st->ini_frame, st->hNoiseEst, st->idchan, element_mode, hCPE != NULL ? hCPE->last_element_mode : element_mode ); -#endif if ( element_mode == IVAS_CPE_TD && ( ( abs( hCPE->hStereoTD->tdm_last_ratio_idx - tdm_ratio_idx ) > 5 && st->idchan == 1 ) || abs( hCPE->hStereoTD->tdm_last_inst_ratio_idx - hCPE->hStereoTD->tdm_inst_ratio_idx ) > 10 ) ) { @@ -530,11 +507,7 @@ ivas_error pre_proc_front_ivas( * Correlation correction as a function of total noise level *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est_down( fr_bands, st->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise, Etot, &st->hNoiseEst->Etot_last, &st->hNoiseEst->Etot_v_h2 ); -#else - noise_est_down( fr_bands, st->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise, *Etot, &st->hNoiseEst->Etot_last, &st->hNoiseEst->Etot_v_h2 ); -#endif if ( lr_vad_enabled && st->idchan == 0 ) { @@ -544,11 +517,7 @@ ivas_error pre_proc_front_ivas( corr_shiftR = correlation_shift( hCPE->hFrontVad[1]->hNoiseEst->totalNoise ); } -#ifdef REMOVE_ETOT_PROPAGATION *relE = Etot - st->lp_speech; -#else - *relE = *Etot - st->lp_speech; -#endif corr_shift = correlation_shift( st->hNoiseEst->totalNoise ); @@ -694,13 +663,8 @@ ivas_error pre_proc_front_ivas( * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est( st, old_pitch1, tmpN, epsP, Etot, *relE, corr_shift, tmpE, fr_bands, cor_map_sum, &ncharX, &sp_div, &non_staX, loc_harm, lf_E, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp, &dummy /*sp_floor*/, S_map, hStereoClassif, NULL, st->ini_frame ); -#else - noise_est( st, old_pitch1, tmpN, epsP, *Etot, *relE, corr_shift, tmpE, fr_bands, cor_map_sum, &ncharX, &sp_div, - &non_staX, loc_harm, lf_E, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp, &dummy /*sp_floor*/, S_map, hStereoClassif, NULL, st->ini_frame ); -#endif if ( lr_vad_enabled && st->idchan == 0 ) { @@ -732,11 +696,7 @@ ivas_error pre_proc_front_ivas( find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef REMOVE_ETOT_PROPAGATION 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 ); -#else - 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 ); -#endif /*-----------------------------------------------------------------* * channel aware mode configuration * @@ -772,11 +732,7 @@ ivas_error pre_proc_front_ivas( * 1st stage speech/music classification (GMM model) *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION 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 ); -#else - 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 ); -#endif #ifdef DEBUGGING if ( st->idchan == 0 ) @@ -799,28 +755,16 @@ ivas_error pre_proc_front_ivas( * Update of old per-band energy spectrum *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION long_enr( st, Etot, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); -#else - long_enr( st, *Etot, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); -#endif mvr2r( fr_bands + NB_BANDS, st->hNoiseEst->enrO, NB_BANDS ); if ( lr_vad_enabled && st->idchan == 0 ) { -#ifdef REMOVE_ETOT_PROPAGATION long_enr( st, -1, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR ); -#else - long_enr( st, *Etot, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR ); -#endif 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 ); -#ifndef REMOVE_ETOT_PROPAGATION - hCPE->hFrontVad[0]->hNoiseEst->Etot_last = Etot_LR[0]; - hCPE->hFrontVad[1]->hNoiseEst->Etot_last = Etot_LR[1]; -#endif } /*----------------------------------------------------------------* @@ -844,11 +788,7 @@ ivas_error pre_proc_front_ivas( else if ( element_mode != IVAS_CPE_MDCT ) { /* SNR-based speech/music classification */ -#ifdef LOW_RATE_TRANS if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= SCE_SMC_THR ) ) -#else - if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= 16000 ) ) -#endif { if ( flag_16k_smc ) { @@ -866,7 +806,6 @@ ivas_error pre_proc_front_ivas( smc_dec = ivas_acelp_tcx20_switching( st, inp_12k8, wsp, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc ); } } -#ifdef LOW_RATE_TRANS /* Switch to ACELP for non-harmonic transient signals */ else if ( ( ( ivas_format == STEREO_FORMAT && element_brate <= IVAS_16k4 ) || ( ivas_format == ISM_FORMAT && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC ) { @@ -888,13 +827,9 @@ ivas_error pre_proc_front_ivas( } } } -#endif + /* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */ -#ifdef REMOVE_ETOT_PROPAGATION ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch ); -#else - ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, *Etot, attack_flag, inp_12k8, S_map, flag_spitch ); -#endif #ifdef ITD_WINNER_GAIN_MODIFY if ( element_mode == IVAS_CPE_DFT ) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index c179ea1e4e0887bd2e6d801edea4e4cde36d77b1..1ab8a5084c2379cb59398429ee81c39e64305e61 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -63,11 +63,8 @@ ivas_error ivas_cpe_enc( CPE_ENC_HANDLE hCPE; Encoder_State **sts; int16_t n, n_CoreChannels; - float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */ - float old_inp_16k[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */ -#ifndef REMOVE_ETOT_PROPAGATION - float Etot[CPE_CHANNELS]; /* total energy; correlation shift */ -#endif + float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */ + float old_inp_16k[CPE_CHANNELS][L_INP]; /* buffer of input signal @ 16kHz */ float ener[CPE_CHANNELS]; /* residual energy from Levinson-Durbin */ float relE[CPE_CHANNELS]; /* frame relative energy */ float A[CPE_CHANNELS][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ @@ -98,9 +95,7 @@ ivas_error ivas_cpe_enc( int16_t 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 */ float orig_input[CPE_CHANNELS][L_FRAME48k]; -#ifdef REMOVE_ETOT_PROPAGATION float Etot_last[CPE_CHANNELS]; -#endif int32_t tmp, input_Fs; int16_t max_bwidth, ivas_format; ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -371,10 +366,9 @@ ivas_error ivas_cpe_enc( { sts[1]->bits_frame_channel -= st_ivas->hQMetaData->metadata_max_bits; } -#ifdef REMOVE_ETOT_PROPAGATION + Etot_last[0] = sts[0]->hNoiseEst->Etot_last; Etot_last[1] = sts[1]->hNoiseEst->Etot_last; -#endif } else if ( hCPE->element_mode == IVAS_CPE_MDCT ) { @@ -435,21 +429,11 @@ ivas_error ivas_cpe_enc( for ( n = 0; n < n_CoreChannels; n++ ) { -#ifdef LOW_RATE_TRANS error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], -#ifndef REMOVE_ETOT_PROPAGATION - &Etot[n], -#endif &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_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#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], &Etot[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_total_brate ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -532,11 +516,7 @@ ivas_error ivas_cpe_enc( { tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr ); -#ifdef REMOVE_ETOT_PROPAGATION tdm_configure_enc( hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); -#else - tdm_configure_enc( hCPE, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); -#endif if ( hEncoderConfig->Opt_DTX_ON ) { @@ -637,11 +617,7 @@ ivas_error ivas_cpe_enc( * Core Encoder *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8, old_inp_16k, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, realBuffer, imagBuffer, old_wsp, loc_harm, cor_map_sum, vad_flag_dtx, enerBuffer, fft_buff, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8, old_inp_16k, Etot, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, realBuffer, imagBuffer, old_wsp, loc_harm, cor_map_sum, vad_flag_dtx, enerBuffer, fft_buff, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 16ea571dd0dc1f43ab787f04dfc83aabff8e90c5..c95f0bc47a55c143ce017134b330f17391f8f89f 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -475,12 +475,7 @@ ivas_error front_vad_spar( ivas_smc_gmm( st, NULL, localVAD_HE_SAD[0], Etot[0], lsp_new, cor_map_sum, epsP, PS, non_staX, relE, &high_lpn_flag, flag_spitch ); /* long-term energy update */ -#ifdef REMOVE_ETOT_PROPAGATION long_enr( st, -1, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot ); -#else - long_enr( st, *Etot, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot ); - hFrontVad->hNoiseEst->Etot_last = Etot[0]; -#endif /* increase ini_frame counter */ hFrontVad->ini_frame = min( hFrontVad->ini_frame + 1, MAX_FRAME_COUNTER ); diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index f59edfaf0e049c199888fd13baa2c729cdbf891c..1849d2da037d21697c1cbd8d2bc38c3e49a1e3e8 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -58,12 +58,9 @@ ivas_error ivas_ism_enc( SCE_ENC_HANDLE hSCE; Encoder_State *st; int16_t sce_id; - float old_inp_12k8[MAX_NUM_OBJECTS][1][L_INP_12k8]; /* buffer of input signal @ 12k8 */ - float old_inp_16k[MAX_NUM_OBJECTS][1][L_INP]; /* buffer of input signal @ 16kHz */ - int16_t vad_flag[MAX_NUM_OBJECTS]; /* VAD flag */ -#ifndef REMOVE_ETOT_PROPAGATION - float Etot[MAX_NUM_OBJECTS][1]; /* total energy; correlation shift */ -#endif + float old_inp_12k8[MAX_NUM_OBJECTS][1][L_INP_12k8]; /* buffer of input signal @ 12k8 */ + float old_inp_16k[MAX_NUM_OBJECTS][1][L_INP]; /* buffer of input signal @ 16kHz */ + int16_t vad_flag[MAX_NUM_OBJECTS]; /* VAD flag */ float ener[MAX_NUM_OBJECTS][1]; /* residual energy from Levinson-Durbin */ float relE[MAX_NUM_OBJECTS][1]; /* frame relative energy */ float A[MAX_NUM_OBJECTS][1][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ @@ -149,25 +146,11 @@ ivas_error ivas_ism_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS 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], -#ifndef REMOVE_ETOT_PROPAGATION - &Etot[sce_id][0], -#endif &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, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#else - 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], -#ifndef REMOVE_ETOT_PROPAGATION - &Etot[sce_id][0], -#endif - &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, - st_ivas->hEncoderConfig->ivas_total_brate ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -279,11 +262,7 @@ ivas_error ivas_ism_enc( * Encoder *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], ener[sce_id], A[sce_id], Aw[sce_id], epsP[sce_id], lsp_new[sce_id], lsp_mid[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer[sce_id], imagBuffer[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum[sce_id], vad_flag_dtx[sce_id], enerBuffer[sce_id], fft_buff[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], Etot[sce_id], ener[sce_id], A[sce_id], Aw[sce_id], epsP[sce_id], lsp_new[sce_id], lsp_mid[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer[sce_id], imagBuffer[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum[sce_id], vad_flag_dtx[sce_id], enerBuffer[sce_id], fft_buff[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 9970d7b5fbaf8f833a9976f84cac50b19a8771ab..a67c52708158971bd80cf38e819243eaf1e6b9a4 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -58,11 +58,8 @@ ivas_error ivas_sce_enc( const int16_t nb_bits_metadata /* i : number of metadata bits */ ) { - float old_inp_12k8[1][L_INP_12k8]; /* buffer of input signal @ 12k8 */ - float old_inp_16k[1][L_INP]; /* buffer of input signal @ 16kHz */ -#ifndef REMOVE_ETOT_PROPAGATION - float Etot[1]; /* total energy; correlation shift */ -#endif + float old_inp_12k8[1][L_INP_12k8]; /* buffer of input signal @ 12k8 */ + float old_inp_16k[1][L_INP]; /* buffer of input signal @ 16kHz */ float ener[1]; /* residual energy from Levinson-Durbin */ float relE[1]; /* frame relative energy */ float A[1][NB_SUBFR16k * ( M + 1 )]; /* A(z) unquantized for subframes */ @@ -183,27 +180,12 @@ ivas_error ivas_sce_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], -#ifndef REMOVE_ETOT_PROPAGATION - &Etot[0], -#endif &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, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#else - error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], -#ifndef REMOVE_ETOT_PROPAGATION - &Etot[0], -#endif - &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, - st_ivas->hEncoderConfig->ivas_total_brate ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -255,11 +237,7 @@ ivas_error ivas_sce_enc( * Encoder *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8, old_inp_16k, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, realBuffer, imagBuffer, old_wsp, loc_harm, cor_map_sum, vad_flag_dtx, enerBuffer, fft_buff, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8, old_inp_16k, Etot, ener, A, Aw, epsP, lsp_new, lsp_mid, vad_hover_flag, attack_flag, realBuffer, imagBuffer, old_wsp, loc_harm, cor_map_sum, vad_flag_dtx, enerBuffer, fft_buff, 0, ivas_format, flag_16k_smc ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 78349edf334d0a37926dfc10044d9d4e0e7c6307..4823e2b5f10bebbaf1d7984f84cb8055bcae1ae9 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -302,15 +302,13 @@ ivas_error stereo_set_tdm( *-------------------------------------------------------------------*/ void tdm_configure_enc( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ -#ifdef REMOVE_ETOT_PROPAGATION + CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ -#endif - const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ - const int16_t tdm_ratio_idx, /* i : ratio index */ - const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ - const int16_t attack_flag, /* i : Primary channel attack flag */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ + const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ + const int16_t tdm_ratio_idx, /* i : ratio index */ + const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ + const int16_t attack_flag, /* i : Primary channel attack flag */ + const int16_t nb_bits_metadata /* i : number of metadata bits */ ) { int16_t tdm_ratio_bit_alloc_idx, mod_ct; @@ -329,21 +327,11 @@ void tdm_configure_enc( *----------------------------------------------------------------*/ hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */ -#ifdef REMOVE_ETOT_PROPAGATION sts[0]->hSpMusClas->tdm_lt_Etot = 0.1f * Etot_last[0] + 0.9f * sts[0]->hSpMusClas->tdm_lt_Etot; sts[1]->hSpMusClas->tdm_lt_Etot = 0.1f * Etot_last[1] + 0.9f * sts[1]->hSpMusClas->tdm_lt_Etot; -#else - sts[0]->hSpMusClas->tdm_lt_Etot = 0.1f * sts[0]->hNoiseEst->Etot_last + 0.9f * sts[0]->hSpMusClas->tdm_lt_Etot; - sts[1]->hSpMusClas->tdm_lt_Etot = 0.1f * sts[1]->hNoiseEst->Etot_last + 0.9f * sts[1]->hSpMusClas->tdm_lt_Etot; -#endif -#ifdef REMOVE_ETOT_PROPAGATION if ( hCPE->hStereoClassif->lrtd_mode == 0 && ( ( sts[1]->hSpMusClas->tdm_lt_Etot < 0 && hCPE->hCoreCoder[1]->vad_flag == 0 ) /* very clean signal */ || ( hCPE->hCoreCoder[1]->vad_flag == 0 || ( Etot_last[1] < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) ) ) -#else - if ( hCPE->hStereoClassif->lrtd_mode == 0 && ( ( sts[1]->hSpMusClas->tdm_lt_Etot < 0 && hCPE->hCoreCoder[1]->vad_flag == 0 ) /* very clean signal */ - || ( hCPE->hCoreCoder[1]->vad_flag == 0 || ( sts[1]->hNoiseEst->Etot_last < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) ) ) -#endif { sts[1]->coder_type = INACTIVE; @@ -353,11 +341,7 @@ void tdm_configure_enc( } hStereoTD->tdm_lp_reuse_flag = 1; } -#ifdef REMOVE_ETOT_PROPAGATION else if ( ( ( hCPE->hCoreCoder[1]->vad_flag == 0 ) || ( hCPE->hCoreCoder[0]->vad_flag == 0 && Etot_last[1] < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) && ( hCPE->hStereoClassif->lrtd_mode == 1 ) /* && NO_DTX */ ) /* boths channels are inactive but not DTX used*/ -#else - else if ( ( ( hCPE->hCoreCoder[1]->vad_flag == 0 ) || ( hCPE->hCoreCoder[0]->vad_flag == 0 && sts[1]->hNoiseEst->Etot_last < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) && ( hCPE->hStereoClassif->lrtd_mode == 1 ) /* && NO_DTX */ ) /* boths channels are inactive but not DTX used*/ -#endif { sts[1]->coder_type = INACTIVE; if ( tdm_ratio_idx > 1 && tdm_ratio_idx < 29 ) @@ -369,11 +353,7 @@ void tdm_configure_enc( hStereoTD->tdm_lp_reuse_flag = 1; } } -#ifdef REMOVE_ETOT_PROPAGATION else if ( !( sts[1]->sp_aud_decision0 ) && sts[1]->tc_cnt <= 0 && ( sts[1]->coder_type_raw == UNVOICED || ( hStereoTD->tdm_LRTD_flag == 1 && hStereoTD->tdm_lp_reuse_flag == 0 && ( hCPE->hCoreCoder[1]->vad_flag == 0 || ( Etot_last[1] < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) ) ) ) -#else - else if ( !( sts[1]->sp_aud_decision0 ) && sts[1]->tc_cnt <= 0 && ( sts[1]->coder_type_raw == UNVOICED || ( hStereoTD->tdm_LRTD_flag == 1 && hStereoTD->tdm_lp_reuse_flag == 0 && ( hCPE->hCoreCoder[1]->vad_flag == 0 || ( sts[1]->hNoiseEst->Etot_last < 30.0f && ( sts[0]->hSpMusClas->tdm_lt_Etot - sts[1]->hSpMusClas->tdm_lt_Etot ) > 26.0f ) ) ) ) ) -#endif { sts[1]->coder_type = UNVOICED; if ( hStereoTD->tdm_LRTD_flag == 1 ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 3b28f0ee64630aee9fcdac4c0e979518f13639e3..4cd70f61fc708a8ca3b55c79d918a6034bfb516c 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -952,11 +952,7 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef FIX_I59_LFE_TD_DELAY *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, 0 ) ); -#else - *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, RENDERER_DISABLE, 0 ) ); -#endif *delay *= hEncoderConfig->nchan_inp; diff --git a/lib_enc/long_enr.c b/lib_enc/long_enr.c index d2100b9ee6d57b6d57d9e62f0f3e3662cffeb72f..012a69ed413207784d69ae1cacd1cf8c5557d0fa 100644 --- a/lib_enc/long_enr.c +++ b/lib_enc/long_enr.c @@ -116,13 +116,11 @@ void long_enr( } } -#ifdef REMOVE_ETOT_PROPAGATION /* Update */ for ( n = 0; n < n_chan; n++ ) { hFrontVad[n]->hNoiseEst->Etot_last = Etot_LR[n]; } -#endif } else { @@ -160,10 +158,8 @@ void long_enr( } } -#ifdef REMOVE_ETOT_PROPAGATION /* Update */ st->hNoiseEst->Etot_last = Etot; -#endif } return; diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index d77a3e729cb2e5b3cd0b708222c8a33fe94aecac..c3247d62d7860f17bfbf18610b5dd6020151c687 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -59,10 +59,7 @@ void pre_proc( 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 */ -#ifndef REMOVE_ETOT_PROPAGATION - float *Etot, /* i : total energy */ -#endif - float *ener, /* o : residual energy from Levinson-Durbin */ + 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 @@ -86,21 +83,19 @@ void pre_proc( float old_wsp[L_WSP], *wsp; /* weighted input signal buffer */ float pitch_fr[NB_SUBFR]; /* fractional pitch values */ float voicing_fr[NB_SUBFR]; /* fractional pitch gains */ -#ifdef REMOVE_ETOT_PROPAGATION - float Etot; /* total energy */ -#endif - float lf_E[2 * VOIC_BINS]; /* per bin spectrum energy in lf */ - float tmpN[NB_BANDS]; /* Temporary noise update */ - float tmpE[NB_BANDS]; /* Temporary averaged energy of 2 sf. */ - float ee[2]; /* Spectral tilt */ - float corr_shift; /* correlation shift */ - float relE; /* frame relative energy */ - int16_t loc_harm; /* harmonicity flag */ - float cor_map_sum, sp_div, PS[128]; /* speech/music clasif. parameters */ - int16_t L_look; /* length of look-ahead */ - float snr_sum_he; /* HE SAD parameters */ - int16_t localVAD_HE_SAD; /* HE SAD parameters */ - int16_t vad_flag_dtx; /* HE-SAD flag with additional DTX HO */ + float Etot; /* total energy */ + float lf_E[2 * VOIC_BINS]; /* per bin spectrum energy in lf */ + float tmpN[NB_BANDS]; /* Temporary noise update */ + float tmpE[NB_BANDS]; /* Temporary averaged energy of 2 sf. */ + float ee[2]; /* Spectral tilt */ + float corr_shift; /* correlation shift */ + float relE; /* frame relative energy */ + int16_t loc_harm; /* harmonicity flag */ + float cor_map_sum, sp_div, PS[128]; /* speech/music clasif. parameters */ + int16_t L_look; /* length of look-ahead */ + float snr_sum_he; /* HE SAD parameters */ + int16_t localVAD_HE_SAD; /* HE SAD parameters */ + int16_t vad_flag_dtx; /* HE-SAD flag with additional DTX HO */ int16_t vad_flag_cldfb; float old_cor; float hp_E[2]; /* Energy in HF */ @@ -195,21 +190,13 @@ void pre_proc( * Spectral analysis *--------------------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION analy_sp( -1, NULL, st->input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, &Etot, st->min_band, st->max_band, band_energies, PS, fft_buff ); -#else - analy_sp( -1, NULL, st->input_Fs, inp_12k8, st->Bin_E, st->Bin_E_old, fr_bands, lf_E, Etot, st->min_band, st->max_band, band_energies, PS, fft_buff ); -#endif /*----------------------------------------------------------------* * SAD (1-signal, 0-noise) *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est_pre( Etot, st->ini_frame, st->hNoiseEst, 0, EVS_MONO, EVS_MONO ); -#else - noise_est_pre( *Etot, st->ini_frame, st->hNoiseEst, 0, EVS_MONO, EVS_MONO ); -#endif st->vad_flag = wb_vad( st, fr_bands, &noisy_speech_HO, &clean_speech_HO, &NB_speech_HO, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f ); @@ -226,8 +213,7 @@ void pre_proc( st->vad_flag = vad_flag_cldfb; } - vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, cldfb_addition, vad_hover_flag, NULL, NULL, - NULL ); + vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, cldfb_addition, vad_hover_flag, NULL, NULL, NULL ); /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector @@ -241,15 +227,9 @@ void pre_proc( * Correlation correction as a function of total noise level *----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est_down( fr_bands, st->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise, Etot, &st->hNoiseEst->Etot_last, &st->hNoiseEst->Etot_v_h2 ); relE = Etot - st->lp_speech; -#else - noise_est_down( fr_bands, st->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &st->hNoiseEst->totalNoise, *Etot, &st->hNoiseEst->Etot_last, &st->hNoiseEst->Etot_v_h2 ); - - relE = *Etot - st->lp_speech; -#endif if ( relE > 1.5f ) { @@ -375,11 +355,7 @@ void pre_proc( * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ -#ifdef REMOVE_ETOT_PROPAGATION noise_est( st, old_pitch1, tmpN, epsP, Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &non_staX, &loc_harm, lf_E, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp, &sp_floor, 0, NULL, NULL, st->ini_frame ); -#else - noise_est( st, old_pitch1, tmpN, epsP, *Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &non_staX, &loc_harm, lf_E, &st->hNoiseEst->harm_cor_cnt, st->hNoiseEst->Etot_l_lp, &sp_floor, 0, NULL, NULL, st->ini_frame ); -#endif /*------------------------------------------------------------------* * Update parameters used in the VAD and DTX @@ -394,11 +370,7 @@ void pre_proc( find_tilt( fr_bands, st->hNoiseEst->bckr, ee, st->pitch, st->voicing, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef REMOVE_ETOT_PROPAGATION st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, Etot, hp_E, &flag_spitch, last_core_orig, NULL ); -#else - st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, *Etot, hp_E, &flag_spitch, last_core_orig, NULL ); -#endif /*-----------------------------------------------------------------* * channel aware mode configuration * @@ -452,15 +424,9 @@ void pre_proc( st->GSC_IVAS_mode = 0; -#ifdef REMOVE_ETOT_PROPAGATION speech_music_classif( st, new_inp_12k8, inp_12k8, localVAD_HE_SAD, lsp_new, cor_map_sum, epsP, PS, Etot, old_cor, attack_flag, non_staX, relE, &high_lpn_flag, flag_spitch ); long_enr( st, Etot, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); -#else - speech_music_classif( st, new_inp_12k8, inp_12k8, localVAD_HE_SAD, lsp_new, cor_map_sum, epsP, PS, *Etot, old_cor, attack_flag, non_staX, relE, &high_lpn_flag, flag_spitch ); - - long_enr( st, *Etot, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); -#endif /*----------------------------------------------------------------* * Final VAD correction ( when HE-SAD is used instead of the normal VAD, @@ -612,11 +578,7 @@ void pre_proc( } if ( st->total_brate == ACELP_13k20 && st->bwidth != FB ) { -#ifdef REMOVE_ETOT_PROPAGATION MDCT_selector( st, sp_floor, Etot, cor_map_sum, enerBuffer ); -#else - MDCT_selector( st, sp_floor, *Etot, cor_map_sum, enerBuffer ); -#endif } } else @@ -912,11 +874,7 @@ void pre_proc( if ( st->total_brate == ACELP_16k40 && st->bwidth != FB ) { -#ifdef REMOVE_ETOT_PROPAGATION MDCT_selector( st, sp_floor, Etot, cor_map_sum, enerBuffer ); -#else - MDCT_selector( st, sp_floor, *Etot, cor_map_sum, enerBuffer ); -#endif } } else diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 8f8c054cff948b67ed1cbcd31876be6720a054bb..48585881d0cf279e245cd8695924c25436546d45 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -123,9 +123,7 @@ typedef struct float firState1; float firState2; -#ifdef LOW_RATE_TRANS int16_t ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ -#endif } SubblockEnergies; diff --git a/lib_enc/swb_bwe_enc.c b/lib_enc/swb_bwe_enc.c index 7aded2bc57f74dcb73562cfba3506b02e55ddee8..a7111c696d40b519b94b9ceb84948f0da5ece1c2 100644 --- a/lib_enc/swb_bwe_enc.c +++ b/lib_enc/swb_bwe_enc.c @@ -1795,12 +1795,10 @@ void hq_generic_hf_encoding( { Word16 tmp, frac, exp; Word32 L_tmp; -#ifdef FIX_150 #ifdef BASOP_NOGLOB Flag Overflow; Overflow = 0; -#endif #endif tmp = add( (int16_t) ( hq_generic_fenv[n_band] * 256 ), (int16_t) ( Mean_env[n_band] * 256 ) ); /*Q8 */ @@ -1812,12 +1810,8 @@ void hq_generic_hf_encoding( /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 13 ); -#ifdef FIX_150 #ifdef BASOP_NOGLOB tmp = shl_o( tmp, add( exp, 1 ), &Overflow ); /*Q1 */ -#else - tmp = shl( tmp, add( exp, 1 ) ); /*Q1 */ -#endif #else tmp = shl( tmp, add( exp, 1 ) ); /*Q1 */ #endif diff --git a/lib_enc/swb_pre_proc.c b/lib_enc/swb_pre_proc.c index 70c12b62322c49b7fc01728e51c1755e0b680b45..321672e11352da4f30b3cf6cb71cf037ece78ac0 100644 --- a/lib_enc/swb_pre_proc.c +++ b/lib_enc/swb_pre_proc.c @@ -677,20 +677,7 @@ void swb_pre_proc( { if ( ( st->bwidth == FB || st->core == ACELP_CORE ) && ( st->element_mode == EVS_MONO ) ) { -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( st->hBWE_TD, shb_speech ); -#else - set_f( hBWE_TD->old_speech_shb, 0, L_LOOK_16k + L_SUBFR16k ); - set_f( shb_speech, 0, L_FRAME16k ); /* shb_speech for FB/SWB BWE_HIGHRATE is not used at 64kbps */ - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_shb_env_tilt = 0.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif } else { diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 9602540dadd09d8343b94530c6dbe1d00b0e33d0..d92b33ad629a5bd5dfebf82c4ef99c1ee68f39cf 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -109,18 +109,7 @@ void InitSWBencBuffer( set_f( hBWE_TD->old_speech_wb, 0.0f, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); set_f( hBWE_TD->old_input_fhb, 0.0f, NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2 ); -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( hBWE_TD, NULL ); -#else - set_f( hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - hBWE_TD->old_mean_EnvSHBres = 0.0f; - hBWE_TD->prev_enr_EnvSHBres = 1.0f; - hBWE_TD->prev_shb_env_tilt = 0.0f; - hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - hBWE_TD->prev_mix_factor = 1.0f; - hBWE_TD->prev_Env_error = 0.0f; -#endif for ( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -161,7 +150,6 @@ void InitSWBencBuffer( } -#ifdef SIMPLIFY_TD_BWE_RESET /*-------------------------------------------------------------------* * InitSWBencBufferStates() * @@ -190,7 +178,6 @@ void InitSWBencBufferStates( return; } -#endif /*-------------------------------------------------------------------* diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index c5a6e4a0e979c4ffcf4364eb757b3b4ee0f35ea5..4ba76500bf2f0d09692fadddf932781b54c53031 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -53,13 +53,12 @@ #define MIN_BLOCK_ENERGY 107.37f -#ifdef LOW_RATE_TRANS #define THR_HIGH 8.5f #define THR_NORM_HIGH 8.0f #define THR_NORM_LOW 4.5f #define THR_LOW 4.25f #define THR_LOW_STEP 1.0f -#endif + /*---------------------------------------------------------------* * Local function prototypes @@ -225,10 +224,7 @@ void RunTransientDetection( float filteredInput[L_FRAME_MAX]; SubblockEnergies *pSubblockEnergies = &hTranDet->subblockEnergies; TransientDetector *pTransientDetector = &hTranDet->transientDetector; -#ifdef LOW_RATE_TRANS - float e0; - float e1; -#endif + float e0, e1; assert( ( input != NULL ) && ( hTranDet != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); @@ -244,7 +240,6 @@ void RunTransientDetection( /* Update the delay buffer. */ UpdateDelayBuffer( filteredInput, length, &hTranDet->delayBuffer ); -#ifdef LOW_RATE_TRANS /* compute ramp up flag */ pSubblockEnergies->ramp_up_flag = pSubblockEnergies->ramp_up_flag << 1; e0 = dotp( filteredInput + length / 2, filteredInput + length / 2, pSubblockEnergies->pDelayBuffer->nSubblockSize / 2 ) + 0.5f * MIN_BLOCK_ENERGY; @@ -253,12 +248,14 @@ void RunTransientDetection( { pSubblockEnergies->ramp_up_flag |= 0x0001; } -#endif return; } -static uint16_t isLongTermTransient( const float frameTFM, float *lastTFM ) + +static uint16_t isLongTermTransient( + const float frameTFM, + float *lastTFM ) { float currTFM; @@ -272,11 +269,13 @@ static uint16_t isLongTermTransient( const float frameTFM, float *lastTFM ) { currTFM = *lastTFM * 0.96875f + frameTFM * 0.03125f; } + *lastTFM = max( 0.015625f, currTFM ); return ( currTFM < 0.5625f ? 1 : 0 ); } + /*-------------------------------------------------------------------* * SetTCXModeInfo() * @@ -579,9 +578,7 @@ static void InitTransientDetector( pTransientDetector->attackRatioThreshold = attackRatioThreshold; pTransientDetector->bIsAttackPresent = FALSE; pTransientDetector->attackIndex = -1; -#ifdef LOW_RATE_TRANS pTransientDetector->pSubblockEnergies->ramp_up_flag = 0x0; -#endif return; } @@ -850,12 +847,12 @@ void set_transient_stereo( return; } -#ifdef LOW_RATE_TRANS /*-------------------------------------------------------------------* * transient_analysis() * * *-------------------------------------------------------------------*/ + /*! r: preliminary flag to force ACELP */ int16_t transient_analysis( TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ @@ -943,6 +940,6 @@ int16_t transient_analysis( } } } + return prel_force_td != 0; } -#endif diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index b425dbe00689fc0c0cda1617137d50e2c326e56a..4fe89cd967b594276df92264d3174e5c0ef17df5 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -188,23 +188,10 @@ void updt_IO_switch_enc( preemph( st->old_inp_16k, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k ) ); /* reset TD BWE buffers */ -#ifndef SIMPLIFY_TD_BWE_RESET - set_f( st->hBWE_TD->old_speech_shb, 0.0f, L_LOOK_16k + L_SUBFR16k ); -#endif set_f( st->hBWE_TD->old_speech_wb, 0.0f, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); set_f( st->hBWE_TD->old_bwe_exc, 0.0f, PIT16k_MAX * 2 ); set_f( st->hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET ); -#ifdef SIMPLIFY_TD_BWE_RESET InitSWBencBufferStates( st->hBWE_TD, NULL ); -#else - set_f( st->hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER ); - set_f( st->hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k ); - st->hBWE_TD->old_mean_EnvSHBres = 0.0f; - st->hBWE_TD->prev_enr_EnvSHBres = 1.0f; - st->hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - st->hBWE_TD->prev_mix_factor = 1.0f; - st->hBWE_TD->prev_Env_error = 0.0f; -#endif st->hBWE_TD->bwe_non_lin_prev_scale = 0.0; set_f( st->hBWE_TD->decim_state1, 0.0f, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 039fe8458bf6e1e292fb2c47a4a4451cc8ea311b..0a364a66e415b563d14fda83b03be341371647e8 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -542,35 +542,10 @@ void ivas_renderer_select( { *renderer_type = RENDERER_DISABLE; } -#ifdef SBA_DIRAC_RENDERER_TYPE_CLEANUP else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO ) { *renderer_type = RENDERER_SBA_LINEAR_DEC; } -#else - else if ( st_ivas->ivas_format == SBA_FORMAT ) - { - int16_t nchan_max; - - if ( ( output_config == AUDIO_CONFIG_MONO ) || ( output_config == AUDIO_CONFIG_STEREO ) ) - { - nchan_max = st_ivas->hDecoderConfig->nchan_out; - } - else if ( st_ivas->hOutSetup.ambisonics_order > 0 ) - { - nchan_max = ivas_sba_get_nchan( st_ivas->hOutSetup.ambisonics_order, st_ivas->sba_planar ); - } - else - { - nchan_max = ivas_sba_get_nchan( 3, st_ivas->sba_planar ); - } - - if ( st_ivas->nchan_transport >= nchan_max ) - { - *renderer_type = RENDERER_SBA_LINEAR_DEC; - } - } -#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c index 81ac69ecc1662fe5f834ff32d3bac8c865cc64f7..eb7b25dfa5c81dca25c0cf956adbefbbaaa349f3 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c @@ -83,60 +83,38 @@ static int32_t ivas_check_rounding( float binaural_latencys_s[3], int16_t use_ro *err_lfe = 0; *err_dec = 0; -#ifdef FIX_I59_CREND - for ( int ind1 = 0; ind1 < 3; ind1++ ) -#else - for ( int ind1 = 0; ind1 < sizeof( sampleRates ) / sizeof( float ); ind1++ ) -#endif + for ( int ind1 = 0; ind1 < 3; ind1++ ) { if ( verbose ) printf( "\nsample rate = %f", sampleRates[ind1] ); - -#ifdef FIX_I59_CREND + for ( int ind2 = 0; ind2 < 3; ind2++ ) -#else - for ( int ind2 = 0; ind2 < sizeof( binaural_latencys_s ) / sizeof( float ); ind2++ ) -#endif { wanted = (int32_t) roundf( binaural_latencys_s[ind2] * sampleRates[ind1] ); if ( verbose ) -#ifdef FIX_I59_CREND printf( "\nbinaural_latencys_s = %f wanted = %d", binaural_latencys_s[ind2], wanted ); -#else - printf( "\nbinaural_latencys_s = %f wanted = %ld", binaural_latencys_s[ind2], wanted ); -#endif if ( use_round_latency ) delay_ns[ind2] = (int32_t) roundf( binaural_latencys_s[ind2] * 1000000000.f ); else delay_ns[ind2] = (int32_t) ( binaural_latencys_s[ind2] * 1000000000.f ); if ( verbose ) -#ifdef FIX_I59_CREND printf( "\n delay_ns[%d] = %d \n", ind2, delay_ns[ind2] ); -#else - printf( "\n delay_ns[%d] = %ld \n", ind2, delay_ns[ind2] ); -#endif if ( use_round_for_lfe ) delay_lfe[ind1][ind2] = (int32_t) roundf( delay_ns[ind2] * sampleRates[ind1] / 1000000000.f ); else delay_lfe[ind1][ind2] = (int32_t) NS2SA( sampleRates[ind1], delay_ns[ind2] ); if ( verbose ) -#ifdef FIX_I59_CREND printf( "\ndelay_lfe[%d][%d] = %d\n", ind1, ind2, delay_lfe[ind1][ind2] ); -#else - printf( "\ndelay_lfe[%d][%d] = %ld\n", ind1, ind2, delay_lfe[ind1][ind2] ); -#endif + *err_lfe += abs( delay_lfe[ind1][ind2] - wanted ); delay_dec[ind1][ind2] = NS2SA( sampleRates[ind1], (float) delay_ns[ind2] + 0.5f ); - // delay_dec[ind1][ind2] = NS2SA( sampleRates[ind1], (float) delay_ns[ind2] ); + /* delay_dec[ind1][ind2] = NS2SA( sampleRates[ind1], (float) delay_ns[ind2] );*/ if ( verbose ) -#ifdef FIX_I59_CREND printf( "\ndelay_dec[%d][%d] = %d \n", ind1, ind2, delay_dec[ind1][ind2] ); -#else - printf( "\ndelay_dec[%d][%d] = %ld \n", ind1, ind2, delay_dec[ind1][ind2] ); -#endif + *err_dec += abs( delay_dec[ind1][ind2] - wanted ); } } @@ -1176,85 +1154,38 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl float binaural_latencys_td_s[3] = { BINAURAL_TD_LATENCY_S, BINAURAL_TD_LATENCY_S + 1.f / 48000.f, BINAURAL_TD_LATENCY_S + 2.f / 48000.f }; int32_t err = 0, err_lfe = 0, err_dec = 0; + binaural_latencys_fastconv_s[0] = FASTCONV_HRIR_latency_s; binaural_latencys_fastconv_s[1] = FASTCONV_BRIR_latency_s; binaural_latencys_fastconv_s[2] = FASTCONV_BRIR_latency_s; + err = ivas_check_rounding( binaural_latencys_fastconv_s, 0, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_crend_s, 0, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_td_s, 0, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\n\nerr = %d err_lfe = %d err_dec = %d\n\n", err, err_lfe, err_dec ); -#else - printf( "\n\nerr = %ld err_lfe = %ld err_dec = %ld\n\n", err, err_lfe, err_dec ); -#endif err = ivas_check_rounding( binaural_latencys_fastconv_s, 0, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_crend_s, 0, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_td_s, 0, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\n\nerr = %d err_lfe = %d err_dec = %d\n\n", err, err_lfe, err_dec ); -#else - printf( "\n\nerr = %ld err_lfe = %ld err_dec = %ld\n\n", err, err_lfe, err_dec ); -#endif err = ivas_check_rounding( binaural_latencys_fastconv_s, 1, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_crend_s, 1, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_td_s, 1, 0, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\n\nerr = %d err_lfe = %d err_dec = %d\n\n", err, err_lfe, err_dec ); -#else - printf( "\n\nerr = %ld err_lfe = %ld err_dec = %ld\n\n", err, err_lfe, err_dec ); -#endif err = ivas_check_rounding( binaural_latencys_fastconv_s, 1, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_crend_s, 1, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\nerr_lfe = %d err_dec = %d", err_lfe, err_dec ); -#else - printf( "\nerr_lfe = %ld err_dec = %ld", err_lfe, err_dec ); -#endif err += ivas_check_rounding( binaural_latencys_td_s, 1, 1, &err_lfe, &err_dec, 0 ); -#ifdef FIX_I59_CREND printf( "\n\nerr = %d err_lfe = %d err_dec = %d\n\n", err, err_lfe, err_dec ); -#else - printf( "\n\nerr = %ld err_lfe = %ld err_dec = %ld\n\n", err, err_lfe, err_dec ); -#endif - ivas_render_config_open( &st_ivas.hRenderConfig ); ivas_render_config_init_from_rom( &st_ivas.hRenderConfig, 0 ); @@ -1292,28 +1223,16 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl { st_ivas.renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL_ROOM; -#ifdef FIX_FIX_I59 pIo_params->latency_ns = ( IVAS_FB_DEC_DELAY_NS + (int32_t) ( FASTCONV_BRIR_latency_s * 1000000000.f ) ); -#else - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_BRIR_latency_s; -#endif } else { st_ivas.renderer_type = RENDERER_BINAURAL_FASTCONV; st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; if ( st_ivas.ivas_format == MC_FORMAT ) -#ifdef FIX_FIX_I59 pIo_params->latency_ns = ( IVAS_FB_DEC_DELAY_NS + (int32_t) ( FASTCONV_HRIR_latency_s * 1000000000.f ) ); -#else - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_HRIR_latency_s; -#endif else -#ifdef FIX_FIX_I59 pIo_params->latency_ns = ( IVAS_FB_DEC_DELAY_NS + (int32_t) ( FASTCONV_HOA3_latency_s * 1000000000.f ) ); -#else - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate + FASTCONV_HOA3_latency_s; -#endif } } else if ( pIo_params->test == TD_BIN_TEST ) @@ -1334,11 +1253,8 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl st_ivas.renderer_type = RENDERER_BINAURAL_OBJECTS_TD; st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; } -#ifdef FIX_FIX_I59 + pIo_params->latency_ns = (int32_t) ( BINAURAL_TD_LATENCY_S * 1000000000.f ); -#else - pIo_params->latency_s = BINAURAL_TD_LATENCY_S; -#endif } else if ( pIo_params->test == PARAM_BIN_TEST ) { @@ -1352,11 +1268,7 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl st_ivas.renderer_type = RENDERER_BINAURAL_PARAMETRIC; st_ivas.hOutSetup.output_config = st_ivas.hDecoderConfig->output_config = AUDIO_CONFIG_BINAURAL; } -#ifdef FIX_FIX_I59 pIo_params->latency_ns = IVAS_FB_DEC_DELAY_NS; -#else - pIo_params->latency_s = ( (float) frame_len ) / (float) dec_io_params.out_sample_rate; -#endif } else if ( pIo_params->test == CREND_BIN_TEST ) { @@ -1496,19 +1408,13 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl if ( pIo_params->test == CREND_BIN_TEST ) { -#ifdef FIX_FIX_I59 pIo_params->latency_ns = (int32_t) ( st_ivas.hHrtf->latency_s * 1000000000.f ); -#else - pIo_params->latency_s = st_ivas.hHrtf->latency_s; -#endif } + if ( st_ivas.ivas_format == MC_FORMAT ) { -#ifdef FIX_FIX_I59 ivas_create_lfe_dec( &st_ivas.hLFE, st_ivas.hDecoderConfig->output_Fs, pIo_params->latency_ns ); -#else - ivas_create_lfe_dec( &st_ivas.hLFE, st_ivas.hDecoderConfig->output_Fs, pIo_params->latency_s ); -#endif + if ( st_ivas.hLFE->lfe_addl_delay > 0 ) { if ( st_ivas.hLFE->lfe_delay_buf != NULL ) @@ -1516,15 +1422,11 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl free( st_ivas.hLFE->lfe_delay_buf ); st_ivas.hLFE->lfe_delay_buf = NULL; } -#ifdef FIX_FIX_I59 + if ( pIo_params->latency_ns > 0 ) { st_ivas.hLFE->lfe_addl_delay = (int16_t) roundf( (float) pIo_params->latency_ns * (float) dec_io_params.out_sample_rate / 1000000000.f ); -#else - if ( pIo_params->latency_s > 0 ) - { - st_ivas.hLFE->lfe_addl_delay = (int16_t) roundf( pIo_params->latency_s * dec_io_params.out_sample_rate ); -#endif + if ( st_ivas.hLFE->lfe_addl_delay > 0 ) { if ( ( st_ivas.hLFE->lfe_delay_buf = (float *) malloc( st_ivas.hLFE->lfe_addl_delay * sizeof( float ) ) ) == NULL ) @@ -1540,6 +1442,7 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl st_ivas.hLFE->lfe_addl_delay = 0; } } + /* delay input channel of latency of lp filter*/ if ( pIo_params->lfe_lp_enable ) { @@ -1555,11 +1458,7 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl } ivas_lfe_lpf_select_filt_coeff( pIo_params->sample_rate, IVAS_FILTER_ORDER_4, &filt_coeff ); ivas_filters_init( &st_ivas.hLFE->filter_state, filt_coeff, IVAS_FILTER_ORDER_4 ); -#ifdef FIX_FIX_I59 pIo_params->latency_ns = pIo_params->latency_ns + (int32_t) ( ivas_lfe_lpf_delay[1] * 1000000000.f ); -#else - pIo_params->latency_s = pIo_params->latency_s + ivas_lfe_lpf_delay[1]; -#endif } else { @@ -1589,13 +1488,10 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl int32_t skip_samples = 0; int32_t skipped_samples = 0; int16_t write_flag = 0; + if ( ( pIo_params->out_fmt == BIN_2 ) && ( pIo_params->no_delay_cmp == 0 ) ) { -#ifdef FIX_FIX_I59 skip_samples = (int32_t) roundf( (float) pIo_params->latency_ns * pIo_params->sample_rate / 1000000000.f ); -#else - skip_samples = NS2SA( pIo_params->sample_rate, (int32_t) ( pIo_params->latency_s * 1000000000.f ) ); -#endif } fprintf( stdout, "IVAS Common Renderer skip samples = %d\n", (int) skip_samples );