diff --git a/apps/encoder.c b/apps/encoder.c index 005794d939b2fd41279963342142bdaa2c366d31..0be04d7c8e4b8b476e67a8d3a4e667f66b541db3 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1273,20 +1273,14 @@ static bool parseCmdlIVAS_enc( arg->inputFormat = IVAS_ENC_INPUT_ISM; i++; -#ifdef IMPROVE_CMDLINE_ROBUSTNESS if ( i < argc - 4 ) -#else - if ( i < argc - 5 ) -#endif { -#ifdef IMPROVE_CMDLINE_ROBUSTNESS if ( !is_digits_only( argv[i] ) ) { fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" ); usage_enc(); return false; } -#endif if ( sscanf( argv[i], "%d", &tmp ) > 0 ) { @@ -1299,14 +1293,12 @@ static bool parseCmdlIVAS_enc( usage_enc(); return false; } -#ifdef IMPROVE_CMDLINE_ROBUSTNESS else if ( tmp > IVAS_MAX_NUM_OBJECTS ) { fprintf( stderr, "Error: Too high number of ISM channels specified!\n\n" ); usage_enc(); return false; } -#endif else { arg->inputFormatConfig.ism.numObjects = (int16_t) tmp; @@ -1338,11 +1330,7 @@ static bool parseCmdlIVAS_enc( } else { -#ifdef IMPROVE_CMDLINE_ROBUSTNESS fprintf( stderr, "Error: not enough metadata arguments specified!\n\n" ); -#else - fprintf( stderr, "Error: not enough arguments\n\n" ); -#endif usage_enc(); return false; } @@ -1354,20 +1342,9 @@ static bool parseCmdlIVAS_enc( arg->inputFormat = IVAS_ENC_INPUT_SBA; /* SBA configuration */ - if ( i < argc - 4 -#ifdef IMPROVE_CMDLINE_ROBUSTNESS - && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 -#endif - ) + if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) { -#ifndef IMPROVE_CMDLINE_ROBUSTNESS - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { -#endif - i++; -#ifndef IMPROVE_CMDLINE_ROBUSTNESS - } -#endif + i++; } else { @@ -1404,14 +1381,12 @@ static bool parseCmdlIVAS_enc( if ( i < argc - 4 ) { -#ifdef IMPROVE_CMDLINE_ROBUSTNESS if ( !is_digits_only( argv[i] ) ) { fprintf( stderr, "Error: Number of MASA channels must be an integer number!\n\n" ); usage_enc(); return false; } -#endif if ( sscanf( argv[i], "%d", &tmp ) > 0 ) { @@ -1427,11 +1402,7 @@ static bool parseCmdlIVAS_enc( arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_2CH; break; default: -#ifdef IMPROVE_CMDLINE_ROBUSTNESS fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" ); -#else - fprintf( stderr, "Error: MASA channels must for the moment be 1 or 2.\n\n" ); -#endif usage_enc(); return false; } diff --git a/apps/renderer.c b/apps/renderer.c index 47159892db354a6bf4dce349ffde54d251d86dd5..506830002c5b3a3a1b6b41814bb2dbf92b85008a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2432,9 +2432,7 @@ static void convertOutputBuffer( int16_t *intBuffer ) { int16_t chnl, smpl, i; -#ifdef FIX_REND_ROUNDING float temp; -#endif i = 0; @@ -2442,7 +2440,6 @@ static void convertOutputBuffer( { for ( chnl = 0; chnl < numChannels; ++chnl ) { -#ifdef FIX_REND_ROUNDING temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; temp = (float) floor( temp + 0.5f ); if ( temp > MAX16B_FLT ) @@ -2454,9 +2451,6 @@ static void convertOutputBuffer( temp = MIN16B_FLT; } intBuffer[i] = (int16_t) temp; -#else - intBuffer[i] = (int16_t) roundf( floatBuffer[chnl * numSamplesPerChannel + smpl] ); -#endif ++i; } diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index a542a4f23030233a101fde27f93a210185e304b6..34c68d254044d09a087ea600b70a378130770157 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1950,24 +1950,12 @@ ivas_error preview_indices( /* read number of objects from the bitstream */ st_ivas->nchan_transport = 1; -#ifdef FIX_ISM_DECODER_PRINTOUT k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); while ( bit_stream[k] == 1 && st_ivas->nchan_transport < MAX_NUM_OBJECTS ) { st_ivas->nchan_transport++; k--; } -#else - if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA ) - { - k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); - while ( bit_stream[k] == 1 && st_ivas->hDecoderConfig->nchan_out < MAX_NUM_OBJECTS ) - { - st_ivas->nchan_transport++; - k--; - } - } -#endif st_ivas->transport_config = AUDIO_CONFIG_EXTERNAL + st_ivas->nchan_transport; st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_transport, total_brate ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 95ce27095755e08fde807f7bd44c9d9e214be85a..9b778c9f6cdfbc6113afac820c62f6ee984db168 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -465,10 +465,8 @@ enum #define STEREO_DFT_OFFSET 1 #define STEREO_DFT_NBDIV 2 -#ifdef FIX_ITD_CNG #define STEREO_DFT_ITD_CNG_XFADE 100 #define STEREO_DFT_ITD_CNG_XFADE_RESET 2 -#endif #define STEREO_DFT_DELAY_DEC_BWE_NS ( STEREO_DFT_OFFSET * STEREO_DFT_HOP_NS - ACELP_LOOK_NS ) /* 1.25ms/2.5ms: max delay for core decoder*/ @@ -535,9 +533,7 @@ typedef enum #define STEREO_DFT_SID_GIPD_NBITS 2 #define STEREO_DFT_FD_FILT 0.9f -#ifdef FIX_ITD_CNG #define STEREO_DFT_CNG_ITD_CNT 8 -#endif /*Residual prediction*/ #define STEREO_DFT_PAST_MAX 4 @@ -1391,7 +1387,6 @@ typedef enum #define SFX_SPAT_BIN_MAX_FILTER_LENGTH 256 #define SPAT_BIN_MAX_INPUT_CHANNELS 1 /* Max number of input channels per source/object. Mono for now, but stereo objects may be considered. */ -#ifdef FIX_ITD #define MAX_ITD 50 #define SFX_SPAT_BIN_SINC_M 5 #define SFX_SPAT_BIN_NUM_SUBSAMPLES 64 @@ -1401,9 +1396,6 @@ typedef enum #define MAX_ANGULAR_STEP_INV ( 1.0f / MAX_ANGULAR_STEP ) #define MAX_INTERPOLATION_STEPS 12 #define BINAURAL_TD_LATENCY_S 0.0f /* ITD fix removes TD renderer delay -- should be cleaned out */ -#else -#define BINAURAL_TD_LATENCY_S 0.00675f /* Binaural TD renderer latency in second == 324 samples in between 333 and 315 */ -#endif /* ----- Enums - TD Renderer ----- */ diff --git a/lib_com/ivas_ism_config.c b/lib_com/ivas_ism_config.c index 75ef0a2ae7a789310abe5f3ec0fab03e0659ccb4..bf782e2a395498c4cba9cbb9f9ef46e20d64107f 100644 --- a/lib_com/ivas_ism_config.c +++ b/lib_com/ivas_ism_config.c @@ -199,11 +199,7 @@ ivas_error ivas_ism_config( diff = 0; for ( ch = 0; ch < n_ISms; ch++ ) { -#ifdef FIX_ISM_INACTIVE_BITS int16_t limit; -#else - int32_t limit; -#endif limit = MIN_BRATE_SWB_BWE / FRMS_PER_SECOND; if ( element_brate[ch] < MIN_BRATE_SWB_STEREO ) /* replicate function set_bw() -> check the coded audio band-width */ @@ -223,20 +219,12 @@ ivas_error ivas_ism_config( else if ( ism_imp[ch] == ISM_LOW_IMP ) { tmp = (int16_t) ( BETA_ISM_LOW_IMP * bits_CoreCoder[ch] ); -#ifdef FIX_ISM_INACTIVE_BITS tmp = max( limit, tmp ); -#else - tmp = (int16_t) max( limit, bits_CoreCoder[ch] - tmp ); -#endif } else if ( ism_imp[ch] == ISM_MEDIUM_IMP ) { tmp = (int16_t) ( BETA_ISM_MEDIUM_IMP * bits_CoreCoder[ch] ); -#ifdef FIX_ISM_INACTIVE_BITS tmp = max( limit, tmp ); -#else - tmp = (int16_t) max( limit, bits_CoreCoder[ch] - tmp ); -#endif } else /* ism_imp[ch] == ISM_HIGH_IMP */ { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6cb365bfadc5c07b16acafb44ec64c62be5baa1b..120042c891c9c0f93d8d555bd2324566fccd5cc1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -934,10 +934,8 @@ float stereo_dft_enc_synthesize( void stereo_dft_enc_process( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ -#ifdef FIX_ITD_CNG const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ const int16_t vad_hover_flag[], /* i: VAD hangover flags */ -#endif const int16_t input_frame /* i : input frame length */ ); @@ -986,11 +984,7 @@ void stereo_dft_dequantize_itd( void stereo_dft_enc_sid_calc_coh( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo handle */ -#ifdef FIX_ITD_CNG float prev_cohBand[2*(STEREO_DFT_BAND_MAX/2)], /* i/o: Previous coherence */ -#else - float coh_crossfade[STEREO_DFT_BAND_MAX / 2], /* i/o: Coherence crossfade memory */ -#endif int16_t *td_active, /* i/o: TD stereo mode indicator */ int16_t *first_SID, /* i/o: First SID indicator */ float *cohBand /* i/o: Coherence per band */ @@ -1143,11 +1137,9 @@ void stereo_dft_dec_read_BS( void stereo_dft_dec_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ -#ifdef FIX_ITD_CNG , const int16_t active_frame_counter, /* i : Active frame counter */ const int32_t element_brate /* i : Element bitrate */ -#endif ); void stereo_dft_generate_res_pred( @@ -1303,10 +1295,8 @@ void stereo_dft_enc_compute_itd( float *DFT_R, const int16_t k_offset, const int16_t input_frame, -#ifdef FIX_ITD_CNG const int16_t vad_flag_dtx[], const int16_t vad_hover_flag[], -#endif float *bin_nrgL, float *bin_nrgR ); @@ -1862,10 +1852,8 @@ void deindex_lvq_SHB( void stereo_td_itd_mdct_stereo( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ -#ifdef FIX_ITD_CNG const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ const int16_t vad_hover_flag[], /* i: VAD hangover flags */ -#endif const int16_t input_frame /* i : frame length */ ); @@ -2425,10 +2413,8 @@ void stereo_cng_upd_counters( const int16_t nbands, /* i : Number of bands in active */ const float sidSideGain[], /* i : SID side gains */ const int16_t burst_ho_count /* i : Hang-over count */ -#ifdef FIX_ITD_CNG , int16_t *coh_fade_counter /* i : Coherence fade counter */ -#endif ); void stereo_cng_init_dec( @@ -2660,10 +2646,8 @@ void ivas_mct_core_enc( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ const int16_t lfe_bits /* i : bits spent for LFE */ -#ifdef FIX_I1_113 , const int16_t sba_order /* i : Ambisonic (SBA) order */ -#endif ); void ivas_mdct_quant_coder( @@ -3919,7 +3903,6 @@ void ivas_spar_set_bitrate_config( const int16_t num_bands /* i : number of bands */ ); -#ifdef FIX_I1_113 void ivas_spar_bitrate_dist( int32_t core_brates_act[], /* o : bitrates per core-coder */ const int16_t nAvailBits, /* i : number of available bits */ @@ -3927,7 +3910,6 @@ void ivas_spar_bitrate_dist( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t bwidth /* i : audio bandwidth */ ); -#endif void ivas_mdct( const float *pIn, float *pOut, const int16_t length ); void ivas_dct_windowing( const int16_t fade_len, const int16_t full_len, const int16_t dct_len, const int16_t zero_pad_len, const float *pWindow_coeffs, const int16_t frame_len, float *pOut_buf, float *pBuffer_prev, float *pTemp_lfe ); @@ -4664,7 +4646,6 @@ void ivas_ism_render( const int16_t output_frame /* i : output frame length per channel */ ); -#ifdef FIX_REND_ISM_STEREO_PANNING void ivas_ism_get_stereo_gains( const float azimuth, /* i : object azimuth */ const float elevation, /* i : object elevation */ @@ -4672,7 +4653,6 @@ void ivas_ism_get_stereo_gains( float *right_gain /* o : right channel gain */ ); -#endif void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ @@ -5025,13 +5005,9 @@ void GetFilterFromAngle( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ const float Elev, /* i : Elevation, degrees */ float Azim, /* i : Azimuth, degrees */ -#ifdef FIX_ITD float *LeftFilter, /* o : Left HR filter */ float *RightFilter, /* o : Right HR filter */ int16_t *itd /* o : ITD value */ -#else - SFX_SpatBin_Params_t *SfxSpatBinParams_p /* i/o: Currently used HR filter */ -#endif ); void HRTF_model_precalc( @@ -5056,22 +5032,11 @@ void TDREND_HRFILT_SetFiltSet( ivas_error TDREND_REND_RenderSourceHRFilt( TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ -#ifdef FIX_ITD const float *hrf_left_delta, /* i: Left filter interpolation delta */ const float *hrf_right_delta, /* i: Right filter interpolation delta */ const int16_t intp_count, /* i: Interpolation count */ -#else -#ifdef TDREND_HRTF_TABLE_METHODS - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ -#endif -#endif float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ -#ifdef FIX_ITD const int16_t subframe_length /* i : Subframe length in use */ -#else - const int16_t subframe_length, /* i : Subframe length in use */ - const int32_t output_Fs /* i : Output sample rate */ -#endif ); /* ----- Object renderer - sources ----- */ @@ -5104,7 +5069,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ -#ifdef FIX_ITD float *hrf_left_prev, /* o: Left filter */ float *hrf_right_prev, /* o: Right filter */ float *hrf_left_delta, /* o: Left filter interpolation delta */ @@ -5115,9 +5079,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( float *Gain, /* o: Gain value */ TDREND_SRC_t *Src_p, const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ -#else - const int32_t output_Fs /* i : Output sample rate */ -#endif ); ivas_error TDREND_SRC_Alloc( @@ -5130,12 +5091,7 @@ void TDREND_SRC_Dealloc( void TDREND_SRC_Init( TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ -#ifdef FIX_ITD const TDREND_PosType_t PosType /* i : Position type specifier */ -#else - const TDREND_PosType_t PosType, /* i : Position type specifier */ - const int32_t output_Fs /* i : Output sampling rate */ -#endif ); /* ----- Object renderer - vec ----- */ @@ -5180,12 +5136,7 @@ int16_t TDREND_SPATIAL_EvalOrthonormOrient( ivas_error TDREND_MIX_AddSrc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ int16_t *SrcInd, /* o : Source index */ -#ifdef FIX_ITD const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ -#else - const TDREND_PosType_t PosType, /* i : Position type (absolute/relative) */ - const int32_t output_Fs /* i : Output sampling rate */ -#endif ); ivas_error TDREND_MIX_SetDistAttenModel( @@ -5216,31 +5167,7 @@ ivas_error TDREND_MIX_Init( ); /* ----- Object renderer - sfx ----- */ -#ifndef FIX_ITD -ivas_error TDREND_SFX_SpatBin_Initialize( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters handle */ - const int32_t output_Fs /* i : Output sampling rate */ -); - -void TDREND_SFX_SpatBin_SetParams( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct to be updated */ - const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -); -void TDREND_SFX_SpatBin_Execute_Main( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters handle */ - const float *InBuffer_p, /* i : Input buffer */ - const int16_t subframe_length, /* i : subframe length */ - float *LeftOutBuffer_p, /* o : Rendered left channel */ - float *RightOutBuffer_p, /* o : Rendered right channel */ - int16_t *NoOfUsedInputSamples_p, /* o : Number of input samples actually used */ - int16_t *NoOfDeliveredOutputSamples_p, /* o : Number of output samples actually rendered */ - const int32_t output_Fs /* i : Output sample rate */ -); -#endif - -#ifdef FIX_ITD void TDREND_Apply_ITD( float *input, /* i: Input SCE subframe to be time adjusted */ float *out_left, /* o: Output left channels with ITD applied */ @@ -5260,7 +5187,6 @@ void TDREND_firfilt( const int16_t subframe_length, /* i : Length of signal */ const int16_t filterlength /* i : Filter length */ ); -#endif /*----------------------------------------------------------------------------------* * Filter-bank (FB) Mixer *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 31db5f1bbc7e1275f14996a2a6959954712d8c39..c71dd97088e81b1578abe8dbe3dcd8f3bcd3746c 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -2149,7 +2149,6 @@ void ivas_spar_set_bitrate_config( } -#ifdef FIX_I1_113 /*-----------------------------------------------------------------------------------------* * Function ivas_spar_bitrate_dist() * @@ -2239,4 +2238,3 @@ void ivas_spar_bitrate_dist( return; } -#endif diff --git a/lib_com/options.h b/lib_com/options.h index e46be24d689dedd163775c3fd0a07757e1988bef..69cdf582f84ee55685ed0bae23d29e1b832ba20a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,25 +144,11 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_I1_113 /* under review : MCT bit distribution optimization for SBA high bitrates*/ -#define FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS /* Issue 124: do not allocate unused plc struct in IVAS modes which is only used in EVS mono */ #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 FIX_ITD /* Contribution 16: TD renderer ITD improvement and code cleanup */ #define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ -#define FIX_ISM_DECODER_PRINTOUT /* Issue 229: fix ISM decoder printout */ #define FIX_150 /* Issue 150: Crash in EVS mono, HQ_HARMONIC mode, related to BASOP_NOGLOB */ -#define FIX_REND_ISM_XFADE /* Issue 193: Crossfade inconsistencies in ISM between decoder and external renderer */ -#define FIX_REND_ISM_POS_ROUNDING /* Issue 193: (Temporary solution until fix for #215) Align rounding of ISM position data in external renderer */ -#define FIX_REND_ISM_STEREO_PANNING /* Issue 193: Use tangent panning for ISM to stereo in external renderer */ -#define FIX_REND_ROUNDING /* Issue 195: Align float to int16 conversion in renderer with decoder */ -#define FIX_REND_MONO_DMX /* Issue 195: Fix mono downmix coefficients in decoder and renderer */ -#define FIX_REND_ROT_MC_BIN /* Issue 195: Fix wrong EFAP handle passed to renderer, resulting in no rotation for BINAURAL_ROOM output */ -#define FIX_ITD_CNG /* Eri Contribution 11: Fix for CNG ITD */ #define FIX_VBR_COMPLEXITY /* Issue 234: fix extremely high complexity numbers for IVAS EVS mode */ -#define FIX_ISM_INACTIVE_BITS /* Issue 230: fix bitbudget distribution in inactive frames in ISM format */ -#define IMPROVE_CMDLINE_ROBUSTNESS /* Issue 233: Improve robustness of command-line parameters */ -#define FIX_MDCT_AND_MC_MONO_ISSUES /* Issue 242: Fix some issues with TCX-LTP and delay alignement for mono output */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 973f15ef5afca6255bdec249949ab9267e766ba3..760571cb46537c628bcdd80e9c6b9906ac31f227 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3833,10 +3833,8 @@ int16_t dtx_hangover_addition( int16_t *vad_hover_flag, /* o : VAD hangover flag */ VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -#ifdef FIX_ITD_CNG , int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ -#endif ); int16_t wb_vad( diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 3316648d8e567495ff3fe97c7b1391d722277c25..fb6af86815875f7f90323dc3b452e680055d22a2 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -152,11 +152,7 @@ void decoder_tcx_post( if ( bfi && !st->use_partial_copy ) { /* run lpc gain compensation not for waveform adjustment */ -#ifdef FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS if ( !st->enablePlcWaveadjust || ( st->hPlcInfo != NULL && st->hPlcInfo->concealment_method == TCX_TONAL ) ) -#else - if ( !st->enablePlcWaveadjust || st->hPlcInfo->concealment_method == TCX_TONAL ) -#endif { float gainHelperFB = hTcxDec->gainHelper; float stepCompensateFB = hTcxDec->stepCompensate * st->L_frame / hTcxDec->L_frameTCX; @@ -334,12 +330,10 @@ void IMDCT( /* number of zero for ALDO windows*/ nz = NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) * L_frame / L_frameTCX; -#ifdef FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS if ( st->element_mode != EVS_MONO && frame_cnt == 0 && !bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && !hTcxCfg->last_aldo ) { v_multc( old_syn_overl, hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, old_syn_overl, overlap ); } -#endif if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 || st->mct_chan_mode == MCT_CHAN_MODE_LFE ) && ( st->tcxonly ) ) { diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 4b74ccebb92a9bc0282d91c145f1da6bbd897144..f7968ba5fc5ecd1941f739b033a5ba8c37337a93 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -661,11 +661,7 @@ ivas_error init_decoder( * Mode 2 initialization *-----------------------------------------------------------------*/ -#ifdef FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS if ( st->element_mode == EVS_MONO ) -#else - if ( idchan == 0 && st->element_mode != IVAS_CPE_MDCT ) -#endif { if ( ( st->hPlcInfo = (T_PLCInfo_HANDLE) count_malloc( sizeof( T_PLCInfo ) ) ) == NULL ) { @@ -689,9 +685,6 @@ ivas_error init_decoder( st->hTECDec = NULL; } -#ifndef FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS // the initialziation is done in open_decoder_LPD() - st->enablePlcWaveadjust = 0; -#endif /* Init Core Decoder */ open_decoder_LPD( st, st->total_brate, st->last_total_brate, st->bwidth, 0, st->element_mode, 1 ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index e4f587a16e6491568033497d28596b02f8c1b481..86c8bdd6058853bf2fa6a627af47b508027c6e6c 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -181,34 +181,11 @@ ivas_error ivas_core_dec( st->flagGuidedAcelp = 0; } -#ifdef FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL ) { v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_outLB, st->L_frame ); } -#else - /* PLC: [TCX: Fade-out-recovery] - overlapping part needs to be attenuated for first good frame */ - if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) ) - { - float gain; - - gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain - : 0.0f; - - if ( ( st->element_mode == IVAS_CPE_MDCT && hMCT == NULL ) || ( st->hPlcInfo != NULL ) ) - { - v_multc( st->hHQ_core->old_out, gain, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); - v_multc( st->hHQ_core->old_outLB, gain, st->hHQ_core->old_outLB, st->L_frame ); - - if ( !st->hTcxCfg->last_aldo && st->hTcxDec != NULL ) - { - v_multc( st->hTcxDec->syn_OverlFB, gain, st->hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB ); - v_multc( st->hTcxDec->syn_Overl, gain, st->hTcxDec->syn_Overl, st->hTcxCfg->tcx_mdct_window_length ); - } - } - } -#endif set_f( voice_factors[n], 0.f, NB_SUBFR16k ); set_f( hb_synth[n], 0.0f, L_FRAME48k ); diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 41b8c339a26ff533d2c941908d6b009017744497..d415407c7b62f0815249b0f5a84c3939c1073f72 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -444,12 +444,6 @@ ivas_error ivas_cpe_dec( } } } -#ifndef FIX_MDCT_AND_MC_MONO_ISSUES - else if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && ( is_DTXrate( ivas_total_brate ) == 0 || ( is_DTXrate( ivas_total_brate ) == 1 && is_DTXrate( st_ivas->hDecoderConfig->last_ivas_total_brate ) == 0 ) ) ) - { - applyDmxMdctStereo( hCPE, output, output_frame ); - } -#endif /*----------------------------------------------------------------* * Update parameters for stereo CNA @@ -463,12 +457,10 @@ ivas_error ivas_cpe_dec( synchro_synthesis( ivas_total_brate, hCPE, output, output_frame, 0 ); -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && ( is_DTXrate( ivas_total_brate ) == 0 || ( is_DTXrate( ivas_total_brate ) == 1 && is_DTXrate( st_ivas->hDecoderConfig->last_ivas_total_brate ) == 0 ) ) ) { applyDmxMdctStereo( hCPE, output, output_frame ); } -#endif #ifndef DEBUG_STEREO_DFT_OUTRESPRED /*----------------------------------------------------------------* @@ -590,11 +582,7 @@ ivas_error create_cpe_dec( hCPE->lt_es_em = 0.0f; /* Note: nchan_out is considered to be related to the structure. This is nchan_out for CPE and for MASA_format is always 2. */ -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MC_FORMAT ) -#else - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ) -#endif { hCPE->nchan_out = CPE_CHANNELS; } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index ca71e4035dcda40bd824a4eff1d02ef5335505b0..2e0874bc6485a4deed557e1450597ac2ba202c13 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -82,11 +82,7 @@ ivas_error ivas_ism_renderer_open( interpolator_length = (uint16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); for ( i = 0; i < interpolator_length; i++ ) { -#ifdef FIX_REND_ISM_XFADE st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); -#else - st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length ); -#endif } return error; @@ -144,43 +140,10 @@ void ivas_ism_render( { if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO ) { -#ifdef FIX_REND_ISM_STEREO_PANNING ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &gains[i][0], &gains[i][1] ); -#else - float aziRad, eleRad; - float y, mappedX, aziRadMapped, A, A2, A3; - const float LsAngleRad = 30.0f * PI_OVER_180; - - /* Convert azi and ele to an azi value of the cone of confusion */ - aziRad = st_ivas->hIsmMetaData[i]->azimuth * PI_OVER_180; - eleRad = st_ivas->hIsmMetaData[i]->elevation * PI_OVER_180; - y = ( sinf( aziRad ) * cosf( eleRad ) ); - mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); - aziRadMapped = atan2f( y, mappedX ); - - /* Determine the amplitude panning gains */ - if ( aziRadMapped >= LsAngleRad ) - { /* Left side */ - gains[i][0] = 1.0f; - gains[i][1] = 0.0f; - } - else if ( aziRadMapped <= -LsAngleRad ) - { /* Right side */ - gains[i][0] = 0.0f; - gains[i][1] = 1.0f; - } - else /* Tangent panning law */ - { - A = tanf( aziRadMapped ) / tanf( LsAngleRad ); - A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); - A3 = 1.0f / ( A2 * A2 + 1.0f ); - gains[i][0] = sqrtf( A3 ); - gains[i][1] = sqrtf( 1.0f - A3 ); - } -#endif } else { @@ -191,14 +154,9 @@ void ivas_ism_render( } else { -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); -#else - azimuth = (int16_t) ( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); - elevation = (int16_t) ( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); -#endif if ( st_ivas->hIntSetup.is_planar_setup ) { @@ -240,7 +198,6 @@ void ivas_ism_render( return; } -#ifdef FIX_REND_ISM_STEREO_PANNING void ivas_ism_get_stereo_gains( const float azimuth, /* i : object azimuth */ const float elevation, /* i : object elevation */ @@ -279,4 +236,3 @@ void ivas_ism_get_stereo_gains( *right_gain = sqrtf( 1.0f - A3 ); } } -#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index de79f876d6a34d458fac0d2a0914006c6df6732c..9baa77d4b9d0ed5d9afca730192fd789c83735be 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -145,7 +145,6 @@ typedef struct stereo_dft_dec_data_struct float itd[STEREO_DFT_DEC_DFT_NB]; -#ifdef FIX_ITD_CNG float itd_xfade_step; float itd_xfade_target; int16_t itd_xfade_counter; @@ -155,7 +154,6 @@ typedef struct stereo_dft_dec_data_struct float ipd_xfade_step; int16_t ipd_xfade_counter; float ipd_xfade_prev; -#endif /*residual prediction*/ int16_t res_pred_mode[STEREO_DFT_DEC_DFT_NB]; /* residual prediction mode: 0(off), 1(stereo filling only), 2(enhanced stereo filling) */ @@ -1323,71 +1321,6 @@ typedef struct ivas_binaural_head_track_struct * TD ISm Object Renderer structure *----------------------------------------------------------------------------------*/ -#ifndef FIX_ITD -// VE2AT: move to ivas_rom_rend.h ? -typedef struct -{ - SFX_OpMode_t OpMode; /* Operating mode. This effect can only be TRANSIENT or OFF. */ - int16_t TurningOffEffect; /* Flag showing if the effect is being turned off. */ - int16_t TurningOnEffect; /* Flag showing if the effect is being turned on. */ - int16_t InitializeParams; /* Flag showing if parameters should be initialized the next SetParam call. */ - int16_t FirstUpdate; /* Flag showing if it SetParams has only been called once (TRUE) or more (FALSE). */ - - int32_t TotNoOfOutputSamples; /* The total number of output samples produced since last SetParam call. */ - int32_t MaxTargetTime; /* The maximum allowed target time. Also used for turning the effect on or off. */ - int32_t MaxBlockLength; /* The maximum block length */ - - int16_t TargetTime; /* Time left until the parameters should have reached the new parameters values. */ - float ItdIncrForResampling; /* Resampling factor for adjusting the ITD. */ - float *LeftOldBuffer; /* Buffer with old samples for the Resampling function */ - int16_t NoOfLeftOldBufferSamples; /* Number of samples in LeftOldBuffer */ - float Left_Tf; /* The left fractional delay. */ - float *RightOldBuffer; /* Buffer with old samples for the Resampling function */ - int16_t NoOfRightOldBufferSamples; /* Number of samples in RightOldBuffer */ - float ResampledBufferLeft[SFX_SPAT_BIN_MAX_NO_OF_OUTPUT_SAMPLES + SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; /* Buffers getting the resampled output and having the old samples used for HR-filtering */ - float ResampledBufferRight[SFX_SPAT_BIN_MAX_NO_OF_OUTPUT_SAMPLES + SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; - int16_t TransientTime; /* Transient time when turning off the effect */ - - int16_t FilterLength; /* HR-filter length */ - - /* HR-filters */ - float *LeftFilter_p; /* Pointer to left filter */ - float *LeftFilterIncr_p; /* Left filter adjustment step */ - float *RightFilter_p; /* Pointer to right filter */ - float *RightFilterIncr_p; /* Right filter adjustment step */ - -#ifdef TDREND_HRTF_TABLE_METHODS - int16_t HrFilterInterpOn; /* Indicates whether to interpolate filter from previous frame */ - float LeftFilterStored[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; /* Stored previous filter for interpolation */ - float RightFilterStored[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; /* Stored previous filter for interpolation */ -#endif - -} SFX_SpatBin_t; - -/* Container struct for setting new parameters in SFX_SpatBin */ -typedef struct -{ - int16_t TurnOn; - int16_t Reset; - /* Rendering parameters */ - float Itd; - int16_t FilterLength; - float *LeftFilter_p; - float *RightFilter_p; - float LeftVolume; - float RightVolume; - -} SFX_SpatBin_Params_t; - -typedef struct TDREND_LIST_Item_s -{ - int16_t Ind; /* Index number of item */ - void *Data_p; /* Pointer to the item data struct */ - struct TDREND_LIST_Item_s *Prev_p; /* Pointer to the prev item */ - struct TDREND_LIST_Item_s *Next_p; /* Pointer to the next item */ - -} TDREND_LIST_Item_t; -#endif typedef struct { @@ -1580,10 +1513,6 @@ typedef struct TDREND_SRC_REND_s float SrcGainMax_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DirGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; float DistGain_p[SPAT_BIN_MAX_INPUT_CHANNELS]; -#ifndef FIX_ITD - /* HR filtering parameters */ - SFX_SpatBin_t *SfxSpatBin_p; -#endif } TDREND_SRC_REND_t; @@ -1606,7 +1535,6 @@ typedef struct float *InputFrame_p; /* Input frame pointer */ TDREND_SRC_SPATIAL_t *SrcSpatial_p; TDREND_SRC_REND_t *SrcRend_p; -#ifdef FIX_ITD int16_t itd; int16_t previtd; int16_t filterlength; @@ -1618,7 +1546,6 @@ typedef struct float mem_hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; float mem_hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; float Gain; -#endif } TDREND_SRC_t; /* Top level TD binaural renderer handle */ diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 32d3510f8019e24f9f5e36a264fb77fb1c35496a..fbe01d15714bc938686ae70056fa8ff2fcfe1e0d 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -480,7 +480,6 @@ void stereo_dft_dec_reset( set_zero( hStereoDft->smooth_fac[0], SBA_DIRAC_STEREO_NUM_BANDS ); set_zero( hStereoDft->smooth_fac[1], SBA_DIRAC_STEREO_NUM_BANDS ); -#ifdef FIX_ITD_CNG hStereoDft->itd_xfade_target = 0.0f; hStereoDft->itd_xfade_step = 0.0f; hStereoDft->itd_xfade_counter = 0; @@ -490,7 +489,6 @@ void stereo_dft_dec_reset( hStereoDft->ipd_xfade_step = 0.0f; hStereoDft->ipd_xfade_counter = 0; hStereoDft->ipd_xfade_prev = 0.0f; -#endif return; } @@ -1174,11 +1172,7 @@ void stereo_dft_dec( } else { -#ifdef FIX_ITD_CNG stereo_dft_dec_smooth_parameters( hStereoDft, hStereoCng->prev_sid_nodata, hStereoCng->active_frame_counter, st0->element_brate ); -#else - stereo_dft_dec_smooth_parameters( hStereoDft, hStereoCng->prev_sid_nodata ); -#endif } } @@ -1762,9 +1756,7 @@ void stereo_dft_dec_read_BS( * Initialization *-----------------------------------------------------------------*/ -#ifdef FIX_ITD_CNG k_offset = STEREO_DFT_OFFSET; -#endif if ( ivas_total_brate == IVAS_SID_5k2 ) { @@ -1790,10 +1782,8 @@ void stereo_dft_dec_read_BS( hStereoDft->frame_sid = 0; *nb_bits = 0; *total_brate = 0; -#ifdef FIX_ITD_CNG hStereoDft->itd[k = hStereoDft->prm_res[k_offset] - 1 + k_offset] = hStereoDft->itd_xfade_target; hStereoDft->gipd[hStereoDft->prm_res[k_offset] - 1 + k_offset] = hStereoDft->ipd_xfade_target; -#endif return; } @@ -1824,9 +1814,6 @@ void stereo_dft_dec_read_BS( /*init*/ max_bits = *nb_bits; *nb_bits = 0; -#ifndef FIX_ITD_CNG - k_offset = STEREO_DFT_OFFSET; -#endif N_div = STEREO_DFT_NBDIV; if ( ivas_total_brate > IVAS_SID_5k2 ) @@ -2774,11 +2761,9 @@ void stereo_dft_generate_res_pred( void stereo_dft_dec_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ -#ifdef FIX_ITD_CNG , const int16_t active_frame_counter, /* i : Active frame counter */ const int32_t element_brate /* i : Element bitrate */ -#endif ) { int16_t k_offset, k, k2, b, N_div; @@ -2800,7 +2785,6 @@ void stereo_dft_dec_smooth_parameters( *( hStereoDft->side_gain + ( ( k + k_offset ) - 1 ) * STEREO_DFT_BAND_MAX + b ) = *( hStereoDft->side_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b ); } -#ifdef FIX_ITD_CNG if ( hStereoDft->frame_sid_nodata ) { /* set new xfade target if new itd received */ @@ -2841,14 +2825,12 @@ void stereo_dft_dec_smooth_parameters( hStereoDft->ipd_xfade_counter = 0; } } -#endif for ( k2 = 1; k2 < hStereoDft->prm_res[k + k_offset]; k2++ ) { hStereoDft->gipd[( k + k_offset ) - k2] = hStereoDft->gipd[k + k_offset]; } -#ifdef FIX_ITD_CNG if ( hStereoDft->frame_sid_nodata ) { /* set new xfade target if new itd received */ @@ -2878,7 +2860,6 @@ void stereo_dft_dec_smooth_parameters( hStereoDft->last_active_element_brate = element_brate; } -#endif for ( k2 = 1; k2 < hStereoDft->prm_res[k + k_offset]; k2++ ) { hStereoDft->itd[( k + k_offset ) - k2] = hStereoDft->itd[k + k_offset]; @@ -2887,7 +2868,6 @@ void stereo_dft_dec_smooth_parameters( return; } -#ifdef FIX_ITD_CNG /* Active frame, "reset" everything "reset" everything if long enough active encoding */ if ( active_frame_counter > STEREO_DFT_ITD_CNG_XFADE_RESET ) { @@ -2898,11 +2878,8 @@ void stereo_dft_dec_smooth_parameters( hStereoDft->ipd_xfade_target = hStereoDft->gipd[STEREO_DFT_NBDIV - 1]; hStereoDft->ipd_xfade_prev = hStereoDft->gipd[STEREO_DFT_NBDIV - 1]; } -#endif -#ifdef FIX_ITD_CNG hStereoDft->last_active_element_brate = element_brate; -#endif for ( k = hStereoDft->prm_res[k_offset] - 1; k < N_div; k += hStereoDft->prm_res[k + k_offset] ) { diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index f58b6ddca44bdeaed3cba81f7aeeb43bb907fa84..648893cbf1c4c81dabc432af5c0d68d5ce11b70b 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -130,11 +130,7 @@ void stereo_dft_unify_dmx( ( st0->core == TCX_20_CORE && ( ( st0->hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) || ( st0->hTcxCfg->tcx_last_overlap_mode == HALF_OVERLAP ) ) ) || ( st0->core == TCX_10_CORE ); /* Smoothing for the current frame */ -#ifdef FIX_ITD_CNG stereo_dft_dec_smooth_parameters( hStereoDft, prev_sid_nodata, st0->hFdCngDec->hFdCngCom->active_frame_counter, st0->element_brate ); -#else - stereo_dft_dec_smooth_parameters( hStereoDft, prev_sid_nodata ); -#endif for ( k = 0; k < N_div; k++ ) { diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 480466ec18b53ade4862704638fb11026bc5cb93..fc53699ec5e4d355d8959c9c944d1a412d46a928 100755 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -655,11 +655,7 @@ void applyDmxMdctStereo( fade = 0.f; dmx_len = crossfade_len; } -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES else if ( hCPE->last_element_mode == IVAS_CPE_DFT && hCPE->last_element_brate <= IVAS_32k ) -#else - else if ( hCPE->last_element_mode == IVAS_CPE_DFT && hCPE->last_element_brate <= IVAS_24k4 ) -#endif { crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS ); step /= crossfade_len; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 8db6ae3ac3e904ea05b58eb09158cb521e07efda..da8c75844ae495c0fdb230cf3a74ba3a57f355f5 100755 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -716,7 +716,6 @@ ivas_error stereo_memory_dec( if ( hCPE->last_element_mode == IVAS_CPE_DFT ) { -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES if ( hCPE->nchan_out == 1 ) { cpy_tcx_ltp_data( hCPE->hCoreCoder[0]->hTcxLtpDec, hCPE->hCoreCoder[1]->hTcxLtpDec, output_Fs ); @@ -725,9 +724,6 @@ ivas_error stereo_memory_dec( { cpy_tcx_ltp_data( &tcxLtpTmp, hCPE->hCoreCoder[1]->hTcxLtpDec, output_Fs ); } -#else - cpy_tcx_ltp_data( &tcxLtpTmp, hCPE->hCoreCoder[1]->hTcxLtpDec, output_Fs ); -#endif } if ( hCPE->last_element_mode == IVAS_CPE_TD ) @@ -986,9 +982,7 @@ void synchro_synthesis( int16_t dft_mono_brate_switch; int16_t delay_diff; float tmpF; -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES int16_t nChannels; -#endif sts = hCPE->hCoreCoder; output_Fs = sts[0]->output_Fs; @@ -1058,13 +1052,11 @@ void synchro_synthesis( } } -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES if ( hCPE->nchan_out == 1 && hCPE->last_element_mode == IVAS_CPE_MDCT ) { v_add( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, sts[0]->prev_synth_buffer, delay_comp_DFT ); v_multc( sts[0]->prev_synth_buffer, INV_SQRT_2, sts[0]->prev_synth_buffer, delay_comp_DFT ); } -#endif if ( use_cldfb_for_last_dft ) { @@ -1161,7 +1153,6 @@ void synchro_synthesis( } } -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES /* if previous frame had only one channel copy buffers to other channel */ if ( hCPE->nchan_out == 1 && hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode == IVAS_CPE_DFT ) { @@ -1169,7 +1160,6 @@ void synchro_synthesis( mvr2r( tmp_out[0], tmp_out[1], delay_cldfb ); mvr2r( p_output_mem[0], p_output_mem[1], delay_diff ); } -#endif /*----------------------------------------------------------------* * update DFT synthesis overlap memory @output_Fs; needed for TD->DFT stereo switching @@ -1254,12 +1244,8 @@ void synchro_synthesis( } } -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out; for ( n = 0; n < nChannels; n++ ) -#else - for ( n = 0; n < hCPE->nchan_out; n++ ) -#endif { if ( hCPE->element_mode == IVAS_CPE_MDCT ) { @@ -1292,11 +1278,7 @@ void synchro_synthesis( } /* cross-fading between DFT OLA memory and TD output */ -#ifdef FIX_MDCT_AND_MC_MONO_ISSUES for ( n = 0; n < nChannels; n++ ) -#else - for ( n = 0; n < hCPE->nchan_out; n++ ) -#endif { if ( hCPE->element_mode == IVAS_CPE_MDCT ) { diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index c73e5a89497070d4515a4f12dc70288fc96bb842..3b342220e3ac0dcdf541c6f3b8298a1af724697f 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -292,12 +292,7 @@ void amr_wb_enc( } /* apply DTX hangover for CNG analysis */ - vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, &vad_hover_flag, NULL, NULL -#ifdef FIX_ITD_CNG - , - NULL -#endif - ); + vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, &vad_hover_flag, NULL, NULL, NULL ); /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 828fdf17a1db4fe7da194c0c38be216bbb7b5c14..1fdb26805c24dc4a4d1a2216f90c89985489c007 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -453,12 +453,7 @@ ivas_error pre_proc_front_ivas( if ( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { - *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL -#ifdef FIX_ITD_CNG - , - NULL -#endif - ); + *vad_flag_dtx = dtx_hangover_addition( st, st->vad_flag, st->lp_speech - st->lp_noise, 0, vad_hover_flag, NULL, NULL, NULL ); } else { @@ -556,13 +551,11 @@ ivas_error pre_proc_front_ivas( dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8 ); -#ifdef FIX_ITD_CNG if ( hCPE != NULL && hCPE->hStereoDft != NULL && st->core_brate == SID_2k40 ) { /* Add another period of expected xcorr updates */ hCPE->hStereoDft->expectedNumUpdates += st->hDtxEnc->max_SID; } -#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 470d597b15ab425dcde5cf681e11ce7a7341dc68..b422bf8c0c57a55829095898815054534267ee78 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -349,11 +349,7 @@ ivas_error ivas_cpe_enc( stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth ); /* DFT stereo processing */ -#ifdef FIX_ITD_CNG stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); -#else - stereo_dft_enc_process( hCPE, input_frame ); -#endif } else if ( hCPE->element_mode == IVAS_CPE_TD ) { @@ -373,11 +369,7 @@ ivas_error ivas_cpe_enc( } else if ( hCPE->element_mode == IVAS_CPE_MDCT ) { -#ifdef FIX_ITD_CNG stereo_td_itd_mdct_stereo( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); -#else - stereo_td_itd_mdct_stereo( hCPE, input_frame ); -#endif } /*----------------------------------------------------------------* @@ -524,11 +516,7 @@ ivas_error ivas_cpe_enc( if ( hEncoderConfig->Opt_DTX_ON ) { -#ifdef FIX_ITD_CNG stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL ); -#else - stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt ); -#endif } } @@ -581,11 +569,7 @@ ivas_error ivas_cpe_enc( } else { -#ifdef FIX_ITD_CNG stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, hCPE->hStereoDft->nbands, hCPE->hStereoDft->sidSideGain, sts[0]->hTdCngEnc->burst_ho_cnt, &hCPE->hStereoDft->coh_fade_counter ); -#else - stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, hCPE->hStereoDft->nbands, hCPE->hStereoDft->sidSideGain, sts[0]->hTdCngEnc->burst_ho_cnt ); -#endif } } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index cc2a4b08d8de3756e85aa511212a63a1bfdeb851..be54c3fc7e83c1509e665b89db88c3919f61f9d3 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -110,9 +110,7 @@ ivas_error front_vad( { localVAD_HE_SAD[n] = 0; vad_hover_flag[n] = 0; -#ifdef FIX_ITD_CNG vad_flag_dtx[n] = 1; -#endif } /*------------------------------------------------------------------* @@ -195,12 +193,7 @@ ivas_error front_vad( } /* DTX hangover addition */ - vad_flag_dtx[n] = dtx_hangover_addition( sts[n], hFrontVad->hVAD->vad_flag, hFrontVad->lp_speech - hFrontVad->lp_noise, 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst -#ifdef FIX_ITD_CNG - , - &hFrontVads[n]->rem_dtx_ho -#endif - ); + vad_flag_dtx[n] = dtx_hangover_addition( sts[n], hFrontVad->hVAD->vad_flag, hFrontVad->lp_speech - hFrontVad->lp_noise, 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); if ( n_chan == 1 ) { diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index c4fcd2dee7d3af543431257faa591a6c0421bf75..57c6a37a7b1e9fae3165ff92f25ac359953a9145 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -105,7 +105,6 @@ static void rate_ism_importance( { ctype = hSCE[ch]->hCoreCoder[0]->coder_type_raw; -#ifdef FIX_ISM_INACTIVE_BITS if ( hSCE[ch]->hCoreCoder[0]->tcxonly ) { if ( hSCE[ch]->hCoreCoder[0]->localVAD == 0 ) @@ -117,7 +116,6 @@ static void rate_ism_importance( ctype = GENERIC; } } -#endif if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 4a94dee5d9bb7c91e6bcee39cc8e7c48a5b8f248..379a1c8358619330b8a92382a8472d500ea7bfc6 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -115,27 +115,17 @@ static void FindChannelRatio( static void AdjustChannelRatios( int16_t chBitRatios[MCT_MAX_CHANNELS], /* o : bit-disctribution channel ratios */ const int16_t nChannels /* i/o: number of channels */ -#ifdef FIX_I1_113 , const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t nAvailBits, /* i : number of available bits */ const int16_t sba_order /* i : Ambisonic (SBA) order */ -#endif ) { int16_t force_ch_bit_ratios[IVAS_SPAR_MAX_DMX_CHS]; -#ifdef FIX_I1_113 int32_t temp_brs[IVAS_SPAR_MAX_DMX_CHS]; -#endif float cur_ratio, tar_ratio, sum_ratio, sum_tar_ratio; int16_t ratio_diff, i; -#ifndef FIX_I1_113 - force_ch_bit_ratios[0] = 9; - force_ch_bit_ratios[1] = 7; - force_ch_bit_ratios[2] = 5; - force_ch_bit_ratios[3] = 3; -#else ivas_spar_bitrate_dist( temp_brs, nAvailBits, ivas_total_brate, sba_order, (int16_t) FB ); sum_ratio = 0.0f; @@ -148,7 +138,6 @@ static void AdjustChannelRatios( cur_ratio = temp_brs[i] / sum_ratio; force_ch_bit_ratios[i] = min( BITRATE_MCT_RATIO_RANGE - 1, max( 1, (uint16_t) ( BITRATE_MCT_RATIO_RANGE * cur_ratio + 0.5f ) ) ); } -#endif /* adjust the ratios further based on received chBitRatios[]*/ ratio_diff = 0; @@ -208,10 +197,8 @@ void ivas_mct_core_enc( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ const int16_t lfe_bits /* i : bits spent for LFE */ -#ifdef FIX_I1_113 , const int16_t sba_order /* i : Ambisonic (SBA) order */ -#endif ) { int16_t ch, ch_core, nSubframes, L_subframeTCX; @@ -477,13 +464,6 @@ void ivas_mct_core_enc( FindChannelRatio( hMCT, sts, chBitRatios, nChannels ); -#ifndef FIX_I1_113 - if ( hMCT->hbr_mct ) - { - assert( ivas_total_brate >= IVAS_256k ); - AdjustChannelRatios( chBitRatios, nChannels ); - } -#endif nAvailBits = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - NBITS_BWIDTH - hMCT->nBitsMCT - lfe_bits ); @@ -523,13 +503,11 @@ void ivas_mct_core_enc( dbgwrite( &nAvailBits, sizeof( int16_t ), 1, 1, "./res/availBits" ); #endif -#ifdef FIX_I1_113 if ( hMCT->hbr_mct ) { assert( ivas_total_brate >= IVAS_256k ); AdjustChannelRatios( chBitRatios, nChannels, ivas_total_brate, nAvailBits, sba_order ); } -#endif for ( ch = 0; ch < nChannels; ch++ ) { diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index c9f3698b27b720b8696de642d916436970193445..0e9eaa1a5a7d5ff84ccd2c7364c21f6e5c7a81c8 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -167,12 +167,7 @@ ivas_error ivas_mct_enc( /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, - ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0 -#ifdef FIX_I1_113 - , - st_ivas->hEncoderConfig->sba_order -#endif - ); + ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); /* Spectrum quantization and coding */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 81b89a5edc1cba59249ba4bf945e29548e3e5b95..465fa3b17a0fcb322511871915fd948200c5ccd5 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -193,10 +193,8 @@ typedef struct stereo_dft_enc_data_struct float Spd_R_smooth[STEREO_DFT_N_32k_ENC / 2]; float sid_gipd; int16_t coh_fade_counter; -#ifdef FIX_ITD_CNG float prev_sid_gipd; int16_t prev_sid_no_ipd_flag; -#endif /*IPD*/ float gipd[STEREO_DFT_ENC_DFT_NB]; @@ -235,11 +233,9 @@ typedef struct stereo_dft_enc_data_struct #endif -#ifdef FIX_ITD_CNG int16_t currentNumUpdates; int16_t expectedNumUpdates; /* Expected number of frames before use of ITD estimate */ int16_t resetFrames; -#endif /* energy buffers for ICBWE */ float nrg_L[2]; @@ -567,9 +563,7 @@ typedef struct front_vad_enc VAD_HANDLE hVAD; /* VAD handle */ float *delay_buf; int16_t delay_samples; -#ifdef FIX_ITD_CNG int16_t rem_dtx_ho; /* Remaining hangover frames */ -#endif } FRONT_VAD_ENC, *FRONT_VAD_ENC_HANDLE; @@ -816,21 +810,17 @@ typedef struct ivas_mcmasa_enc_data_structure typedef struct stereo_cng_enc { - int16_t prev_sg_average_counter; /* Counter for sidegain averaging */ - int16_t sg_active_cnt; /* Counter for sidegain averaging */ - int16_t sg_average_counter; /* Counter for sidegain averaging */ - float sg_average[STEREO_DFT_ERB4_BANDS]; /* Sidegain average */ - float prev_sg_average[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average */ - float mem_cohBand[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ -#ifdef FIX_ITD_CNG + int16_t prev_sg_average_counter; /* Counter for sidegain averaging */ + int16_t sg_active_cnt; /* Counter for sidegain averaging */ + int16_t sg_average_counter; /* Counter for sidegain averaging */ + float sg_average[STEREO_DFT_ERB4_BANDS]; /* Sidegain average */ + float prev_sg_average[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average */ + float mem_cohBand[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ float prev_cohBand[2 * ( STEREO_DFT_BAND_MAX / 2 )]; /* Previous coherence */ int16_t cng_counter; /* Counter for cng period length */ -#else - float coh_crossfade[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ -#endif - int16_t td_active; /* TD-stereo indication */ - int16_t first_SID_after_TD; /* Set if first SID frame after TD stereo */ - int16_t first_SID; /* Set if first SID frame since codec start */ + int16_t td_active; /* TD-stereo indication */ + int16_t first_SID_after_TD; /* Set if first SID frame after TD stereo */ + int16_t first_SID; /* Set if first SID frame since codec start */ } STEREO_CNG_ENC, *STEREO_CNG_ENC_HANDLE; diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index 68be66c2a107e18d20827281aa7844ea4b6f0d37..ca15794cc05903b5e45eea6b3d501afb4cabe9a3 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -50,10 +50,8 @@ * Local constants *-------------------------------------------------------------------*/ -#define COH_FADE_MAX 4 -#ifdef FIX_ITD_CNG +#define COH_FADE_MAX 4 #define COH_FADE_UPDATES 2 -#endif /*--------------------------------------------------------------- @@ -63,23 +61,17 @@ * ---------------------------------------------------------------*/ void stereo_dft_enc_sid_calc_coh( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo handle */ -#ifdef FIX_ITD_CNG + STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo handle */ float prev_cohBand[2 * ( STEREO_DFT_BAND_MAX / 2 )], /* i/o: Previous coherence */ -#else - float coh_crossfade[STEREO_DFT_BAND_MAX / 2], /* i/o: Coherence crossfade memory */ -#endif - int16_t *td_active, /* i/o: TD stereo mode indicator */ - int16_t *first_SID, /* i/o: First SID indicator */ - float *cohBand /* i/o: Coherence per band */ + int16_t *td_active, /* i/o: TD stereo mode indicator */ + int16_t *first_SID, /* i/o: First SID indicator */ + float *cohBand /* i/o: Coherence per band */ ) { int16_t b, k; float coh_weight; float coh_weight_sum; -#ifdef FIX_ITD_CNG float xspec_scale; -#endif /* Cluster the coherence into bands using a weighted average. The coherence is weighted with the energy spectrum of the mixdown signal. */ for ( b = 0; b < hStereoDft->nbands; b++ ) @@ -87,7 +79,6 @@ void stereo_dft_enc_sid_calc_coh( cohBand[b] = 0; coh_weight_sum = 0; -#ifdef FIX_ITD_CNG if ( hStereoDft->coh_fade_counter == 0 && !*first_SID ) { for ( k = hStereoDft->band_limits[b]; k < hStereoDft->band_limits[b + 1]; k++ ) @@ -112,67 +103,35 @@ void stereo_dft_enc_sid_calc_coh( cohBand[b] = cohBand[b] / coh_weight_sum; } } -#else - for ( k = hStereoDft->band_limits[b]; k < hStereoDft->band_limits[b + 1]; k++ ) - { - coh_weight = hStereoDft->DFT[0][2 * k] * hStereoDft->DFT[0][2 * k] + hStereoDft->DFT[0][2 * k + 1] * hStereoDft->DFT[0][2 * k + 1]; - cohBand[b] += coh_weight * ( hStereoDft->xspec_smooth[2 * k] * hStereoDft->xspec_smooth[2 * k] + hStereoDft->xspec_smooth[2 * k + 1] * hStereoDft->xspec_smooth[2 * k + 1] ) / ( hStereoDft->Spd_L_smooth[k] * hStereoDft->Spd_R_smooth[k] + EPSILON ); - coh_weight_sum += coh_weight; - } - if ( coh_weight_sum > 0 ) - { - cohBand[b] = cohBand[b] / coh_weight_sum; - } -#endif } if ( *first_SID ) { -#ifdef FIX_ITD_CNG mvr2r( cohBand, prev_cohBand, hStereoDft->nbands ); mvr2r( prev_cohBand, &( prev_cohBand[STEREO_DFT_BAND_MAX / 2] ), hStereoDft->nbands ); -#else - mvr2r( cohBand, coh_crossfade, hStereoDft->nbands ); -#endif *first_SID = 0; } -#ifdef FIX_ITD_CNG if ( hStereoDft->coh_fade_counter < COH_FADE_MAX && ( *td_active || hStereoDft->currentNumUpdates < COH_FADE_UPDATES ) ) -#else - if ( hStereoDft->coh_fade_counter < COH_FADE_MAX && *td_active ) -#endif { for ( b = 0; b < hStereoDft->nbands; b++ ) { -#ifdef FIX_ITD_CNG cohBand[b] = ( cohBand[b] * hStereoDft->coh_fade_counter + prev_cohBand[b] * ( COH_FADE_MAX - hStereoDft->coh_fade_counter ) ) / COH_FADE_MAX; -#else - cohBand[b] = ( cohBand[b] * hStereoDft->coh_fade_counter + coh_crossfade[b] * ( COH_FADE_MAX - hStereoDft->coh_fade_counter ) ) / COH_FADE_MAX; -#endif } hStereoDft->coh_fade_counter++; -#ifdef FIX_ITD_CNG if ( hStereoDft->coh_fade_counter > 0 ) { mvr2r( &prev_cohBand[STEREO_DFT_BAND_MAX / 2], prev_cohBand, hStereoDft->nbands ); } mvr2r( cohBand, &prev_cohBand[STEREO_DFT_BAND_MAX / 2], hStereoDft->nbands ); -#else - mvr2r( cohBand, coh_crossfade, hStereoDft->nbands ); -#endif } else { -#ifdef FIX_ITD_CNG if ( hStereoDft->coh_fade_counter > 0 ) { mvr2r( &prev_cohBand[STEREO_DFT_BAND_MAX / 2], prev_cohBand, hStereoDft->nbands ); } mvr2r( cohBand, &prev_cohBand[STEREO_DFT_BAND_MAX / 2], hStereoDft->nbands ); -#else - mvr2r( cohBand, coh_crossfade, hStereoDft->nbands ); -#endif hStereoDft->coh_fade_counter = COH_FADE_MAX; *td_active = 0; } @@ -412,10 +371,8 @@ void stereo_dft_cng_side_gain( } hStereoCng->sg_average_counter++; -#ifdef FIX_ITD_CNG hStereoCng->cng_counter++; hStereoCng->cng_counter = min( hStereoCng->cng_counter, STEREO_DFT_SG_ACT_CNT_MAX ); -#endif if ( core_brate == SID_2k40 ) { @@ -514,16 +471,10 @@ void stereo_enc_cng_init( hStereoCng->sg_active_cnt = 0; hStereoCng->first_SID = 1; set_f( hStereoCng->mem_cohBand, 0.5f, STEREO_DFT_BAND_MAX / 2 ); -#ifdef FIX_ITD_CNG set_zero( hStereoCng->prev_cohBand, 2 * ( STEREO_DFT_BAND_MAX / 2 ) ); -#else - set_zero( hStereoCng->coh_crossfade, STEREO_DFT_BAND_MAX / 2 ); -#endif hStereoCng->td_active = 0; hStereoCng->first_SID_after_TD = 1; -#ifdef FIX_ITD_CNG hStereoCng->cng_counter = 0; -#endif return; } @@ -541,10 +492,8 @@ void stereo_cng_upd_counters( const int16_t nbands, /* i : Number of bands in active */ const float sidSideGain[], /* i : SID side gains */ const int16_t burst_ho_count /* i : Hang-over count */ -#ifdef FIX_ITD_CNG , int16_t *coh_fade_counter /* i : Coherence fade counter */ -#endif ) { int16_t b; @@ -568,7 +517,6 @@ void stereo_cng_upd_counters( hStereoCng->sg_active_cnt++; hStereoCng->sg_active_cnt = min( hStereoCng->sg_active_cnt, STEREO_DFT_SG_ACT_CNT_MAX ); -#ifdef FIX_ITD_CNG if ( hStereoCng->sg_active_cnt > STEREO_DFT_CNG_ITD_CNT ) { hStereoCng->cng_counter = 0; @@ -578,6 +526,5 @@ void stereo_cng_upd_counters( { *coh_fade_counter = 0; } -#endif return; } diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index e54b98a942499f062d44dec67e4d5cf9057ad06a..c97e6715cc95c3a8ac43881c254789aec882893a 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -62,9 +62,7 @@ static FILE *pF = NULL; #define STEREO_DFT_NRG_PAST_MAX_BAND_LB 4 #define STEREO_DFT_DMX_CROSSOVER ( int16_t )( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) /* crossover bin between binwise and bandwise DMX */ #define ITD_VAD_E_BAND_N_INIT 200000 -#ifdef FIX_ITD_CNG -#define ITD_SID_PREV_FRAMES 5 -#endif +#define ITD_SID_PREV_FRAMES 5 /*------------------------------------------------------------------------- @@ -494,14 +492,12 @@ void stereo_dft_enc_reset( set_f( hStereoDft->Spd_L_smooth, 1.0f, STEREO_DFT_N_32k_ENC / 2 ); set_f( hStereoDft->Spd_R_smooth, 1.0f, STEREO_DFT_N_32k_ENC / 2 ); -#ifdef FIX_ITD_CNG hStereoDft->currentNumUpdates = 0; hStereoDft->expectedNumUpdates = FIXED_SID_RATE; hStereoDft->resetFrames = 0; hStereoDft->sid_gipd = 0; hStereoDft->prev_sid_gipd = 0; hStereoDft->prev_sid_no_ipd_flag = 1; -#endif hStereoDft->coh_fade_counter = 0; @@ -1234,12 +1230,10 @@ float stereo_dft_enc_synthesize( *-------------------------------------------------------------------------*/ void stereo_dft_enc_process( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#ifdef FIX_ITD_CNG + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ const int16_t vad_hover_flag[], /* i: VAD hangover flags */ -#endif - const int16_t input_frame /* i : input frame length */ + const int16_t input_frame /* i : input frame length */ ) { int16_t i, j, b; @@ -1309,11 +1303,7 @@ void stereo_dft_enc_process( if ( hStereoDft->hConfig->itd_mode ) #endif { -#ifdef FIX_ITD_CNG stereo_dft_enc_compute_itd( hCPE, pDFT_L, pDFT_R, k_offset, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL, bin_nrgR ); -#else - stereo_dft_enc_compute_itd( hCPE, pDFT_L, pDFT_R, k_offset, input_frame, bin_nrgL, bin_nrgR ); -#endif if ( hCPE->element_mode == IVAS_CPE_MDCT ) { return; @@ -1386,7 +1376,6 @@ void stereo_dft_enc_process( /* DFT stereo parameters */ stereo_dft_enc_compute_prm( hStereoDft, pDFT_L, pDFT_R, k_offset, 1, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->vad_flag, bin_nrgL, bin_nrgR, dot_prod_nrg_ratio ); -#ifdef FIX_ITD_CNG if ( vad_flag_dtx[0] == 0 ) { if ( hCPE->hStereoCng->cng_counter == 0 && !hCPE->hStereoCng->first_SID_after_TD ) @@ -1401,7 +1390,6 @@ void stereo_dft_enc_process( hStereoDft->prev_sid_no_ipd_flag = hStereoDft->no_ipd_flag; } } -#endif /*----------------------------------------------------------------* * UNCLR classifier (detection of uncorrelated L and R channels) @@ -1459,11 +1447,7 @@ void stereo_dft_enc_process( } } -#ifdef FIX_ITD_CNG if ( b < hStereoDft->res_cod_band_max && vad_flag_dtx[0] ) -#else - if ( b < hStereoDft->res_cod_band_max ) -#endif { #ifdef DEBUGGING assert( hStereoDft->nbands == hStereoDft->nbands_dmx && "Don't use coarser stereo parameter resolution for residual coding bitrates!" ); @@ -2353,11 +2337,7 @@ void stereo_dft_enc_write_BS( if ( core_brate == SID_2k40 ) { -#ifdef FIX_ITD_CNG stereo_dft_enc_sid_calc_coh( hStereoDft, hCPE->hStereoCng->prev_cohBand, &hCPE->hStereoCng->td_active, &hCPE->hStereoCng->first_SID, cohBand ); -#else - stereo_dft_enc_sid_calc_coh( hStereoDft, hCPE->hStereoCng->coh_crossfade, &hCPE->hStereoCng->td_active, &hCPE->hStereoCng->first_SID, cohBand ); -#endif if ( *nb_bits <= ( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - STEREO_DFT_ITD_MODE_NBITS - STEREO_DFT_SID_ITD_NBITS - 1 ) ) { diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index e917c36e361d780cbc78edda143909fe98032851..d8c32e7aee66afb72e747248d326c49e5ba49711 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -66,11 +66,9 @@ #define SUBDIV ( 2 * STEREO_DFT_ITD_MAX_ANA / L_SAMPLES ) #define DENOM 0.05f -#define XSPEC_ALPHA ( 1.f / 32 ) -#ifdef FIX_ITD_CNG +#define XSPEC_ALPHA ( 1.f / 32 ) #define CORR_FILT 0.8f #define CORR_RESET_FRAMES_MAX 20 -#endif #define ITD_VAD_NOISE_INIT_FRAMES 30 #define ITD_VAD_THRSHOLD 0.001f @@ -726,10 +724,8 @@ void stereo_dft_enc_compute_itd( float *DFT_R, const int16_t k_offset, const int16_t input_frame, -#ifdef FIX_ITD_CNG const int16_t vad_flag_dtx[], const int16_t vad_hover_flag[], -#endif float *bin_nrgL, float *bin_nrgR ) { @@ -776,9 +772,7 @@ void stereo_dft_enc_compute_itd( const float *dft_trigo32k; float trigo_enc[STEREO_DFT_N_32k_ENC / 2 + 1]; -#ifdef FIX_ITD_CNG float cng_xcorr_filt; -#endif if ( hCPE->element_mode == IVAS_CPE_DFT ) { @@ -938,9 +932,7 @@ void stereo_dft_enc_compute_itd( vad_flag_itd = stereo_dft_enc_itd_vad( hItd->E_band_n, &( hItd->vad_frm_cnt ), Spd_L, Spd_R, &mssnr ); -#ifdef FIX_ITD_CNG vad_flag_itd = vad_flag_itd && vad_flag_dtx[0]; -#endif if ( sum_nrg_L < EPSILON ) { @@ -1069,7 +1061,6 @@ void stereo_dft_enc_compute_itd( if ( hCPE->hCoreCoder[0]->Opt_DTX_ON && hCPE->element_mode == IVAS_CPE_DFT ) { -#ifdef FIX_ITD_CNG if ( hCPE->hFrontVad[0] != NULL ) { /* Determine if we are in hangover */ @@ -1119,14 +1110,8 @@ void stereo_dft_enc_compute_itd( } } } -#endif -#ifdef FIX_ITD_CNG if ( ( vad_flag_dtx[0] == 0 ) || ( hCPE->hFrontVad[0] == NULL && ( hCPE->hCoreCoder[0]->last_core_brate == SID_2k40 || hCPE->hCoreCoder[0]->last_core_brate == FRAME_NO_DATA ) ) || hCPE->hStereoCng->first_SID_after_TD ) -#else - if ( hCPE->hCoreCoder[0]->last_core_brate == SID_2k40 || hCPE->hCoreCoder[0]->last_core_brate == FRAME_NO_DATA || hCPE->hStereoCng->first_SID_after_TD ) -#endif { -#ifdef FIX_ITD_CNG if ( vad_flag_dtx[0] == 0 ) { /* expectedNumUpdates updated after call to dtx() in SID frames */ @@ -1144,19 +1129,13 @@ void stereo_dft_enc_compute_itd( { mvr2r( hStereoDft->xspec_smooth, hItd->xcorr_smooth, NFFT ); } -#endif for ( i = 1; i < NFFT / 2; i++ ) { /* Low pass filter cross L/R power spectrum */ hStereoDft->xspec_smooth[2 * i] = ( 1.f - XSPEC_ALPHA ) * hStereoDft->xspec_smooth[2 * i] + XSPEC_ALPHA * xcorr[2 * i]; hStereoDft->xspec_smooth[2 * i + 1] = ( 1.f - XSPEC_ALPHA ) * hStereoDft->xspec_smooth[2 * i + 1] + XSPEC_ALPHA * xcorr[2 * i + 1]; -#ifdef FIX_ITD_CNG hItd->xcorr_smooth[2 * i] = ( 1.f - cng_xcorr_filt ) * hItd->xcorr_smooth[2 * i] + cng_xcorr_filt * xcorr[2 * i]; hItd->xcorr_smooth[2 * i + 1] = ( 1.f - cng_xcorr_filt ) * hItd->xcorr_smooth[2 * i + 1] + cng_xcorr_filt * xcorr[2 * i + 1]; -#else - hItd->xcorr_smooth[2 * i] = ( 1.f - sfm_L ) * hItd->xcorr_smooth[2 * i] + sfm_L * xcorr[2 * i]; - hItd->xcorr_smooth[2 * i + 1] = ( 1.f - sfm_L ) * hItd->xcorr_smooth[2 * i + 1] + sfm_L * xcorr[2 * i + 1]; -#endif tmpf1 = sqrtf( hItd->xcorr_smooth[i * 2] * hItd->xcorr_smooth[i * 2] + hItd->xcorr_smooth[i * 2 + 1] * hItd->xcorr_smooth[i * 2 + 1] ); tmpf1 += EPSILON; tmpf2 = tmpf1; diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index fd4cbdde71842712c1aa5a1b5c8f63d4a4e2c7eb..4f7060e3503ba860b6b7544d88d39d30785cdd57 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -383,12 +383,10 @@ void stereo_td_itd( * ---------------------------------------------------------------*/ void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ -#ifdef FIX_ITD_CNG + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ const int16_t vad_hover_flag[], /* i: VAD hangover flags */ -#endif - const int16_t input_frame /* i : frame length */ + const int16_t input_frame /* i : frame length */ ) { int16_t i; @@ -415,11 +413,7 @@ void stereo_td_itd_mdct_stereo( stereo_dft_enc_analyze( hCPE->hCoreCoder, CPE_CHANNELS, input_frame, NULL, hStereoMdct, DFT, hCPE->input_mem ); /*call ITD function*/ -#ifdef FIX_ITD_CNG stereo_dft_enc_compute_itd( hCPE, DFT[0], DFT[1], STEREO_DFT_OFFSET, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL, bin_nrgR ); -#else - stereo_dft_enc_compute_itd( hCPE, DFT[0], DFT[1], STEREO_DFT_OFFSET, input_frame, bin_nrgL, bin_nrgR ); -#endif /* Time Domain ITD compensation using extrapolation */ #ifdef DEBUG_MODE_DFT diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 7fb89690f1be709c7b62c9f606994bf9076e5ea3..33728a6f40a3cfe6ca36343d379b31c2ffc2e9d3 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -211,12 +211,8 @@ 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 -#ifdef FIX_ITD_CNG - , - NULL -#endif - ); + 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 diff --git a/lib_enc/vad.c b/lib_enc/vad.c index 98b6ad240e3a8e22db89102724cae0c4230c2114..5379f86dc0c10689760db6bff312919b88779230 100644 --- a/lib_enc/vad.c +++ b/lib_enc/vad.c @@ -162,10 +162,8 @@ int16_t dtx_hangover_addition( int16_t *vad_hover_flag, /* o : VAD hangover flag */ VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -#ifdef FIX_ITD_CNG , int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ -#endif ) { int16_t hangover_short_dtx, flag_dtx; @@ -307,12 +305,10 @@ int16_t dtx_hangover_addition( if ( flag_dtx != 0 && st->localVAD == 0 ) { *vad_hover_flag = 1; -#ifdef FIX_ITD_CNG if ( rem_dtx_ho != NULL ) { *rem_dtx_ho = max( hangover_short_dtx - hVAD->hangover_cnt_dtx, 0 ); } -#endif } return flag_dtx; diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h index f758bc780a12011e733f81c36b5ef2813ddef435..c779916703be646f4789e40497f4672422e0c9fd 100644 --- a/lib_rend/ivas_lib_rend_internal.h +++ b/lib_rend/ivas_lib_rend_internal.h @@ -108,10 +108,7 @@ ivas_error ivas_rend_TDObjRenderFrame( const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const int16_t output_frame, /* i : output frame length */ -#ifndef FIX_ITD - const int32_t output_Fs, /* i : output sampling rate */ -#endif - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); ivas_error ivas_rend_TDObjRendOpen( diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index da4c10a888f9a7e1dc54bbae9eb00dac80eb9d49..9fc512e639c8cf63a06db3451c9581c06501842c 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -48,11 +48,7 @@ * Local function prototypes *---------------------------------------------------------------------*/ -#ifdef FIX_ITD static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int16_t subframe_idx ); -#else -static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int32_t output_Fs, const int16_t subframe_idx ); -#endif static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, @@ -128,11 +124,7 @@ ivas_error ivas_td_binaural_open( for ( nS = 0; nS < nchan_rend; nS++ ) { -#ifdef FIX_ITD if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) -#else - if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -273,11 +265,7 @@ void ObjRenderIVASFrame( } /* Render subframe */ -#ifdef FIX_ITD TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, subframe_idx ); -#else - TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, st_ivas->hDecoderConfig->output_Fs, subframe_idx ); -#endif } if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ @@ -303,10 +291,7 @@ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ -#ifndef FIX_ITD - const int32_t output_Fs, /* i : Output sampling rate */ -#endif - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ) { int16_t i; @@ -315,23 +300,19 @@ static ivas_error TDREND_GetMix( TDREND_SRC_REND_t *SrcRend_p; ivas_error error; float output_buf[2][L_SPATIAL_SUBFR_48k]; /* Temp buffer for left/right rendered signal */ -#ifdef FIX_ITD float hrf_left_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; float hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; int16_t intp_count; -#endif error = IVAS_ERR_OK; /* Clear the output buffer to accumulate rendered sources */ set_f( output_buf[0], 0.0f, subframe_length ); set_f( output_buf[1], 0.0f, subframe_length ); -#ifdef FIX_ITD /* Clear interpolation buffers and counter */ set_f( hrf_left_delta, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); set_f( hrf_right_delta, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH ); intp_count = 0; -#endif /* Create the mix */ /* Loop through the source list and render each source */ @@ -344,26 +325,14 @@ static ivas_error TDREND_GetMix( /* Update rendering params if needed */ if ( hBinRendererTd->Listener_p->PoseUpdated || SrcSpatial_p->Updated ) { -#ifdef FIX_ITD TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, Src_p->hrf_left_prev, Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p, subframe_idx ); -#else - TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, output_Fs ); -#endif } /* Render source if needed */ if ( ( SrcRend_p->InputAvailable == TRUE ) && ( SrcRend_p->PlayStatus == TDREND_PLAYSTATUS_PLAYING ) ) { -#ifdef FIX_ITD error = TDREND_REND_RenderSourceHRFilt( Src_p, hrf_left_delta, hrf_right_delta, intp_count, output_buf, subframe_length ); -#else -#ifdef TDREND_HRTF_TABLE_METHODS - error = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, subframe_length, output_Fs ); -#else - error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, subframe_length, output_Fs ); -#endif -#endif } } @@ -588,11 +557,7 @@ ivas_error ivas_rend_TDObjRendOpen( for ( nS = 0; nS < nchan_rend; nS++ ) { -#ifdef FIX_ITD if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK ) -#else - if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType, outFs ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -677,10 +642,7 @@ ivas_error ivas_rend_TDObjRenderFrame( const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const int16_t output_frame, /* i : output frame length */ -#ifndef FIX_ITD - const int32_t output_Fs, /* i : output sampling rate */ -#endif - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) { int16_t subframe_length; @@ -751,11 +713,7 @@ ivas_error ivas_rend_TDObjRenderFrame( // } /* Render subframe */ -#ifdef FIX_ITD TDREND_GetMix( pTDRend->hBinRendererTd, output, subframe_length, subframe_idx ); -#else - TDREND_GetMix( pTDRend->hBinRendererTd, output, subframe_length, output_Fs, subframe_idx ); -#endif } /* TODO tmu : pass down renderer config struct */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 5269b580b0d74698d24127459f40265a4a6cbc5f..9230ad3dc8d7a4b2f7c8532217a194eadfc3a2c0 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -343,56 +343,20 @@ void TDREND_HRFILT_SetFiltSet( --------------------------------------------------------------------*/ ivas_error TDREND_REND_RenderSourceHRFilt( - TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ -#ifdef FIX_ITD - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ -#else -#ifdef TDREND_HRTF_TABLE_METHODS - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ -#endif -#endif + TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ + const float *hrf_left_delta, /* i: Left filter interpolation delta */ + const float *hrf_right_delta, /* i: Right filter interpolation delta */ + const int16_t intp_count, /* i: Interpolation count */ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ -#ifdef FIX_ITD - const int16_t subframe_length /* i : Subframe length in use */ -#else - const int16_t subframe_length, /* i : Subframe length in use */ - const int32_t output_Fs /* i : Output sample rate */ -#endif + const int16_t subframe_length /* i : Subframe length in use */ ) { -#ifndef FIX_ITD - TDREND_SRC_REND_t *SrcRend_p; - const float *InFrame_nIC_p; - int16_t NoOfUsedInputSamples, NoOfDeliveredOutputSamples; -#endif float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; -#ifdef FIX_ITD TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength ); -#else - - /* Input channel rendering loop */ - InFrame_nIC_p = Src_p->InputFrame_p; - SrcRend_p = Src_p->SrcRend_p; - - /* Gain not currently encoded/used */ - /* SrcGain = Mix_p->Gain * ( *SrcRend_p->SrcGain_p ); */ - /* SrcGain *= ( *SrcRend_p->DirGain_p ) * ( *SrcRend_p->DistGain_p ); */ - - TDREND_SFX_SpatBin_Execute_Main( SrcRend_p->SfxSpatBin_p, InFrame_nIC_p, subframe_length, LeftOutputFrame, RightOutputFrame, &NoOfUsedInputSamples, &NoOfDeliveredOutputSamples, output_Fs ); - -#ifdef TDREND_HRTF_TABLE_METHODS - if ( hBinRendererTd->HrFiltSet_p->FilterMethod != TDREND_HRFILT_Method_BSplineModel ) - { - SrcRend_p->SfxSpatBin_p->HrFilterInterpOn = 1; /* Turn on after first frame is rendered. */ - } -#endif -#endif /* Copy to accumulative output frame */ v_add( LeftOutputFrame, output_buf[0], output_buf[0], subframe_length ); v_add( RightOutputFrame, output_buf[1], output_buf[1], subframe_length ); @@ -718,51 +682,25 @@ void GetFilterFromAngle( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */ const float Elev, /* i : Elevation, degrees */ float Azim, /* i : Azimuth, degrees */ -#ifdef FIX_ITD - float *hrf_left, /* o : Left HR filter */ - float *hrf_right, /* o : Right HR filter */ - int16_t *itd /* o : ITD value */ -#else - SFX_SpatBin_Params_t *SfxSpatBinParams_p /* i/o: Currently used HR filter */ -#endif + float *hrf_left, /* o : Left HR filter */ + float *hrf_right, /* o : Right HR filter */ + int16_t *itd /* o : ITD value */ ) { -#ifndef FIX_ITD - int16_t count, ii; -#endif GenerateFilter( Elev, Azim, &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ); -#ifdef FIX_ITD mvr2r( HrFiltSet_p->ModelEval.hrfModL, hrf_left, HrFiltSet_p->ModelParams.K ); mvr2r( HrFiltSet_p->ModelEval.hrfModR, hrf_right, HrFiltSet_p->ModelParams.K ); -#else - /* Renderer requires filter in reversed order: */ - count = 0; - for ( ii = ( HrFiltSet_p->ModelParams.K - 1 ); ii >= 0; ii-- ) - { - SfxSpatBinParams_p->LeftFilter_p[ii] = HrFiltSet_p->ModelEval.hrfModL[count]; - SfxSpatBinParams_p->RightFilter_p[ii] = HrFiltSet_p->ModelEval.hrfModR[count]; - count++; - } -#endif /* 4. Evaluate the ITD */ if ( HrFiltSet_p->ModelParams.UseItdModel ) { GenerateITD( Elev, Azim, &HrFiltSet_p->ModelParamsITD, &HrFiltSet_p->ModelEval ); -#ifdef FIX_ITD *itd = (int16_t) HrFiltSet_p->ModelEval.itdMod; -#else - SfxSpatBinParams_p->Itd = HrFiltSet_p->ModelEval.itdMod; -#endif } else { -#ifdef FIX_ITD *itd = 0; -#else - SfxSpatBinParams_p->Itd = 0; /* No extracted ITD */ -#endif } return; diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index c8e75cfd0451e19cc236d8abad9533e0367d53e6..670c4378dfb1fc1380f6d24369bb8d447c0c6895 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -290,12 +290,7 @@ ivas_error TDREND_MIX_SetDistAttenModel( ivas_error TDREND_MIX_AddSrc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ int16_t *SrcInd, /* o : Source index */ -#ifdef FIX_ITD - const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ -#else - const TDREND_PosType_t PosType, /* i : Position type (absolute/relative) */ - const int32_t output_Fs /* i : Output sampling rate */ -#endif + const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ ) { TDREND_SRC_t *Src_p; @@ -327,11 +322,7 @@ ivas_error TDREND_MIX_AddSrc( return error; } -#ifdef FIX_ITD TDREND_SRC_Init( Src_p, PosType ); -#else - TDREND_SRC_Init( Src_p, PosType, output_Fs ); -#endif /* Special OpenAL initialization due to a common distance attenuation model */ if ( hBinRendererTd->DistAttenModel != 0 ) diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index a5f3b58e7a9545696157a16efe98a6675a643163..cc6e6c0a8d78f2b5257be37751d875d7ff42f377 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -43,1421 +43,13 @@ * Local constants *---------------------------------------------------------------------*/ -#ifndef FIX_ITD -/* Sinc constants */ -#define SFX_SPAT_BIN_SINC_M 5 -#define SFX_SPAT_BIN_NUM_SUBSAMPLES_BITS 6 -#define SFX_SPAT_BIN_NUM_SUBSAMPLES ( 1 << SFX_SPAT_BIN_NUM_SUBSAMPLES_BITS ) -#endif /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ -#ifndef FIX_ITD -static void TDREND_SFX_SpatBin_SetParamsInitializeOn( SFX_SpatBin_t *SfxSpatBin_p, const SFX_SpatBin_Params_t *NewParam_p, const int32_t output_Fs ); -static void TDREND_SFX_SpatBin_SetParamsInitializeOff( SFX_SpatBin_t *SfxSpatBin_p, const SFX_SpatBin_Params_t *NewParam_p, const int32_t output_Fs ); -static void TDREND_SFX_SpatBin_SetParamsOn( SFX_SpatBin_t *SfxSpatBin_p, const SFX_SpatBin_Params_t *NewParam_p, const int32_t output_Fs ); -static void TDREND_SFX_SpatBin_SetParamsOff( SFX_SpatBin_t *const SfxSpatBin_p, const int32_t output_Fs ); -static void TDREND_SFX_SpatBin_Execute( SFX_SpatBin_t *SfxSpatBin_p, const float *InBuffer_p, -#ifdef DEBUGGING - const int16_t NoOfInputSamples, -#endif - const int16_t NoOfRequestedOutputSamples, - float *LeftOutBuffer_p, - float *RightOutBuffer_p, - int16_t *NoOfUsedInputSamples_p, - int16_t *NoOfDeliveredOutputSamples_p, - const int32_t output_Fs ); -static void TDREND_FirFilterRev( float *OutputFrame_p, float *FirFilterRev_p, const int16_t FirFilterLength, float *InputFrame_p, const int16_t NumOfSamples ); -#ifdef TDREND_HRTF_TABLE_METHODS -static void TDREND_FirFilterRevInterp( float *OutputFrame_p, float *FirFilterRev_p, const int16_t FirFilterLength, float *InputFrame_p, const int16_t NumOfSamples, float *FilterStored ); -#endif -static void TDREND_SFX_SpatBin_Clear( SFX_SpatBin_t *SfxSpatBin_p, const int32_t output_Fs ); -#else static void sincResample( const float *input, float *output, const int16_t length_in, const int16_t length_out ); -#endif -#ifndef FIX_ITD -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_Resampling() - * - * Resamples input data with a given resampling factor and returns the - * resampled data. - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_Resampling( - const float *const InputBuffer_p, /* i : The input buffer with audio samples. */ - const int16_t NoOfInputSamples, /* i : Length of input buffer */ - float *const ResampleOutBuffer_p, /* o : Resampled output */ - const int16_t NoOfResampledSamples, /* i : Length of resampled output */ - float *const OldBuffer_p, /* i/o: Samples from previous input buffer (in case of buffer surplus) */ - int16_t *const NoOfOldBufferSamples_p, /* i/o: Length of OldBuffer_p */ - const float Alpha, /* i : Resampling factor */ - float *const Tf_p /* i/o: Old fractional time value / updated time value 0.0 <= Tf < 1.0 */ -) -{ - int16_t i, k, n, n0; - float AlphaInv; - float T; - int16_t nt, snc0, SubsamplesSteps; - const float *SamplePointer_p, *SincPointer_p; - float Temp; - int16_t NoOfSamplesToCopy, MaximumIndInOldBuffer, Ind; - - T = *Tf_p; - - /* The inverse of the resampling factor */ - AlphaInv = 1 / Alpha; - - /* Check how many input samples we have */ - if ( NoOfInputSamples < 2 * SFX_SPAT_BIN_SINC_M ) - { - NoOfSamplesToCopy = NoOfInputSamples; - MaximumIndInOldBuffer = *NoOfOldBufferSamples_p - ( 2 * SFX_SPAT_BIN_SINC_M - NoOfInputSamples ); - } - else - { - NoOfSamplesToCopy = 2 * SFX_SPAT_BIN_SINC_M; - MaximumIndInOldBuffer = *NoOfOldBufferSamples_p; - } - - /* 1. Append min(2M,N_input) samples from input buffer to old buffer */ - for ( i = 0; i < NoOfSamplesToCopy; i++ ) - { - OldBuffer_p[*NoOfOldBufferSamples_p + i] = InputBuffer_p[i]; - } - - /* 2. Resampling */ - nt = 0; - n0 = SFX_SPAT_BIN_SINC_M - 1; - k = 0; - if ( Alpha <= 1.0 ) - { - /* 2.1 Resample (without scaling) old buffer */ - while ( nt <= MaximumIndInOldBuffer ) - { - /* Calculate the sinc-index for the center value of the sinc */ - snc0 = (int16_t) ( ( T + EPSILON - nt ) * SFX_SPAT_BIN_NUM_SUBSAMPLES + 0.5 ); - - /* The convolution of the sinc and the data */ - SamplePointer_p = &OldBuffer_p[n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 )]; - SincPointer_p = &SincTable[snc0 - SFX_SPAT_BIN_NUM_SUBSAMPLES * ( -( SFX_SPAT_BIN_SINC_M - 1 ) )]; - - Temp = *SamplePointer_p * *SincPointer_p; - for ( i = -( SFX_SPAT_BIN_SINC_M - 2 ); i <= 0; i++ ) - { - SamplePointer_p++; - SincPointer_p -= SFX_SPAT_BIN_NUM_SUBSAMPLES; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - - SamplePointer_p++; - SincPointer_p = &SincTable[SFX_SPAT_BIN_NUM_SUBSAMPLES - snc0]; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - for ( i = 2; i <= SFX_SPAT_BIN_SINC_M; i++ ) - { - SamplePointer_p++; - SincPointer_p += SFX_SPAT_BIN_NUM_SUBSAMPLES; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - - ResampleOutBuffer_p[k] = Temp; - - /* Update the time index */ - T = T + Alpha; - /* Update the time index for the old buffer data */ - nt = (int16_t) ( T + EPSILON ); - /* Update the resampled buffer index */ - k++; - - /* Make sure we don't process too many samples. This check is needed for the cases */ - /* when all resampled samples are obtained from the old buffer. */ - if ( k >= NoOfResampledSamples ) - { - /* We have processed enough data. Jump out of the while-loop! */ - break; - } - } - - /* 2.2 Resample (without scaling) input buffer */ - n0 = ( SFX_SPAT_BIN_SINC_M - 1 ) - *NoOfOldBufferSamples_p; - for ( n = k; n < NoOfResampledSamples; n++ ) - { - /* Calculate the sinc-index for the center value of the sinc */ - snc0 = (int16_t) ( ( T + EPSILON - nt ) * SFX_SPAT_BIN_NUM_SUBSAMPLES + 0.5 ); - - /* The convolution of the sinc and the data */ - SamplePointer_p = &InputBuffer_p[n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 )]; - SincPointer_p = &SincTable[snc0 - SFX_SPAT_BIN_NUM_SUBSAMPLES * ( -( SFX_SPAT_BIN_SINC_M - 1 ) )]; - - Temp = *SamplePointer_p * *SincPointer_p; - for ( i = -( SFX_SPAT_BIN_SINC_M - 2 ); i <= 0; i++ ) - { - SamplePointer_p++; - SincPointer_p -= SFX_SPAT_BIN_NUM_SUBSAMPLES; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - - SamplePointer_p++; - SincPointer_p = &SincTable[SFX_SPAT_BIN_NUM_SUBSAMPLES - snc0]; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - for ( i = 2; i <= SFX_SPAT_BIN_SINC_M; i++ ) - { - SamplePointer_p++; - SincPointer_p += SFX_SPAT_BIN_NUM_SUBSAMPLES; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - ResampleOutBuffer_p[n] = Temp; - - /* Update the time index */ - T = T + Alpha; - /* Update the time index for the input buffer data */ - nt = (int16_t) ( T + EPSILON ); - } - } - else - { - /* Calculate the constant step length in subsamples for the sinc */ - SubsamplesSteps = (int16_t) ( AlphaInv * SFX_SPAT_BIN_NUM_SUBSAMPLES ); - - /* 2.3 Resample (with scaling) old buffer */ - while ( nt <= MaximumIndInOldBuffer ) - { - /* Calculate the sinc-index for the center value of the sinc */ - snc0 = (int16_t) ( ( T + EPSILON - nt ) * SubsamplesSteps + 0.5f ); - - /* The convolution of the sinc and the data */ - - SamplePointer_p = &OldBuffer_p[n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 )]; - SincPointer_p = &SincTable[snc0 - SubsamplesSteps * ( -( SFX_SPAT_BIN_SINC_M - 1 ) )]; - - Temp = *SamplePointer_p * *SincPointer_p; - for ( i = -( SFX_SPAT_BIN_SINC_M - 2 ); i <= 0; i++ ) - { - SamplePointer_p++; - SincPointer_p -= SubsamplesSteps; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - - SamplePointer_p++; - SincPointer_p = &SincTable[SubsamplesSteps - snc0]; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - for ( i = 2; i <= SFX_SPAT_BIN_SINC_M; i++ ) - { - SamplePointer_p++; - SincPointer_p += SubsamplesSteps; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - /* Multiply by the inverse of the resampling factor */ - Temp = Temp * AlphaInv; - ResampleOutBuffer_p[k] = Temp; - - /* Update the time index */ - T = T + Alpha; - /* Update the time index for the input buffer data */ - nt = (int16_t) ( T + EPSILON ); - /* Update the resampled buffer index */ - k++; - - /* Make sure we don't process too many samples. This check is needed for the cases */ - /* when all resampled samples are obtained from the old buffer. */ - if ( k >= NoOfResampledSamples ) - { - /* We have processed enough data. Jump out of the while-loop! */ - break; - } - } - - /* 2.4 Resample (with scaling) input buffer */ - n0 = ( SFX_SPAT_BIN_SINC_M - 1 ) - *NoOfOldBufferSamples_p; - for ( n = k; n < NoOfResampledSamples; n++ ) - { - /* Calculate the sinc-index for the center value of the sinc */ - snc0 = (int16_t) ( ( T + EPSILON - nt ) * SubsamplesSteps + 0.5 ); - - /* The convolution of the sinc and the data */ - - SamplePointer_p = &InputBuffer_p[n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 )]; - SincPointer_p = &SincTable[snc0 - SubsamplesSteps * ( -( SFX_SPAT_BIN_SINC_M - 1 ) )]; - - Temp = *SamplePointer_p * *SincPointer_p; - for ( i = -( SFX_SPAT_BIN_SINC_M - 2 ); i <= 0; i++ ) - { - SamplePointer_p++; - SincPointer_p -= SubsamplesSteps; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - - SamplePointer_p++; - SincPointer_p = &SincTable[SubsamplesSteps - snc0]; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - for ( i = 2; i <= SFX_SPAT_BIN_SINC_M; i++ ) - { - SamplePointer_p++; - SincPointer_p += SubsamplesSteps; - Temp = Temp + *SamplePointer_p * *SincPointer_p; - } - /* Multiply by the inverse of the resampling factor */ - Temp = Temp * AlphaInv; - ResampleOutBuffer_p[n] = Temp; - - /* Update the time index */ - T = T + Alpha; - /* Update the time index for the input buffer data */ - nt = (int16_t) ( T + EPSILON ); - } - } - - /* 3. Update old buffer */ - Ind = (int16_t) ( n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 ) ); - if ( Ind < 0 ) - { - /* Must save some samples from the old buffer */ - for ( i = 0; i < -Ind; i++ ) - { - OldBuffer_p[i] = OldBuffer_p[i + *NoOfOldBufferSamples_p + Ind]; - } - /* Copy the input samples */ - for ( i = 0; i < NoOfInputSamples; i++ ) - { - OldBuffer_p[i - Ind] = InputBuffer_p[i]; - } - *NoOfOldBufferSamples_p = NoOfInputSamples - Ind; - } - else - { - *NoOfOldBufferSamples_p = NoOfInputSamples - (int16_t) ( n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 ) ); - - SamplePointer_p = &InputBuffer_p[n0 + nt - ( SFX_SPAT_BIN_SINC_M - 1 )]; - for ( i = 0; i < *NoOfOldBufferSamples_p; i++ ) - { - OldBuffer_p[i] = *( SamplePointer_p + i ); - } - } - - /* 4. Update Tf_p */ - *Tf_p = T - nt; - /* Due to the EPSILON factor and rounding problems t_new may be a little negative, ~ -10^-7. This should in theory not be possible so we need to */ - /* make sure that Tf_p is greater than or equal to 0. This problem is not present for fix-code, though. */ - if ( *Tf_p < 0 ) - { - *Tf_p = 0; - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_SetParams() - * - * Updates the ITD increment, HR-filters increments - * and volumes increments that are used by SFX_SPAT_BIN_UpdateParams(). - * - --------------------------------------------------------------------*/ - -void TDREND_SFX_SpatBin_SetParams( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct to be updated */ - const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - if ( NewParam_p->Reset == TRUE ) - { - /* Calling TDREND_SFX_SpatBin_Clear will clear buffers and sets SfxSpatBin_p->InitializeParams = TRUE, which forces all */ - /* rendering parameters to be set directly without any transition period. */ - TDREND_SFX_SpatBin_Clear( SfxSpatBin_p, output_Fs ); - } - - if ( NewParam_p->TurnOn == TRUE ) - { - /* Turn on the effect if it is not already on. */ - if ( SfxSpatBin_p->InitializeParams == TRUE ) - { - TDREND_SFX_SpatBin_SetParamsInitializeOn( SfxSpatBin_p, NewParam_p, output_Fs ); - } - else - { - TDREND_SFX_SpatBin_SetParamsOn( SfxSpatBin_p, NewParam_p, output_Fs ); - } - - SfxSpatBin_p->OpMode = SFX_TRANSIENT; - } - else - { - /* Turn off the effect if it is not already off. */ - if ( SfxSpatBin_p->InitializeParams == TRUE ) - { - TDREND_SFX_SpatBin_SetParamsInitializeOff( SfxSpatBin_p, NewParam_p, output_Fs ); - } - else - { - /* Turn off the effect */ - - TDREND_SFX_SpatBin_SetParamsOff( SfxSpatBin_p, output_Fs ); - } - - SfxSpatBin_p->OpMode = SFX_OFF; - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_SetParamsInitializeOn() - * - * Initialize spatial parameters and turn the effect on - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_SetParamsInitializeOn( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - float ItdAbs; - float *LeftFilter_p, *RightFilter_p, *LeftFilterIncr_p, *RightFilterIncr_p; - int16_t mem_size; - - SfxSpatBin_p->InitializeParams = FALSE; - /* The first parameter update */ - SfxSpatBin_p->FirstUpdate = TRUE; - SfxSpatBin_p->TargetTime = 0; - - SfxSpatBin_p->ItdIncrForResampling = 0.0; - - /* Copy the HR-filters */ - SfxSpatBin_p->FilterLength = NewParam_p->FilterLength; - - mem_size = (int16_t) SfxSpatBin_p->FilterLength * sizeof( float ); - LeftFilter_p = (float *) count_malloc( mem_size ); - RightFilter_p = (float *) count_malloc( mem_size ); - LeftFilterIncr_p = (float *) count_malloc( mem_size ); - RightFilterIncr_p = (float *) count_malloc( mem_size ); - - SfxSpatBin_p->LeftFilter_p = LeftFilter_p; - SfxSpatBin_p->RightFilter_p = RightFilter_p; - SfxSpatBin_p->LeftFilterIncr_p = LeftFilterIncr_p; - SfxSpatBin_p->RightFilterIncr_p = RightFilterIncr_p; - - for ( i = 0; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilter_p++ = NewParam_p->LeftVolume * ( NewParam_p->LeftFilter_p[i] ); - *RightFilter_p++ = NewParam_p->RightVolume * ( NewParam_p->RightFilter_p[i] ); - - /* Set initial increments to 0 */ - *LeftFilterIncr_p++ = 0.0; - *RightFilterIncr_p++ = 0.0; - } - - SfxSpatBin_p->TotNoOfOutputSamples = 0; - - switch ( output_Fs ) - { - case 16000: - i = 0; - break; - case 32000: - i = 1; - break; - case 48000: - i = 2; - break; - } - - /* Initialize ITD */ - if ( NewParam_p->Itd > 0.0 ) - { - SfxSpatBin_p->NoOfLeftOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i] - (int16_t) floor( NewParam_p->Itd ); - SfxSpatBin_p->Left_Tf = ( NewParam_p->Itd ) - floorf( NewParam_p->Itd ); - SfxSpatBin_p->NoOfRightOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; - } - else - { - ItdAbs = -NewParam_p->Itd; - SfxSpatBin_p->NoOfLeftOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i] + (int16_t) ceil( ItdAbs ); - SfxSpatBin_p->Left_Tf = ceilf( ItdAbs ) - ( ItdAbs ); - SfxSpatBin_p->NoOfRightOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_SetParamsInitializeOff() - * - * Initialize spatial parameters and turn the effect off - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_SetParamsInitializeOff( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - float *LeftFilter_p, *RightFilter_p, *LeftFilterIncr_p, *RightFilterIncr_p; - int16_t mem_size; - - SfxSpatBin_p->InitializeParams = FALSE; - /* The first parameter update */ - SfxSpatBin_p->FirstUpdate = TRUE; - SfxSpatBin_p->TargetTime = 0; - SfxSpatBin_p->ItdIncrForResampling = 0.0; - - /* Set the HR-filters */ - SfxSpatBin_p->FilterLength = NewParam_p->FilterLength; - - mem_size = (int16_t) SfxSpatBin_p->FilterLength * sizeof( float ); - LeftFilter_p = (float *) count_malloc( mem_size ); - RightFilter_p = (float *) count_malloc( mem_size ); - LeftFilterIncr_p = (float *) count_malloc( mem_size ); - RightFilterIncr_p = (float *) count_malloc( mem_size ); - - SfxSpatBin_p->LeftFilter_p = LeftFilter_p; - SfxSpatBin_p->RightFilter_p = RightFilter_p; - SfxSpatBin_p->LeftFilterIncr_p = LeftFilterIncr_p; - SfxSpatBin_p->RightFilterIncr_p = RightFilterIncr_p; - - *LeftFilter_p++ = 0.5; - *RightFilter_p++ = 0.5; - /* Set initial increments to 0 */ - *LeftFilterIncr_p++ = 0.0; - *RightFilterIncr_p++ = 0.0; - - for ( i = 1; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilter_p++ = 0.0; - *RightFilter_p++ = 0.0; - /* Set initial increments to 0 */ - *LeftFilterIncr_p++ = 0.0; - *RightFilterIncr_p++ = 0.0; - } - - SfxSpatBin_p->TotNoOfOutputSamples = 0; - - /* Initialize ITD to 0 */ - switch ( output_Fs ) - { - case 16000: - i = 0; - break; - case 32000: - i = 1; - break; - case 48000: - i = 2; - break; - } - SfxSpatBin_p->NoOfLeftOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; - SfxSpatBin_p->NoOfRightOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; - SfxSpatBin_p->Left_Tf = 0.0; - - return; -} - - -/*-------------------------------------------------------------------* - * void TDREND_SFX_SpatBin_SetParamsOn() - * - * Turn the effect on - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_SetParamsOn( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - float *LeftFilterIncr_p, *RightFilterIncr_p; - float MaxITDIncr = TDREND_MaxITD_Incr[2]; - /* Set FirstUpdate to FALSE, which makes SFX_SPAT_BIN_UpdateParams to start */ - /* updating the parameters. */ - SfxSpatBin_p->FirstUpdate = FALSE; - - /* Update TargetTime */ - if ( SfxSpatBin_p->OpMode == SFX_OFF ) - { - /* Start turning on the effect */ - SfxSpatBin_p->TurningOnEffect = TRUE; - /* Stop turning off the effect */ - SfxSpatBin_p->TurningOffEffect = FALSE; - /* Use the transient time instead of the target time */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->MaxTargetTime; - } - else - { - if ( SfxSpatBin_p->TurningOnEffect == FALSE ) - { - /* The effect is already on. Use the target time. */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->TotNoOfOutputSamples; - } - else if ( SfxSpatBin_p->TotNoOfOutputSamples > SfxSpatBin_p->TargetTime ) - { - /* The effect has already been turned on or will be turned on now. */ - /* If SfxSpatBin_p->TargetTime > SfxSpatBin_p->TotNoOfOutputSamples then continue with SfxSpatBin_p->TargetTime. */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->TotNoOfOutputSamples; - SfxSpatBin_p->TurningOnEffect = FALSE; - } - } - - /* Restart the counting of output samples */ - SfxSpatBin_p->TotNoOfOutputSamples = 0; - - /* 1. Calculate the new ITD increment. Here the half ITD increment is calculated due to that */ - /* half of it should be applied on the left channel and half on the right channel. */ - /* However, since doppler is not supported anymore resampling is only applied to the left */ - /* channel so the division by 2 could now be removed. */ - if ( SfxSpatBin_p->TargetTime > 0 ) - { - SfxSpatBin_p->ItdIncrForResampling = ( NewParam_p->Itd - ( SfxSpatBin_p->NoOfRightOldBufferSamples - ( SfxSpatBin_p->NoOfLeftOldBufferSamples - SfxSpatBin_p->Left_Tf ) ) ) / SfxSpatBin_p->TargetTime / 2; - } - - switch ( output_Fs ) - { - case 16000: - MaxITDIncr = TDREND_MaxITD_Incr[0]; - break; - case 32000: - MaxITDIncr = TDREND_MaxITD_Incr[1]; - break; - case 48000: - MaxITDIncr = TDREND_MaxITD_Incr[2]; - break; - } - /* Check that ItdIncrForResampling is within limits */ - if ( SfxSpatBin_p->ItdIncrForResampling > MaxITDIncr ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too large: %f > %f\n", SfxSpatBin_p->ItdIncrForResampling, MaxITDIncr ); - printf( " ParamsOn : TargetTime = %5d\n", SfxSpatBin_p->TargetTime ); -#endif - SfxSpatBin_p->ItdIncrForResampling = MaxITDIncr; - } - else if ( SfxSpatBin_p->ItdIncrForResampling < ( -MaxITDIncr ) ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too small: %f < %f\n", SfxSpatBin_p->ItdIncrForResampling, ( -MaxITDIncr ) ); -#endif - SfxSpatBin_p->ItdIncrForResampling = ( -MaxITDIncr ); - } - - /* 2. Calculate the HR-filter increments. Includes the left and right volume. */ - LeftFilterIncr_p = SfxSpatBin_p->LeftFilterIncr_p; - RightFilterIncr_p = SfxSpatBin_p->RightFilterIncr_p; - - for ( i = 0; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilterIncr_p++ = ( NewParam_p->LeftFilter_p[i] * NewParam_p->LeftVolume - SfxSpatBin_p->LeftFilter_p[i] ) / SfxSpatBin_p->TargetTime; - *RightFilterIncr_p++ = ( NewParam_p->RightFilter_p[i] * NewParam_p->RightVolume - SfxSpatBin_p->RightFilter_p[i] ) / SfxSpatBin_p->TargetTime; - } - - return; -} - - -/*-------------------------------------------------------------------* - * void TDREND_SFX_SpatBin_SetParamsOff() - * - * Turn the effect off - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_SetParamsOff( - SFX_SpatBin_t *const SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - float *LeftFilterIncr_p, *RightFilterIncr_p; - - int16_t MaxITD = TDREND_MaxITD[2]; - float MaxITDIncr = TDREND_MaxITD_Incr[2]; - switch ( output_Fs ) - { - case 16000: - MaxITD = TDREND_MaxITD[0]; - MaxITDIncr = TDREND_MaxITD_Incr[0]; - break; - case 32000: - MaxITD = TDREND_MaxITD[1]; - MaxITDIncr = TDREND_MaxITD_Incr[1]; - break; - case 48000: - MaxITD = TDREND_MaxITD[2]; - MaxITDIncr = TDREND_MaxITD_Incr[2]; - break; - } - - if ( SfxSpatBin_p->OpMode == SFX_TRANSIENT ) - { - /* The number of samples after which the ITD and HR-filters should have been reset. */ - SfxSpatBin_p->TransientTime = (int16_t) SfxSpatBin_p->MaxTargetTime; - } - - /* Set FirstUpdate to FALSE, which makes SFX_SPAT_BIN_UpdateParams to start updating the parameters. */ - SfxSpatBin_p->FirstUpdate = FALSE; - - /* Update TargetTime */ - if ( SfxSpatBin_p->OpMode == SFX_TRANSIENT ) - { - /* Start turning off the effect */ - SfxSpatBin_p->TurningOffEffect = TRUE; - /* Stop turning on the effect */ - SfxSpatBin_p->TurningOnEffect = FALSE; - /* Use the transient time instead of the target time */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->MaxTargetTime; - } - else - { - if ( SfxSpatBin_p->TurningOffEffect == FALSE ) - { - /* The effect is already off. Use the target time. */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->TotNoOfOutputSamples; - } - else if ( SfxSpatBin_p->TotNoOfOutputSamples > SfxSpatBin_p->TargetTime ) - { - /* The effect has already been turned off or will be turned off now. */ - /* If SfxSpatBin_p->TargetTime > SfxSpatBin_p->TotNoOfOutputSamples then continue */ - /* with SfxSpatBin_p->TargetTime. */ - SfxSpatBin_p->TargetTime = (int16_t) SfxSpatBin_p->TotNoOfOutputSamples; - } - } - - /* Restart the counting of output samples */ - SfxSpatBin_p->TotNoOfOutputSamples = 0; - - /* 1. Calculate the new ITD increment. Here the half ITD increment is calculated due to that */ - /* half of it should be applied on the left channel and half on the right channel. */ - /* if (SfxSpatBin_p->TurnedOn == FALSE) */ - if ( SfxSpatBin_p->OpMode == SFX_OFF ) - { - /* The effect has already been turned off */ - SfxSpatBin_p->ItdIncrForResampling = ( 0.0f - ( SfxSpatBin_p->NoOfRightOldBufferSamples - - ( SfxSpatBin_p->NoOfLeftOldBufferSamples - SfxSpatBin_p->Left_Tf ) ) ) / - SfxSpatBin_p->TargetTime / 2.0f; - - /* Check that ItdIncrForResampling is within limits */ - if ( SfxSpatBin_p->ItdIncrForResampling > MaxITDIncr ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too large: %f > %f\n", SfxSpatBin_p->ItdIncrForResampling, MaxITDIncr ); - printf( " ParamsOff : TargetTime = %5d\n", SfxSpatBin_p->TargetTime ); -#endif - SfxSpatBin_p->ItdIncrForResampling = MaxITDIncr; - } - else if ( SfxSpatBin_p->ItdIncrForResampling < ( -MaxITDIncr ) ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too small: %f < %f\n", SfxSpatBin_p->ItdIncrForResampling, ( -MaxITDIncr ) ); -#endif - SfxSpatBin_p->ItdIncrForResampling = ( -MaxITDIncr ); - } - } - else /*if (SfxSpatBin_p->TurnedOn == TRUE && NewParam_p->TurnOn == FALSE) */ - { - /* The effect is about to be turned off */ - SfxSpatBin_p->ItdIncrForResampling = ( 0.0f - ( SfxSpatBin_p->NoOfRightOldBufferSamples - - ( SfxSpatBin_p->NoOfLeftOldBufferSamples - SfxSpatBin_p->Left_Tf ) ) ) / - SfxSpatBin_p->TransientTime / 2.0f; - - /* Check that ItdIncrForResampling is within limits */ - if ( SfxSpatBin_p->ItdIncrForResampling > MaxITDIncr ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too large: %f > %f\n", SfxSpatBin_p->ItdIncrForResampling, MaxITDIncr ); - printf( " ParamsOff : TransientTime = %5d\n", SfxSpatBin_p->TransientTime ); -#endif - SfxSpatBin_p->ItdIncrForResampling = MaxITD; - } - else if ( SfxSpatBin_p->ItdIncrForResampling < ( -MaxITDIncr ) ) - { -#ifdef DEBUGGING - printf( "ItdIncrForResampling too small: %f < %f\n", SfxSpatBin_p->ItdIncrForResampling, ( -MaxITDIncr ) ); -#endif - SfxSpatBin_p->ItdIncrForResampling = ( -MaxITDIncr ); - } - - /* 2. Calculate the HR-filter increments. Includes the left and right volume. */ - LeftFilterIncr_p = SfxSpatBin_p->LeftFilterIncr_p; - RightFilterIncr_p = SfxSpatBin_p->RightFilterIncr_p; - - *LeftFilterIncr_p++ = ( 0.5f - SfxSpatBin_p->LeftFilter_p[0] ) / SfxSpatBin_p->TransientTime; - *RightFilterIncr_p++ = ( 0.5f - SfxSpatBin_p->RightFilter_p[0] ) / SfxSpatBin_p->TransientTime; - - for ( i = 1; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilterIncr_p++ = ( 0.0f - SfxSpatBin_p->LeftFilter_p[i] ) / SfxSpatBin_p->TransientTime; - *RightFilterIncr_p++ = ( 0.0f - SfxSpatBin_p->RightFilter_p[i] ) / SfxSpatBin_p->TransientTime; - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_UpdateParams() - * - * Updates the ITD, HR-filters and volumes, - * which are to be used when processing the next data - * block. - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_UpdateParams( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const int32_t NoOfOutputSamples /* i : Number of output samples */ -) -{ - int16_t i; - float *LeftFilter_p, *RightFilter_p, *LeftFilterIncr_p, *RightFilterIncr_p; - - LeftFilter_p = SfxSpatBin_p->LeftFilter_p; - RightFilter_p = SfxSpatBin_p->RightFilter_p; - LeftFilterIncr_p = SfxSpatBin_p->LeftFilterIncr_p; - RightFilterIncr_p = SfxSpatBin_p->RightFilterIncr_p; - - /* 1. Update the total number of output samples that has been rendered since the */ - /* last ARM update. This value is zeroed in the SetParams function. */ - SfxSpatBin_p->TotNoOfOutputSamples = SfxSpatBin_p->TotNoOfOutputSamples + NoOfOutputSamples; - if ( SfxSpatBin_p->TotNoOfOutputSamples > SfxSpatBin_p->MaxTargetTime ) - { - /* We need to limit TotNoOfOutputSamples in order to avoid wrap around as well */ - /* as when it is used in SetParams its maximum allowed value is MaxTargetTime. */ - SfxSpatBin_p->TotNoOfOutputSamples = SfxSpatBin_p->MaxTargetTime; - } - - /* No need to update if FirstUpdate is not true. All increments are zero. */ - if ( SfxSpatBin_p->FirstUpdate == FALSE ) - { - SfxSpatBin_p->TargetTime -= (int16_t) NoOfOutputSamples; - if ( SfxSpatBin_p->TargetTime < 0 ) - { - /* This is instead of using sub with saturation in order to */ - /* avoid wrap around. */ - SfxSpatBin_p->TargetTime = -1; - } - - if ( SfxSpatBin_p->TurningOffEffect == TRUE ) - { - SfxSpatBin_p->TransientTime -= (int16_t) NoOfOutputSamples; - if ( SfxSpatBin_p->TransientTime <= 0 ) - { - /* The effect has now been turned off */ - - SfxSpatBin_p->ItdIncrForResampling = 0.0; - - /* Set the default HR-filters */ - /* - SfxSpatBin_p->LeftFilter[0] = 0.5; - SfxSpatBin_p->RightFilter[0] = 0.5; - for (i = 1; i < SfxSpatBin_p->FilterLength; i++) - { - SfxSpatBin_p->LeftFilter[i] = 0.0; - SfxSpatBin_p->RightFilter[i] = 0.0; - }*/ - - *LeftFilter_p++ = 0.5; - *RightFilter_p++ = 0.5; - for ( i = 1; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilter_p++ = 0.0; - *RightFilter_p++ = 0.0; - } - - /* Put HR-filter increments to zero */ - /* - for (i = 0; i < SfxSpatBin_p->FilterLength; i++) - { - SfxSpatBin_p->LeftFilterIncr[i] = 0.0; - SfxSpatBin_p->RightFilterIncr[i] = 0.0; - }*/ - - for ( i = 0; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilterIncr_p++ = 0.0; - *RightFilterIncr_p++ = 0.0; - } - - /* The effect is now off */ - SfxSpatBin_p->TurningOffEffect = FALSE; - } - } - - /* 2. Check whether increments should continue to be updated. */ - if ( SfxSpatBin_p->TargetTime < 0 ) - { - /* Put ItdIncrForResampling to zero if TargetTime<0 */ - SfxSpatBin_p->ItdIncrForResampling = 0.0; - /* The effect has been turned on if it was being turned on */ - SfxSpatBin_p->TurningOnEffect = FALSE; - } - else - { - /* 3. Update the HR-filters. */ - /* Don't update if the effect is off. */ - if ( SfxSpatBin_p->OpMode == SFX_TRANSIENT || SfxSpatBin_p->TurningOffEffect == TRUE ) - { - /* - for (i = 0; i < SfxSpatBin_p->FilterLength; i++) - { - SfxSpatBin_p->LeftFilter[i] += SfxSpatBin_p->LeftFilterIncr[i] * NoOfOutputSamples; - SfxSpatBin_p->RightFilter[i] += SfxSpatBin_p->RightFilterIncr[i] * NoOfOutputSamples; - }*/ - - for ( i = 0; i < SfxSpatBin_p->FilterLength; i++ ) - { - *LeftFilter_p++ += ( *LeftFilterIncr_p++ ) * NoOfOutputSamples; - *RightFilter_p++ += ( *RightFilterIncr_p++ ) * NoOfOutputSamples; - } - } - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_Execute_Main() - * - * The main rendering function that is called from the Audio Mixer. - --------------------------------------------------------------------*/ - -void TDREND_SFX_SpatBin_Execute_Main( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const float *InBuffer_p, /* i : Input buffer */ - const int16_t subframe_length, /* i : subframe length */ - float *LeftOutBuffer_p, /* o : Rendered left channel */ - float *RightOutBuffer_p, /* o : Rendered right channel */ - int16_t *NoOfUsedInputSamples_p, /* o : Number of input samples actually used */ - int16_t *NoOfDeliveredOutputSamples_p, /* o : Number of output samples actually rendered */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - const float *InBufferPointer_p; - float *LeftOutBufferPointer_p, *RightOutBufferPointer_p; - int16_t TempNoOfRequestedOutputSamples, TempNoOfUsedInputSamples, TempNoOfDeliveredOutputSamples; - int16_t TempNoOfInputSamples; - int16_t NoOfBlocks; - - /* Make sure the blocks are not longer than 6 msec. */ - - NoOfBlocks = 1; - TempNoOfRequestedOutputSamples = subframe_length; - while ( TempNoOfRequestedOutputSamples > SfxSpatBin_p->MaxBlockLength ) - { - NoOfBlocks = NoOfBlocks << 1; - /* Shift with rounding */ - TempNoOfRequestedOutputSamples = ( TempNoOfRequestedOutputSamples >> 1 ) + ( TempNoOfRequestedOutputSamples & 1 ); - } - - /* Divide the output_frame into NoOfBlocks blocks. */ - InBufferPointer_p = InBuffer_p; - LeftOutBufferPointer_p = LeftOutBuffer_p; - RightOutBufferPointer_p = RightOutBuffer_p; - *NoOfUsedInputSamples_p = 0; - *NoOfDeliveredOutputSamples_p = 0; - TempNoOfInputSamples = subframe_length; - - for ( i = 0; i < NoOfBlocks; i++ ) - { - /* The effect is not being turned off or on. Normal rendering. */ - if ( SfxSpatBin_p->TargetTime < TempNoOfRequestedOutputSamples ) - { - /* Put ITD increment to zero. This prevents the ITD to become too large. */ - SfxSpatBin_p->ItdIncrForResampling = 0.0; - } - - TDREND_SFX_SpatBin_Execute( SfxSpatBin_p, InBufferPointer_p, -#ifdef DEBUGGING - TempNoOfInputSamples, -#endif - TempNoOfRequestedOutputSamples, LeftOutBufferPointer_p, RightOutBufferPointer_p, &TempNoOfUsedInputSamples, &TempNoOfDeliveredOutputSamples, output_Fs ); - - /* DSP update */ - TDREND_SFX_SpatBin_UpdateParams( SfxSpatBin_p, TempNoOfDeliveredOutputSamples ); - - /* Update the temp pointers */ - InBufferPointer_p += TempNoOfUsedInputSamples; - LeftOutBufferPointer_p += TempNoOfDeliveredOutputSamples; - RightOutBufferPointer_p += TempNoOfDeliveredOutputSamples; - - *NoOfDeliveredOutputSamples_p = *NoOfDeliveredOutputSamples_p + TempNoOfDeliveredOutputSamples; - if ( i == NoOfBlocks - 2 ) - { - /* The last block should produce the remaining number of samples */ - TempNoOfRequestedOutputSamples = subframe_length - *NoOfDeliveredOutputSamples_p; - } - *NoOfUsedInputSamples_p = *NoOfUsedInputSamples_p + TempNoOfUsedInputSamples; - TempNoOfInputSamples = TempNoOfInputSamples - TempNoOfUsedInputSamples; - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_Execute() - * - * Run renderer for one block - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_Execute( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const float *InBuffer_p, /* i : Input buffer */ -#ifdef DEBUGGING - const int16_t NoOfInputSamples, /* i : Length of input buffer */ -#endif - const int16_t NoOfRequestedOutputSamples, /* i : Length of output */ - float *LeftOutBuffer_p, /* o : Rendered left channel */ - float *RightOutBuffer_p, /* o : Rendered right channel */ - int16_t *NoOfUsedInputSamples_p, /* o : Number of input samples actually used */ - int16_t *NoOfDeliveredOutputSamples_p, /* o : Number of output samples actually rendered */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i = 0; - int16_t NoOfInputSamplesForLeft, NoOfInputSamplesForRight; - float TotalLeftFlp; - int16_t NoOfSamplesToCopy, Ind; - /* 1. Calculate the resampling factors for the left channel. */ - TotalLeftFlp = 1.0f + 2.0f * SfxSpatBin_p->ItdIncrForResampling; - - /* 2. Calculate the number of input samples needed for the left and right channel. */ - NoOfInputSamplesForLeft = 2 * SFX_SPAT_BIN_SINC_M - SfxSpatBin_p->NoOfLeftOldBufferSamples + - (int16_t) ( SfxSpatBin_p->Left_Tf + TotalLeftFlp * ( NoOfRequestedOutputSamples - 1 ) ); - - switch ( output_Fs ) - { - case 16000: - i = 0; - break; - case 32000: - i = 1; - break; - case 48000: - i = 2; - break; - } - NoOfInputSamplesForRight = NoOfRequestedOutputSamples + SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i] - - SfxSpatBin_p->NoOfRightOldBufferSamples; - /* Set the number of used Input samples to the maximum. */ - if ( NoOfInputSamplesForLeft > NoOfInputSamplesForRight ) - { - *NoOfUsedInputSamples_p = NoOfInputSamplesForLeft; - } - else - { - *NoOfUsedInputSamples_p = NoOfInputSamplesForRight; - } - /* Set the number of used input samples to zero if it is negative. */ - if ( *NoOfUsedInputSamples_p < 0 ) - { -#ifdef DEBUGGING - printf( "2. *NoOfUsedInputSamples_p < 0\n" ); -#endif - *NoOfUsedInputSamples_p = 0; - } - -#ifdef DEBUGGING - /* The following should never happen */ - if ( *NoOfUsedInputSamples_p > NoOfInputSamples ) - { - printf( "2. *NoOfUsedInputSamples_p > NoInputSamples %d %d \n", *NoOfUsedInputSamples_p, NoOfInputSamples ); - } -#endif - - *NoOfDeliveredOutputSamples_p = NoOfRequestedOutputSamples; - - /* 3. Resample the left channel. */ - TDREND_SFX_SpatBin_Resampling( InBuffer_p, - *NoOfUsedInputSamples_p, - &( SfxSpatBin_p->ResampledBufferLeft[SfxSpatBin_p->FilterLength - 1] ), - *NoOfDeliveredOutputSamples_p, - SfxSpatBin_p->LeftOldBuffer, - &( SfxSpatBin_p->NoOfLeftOldBufferSamples ), - TotalLeftFlp, - &( SfxSpatBin_p->Left_Tf ) ); - - /* 4. Prepare the right input buffer for the HR-filtering. */ - NoOfSamplesToCopy = SfxSpatBin_p->NoOfRightOldBufferSamples - ( SFX_SPAT_BIN_SINC_M - 1 ); - if ( NoOfSamplesToCopy > *NoOfDeliveredOutputSamples_p ) - { - NoOfSamplesToCopy = *NoOfDeliveredOutputSamples_p; - } - - for ( i = 0; i < NoOfSamplesToCopy; i++ ) - { - SfxSpatBin_p->ResampledBufferRight[SfxSpatBin_p->FilterLength - 1 + i] = - SfxSpatBin_p->RightOldBuffer[( SFX_SPAT_BIN_SINC_M - 1 ) + i]; - } - - for ( i = NoOfSamplesToCopy; i < *NoOfDeliveredOutputSamples_p; i++ ) - { - SfxSpatBin_p->ResampledBufferRight[SfxSpatBin_p->FilterLength - 1 + i] = - InBuffer_p[i - SfxSpatBin_p->NoOfRightOldBufferSamples + ( SFX_SPAT_BIN_SINC_M - 1 )]; - } - - /* 5. HR-filtering on the left and right channel. */ -#ifdef TDREND_HRTF_TABLE_METHODS - if ( SfxSpatBin_p->HrFilterInterpOn ) - { - TDREND_FirFilterRevInterp( LeftOutBuffer_p, - SfxSpatBin_p->LeftFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferLeft, - *NoOfDeliveredOutputSamples_p, - SfxSpatBin_p->LeftFilterStored ); - TDREND_FirFilterRevInterp( RightOutBuffer_p, - SfxSpatBin_p->RightFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferRight, - *NoOfDeliveredOutputSamples_p, - SfxSpatBin_p->RightFilterStored ); - } - else - { - /* First time - filter without interpolation, and set filter to use as previous. */ - TDREND_FirFilterRev( LeftOutBuffer_p, - SfxSpatBin_p->LeftFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferLeft, - *NoOfDeliveredOutputSamples_p ); - TDREND_FirFilterRev( RightOutBuffer_p, - SfxSpatBin_p->RightFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferRight, - *NoOfDeliveredOutputSamples_p ); - for ( i = 0; i < SfxSpatBin_p->FilterLength; i++ ) - { - SfxSpatBin_p->LeftFilterStored[i] = SfxSpatBin_p->LeftFilter_p[i]; - SfxSpatBin_p->RightFilterStored[i] = SfxSpatBin_p->RightFilter_p[i]; - } - } -#else - TDREND_FirFilterRev( LeftOutBuffer_p, - SfxSpatBin_p->LeftFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferLeft, - *NoOfDeliveredOutputSamples_p ); - TDREND_FirFilterRev( RightOutBuffer_p, - SfxSpatBin_p->RightFilter_p, - SfxSpatBin_p->FilterLength, - SfxSpatBin_p->ResampledBufferRight, - *NoOfDeliveredOutputSamples_p ); -#endif - - /* Store the samples needed for next block */ - Ind = *NoOfDeliveredOutputSamples_p - SfxSpatBin_p->NoOfRightOldBufferSamples; - if ( Ind < 0 ) - { - /* Must store some samples from the OldBuffer */ - for ( i = Ind; i < 0; i++ ) - { - SfxSpatBin_p->RightOldBuffer[i - Ind] = SfxSpatBin_p->RightOldBuffer[i + SfxSpatBin_p->NoOfRightOldBufferSamples]; - } - - /* Store all samples in the InputBuffer that has been used by either channel */ - for ( i = 0; i < *NoOfUsedInputSamples_p; i++ ) - { - SfxSpatBin_p->RightOldBuffer[i - Ind] = InBuffer_p[i]; - } - } - else - { - /* Store samples from the InputBuffer */ - for ( i = Ind; i < *NoOfUsedInputSamples_p; i++ ) - { - SfxSpatBin_p->RightOldBuffer[i - Ind] = InBuffer_p[i]; - } - } - - /* Update number of old samples */ - SfxSpatBin_p->NoOfRightOldBufferSamples = *NoOfUsedInputSamples_p - Ind; - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_Initialize() - * - * Initializes the spatial parameters struct - * - --------------------------------------------------------------------*/ - -ivas_error TDREND_SFX_SpatBin_Initialize( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const int32_t output_Fs /* i : Output sampling rate */ -) -{ - int16_t i; - - SfxSpatBin_p->OpMode = SFX_OFF; - SfxSpatBin_p->TurningOffEffect = FALSE; - SfxSpatBin_p->TurningOnEffect = FALSE; - /* Init during next SetParams-call */ - SfxSpatBin_p->InitializeParams = TRUE; -#ifdef FIX_I81 - SfxSpatBin_p->LeftFilter_p = NULL; - SfxSpatBin_p->LeftFilterIncr_p = NULL; - SfxSpatBin_p->RightFilter_p = NULL; - SfxSpatBin_p->RightFilterIncr_p = NULL; -#endif - - /* Init MaxTargetTime and MaxBlockLength */ - switch ( output_Fs ) - { - case 16000: - SfxSpatBin_p->MaxTargetTime = TDREND_SRC_REND_MaxTargetTimes[0]; - SfxSpatBin_p->MaxBlockLength = TDREND_SRC_REND_MaxBlockLengths[0]; - SfxSpatBin_p->LeftOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[0] ) * sizeof( float ) ); - SfxSpatBin_p->RightOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[0] ) * sizeof( float ) ); - /* Fill old buffers with zeros */ - for ( i = 0; i < SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[0]; i++ ) - { - SfxSpatBin_p->LeftOldBuffer[i] = 0.0f; - SfxSpatBin_p->RightOldBuffer[i] = 0.0f; - } - break; - case 32000: - SfxSpatBin_p->MaxTargetTime = TDREND_SRC_REND_MaxTargetTimes[1]; - SfxSpatBin_p->MaxBlockLength = TDREND_SRC_REND_MaxBlockLengths[1]; - SfxSpatBin_p->LeftOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[1] ) * sizeof( float ) ); - SfxSpatBin_p->RightOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[1] ) * sizeof( float ) ); - /* Fill old buffers with zeros */ - for ( i = 0; i < SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[1]; i++ ) - { - SfxSpatBin_p->LeftOldBuffer[i] = 0.0f; - SfxSpatBin_p->RightOldBuffer[i] = 0.0f; - } - break; - case 48000: - SfxSpatBin_p->MaxTargetTime = TDREND_SRC_REND_MaxTargetTimes[2]; - SfxSpatBin_p->MaxBlockLength = TDREND_SRC_REND_MaxBlockLengths[2]; - SfxSpatBin_p->LeftOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[2] ) * sizeof( float ) ); - SfxSpatBin_p->RightOldBuffer = count_malloc( ( SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[2] ) * sizeof( float ) ); - /* Fill old buffers with zeros */ - for ( i = 0; i < SFX_SPAT_BIN_SINC_M * 4 + 2 * TDREND_MaxITD[2]; i++ ) - { - SfxSpatBin_p->LeftOldBuffer[i] = 0.0f; - SfxSpatBin_p->RightOldBuffer[i] = 0.0f; - } - break; -#ifdef DEBUGGING - default: - IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Error: Unrecognised output_Fs in TDREND_SFX_SpatBin_Initialize()" ); -#endif - } - - /* Fill the beginning of the resampled buffers with zeros */ - for ( i = 0; i < SFX_SPAT_BIN_MAX_FILTER_LENGTH; i++ ) - { - SfxSpatBin_p->ResampledBufferLeft[i] = 0.0f; - SfxSpatBin_p->ResampledBufferRight[i] = 0.0f; - } - - return IVAS_ERR_OK; -} - - -/*-------------------------------------------------------------------* - * TDREND_SFX_SpatBin_Clear() - * - * Clear spatial parameters - * - --------------------------------------------------------------------*/ - -static void TDREND_SFX_SpatBin_Clear( - SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ - const int32_t output_Fs /* i : Output sample rate */ -) -{ - int16_t i; - int16_t MaxITD = TDREND_MaxITD[2]; - - SfxSpatBin_p->OpMode = SFX_OFF; - SfxSpatBin_p->TurningOffEffect = FALSE; - SfxSpatBin_p->TurningOnEffect = FALSE; - - /* Init during next SetParams-call */ - SfxSpatBin_p->InitializeParams = TRUE; - - /* Fill old buffers with zeros */ - switch ( output_Fs ) - { - case 16000: - MaxITD = TDREND_MaxITD[0]; - break; - case 32000: - MaxITD = TDREND_MaxITD[1]; - break; - case 48000: - MaxITD = TDREND_MaxITD[2]; - break; - } - for ( i = 0; i < SFX_SPAT_BIN_SINC_M * 4 + 2 * MaxITD; i++ ) - { - SfxSpatBin_p->LeftOldBuffer[i] = 0.0f; - SfxSpatBin_p->RightOldBuffer[i] = 0.0f; - } - /* Fill the beginning of the resampled buffers with zeros */ - for ( i = 0; i < SFX_SPAT_BIN_MAX_FILTER_LENGTH; i++ ) - { - SfxSpatBin_p->ResampledBufferLeft[i] = 0.0f; - SfxSpatBin_p->ResampledBufferRight[i] = 0.0f; - } - - return; -} - - -/*-------------------------------------------------------------------* - * TDREND_FirFilterRev() - * - * FIR filtering function with reversed filter sequence. - * The FIR filter seqeunce is reversed, i.e. - * FirFilterRev(n) = FirFilter(N-1-n) for n=0:N-1 - * The first N-1 samples of the input buffer store the last N-1 - * samples from the previous input buffer. - * - --------------------------------------------------------------------*/ - -static void TDREND_FirFilterRev( - float *OutputFrame_p, /* o : Filtered samples */ - float *FirFilterRev_p, /* i/o: Reversed FIR filter */ - const int16_t FirFilterLength, /* i : Filter length */ - float *InputFrame_p, /* i : Input samples */ - const int16_t NumOfSamples /* i : Number of input samples */ -) -{ - /* In this function we assume that the last FirFilterLength-1 samples from */ - /* the previous InputBuffer starts this new InputBuffer. */ - int16_t n, k; - int16_t FirFilterLengthMinusOne; - float Acc; - float *InputBuffer_nk_p, *InputBuffer_n_p, *FirFilterRev_k_p, *OutputBuffer_n_p; - - FirFilterLengthMinusOne = FirFilterLength - 1; - - /* 1. Filter the input buffer. NOTE: Reversed filter sequence */ - InputBuffer_n_p = InputFrame_p; - OutputBuffer_n_p = OutputFrame_p; - - for ( n = NumOfSamples; n > 0; n-- ) - { - - Acc = 0.0f; - FirFilterRev_k_p = FirFilterRev_p; - InputBuffer_nk_p = InputBuffer_n_p; - - for ( k = FirFilterLength; k > 0; k-- ) - { - Acc += *( FirFilterRev_k_p++ ) * *( InputBuffer_nk_p++ ); - } - - InputBuffer_n_p++; - *( OutputBuffer_n_p++ ) = Acc; - } - - /* 2. Copy the last FirFilterLength-1 samples of the InputFrame to the beginning of the InputFrame */ - mvr2r( InputFrame_p + NumOfSamples, InputFrame_p, FirFilterLengthMinusOne ); - - return; -} - -#ifdef TDREND_HRTF_TABLE_METHODS -/*-------------------------------------------------------------------* - * TDREND_FirFilterRevInterp() - * - * FIR filtering function with reversed filter sequence. - * The FIR filter seqeunce is reversed, i.e. - * FirFilterRev(n) = FirFilter(N-1-n) for n=0:N-1 - * The first N-1 samples of the input buffer store the last N-1 - * samples from the previous input buffer. - * - --------------------------------------------------------------------*/ - -static void TDREND_FirFilterRevInterp( - float *OutputFrame_p, /* o : Filtered samples */ - float *FirFilterRev_p, /* i/o: Reversed FIR filter */ - const int16_t FirFilterLength, /* i : Filter length */ - float *InputFrame_p, /* i : Input samples */ - const int16_t NumOfSamples, /* i : Number of input samples */ - float *FilterStored /* i/o: Old filter memory for interpolation */ -) -{ - /* In this function we assume that the last FirFilterLength-1 samples from */ - /* the previous InputBuffer starts this new InputBuffer. */ - int16_t n, k; - int16_t FirFilterLengthMinusOne; - float Acc1; - float Acc2; - - float *InputBuffer_nk_p, *InputBuffer_n_p, *FirFilterRev_k_p, *OutputBuffer_n_p; - float interpFactor, interpComplement; - float *FilterStored_n_p; - float inv_NumOfSamples; - - FirFilterLengthMinusOne = FirFilterLength - 1; - inv_NumOfSamples = 1.0f / NumOfSamples; - - /* 1. Filter the input buffer */ - /* NOTE: Reversed filter sequence */ - InputBuffer_n_p = InputFrame_p; - OutputBuffer_n_p = OutputFrame_p; - - interpFactor = 1.0f; - interpComplement = 0.0f; - for ( n = NumOfSamples; n > 0; n-- ) - { - - Acc1 = 0.0f; - Acc2 = 0.0f; - FirFilterRev_k_p = FirFilterRev_p; - FilterStored_n_p = FilterStored; - InputBuffer_nk_p = InputBuffer_n_p; - - for ( k = FirFilterLength; k > 0; k-- ) - { - Acc1 += *( FirFilterRev_k_p++ ) * *( InputBuffer_nk_p ); - Acc2 += *( FilterStored_n_p++ ) * *( InputBuffer_nk_p++ ); - } - - InputBuffer_n_p++; - *( OutputBuffer_n_p++ ) = Acc1 * interpComplement + Acc2 * interpFactor; - interpFactor -= inv_NumOfSamples; - interpComplement += inv_NumOfSamples; - } - - /* Store the old filter for interpolation next time */ - for ( k = 0; k < FirFilterLength; k++ ) - { - FilterStored[k] = FirFilterRev_p[k]; - } - - /* 2. Copy the last FirFilterLength-1 samples of the InputFrame to */ - /* the beginning of the InputFrame */ - mvr2r( InputFrame_p + NumOfSamples, InputFrame_p, FirFilterLengthMinusOne ); - - return; -} -#endif -#endif - -#ifdef FIX_ITD /*---------------------------------------------------------------------* * TDREND_Apply_ITD() * @@ -1677,5 +269,3 @@ void TDREND_firfilt( return; } - -#endif diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index fa645f1492f6d3800f3b76e856d0b4e63e67689c..d3f3df30fac361920bad46f9f70f2859c403d433 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -50,14 +50,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); -#ifndef FIX_ITD -static void TDREND_SRC_REND_Dealloc( TDREND_SRC_REND_t *SrcRend_p ); -#endif -#ifdef FIX_ITD static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p ); -#else -static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p, const int32_t output_Fs ); -#endif /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPos() @@ -197,70 +190,11 @@ static ivas_error TDREND_SRC_REND_Alloc( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "SrcRend_p allocation error\n" ) ); } -#ifndef FIX_ITD - /* Allocate the HR filtering structures */ - SrcRend_p->SfxSpatBin_p = (SFX_SpatBin_t *) count_malloc( SPAT_BIN_MAX_INPUT_CHANNELS * sizeof( SFX_SpatBin_t ) ); - if ( SrcRend_p->SfxSpatBin_p == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "SrcRend_p->SfxSpatBin_p allocation error\n" ) ); - } -#endif *SrcRend_pp = SrcRend_p; return IVAS_ERR_OK; } -#ifndef FIX_ITD -/*-------------------------------------------------------------------* - * TDREND_SRC_REND_Dealloc() - * - * Deallocate rendering aspects of source. - --------------------------------------------------------------------*/ - -static void TDREND_SRC_REND_Dealloc( - TDREND_SRC_REND_t *SrcRend_p /* i/o: Source object */ -) -{ - if ( SrcRend_p == NULL ) - { - return; - } - if ( SrcRend_p->SfxSpatBin_p->LeftOldBuffer != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->LeftOldBuffer ); - } - if ( SrcRend_p->SfxSpatBin_p->RightOldBuffer != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->RightOldBuffer ); - } - if ( SrcRend_p->SfxSpatBin_p->LeftFilter_p != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->LeftFilter_p ); - } - if ( SrcRend_p->SfxSpatBin_p->LeftFilterIncr_p != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->LeftFilterIncr_p ); - } - if ( SrcRend_p->SfxSpatBin_p->RightFilter_p != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->RightFilter_p ); - } - if ( SrcRend_p->SfxSpatBin_p->RightFilterIncr_p != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p->RightFilterIncr_p ); - } - if ( SrcRend_p->SfxSpatBin_p != NULL ) - { - count_free( SrcRend_p->SfxSpatBin_p ); - } - - /* Free the SrcRend_p variable */ - count_free( SrcRend_p ); - SrcRend_p = NULL; - - return; -} -#endif /*-------------------------------------------------------------------* * TDREND_SRC_REND_Init() @@ -269,12 +203,7 @@ static void TDREND_SRC_REND_Dealloc( --------------------------------------------------------------------*/ static void TDREND_SRC_REND_Init( -#ifdef FIX_ITD TDREND_SRC_REND_t *SrcRend_p /* i/o: Source object */ -#else - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - const int32_t output_Fs /* i : Output sampling rate */ -#endif ) { int16_t nC; @@ -302,13 +231,6 @@ static void TDREND_SRC_REND_Init( SrcRend_p->DistGain_p[nC] = 1.0f; } -#ifndef FIX_ITD - /* Init the SfxSpatBin structs. One per channel. Default is effect turned off. */ - for ( nC = 0; nC < SPAT_BIN_MAX_INPUT_CHANNELS; nC++ ) - { - TDREND_SFX_SpatBin_Initialize( SrcRend_p->SfxSpatBin_p + nC, output_Fs ); - } -#endif return; } @@ -324,62 +246,32 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ -#ifdef FIX_ITD - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ -#else - const int32_t output_Fs /* i : Output sampling rate */ -#endif + float *hrf_left_prev, /* o: Left filter */ + float *hrf_right_prev, /* o: Right filter */ + float *hrf_left_delta, /* o: Left filter interpolation delta */ + float *hrf_right_delta, /* o: Right filter interpolation delta */ + int16_t *intp_count, /* o: Interpolation count */ + int16_t *filterlength, /* o: Length of filters */ + int16_t *itd, /* o: ITD value */ + float *Gain, /* o: Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ) { TDREND_MIX_Listener_t *Listener_p; TDREND_HRFILT_FiltSet_t *HrFiltSet_p; -#ifndef FIX_ITD - SFX_SpatBin_t *SfxSpatBin_p; - SFX_SpatBin_Params_t SfxSpatBinParams; -#endif float ListRelPos[3], ListRelDist; -#ifndef FIX_ITD - float Gain; -#endif float Azim, Elev; -#ifndef FIX_ITD - int16_t mem_size; -#else float hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; float hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; float azim_delta; float elev_delta; -#endif /* Evaluate the HR filters from the source and listener positions and orientations */ Listener_p = hBinRendererTd->Listener_p; HrFiltSet_p = hBinRendererTd->HrFiltSet_p; -#ifdef FIX_ITD *filterlength = HrFiltSet_p->FiltLength; -#else - SfxSpatBinParams.LeftFilter_p = NULL; - SfxSpatBinParams.RightFilter_p = NULL; - - mem_size = (int16_t) ( HrFiltSet_p->FiltLength * sizeof( float ) ); - - SfxSpatBin_p = SrcRend_p->SfxSpatBin_p; - SfxSpatBinParams.TurnOn = TRUE; - SfxSpatBinParams.Reset = FALSE; - - SfxSpatBinParams.FilterLength = HrFiltSet_p->FiltLength; - SfxSpatBinParams.LeftFilter_p = (float *) count_malloc( mem_size ); - SfxSpatBinParams.RightFilter_p = (float *) count_malloc( mem_size ); -#endif /* 1. Map source pos to the coordinate system of the listener */ switch ( SrcSpatial_p->PosType ) @@ -416,11 +308,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( Azim = -1.0f * _180_OVER_PI * (float) atan2f( ListRelPos[1], ListRelPos[0] ); } -#ifdef FIX_ITD GetFilterFromAngle( HrFiltSet_p, Elev, Azim, hrf_left, hrf_right, itd ); -#else - GetFilterFromAngle( HrFiltSet_p, Elev, Azim, &SfxSpatBinParams ); -#endif /* 6. Evaluate the directional and distance gains */ /* Directional gain */ @@ -449,7 +337,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( } /* Update total gains */ -#ifdef FIX_ITD *Gain = ( *SrcRend_p->SrcGain_p ) * ( *SrcRend_p->DirGain_p ) * ( *SrcRend_p->DistGain_p ) * hBinRendererTd->Gain; /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ @@ -477,27 +364,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( set_f( hrf_left_delta, 0.0f, *filterlength ); set_f( hrf_right_delta, 0.0f, *filterlength ); } -#else - Gain = ( *SrcRend_p->SrcGain_p ) * ( *SrcRend_p->DirGain_p ) * ( *SrcRend_p->DistGain_p ) * hBinRendererTd->Gain; - SfxSpatBinParams.LeftVolume = Gain; - SfxSpatBinParams.RightVolume = Gain; - - /* Reset source gain update flag (That update is now included in the total gain update) */ - SrcRend_p->SrcGainUpdated = FALSE; - - /* Update the rendering parameters of the SFX effect */ - TDREND_SFX_SpatBin_SetParams( SfxSpatBin_p, &SfxSpatBinParams, output_Fs ); - - if ( SfxSpatBinParams.LeftFilter_p != NULL ) - { - count_free( SfxSpatBinParams.LeftFilter_p ); - } - - if ( SfxSpatBinParams.RightFilter_p != NULL ) - { - count_free( SfxSpatBinParams.RightFilter_p ); - } -#endif return; } @@ -772,12 +638,8 @@ void TDREND_SRC_Dealloc( TDREND_SRC_SPATIAL_Dealloc( Src_p->SrcSpatial_p ); /* Delloc the TDREND_SRC_REND__t variable */ -#ifdef FIX_ITD count_free( Src_p->SrcRend_p ); Src_p->SrcRend_p = NULL; -#else - TDREND_SRC_REND_Dealloc( Src_p->SrcRend_p ); -#endif /* Free the Src_p variable */ count_free( Src_p ); @@ -794,13 +656,8 @@ void TDREND_SRC_Dealloc( --------------------------------------------------------------------*/ void TDREND_SRC_Init( - TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ -#ifdef FIX_ITD + TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ const TDREND_PosType_t PosType /* i : Position type specifier */ -#else - const TDREND_PosType_t PosType, /* i : Position type specifier */ - const int32_t output_Fs /* i : Output sampling rate */ -#endif ) { /* Init the TDREND_SRC_Spatial_t variable */ @@ -810,13 +667,8 @@ void TDREND_SRC_Init( } /* Init the TDREND_SRC_REND_t variable */ -#ifdef FIX_ITD TDREND_SRC_REND_Init( Src_p->SrcRend_p ); -#else - TDREND_SRC_REND_Init( Src_p->SrcRend_p, output_Fs ); -#endif -#ifdef FIX_ITD /* Reset memory buffers */ Src_p->itd = 0; Src_p->previtd = 0; @@ -832,7 +684,6 @@ void TDREND_SRC_Init( Src_p->azim_prev = 0.0f; Src_p->elev_prev = 0.0f; -#endif return; } diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 4f647922c59e5640e517b9ecf1518e59b89c446b..773cd57effd7991925df20ed6793027d4e5035da 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -361,7 +361,6 @@ const uint32_t ls_LFE_last_idx_CICP19[12] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, /* Downmix matrices */ const float ls_conversion_cicpX_mono[12][1] = { -#ifdef FIX_REND_MONO_DMX {1.00000000f}, {1.00000000f}, {1.00000000f}, @@ -374,20 +373,6 @@ const float ls_conversion_cicpX_mono[12][1] = {0.849999964f}, {0.849999964f}, {0.849999964f} -#else - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, - {1.00000000f}, -#endif }; const float ls_conversion_cicpX_stereo[12][2] = diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 0c28a3d4324e2862cbf3be85def952d6950ecfd9..92284a7451e523c9dc999ed4e15266d20e005220 100755 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -305,35 +305,22 @@ void ivas_ism2sba( for ( i = 0; i < num_objects; i++ ) { -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f ); -#else - azimuth = (int16_t) ( hIsmMetaData[i]->azimuth + 0.5f ); - elevation = (int16_t) ( hIsmMetaData[i]->elevation + 0.5f ); -#endif /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order ); for ( j = 0; j < sba_num_chans; j++ ) { -#ifdef FIX_REND_ISM_XFADE g1 = 1.f; -#endif g2 = 0.f; for ( k = 0; k < output_frame; k++ ) { -#ifdef FIX_REND_ISM_XFADE buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k]; g2 += 1.f / ( output_frame - 1 ); g1 = 1.0f - g2; -#else - g2 += 1.f / output_frame; - g1 = 1.0f - g2; - buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k]; -#endif } hIsmRendererData->prev_gains[i][j] = gains[j]; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 179b8214b58a531a40a312459f3de508b9dcac11..f682a0731f2be910dd4601ce6a5d879f1b92049e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1198,11 +1198,9 @@ static ivas_error initMcPanGainsWithMonoOut( { int16_t i; int16_t numInChannels; -#ifdef FIX_REND_MONO_DMX int16_t readIdx; int16_t writeIdx; bool skipSideSpeakers; -#endif ivas_error error; if ( ( error = getRendInputNumChannels( inputMc, &numInChannels ) ) != IVAS_ERR_OK ) @@ -1210,7 +1208,6 @@ static ivas_error initMcPanGainsWithMonoOut( return error; } -#ifdef FIX_REND_MONO_DMX if ( inputMc->base.inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { for ( i = 0; i < numInChannels; ++i ) @@ -1246,14 +1243,6 @@ static ivas_error initMcPanGainsWithMonoOut( inputMc->panGains[writeIdx][0] = ls_conversion_cicpX_mono[readIdx][0]; } } -#else - for ( i = 0; i < numInChannels; ++i ) - { - /* It's OK to also set gain 1 for LFE input channels here. - * Correct LFE handling will be applied within updateMcPanGains() */ - inputMc->panGains[i][0] = 1.f; - } -#endif return IVAS_ERR_OK; } @@ -1516,27 +1505,6 @@ static ivas_error updateMcPanGains( return IVAS_ERR_OK; } -#ifndef FIX_ITD -#ifndef FIX_I81 -/* Fixes initialization issues in TD renderer. Fix to be merged with branch. - See issue: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/issues/81 */ -static void tmpFixBuggyTdBinRendInit( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ) -{ - int16_t i, j; - - for ( i = 0; i < hBinRendererTd->NumOfSrcs; ++i ) - { - for ( j = 0; j < SPAT_BIN_MAX_INPUT_CHANNELS; ++j ) - { - hBinRendererTd->Sources[i]->SrcRend_p->SfxSpatBin_p[j].LeftFilter_p = NULL; - hBinRendererTd->Sources[i]->SrcRend_p->SfxSpatBin_p[j].LeftFilterIncr_p = NULL; - hBinRendererTd->Sources[i]->SrcRend_p->SfxSpatBin_p[j].RightFilter_p = NULL; - hBinRendererTd->Sources[i]->SrcRend_p->SfxSpatBin_p[j].RightFilterIncr_p = NULL; - } - } -} -#endif -#endif static ivas_error initMcBinauralRendering( input_mc *inputMc, @@ -1557,12 +1525,10 @@ static ivas_error initMcBinauralRendering( { ivas_rend_closeCrend( &inputMc->crendWrapper ); } -#ifdef FIX_REND_ROT_MC_BIN if ( inputMc->efapInWrapper.hEfap != NULL ) { efap_free_data( &inputMc->efapInWrapper.hEfap ); } -#endif outSampleRate = *inputMc->base.ctx.pOutSampleRate; @@ -1588,11 +1554,6 @@ static ivas_error initMcBinauralRendering( { return error; } -#ifndef FIX_ITD -#ifndef FIX_I81 - tmpFixBuggyTdBinRendInit( inputMc->tdRendWrapper.hBinRendererTd ); -#endif -#endif } { @@ -1606,13 +1567,11 @@ static ivas_error initMcBinauralRendering( } } -#ifdef FIX_REND_ROT_MC_BIN /* Initialise the EFAP handle for rotation on input layout */ if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled ) { initEfap( &inputMc->efapInWrapper, inConfig, NULL ); } -#endif return error; } @@ -3700,9 +3659,6 @@ static ivas_error renderIsmToBinaural( ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, outAudio.config.numSamplesPerChannel, -#ifndef FIX_ITD - *ismInput->base.ctx.pOutSampleRate, -#endif tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -3824,8 +3780,7 @@ static ivas_error renderIsmToMc( wmops_sub_start( "renderIsmToMc" ); -/* TODO(sgi): Possible optimization: less processing needed if position didn't change */ -#ifdef FIX_REND_ISM_STEREO_PANNING + /* TODO(sgi): Possible optimization: less processing needed if position didn't change */ if ( *ismInput->base.ctx.pOutConfig == IVAS_REND_AUDIO_CONFIG_STEREO ) { set_zero( currentPanGains, 16 ); @@ -3841,29 +3796,20 @@ static ivas_error renderIsmToMc( &previousPanGains[1] ); } else -#endif { -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, (int16_t) floorf( ismInput->currentPos.azimuth + 0.5f ), (int16_t) floorf( ismInput->currentPos.elevation + 0.5f ), currentPanGains ) ) != IVAS_ERR_OK ) -#else - if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, ismInput->currentPos.azimuth, ismInput->currentPos.elevation, currentPanGains ) ) != IVAS_ERR_OK ) -#endif { return error; } -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, (int16_t) floorf( ismInput->previousPos.azimuth + 0.5f ), (int16_t) floorf( ismInput->previousPos.elevation + 0.5f ), previousPanGains ) ) != IVAS_ERR_OK ) -#else - if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, ismInput->previousPos.azimuth, ismInput->previousPos.elevation, previousPanGains ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -3900,15 +3846,11 @@ static ivas_error renderIsmToSba( return error; } -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved ivas_dirac_dec_get_response( (int16_t) floorf( ismInput->previousPos.azimuth + 0.5f ), (int16_t) floorf( ismInput->previousPos.elevation + 0.5f ), previousPanGains, ambiOrderOut ); -#else - ivas_dirac_dec_get_response( (int16_t) ismInput->previousPos.azimuth, (int16_t) ismInput->previousPos.elevation, previousPanGains, ambiOrderOut ); -#endif if ( ( ismInput->currentPos.azimuth == ismInput->previousPos.azimuth ) && ( ismInput->currentPos.elevation == ismInput->previousPos.elevation ) ) @@ -3917,15 +3859,11 @@ static ivas_error renderIsmToSba( } else { -#ifdef FIX_REND_ISM_POS_ROUNDING // TODO tmu review when #215 is resolved ivas_dirac_dec_get_response( (int16_t) floorf( ismInput->currentPos.azimuth + 0.5f ), (int16_t) floorf( ismInput->currentPos.elevation + 0.5f ), currentPanGains, ambiOrderOut ); -#else - ivas_dirac_dec_get_response( (int16_t) ismInput->currentPos.azimuth, (int16_t) ismInput->currentPos.elevation, currentPanGains, ambiOrderOut ); -#endif } /* Assume num channels in audio buffer to be 1. @@ -4092,9 +4030,6 @@ static ivas_error renderMcToBinaural( mcInput->base.ctx.pHeadRotData, NULL, mcInput->base.inputBuffer.config.numSamplesPerChannel, -#ifndef FIX_ITD - *mcInput->base.ctx.pOutSampleRate, -#endif tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; diff --git a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c index 948da8a4259ed4da853bdd6ca0da696a6753f972..3727aeec5be6c4faa609661f42c9c442fed9d536 100644 --- a/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c +++ b/scripts/td_object_renderer/object_renderer_standalone/object_renderer_standalone/renderer_standalone.c @@ -115,9 +115,6 @@ int main( int argc, char *argv[] ) { int16_t nFrameLength; int16_t n, nS, nSamplesRead, i, j; -#ifndef FIX_ITD - int16_t offset; -#endif float *MixFrame; float output[MAX_CICP_CHANNELS][L_FRAME48k]; @@ -381,17 +378,13 @@ int main( int argc, char *argv[] ) { output[nS][n] = input_buff[nChannels * n + nS]; } -#ifdef FIX_ITD /* Pad to full frame length */ for ( ; n < nFrameLength; n++ ) { output[nS][n] = 0; } -#endif } -#ifdef FIX_ITD currFrameLength = nFrameLength; -#endif if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -447,32 +440,13 @@ int main( int argc, char *argv[] ) ivas_limiter_dec( st_ivas->hLimiter, output, st_ivas->hDecoderConfig->nchan_out, nFrameLength, FALSE ); -#ifndef FIX_ITD - /* Trim first frame to compensate for delay */ - if ( nFrameCount == 0 ) - { - offset = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / 200 ); /* 240 samples for 48kHz etc */ - } - else - { - offset = 0; - } -#endif /* For Wav: Interleave, convert to int16_t */ -#ifdef FIX_ITD for ( n = 0; n < currFrameLength; n++ ) -#else - for ( n = 0; n < ( currFrameLength - offset ); n++ ) -#endif { for ( nS = 0; nS < NumLdspks; nS++ ) { -#ifdef FIX_ITD tmp = output[nS][n] + 0.5f * sign( output[nS][n] ); -#else - tmp = output[nS][n + offset] + 0.5f * sign( output[nS][n + offset] ); -#endif if ( tmp > MAX16B_FLT ) { tmp = MAX16B_FLT; @@ -486,11 +460,7 @@ int main( int argc, char *argv[] ) MixFrameWav[n * NumLdspks + nS] = (int16_t) ( tmp ); } } -#ifdef FIX_ITD fwrite( MixFrameWav, sizeof( int16_t ), ( currFrameLength ) * NumLdspks, f_output ); -#else - fwrite( MixFrameWav, sizeof( int16_t ), ( currFrameLength - offset ) * NumLdspks, f_output ); -#endif nFrameCount++;