From beac45cea6abdbea12b2fc9d9f36608767097796 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 24 Jul 2023 09:35:35 +0200 Subject: [PATCH 01/33] initial support for parambin renderer in split rendering in decoder. switch: SPLIT_REND_WITH_HEAD_ROT_PARAMBIN --- lib_com/options.h | 3 + lib_dec/ivas_dec.c | 19 + lib_dec/ivas_dirac_dec.c | 79 +- lib_dec/ivas_init_dec.c | 46 +- lib_dec/ivas_ism_dec.c | 9 +- lib_dec/ivas_ism_param_dec.c | 13 + lib_dec/ivas_masa_dec.c | 39 + lib_dec/ivas_mct_dec.c | 8 + lib_dec/ivas_sba_dec.c | 21 + lib_dec/ivas_stat_dec.h | 4 + lib_rend/ivas_dirac_dec_binaural_functions.c | 1003 ++++++++++++++--- lib_rend/lib_rend.c | 22 +- tests/split_rendering/test_split_rendering.py | 8 +- 13 files changed, 1120 insertions(+), 154 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b35772ecc1..e8a5a8b4d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -211,6 +211,9 @@ #define FIX_622_SILENCE_USAN_WARNING /* FhG: silenceusan warning in ifft code */ #define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/ +#define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ +#define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT /* Nokia: Issue 623: Split rendering support for parambin renderer, computational optimization */ + /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5ca878a00e..e945f04525 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -124,10 +124,20 @@ ivas_error ivas_dec( if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN assert( ( st_ivas->ivas_format == SBA_FORMAT || + st_ivas->ivas_format == MASA_FORMAT || + st_ivas->ivas_format == ISM_FORMAT || + st_ivas->ivas_format == MC_FORMAT ) && + ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, MASA, discrete and parametric ISM, or MC formats and 48 kHz sampling rate only" ); +#else + assert( ( st_ivas->ivas_format == SBA_FORMAT || + st_ivas->ivas_format == MASA_FORMAT || + st_ivas->ivas_format == ISM_FORMAT || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCMASA ) ) && ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, discrete ISM, or MCT-MC formats and 48 kHz sampling rate only" ); +#endif ivas_set_split_rend_setup( &st_ivas->splitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ); } #endif @@ -845,6 +855,11 @@ ivas_error ivas_dec( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend; int16_t max_band; int16_t pcm_out; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t td_input; + + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; +#endif hSplitBinRend = &st_ivas->splitBinRend; max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; @@ -857,7 +872,11 @@ ivas_error ivas_dec( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, max_band, output, 1, +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + td_input, +#else st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV, +#endif pcm_out ); free( st_ivas->splitBinRend.hMultiBinCldfbData ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 766f4ff08f..3e9987e5da 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -826,7 +826,11 @@ ivas_error ivas_dirac_dec_config( if ( !need_parambin ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } need_dirac_rend = 0; @@ -870,13 +874,48 @@ ivas_error ivas_dirac_dec_config( { if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + /* populate pMultiBinPoseData with the additional poses determined from the DoF */ + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &st_ivas->splitBinRend.splitrend.multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + } +#endif if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } - +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + /* TODO: can we keep isRenderingInTd fixed? */ + ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, + 0, /* isRenderingInTd */ + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* pcm_out */ + + error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, + &st_ivas->hRenderConfig->split_rend_config, + st_ivas->hDecoderConfig->output_Fs, + 1, /* is_cldfb_in */ + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* is_pcm_out */ + + if ( error != IVAS_ERR_OK ) + { + return error; + } + } +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0] == NULL ) +#else if ( st_ivas->hDiracDecBin == NULL ) +#endif { if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { @@ -886,24 +925,55 @@ ivas_error ivas_dirac_dec_config( else { /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) +#else if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ); +#else ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + /* copy td-decorr flag to split renderer side rendereres */ + for ( int16_t pos_idx = 1; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; + } + + if ( !st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( !st_ivas->hDiracDecBin->useTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) +#else if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params == NULL ) +#endif { float frequency_axis[CLDFB_NO_CHANNELS_MAX]; ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), + &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), +#else if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), +#endif st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, @@ -917,7 +987,14 @@ ivas_error ivas_dirac_dec_config( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( int16_t pos_idx = 0; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + } +#else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif } } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 616069f25f..2087e7c9e4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1319,6 +1319,16 @@ ivas_error ivas_init_decoder( /* ParamISM is handled separately from other common config */ else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &st_ivas->splitBinRend.splitrend.multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + } +#endif if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) @@ -1331,6 +1341,26 @@ ivas_error ivas_init_decoder( { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { +#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING + error = +#endif + ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, + &st_ivas->hRenderConfig->split_rend_config, + hDecoderConfig->output_Fs, + 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); + +#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING + if ( error != IVAS_ERR_OK ) + { + return error; + } +#endif + } +#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -1820,7 +1850,14 @@ void ivas_initialize_handles_dec( st_ivas->splitBinRend.hSplitRendBits = NULL; ivas_init_split_rend_handles( &st_ivas->splitBinRend.splitrend ); #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + st_ivas->hDiracDecBin[i] = NULL; + } +#else st_ivas->hDiracDecBin = NULL; +#endif st_ivas->hDirACRend = NULL; st_ivas->hSpatParamRendCom = NULL; st_ivas->hLsSetUpConversion = NULL; @@ -1984,7 +2021,11 @@ void ivas_destroy_dec( #endif /* Parametric binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Crend handle */ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) @@ -2103,8 +2144,11 @@ void ivas_init_dec_get_num_cldfb_instances( { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { *numCldfbAnalyses += 2; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index fa5783d90a..95cf886cb3 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -178,8 +178,11 @@ static ivas_error ivas_ism_bitrate_switching( #endif { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); - +#endif /* Open the TD Binaural renderer */ if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) { @@ -221,7 +224,11 @@ static ivas_error ivas_ism_bitrate_switching( #endif { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Open Crend Binaural renderer */ if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 4662304a4a..1e8b2f3083 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -386,7 +386,11 @@ static ivas_error ivas_param_ism_rendering_init( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM) ) +#else if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { /* computation of proto matrix */ ivas_ism_get_proto_matrix( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix ); @@ -540,8 +544,13 @@ ivas_error ivas_param_ism_dec_open( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || + output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) ) +#endif { /* Initialize efap handle */ if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth, hOutSetup.ls_elevation, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) @@ -559,7 +568,11 @@ ivas_error ivas_param_ism_dec_open( hSpatParamRendCom->dirac_read_idx = 0; hDirAC->spar_to_dirac_write_idx = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 4a6053ccd5..ca48e4bdf2 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -971,6 +971,9 @@ ivas_error ivas_masa_dec_reconfigure( int32_t ivas_total_brate, last_ivas_total_brate; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t pos_idx; +#endif error = IVAS_ERR_OK; @@ -982,7 +985,11 @@ ivas_error ivas_masa_dec_reconfigure( /* renderer might have changed, reselect */ ivas_renderer_select( st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend == NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] == NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend == NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin == NULL ) ) +#endif { /* init a new DirAC dec */ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) @@ -995,7 +1002,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDirAC != NULL ) { /* close all unnecessary parametric decoding and rendering */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); @@ -1019,7 +1030,11 @@ ivas_error ivas_masa_dec_reconfigure( sts[0]->bit_stream = bit_stream + num_bits; num_bits += (int16_t) ( st_ivas->hSCE[sce_id]->element_brate / FRAMES_PER_SEC ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) +#else if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1046,7 +1061,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->nchan_out = 1; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1058,7 +1077,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->nchan_out = CPE_CHANNELS; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1068,10 +1091,22 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + if ( st_ivas->hDiracDecBin[pos_idx] != NULL ) + { +#else if ( st_ivas->hDiracDecBin != NULL ) { +#endif /* regularization factor is bitrate-dependent */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + } +#else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif } /*-----------------------------------------------------------------* @@ -1149,7 +1184,11 @@ void ivas_spar_param_to_masa_param_mapping( hDirAC = st_ivas->hDirAC; hSpatParamRendCom = st_ivas->hSpatParamRendCom; hSpatParamRendCom->numSimultaneousDirections = 1; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; /* TODO: this may need to use different pose indices */ +#else hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; +#endif nchan_transport = st_ivas->nchan_transport; band_grouping = hDirAC->band_grouping; hSpar = st_ivas->hSpar; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index e99cf63fa6..f31aff2327 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1161,11 +1161,19 @@ static ivas_error ivas_mc_dec_reconfig( ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0] != NULL ) +#else if ( st_ivas->hDiracDecBin != NULL ) +#endif { if ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 763a1b222f..5659a96b24 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -357,12 +357,21 @@ ivas_error ivas_sba_dec_reconfigure( * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0] != NULL ) + { + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hDiracDecBin != NULL ) { if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } +#endif } /*-----------------------------------------------------------------* @@ -450,7 +459,11 @@ ivas_error ivas_sba_dec_digest_tc( ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0] != NULL && ( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) +#else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) +#endif { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; @@ -468,9 +481,17 @@ ivas_error ivas_sba_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->hTdDecorr ) +#else if ( st_ivas->hDiracDecBin->hTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_td_decorr_process( st_ivas->hDiracDecBin[0]->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#endif } for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5c70409ac2..003a45056c 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -997,7 +997,11 @@ typedef struct Decoder_Struct BINAURAL_RENDERER_HANDLE hBinRenderer; /* fastconv binaural renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; /* Time domain binaural object renderer handle */ TDREND_HRFILT_FiltSet_t *hHrtfTD; /* pointer to HRTF data for TD renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; /* parametric binaural renderer handle */ +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; /* parametric binaural renderer handle */ +#endif LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; /* MC LS configuration convertion handle */ EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8a3f33b80b..258a8bf7d8 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -95,11 +95,26 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, const int16_t isHeadtracked, float *subFrameTotalEne, float *IIReneLimiter ); +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter ); +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked ); +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t isHeadtracked ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN +static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], + float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe, + float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const uint8_t recompute ); +#else static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe ); +#endif static void adaptTransportSignalsHeadtracked( COMBINED_ORIENTATION_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, const int16_t nSlots, float Rmat[3][3] ); @@ -138,143 +153,169 @@ ivas_error ivas_dirac_dec_init_binaural_data( float binCenterFreq, tmpFloat; ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ ) + { + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; +#else hDiracDecBin = st_ivas->hDiracDecBin; +#endif - if ( hDiracDecBin == NULL ) - { - if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + if ( hDiracDecBin == NULL ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + } + + hDiracDecBin->hTdDecorr = NULL; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; } - hDiracDecBin->hTdDecorr = NULL; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; - } + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + renderer_type = st_ivas->renderer_type; - output_Fs = st_ivas->hDecoderConfig->output_Fs; - nBins = st_ivas->hSpatParamRendCom->num_freq_bands; - renderer_type = st_ivas->renderer_type; + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + for ( k = 0; k < BINAURAL_CHANNELS + 1; k++ ) + { + set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); + } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; k < BINAURAL_CHANNELS + 1; k++ ) + for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + { + set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + } + set_zero( hDiracDecBin->ChEnePrev[j], nBins ); + set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); + } + set_zero( hDiracDecBin->ChCrossRePrev, nBins ); + set_zero( hDiracDecBin->ChCrossImPrev, nBins ); + set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); + set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; + + + for ( bin = 0; bin < nBins; bin++ ) { - set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); + binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); + /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ + tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); + hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); } - for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) { - set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + hDiracDecBin->diffuseFieldCoherenceX[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceX[bin]; + hDiracDecBin->diffuseFieldCoherenceY[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceY[bin]; + hDiracDecBin->diffuseFieldCoherenceZ[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceZ[bin]; } - set_zero( hDiracDecBin->ChEnePrev[j], nBins ); - set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); - } - set_zero( hDiracDecBin->ChCrossRePrev, nBins ); - set_zero( hDiracDecBin->ChCrossImPrev, nBins ); - set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); - set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; + if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + } + else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ + { + mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); - for ( bin = 0; bin < nBins; bin++ ) - { - binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); - /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); - hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); - } + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ + if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || + ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) + { + ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + } - for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) - { - hDiracDecBin->diffuseFieldCoherenceX[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceX[bin]; - hDiracDecBin->diffuseFieldCoherenceY[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceY[bin]; - hDiracDecBin->diffuseFieldCoherenceZ[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceZ[bin]; - } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ +#else + if ( hDiracDecBin->hReverb == NULL ) +#endif + { + if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, + nBins, + CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, + st_ivas->hIntSetup.output_config, + output_Fs, + RENDERER_BINAURAL_PARAMETRIC_ROOM, + st_ivas->hHrtfFastConv, + st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; + } + else /* Not valid renderer type for this renderer */ + { + assert( false ); + } - if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - } - else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ - { - mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); + hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ + + if ( hDiracDecBin->hTdDecorr == NULL ) + { + hDiracDecBin->useTdDecorr = 0; + } - /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ - if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || - ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) + if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) { - ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } - if ( hDiracDecBin->hReverb == NULL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( pos_idx == 0) /* open decorrelator only for the main direction */ { - if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, - nBins, - CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, - st_ivas->hIntSetup.output_config, - output_Fs, - RENDERER_BINAURAL_PARAMETRIC_ROOM, - st_ivas->hHrtfFastConv, - st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) +#endif + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } + if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) + { + ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis, + BINAURAL_CHANNELS, + output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN } - } - else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; - } - else /* Not valid renderer type for this renderer */ - { - assert( false ); - } - - hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ - - if ( hDiracDecBin->hTdDecorr == NULL ) - { - hDiracDecBin->useTdDecorr = 0; - } - - if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); - } - - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) - { - ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - output_Fs ) ) != IVAS_ERR_OK ) + else { - return error; + hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ } - } +#endif - hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin; + } +#else st_ivas->hDiracDecBin = hDiracDecBin; +#endif /* allocate transport channels*/ if ( st_ivas->hDecoderConfig->voip_active == 1 && st_ivas->hTcBuffer == NULL ) @@ -302,11 +343,31 @@ void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t pos_idx; +#endif if ( hBinaural == NULL || *hBinaural == NULL ) { return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + if ( hBinaural[pos_idx] != NULL ) + { + if ( hBinaural[pos_idx]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + } + + ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); + + free( hBinaural[pos_idx] ); + hBinaural[pos_idx] = NULL; + } + } +#else if ( ( *hBinaural )->hReverb != NULL ) { ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); @@ -320,6 +381,7 @@ void ivas_dirac_dec_close_binaural_data( free( *hBinaural ); *hBinaural = NULL; +#endif return; } @@ -423,6 +485,7 @@ void ivas_dirac_dec_binaural_render( { int16_t n_samples_sf = slot_size * hSpatParamRendCom->subframe_nbslots[subframe_idx]; ivas_dirac_dec_binaural_internal( st_ivas, st_ivas->hCombinedOrientationData, output_f_local, nchan_transport, subframe_idx ); + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] += n_samples_sf; @@ -519,8 +582,11 @@ void ivas_dirac_dec_binaural( { ivas_spar_dec_set_render_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); } - +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { float *decorr_signal[BINAURAL_CHANNELS]; int16_t output_frame; @@ -532,7 +598,11 @@ void ivas_dirac_dec_binaural( } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_td_decorr_process( st_ivas->hDiracDecBin[0]->hTdDecorr, p_output, decorr_signal, output_frame ); +#else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); +#endif } if ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) @@ -588,13 +658,31 @@ static void ivas_dirac_dec_binaural_internal( int16_t nBins, offsetSamples; int16_t i, j; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t pos_idx; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + float tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */ + float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + float IIReneLimiter[CLDFB_NO_CHANNELS_MAX]; +#endif + + hDiracDecBin = st_ivas->hDiracDecBin[0]; +#else hDiracDecBin = st_ivas->hDiracDecBin; +#endif assert( hDiracDecBin ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; offsetSamples = hSpatParamRendCom->slots_rendered * nBins; - /* Setuo internal config */ + /* Setup internal config */ config_data.separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; config_data.ivas_format = st_ivas->ivas_format; config_data.mc_mode = st_ivas->mc_mode; @@ -726,7 +814,6 @@ static void ivas_dirac_dec_binaural_internal( hDiracDecBin->hDiffuseDist = &diffuseDistData; ivas_spar_param_to_masa_param_mapping( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); - ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); } @@ -742,14 +829,19 @@ static void ivas_dirac_dec_binaural_internal( if ( nchan_transport == 2 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ +#endif adaptTransportSignalsHeadtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); } } +#ifndef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); +#endif if ( config_data.ivas_format == ISM_FORMAT ) { @@ -764,13 +856,121 @@ static void ivas_dirac_dec_binaural_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT + ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne, IIReneLimiter ); +#else + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); +#endif +#endif ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); - ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + pMultiBinPoseData = &st_ivas->splitBinRend.splitrend.multiBinPoseData; + + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + mvr2r(tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + mvr2r(tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + } + } + } + else + { + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, NULL, NULL, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + } +#endif hDiracDecBin->hDiffuseDist = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ + IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; + float Rmat_local[3][3]; + + if ( hCombinedOrientationData ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Quaternions_rot.w = -3.0f; /* signal to use Euler */ + Quaternions_abs.w = -3.0f; /* signal to use Euler */ + Quat2EulerDegree( *Quaternions_ref, &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + for ( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + Quaternions_rot.x = Quaternions_abs.x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_rot.y = Quaternions_abs.y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_rot.z = Quaternions_abs.z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + + QuatToRotMat( Quaternions_rot, Rmat_local ); + + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; + assert(hDiracDecBin != NULL && "No DiracDecBin handle for this position"); + if ( config_data.ivas_format == SBA_FORMAT ) + { + hDiracDecBin->hDiffuseDist = &diffuseDistData; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT + /* re-use input covariance for the side renderings */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + mvr2r(st_ivas->hDiracDecBin[0]->ChEne[ch], hDiracDecBin->ChEne[ch], hSpatParamRendCom->num_freq_bands); + } + mvr2r(st_ivas->hDiracDecBin[0]->ChCrossRe, hDiracDecBin->ChCrossRe, hSpatParamRendCom->num_freq_bands); + mvr2r(st_ivas->hDiracDecBin[0]->ChCrossIm, hDiracDecBin->ChCrossIm, hSpatParamRendCom->num_freq_bands); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne, IIReneLimiter ); + +#else + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); +#endif + + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); + + /* re-use reverb and decorr from main direction for the sides */ + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, + decorrRe, decorrIm, 0); + + /* copy from temporary buffer to the main split rendering buffer */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + mvr2r(tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + mvr2r(tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + } + } + + hDiracDecBin->hDiffuseDist = NULL; + } + } + } + /* update this counter only after the last rendering of split directions */ +#endif hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe]; hSpatParamRendCom->subframes_rendered++; @@ -832,36 +1032,29 @@ static void ivas_dirac_dec_decorrelate_slot( return; } - -static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float Rmat[3][3], const int16_t subframe, - const int16_t isHeadtracked ) + const int16_t isHeadtracked, + float *subFrameTotalEne, + float *IIReneLimiter ) { int16_t ch, slot, bin; - int16_t separateCenterChannelRendering; - int16_t nBins, idx; - float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + int16_t nBins; float IIReneLimiterFactor; float qualityBasedSmFactor; float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; uint8_t applyLowBitRateEQ; - int16_t dirac_read_idx; - float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; - PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; IVAS_FORMAT ivas_format; - MC_MODE mc_mode; int32_t ivas_total_brate; int16_t nchan_transport; - separateCenterChannelRendering = hConfig->separateCenterChannelRendering; ivas_format = hConfig->ivas_format; - mc_mode = hConfig->mc_mode; ivas_total_brate = hConfig->ivas_total_brate; nchan_transport = hConfig->nchan_transport; qualityBasedSmFactor = hConfig->qualityBasedSmFactor; @@ -870,20 +1063,9 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric set_zero( hDiracDecBin->ChCrossRe, nBins ); set_zero( hDiracDecBin->ChCrossIm, nBins ); - set_zero( hDiracDecBin->ChCrossReOut, nBins ); - set_zero( hDiracDecBin->ChCrossImOut, nBins ); for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { set_zero( hDiracDecBin->ChEne[ch], nBins ); - set_zero( hDiracDecBin->ChEneOut[ch], nBins ); - } - set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); - - set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); - - for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) - { - gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ } /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ @@ -909,7 +1091,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Formulate input and target covariance matrices for this subframe */ set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); - dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; /* Calculate input covariance matrix */ for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) @@ -964,6 +1145,96 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric } } + /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ + if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); + } + else + { + IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); + } + for ( bin = 0; bin < nBins; bin++ ) + { + float eneRatio; + + /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that + * the energy history (IIR) must not be more than double of the current frame energy. This provides more + * robust performance at energy offsets when compared to typical IIR averaging. */ + eneRatio = ( hDiracDecBin->ChEne[0][bin] + hDiracDecBin->ChEne[1][bin] ) / fmaxf( 1e-12f, ( hDiracDecBin->ChEnePrev[0][bin] + hDiracDecBin->ChEnePrev[1][bin] ) ); + IIReneLimiter[bin] = fminf( 1.0f, eneRatio * IIReneLimiterFactor ); + + hDiracDecBin->ChCrossRe[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossIm[bin] *= qualityBasedSmFactor; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] *= qualityBasedSmFactor; + } + + hDiracDecBin->ChCrossRe[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossRePrev[bin]; + hDiracDecBin->ChCrossIm[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossImPrev[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] += IIReneLimiter[bin] * hDiracDecBin->ChEnePrev[ch][bin]; + } + + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossRePrev[bin] = hDiracDecBin->ChCrossRe[bin]; + hDiracDecBin->ChCrossImPrev[bin] = hDiracDecBin->ChCrossIm[bin]; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEnePrev[ch][bin] = hDiracDecBin->ChEne[ch][bin]; + } + } + + return; +} + +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + PARAMBIN_REND_CONFIG_HANDLE hConfig, + float Rmat[3][3], + const int16_t subframe, + const int16_t isHeadtracked, + const float *subFrameTotalEne, + const float *IIReneLimiter ) +{ + int16_t ch, bin; + int16_t separateCenterChannelRendering; + int16_t nBins, idx; + float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + float qualityBasedSmFactor; + int16_t dirac_read_idx; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + MC_MODE mc_mode; + + separateCenterChannelRendering = hConfig->separateCenterChannelRendering; + ivas_format = hConfig->ivas_format; + mc_mode = hConfig->mc_mode; + qualityBasedSmFactor = hConfig->qualityBasedSmFactor; + qualityBasedSmFactor *= qualityBasedSmFactor; + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + + set_zero( hDiracDecBin->ChCrossReOut, nBins ); + set_zero( hDiracDecBin->ChCrossImOut, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( hDiracDecBin->ChEneOut[ch], nBins ); + } + set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); + + set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); + + for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) + { + gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ + } + + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + /* Determine target covariance matrix containing target binaural properties */ for ( bin = 0; bin < nBins; bin++ ) { @@ -1187,14 +1458,400 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric hDiracDecBin->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); } - /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ - if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) - { - IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); - } - else + for ( bin = 0; bin < nBins; bin++ ) { - IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); + hDiracDecBin->ChCrossReOut[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossImOut[bin] *= qualityBasedSmFactor; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEneOut[ch][bin] *= qualityBasedSmFactor; + } + + hDiracDecBin->ChCrossReOut[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossReOutPrev[bin]; + hDiracDecBin->ChCrossImOut[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossImOutPrev[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEneOut[ch][bin] += IIReneLimiter[bin] * hDiracDecBin->ChEneOutPrev[ch][bin]; + } + + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossReOutPrev[bin] = hDiracDecBin->ChCrossReOut[bin]; + hDiracDecBin->ChCrossImOutPrev[bin] = hDiracDecBin->ChCrossImOut[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEneOutPrev[ch][bin] = hDiracDecBin->ChEneOut[ch][bin]; + } + } + + return; +} + +#else +static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + PARAMBIN_REND_CONFIG_HANDLE hConfig, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float Rmat[3][3], + const int16_t subframe, + const int16_t isHeadtracked ) +{ + int16_t ch, slot, bin; + int16_t separateCenterChannelRendering; + int16_t nBins, idx; + float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + float IIReneLimiterFactor; + float qualityBasedSmFactor; + float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; + uint8_t applyLowBitRateEQ; + int16_t dirac_read_idx; + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + MC_MODE mc_mode; + int32_t ivas_total_brate; + int16_t nchan_transport; + + separateCenterChannelRendering = hConfig->separateCenterChannelRendering; + ivas_format = hConfig->ivas_format; + mc_mode = hConfig->mc_mode; + ivas_total_brate = hConfig->ivas_total_brate; + nchan_transport = hConfig->nchan_transport; + qualityBasedSmFactor = hConfig->qualityBasedSmFactor; + qualityBasedSmFactor *= qualityBasedSmFactor; + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + + set_zero( hDiracDecBin->ChCrossRe, nBins ); + set_zero( hDiracDecBin->ChCrossIm, nBins ); + set_zero( hDiracDecBin->ChCrossReOut, nBins ); + set_zero( hDiracDecBin->ChCrossImOut, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( hDiracDecBin->ChEne[ch], nBins ); + set_zero( hDiracDecBin->ChEneOut[ch], nBins ); + } + set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); + + set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); + + for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) + { + gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ + } + + /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ + applyLowBitRateEQ = 0; + if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + applyLowBitRateEQ = 1; + if ( ivas_total_brate == IVAS_16k4 ) + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin] * 0.5f + 0.5f; + } + } + else + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin]; + } + } + } + + /* Formulate input and target covariance matrices for this subframe */ + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + + /* Calculate input covariance matrix */ + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float instEne; + + instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); + instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + hDiracDecBin->ChEne[ch][bin] += instEne; + subFrameTotalEne[bin] += instEne; + } + hDiracDecBin->ChCrossRe[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; + hDiracDecBin->ChCrossRe[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] += inRe[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] -= inIm[0][slot][bin] * inRe[1][slot][bin]; + } + } + + /* Apply EQ at low bit rates */ + if ( applyLowBitRateEQ ) + { + int16_t lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; + + for ( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[bin]; + } + for ( ; bin < nBins; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[lastEqBin]; + } + } + + if ( ivas_format == SBA_FORMAT && nchan_transport == 2 ) + { + float tempRe, tempIm; + + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + tempRe = inRe[0][slot][bin] + inRe[1][slot][bin]; + tempIm = inIm[0][slot][bin] + inIm[1][slot][bin]; + subFrameTotalEne[bin] += tempRe * tempRe + tempIm * tempIm; + } + } + } + + /* Determine target covariance matrix containing target binaural properties */ + for ( bin = 0; bin < nBins; bin++ ) + { + float diffuseness = 1.0f; /* ratio1 and ratio2 are subtracted from diffuseness further below */ + float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */ + float diffEne, dirEne, meanEnePerCh; + int16_t dirIndex; + + /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. + * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the + * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match + * the early spectrum of the BRIR data, using the spectral correction data in + * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ + meanEnePerCh = hDiracDecBin->earlyPartEneCorrection[bin] * subFrameTotalEne[bin] / 2.0f; + + /* Determine direct part target covariance matrix (for 1 or 2 directions) */ + for ( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) + { + int16_t aziDeg, eleDeg; + float lRealp, lImagp, rRealp, rImagp; + float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; + float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; + + if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ + { + aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; + ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence[dirac_read_idx][bin]; + } + else /* For second of the two simultaneous directions */ + { + if ( ( ratio = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) + { + /* This touches only MASA path where second direction always has smaller ratio and + * for non-2dir it is zero. As the whole direction contribution is multiplied with + * the ratio, a very small ratio does not contribute any energy to output. Thus, + * it is better to save complexity. */ + continue; + } + aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence2[dirac_read_idx][bin]; + } + diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ + + if ( separateCenterChannelRendering ) + { + /* In masa + mono rendering mode, the center directions originate from phantom sources, so the + * spread coherence is increased */ + float aziRad, eleRad, doaVectorX, spatialAngleDeg, altSpreadCoh; + + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + doaVectorX = cosf( aziRad ) * cosf( eleRad ); + spatialAngleDeg = acosf( doaVectorX ) * _180_OVER_PI; + altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); + spreadCoh = max( spreadCoh, altSpreadCoh ); + } + + getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 )], isHeadtracked ); + + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* Synthesizing spread coherence is not needed for stereo loudspeaker output, + * as directional sound is reproduced with two loudspeakers in any case */ + spreadCoh = 0.0f; + } + + if ( spreadCoh > 0.0f ) + { + float centerMul, sidesMul; + float hrtfEneCenter, hrtfEneSides, hrtfEneRealized, eneCorrectionFactor; + float w1, w2, w3, eq; + + hrtfEneCenter = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + + /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. + * The following formulas determine the gains for these sources. + * spreadCoh = 0: Only panning + * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) + * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ + if ( spreadCoh < 0.5f ) + { + /* 0.0f < spreadCoh < 0.5f */ + sidesMul = 0.5774f * spreadCoh * 2.0f; /* sqrt(1/3) = 0.5774f */ + centerMul = 1.0f - ( spreadCoh * 2.0f ) + sidesMul; + } + else + { + /* 0.5f <= spreadCoh < 1.0f */ + centerMul = 2.0f - ( 2.0f * spreadCoh ); + sidesMul = inv_sqrt( centerMul + 2.0f ); + centerMul *= sidesMul; + } + + /* Apply the gain for the center source of the three coherent sources */ + lRealp *= centerMul; + lImagp *= centerMul; + rRealp *= centerMul; + rImagp *= centerMul; + + /* Apply the gain for the left source of the three coherent sources */ + getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 1 )], isHeadtracked ); + + hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Apply the gain for the right source of the three coherent sources. + * -30 degrees to 330 wrapping due to internal functions. */ + getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 2 )], isHeadtracked ); + + hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ + hrtfEneRealized = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + eneCorrectionFactor = ( ( hrtfEneSides * sidesMul * sidesMul ) + + ( hrtfEneCenter * centerMul * centerMul ) ) / + max( 1e-12f, hrtfEneRealized ); + + /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ + if ( spreadCoh < 0.5 ) + { + w1 = 1.0f - 2.0f * spreadCoh; + w2 = 2.0f * spreadCoh; + w3 = 0.0f; + } + else + { + w1 = 0.0f; + w2 = 2.0f - 2.0f * spreadCoh; + w3 = 2.0f * spreadCoh - 1.0f; + } + + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + + /* Apply the target spectrum to the eneCorrectionFactor */ + if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ + { + eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; + } + else + { + eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; + } + } + + /* Equalize the spread coherent combined HRTFs */ + eq = min( 4.0f, sqrtf( eneCorrectionFactor ) ); + lRealp *= eq; + lImagp *= eq; + rRealp *= eq; + rImagp *= eq; + } + + hrtfEne[0] = ( lRealp * lRealp ) + ( lImagp * lImagp ); + hrtfEne[1] = ( rRealp * rRealp ) + ( rImagp * rImagp ); + hrtfCrossRe = ( lRealp * rRealp ) + ( lImagp * rImagp ); + hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); + + /* Add direct part (1 or 2) covariance matrix */ + dirEne = ratio * meanEnePerCh; + hDiracDecBin->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ + hDiracDecBin->ChEneOut[1][bin] += dirEne * hrtfEne[1]; + hDiracDecBin->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ + hDiracDecBin->ChCrossImOut[bin] += dirEne * hrtfCrossIm; /* Dir cross im */ + } + + /* Add diffuse / ambient part covariance matrix */ + diffuseness = max( 0.0f, diffuseness ); + diffEne = diffuseness * meanEnePerCh; + surCoh = hSpatParamRendCom->surroundingCoherence[dirac_read_idx][bin]; + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) + { + if ( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ + diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; + } + } + hDiracDecBin->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ + hDiracDecBin->ChEneOut[1][bin] += diffEne; + + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ + hDiracDecBin->ChCrossReOut[bin] += surCoh * diffEne; + } + else /* When rendering binaural, ambience has frequency dependent ICC. */ + { + if ( ivas_format == SBA_FORMAT && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) + { + float diffuseFieldCoherence; + diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin]; + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * diffuseFieldCoherence + surCoh ) * diffEne; + } + else + { + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * hDiracDecBin->diffuseFieldCoherence[bin] + surCoh ) * diffEne; + } + } + + /* Store parameters for formulating average diffuseness over frame */ + hDiracDecBin->frameMeanDiffuseness[bin] += diffEne; + frameMeanDiffusenessEneWeight[bin] += meanEnePerCh; + } + + /* Formulate average diffuseness over frame */ + for ( bin = 0; bin < nBins; bin++ ) + { + hDiracDecBin->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); + } + + /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ + if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); + } + else + { + IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); } for ( bin = 0; bin < nBins; bin++ ) { @@ -1243,7 +1900,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric return; } - +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, @@ -1436,14 +2093,27 @@ static void ivas_dirac_dec_binaural_process_output( const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, - const int16_t subframe ) + const int16_t subframe +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + , + float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const uint8_t recompute +#endif + ) { int16_t slot, bin, chA, chB; int16_t nBins; float outSlotRe[CLDFB_NO_CHANNELS_MAX], outSlotIm[CLDFB_NO_CHANNELS_MAX]; float decSlotRe[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], decSlotIm[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; +#ifndef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif float interpVal; float *decSlotRePointer; float *decSlotImPointer; @@ -1457,7 +2127,14 @@ static void ivas_dirac_dec_binaural_process_output( if ( processReverb ) { /* Process second / room effect part of binaural output when needed */ - ivas_binaural_reverb_processSubframe( hDiracDecBin->hReverb, numInChannels, nSlots, inRe, inIm, reverbRe, reverbIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( recompute == 1 ) + { +#endif + ivas_binaural_reverb_processSubframe( hDiracDecBin->hReverb, numInChannels, nSlots, inRe, inIm, reverbRe, reverbIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + } +#endif } interpVal = 0.0f; @@ -1466,7 +2143,27 @@ static void ivas_dirac_dec_binaural_process_output( interpVal += 1.0f / (float) nSlots; if ( !hDiracDecBin->useTdDecorr && max_band_decorr > 0 ) { - ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( recompute == 1 ) + { +#endif + ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + mvr2r(decSlotRe[chA], decorrRe[chA][slot], CLDFB_NO_CHANNELS_MAX); + mvr2r(decSlotIm[chA], decorrIm[chA][slot], CLDFB_NO_CHANNELS_MAX); + } + } + else + { + for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + mvr2r(decorrRe[chA][slot], decSlotRe[chA], CLDFB_NO_CHANNELS_MAX); + mvr2r(decorrIm[chA][slot], decSlotIm[chA], CLDFB_NO_CHANNELS_MAX); + } + } +#endif } for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -1531,8 +2228,22 @@ static void ivas_dirac_dec_binaural_process_output( outSlotRePr = &( outSlotRe[0] ); outSlotImPr = &( outSlotIm[0] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( outRe != NULL && outIm != NULL ) + { + /* provide the data outside in CLDFB domain => mainly for split rendering */ + mvr2r(outSlotRePr, outRe[chA][slot], CLDFB_NO_CHANNELS_MAX); + mvr2r(outSlotImPr, outIm[chA][slot], CLDFB_NO_CHANNELS_MAX); + } + if ( recompute == 1 ) + { + /* Inverse filter bank */ + cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( output_f[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); + } +#else /* Inverse filter bank */ cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( output_f[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); +#endif } } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c8c4cabc3b..473ea1c24e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3244,7 +3244,14 @@ static DecoderDummy *initDecoderDummy( decDummy->hoa_dec_mtx = NULL; decDummy->hVBAPdata = NULL; // note: not used at the moment decDummy->hMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + decDummy->hDiracDecBin[i] = NULL; + } +#else decDummy->hDiracDecBin = NULL; +#endif decDummy->hDirACRend = NULL; decDummy->hSpatParamRendCom = NULL; decDummy->hQMetaData = NULL; @@ -3370,7 +3377,9 @@ static ivas_error setRendInputActiveMasa( { inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); inputMasa->metadataHasBeenFed = false; - +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + inputMasa->decDummy->hRenderConfig = hRendCfg; +#endif if ( ( error = updateMasaDummyDec( inputMasa, outConfig ) ) != IVAS_ERR_OK ) { return error; @@ -3455,7 +3464,11 @@ static void freeDecoderDummy( free( pDecDummy->hHrtfParambin ); /* Parametric binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( pDecDummy->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &pDecDummy->hDiracDecBin ); +#endif /* TC buffer */ ivas_jbm_dec_tc_buffer_close( &pDecDummy->hTcBuffer ); @@ -8101,6 +8114,13 @@ static ivas_error renderInputMasa( //#endif // renderMasaToBinauralRoom( masaInput, outConfig, outAudio ); // break; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + /* TODO: implement */ + renderMasaToBinaural( masaInput, outAudio ); + break; +#endif default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 76f114b689..3d93ee980a 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -37,8 +37,8 @@ from tests.split_rendering.utils import * @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") + if in_fmt in ("MONO", "STEREO",): + pytest.xfail("Split Rendering currently not supported with MONO or STEREO") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -56,8 +56,8 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") + if in_fmt in ("MONO", "STEREO",): + pytest.xfail("Split Rendering currently not supported with MONO or STEREO") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -- GitLab From c4a81ef0fa284dc56991e40d1061e61ec1370b4e Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 24 Jul 2023 09:38:45 +0200 Subject: [PATCH 02/33] remove switch SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT --- lib_com/options.h | 1 - lib_rend/ivas_dirac_dec_binaural_functions.c | 429 ------------------- 2 files changed, 430 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e8a5a8b4d1..1566e2d7b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -212,7 +212,6 @@ #define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/ #define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN /* Nokia: Issue 623: Split rendering support for parambin renderer */ -#define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT /* Nokia: Issue 623: Split rendering support for parambin renderer, computational optimization */ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 258a8bf7d8..0d659479f6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -95,12 +95,8 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, const int16_t isHeadtracked, float *subFrameTotalEne, float *IIReneLimiter ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter ); -#else -static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked ); -#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t isHeadtracked ); @@ -668,10 +664,8 @@ static void ivas_dirac_dec_binaural_internal( float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float decorrRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float decorrIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; float IIReneLimiter[CLDFB_NO_CHANNELS_MAX]; -#endif hDiracDecBin = st_ivas->hDiracDecBin[0]; #else @@ -857,17 +851,12 @@ static void ivas_dirac_dec_binaural_internal( } #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter ); -#else - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); -#endif #endif ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); @@ -927,7 +916,6 @@ static void ivas_dirac_dec_binaural_internal( hDiracDecBin->hDiffuseDist = &diffuseDistData; } -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT /* re-use input covariance for the side renderings */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -940,10 +928,6 @@ static void ivas_dirac_dec_binaural_internal( hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter ); -#else - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat_local, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); -#endif ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0 ); @@ -1032,7 +1016,6 @@ static void ivas_dirac_dec_decorrelate_slot( return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1489,418 +1472,6 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( return; } -#else -static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( - DIRAC_DEC_BIN_HANDLE hDiracDecBin, - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, - PARAMBIN_REND_CONFIG_HANDLE hConfig, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float Rmat[3][3], - const int16_t subframe, - const int16_t isHeadtracked ) -{ - int16_t ch, slot, bin; - int16_t separateCenterChannelRendering; - int16_t nBins, idx; - float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; - float IIReneLimiterFactor; - float qualityBasedSmFactor; - float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; - uint8_t applyLowBitRateEQ; - int16_t dirac_read_idx; - float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; - PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; - IVAS_FORMAT ivas_format; - MC_MODE mc_mode; - int32_t ivas_total_brate; - int16_t nchan_transport; - - separateCenterChannelRendering = hConfig->separateCenterChannelRendering; - ivas_format = hConfig->ivas_format; - mc_mode = hConfig->mc_mode; - ivas_total_brate = hConfig->ivas_total_brate; - nchan_transport = hConfig->nchan_transport; - qualityBasedSmFactor = hConfig->qualityBasedSmFactor; - qualityBasedSmFactor *= qualityBasedSmFactor; - nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ - - set_zero( hDiracDecBin->ChCrossRe, nBins ); - set_zero( hDiracDecBin->ChCrossIm, nBins ); - set_zero( hDiracDecBin->ChCrossReOut, nBins ); - set_zero( hDiracDecBin->ChCrossImOut, nBins ); - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - set_zero( hDiracDecBin->ChEne[ch], nBins ); - set_zero( hDiracDecBin->ChEneOut[ch], nBins ); - } - set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); - - set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); - - for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) - { - gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ - } - - /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ - applyLowBitRateEQ = 0; - if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) - { - applyLowBitRateEQ = 1; - if ( ivas_total_brate == IVAS_16k4 ) - { - for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) - { - lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin] * 0.5f + 0.5f; - } - } - else - { - for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) - { - lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin]; - } - } - } - - /* Formulate input and target covariance matrices for this subframe */ - set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); - dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; - - /* Calculate input covariance matrix */ - for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - for ( bin = 0; bin < nBins; bin++ ) - { - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - float instEne; - - instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); - instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); - hDiracDecBin->ChEne[ch][bin] += instEne; - subFrameTotalEne[bin] += instEne; - } - hDiracDecBin->ChCrossRe[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; - hDiracDecBin->ChCrossRe[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; - hDiracDecBin->ChCrossIm[bin] += inRe[0][slot][bin] * inIm[1][slot][bin]; - hDiracDecBin->ChCrossIm[bin] -= inIm[0][slot][bin] * inRe[1][slot][bin]; - } - } - - /* Apply EQ at low bit rates */ - if ( applyLowBitRateEQ ) - { - int16_t lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; - - for ( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) - { - subFrameTotalEne[bin] *= lowBitRateEQ[bin]; - } - for ( ; bin < nBins; bin++ ) - { - subFrameTotalEne[bin] *= lowBitRateEQ[lastEqBin]; - } - } - - if ( ivas_format == SBA_FORMAT && nchan_transport == 2 ) - { - float tempRe, tempIm; - - set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); - - for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - for ( bin = 0; bin < nBins; bin++ ) - { - tempRe = inRe[0][slot][bin] + inRe[1][slot][bin]; - tempIm = inIm[0][slot][bin] + inIm[1][slot][bin]; - subFrameTotalEne[bin] += tempRe * tempRe + tempIm * tempIm; - } - } - } - - /* Determine target covariance matrix containing target binaural properties */ - for ( bin = 0; bin < nBins; bin++ ) - { - float diffuseness = 1.0f; /* ratio1 and ratio2 are subtracted from diffuseness further below */ - float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */ - float diffEne, dirEne, meanEnePerCh; - int16_t dirIndex; - - /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. - * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the - * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match - * the early spectrum of the BRIR data, using the spectral correction data in - * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ - meanEnePerCh = hDiracDecBin->earlyPartEneCorrection[bin] * subFrameTotalEne[bin] / 2.0f; - - /* Determine direct part target covariance matrix (for 1 or 2 directions) */ - for ( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) - { - int16_t aziDeg, eleDeg; - float lRealp, lImagp, rRealp, rImagp; - float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; - float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; - - if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ - { - aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; - eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; - ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; - spreadCoh = hSpatParamRendCom->spreadCoherence[dirac_read_idx][bin]; - } - else /* For second of the two simultaneous directions */ - { - if ( ( ratio = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) - { - /* This touches only MASA path where second direction always has smaller ratio and - * for non-2dir it is zero. As the whole direction contribution is multiplied with - * the ratio, a very small ratio does not contribute any energy to output. Thus, - * it is better to save complexity. */ - continue; - } - aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; - eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; - spreadCoh = hSpatParamRendCom->spreadCoherence2[dirac_read_idx][bin]; - } - diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ - - if ( separateCenterChannelRendering ) - { - /* In masa + mono rendering mode, the center directions originate from phantom sources, so the - * spread coherence is increased */ - float aziRad, eleRad, doaVectorX, spatialAngleDeg, altSpreadCoh; - - aziRad = (float) aziDeg * PI_OVER_180; - eleRad = (float) eleDeg * PI_OVER_180; - doaVectorX = cosf( aziRad ) * cosf( eleRad ); - spatialAngleDeg = acosf( doaVectorX ) * _180_OVER_PI; - altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); - spreadCoh = max( spreadCoh, altSpreadCoh ); - } - - getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 )], isHeadtracked ); - - if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - /* Synthesizing spread coherence is not needed for stereo loudspeaker output, - * as directional sound is reproduced with two loudspeakers in any case */ - spreadCoh = 0.0f; - } - - if ( spreadCoh > 0.0f ) - { - float centerMul, sidesMul; - float hrtfEneCenter, hrtfEneSides, hrtfEneRealized, eneCorrectionFactor; - float w1, w2, w3, eq; - - hrtfEneCenter = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); - - /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. - * The following formulas determine the gains for these sources. - * spreadCoh = 0: Only panning - * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) - * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ - if ( spreadCoh < 0.5f ) - { - /* 0.0f < spreadCoh < 0.5f */ - sidesMul = 0.5774f * spreadCoh * 2.0f; /* sqrt(1/3) = 0.5774f */ - centerMul = 1.0f - ( spreadCoh * 2.0f ) + sidesMul; - } - else - { - /* 0.5f <= spreadCoh < 1.0f */ - centerMul = 2.0f - ( 2.0f * spreadCoh ); - sidesMul = inv_sqrt( centerMul + 2.0f ); - centerMul *= sidesMul; - } - - /* Apply the gain for the center source of the three coherent sources */ - lRealp *= centerMul; - lImagp *= centerMul; - rRealp *= centerMul; - rImagp *= centerMul; - - /* Apply the gain for the left source of the three coherent sources */ - getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 1 )], isHeadtracked ); - - hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); - lRealp += sidesMul * lRealpTmp; - lImagp += sidesMul * lImagpTmp; - rRealp += sidesMul * rRealpTmp; - rImagp += sidesMul * rImagpTmp; - - /* Apply the gain for the right source of the three coherent sources. - * -30 degrees to 330 wrapping due to internal functions. */ - getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 2 )], isHeadtracked ); - - hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); - lRealp += sidesMul * lRealpTmp; - lImagp += sidesMul * lImagpTmp; - rRealp += sidesMul * rRealpTmp; - rImagp += sidesMul * rImagpTmp; - - /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ - hrtfEneRealized = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); - eneCorrectionFactor = ( ( hrtfEneSides * sidesMul * sidesMul ) + - ( hrtfEneCenter * centerMul * centerMul ) ) / - max( 1e-12f, hrtfEneRealized ); - - /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ - if ( spreadCoh < 0.5 ) - { - w1 = 1.0f - 2.0f * spreadCoh; - w2 = 2.0f * spreadCoh; - w3 = 0.0f; - } - else - { - w1 = 0.0f; - w2 = 2.0f - 2.0f * spreadCoh; - w3 = 2.0f * spreadCoh - 1.0f; - } - - if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) - { - idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); - - /* Apply the target spectrum to the eneCorrectionFactor */ - if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ - { - eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; - } - else - { - eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; - } - } - - /* Equalize the spread coherent combined HRTFs */ - eq = min( 4.0f, sqrtf( eneCorrectionFactor ) ); - lRealp *= eq; - lImagp *= eq; - rRealp *= eq; - rImagp *= eq; - } - - hrtfEne[0] = ( lRealp * lRealp ) + ( lImagp * lImagp ); - hrtfEne[1] = ( rRealp * rRealp ) + ( rImagp * rImagp ); - hrtfCrossRe = ( lRealp * rRealp ) + ( lImagp * rImagp ); - hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); - - /* Add direct part (1 or 2) covariance matrix */ - dirEne = ratio * meanEnePerCh; - hDiracDecBin->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ - hDiracDecBin->ChEneOut[1][bin] += dirEne * hrtfEne[1]; - hDiracDecBin->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ - hDiracDecBin->ChCrossImOut[bin] += dirEne * hrtfCrossIm; /* Dir cross im */ - } - - /* Add diffuse / ambient part covariance matrix */ - diffuseness = max( 0.0f, diffuseness ); - diffEne = diffuseness * meanEnePerCh; - surCoh = hSpatParamRendCom->surroundingCoherence[dirac_read_idx][bin]; - if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) - { - if ( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); - /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ - diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; - } - } - hDiracDecBin->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ - hDiracDecBin->ChEneOut[1][bin] += diffEne; - - if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ - hDiracDecBin->ChCrossReOut[bin] += surCoh * diffEne; - } - else /* When rendering binaural, ambience has frequency dependent ICC. */ - { - if ( ivas_format == SBA_FORMAT && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) - { - float diffuseFieldCoherence; - diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin]; - hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * diffuseFieldCoherence + surCoh ) * diffEne; - } - else - { - hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * hDiracDecBin->diffuseFieldCoherence[bin] + surCoh ) * diffEne; - } - } - - /* Store parameters for formulating average diffuseness over frame */ - hDiracDecBin->frameMeanDiffuseness[bin] += diffEne; - frameMeanDiffusenessEneWeight[bin] += meanEnePerCh; - } - - /* Formulate average diffuseness over frame */ - for ( bin = 0; bin < nBins; bin++ ) - { - hDiracDecBin->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); - } - - /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ - if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) - { - IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); - } - else - { - IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); - } - for ( bin = 0; bin < nBins; bin++ ) - { - float eneRatio, IIReneLimiter; - - /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that - * the energy history (IIR) must not be more than double of the current frame energy. This provides more - * robust performance at energy offsets when compared to typical IIR averaging. */ - eneRatio = ( hDiracDecBin->ChEne[0][bin] + hDiracDecBin->ChEne[1][bin] ) / fmaxf( 1e-12f, ( hDiracDecBin->ChEnePrev[0][bin] + hDiracDecBin->ChEnePrev[1][bin] ) ); - IIReneLimiter = fminf( 1.0f, eneRatio * IIReneLimiterFactor ); - - hDiracDecBin->ChCrossRe[bin] *= qualityBasedSmFactor; - hDiracDecBin->ChCrossIm[bin] *= qualityBasedSmFactor; - hDiracDecBin->ChCrossReOut[bin] *= qualityBasedSmFactor; - hDiracDecBin->ChCrossImOut[bin] *= qualityBasedSmFactor; - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEne[ch][bin] *= qualityBasedSmFactor; - hDiracDecBin->ChEneOut[ch][bin] *= qualityBasedSmFactor; - } - - hDiracDecBin->ChCrossRe[bin] += IIReneLimiter * hDiracDecBin->ChCrossRePrev[bin]; - hDiracDecBin->ChCrossIm[bin] += IIReneLimiter * hDiracDecBin->ChCrossImPrev[bin]; - hDiracDecBin->ChCrossReOut[bin] += IIReneLimiter * hDiracDecBin->ChCrossReOutPrev[bin]; - hDiracDecBin->ChCrossImOut[bin] += IIReneLimiter * hDiracDecBin->ChCrossImOutPrev[bin]; - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEne[ch][bin] += IIReneLimiter * hDiracDecBin->ChEnePrev[ch][bin]; - hDiracDecBin->ChEneOut[ch][bin] += IIReneLimiter * hDiracDecBin->ChEneOutPrev[ch][bin]; - } - - /* Store energy values and coefficients for next round */ - hDiracDecBin->ChCrossRePrev[bin] = hDiracDecBin->ChCrossRe[bin]; - hDiracDecBin->ChCrossImPrev[bin] = hDiracDecBin->ChCrossIm[bin]; - hDiracDecBin->ChCrossReOutPrev[bin] = hDiracDecBin->ChCrossReOut[bin]; - hDiracDecBin->ChCrossImOutPrev[bin] = hDiracDecBin->ChCrossImOut[bin]; - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEnePrev[ch][bin] = hDiracDecBin->ChEne[ch][bin]; - hDiracDecBin->ChEneOutPrev[ch][bin] = hDiracDecBin->ChEneOut[ch][bin]; - } - } - - return; -} -#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, -- GitLab From 63d92d3df743fadd67dacf00f271d830b6466cc5 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 24 Jul 2023 10:11:19 +0200 Subject: [PATCH 03/33] remove unused parameter --- lib_rend/ivas_dirac_dec_binaural_functions.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0d659479f6..e77fabf73c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -95,7 +95,7 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); -static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, const int16_t isHeadtracked, float *subFrameTotalEne, float *IIReneLimiter ); +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter ); static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t isHeadtracked ); @@ -852,7 +852,6 @@ static void ivas_dirac_dec_binaural_internal( #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, @@ -1023,7 +1022,6 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, - const int16_t isHeadtracked, float *subFrameTotalEne, float *IIReneLimiter ) { -- GitLab From 3381064cace5933c4058dcaf5481c369f7c492d2 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 24 Jul 2023 10:33:04 +0200 Subject: [PATCH 04/33] fix memory leak --- lib_rend/ivas_dirac_dec_binaural_functions.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index e77fabf73c..a408af8d4f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -359,6 +359,11 @@ void ivas_dirac_dec_close_binaural_data( ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); + if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &(hBinaural[pos_idx]->h_freq_domain_decorr_ap_params), &(hBinaural[pos_idx]->h_freq_domain_decorr_ap_state) ); + } + free( hBinaural[pos_idx] ); hBinaural[pos_idx] = NULL; } -- GitLab From 38e787590386f0de9d04ca6dedc75a10c32a1ec2 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 24 Jul 2023 10:39:03 +0200 Subject: [PATCH 05/33] fix double-free in renderer --- lib_rend/lib_rend.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 473ea1c24e..c60a2cdfe6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3377,9 +3377,7 @@ static ivas_error setRendInputActiveMasa( { inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); inputMasa->metadataHasBeenFed = false; -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - inputMasa->decDummy->hRenderConfig = hRendCfg; -#endif + if ( ( error = updateMasaDummyDec( inputMasa, outConfig ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 9b02e1c81ded7b5fcbcc0dafcb0432b7293ee97c Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 24 Jul 2023 23:30:39 +1000 Subject: [PATCH 06/33] split rend MC 160 fixes, CLDFB interface placeholder, finer quantization for pose correction MD --- lib_com/ivas_cnst.h | 19 +++++ lib_com/options.h | 4 +- lib_dec/ivas_binRenderer_internal.c | 102 ++++++++++++++++++++++-- lib_dec/ivas_dec.c | 51 +++--------- lib_dec/ivas_dirac_dec.c | 23 +++++- lib_dec/ivas_init_dec.c | 22 ++++- lib_dec/ivas_rom_dec.c | 104 +++++++++++++++++++++--- lib_dec/ivas_rom_dec.h | 8 ++ lib_dec/ivas_stat_dec.h | 9 +++ lib_dec/lib_dec.c | 58 ++++++++++++++ lib_dec/lib_dec.h | 11 +++ lib_rend/ivas_splitRendererPost.c | 107 +++++++++++++++++++++++-- lib_rend/ivas_splitRendererPre.c | 119 ++++++++++++++++++++++++++-- lib_rend/ivas_splitRenderer_utils.c | 25 ++++++ lib_rend/ivas_stat_rend.h | 12 +++ 15 files changed, 601 insertions(+), 73 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4080485f60..addd0ad017 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1512,6 +1512,9 @@ typedef enum PITCH_ONLY, ANY_ROLL, PRED_ONLY, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + PRED_ROLL_ONLY, +#endif COM_GAIN_ONLY, LR_GAIN_ONLY } IVAS_SPLIT_REND_POSE_TYPE; @@ -1552,7 +1555,13 @@ typedef enum #define IVAS_SPLIT_REND_NUM_QUANT_STRATS (3) +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS +#define IVAS_SPLIT_REND_PRED_63QUANT_PNTS ( 63 ) +#define IVAS_SPLIT_REND_PRED_31QUANT_PNTS ( 31 ) +#define IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS ( 31 ) +#else #define IVAS_SPLIT_REND_PRED_QUANT_PNTS ( 31 ) +#endif #define IVAS_SPLIT_REND_D_QUANT_PNTS ( 15 ) #define IVAS_SPLIT_REND_PRED_MIN_VAL ( -1.4f ) #define IVAS_SPLIT_REND_PRED_MAX_VAL ( 1.4f ) @@ -1563,8 +1572,18 @@ typedef enum #define IVAS_SPLIT_REND_D_MIN_VAL ( 0.0f ) #define IVAS_SPLIT_REND_D_MAX_VAL ( 1.0f ) +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS +#define IVAS_SPLIT_REND_PRED_ROLL_Q_STEP (( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL ) / ( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 )) +#define IVAS_SPLIT_REND_PRED_ROLL_1BYQ_STEP (( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 )/( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL )) +#define IVAS_SPLIT_REND_PRED31_Q_STEP (( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL ) / ( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 )) +#define IVAS_SPLIT_REND_PRED31_1BYQ_STEP (( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 )/( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL )) +#define IVAS_SPLIT_REND_PRED63_Q_STEP (( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL ) / ( IVAS_SPLIT_REND_PRED_63QUANT_PNTS - 1 )) +#define IVAS_SPLIT_REND_PRED63_1BYQ_STEP (( IVAS_SPLIT_REND_PRED_63QUANT_PNTS - 1 )/( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL )) +#else #define IVAS_SPLIT_REND_PRED_Q_STEP (( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL ) / ( IVAS_SPLIT_REND_PRED_QUANT_PNTS - 1 )) #define IVAS_SPLIT_REND_PRED_1BYQ_STEP (( IVAS_SPLIT_REND_PRED_QUANT_PNTS - 1 )/( IVAS_SPLIT_REND_PRED_MAX_VAL - IVAS_SPLIT_REND_PRED_MIN_VAL )) +#endif + #define IVAS_SPLIT_REND_D_Q_STEP (( IVAS_SPLIT_REND_D_MAX_VAL - IVAS_SPLIT_REND_D_MIN_VAL ) / ( IVAS_SPLIT_REND_D_QUANT_PNTS - 1 )) #define IVAS_SPLIT_REND_D_1BYQ_STEP (( IVAS_SPLIT_REND_D_QUANT_PNTS - 1 )/( IVAS_SPLIT_REND_D_MAX_VAL - IVAS_SPLIT_REND_D_MIN_VAL )) #define IVAS_SPLIT_REND_PITCH_G_Q_STEP (( IVAS_SPLIT_REND_PITCH_G_MAX_VAL - IVAS_SPLIT_REND_PITCH_G_MIN_VAL ) / ( IVAS_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 )) diff --git a/lib_com/options.h b/lib_com/options.h index 570d275dd2..5f83da8175 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -195,7 +195,9 @@ #define RENAME_GWLPR /* FhG: Rename clashing symbol */ #define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ - +#ifdef SPLIT_REND_WITH_HEAD_ROT +#define SPLIT_REND_PRED_QUANT_63_PNTS +#endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 1c7372c932..f8d000e429 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1270,8 +1270,8 @@ void ivas_binaural_cldfb( float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #ifdef SPLIT_REND_WITH_HEAD_ROT - float Cldfb_RealBuffer_Binaural[1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1309,6 +1309,33 @@ void ivas_binaural_cldfb( idx_in++; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), + Cldfb_RealBuffer[idx_in][slot_idx], + Cldfb_ImagBuffer[idx_in][slot_idx], + maxBand, st_ivas->cldfbAnaDec[idx_in] ); + idx_in++; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + } + st_ivas->splitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } +#endif + } +#endif } /* Implement binaural rendering */ @@ -1325,6 +1352,44 @@ void ivas_binaural_cldfb( Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t pos_idx; + for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) + { + if ( st_ivas->hIntSetup.num_lfe > 0 ) + { + v_multc( Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); + v_multc( Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); + } + } + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + if ( st_ivas->hIntSetup.num_lfe > 0 ) + { + v_add( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], + Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], + Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], + maxBand ); + v_add( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], + Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], + maxBand ); + } + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + } + } + } + } +#endif + /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1370,8 +1435,8 @@ void ivas_binaural_cldfb_sf( float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #ifdef SPLIT_REND_WITH_HEAD_ROT - float Cldfb_RealBuffer_Binaural[1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1440,6 +1505,25 @@ void ivas_binaural_cldfb_sf( #endif st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + } + } + } + } +#endif + /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1594,7 +1678,15 @@ void ivas_binRenderer( QuatToRotMat( Quaternions_rel, Rmat_local ); - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + { + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } + else + { + rotateFrame_sd_cldfb( Rmat_local, RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[pos_idx], Cldfb_ImagBuffer_Binaural[pos_idx], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, pos_idx ); } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5fa8d4bec4..01b9fc0464 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -124,7 +124,7 @@ ivas_error ivas_dec( assert( ( st_ivas->ivas_format == SBA_FORMAT || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCMASA ) ) && - ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, discrete ISM, or MCT-MC formats and 48 kHz sampling rate only" ); + ( output_Fs == 48000 ) && "split binaural mode is currently not supported with paramteric renderers and 16/32 kHz sampling rates" ); ivas_set_split_rend_setup( &st_ivas->splitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ); } #endif @@ -593,11 +593,16 @@ ivas_error ivas_dec( ivas_mc_paramupmix_dec( st_ivas, output ); /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif { - if ( n != LFE_CHANNEL ) + for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + if ( n != LFE_CHANNEL ) + { + hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } } } @@ -610,45 +615,15 @@ ivas_error ivas_dec( #ifdef JBM_PARAMUPMIX if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#else - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_rend_crendProcessSplitBin( - st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - p_output, - output_Fs ); - } - else - { + if ( ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #endif - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 -#endif - ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef SPLIT_REND_WITH_HEAD_ROT + { ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); } -#endif -#endif /* JBM_PARAMUPMIX */ } +#endif /* JBM_PARAMUPMIX */ else if ( st_ivas->renderer_type == RENDERER_MC ) { if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c1ea3765a2..5bcceab9a5 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2929,6 +2929,25 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx_start + slot_idx], hDirAC->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx_start + slot_idx], hDirAC->num_freq_bands ); + } + } + st_ivas->splitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } + } +#endif + /* Perform binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -2947,11 +2966,7 @@ void ivas_dirac_dec_render_sf( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { int16_t pos_idx; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) -#else for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) -#endif { for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ee15c79faa..fe5b4eca09 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1265,6 +1265,13 @@ ivas_error ivas_init_decoder( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->splitBinRend.splitrend.multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); + if ( st_ivas->splitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + if ( ( st_ivas->splitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } } #endif if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -1486,8 +1493,14 @@ ivas_error ivas_init_decoder( { if ( st_ivas->hBinRenderer->render_lfe ) { - /* Account for filterbank delay */ - binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + { + /* Account for filterbank delay */ + binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + } } else { @@ -1791,6 +1804,7 @@ void ivas_initialize_handles_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->splitBinRend.hMultiBinCldfbData = NULL; st_ivas->splitBinRend.hSplitRendBits = NULL; + st_ivas->splitBinRend.hCldfbDataOut = NULL; ivas_init_split_rend_handles( &st_ivas->splitBinRend.splitrend ); #endif st_ivas->hDiracDecBin = NULL; @@ -1950,6 +1964,10 @@ void ivas_destroy_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural renderer handle */ ivas_split_renderer_close( &st_ivas->splitBinRend.splitrend ); + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + free( st_ivas->splitBinRend.hCldfbDataOut ); + } #endif /* Parametric binaural renderer handle */ diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 5ca2f3fe0f..f89b22022c 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -584,17 +584,95 @@ const int32_t ivas_split_rend_huff_d_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3] = { { 8, 9, 510 },{ 9, 10, 1022 },{ 10, 11, 2046 },{ 11, 12, 4094 }, { 12, 13, 8190 },{ 13, 14, 16382 },{ 14, 14, 16383 } }; -const int32_t ivas_split_rend_huff_pred_consts[IVAS_SPLIT_REND_PRED_QUANT_PNTS][3] = { - /* - { -15, 16, 65532 },{ -14, 16, 65533 },{ -13, 15, 32764 },{ -12, 14, 16380 }, - { -11, 13, 8188 },{ -10, 12, 4092 },{ -9, 11, 2044 },{ -8, 10, 1020 },{ -7, 9, 508 }, - { -6, 8, 252 },{ -5, 7, 124 },{ -4, 6, 60 },{ -3, 5, 28 }, - { -2, 4, 12 },{ -1, 3, 4 },{ 0, 1, 0 },{ 1, 3, 5 }, - { 2, 4, 13 },{ 3, 5, 29 },{ 4, 6, 61 },{ 5, 7, 125 }, - { 6, 8, 253 },{ 7, 9, 509 },{ 8, 10, 1021 },{ 9, 11, 2045 }, - { 10, 12, 4093 },{ 11, 13, 8189 },{ 12, 14, 16381 },{ 13, 15, 32765 }, - { 14, 16, 65534 },{ 15, 16, 65535 }*/ +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS +const int32_t ivas_split_rend_huff_pred63_consts[IVAS_SPLIT_REND_PRED_63QUANT_PNTS][3] = { +{-31,11,2040}, +{-30,11,2041}, +{-29,11,2042}, +{-28,11,2043}, +{-27,10,1012}, +{-26,10,1013}, +{-25,10,1014}, +{-24,10,1015}, +{-23,9,498}, +{-22,9,499}, +{-21,9,500}, +{-20,9,501}, +{-19,8,242}, +{-18,8,243}, +{-17,8,244}, +{-16,8,245}, +{-15,7,112}, +{-14,7,113}, +{-13,7,114}, +{-12,7,115}, +{-11,6,48}, +{-10,6,49}, +{-9,6,50}, +{-8,6,51}, +{-7,5,16}, +{-6,5,17}, +{-5,5,18}, +{-4,5,19}, +{-3,4,2}, +{-2,4,3}, +{-1,4,4}, +{0,3,0}, +{1,4,5}, +{2,4,6}, +{3,4,7}, +{4,5,20}, +{5,5,21}, +{6,5,22}, +{7,5,23}, +{8,6,52}, +{9,6,53}, +{10,6,54}, +{11,6,55}, +{12,7,116}, +{13,7,117}, +{14,7,118}, +{15,7,119}, +{16,7,120}, +{17,8,246}, +{18,8,247}, +{19,8,248}, +{20,9,502}, +{21,9,503}, +{22,9,504}, +{23,9,505}, +{24,10,1016}, +{25,10,1017}, +{26,10,1018}, +{27,10,1019}, +{28,11,2044}, +{29,11,2045}, +{30,11,2046}, +{31,11,2047}, +}; +const int32_t ivas_split_rend_huff_pred31_consts[IVAS_SPLIT_REND_PRED_31QUANT_PNTS][3] = { +{-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, +{-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, +{-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, +{-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, +{2,4,10},{3,4,11},{4,5,26},{5,5,27}, +{6,6,58},{7,6,59},{8,7,122},{9,7,123}, +{10,7,124},{11,8,252},{12,9,508},{13,9,509}, +{14,10,1022},{15,10,1023}, +}; +const int32_t ivas_split_rend_huff_roll_pred_consts[IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3] = { +{-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, +{-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, +{-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, +{-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, +{2,4,10},{3,4,11},{4,5,26},{5,5,27}, +{6,6,58},{7,6,59},{8,7,122},{9,7,123}, +{10,7,124},{11,8,252},{12,9,508},{13,9,509}, +{14,10,1022},{15,10,1023}, +}; +#else +const int32_t ivas_split_rend_huff_pred_consts[IVAS_SPLIT_REND_PRED_QUANT_PNTS][3] = { {-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, {-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, {-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, @@ -604,11 +682,9 @@ const int32_t ivas_split_rend_huff_pred_consts[IVAS_SPLIT_REND_PRED_QUANT_PNTS][ {10,7,124},{11,8,252},{12,9,508},{13,9,509}, {14,10,1022},{15,10,1023}, }; +#endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ -/* clang-format on */ - - const int16_t huff_nodes_first_band_alpha[32][2] = { /* Alpha Fine Huffman table df0 */ { -17, 1 }, { 3, 2 }, @@ -894,3 +970,5 @@ HUFF_NODE_TABLE huff_nodes_dt = { { huff_nodes_alpha_1D_DT, huff_nodes_alpha_1D_DT_coarse }, { huff_nodes_beta_1D_DT, huff_nodes_beta_1D_DT_coarse } }; + +/* clang-format on */ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index c2b879f2bf..e47f66807f 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -139,7 +139,15 @@ extern const float split_rend_relative_roll_pos_angles_hq[SPLIT_REND_MAX_PITCH_O extern const float split_rend_relative_pos_angles[MAX_HEAD_ROT_POSES][3]; extern const int16_t SplitRend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1]; extern const int32_t ivas_split_rend_huff_d_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3]; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS +extern const int32_t ivas_split_rend_huff_pred63_consts[IVAS_SPLIT_REND_PRED_31QUANT_PNTS][3]; +extern const int32_t ivas_split_rend_huff_pred31_consts[IVAS_SPLIT_REND_PRED_31QUANT_PNTS][3]; +#else extern const int32_t ivas_split_rend_huff_pred_consts[IVAS_SPLIT_REND_PRED_QUANT_PNTS][3]; +#endif +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS +extern const int32_t ivas_split_rend_huff_roll_pred_consts[IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3]; +#endif extern const int32_t ivas_split_rend_huff_p_d_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3]; extern const int32_t ivas_split_rend_huff_p_d_diff_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3]; extern const int32_t split_rend_brate_tbl[]; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 94953f63a4..cd102fb7e2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1212,11 +1212,20 @@ typedef struct float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; } IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; + +typedef struct +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + AUDIO_CONFIG config; +} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + typedef struct { IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ SPLIT_REND_WRAPPER splitrend; + IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ } IVAS_DEC_SPLIT_REND_WRAPPER; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b66d4ac420..f2fd7407f2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3237,3 +3237,61 @@ ivas_error IVAS_DEC_VoIP_reconfigure( return error; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetCldfbSamples() + * + * + *---------------------------------------------------------------------*/ +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o: buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o: buffer for decoded PCM imag output in CLDFB domain */ + IVAS_DEC_AUDIO_CONFIG *audio_config, + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +) +{ + Decoder_Struct *st_ivas; + ivas_error error; + int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; + + error = IVAS_ERR_OK; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + num_samples = 0; + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + *audio_config = st_ivas->splitBinRend.hCldfbDataOut->config; + if ( st_ivas->splitBinRend.hCldfbDataOut->config != AUDIO_CONFIG_INVALID ) + { + getAudioConfigNumChannels( st_ivas->splitBinRend.hCldfbDataOut->config, &num_chs ); + maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + for ( b = 0; b < maxBand; b++ ) + { + for ( ch = 0; ch < num_chs; ch++ ) + { + *out_real++ = st_ivas->splitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; + *out_imag++ = st_ivas->splitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; + } + } + } + num_samples = CLDFB_NO_COL_MAX * maxBand; + } + } + else + { + *audio_config = AUDIO_CONFIG_INVALID; + } + *nOutSamples = num_samples; + return error; +} +#endif \ No newline at end of file diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9edc1a130c..1f2c62e5fd 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -182,6 +182,17 @@ ivas_error IVAS_DEC_GetSamples( #endif ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o: buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o: buffer for decoded PCM imag output in CLDFB domain */ + IVAS_DEC_AUDIO_CONFIG *audio_config, + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +); +#endif + /*! r: error code */ ivas_error IVAS_DEC_GetObjectMetadata( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 74fb7fae68..0e97a78dbf 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -260,14 +260,36 @@ static void ivas_split_rend_unquant_md( int16_t ch1, ch2; int16_t gd_idx_min; - if ( pose_type == PRED_ONLY ) + if ( pose_type == PRED_ONLY +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + || pose_type == PRED_ROLL_ONLY +#endif + ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + float quantstep; +#endif + +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + if ( pose_type == PRED_ONLY ) + { + quantstep = IVAS_SPLIT_REND_PRED31_Q_STEP; + } + else + { + quantstep = IVAS_SPLIT_REND_PRED_ROLL_Q_STEP; + } +#endif for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep; +#else hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * IVAS_SPLIT_REND_PRED_Q_STEP; +#endif hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + fix_pos_rot_mat[ch1][ch2]; } } @@ -287,7 +309,11 @@ static void ivas_split_rend_unquant_md( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * quantstep; +#else hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * IVAS_SPLIT_REND_PRED_Q_STEP; +#endif } } } @@ -329,15 +355,28 @@ static void ivas_splitBinPostRendMdBase2Dec( { int16_t sf_idx, pos_idx, b, ch1, ch2; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len; + int16_t min_pred_roll_idx, pred_roll_code_len; int16_t code; BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; +#else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; + min_pred_roll_idx = min_pred_idx; +#endif min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_code_len = pHuff_cfg->pred_base2_code_len[0]; + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; +#else pred_code_len = pHuff_cfg->pred_base2_code_len; + pred_roll_code_len = pred_code_len; +#endif gd_code_len = pHuff_cfg->gd_base2_code_len; p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; @@ -398,8 +437,8 @@ static void ivas_splitBinPostRendMdBase2Dec( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - code = (int16_t) ivas_split_rend_bitstream_read_int32( pBits, pred_code_len ); - hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_idx; + code = (int16_t) ivas_split_rend_bitstream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_roll_idx; } } } @@ -410,8 +449,8 @@ static void ivas_splitBinPostRendMdBase2Dec( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - code = (int16_t) ivas_split_rend_bitstream_read_int32( pBits, pred_code_len ); - hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_idx; + code = (int16_t) ivas_split_rend_bitstream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_roll_idx; } } } @@ -438,13 +477,25 @@ static void ivas_splitBinPostRendMdHuffDec( int16_t ch1, ch2; int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t min_pred_idx, max_pred_idx; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t min_pred_roll_idx, max_pred_roll_idx; +#endif BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) * 3]; +#else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; max_pred_idx = (int16_t) pHuff_cfg->pred.codebook[( IVAS_SPLIT_REND_PRED_QUANT_PNTS - 1 ) * 3]; +#endif +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3]; +#endif for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { @@ -459,7 +510,11 @@ static void ivas_splitBinPostRendMdHuffDec( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[0], pBits, pHuff_cfg->pred_idx_trav[0] ); +#else sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred, pBits, pHuff_cfg->pred_idx_trav ); +#endif // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); } } @@ -472,7 +527,11 @@ static void ivas_splitBinPostRendMdHuffDec( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[0], pBits, pHuff_cfg->pred_idx_trav[0] ); +#else sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred, pBits, pHuff_cfg->pred_idx_trav ); +#endif // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); } } @@ -498,6 +557,35 @@ static void ivas_splitBinPostRendMdHuffDec( } else { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + ivas_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + } + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); + } + } + ivas_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } +#else for ( b = 0; b < pred_real_bands_roll; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -524,6 +612,7 @@ static void ivas_splitBinPostRendMdHuffDec( } ivas_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); } +#endif } } } @@ -797,14 +886,22 @@ void ivas_splitBinPostRendMdDec( { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + PRED_ROLL_ONLY, +#else PRED_ONLY, +#endif 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); } for ( ; b < pred_real_bands_roll[quant_strat]; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + PRED_ROLL_ONLY, +#else PRED_ONLY, +#endif 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); } for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 1b8a157f5b..5e446f7b2f 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -465,8 +465,27 @@ static void ivas_split_rend_quant_md( int16_t gd_idx_min; float sign, quant_val; - if ( pose_type == PRED_ONLY ) + if ( pose_type == PRED_ONLY +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + || pose_type == PRED_ROLL_ONLY +#endif + ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + float onebyquantstep; +#endif + +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + if ( pose_type == PRED_ONLY ) + { + onebyquantstep = IVAS_SPLIT_REND_PRED31_1BYQ_STEP; + } + else + { + onebyquantstep = IVAS_SPLIT_REND_PRED_ROLL_1BYQ_STEP; + } + +#endif if ( real_only == 1 ) { for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) @@ -486,7 +505,11 @@ static void ivas_split_rend_quant_md( { quant_val = hMd->pred_mat_re[ch1][ch2] - fix_pos_rot_mat[ch1][ch2]; quant_val = min( IVAS_SPLIT_REND_PRED_MAX_VAL, max( quant_val, IVAS_SPLIT_REND_PRED_MIN_VAL ) ); +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + hMd->pred_mat_re_idx[ch1][ch2] = (int16_t) roundf( onebyquantstep * quant_val ); +#else hMd->pred_mat_re_idx[ch1][ch2] = (int16_t) roundf( IVAS_SPLIT_REND_PRED_1BYQ_STEP * quant_val ); +#endif // hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * IVAS_SPLIT_REND_PRED_Q_STEP; } } @@ -497,7 +520,11 @@ static void ivas_split_rend_quant_md( for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { quant_val = min( IVAS_SPLIT_REND_PRED_MAX_VAL, max( hMd->pred_mat_im[ch1][ch2], IVAS_SPLIT_REND_PRED_MIN_VAL ) ); +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + hMd->pred_mat_im_idx[ch1][ch2] = (int16_t) roundf( onebyquantstep * quant_val ); +#else hMd->pred_mat_im_idx[ch1][ch2] = (int16_t) roundf( IVAS_SPLIT_REND_PRED_1BYQ_STEP * quant_val ); +#endif // hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * IVAS_SPLIT_REND_PRED_Q_STEP; } } @@ -739,9 +766,17 @@ static void get_base2_bits( int32_t base2bits[IVAS_SPLIT_REND_NUM_QUANT_STRATS] ) { int16_t pred_bits, d_gain_bits, pitch_gain_bits, pose_idx, q; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_roll_bits; +#endif IVAS_SPLIT_REND_POSE_TYPE pose_type; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_PRED_31QUANT_PNTS ) ); + pred_roll_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS ) ); +#else pred_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_PRED_QUANT_PNTS ) ); +#endif d_gain_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_D_QUANT_PNTS ) ); pitch_gain_bits = d_gain_bits; @@ -768,8 +803,13 @@ static void get_base2_bits( } else { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + base2bits[q] += pred_roll_bits * pred_real_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; + base2bits[q] += pred_roll_bits * pred_imag_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else base2bits[q] += pred_bits * pred_real_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; base2bits[q] += pred_bits * pred_imag_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#endif } } } @@ -791,14 +831,27 @@ static void ivas_SplitRenderer_code_md_base2( { int16_t pos_idx, b, ch1, ch2, sf_idx; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; + int16_t min_pred_roll_idx, pred_roll_code_len; int32_t code; BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; +#else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; + min_pred_roll_idx = min_pred_idx; +#endif min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_code_len = pHuff_cfg->pred_base2_code_len[0]; + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; +#else pred_code_len = pHuff_cfg->pred_base2_code_len; + pred_roll_code_len = pred_code_len; +#endif gd_code_len = pHuff_cfg->gd_base2_code_len; p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; @@ -863,8 +916,8 @@ static void ivas_SplitRenderer_code_md_base2( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_idx; - ivas_split_rend_bitstream_write_int32( pBits, code, pred_code_len ); + code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_roll_idx; + ivas_split_rend_bitstream_write_int32( pBits, code, pred_roll_code_len ); } } } @@ -876,8 +929,8 @@ static void ivas_SplitRenderer_code_md_base2( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { - code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_idx; - ivas_split_rend_bitstream_write_int32( pBits, code, pred_code_len ); + code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_roll_idx; + ivas_split_rend_bitstream_write_int32( pBits, code, pred_roll_code_len ); } } } @@ -922,12 +975,23 @@ static void ivas_SplitRenderer_code_md_huff( int16_t pos_idx, b, ch1, ch2, sf_idx, num_poses; int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t min_pred_idx, max_pred_idx; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t min_pred_roll_idx, max_pred_roll_idx; +#endif int32_t code, len; BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; + +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) * 3]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3]; +#else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; max_pred_idx = (int16_t) pHuff_cfg->pred.codebook[( IVAS_SPLIT_REND_PRED_QUANT_PNTS - 1 ) * 3]; +#endif num_poses = pMultiBinPoseData->num_poses; @@ -945,7 +1009,11 @@ static void ivas_SplitRenderer_code_md_huff( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + ivas_split_rend_huffman_encode( &pHuff_cfg->pred[0], sym_adj_idx[ch1][ch2], &code, &len ); +#else ivas_split_rend_huffman_encode( &pHuff_cfg->pred, sym_adj_idx[ch1][ch2], &code, &len ); +#endif ivas_split_rend_bitstream_write_int32( pBits, code, len ); } } @@ -958,7 +1026,11 @@ static void ivas_SplitRenderer_code_md_huff( { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + ivas_split_rend_huffman_encode( &pHuff_cfg->pred[0], sym_adj_idx[ch1][ch2], &code, &len ); +#else ivas_split_rend_huffman_encode( &pHuff_cfg->pred, sym_adj_idx[ch1][ch2], &code, &len ); +#endif ivas_split_rend_bitstream_write_int32( pBits, code, len ); } } @@ -984,6 +1056,34 @@ static void ivas_SplitRenderer_code_md_huff( } else { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + ivas_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + ivas_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ivas_split_rend_bitstream_write_int32( pBits, code, len ); + } + } + } + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + ivas_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + ivas_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ivas_split_rend_bitstream_write_int32( pBits, code, len ); + } + } + } +#else for ( b = 0; b < pred_real_bands_roll; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1010,6 +1110,7 @@ static void ivas_SplitRenderer_code_md_huff( } } } +#endif } } } @@ -1158,14 +1259,22 @@ static void ivas_SplitRenderer_quant_code( { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + PRED_ROLL_ONLY, +#else PRED_ONLY, +#endif 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); } for ( ; b < pred_real_bands_roll[q]; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + PRED_ROLL_ONLY, +#else PRED_ONLY, +#endif 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); } } diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index b1068054f8..5f7c46eb33 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -160,12 +160,37 @@ static void ivas_split_huff_get_idx_trav_list( int16_t *idx_list, ivas_split_ren void ivas_split_rend_init_huff_cfg( BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pHuff_cfg->pred[0].codebook = &ivas_split_rend_huff_pred31_consts[0][0]; + pHuff_cfg->pred[0].sym_len = IVAS_SPLIT_REND_PRED_31QUANT_PNTS; + ivas_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[0] ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[0], &pHuff_cfg->pred[0] ); + pHuff_cfg->pred_base2_code_len[0] = (int16_t) ceilf( log2f( pHuff_cfg->pred[0].sym_len ) ); + + pHuff_cfg->pred[1].codebook = &ivas_split_rend_huff_pred63_consts[0][0]; + pHuff_cfg->pred[1].sym_len = IVAS_SPLIT_REND_PRED_63QUANT_PNTS; + ivas_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[1] ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[1], &pHuff_cfg->pred[1] ); + pHuff_cfg->pred_base2_code_len[1] = (int16_t) ceilf( log2f( pHuff_cfg->pred[1].sym_len ) ); + +#else pHuff_cfg->pred.codebook = &ivas_split_rend_huff_pred_consts[0][0]; pHuff_cfg->pred.sym_len = IVAS_SPLIT_REND_PRED_QUANT_PNTS; + ivas_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred ); ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav, &pHuff_cfg->pred ); pHuff_cfg->pred_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->pred.sym_len ) ); +#endif + +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pHuff_cfg->pred_roll.codebook = &ivas_split_rend_huff_roll_pred_consts[0][0]; + pHuff_cfg->pred_roll.sym_len = IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS; + ivas_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred_roll ); + ivas_split_huff_get_idx_trav_list( pHuff_cfg->pred_roll_idx_trav, &pHuff_cfg->pred_roll ); + pHuff_cfg->pred_roll_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->pred_roll.sym_len ) ); +#endif + pHuff_cfg->gd.codebook = &ivas_split_rend_huff_d_consts[0][0]; pHuff_cfg->gd.sym_len = IVAS_SPLIT_REND_D_QUANT_PNTS; ivas_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->gd ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 04cfd144ed..8690ac593b 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -196,9 +196,21 @@ typedef struct ivas_split_rend_huffman_cfg_t typedef struct ivas_binaural_head_rot_split_rendering_huff_struct { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + ivas_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][IVAS_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; +#else ivas_split_rend_huffman_cfg_t pred; int16_t pred_idx_trav[IVAS_SPLIT_REND_PRED_QUANT_PNTS]; int16_t pred_base2_code_len; +#endif + +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + ivas_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; +#endif ivas_split_rend_huffman_cfg_t gd; int16_t gd_base2_code_len; int16_t gd_idx_trav[IVAS_SPLIT_REND_D_QUANT_PNTS]; -- GitLab From ac0f7407a44e4c203e177a5e24cf390c06970c42 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 25 Jul 2023 21:45:02 +1000 Subject: [PATCH 07/33] 63 quant point support for pred coeffs --- lib_com/ivas_cnst.h | 5 +- lib_rend/ivas_prot_rend.h | 5 + lib_rend/ivas_splitRendererPost.c | 113 ++++++++++++++++++----- lib_rend/ivas_splitRendererPre.c | 137 ++++++++++++++++++++++------ lib_rend/ivas_splitRenderer_utils.c | 36 +++++++- 5 files changed, 244 insertions(+), 52 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index addd0ad017..d441d8f0ed 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1553,8 +1553,11 @@ typedef enum #define COMPLEX_MD_BAND_THRESH (MAX_SPLIT_REND_MD_BANDS) #define COMPLEX_MD_BAND_THRESH_LOW (5) - +#ifndef SPLIT_REND_PRED_QUANT_63_PNTS #define IVAS_SPLIT_REND_NUM_QUANT_STRATS (3) +#else +#define IVAS_SPLIT_REND_NUM_QUANT_STRATS (4) +#endif #ifdef SPLIT_REND_PRED_QUANT_63_PNTS #define IVAS_SPLIT_REND_PRED_63QUANT_PNTS ( 63 ) #define IVAS_SPLIT_REND_PRED_31QUANT_PNTS ( 31 ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index e64fdce77a..d2f0285ebe 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -596,6 +596,11 @@ void ivas_split_rend_get_quant_params( const int16_t num_md_bands, int16_t pred_real_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t pred_imag_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_quant_pnts_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], + float pred_quantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], + float pred_1byquantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#endif int16_t d_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t bands_pitch[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t pred_real_bands_roll[IVAS_SPLIT_REND_NUM_QUANT_STRATS], diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 0e97a78dbf..1adf977496 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -255,7 +255,12 @@ static void ivas_split_rend_unquant_md( BIN_HR_SPLIT_REND_MD_HANDLE hMd, IVAS_SPLIT_REND_POSE_TYPE pose_type, int16_t real_only, - float fix_pos_rot_mat[][BINAURAL_CHANNELS] ) + float fix_pos_rot_mat[][BINAURAL_CHANNELS] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + float pred_quant_step +#endif +) { int16_t ch1, ch2; int16_t gd_idx_min; @@ -271,14 +276,7 @@ static void ivas_split_rend_unquant_md( #endif #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - if ( pose_type == PRED_ONLY ) - { - quantstep = IVAS_SPLIT_REND_PRED31_Q_STEP; - } - else - { - quantstep = IVAS_SPLIT_REND_PRED_ROLL_Q_STEP; - } + quantstep = pred_quant_step; #endif for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) @@ -348,6 +346,9 @@ static void ivas_splitBinPostRendMdBase2Dec( const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + const int16_t pred_quant_pnts_yaw, +#endif const int16_t d_bands_yaw, const int16_t bands_pitch, const int16_t pred_real_bands_roll, @@ -356,13 +357,24 @@ static void ivas_splitBinPostRendMdBase2Dec( int16_t sf_idx, pos_idx, b, ch1, ch2; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len; int16_t min_pred_roll_idx, pred_roll_code_len; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_cb_idx; +#endif int16_t code; BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + if ( pred_quant_pnts_yaw == IVAS_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; #else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; @@ -371,7 +383,7 @@ static void ivas_splitBinPostRendMdBase2Dec( min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - pred_code_len = pHuff_cfg->pred_base2_code_len[0]; + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; #else pred_code_len = pHuff_cfg->pred_base2_code_len; @@ -468,6 +480,9 @@ static void ivas_splitBinPostRendMdHuffDec( const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + const int16_t pred_quant_pnts_yaw, +#endif const int16_t d_bands_yaw, const int16_t bands_pitch, const int16_t pred_real_bands_roll, @@ -478,15 +493,23 @@ static void ivas_splitBinPostRendMdHuffDec( int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t min_pred_idx, max_pred_idx; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - int16_t min_pred_roll_idx, max_pred_roll_idx; + int16_t min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; #endif BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; - max_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) * 3]; + if ( pred_quant_pnts_yaw == IVAS_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3]; #else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; max_pred_idx = (int16_t) pHuff_cfg->pred.codebook[( IVAS_SPLIT_REND_PRED_QUANT_PNTS - 1 ) * 3]; @@ -511,7 +534,7 @@ static void ivas_splitBinPostRendMdHuffDec( for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[0], pBits, pHuff_cfg->pred_idx_trav[0] ); + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); #else sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred, pBits, pHuff_cfg->pred_idx_trav ); #endif @@ -528,7 +551,7 @@ static void ivas_splitBinPostRendMdHuffDec( for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[0], pBits, pHuff_cfg->pred_idx_trav[0] ); + sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); #else sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred, pBits, pHuff_cfg->pred_idx_trav ); #endif @@ -636,6 +659,11 @@ void ivas_splitBinPostRendMdDec( int16_t d_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; int16_t num_complex_bands, num_quant_strats; int32_t quant_strat_bits, is_huff_coding, quant_strat; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_quant_pnts_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_1byquantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_quantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG int16_t ch1, ch2; #endif @@ -681,6 +709,11 @@ void ivas_splitBinPostRendMdDec( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw, + pred_quantstep_yaw, + pred_1byquantstep_yaw, +#endif d_bands_yaw, bands_pitch, pred_real_bands_roll, @@ -700,6 +733,9 @@ void ivas_splitBinPostRendMdDec( num_subframes, pred_real_bands_yaw[quant_strat], pred_imag_bands_yaw[quant_strat], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw[quant_strat], +#endif d_bands_yaw[quant_strat], bands_pitch[quant_strat], pred_real_bands_roll[quant_strat], @@ -713,6 +749,9 @@ void ivas_splitBinPostRendMdDec( num_subframes, pred_real_bands_yaw[quant_strat], pred_imag_bands_yaw[quant_strat], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw[quant_strat], +#endif d_bands_yaw[quant_strat], bands_pitch[quant_strat], pred_real_bands_roll[quant_strat], @@ -832,14 +871,24 @@ void ivas_splitBinPostRendMdDec( hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, PRED_ONLY, - 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + pred_quantstep_yaw[quant_strat] +#endif + ); } for ( ; b < pred_real_bands_yaw[quant_strat]; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, PRED_ONLY, - 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + pred_quantstep_yaw[quant_strat] +#endif + ); } for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) { @@ -856,7 +905,12 @@ void ivas_splitBinPostRendMdDec( hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, COM_GAIN_ONLY, - 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + 0 +#endif + ); } for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) { @@ -871,7 +925,12 @@ void ivas_splitBinPostRendMdDec( hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_unquant_md( hMd, LR_GAIN_ONLY, - 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + 0 +#endif + ); } for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) { @@ -891,7 +950,12 @@ void ivas_splitBinPostRendMdDec( #else PRED_ONLY, #endif - 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + IVAS_SPLIT_REND_PRED_ROLL_Q_STEP +#endif + ); } for ( ; b < pred_real_bands_roll[quant_strat]; b++ ) { @@ -902,7 +966,12 @@ void ivas_splitBinPostRendMdDec( #else PRED_ONLY, #endif - 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + IVAS_SPLIT_REND_PRED_ROLL_Q_STEP +#endif + ); } for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) { diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 5e446f7b2f..a8c9f3fb6e 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -459,7 +459,12 @@ static void ivas_split_rend_quant_md( BIN_HR_SPLIT_REND_MD_HANDLE hMd, IVAS_SPLIT_REND_POSE_TYPE pose_type, int16_t real_only, - float fix_pos_rot_mat[][BINAURAL_CHANNELS] ) + float fix_pos_rot_mat[][BINAURAL_CHANNELS] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + float pred_1byquantstep +#endif +) { int16_t ch1, ch2; int16_t gd_idx_min; @@ -476,15 +481,7 @@ static void ivas_split_rend_quant_md( #endif #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - if ( pose_type == PRED_ONLY ) - { - onebyquantstep = IVAS_SPLIT_REND_PRED31_1BYQ_STEP; - } - else - { - onebyquantstep = IVAS_SPLIT_REND_PRED_ROLL_1BYQ_STEP; - } - + onebyquantstep = pred_1byquantstep; #endif if ( real_only == 1 ) { @@ -543,12 +540,10 @@ static void ivas_split_rend_quant_md( quant_val = min( IVAS_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd, IVAS_SPLIT_REND_PITCH_G_MIN_VAL ) ); gd_idx_min = (int16_t) roundf( IVAS_SPLIT_REND_PITCH_G_1BYQ_STEP * IVAS_SPLIT_REND_PITCH_G_MIN_VAL ); hMd->gd_idx = (int16_t) roundf( IVAS_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val ); - // hMd->gd = hMd->gd_idx * IVAS_SPLIT_REND_PITCH_G_Q_STEP; hMd->gd_idx = hMd->gd_idx - gd_idx_min; quant_val = min( IVAS_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd2, IVAS_SPLIT_REND_PITCH_G_MIN_VAL ) ); hMd->gd2_idx = (int16_t) roundf( IVAS_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val ); - // hMd->gd2 = hMd->gd2_idx * IVAS_SPLIT_REND_PITCH_G_Q_STEP; hMd->gd2_idx = hMd->gd2_idx - gd_idx_min; } @@ -759,20 +754,29 @@ static void get_base2_bits( const int16_t num_quant_strats, const int16_t pred_real_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], const int16_t pred_imag_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_quant_pnts_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#endif const int16_t d_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], const int16_t bands_pitch[IVAS_SPLIT_REND_NUM_QUANT_STRATS], const int16_t pred_real_bands_roll[IVAS_SPLIT_REND_NUM_QUANT_STRATS], const int16_t pred_imag_bands_roll[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int32_t base2bits[IVAS_SPLIT_REND_NUM_QUANT_STRATS] ) { - int16_t pred_bits, d_gain_bits, pitch_gain_bits, pose_idx, q; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS int16_t pred_roll_bits; + int16_t d_gain_bits, pitch_gain_bits, pose_idx, q; + int16_t pred_yaw_bits[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; +#else + int16_t pred_bits, d_gain_bits, pitch_gain_bits, pose_idx, q; #endif IVAS_SPLIT_REND_POSE_TYPE pose_type; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - pred_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_PRED_31QUANT_PNTS ) ); + for ( q = 0; q < num_quant_strats; q++ ) + { + pred_yaw_bits[q] = (int16_t) ceilf( log2f( pred_quant_pnts_yaw[q] ) ); + } pred_roll_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS ) ); #else pred_bits = (int16_t) ceilf( log2f( IVAS_SPLIT_REND_PRED_QUANT_PNTS ) ); @@ -792,8 +796,13 @@ static void get_base2_bits( pose_type = hBinHrSplitPreRend->pose_type[pose_idx]; if ( pose_type == ANY_YAW ) { +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + base2bits[q] += pred_yaw_bits[q] * pred_real_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; + base2bits[q] += pred_yaw_bits[q] * pred_imag_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else base2bits[q] += pred_bits * pred_real_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; base2bits[q] += pred_bits * pred_imag_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#endif base2bits[q] += d_gain_bits * d_bands_yaw[q] * num_subframes; } else if ( pose_type == PITCH_ONLY ) @@ -823,6 +832,9 @@ static void ivas_SplitRenderer_code_md_base2( const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + const int16_t pred_quant_pnts_yaw, +#endif const int16_t d_bands_yaw, const int16_t bands_pitch, const int16_t pred_real_bands_roll, @@ -832,12 +844,23 @@ static void ivas_SplitRenderer_code_md_base2( int16_t pos_idx, b, ch1, ch2, sf_idx; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; int16_t min_pred_roll_idx, pred_roll_code_len; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_cb_idx; +#endif int32_t code; BIN_HR_SPLIT_REND_MD_HANDLE hMd; BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; + if ( pred_quant_pnts_yaw == IVAS_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; #else min_pred_idx = (int16_t) pHuff_cfg->pred.codebook[0]; @@ -846,7 +869,7 @@ static void ivas_SplitRenderer_code_md_base2( min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - pred_code_len = pHuff_cfg->pred_base2_code_len[0]; + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; #else pred_code_len = pHuff_cfg->pred_base2_code_len; @@ -966,6 +989,9 @@ static void ivas_SplitRenderer_code_md_huff( const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + const int16_t pred_quant_pnts_yaw, +#endif const int16_t d_bands_yaw, const int16_t bands_pitch, const int16_t pred_real_bands_roll, @@ -976,7 +1002,7 @@ static void ivas_SplitRenderer_code_md_huff( int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t min_pred_idx, max_pred_idx; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - int16_t min_pred_roll_idx, max_pred_roll_idx; + int16_t min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; #endif int32_t code, len; BIN_HR_SPLIT_REND_MD_HANDLE hMd; @@ -984,8 +1010,16 @@ static void ivas_SplitRenderer_code_md_huff( pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - min_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[0]; - max_pred_idx = (int16_t) pHuff_cfg->pred[0].codebook[( IVAS_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) * 3]; + if ( pred_quant_pnts_yaw == IVAS_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3]; min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3]; #else @@ -1010,7 +1044,7 @@ static void ivas_SplitRenderer_code_md_huff( for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - ivas_split_rend_huffman_encode( &pHuff_cfg->pred[0], sym_adj_idx[ch1][ch2], &code, &len ); + ivas_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); #else ivas_split_rend_huffman_encode( &pHuff_cfg->pred, sym_adj_idx[ch1][ch2], &code, &len ); #endif @@ -1027,7 +1061,7 @@ static void ivas_SplitRenderer_code_md_huff( for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) { #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - ivas_split_rend_huffman_encode( &pHuff_cfg->pred[0], sym_adj_idx[ch1][ch2], &code, &len ); + ivas_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); #else ivas_split_rend_huffman_encode( &pHuff_cfg->pred, sym_adj_idx[ch1][ch2], &code, &len ); #endif @@ -1150,6 +1184,11 @@ static void ivas_SplitRenderer_quant_code( int16_t pred_imag_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; int16_t d_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; int32_t base2bits[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_quant_pnts_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_1byquantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_quantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS]; +#endif BIN_HR_SPLIT_REND_MD_HANDLE hMd; if ( low_res_pre_rend_rot ) @@ -1191,6 +1230,11 @@ static void ivas_SplitRenderer_quant_code( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw, + pred_quantstep_yaw, + pred_1byquantstep_yaw, +#endif d_bands_yaw, bands_pitch, pred_real_bands_roll, @@ -1207,6 +1251,9 @@ static void ivas_SplitRenderer_quant_code( num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw, +#endif d_bands_yaw, bands_pitch, pred_real_bands_roll, @@ -1226,21 +1273,36 @@ static void ivas_SplitRenderer_quant_code( hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, PRED_ONLY, - 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + pred_1byquantstep_yaw[q] +#endif + ); } for ( ; b < pred_real_bands_yaw[q]; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, PRED_ONLY, - 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + pred_1byquantstep_yaw[q] +#endif + ); } for ( b = 0; b < d_bands_yaw[q]; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, COM_GAIN_ONLY, - 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + 0 +#endif + ); } } else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) @@ -1250,7 +1312,12 @@ static void ivas_SplitRenderer_quant_code( hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; ivas_split_rend_quant_md( hMd, LR_GAIN_ONLY, - 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + 0 +#endif + ); } } else @@ -1264,7 +1331,12 @@ static void ivas_SplitRenderer_quant_code( #else PRED_ONLY, #endif - 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + IVAS_SPLIT_REND_PRED_ROLL_1BYQ_STEP +#endif + ); } for ( ; b < pred_real_bands_roll[q]; b++ ) { @@ -1275,7 +1347,12 @@ static void ivas_SplitRenderer_quant_code( #else PRED_ONLY, #endif - 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] ); + 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx] +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + , + IVAS_SPLIT_REND_PRED_ROLL_1BYQ_STEP +#endif + ); } } } @@ -1293,6 +1370,9 @@ static void ivas_SplitRenderer_quant_code( num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw[q], +#endif d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], @@ -1312,6 +1392,9 @@ static void ivas_SplitRenderer_quant_code( num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw[q], +#endif d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index 5f7c46eb33..baa5f79139 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -617,6 +617,11 @@ void ivas_split_rend_get_quant_params( const int16_t num_md_bands, int16_t pred_real_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t pred_imag_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + int16_t pred_quant_pnts_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], + float pred_quantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], + float pred_1byquantstep_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], +#endif int16_t d_bands_yaw[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t bands_pitch[IVAS_SPLIT_REND_NUM_QUANT_STRATS], int16_t pred_real_bands_roll[IVAS_SPLIT_REND_NUM_QUANT_STRATS], @@ -629,7 +634,17 @@ void ivas_split_rend_get_quant_params( *num_quant_strats = IVAS_SPLIT_REND_NUM_QUANT_STRATS; *num_complex_bands = COMPLEX_MD_BAND_THRESH_LOW; assert( *num_complex_bands <= num_md_bands ); - +#ifdef SPLIT_REND_PRED_QUANT_63_PNTS + pred_quant_pnts_yaw[0] = IVAS_SPLIT_REND_PRED_63QUANT_PNTS; + pred_quantstep_yaw[0] = IVAS_SPLIT_REND_PRED63_Q_STEP; + pred_1byquantstep_yaw[0] = IVAS_SPLIT_REND_PRED63_1BYQ_STEP; + for ( q = 1; q < *num_quant_strats; q++ ) + { + pred_quant_pnts_yaw[q] = IVAS_SPLIT_REND_PRED_31QUANT_PNTS; + pred_quantstep_yaw[q] = IVAS_SPLIT_REND_PRED31_Q_STEP; + pred_1byquantstep_yaw[q] = IVAS_SPLIT_REND_PRED31_1BYQ_STEP; + } +#endif for ( q = 0; q < *num_quant_strats; q++ ) { @@ -638,12 +653,22 @@ void ivas_split_rend_get_quant_params( } pred_imag_bands_yaw[0] = num_md_bands; pred_imag_bands_roll[0] = num_md_bands; +#ifndef SPLIT_REND_PRED_QUANT_63_PNTS for ( q = 1; q < *num_quant_strats; q++ ) +#else + pred_imag_bands_yaw[1] = num_md_bands; + pred_imag_bands_roll[1] = num_md_bands; + for ( q = 2; q < *num_quant_strats; q++ ) +#endif { +#ifndef SPLIT_REND_PRED_QUANT_63_PNTS pred_imag_bands_yaw[q] = ( q == 1 ) ? num_md_bands : *num_complex_bands; +#else + pred_imag_bands_yaw[q] = ( q < ( *num_quant_strats - 1 ) ) ? num_md_bands : *num_complex_bands; +#endif pred_imag_bands_roll[q] = *num_complex_bands; } - +#ifndef SPLIT_REND_PRED_QUANT_63_PNTS d_bands_yaw[0] = 0; bands_pitch[0] = num_md_bands; for ( q = 1; q < *num_quant_strats; q++ ) @@ -651,6 +676,13 @@ void ivas_split_rend_get_quant_params( d_bands_yaw[q] = 0; bands_pitch[q] = num_md_bands; } +#else + for ( q = 0; q < *num_quant_strats; q++ ) + { + d_bands_yaw[q] = 0; + bands_pitch[q] = num_md_bands; + } +#endif return; } -- GitLab From fbd4808b251995e801defe0019ce5a885cd71a8f Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Wed, 26 Jul 2023 18:26:19 +1000 Subject: [PATCH 08/33] Add renderer configs and IVAS bitrates to split rendering tests --- tests/split_rendering/constants.py | 41 ++++++++++- ...lit_renderer_config_0dof_256k_default.txt} | 0 ...lit_renderer_config_0dof_320k_default.txt} | 0 ...lit_renderer_config_0dof_384k_default.txt} | 0 ...lit_renderer_config_0dof_512k_default.txt} | 0 ...lit_renderer_config_0dof_768k_default.txt} | 0 ...lit_renderer_config_1dof_512k_default.txt} | 0 ...lit_renderer_config_1dof_768k_default.txt} | 0 ...lit_renderer_config_2dof_512k_default.txt} | 0 ...lit_renderer_config_2dof_768k_default.txt} | 0 ...plit_renderer_config_3dof_384k_lc3plus.txt | 5 ++ .../split_renderer_config_3dof_384k_lcld.txt | 5 ++ ...lit_renderer_config_3dof_512k_default.txt} | 0 ...lit_renderer_config_3dof_768k_default.txt} | 0 ...plit_renderer_config_3dof_768k_lc3plus.txt | 5 ++ .../split_renderer_config_3dof_768k_lcld.txt | 5 ++ ...t_renderer_config_3dofhq_512k_default.txt} | 0 ...it_renderer_config_3dofhq_512k_lc3plus.txt | 5 ++ ...split_renderer_config_3dofhq_512k_lcld.txt | 5 ++ ...t_renderer_config_3dofhq_768k_default.txt} | 0 ...it_renderer_config_3dofhq_768k_lc3plus.txt | 5 ++ ...split_renderer_config_3dofhq_768k_lcld.txt | 5 ++ tests/split_rendering/test_split_rendering.py | 71 ++++++++++-------- .../test_split_rendering_be_comparison.py | 72 +++++++++++-------- tests/split_rendering/utils.py | 26 +++++-- 25 files changed, 188 insertions(+), 62 deletions(-) rename tests/split_rendering/renderer_configs/{split_renderer_config_0dof_256k.txt => split_renderer_config_0dof_256k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_0dof_320k.txt => split_renderer_config_0dof_320k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_0dof_384k.txt => split_renderer_config_0dof_384k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_0dof_512k.txt => split_renderer_config_0dof_512k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_0dof_768k.txt => split_renderer_config_0dof_768k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_1dof_512k.txt => split_renderer_config_1dof_512k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_1dof_768k.txt => split_renderer_config_1dof_768k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_2dof_512k.txt => split_renderer_config_2dof_512k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_2dof_768k.txt => split_renderer_config_2dof_768k_default.txt} (100%) create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lc3plus.txt create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lcld.txt rename tests/split_rendering/renderer_configs/{split_renderer_config_3dof_512k.txt => split_renderer_config_3dof_512k_default.txt} (100%) rename tests/split_rendering/renderer_configs/{split_renderer_config_3dof_768k.txt => split_renderer_config_3dof_768k_default.txt} (100%) create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lc3plus.txt create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lcld.txt rename tests/split_rendering/renderer_configs/{split_renderer_config_3dofhq_512k.txt => split_renderer_config_3dofhq_512k_default.txt} (100%) create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lc3plus.txt create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lcld.txt rename tests/split_rendering/renderer_configs/{split_renderer_config_3dofhq_768k.txt => split_renderer_config_3dofhq_768k_default.txt} (100%) create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lc3plus.txt create mode 100644 tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lcld.txt diff --git a/tests/split_rendering/constants.py b/tests/split_rendering/constants.py index aa9e367220..e50d916cf6 100644 --- a/tests/split_rendering/constants.py +++ b/tests/split_rendering/constants.py @@ -57,7 +57,14 @@ from tests.renderer.constants import ( ) """ Renderer configurations """ -RENDERER_CONFIGS_TO_TEST = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*.txt")] +RENDERER_CONFIGS_DEFAULT_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_default.txt")] +RENDERER_CONFIGS_LCLD_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lcld.txt")] +RENDERER_CONFIGS_LC3PLUS_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lc3plus.txt")] + +RENDERER_CONFIGS_TO_TEST_AMBI = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC +RENDERER_CONFIGS_TO_TEST_MC = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC +RENDERER_CONFIGS_TO_TEST_ISM = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC +RENDERER_CONFIGS_TO_TEST_MASA = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC """ IVAS specific constants """ FORMAT_TO_IVAS_COD_FORMAT = { @@ -75,8 +82,36 @@ FORMAT_TO_IVAS_COD_FORMAT = { "FOA": ["-sba", "1"], "HOA2": ["-sba", "2"], "HOA3": ["-sba", "3"], + # "MASA1": ["-masa", "1"], + # "MASA2": ["-masa", "2"], +} + +FORMAT_TO_NCHAN = { + "MONO": 1, + "STEREO": 2, + "ISM1": 1, + "ISM2": 2, + "ISM3": 3, + "ISM4": 4, + "5_1": 6, + "5_1_2": 8, + "5_1_4": 10, + "7_1": 8, + "7_1_4": 12, + "FOA": 4, + "HOA2": 9, + "HOA3": 16, + # "MASA1": 1, + # "MASA2": 2, } +IVAS_BITRATES_AMBI = ["96000", "512000"] +IVAS_BITRATES_MC = ["128000", "384000"] +# TODO: Enable after MC 160kbps split rendering support +# IVAS_BITRATES_MC = ["128000", "160000", "384000"] +IVAS_BITRATES_ISM = ["128000"] +# IVAS_BITRATES_MASA = ["128000"] + IVAS_MAX_ISM_BITRATE = { "1": "128000", "2": "256000", @@ -84,10 +119,12 @@ IVAS_MAX_ISM_BITRATE = { "4": "512000", } +INPUT_DURATION_SEC = 5 + """ Encoder commandline template """ SPLIT_PRE_COD_CMD = [ str(TESTS_DIR.parent.parent.joinpath("IVAS_cod")), - "512000", + "", # 1 -> bitrate "48", "", # 3 -> input file "", # 4 -> output bitstream diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_0dof_256k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_0dof_256k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_0dof_256k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_0dof_256k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_0dof_320k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_0dof_320k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_0dof_320k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_0dof_320k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_0dof_384k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_0dof_384k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_0dof_384k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_0dof_384k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_0dof_512k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_0dof_512k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_0dof_512k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_0dof_512k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_0dof_768k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_0dof_768k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_0dof_768k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_0dof_768k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_1dof_512k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_1dof_512k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_1dof_512k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_1dof_512k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_1dof_768k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_1dof_768k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_1dof_768k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_1dof_768k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_2dof_512k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_2dof_512k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_2dof_512k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_2dof_512k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_2dof_768k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_2dof_768k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_2dof_768k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_2dof_768k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lc3plus.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lc3plus.txt new file mode 100644 index 0000000000..2a726e8470 --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lc3plus.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 384000; +DOF = 3; +HQMODE = 0; +CODEC = LC3PLUS; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lcld.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lcld.txt new file mode 100644 index 0000000000..c2172074d4 --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_384k_lcld.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 384000; +DOF = 3; +HQMODE = 0; +CODEC = LCLD; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_512k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_512k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_3dof_512k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_3dof_512k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lc3plus.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lc3plus.txt new file mode 100644 index 0000000000..0caa653c0d --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lc3plus.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 768000; +DOF = 3; +HQMODE = 0; +CODEC = LC3PLUS; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lcld.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lcld.txt new file mode 100644 index 0000000000..825543d57f --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_lcld.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 768000; +DOF = 3; +HQMODE = 0; +CODEC = LCLD; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lc3plus.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lc3plus.txt new file mode 100644 index 0000000000..378cca9c25 --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lc3plus.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 512000; +DOF = 3; +HQMODE = 1; +CODEC = LC3PLUS; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lcld.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lcld.txt new file mode 100644 index 0000000000..226600ab06 --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_512k_lcld.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 512000; +DOF = 3; +HQMODE = 1; +CODEC = LCLD; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_default.txt similarity index 100% rename from tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k.txt rename to tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_default.txt diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lc3plus.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lc3plus.txt new file mode 100644 index 0000000000..d9df2f2254 --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lc3plus.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 768000; +DOF = 3; +HQMODE = 1; +CODEC = LC3PLUS; diff --git a/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lcld.txt b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lcld.txt new file mode 100644 index 0000000000..e8f2ff8acb --- /dev/null +++ b/tests/split_rendering/renderer_configs/split_renderer_config_3dofhq_768k_lcld.txt @@ -0,0 +1,5 @@ +[SPLITREND] +BITRATE = 768000; +DOF = 3; +HQMODE = 1; +CODEC = LCLD; diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 76f114b689..42419a6df4 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -34,17 +34,19 @@ from tests.split_rendering.utils import * @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") +def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") run_full_chain_split_rendering( in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -53,11 +55,11 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -75,17 +77,19 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory) @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) -def test_multichannel_full_chain_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") +def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") run_full_chain_split_rendering( in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -94,11 +98,11 @@ def test_multichannel_full_chain_split(test_info, in_fmt, render_config, traject @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) def test_multichannel_external_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -116,17 +120,21 @@ def test_multichannel_external_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_full_chain_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") +def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + elif int(bitrate) > int(IVAS_MAX_ISM_BITRATE[in_fmt[-1]]): + pytest.skip(f"Unsupported configuration with {in_fmt} at {bitrate}bps") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") run_full_chain_split_rendering( in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -135,11 +143,11 @@ def test_ism_full_chain_split(test_info, in_fmt, render_config, trajectory): @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_external_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -158,28 +166,35 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): # @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) +# @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) # @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_full_chain_split(test_info, in_fmt, render_config, trajectory): +# def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): +# if "0dof_768k_lc3plus" in render_config: +# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + # post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") # pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -# + # run_full_chain_split_rendering( # in_fmt=in_fmt, +# bitrate=bitrate, # render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), # pre_trajectory=pre_trajectory, # post_trajectory=post_trajectory, # output_path_base=OUTPUT_PATH_CUT, # ) -# -# + # @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) # @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) # def test_masa_external_split(test_info, in_fmt, render_config, trajectory): +# if "0dof_768k_lc3plus" in render_config: +# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + # post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") # pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -# + # run_external_split_rendering( # in_fmt=in_fmt, # render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), diff --git a/tests/split_rendering/test_split_rendering_be_comparison.py b/tests/split_rendering/test_split_rendering_be_comparison.py index 5f0d07b23a..70ee753af2 100644 --- a/tests/split_rendering/test_split_rendering_be_comparison.py +++ b/tests/split_rendering/test_split_rendering_be_comparison.py @@ -34,11 +34,12 @@ from tests.split_rendering.utils import * @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") +def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -46,6 +47,7 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajector compare_full_chain_split_args( test_info, in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -53,11 +55,11 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory): - if in_fmt != "HOA3": - pytest.xfail("Split Rendering currently only supported with HOA3") + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -75,11 +77,12 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory) @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) -def test_multichannel_full_chain_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") +def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -87,6 +90,7 @@ def test_multichannel_full_chain_split(test_info, in_fmt, render_config, traject compare_full_chain_split_args( test_info, in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -94,11 +98,11 @@ def test_multichannel_full_chain_split(test_info, in_fmt, render_config, traject @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) def test_multichannel_external_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -116,11 +120,14 @@ def test_multichannel_external_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_full_chain_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") +def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + elif int(bitrate) > int(IVAS_MAX_ISM_BITRATE[in_fmt[-1]]): + pytest.skip(f"Unsupported configuration with {in_fmt} at {bitrate}bps") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -128,6 +135,7 @@ def test_ism_full_chain_split(test_info, in_fmt, render_config, trajectory): compare_full_chain_split_args( test_info, in_fmt=in_fmt, + bitrate=bitrate, render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), pre_trajectory=pre_trajectory, post_trajectory=post_trajectory, @@ -135,11 +143,11 @@ def test_ism_full_chain_split(test_info, in_fmt, render_config, trajectory): @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_external_split(test_info, in_fmt, render_config, trajectory): - if "768k" in render_config: - pytest.xfail("Unsupported bitrate for LC3plus") + if "0dof_768k_default" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -158,28 +166,36 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): # @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) +# @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) # @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_full_chain_split(test_info, in_fmt, render_config, trajectory): +# def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): +# if "0dof_768k_lc3plus" in render_config: +# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + # post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") # pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -# + # compare_full_chain_split_args( # test_info, # in_fmt=in_fmt, +# bitrate=bitrate, # render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), # pre_trajectory=pre_trajectory, # post_trajectory=post_trajectory, # ) -# -# + + # @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST) +# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) # @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) # def test_masa_external_split(test_info, in_fmt, render_config, trajectory): +# if "0dof_768k_lc3plus" in render_config: +# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + # post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") # pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -# + # compare_external_split_args( # test_info, # in_fmt=in_fmt, diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index 6215b3e8a1..21fe2304ba 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -27,12 +27,15 @@ """ import sys +import numpy as np from pathlib import Path from tempfile import TemporaryDirectory +from typing import Tuple from tests.split_rendering.constants import * from tests.renderer.utils import check_BE, run_cmd, test_info +from tests.cut_pcm import cut_samples sys.path.append(SCRIPTS_DIR) from pyaudio3dtools.audiofile import readfile @@ -40,23 +43,25 @@ from pyaudio3dtools.audiofile import readfile def run_full_chain_split_rendering( in_fmt: str, + bitrate: str, render_config: Path, pre_trajectory: Path, post_trajectory: Path, output_path_base: Path, binary_suffix: str = "", is_comparetest: bool = False, -) -> Path: +) -> Tuple[np.ndarray, int]: """ Runs the full split rendering chain consisting of the IVAS encoder, decoder and split renderer """ with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) + cut_in_file = tmp_dir.joinpath("cut_input.wav") ivas_bitstream = tmp_dir.joinpath("ivas.192") split_bitstream = tmp_dir.joinpath("split.bit") out_file = output_path_base.joinpath( - f"{in_fmt}_{pre_trajectory.stem}_split_full_{post_trajectory.stem}__config_{render_config.stem}.wav" + f"{in_fmt}_{bitrate}bps_{pre_trajectory.stem}_split_full_{post_trajectory.stem}__config_{render_config.stem}.wav" ) # check for metadata files @@ -69,8 +74,21 @@ def run_full_chain_split_rendering( cmd = SPLIT_PRE_COD_CMD[:] cmd[0] += binary_suffix + cmd[1] = bitrate if is_comparetest: - cmd[3] = str(FORMAT_TO_FILE_COMPARETEST[in_fmt]) + # Cut input if longer than INPUT_DURATION_SEC + in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt] + in_data, in_fs = readfile(in_file) + if len(in_data) > INPUT_DURATION_SEC * in_fs: + cut_samples(in_file=in_file, + out_file=cut_in_file, + num_channels=FORMAT_TO_NCHAN[in_fmt], + sample_rate=in_fs, + start=0, + duration=INPUT_DURATION_SEC) + cmd[3] = str(cut_in_file) + else: + cmd[3] = str(in_file) else: cmd[3] = str(FORMAT_TO_FILE_SMOKETEST[in_fmt]) cmd[4] = str(ivas_bitstream) @@ -118,7 +136,7 @@ def run_external_split_rendering( output_path_base: Path, binary_suffix: str = "", is_comparetest: bool = False, -) -> Path: +) -> Tuple[np.ndarray, int]: """ Runs the exeternal split rendering chain consisting of the IVAS renderer in split-pre and split-post rendering mode -- GitLab From 478c21d2e6f13f0ac688315f521acaf4204447f2 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 27 Jul 2023 11:58:43 +1000 Subject: [PATCH 09/33] rend MC fix --- lib_rend/lib_rend.c | 57 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 10ea4d47a7..be15911337 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -177,7 +177,11 @@ typedef struct TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ #endif REVERB_HANDLE hReverb; +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotation_gains rot_gains_prev[MAX_HEAD_ROT_POSES]; +#else rotation_gains rot_gains_prev; +#endif int16_t nonDiegeticPan; float nonDiegeticPanGain; lfe_routing lfeRouting; @@ -2407,6 +2411,9 @@ static ivas_error setRendInputActiveMc( rendering_context rendCtx; IVAS_REND_AudioConfig outConfig; input_mc *inputMc; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif inputMc = (input_mc *) input; rendCtx = inputMc->base.ctx; @@ -2436,7 +2443,14 @@ static ivas_error setRendInputActiveMc( inputMc->crendWrapper = NULL; inputMc->hReverb = NULL; inputMc->hMcMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + initRotGains( inputMc->rot_gains_prev[pos_idx] ); + } +#else initRotGains( inputMc->rot_gains_prev ); +#endif inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); #ifdef FIX_194_LFE_DELAY_EXTREND set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ); @@ -6453,7 +6467,12 @@ static ivas_error renderMcToBinaural( if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, - mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[0], +#else + mcInput->rot_gains_prev, +#endif + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6561,7 +6580,12 @@ static ivas_error renderMcToBinauralRoom( if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, - mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[0], +#else + mcInput->rot_gains_prev, +#endif + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6652,7 +6676,12 @@ static ivas_error renderMcCustomLsToBinauralRoom( if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, - mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[0], +#else + mcInput->rot_gains_prev, +#endif + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6895,7 +6924,11 @@ static ivas_error renderMcToSplitBinaural( mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[pos_idx], +#else mcInput->rot_gains_prev, +#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { @@ -8116,15 +8149,15 @@ static ivas_error renderInputMasa( case IVAS_REND_AUDIO_CONFIG_BINAURAL: renderMasaToBinaural( masaInput, outAudio ); break; - /* ToDo */ - //#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG - // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_IR: - // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: - //#else - // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM: - //#endif - // renderMasaToBinauralRoom( masaInput, outConfig, outAudio ); - // break; + /* ToDo */ + //#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG + // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_IR: + // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + //#else + // case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM: + //#endif + // renderMasaToBinauralRoom( masaInput, outConfig, outAudio ); + // break; #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -- GitLab From ef2b80ef258296ca2acef7e11b8cb86b899aff38 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 27 Jul 2023 12:20:18 +1000 Subject: [PATCH 10/33] build sanitizer fix, clang formatting fix --- lib_dec/ivas_dirac_dec.c | 8 +- lib_dec/ivas_ism_param_dec.c | 2 +- lib_dec/ivas_masa_dec.c | 4 +- lib_dec/lib_dec.c | 95 +++++++++++++++++++- lib_rend/ivas_dirac_dec_binaural_functions.c | 54 +++++------ 5 files changed, 123 insertions(+), 40 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index b2c34ca2de..e9443fda32 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -896,14 +896,14 @@ ivas_error ivas_dirac_dec_config( { /* TODO: can we keep isRenderingInTd fixed? */ ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, - 0, /* isRenderingInTd */ - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* pcm_out */ + 0, /* isRenderingInTd */ + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* pcm_out */ error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, - 1, /* is_cldfb_in */ - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* is_pcm_out */ + 1, /* is_cldfb_in */ + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* is_pcm_out */ if ( error != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e536d8f25b..b64c52bc71 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -387,7 +387,7 @@ static ivas_error ivas_param_ism_rendering_init( } #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM) ) + if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else if ( !( output_config == AUDIO_CONFIG_EXTERNAL || output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index ca48e4bdf2..6eea8591f5 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1100,7 +1100,7 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDiracDecBin != NULL ) { #endif - /* regularization factor is bitrate-dependent */ + /* regularization factor is bitrate-dependent */ #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); } @@ -1185,7 +1185,7 @@ void ivas_spar_param_to_masa_param_mapping( hSpatParamRendCom = st_ivas->hSpatParamRendCom; hSpatParamRendCom->numSimultaneousDirections = 1; #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; /* TODO: this may need to use different pose indices */ + hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; /* TODO: this may need to use different pose indices */ #else hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3fbbb27d8f..969590e2a3 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -286,7 +286,96 @@ void IVAS_DEC_Close( return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * mapAudioConfig2DecAudoioConfig() + * + * + *---------------------------------------------------------------------*/ + +static IVAS_DEC_AUDIO_CONFIG mapAudioConfig2DecAudoioConfig( + const AUDIO_CONFIG audio_config ) +{ + IVAS_DEC_AUDIO_CONFIG dec_audio_config; + if ( audio_config == AUDIO_CONFIG_EXTERNAL ) /* external renderer */ + { + dec_audio_config = IVAS_DEC_OUTPUT_EXT; + } + else if ( audio_config == AUDIO_CONFIG_MONO ) + { + dec_audio_config = IVAS_DEC_OUTPUT_MONO; + } + else if ( audio_config == AUDIO_CONFIG_STEREO ) + { + dec_audio_config = IVAS_DEC_OUTPUT_STEREO; + } + else if ( audio_config == AUDIO_CONFIG_5_1 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_5_1; + } + else if ( audio_config == AUDIO_CONFIG_7_1 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_7_1; + } + else if ( audio_config == AUDIO_CONFIG_5_1_2 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_5_1_2; + } + else if ( audio_config == AUDIO_CONFIG_5_1_4 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_5_1_4; + } + else if ( audio_config == AUDIO_CONFIG_7_1_4 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_7_1_4; + } + else if ( audio_config == AUDIO_CONFIG_LS_CUSTOM ) + { + dec_audio_config = IVAS_DEC_OUTPUT_LS_CUSTOM; + } + else if ( audio_config == AUDIO_CONFIG_FOA ) + { + dec_audio_config = IVAS_DEC_OUTPUT_FOA; + } + else if ( audio_config == AUDIO_CONFIG_HOA2 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_HOA2; + } + else if ( audio_config == AUDIO_CONFIG_HOA3 ) + { + dec_audio_config = IVAS_DEC_OUTPUT_HOA3; + } + else if ( audio_config == AUDIO_CONFIG_BINAURAL ) + { + dec_audio_config = IVAS_DEC_OUTPUT_BINAURAL; + } + else if ( audio_config == AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + dec_audio_config = IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR; + } + else if ( audio_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + dec_audio_config = IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( audio_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + dec_audio_config = IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED; + } + else if ( audio_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + dec_audio_config = IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM; + } +#endif + else + { + dec_audio_config = IVAS_DEC_OUTPUT_UNKNOWN; + } + + return dec_audio_config; +} +#endif /*---------------------------------------------------------------------* * mapOutputFormat() @@ -3262,10 +3351,10 @@ ivas_error IVAS_DEC_GetCldfbSamples( num_samples = 0; if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) { - *audio_config = st_ivas->splitBinRend.hCldfbDataOut->config; + *audio_config = mapAudioConfig2DecAudoioConfig( st_ivas->splitBinRend.hCldfbDataOut->config ); if ( st_ivas->splitBinRend.hCldfbDataOut->config != AUDIO_CONFIG_INVALID ) { - getAudioConfigNumChannels( st_ivas->splitBinRend.hCldfbDataOut->config, &num_chs ); + num_chs = audioCfg2channels( st_ivas->splitBinRend.hCldfbDataOut->config ); maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) @@ -3284,7 +3373,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( } else { - *audio_config = AUDIO_CONFIG_INVALID; + *audio_config = IVAS_DEC_OUTPUT_UNKNOWN; } *nOutSamples = num_samples; return error; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index a408af8d4f..f0085cee84 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -101,13 +101,7 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_ static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t isHeadtracked ); #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN -static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], - float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe, - float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const uint8_t recompute ); +static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe, float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute ); #else static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe ); #endif @@ -231,9 +225,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( } #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ #else - if ( hDiracDecBin->hReverb == NULL ) + if ( hDiracDecBin->hReverb == NULL ) #endif { if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, @@ -273,7 +267,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( } #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( pos_idx == 0) /* open decorrelator only for the main direction */ + if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ { #endif if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) @@ -300,7 +294,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else { - hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ + hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ } #endif @@ -361,7 +355,7 @@ void ivas_dirac_dec_close_binaural_data( if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) { - ivas_dirac_dec_decorr_close( &(hBinaural[pos_idx]->h_freq_domain_decorr_ap_params), &(hBinaural[pos_idx]->h_freq_domain_decorr_ap_state) ); + ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); } free( hBinaural[pos_idx] ); @@ -877,8 +871,8 @@ static void ivas_dirac_dec_binaural_internal( { for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) { - mvr2r(tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); - mvr2r(tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); } } } @@ -901,8 +895,8 @@ static void ivas_dirac_dec_binaural_internal( if ( hCombinedOrientationData ) { Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; - Quaternions_rot.w = -3.0f; /* signal to use Euler */ - Quaternions_abs.w = -3.0f; /* signal to use Euler */ + Quaternions_rot.w = -3.0f; /* signal to use Euler */ + Quaternions_abs.w = -3.0f; /* signal to use Euler */ Quat2EulerDegree( *Quaternions_ref, &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ for ( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) @@ -914,7 +908,7 @@ static void ivas_dirac_dec_binaural_internal( QuatToRotMat( Quaternions_rot, Rmat_local ); hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; - assert(hDiracDecBin != NULL && "No DiracDecBin handle for this position"); + assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); if ( config_data.ivas_format == SBA_FORMAT ) { hDiracDecBin->hDiffuseDist = &diffuseDistData; @@ -923,10 +917,10 @@ static void ivas_dirac_dec_binaural_internal( /* re-use input covariance for the side renderings */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - mvr2r(st_ivas->hDiracDecBin[0]->ChEne[ch], hDiracDecBin->ChEne[ch], hSpatParamRendCom->num_freq_bands); + mvr2r( st_ivas->hDiracDecBin[0]->ChEne[ch], hDiracDecBin->ChEne[ch], hSpatParamRendCom->num_freq_bands ); } - mvr2r(st_ivas->hDiracDecBin[0]->ChCrossRe, hDiracDecBin->ChCrossRe, hSpatParamRendCom->num_freq_bands); - mvr2r(st_ivas->hDiracDecBin[0]->ChCrossIm, hDiracDecBin->ChCrossIm, hSpatParamRendCom->num_freq_bands); + mvr2r( st_ivas->hDiracDecBin[0]->ChCrossRe, hDiracDecBin->ChCrossRe, hSpatParamRendCom->num_freq_bands ); + mvr2r( st_ivas->hDiracDecBin[0]->ChCrossIm, hDiracDecBin->ChCrossIm, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, @@ -940,15 +934,15 @@ static void ivas_dirac_dec_binaural_internal( ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe, reverbIm, - decorrRe, decorrIm, 0); + decorrRe, decorrIm, 0 ); /* copy from temporary buffer to the main split rendering buffer */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) { - mvr2r(tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); - mvr2r(tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX); + mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); } } @@ -1678,7 +1672,7 @@ static void ivas_dirac_dec_binaural_process_output( float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute #endif - ) +) { int16_t slot, bin, chA, chB; int16_t nBins; @@ -1725,16 +1719,16 @@ static void ivas_dirac_dec_binaural_process_output( #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - mvr2r(decSlotRe[chA], decorrRe[chA][slot], CLDFB_NO_CHANNELS_MAX); - mvr2r(decSlotIm[chA], decorrIm[chA][slot], CLDFB_NO_CHANNELS_MAX); + mvr2r( decSlotRe[chA], decorrRe[chA][slot], CLDFB_NO_CHANNELS_MAX ); + mvr2r( decSlotIm[chA], decorrIm[chA][slot], CLDFB_NO_CHANNELS_MAX ); } } else { for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - mvr2r(decorrRe[chA][slot], decSlotRe[chA], CLDFB_NO_CHANNELS_MAX); - mvr2r(decorrIm[chA][slot], decSlotIm[chA], CLDFB_NO_CHANNELS_MAX); + mvr2r( decorrRe[chA][slot], decSlotRe[chA], CLDFB_NO_CHANNELS_MAX ); + mvr2r( decorrIm[chA][slot], decSlotIm[chA], CLDFB_NO_CHANNELS_MAX ); } } #endif @@ -1806,8 +1800,8 @@ static void ivas_dirac_dec_binaural_process_output( if ( outRe != NULL && outIm != NULL ) { /* provide the data outside in CLDFB domain => mainly for split rendering */ - mvr2r(outSlotRePr, outRe[chA][slot], CLDFB_NO_CHANNELS_MAX); - mvr2r(outSlotImPr, outIm[chA][slot], CLDFB_NO_CHANNELS_MAX); + mvr2r( outSlotRePr, outRe[chA][slot], CLDFB_NO_CHANNELS_MAX ); + mvr2r( outSlotImPr, outIm[chA][slot], CLDFB_NO_CHANNELS_MAX ); } if ( recompute == 1 ) { -- GitLab From 557547b5ac7fbd5b6a43b9de05ca8b8192745b0f Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 27 Jul 2023 12:32:11 +1000 Subject: [PATCH 11/33] new line warning fix --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 969590e2a3..e83e5a7e3c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3378,4 +3378,4 @@ ivas_error IVAS_DEC_GetCldfbSamples( *nOutSamples = num_samples; return error; } -#endif \ No newline at end of file +#endif -- GitLab From 775d29c21762daf4f34606a42ff1ce78a110e626 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 27 Jul 2023 15:00:16 +1000 Subject: [PATCH 12/33] JBM fix in MC param upmix path in SR mode --- lib_dec/ivas_binRenderer_internal.c | 27 +++++++++++++++++++++++++++ lib_dec/ivas_jbm_dec.c | 21 +++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index f8d000e429..555333785e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1496,6 +1496,33 @@ void ivas_binaural_cldfb_sf( idx_in++; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), + Cldfb_RealBuffer[idx_in][slot_idx], + Cldfb_ImagBuffer[idx_in][slot_idx], + maxBand, st_ivas->cldfbAnaDec[idx_in] ); + idx_in++; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->splitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_index_start + slot_idx], maxBand ); + } + st_ivas->splitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } +#endif + } +#endif } /* Implement binaural rendering */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e1a7a9cbd2..436c08c417 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -926,11 +926,17 @@ ivas_error ivas_jbm_dec_render( ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output ); /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*no HPF when rendering is already done*/ + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif { - if ( n != LFE_CHANNEL ) + for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( p_output[n], *nSamplesRendered, st_ivas->mem_hp20_out[n], output_Fs ); + if ( n != LFE_CHANNEL ) + { + hp20( p_output[n], *nSamplesRendered, st_ivas->mem_hp20_out[n], output_Fs ); + } } } @@ -942,7 +948,14 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*handled in CLDFB domain already*/ + if ( ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + { + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + } } else if ( st_ivas->renderer_type == RENDERER_MC ) { -- GitLab From 4654968cc25ba524913493b9a9bbe4c598017be2 Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Fri, 28 Jul 2023 11:21:14 +1000 Subject: [PATCH 13/33] Uncomment split rendering tests with MASA input and MC 160kbps --- tests/renderer/constants.py | 4 +- tests/split_rendering/constants.py | 14 ++-- tests/split_rendering/test_split_rendering.py | 65 ++++++------------- .../test_split_rendering_be_comparison.py | 62 ++++++------------ 4 files changed, 49 insertions(+), 96 deletions(-) diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index 877a1454c2..4967f66da6 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -164,9 +164,7 @@ FORMAT_TO_METADATA_FILES = { INPUT_FORMATS_AMBI = ["FOA", "HOA2", "HOA3"] INPUT_FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] INPUT_FORMATS_ISM = ["ISM1", "ISM2", "ISM3", "ISM4"] -INPUT_FORMATS_MASA = [ - "MASA2" -] # ["MASA1", "MASA2"] # Disable MASA1 tests until MASA1 can be implemented properly +INPUT_FORMATS_MASA = ["MASA1", "MASA2"] """ Non binaural / parametric output formats """ OUTPUT_FORMATS = [ diff --git a/tests/split_rendering/constants.py b/tests/split_rendering/constants.py index e50d916cf6..e500f526d2 100644 --- a/tests/split_rendering/constants.py +++ b/tests/split_rendering/constants.py @@ -82,8 +82,8 @@ FORMAT_TO_IVAS_COD_FORMAT = { "FOA": ["-sba", "1"], "HOA2": ["-sba", "2"], "HOA3": ["-sba", "3"], - # "MASA1": ["-masa", "1"], - # "MASA2": ["-masa", "2"], + "MASA1": ["-masa", "1"], + "MASA2": ["-masa", "2"], } FORMAT_TO_NCHAN = { @@ -101,16 +101,14 @@ FORMAT_TO_NCHAN = { "FOA": 4, "HOA2": 9, "HOA3": 16, - # "MASA1": 1, - # "MASA2": 2, + "MASA1": 1, + "MASA2": 2, } IVAS_BITRATES_AMBI = ["96000", "512000"] -IVAS_BITRATES_MC = ["128000", "384000"] -# TODO: Enable after MC 160kbps split rendering support -# IVAS_BITRATES_MC = ["128000", "160000", "384000"] +IVAS_BITRATES_MC = ["128000", "160000", "384000"] IVAS_BITRATES_ISM = ["128000"] -# IVAS_BITRATES_MASA = ["128000"] +IVAS_BITRATES_MASA = ["24400", "128000"] IVAS_MAX_ISM_BITRATE = { "1": "128000", diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 82e8a0ac58..ecfa875f4a 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -83,8 +83,6 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory) def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): if "0dof_768k_default" in render_config: pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - if in_fmt in ("MONO", "STEREO",): - pytest.xfail("Split Rendering currently not supported with MONO or STEREO") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -105,8 +103,6 @@ def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config def test_multichannel_external_split(test_info, in_fmt, render_config, trajectory): if "0dof_768k_default" in render_config: pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - if in_fmt in ("MONO", "STEREO",): - pytest.xfail("Split Rendering currently not supported with MONO or STEREO") post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -166,43 +162,24 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): """ MASA """ -# TODO - - -# @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) -# @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) -# @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): -# if "0dof_768k_lc3plus" in render_config: -# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - -# post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") -# pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") - -# run_full_chain_split_rendering( -# in_fmt=in_fmt, -# bitrate=bitrate, -# render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), -# pre_trajectory=pre_trajectory, -# post_trajectory=post_trajectory, -# output_path_base=OUTPUT_PATH_CUT, -# ) - -# @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) -# @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_external_split(test_info, in_fmt, render_config, trajectory): -# if "0dof_768k_lc3plus" in render_config: -# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - -# post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") -# pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") - -# run_external_split_rendering( -# in_fmt=in_fmt, -# render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), -# pre_trajectory=pre_trajectory, -# post_trajectory=post_trajectory, -# output_path_base=OUTPUT_PATH_CUT, -# ) + + +@pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) +def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + + post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") + pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") + + run_full_chain_split_rendering( + in_fmt=in_fmt, + bitrate=bitrate, + render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), + pre_trajectory=pre_trajectory, + post_trajectory=post_trajectory, + output_path_base=OUTPUT_PATH_CUT, + ) diff --git a/tests/split_rendering/test_split_rendering_be_comparison.py b/tests/split_rendering/test_split_rendering_be_comparison.py index 70ee753af2..3cd037233a 100644 --- a/tests/split_rendering/test_split_rendering_be_comparison.py +++ b/tests/split_rendering/test_split_rendering_be_comparison.py @@ -162,44 +162,24 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): """ MASA """ -# TODO - - -# @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) -# @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) -# @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): -# if "0dof_768k_lc3plus" in render_config: -# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - -# post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") -# pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") - -# compare_full_chain_split_args( -# test_info, -# in_fmt=in_fmt, -# bitrate=bitrate, -# render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), -# pre_trajectory=pre_trajectory, -# post_trajectory=post_trajectory, -# ) - - -# @pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) -# @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) -# @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) -# def test_masa_external_split(test_info, in_fmt, render_config, trajectory): -# if "0dof_768k_lc3plus" in render_config: -# pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - -# post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") -# pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") - -# compare_external_split_args( -# test_info, -# in_fmt=in_fmt, -# render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), -# pre_trajectory=pre_trajectory, -# post_trajectory=post_trajectory, -# ) + + +@pytest.mark.parametrize("trajectory", HR_TRAJECTORIES_TO_TEST) +@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MASA) +@pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) +def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): + if "0dof_768k_lc3plus" in render_config: + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + + post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") + pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") + + compare_full_chain_split_args( + test_info, + in_fmt=in_fmt, + bitrate=bitrate, + render_config=RENDER_CFG_DIR.joinpath(f"{render_config}.txt"), + pre_trajectory=pre_trajectory, + post_trajectory=post_trajectory, + ) -- GitLab From 2ceeb4d4aaee7dbd51ea619b68c888518bbf239f Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Fri, 28 Jul 2023 11:29:02 +1000 Subject: [PATCH 14/33] Remove unused split rendering scripts, renderer configs, and trajectories --- .../split_renderer_config_384_3dof.txt | 11 -- .../split_renderer_config_384_3dof_hq.txt | 11 -- .../split_renderer_config_512_2dof.txt | 11 -- .../split_renderer_config_768_1dof.txt | 11 -- ...t_renderer_config_768_1dof_hoa_lc3plus.txt | 11 -- .../split_renderer_config_768_2dof.txt | 11 -- .../split_renderer_config_fc_384_3dof.txt | 11 -- .../split_renderer_config_fc_384_3dof_hq.txt | 11 -- .../split_renderer_config_fc_512_2dof.txt | 11 -- .../split_renderer_config_fc_768_1dof.txt | 11 -- .../split_renderer_config_pcm_1dof.txt | 10 -- .../split_renderer_config_pcm_2dof.txt | 10 -- .../split_renderer_config_pcm_3dof.txt | 10 -- .../split_renderer_config_pcm_3dof_hq.txt | 10 -- .../sample_split_rend_script_ivas_enc_dec.py | 138 -------------- ...mple_split_rend_script_ivas_enc_dec_ism.py | 170 ------------------ .../sample_split_rend_script_ivas_rend.py | 147 --------------- .../sample_split_rend_script_ivas_rend_ism.py | 151 ---------------- .../sample_split_rend_script_ivas_rend_mc.py | 145 --------------- .../post-renderer_pose_files/post_0static.csv | 4 - .../pre_pitch-20static.csv | 4 - .../pre_pitch20static.csv | 4 - .../pre_roll-20static.csv | 4 - .../pre_roll20static.csv | 4 - .../pre_yaw-20pitch-20static.csv | 4 - .../pre_yaw-20static.csv | 4 - .../pre_yaw20pitch20static.csv | 4 - .../pre_yaw20static.csv | 4 - 28 files changed, 937 deletions(-) delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_384_3dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_384_3dof_hq.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_512_2dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_768_1dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_768_2dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof_hq.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_fc_512_2dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_fc_768_1dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_pcm_1dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_pcm_2dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof.txt delete mode 100644 Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof_hq.txt delete mode 100644 Workspace_msvc/sample_split_rend_script_ivas_enc_dec.py delete mode 100644 Workspace_msvc/sample_split_rend_script_ivas_enc_dec_ism.py delete mode 100644 Workspace_msvc/sample_split_rend_script_ivas_rend.py delete mode 100644 Workspace_msvc/sample_split_rend_script_ivas_rend_ism.py delete mode 100644 Workspace_msvc/sample_split_rend_script_ivas_rend_mc.py delete mode 100644 Workspace_msvc/trajectories/post-renderer_pose_files/post_0static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch-20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll-20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20pitch-20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20pitch20static.csv delete mode 100644 Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20static.csv diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof.txt deleted file mode 100644 index 0889c6f2d0..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 384000; -DOF = 3; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof_hq.txt b/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof_hq.txt deleted file mode 100644 index fb8adf64cf..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_384_3dof_hq.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 384000; -DOF = 3; -HQMODE = 1; -CODEC = LCLD; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_512_2dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_512_2dof.txt deleted file mode 100644 index ec4418eca3..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_512_2dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 512000; -DOF = 2; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof.txt deleted file mode 100644 index 02b4665e72..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 768000; -DOF = 1; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt b/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt deleted file mode 100644 index ca6fbaf9d3..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 768000; -DOF = 1; -HQMODE = 0; -CODEC = LC3PLUS; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_768_2dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_768_2dof.txt deleted file mode 100644 index 8aaccb64fe..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_768_2dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 768000; -DOF = 2; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof.txt deleted file mode 100644 index dccf44a9f3..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 384000; -DOF = 3; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = FASTCONV; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof_hq.txt b/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof_hq.txt deleted file mode 100644 index 5a9770e61d..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_fc_384_3dof_hq.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 384000; -DOF = 3; -HQMODE = 1; -CODEC = LCLD; - -[GENERAL] -RENDERER = FASTCONV; - -[ROOMACOUSTICS] -REVERB = FALSE; \ No newline at end of file diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_fc_512_2dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_fc_512_2dof.txt deleted file mode 100644 index 112177d636..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_fc_512_2dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 512000; -DOF = 2; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = FASTCONV; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_fc_768_1dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_fc_768_1dof.txt deleted file mode 100644 index 68221b269e..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_fc_768_1dof.txt +++ /dev/null @@ -1,11 +0,0 @@ -[SPLITREND] -BITRATE = 768000; -DOF = 1; -HQMODE = 0; -CODEC = LCLD; - -[GENERAL] -RENDERER = FASTCONV; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_1dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_pcm_1dof.txt deleted file mode 100644 index d956b90ce6..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_1dof.txt +++ /dev/null @@ -1,10 +0,0 @@ -[SPLITREND] -BITRATE = 256000; -DOF = 1; -HQMODE = 0; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_2dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_pcm_2dof.txt deleted file mode 100644 index d8eb266458..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_2dof.txt +++ /dev/null @@ -1,10 +0,0 @@ -[SPLITREND] -BITRATE = 384000; -DOF = 2; -HQMODE = 0; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof.txt b/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof.txt deleted file mode 100644 index e8c9088862..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof.txt +++ /dev/null @@ -1,10 +0,0 @@ -[SPLITREND] -BITRATE = 512000; -DOF = 3; -HQMODE = 0; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof_hq.txt b/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof_hq.txt deleted file mode 100644 index 4e38b77145..0000000000 --- a/Workspace_msvc/renderer_configs/split_renderer_config_pcm_3dof_hq.txt +++ /dev/null @@ -1,10 +0,0 @@ -[SPLITREND] -BITRATE = 768000; -DOF = 3; -HQMODE = 1; - -[GENERAL] -RENDERER = CREND; - -[ROOMACOUSTICS] -REVERB = FALSE; diff --git a/Workspace_msvc/sample_split_rend_script_ivas_enc_dec.py b/Workspace_msvc/sample_split_rend_script_ivas_enc_dec.py deleted file mode 100644 index 2c545b4239..0000000000 --- a/Workspace_msvc/sample_split_rend_script_ivas_enc_dec.py +++ /dev/null @@ -1,138 +0,0 @@ -from scipy.io.wavfile import read, write -from scipy import signal -import subprocess -import numpy as np -import sys -import os - -## dimension of following 2 arrays should be same, that is for each file name there should be a tag -file_names = [ -'../scripts/testv/stv3OA48c.wav' -]; -file_tags = [ -'test_HOA3' -]; - -## dimension of following 3 arrays should be same, that is for each pre file there should be a post file and a tag -pre_hr_file_names = [ -'trajectories/pre-renderer_pose_files/pre_yaw20static.csv' -]; -post_hr_file_names = [ -'trajectories/post-renderer_pose_files/post_0static.csv' -]; -hr_file_tags = [ -'yaw20static' -]; - -renderers = [ -('fast_conv_768_1dof', 'renderer_configs/split_renderer_config_fc_768_1dof.txt', '0'), -('fast_conv_512_2dof', 'renderer_configs/split_renderer_config_fc_512_2dof.txt', '0'), -('fast_conv_384_3dof', 'renderer_configs/split_renderer_config_fc_384_3dof.txt', '0'), -('fast_conv_384_3dof_hq', 'renderer_configs/split_renderer_config_fc_384_3dof_hq.txt', '0')]; - - -split_rend_file_outs = ['recons_out_pos0.wav', - 'recons_out_pos1.wav', - 'recons_out_pos2.wav', - 'rotated_ref_pos0.wav', - 'rotated_ref_pos1.wav', - 'rotated_ref_pos2.wav', - 'rotated_ref_RefPos.wav', - 'split_rend_MD_bitrate.txt'] - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - - -def generate_split_rend_lis_items(file_dir, exe_dir, out_dir): - check_and_makedir(out_dir); - for idx in range(0, len(file_tags)): - for hr_idx in range(0, len(hr_file_tags)): - for rend in range(0, len(renderers)): - bitrate = '384000'; - filename = file_names[idx]; - file_in = os.path.join(file_dir, filename); - enc_exe = os.path.join(exe_dir, 'IVAS_cod.exe'); - dec_exe = os.path.join(exe_dir, 'IVAS_dec.exe'); - rend_exe = os.path.join(exe_dir, 'IVAS_rend.exe'); - file_pkt_name = '_'.join([file_tags[idx], bitrate, 'out.pkt']); - file_pkt = os.path.join(out_dir, file_pkt_name); - file_out_name = '_'.join([file_tags[idx], bitrate, renderers[rend][0], 'out.wav']); - file_out = os.path.join(out_dir, file_out_name); - bs_file_out_name = '_'.join([file_tags[idx], '_ivas_dec_out.pkt']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - - print(file_in) - print(file_pkt) - print(bs_file_out) - print(file_out) - - enc_cmd = [ - enc_exe, - '-sba', '3', - '-max_band', 'FB', - bitrate, - '48', - file_in, - file_pkt - ] - - hr_pre_file_name = pre_hr_file_names[hr_idx]; - hr_pre_file = os.path.join(file_dir, hr_pre_file_name); - hr_post_file_name = post_hr_file_names[hr_idx]; - hr_post_file = os.path.join(file_dir, hr_post_file_name); - - dec_cmd = [ - dec_exe, - '-RENDER_CONFIG', renderers[rend][1], - '-t', hr_pre_file, - 'BINAURAL_SPLIT_CODED', - '48', - file_pkt, - bs_file_out - ] - print(enc_cmd) - print(dec_cmd) - test_status = subprocess.call(enc_cmd, shell=False) - test_status = subprocess.call(dec_cmd, shell=False) - - post_rend_cmd = [ - rend_exe, - '-i', bs_file_out, - '-if', 'BINAURAL_SPLIT_CODED', - '-o', file_out, - '-of', 'BINAURAL', - '-fs', '48', - '-tf', hr_post_file, - ] - print(post_rend_cmd) - test_status = subprocess.call(post_rend_cmd, shell=False) - - if os.path.isfile(file_pkt): - os.remove(file_pkt) - - if os.path.exists(bs_file_out): - os.remove(bs_file_out); - - for fo in split_rend_file_outs: - file_old = os.path.join(os. getcwd(), fo); - file_out_name = '_'.join([file_tags[idx], hr_file_tags[hr_idx], fo]); - file_new = os.path.join(out_dir, file_out_name); - if os.path.exists(file_old): - os.rename(file_old, file_new); - - -def main(argv): - print('USAGE : python generate_split_rend_lis_items.py file_dir exe_dir out_dir') - if len(argv) < 3: - return print(len(argv)) - return generate_split_rend_lis_items(*argv[1:]) - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) \ No newline at end of file diff --git a/Workspace_msvc/sample_split_rend_script_ivas_enc_dec_ism.py b/Workspace_msvc/sample_split_rend_script_ivas_enc_dec_ism.py deleted file mode 100644 index 61c9d65963..0000000000 --- a/Workspace_msvc/sample_split_rend_script_ivas_enc_dec_ism.py +++ /dev/null @@ -1,170 +0,0 @@ -from scipy.io.wavfile import read, write -from scipy import signal -import subprocess -import numpy as np -import sys -import os - -## dimension of following 2 arrays should be same, that is for each file name there should be a tag -file_names = [ -'../scripts/testv/stv4ISM48s.wav' -]; -ism_md_file_names = [ -'../scripts/testv/stvISM1.csv', -'../scripts/testv/stvISM2.csv', -'../scripts/testv/stvISM3.csv', -'../scripts/testv/stvISM4.csv' -]; -file_tags = [ -'test_ISM' -]; - -## dimension of following 3 arrays should be same, that is for each pre file there should be a post file and a tag -pre_hr_file_names = [ -'trajectories/pre-renderer_pose_files/pre_yaw20static.csv' -]; -post_hr_file_names = [ -'trajectories/post-renderer_pose_files/post_0static.csv' -]; -hr_file_tags = [ -'yaw20static' -]; - -renderers = [ -('crend_768_1dof', 'renderer_configs/split_renderer_config_768_1dof.txt', '0'), -('crend_pcm_1dof', 'renderer_configs/split_renderer_config_pcm_1dof.txt', '1'), -('crend_512_2dof', 'renderer_configs/split_renderer_config_512_2dof.txt', '0'), -('crend_pcm_2dof', 'renderer_configs/split_renderer_config_pcm_2dof.txt', '1'), -('crend_384_3dof', 'renderer_configs/split_renderer_config_384_3dof.txt', '0'), -('crend_pcm_3dof', 'renderer_configs/split_renderer_config_pcm_3dof.txt', '1'), -('crend_384_3dof_hq', 'renderer_configs/split_renderer_config_384_3dof_hq.txt', '0'), -('crend_pcm_3dof_hq', 'renderer_configs/split_renderer_config_pcm_3dof_hq.txt', '1'), -('crend_lc3plus_1dof', 'renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt', '0')]; - -split_md_file_name = 'split_md.bin'; - -split_rend_file_outs = ['recons_out_pos0.wav', - 'recons_out_pos1.wav', - 'recons_out_pos2.wav', - 'rotated_ref_pos0.wav', - 'rotated_ref_pos1.wav', - 'rotated_ref_pos2.wav', - 'rotated_ref_RefPos.wav', - 'split_rend_MD_bitrate.txt'] - - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - - -def generate_split_rend_lis_items(file_dir, exe_dir, out_dir): - check_and_makedir(out_dir); - for idx in range(0, len(file_tags)): - for hr_idx in range(0, len(hr_file_tags)): - for rend in range(0, len(renderers)): - bitrate = '384000'; - filename = file_names[idx]; - file_in = os.path.join(file_dir, filename); - enc_exe = os.path.join(exe_dir, 'IVAS_cod.exe'); - dec_exe = os.path.join(exe_dir, 'IVAS_dec.exe'); - rend_exe = os.path.join(exe_dir, 'IVAS_rend.exe'); - file_pkt_name = '_'.join([file_tags[idx], bitrate, 'out.pkt']); - file_pkt = os.path.join(out_dir, file_pkt_name); - if renderers[rend][2] == '0': - bs_file_out_name = '_'.join([file_tags[idx], 'out.pkt']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_CODED'; - else: - bs_file_out_name = '_'.join([file_tags[idx], 'out.wav']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_PCM'; - md_out_arg = ['-om', split_md_file_name]; - md_in_arg = ['-im', split_md_file_name]; - file_out_name = '_'.join([file_tags[idx], renderers[rend][0], 'out.wav']); - file_out = os.path.join(out_dir, file_out_name); - - print(file_in) - print(bs_file_out) - print(file_out) - print(file_pkt) - - hr_pre_file_name = pre_hr_file_names[hr_idx]; - hr_pre_file = os.path.join(file_dir, hr_pre_file_name); - hr_post_file_name = post_hr_file_names[hr_idx]; - hr_post_file = os.path.join(file_dir, hr_post_file_name); - - enc_cmd = [ - enc_exe, - '-ism', '4', ism_md_file_names[0], ism_md_file_names[1], ism_md_file_names[2], ism_md_file_names[3], - '-max_band', 'FB', - bitrate, - '48', - file_in, - file_pkt - ] - - print(enc_cmd) - test_status = subprocess.call(enc_cmd, shell=False) - - dec_cmd = [ - dec_exe, - '-RENDER_CONFIG', renderers[rend][1], - md_out_arg[0], md_out_arg[1], - '-t', hr_pre_file, - out_fmt, - '48', - file_pkt, - bs_file_out - ] - - print(dec_cmd) - test_status = subprocess.call(dec_cmd, shell=False) - - - post_rend_cmd = [ - rend_exe, - md_in_arg[0], md_in_arg[1], - '-i', bs_file_out, - '-if', out_fmt, - '-o', file_out, - '-of', 'BINAURAL', - '-fs', '48', - '-tf', hr_post_file, - ] - - - print(post_rend_cmd) - test_status = subprocess.call(post_rend_cmd, shell=False) - - if os.path.exists(file_pkt): - os.remove(file_pkt); - - if os.path.exists(bs_file_out): - os.remove(bs_file_out); - - if os.path.exists(split_md_file_name): - os.remove(split_md_file_name); - - - for fo in split_rend_file_outs: - file_old = os.path.join(os. getcwd(), fo); - file_out_name = '_'.join([file_tags[idx], hr_file_tags[hr_idx], renderers[rend][0], fo]); - file_new = os.path.join(out_dir, file_out_name); - if os.path.exists(file_old): - os.rename(file_old, file_new); - - -def main(argv): - print('USAGE : python generate_split_rend_lis_items.py file_dir exe_dir out_dir') - if len(argv) < 3: - return print(len(argv)) - return generate_split_rend_lis_items(*argv[1:]) - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) \ No newline at end of file diff --git a/Workspace_msvc/sample_split_rend_script_ivas_rend.py b/Workspace_msvc/sample_split_rend_script_ivas_rend.py deleted file mode 100644 index fe81a2c39d..0000000000 --- a/Workspace_msvc/sample_split_rend_script_ivas_rend.py +++ /dev/null @@ -1,147 +0,0 @@ -from scipy.io.wavfile import read, write -from scipy import signal -import subprocess -import numpy as np -import sys -import os - -## dimension of following 2 arrays should be same, that is for each file name there should be a tag -file_names = [ -'../scripts/testv/stv3OA48c.wav' -]; -file_tags = [ -'test_HOA3' -]; - -## dimension of following 3 arrays should be same, that is for each pre file there should be a post file and a tag -pre_hr_file_names = [ -'trajectories/pre-renderer_pose_files/pre_yaw20static.csv' -]; -post_hr_file_names = [ -'trajectories/post-renderer_pose_files/post_0static.csv' -]; -hr_file_tags = [ -'yaw20static' -]; - -renderers = [ -('crend_768_1dof', 'renderer_configs/split_renderer_config_768_1dof.txt', '0'), -('crend_pcm_1dof', 'renderer_configs/split_renderer_config_pcm_1dof.txt', '1'), -('fast_conv_768_1dof', 'renderer_configs/split_renderer_config_fc_768_1dof.txt', '0'), -('crend_512_2dof', 'renderer_configs/split_renderer_config_512_2dof.txt', '0'), -('crend_pcm_2dof', 'renderer_configs/split_renderer_config_pcm_2dof.txt', '1'), -('fast_conv_512_2dof', 'renderer_configs/split_renderer_config_fc_512_2dof.txt', '0'), -('crend_384_3dof', 'renderer_configs/split_renderer_config_384_3dof.txt', '0'), -('crend_pcm_3dof', 'renderer_configs/split_renderer_config_pcm_3dof.txt', '1'), -('fast_conv_384_3dof', 'renderer_configs/split_renderer_config_fc_384_3dof.txt', '0'), -('crend_384_3dof_hq', 'renderer_configs/split_renderer_config_384_3dof_hq.txt', '0'), -('crend_pcm_3dof_hq', 'renderer_configs/split_renderer_config_pcm_3dof_hq.txt', '1'), -('fast_conv_384_3dof_hq', 'renderer_configs/split_renderer_config_fc_384_3dof_hq.txt', '0')]; - -split_md_file_name = 'split_md.bin'; - -split_rend_file_outs = ['recons_out_pos0.wav', - 'recons_out_pos1.wav', - 'recons_out_pos2.wav', - 'rotated_ref_pos0.wav', - 'rotated_ref_pos1.wav', - 'rotated_ref_pos2.wav', - 'rotated_ref_RefPos.wav', - 'split_rend_MD_bitrate.txt'] - - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - - -def generate_split_rend_lis_items(file_dir, exe_dir, out_dir): - check_and_makedir(out_dir); - for idx in range(0, len(file_tags)): - for hr_idx in range(0, len(hr_file_tags)): - for rend in range(0, len(renderers)): - filename = file_names[idx]; - file_in = os.path.join(file_dir, filename); - rend_exe = os.path.join(exe_dir, 'IVAS_rend.exe'); - if renderers[rend][2] == '0': - bs_file_out_name = '_'.join([file_tags[idx], 'out.pkt']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_CODED'; - else: - bs_file_out_name = '_'.join([file_tags[idx], 'out.wav']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_PCM'; - md_out_arg = ['-om', split_md_file_name]; - md_in_arg = ['-im', split_md_file_name]; - file_out_name = '_'.join([file_tags[idx], renderers[rend][0], 'out.wav']); - file_out = os.path.join(out_dir, file_out_name); - - print(file_in) - print(bs_file_out) - print(file_out) - - hr_pre_file_name = pre_hr_file_names[hr_idx]; - hr_pre_file = os.path.join(file_dir, hr_pre_file_name); - hr_post_file_name = post_hr_file_names[hr_idx]; - hr_post_file = os.path.join(file_dir, hr_post_file_name); - - pre_rend_cmd = [ - rend_exe, - '-rc', renderers[rend][1], - md_out_arg[0], md_out_arg[1], - '-i', file_in, - '-if', 'HOA3', - '-o', bs_file_out, - '-of', out_fmt, - '-fs', '48', - '-tf', hr_pre_file, - ] - - - print(pre_rend_cmd) - test_status = subprocess.call(pre_rend_cmd, shell=False) - - - post_rend_cmd = [ - rend_exe, - md_in_arg[0], md_in_arg[1], - '-i', bs_file_out, - '-if', out_fmt, - '-o', file_out, - '-of', 'BINAURAL', - '-fs', '48', - '-tf', hr_post_file, - ] - - - print(post_rend_cmd) - test_status = subprocess.call(post_rend_cmd, shell=False) - - if os.path.exists(bs_file_out): - os.remove(bs_file_out); - - if os.path.exists(split_md_file_name): - os.remove(split_md_file_name); - - - for fo in split_rend_file_outs: - file_old = os.path.join(os. getcwd(), fo); - file_out_name = '_'.join([file_tags[idx], hr_file_tags[hr_idx], renderers[rend][0], fo]); - file_new = os.path.join(out_dir, file_out_name); - if os.path.exists(file_old): - os.rename(file_old, file_new); - - -def main(argv): - print('USAGE : python generate_split_rend_lis_items.py file_dir exe_dir out_dir') - if len(argv) < 3: - return print(len(argv)) - return generate_split_rend_lis_items(*argv[1:]) - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) \ No newline at end of file diff --git a/Workspace_msvc/sample_split_rend_script_ivas_rend_ism.py b/Workspace_msvc/sample_split_rend_script_ivas_rend_ism.py deleted file mode 100644 index e4e4c5beba..0000000000 --- a/Workspace_msvc/sample_split_rend_script_ivas_rend_ism.py +++ /dev/null @@ -1,151 +0,0 @@ -from scipy.io.wavfile import read, write -from scipy import signal -import subprocess -import numpy as np -import sys -import os - -## dimension of following 2 arrays should be same, that is for each file name there should be a tag -file_names = [ -'../scripts/testv/stv4ISM48s.wav' -]; -ism_md_file_names = [ -'../scripts/testv/stvISM1.csv', -'../scripts/testv/stvISM2.csv', -'../scripts/testv/stvISM3.csv', -'../scripts/testv/stvISM4.csv' -]; -file_tags = [ -'test_ISM' -]; - -## dimension of following 3 arrays should be same, that is for each pre file there should be a post file and a tag -pre_hr_file_names = [ -'trajectories/pre-renderer_pose_files/pre_yaw20static.csv' -]; -post_hr_file_names = [ -'trajectories/post-renderer_pose_files/post_0static.csv' -]; -hr_file_tags = [ -'yaw20static' -]; - -renderers = [ -('crend_768_1dof', 'renderer_configs/split_renderer_config_768_1dof.txt', '0'), -('crend_pcm_1dof', 'renderer_configs/split_renderer_config_pcm_1dof.txt', '1'), -('crend_512_2dof', 'renderer_configs/split_renderer_config_512_2dof.txt', '0'), -('crend_pcm_2dof', 'renderer_configs/split_renderer_config_pcm_2dof.txt', '1'), -('crend_384_3dof', 'renderer_configs/split_renderer_config_384_3dof.txt', '0'), -('crend_pcm_3dof', 'renderer_configs/split_renderer_config_pcm_3dof.txt', '1'), -('crend_384_3dof_hq', 'renderer_configs/split_renderer_config_384_3dof_hq.txt', '0'), -('crend_pcm_3dof_hq', 'renderer_configs/split_renderer_config_pcm_3dof_hq.txt', '1'), -('crend_lc3plus_1dof', 'renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt', '0')]; - -split_md_file_name = 'split_md.bin'; - -split_rend_file_outs = ['recons_out_pos0.wav', - 'recons_out_pos1.wav', - 'recons_out_pos2.wav', - 'rotated_ref_pos0.wav', - 'rotated_ref_pos1.wav', - 'rotated_ref_pos2.wav', - 'rotated_ref_RefPos.wav', - 'split_rend_MD_bitrate.txt'] - - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - - -def generate_split_rend_lis_items(file_dir, exe_dir, out_dir): - check_and_makedir(out_dir); - for idx in range(0, len(file_tags)): - for hr_idx in range(0, len(hr_file_tags)): - for rend in range(0, len(renderers)): - filename = file_names[idx]; - file_in = os.path.join(file_dir, filename); - rend_exe = os.path.join(exe_dir, 'IVAS_rend.exe'); - if renderers[rend][2] == '0': - bs_file_out_name = '_'.join([file_tags[idx], 'out.pkt']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_CODED'; - else: - bs_file_out_name = '_'.join([file_tags[idx], 'out.wav']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_PCM'; - md_out_arg = ['-om', split_md_file_name]; - md_in_arg = ['-im', split_md_file_name]; - file_out_name = '_'.join([file_tags[idx], renderers[rend][0], 'out.wav']); - file_out = os.path.join(out_dir, file_out_name); - - print(file_in) - print(bs_file_out) - print(file_out) - - hr_pre_file_name = pre_hr_file_names[hr_idx]; - hr_pre_file = os.path.join(file_dir, hr_pre_file_name); - hr_post_file_name = post_hr_file_names[hr_idx]; - hr_post_file = os.path.join(file_dir, hr_post_file_name); - - pre_rend_cmd = [ - rend_exe, - '-rc', renderers[rend][1], - md_out_arg[0], md_out_arg[1], - '-i', file_in, - '-if', 'ISM4', - '-im', ism_md_file_names[0], ism_md_file_names[1], ism_md_file_names[2], ism_md_file_names[3], - '-o', bs_file_out, - '-of', out_fmt, - '-fs', '48', - '-tf', hr_pre_file, - ] - - - print(pre_rend_cmd) - test_status = subprocess.call(pre_rend_cmd, shell=False) - - - post_rend_cmd = [ - rend_exe, - md_in_arg[0], md_in_arg[1], - '-i', bs_file_out, - '-if', out_fmt, - '-o', file_out, - '-of', 'BINAURAL', - '-fs', '48', - '-tf', hr_post_file, - ] - - - print(post_rend_cmd) - test_status = subprocess.call(post_rend_cmd, shell=False) - - if os.path.exists(bs_file_out): - os.remove(bs_file_out); - - if os.path.exists(split_md_file_name): - os.remove(split_md_file_name); - - - for fo in split_rend_file_outs: - file_old = os.path.join(os. getcwd(), fo); - file_out_name = '_'.join([file_tags[idx], hr_file_tags[hr_idx], renderers[rend][0], fo]); - file_new = os.path.join(out_dir, file_out_name); - if os.path.exists(file_old): - os.rename(file_old, file_new); - - -def main(argv): - print('USAGE : python generate_split_rend_lis_items.py file_dir exe_dir out_dir') - if len(argv) < 3: - return print(len(argv)) - return generate_split_rend_lis_items(*argv[1:]) - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) \ No newline at end of file diff --git a/Workspace_msvc/sample_split_rend_script_ivas_rend_mc.py b/Workspace_msvc/sample_split_rend_script_ivas_rend_mc.py deleted file mode 100644 index ba258091f9..0000000000 --- a/Workspace_msvc/sample_split_rend_script_ivas_rend_mc.py +++ /dev/null @@ -1,145 +0,0 @@ -from scipy.io.wavfile import read, write -from scipy import signal -import subprocess -import numpy as np -import sys -import os - -## dimension of following 2 arrays should be same, that is for each file name there should be a tag -file_names = [ -'../scripts/testv/stv714MC48c.wav' -]; - -file_tags = [ -'test_MC714' -]; - -## dimension of following 3 arrays should be same, that is for each pre file there should be a post file and a tag -pre_hr_file_names = [ -'trajectories/pre-renderer_pose_files/pre_yaw20static.csv' -]; -post_hr_file_names = [ -'trajectories/post-renderer_pose_files/post_0static.csv' -]; -hr_file_tags = [ -'yaw20static' -]; - -renderers = [ -('crend_768_1dof', 'renderer_configs/split_renderer_config_768_1dof.txt', '0'), -('crend_pcm_1dof', 'renderer_configs/split_renderer_config_pcm_1dof.txt', '1'), -('crend_512_2dof', 'renderer_configs/split_renderer_config_512_2dof.txt', '0'), -('crend_pcm_2dof', 'renderer_configs/split_renderer_config_pcm_2dof.txt', '1'), -('crend_384_3dof', 'renderer_configs/split_renderer_config_384_3dof.txt', '0'), -('crend_pcm_3dof', 'renderer_configs/split_renderer_config_pcm_3dof.txt', '1'), -('crend_384_3dof_hq', 'renderer_configs/split_renderer_config_384_3dof_hq.txt', '0'), -('crend_pcm_3dof_hq', 'renderer_configs/split_renderer_config_pcm_3dof_hq.txt', '1'), -('crend_lc3plus_1dof', 'renderer_configs/split_renderer_config_768_1dof_hoa_lc3plus.txt', '0')]; - -split_md_file_name = 'split_md.bin'; - -split_rend_file_outs = ['recons_out_pos0.wav', - 'recons_out_pos1.wav', - 'recons_out_pos2.wav', - 'rotated_ref_pos0.wav', - 'rotated_ref_pos1.wav', - 'rotated_ref_pos2.wav', - 'rotated_ref_RefPos.wav', - 'split_rend_MD_bitrate.txt'] - - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - - -def generate_split_rend_lis_items(file_dir, exe_dir, out_dir): - check_and_makedir(out_dir); - for idx in range(0, len(file_tags)): - for hr_idx in range(0, len(hr_file_tags)): - for rend in range(0, len(renderers)): - filename = file_names[idx]; - file_in = os.path.join(file_dir, filename); - rend_exe = os.path.join(exe_dir, 'IVAS_rend.exe'); - if renderers[rend][2] == '0': - bs_file_out_name = '_'.join([file_tags[idx], 'out.pkt']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_CODED'; - else: - bs_file_out_name = '_'.join([file_tags[idx], 'out.wav']); - bs_file_out = os.path.join(out_dir, bs_file_out_name); - out_fmt = 'BINAURAL_SPLIT_PCM'; - md_out_arg = ['-om', split_md_file_name]; - md_in_arg = ['-im', split_md_file_name]; - file_out_name = '_'.join([file_tags[idx], renderers[rend][0], 'out.wav']); - file_out = os.path.join(out_dir, file_out_name); - - print(file_in) - print(bs_file_out) - print(file_out) - - hr_pre_file_name = pre_hr_file_names[hr_idx]; - hr_pre_file = os.path.join(file_dir, hr_pre_file_name); - hr_post_file_name = post_hr_file_names[hr_idx]; - hr_post_file = os.path.join(file_dir, hr_post_file_name); - - pre_rend_cmd = [ - rend_exe, - '-rc', renderers[rend][1], - md_out_arg[0], md_out_arg[1], - '-i', file_in, - '-if', '7_1_4', - '-o', bs_file_out, - '-of', out_fmt, - '-fs', '48', - '-tf', hr_pre_file, - ] - - - print(pre_rend_cmd) - test_status = subprocess.call(pre_rend_cmd, shell=False) - - - post_rend_cmd = [ - rend_exe, - md_in_arg[0], md_in_arg[1], - '-i', bs_file_out, - '-if', out_fmt, - '-o', file_out, - '-of', 'BINAURAL', - '-fs', '48', - '-tf', hr_post_file, - ] - - - print(post_rend_cmd) - test_status = subprocess.call(post_rend_cmd, shell=False) - - if os.path.exists(bs_file_out): - os.remove(bs_file_out); - - if os.path.exists(split_md_file_name): - os.remove(split_md_file_name); - - - for fo in split_rend_file_outs: - file_old = os.path.join(os. getcwd(), fo); - file_out_name = '_'.join([file_tags[idx], hr_file_tags[hr_idx], renderers[rend][0], fo]); - file_new = os.path.join(out_dir, file_out_name); - if os.path.exists(file_old): - os.rename(file_old, file_new); - - -def main(argv): - print('USAGE : python generate_split_rend_lis_items.py file_dir exe_dir out_dir') - if len(argv) < 3: - return print(len(argv)) - return generate_split_rend_lis_items(*argv[1:]) - - -if __name__ == "__main__": - sys.exit(main(sys.argv)) \ No newline at end of file diff --git a/Workspace_msvc/trajectories/post-renderer_pose_files/post_0static.csv b/Workspace_msvc/trajectories/post-renderer_pose_files/post_0static.csv deleted file mode 100644 index a292a3576c..0000000000 --- a/Workspace_msvc/trajectories/post-renderer_pose_files/post_0static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,0,0,0 --3,0,0,0 --3,0,0,0 --3,0,0,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch-20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch-20static.csv deleted file mode 100644 index dab3c6940a..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch-20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,0,-20,0 --3,0,-20,0 --3,0,-20,0 --3,0,-20,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch20static.csv deleted file mode 100644 index ae6ac9cd9c..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_pitch20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,0,20,0 --3,0,20,0 --3,0,20,0 --3,0,20,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll-20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll-20static.csv deleted file mode 100644 index 5db0b1cab3..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll-20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,0,0,-20 --3,0,0,-20 --3,0,0,-20 --3,0,0,-20 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll20static.csv deleted file mode 100644 index 5bd8c2c4d9..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_roll20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,0,0,20 --3,0,0,20 --3,0,0,20 --3,0,0,20 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20pitch-20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20pitch-20static.csv deleted file mode 100644 index e48c0a58f5..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20pitch-20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,-20,-20,0 --3,-20,-20,0 --3,-20,-20,0 --3,-20,-20,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20static.csv deleted file mode 100644 index 6e446847a9..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,-20,0,0 --3,-20,0,0 --3,-20,0,0 --3,-20,0,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20pitch20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20pitch20static.csv deleted file mode 100644 index 58788cc7de..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20pitch20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,20,20,0 --3,20,20,0 --3,20,20,0 --3,20,20,0 diff --git a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20static.csv b/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20static.csv deleted file mode 100644 index 2d674f971b..0000000000 --- a/Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw20static.csv +++ /dev/null @@ -1,4 +0,0 @@ --3,20,0,0 --3,20,0,0 --3,20,0,0 --3,20,0,0 -- GitLab From 9f6e86f9dfe9c56d6094e8dce4ebb0f12c46930f Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Fri, 28 Jul 2023 12:10:08 +1000 Subject: [PATCH 15/33] Revert the uncommenting of MASA1 input format in tests/renderer/constants.py --- tests/renderer/constants.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/renderer/constants.py b/tests/renderer/constants.py index 4967f66da6..877a1454c2 100644 --- a/tests/renderer/constants.py +++ b/tests/renderer/constants.py @@ -164,7 +164,9 @@ FORMAT_TO_METADATA_FILES = { INPUT_FORMATS_AMBI = ["FOA", "HOA2", "HOA3"] INPUT_FORMATS_MC = ["MONO", "STEREO", "5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] INPUT_FORMATS_ISM = ["ISM1", "ISM2", "ISM3", "ISM4"] -INPUT_FORMATS_MASA = ["MASA1", "MASA2"] +INPUT_FORMATS_MASA = [ + "MASA2" +] # ["MASA1", "MASA2"] # Disable MASA1 tests until MASA1 can be implemented properly """ Non binaural / parametric output formats """ OUTPUT_FORMATS = [ -- GitLab From 3471be7f002d51385e4e6b669d0885ca38c24d37 Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Fri, 28 Jul 2023 15:42:16 +1000 Subject: [PATCH 16/33] Add README.md for split rendering tests --- tests/split_rendering/README.md | 104 ++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 tests/split_rendering/README.md diff --git a/tests/split_rendering/README.md b/tests/split_rendering/README.md new file mode 100644 index 0000000000..27dad9f32d --- /dev/null +++ b/tests/split_rendering/README.md @@ -0,0 +1,104 @@ + + +# IVAS Split Rendering Tests +The IVAS split rendering tests are implemented using `pytest`. + +## Overview +The split rendering tests consist of: +* Smoke tests +* BE (bit exact) comparison tests + +The tests cover the following IVAS formats: +* Ambisonics +* Multi-Channel +* ISM +* MASA + +The tests include both split rendering operating modes: +* Full chain: encoder, decoder, external renderer +* External: external renderer only + +Note: MASA format only supports the full chain split rendering mode. + +Furthermore, the tests iterate over the following parameters: +* Renderer config file which specifies DoF (degrees of freedom), split rendering bitrate, and split rendering codec +* Trajectory file +* Encoder/decoder bitrate (only for full-chain split rendering mode) + +## Directory Structure + +``` +ivas-codec +├── tests +| ├── split_rendering +| | ├── test_split_rendering.py -> split rendering smoke tests +| | ├── test_split_rendering_be_comparison.py -> split rendering BE comparison tests +| | ├── constants.py -> split rendering constants +| | ├── utils.py -> split rendering functions +| | └── renderer_configs -> directory of render config files +| └── renderer +| ├── constants.py -> renderer constants +| └── utils.py -> renderer functions +└── scripts + └── trajectories -> directory of trajectory files +``` + +## Running Tests +### Smoke Tests +```bash +python3 -m pytest -n auto -rA tests/split_rendering/test_split_rendering.py +``` + +### BE Comparison Tests +```bash +python3 -m pytest -n auto -rA tests/split_rendering/test_split_rendering_be_comparison.py +``` + +## Useful pytest Options + +* `-h`: Help options +* `-n N`: Run tests in parallel using `N` processes (requires `pytest-xdist` package) +* `-rA`: Report all test results +* `-k KEYWORD`: Only run tests which match `KEYWORD` +* `--collect-only`: Only collect tests without running them + +## Example Commands for Split Rendering + +Commands executed for a test can be found from the corresponding test output. + +### Full Chain Split Rendering - Ambisonics HOA3 +```bash +IVAS_cod -sba 3 512000 48 tests/renderer/data/spectral_test_16ch_48kHz.wav ivas.192 + +IVAS_dec -T scripts/trajectories/rotate_yaw_pitch_roll1_delayed.csv -render_config tests/split_rendering/renderer_configs/split_renderer_config_3dof_768k_default.txt BINAURAL_SPLIT_CODED 48 ivas.192 split.bit + +IVAS_rend -fs 48 -i split.bit -if BINAURAL_SPLIT_CODED -o tests/split_rendering/cut/HOA3_512000bps_rotate_yaw_pitch_roll1_delayed_split_full_rotate_yaw_pitch_roll1__config_split_renderer_config_3dof_768k_default.wav -of BINAURAL -tf scripts/trajectories/rotate_yaw_pitch_roll1.csv +``` -- GitLab From 419227735cc20f86cbe01ae1fe7ef1b8f432613d Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 28 Jul 2023 19:12:52 +1000 Subject: [PATCH 17/33] bitrate switching fixes, MASA ext renderer fixes, clean up --- lib_com/ivas_prot.h | 6 + lib_dec/ivas_dirac_dec.c | 33 +--- lib_dec/ivas_init_dec.c | 302 ++++++++++++++++++------------- lib_dec/ivas_ism_dec.c | 16 +- lib_dec/ivas_mct_dec.c | 10 +- lib_dec/ivas_output_config.c | 12 +- lib_dec/ivas_sba_dec.c | 27 --- lib_rend/ivas_splitRendererPre.c | 26 ++- lib_rend/lib_rend.c | 106 ++++++++--- 9 files changed, 321 insertions(+), 217 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 885de08281..9cf8c3e168 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -314,6 +314,12 @@ ivas_error ivas_dec( #endif ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +); +#endif + ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index e9443fda32..2c495a4b35 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -874,43 +874,12 @@ ivas_error ivas_dirac_dec_config( { if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - /* populate pMultiBinPoseData with the additional poses determined from the DoF */ - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - } -#endif if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - /* TODO: can we keep isRenderingInTd fixed? */ - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, - 0, /* isRenderingInTd */ - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* pcm_out */ - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - st_ivas->hDecoderConfig->output_Fs, - 1, /* is_cldfb_in */ - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); /* is_pcm_out */ - - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN if ( st_ivas->hDiracDecBin[0] == NULL ) #else diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d5c385e24d..1bb5ed5e2d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -53,7 +53,159 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_read ); static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + CLDFB_TYPE cldfbMode; + + hSplitRendWrapper = &st_ivas->splitBinRend.splitrend; + pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in = 1; + } + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &hSplitRendWrapper->multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + + isCldfbNeeded = 0; + cldfbMode = CLDFB_ANALYSIS; + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in == 0 ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_ANALYSIS; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_SYNTHESIS; + } + else if ( pcm_out && cldfb_in ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_SYNTHESIS; + } + } + + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), + cldfbMode, + st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } + } + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( hSplitRendWrapper->hTdRendHandles[i] != NULL ) + { + hSplitRendWrapper->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &hSplitRendWrapper->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ +ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in, pcm_out; + + pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in = 1; + } + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &st_ivas->splitBinRend.splitrend.multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + if ( cldfb_in == 1 && ( st_ivas->splitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + if ( ( st_ivas->splitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, ( cldfb_in == 0 ), pcm_out ); + + error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, + &st_ivas->hRenderConfig->split_rend_config, + st_ivas->hDecoderConfig->output_Fs, + cldfb_in, pcm_out ); + + return error; +} +#endif /*-------------------------------------------------------------------* * ivas_dec_setup() @@ -313,6 +465,17 @@ ivas_error ivas_dec_setup( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * reconfig split rendering as renderer might change after bitrate switching + *-----------------------------------------------------------------*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_dec_reconfig_split_rend( st_ivas ); + } +#endif + /*-------------------------------------------------------------------* * Initialize decoder in the first good frame based on IVAS format * and number of transport channels @@ -533,7 +696,6 @@ int16_t getNumChanSynthesis( return n; } - /*-------------------------------------------------------------------* * copy_decoder_config() * @@ -802,6 +964,21 @@ ivas_error ivas_init_decoder( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * Initialize split rendering + *-----------------------------------------------------------------*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_dec_init_split_rend( st_ivas ); + } + else + { + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses = 1; + } +#endif + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ @@ -1280,62 +1457,16 @@ ivas_error ivas_init_decoder( /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - if ( st_ivas->splitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) - { - if ( ( st_ivas->splitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); - } - } - } -#endif if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 0, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, - 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif } /* ParamISM is handled separately from other common config */ else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - } -#endif if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) @@ -1348,26 +1479,6 @@ ivas_error ivas_init_decoder( { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { -#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING - error = -#endif - ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, - 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - -#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING - if ( error != IVAS_ERR_OK ) - { - return error; - } -#endif - } -#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -1385,29 +1496,6 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 1, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, 0, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif if ( st_ivas->hDecoderConfig->voip_active ) { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1443,41 +1531,11 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t num_poses; - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - int16_t pcm_out; - pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 1, - pcm_out ); - - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, 0, pcm_out ); - if ( error != IVAS_ERR_OK ) - { - return error; - } - num_poses = st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; - } - else - { - num_poses = 1; - } -#endif - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT , - num_poses + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { @@ -2049,7 +2107,7 @@ void ivas_destroy_dec( ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 485511c23d..11b8b37bc1 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -171,7 +171,11 @@ static ivas_error ivas_ism_bitrate_switching( /* Deallocate the ParamISM struct */ ivas_param_ism_dec_close( &( st_ivas->hDirAC ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); - if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* close the parametric binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN @@ -226,7 +230,7 @@ static ivas_error ivas_ism_bitrate_switching( if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { @@ -245,7 +249,11 @@ static ivas_error ivas_ism_bitrate_switching( { return error; } - if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) @@ -308,7 +316,7 @@ static ivas_error ivas_ism_bitrate_switching( ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ); } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f31aff2327..ed5bd79d7a 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1134,7 +1134,11 @@ static ivas_error ivas_mc_dec_reconfig( output_config = st_ivas->hDecoderConfig->output_config; /* binaural renderers*/ - if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* remove unneeded binaural renderers */ if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -1151,7 +1155,7 @@ static ivas_error ivas_mc_dec_reconfig( ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ); } @@ -1225,7 +1229,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index abc9a9012d..0df70ac4d1 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -90,7 +90,11 @@ void ivas_renderer_select( if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { #ifdef FIX_571_REVERB_NOT_ACTIVATED_ISM - if ( output_config == AUDIO_CONFIG_BINAURAL ) + if ( output_config == AUDIO_CONFIG_BINAURAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) #else if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif @@ -214,7 +218,11 @@ void ivas_renderer_select( if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *internal_config = output_config; - if ( output_config == AUDIO_CONFIG_BINAURAL ) + if ( output_config == AUDIO_CONFIG_BINAURAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5659a96b24..e1c95812ac 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -252,42 +252,15 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - } -#endif /* open fastconv binaural renderer */ if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - assert( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LCLD ); - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif } else if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) { ivas_binRenderer_close( &st_ivas->hBinRenderer ); -#ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_split_renderer_close( &st_ivas->splitBinRend.splitrend ); -#endif } if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) || ( last_ivas_total_brate > IVAS_256k && ivas_total_brate <= IVAS_256k ) || ( last_ivas_total_brate <= IVAS_256k && ivas_total_brate > IVAS_256k ) ) diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index a8c9f3fb6e..83159854ed 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -1922,6 +1922,11 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, isCldfbNeeded = 1; cldfbMode = CLDFB_SYNTHESIS; } + else if ( is_pcm_out && is_cldfb_in ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_SYNTHESIS; + } hSplitRendWrapper->hCldfbHandles = NULL; if ( isCldfbNeeded ) @@ -2003,11 +2008,7 @@ void ivas_split_renderer_close( SPLIT_REND_WRAPPER *hSplitBinRend ) if ( hSplitBinRend->hCldfbHandles != NULL ) { int16_t num_ch, ch; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - num_ch = ( 1 + MAX_HEAD_ROT_POSES ) * BINAURAL_CHANNELS; -#else num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; -#endif for ( ch = 0; ch < num_ch; ch++ ) { if ( hSplitBinRend->hCldfbHandles->cldfbAna[ch] != NULL ) @@ -2378,7 +2379,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } - cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], -1, hSplitBin->hCldfbHandles->cldfbAna[ch] ); + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); } if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, out ) ) != IVAS_ERR_OK ) @@ -2389,6 +2390,21 @@ ivas_error ivas_renderMultiBinToSplitBinaural( } else { + int16_t ch, slot_idx; + /* CLDFB synthesis of main pose */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float *Cldfb_In_BinReal_p[CLDFB_NO_COL_MAX]; + float *Cldfb_In_BinImag_p[CLDFB_NO_COL_MAX]; + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; + Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; + } + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); + } + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec = IVAS_SPLIT_REND_CODEC_NONE; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index be15911337..ee9ec89fac 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1360,7 +1360,7 @@ static ivas_error initIsmMasaRendering( ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); ivas_reverb_close( &inputIsm->hReverb ); @@ -1477,7 +1477,7 @@ static ivas_error setRendInputActiveIsm( NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { @@ -1510,7 +1510,7 @@ static void clearInputIsm( ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); @@ -2199,7 +2199,7 @@ static ivas_error initMcBinauralRendering( ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); @@ -2323,7 +2323,7 @@ static ivas_error initMcMasaRendering( ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); ivas_reverb_close( &inputMc->hReverb ); @@ -2515,7 +2515,7 @@ static void clearInputMc( ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); @@ -2742,7 +2742,7 @@ static ivas_error updateSbaPanGains( *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); } @@ -2762,7 +2762,7 @@ static ivas_error updateSbaPanGains( *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); break; @@ -2825,7 +2825,7 @@ static ivas_error initSbaMasaRendering( ivas_rend_closeCrend( &inputSba->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses #endif ); @@ -3213,7 +3213,12 @@ static DecoderDummy *initDecoderDummy( const int32_t sampleRate, const int16_t numTransChannels, const IVAS_REND_AudioConfig outConfig, - const uint8_t enableRenderConfig ) + const uint8_t enableRenderConfig +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const SPLIT_REND_WRAPPER *pSplitRendWrapper +#endif +) { ivas_error error; int16_t i; @@ -3238,6 +3243,14 @@ static DecoderDummy *initDecoderDummy( decDummy->splitBinRend.hSplitRendBits = NULL; decDummy->splitBinRend.hMultiBinCldfbData = NULL; ivas_init_split_rend_handles( &decDummy->splitBinRend.splitrend ); + decDummy->splitBinRend.splitrend = *pSplitRendWrapper; + if ( decDummy->splitBinRend.splitrend.multiBinPoseData.num_poses > 1 ) + { + if ( ( decDummy->splitBinRend.hMultiBinCldfbData = (IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) + { + assert( error == IVAS_ERR_OK ); + } + } #endif decDummy->hEFAPdata = NULL; decDummy->hCrendWrapper = NULL; @@ -3371,7 +3384,12 @@ static ivas_error setRendInputActiveMasa( } else { - inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + rendCtx.pSplitRendWrapper +#endif + ); inputMasa->metadataHasBeenFed = false; if ( ( error = updateMasaDummyDec( inputMasa, outConfig ) ) != IVAS_ERR_OK ) @@ -3457,6 +3475,14 @@ static void freeDecoderDummy( /* Parametric binaural renderer HRTF structure */ free( pDecDummy->hHrtfParambin ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pDecDummy->splitBinRend.hMultiBinCldfbData != NULL ) + { + free( pDecDummy->splitBinRend.hMultiBinCldfbData ); + pDecDummy->splitBinRend.hMultiBinCldfbData = NULL; + } +#endif + /* Parametric binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN ivas_dirac_dec_close_binaural_data( pDecDummy->hDiracDecBin ); @@ -3491,7 +3517,7 @@ static void clearInputMasa( } #ifdef SPLIT_REND_WITH_HEAD_ROT -static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer, const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, IVAS_REND_HeadRotData headRotData, const int32_t outputSampleRate, const IVAS_REND_AudioConfig outConfig ) +static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer, const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, IVAS_REND_HeadRotData headRotData, const int32_t outputSampleRate, const IVAS_REND_AudioConfig outConfig, const int16_t cldfb_in ) { ivas_error error; IVAS_REND_AudioBufferConfig bufConfig; @@ -3511,7 +3537,7 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, - 0, + cldfb_in, ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); if ( error != IVAS_ERR_OK ) { @@ -4127,7 +4153,14 @@ ivas_error IVAS_REND_AddInput( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) { - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig ) ) != IVAS_ERR_OK ) + int16_t cldfb_in; + cldfb_in = 0; + if ( ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) || + ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS && hIvasRend->hRendererConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) ) + { + cldfb_in = 1; + } + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in ) ) != IVAS_ERR_OK ) { return error; } @@ -7772,7 +7805,7 @@ static ivas_error renderInputSba( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( sbaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) && - ( outConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + ( outConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #else if ( sbaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) #endif @@ -7966,7 +7999,12 @@ static void renderMasaToSba( static void renderMasaToBinaural( input_masa *masaInput, - IVAS_REND_AudioBuffer outAudio ) + IVAS_REND_AudioBuffer outAudio +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t is_split_rend_mode +#endif +) { float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -7974,8 +8012,17 @@ static void renderMasaToBinaural( copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->decDummy->hSpatParamRendCom ); ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels ); - - accumulate2dArrayToBuffer( tmpBuffer, &outAudio ); + if ( is_split_rend_mode ) + { + accumulateCLDFBArrayToBuffer( + masaInput->decDummy->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, + masaInput->decDummy->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, + &outAudio ); + } + else + { + accumulate2dArrayToBuffer( tmpBuffer, &outAudio ); + } return; } @@ -8121,8 +8168,12 @@ static ivas_error renderInputMasa( } inAudio = masaInput->base.inputBuffer; - +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( masaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) && + ( outConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( masaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) +#endif { /* Mismatch between the number of input samples vs number of requested output samples - currently not allowed */ return IVAS_ERR_INVALID_BUFFER_SIZE; @@ -8147,7 +8198,12 @@ static ivas_error renderInputMasa( switch ( outConfig ) { case IVAS_REND_AUDIO_CONFIG_BINAURAL: - renderMasaToBinaural( masaInput, outAudio ); + renderMasaToBinaural( masaInput, outAudio +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif + ); break; /* ToDo */ //#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG @@ -8162,7 +8218,12 @@ static ivas_error renderInputMasa( case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: /* TODO: implement */ - renderMasaToBinaural( masaInput, outAudio ); + renderMasaToBinaural( masaInput, outAudio +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 1 +#endif + ); break; #endif default: @@ -8498,7 +8559,8 @@ ivas_error IVAS_REND_GetSamples( int16_t num_poses_orig; num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; outAudio = hIvasRend->splitRendEncBuffer; - if ( outAudioOrig.config.is_cldfb == 0 ) + if ( ( outAudioOrig.config.is_cldfb == 0 ) && + ( hIvasRend->inputsMasa[0].base.inConfig == IVAS_REND_AUDIO_CONFIG_UNKNOWN ) ) { outAudio.config.is_cldfb = 0; outAudio.config.numSamplesPerChannel >>= 1; -- GitLab From 2cde9e6be0c49d46379c83f005a0a721bb30aca9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 11:09:05 +0200 Subject: [PATCH 18/33] Revert "Remove options.h include from lc3plus code" This reverts commit a91d5d6ae80371be93864d54f299f9487c183d09. --- lc3plus/adjust_global_gain.c | 1 + lc3plus/al_fec_fl.c | 1 + lc3plus/apply_global_gain.c | 1 + lc3plus/ari_codec.c | 1 + lc3plus/attack_detector.c | 1 + lc3plus/constants.c | 1 + lc3plus/cutoff_bandwidth.c | 1 + lc3plus/dct4.c | 1 + lc3plus/dec_entropy.c | 1 + lc3plus/dec_lc3_fl.c | 1 + lc3plus/detect_cutoff_warped.c | 1 + lc3plus/enc_entropy.c | 1 + lc3plus/enc_lc3_fl.c | 1 + lc3plus/estimate_global_gain.c | 1 + lc3plus/fft/cfft.c | 1 + lc3plus/fft/iis_fft.c | 1 + lc3plus/fft/iisfft.c | 1 + lc3plus/imdct.c | 1 + lc3plus/lc3.c | 1 + lc3plus/lc3plus_fft.c | 26 +- lc3plus/ltpf_coder.c | 1 + lc3plus/ltpf_decoder.c | 1 + lc3plus/mdct.c | 1 + lc3plus/mdct_shaping.c | 1 + lc3plus/near_nyquist_detector.c | 1 + lc3plus/noise_factor.c | 1 + lc3plus/noise_filling.c | 1 + lc3plus/olpa.c | 1 + lc3plus/pc_apply.c | 1 + lc3plus/pc_classify.c | 1 + lc3plus/pc_main.c | 1 + lc3plus/pc_update.c | 1 + lc3plus/per_band_energy.c | 1 + lc3plus/plc_classify.c | 1 + lc3plus/plc_compute_stab_fac.c | 1 + lc3plus/plc_damping_scrambling.c | 1 + lc3plus/plc_main.c | 1 + lc3plus/plc_noise_substitution.c | 1 + lc3plus/plc_phecu_f0_refine_first.c | 1 + lc3plus/plc_phecu_fec_hq.c | 1 + lc3plus/plc_phecu_hq_ecu.c | 1 + lc3plus/plc_phecu_lf_peak_analysis.c | 1 + lc3plus/plc_phecu_rec_frame.c | 1 + lc3plus/plc_phecu_setf0hz.c | 1 + lc3plus/plc_phecu_spec_ana.c | 1 + lc3plus/plc_phecu_subst_spec.c | 1 + lc3plus/plc_phecu_tba_per_band_gain.c | 1 + lc3plus/plc_phecu_tba_spect_Xavg.c | 1 + lc3plus/plc_phecu_tba_trans_dect_gains.c | 1 + lc3plus/plc_phecu_trans_burst_ana_sub.c | 1 + lc3plus/plc_tdc.c | 1 + lc3plus/plc_tdc_tdac.c | 1 + lc3plus/plc_update.c | 1 + lc3plus/quantize_spec.c | 1 + lc3plus/reorder_bitstream.c | 1 + lc3plus/resamp12k8.c | 1 + lc3plus/residual_coding.c | 1 + lc3plus/residual_decoding.c | 1 + lc3plus/setup_com_lc3.c | 1 + lc3plus/setup_dec_lc3.c | 1 + lc3plus/setup_enc_lc3.c | 1 + lc3plus/sns_compute_scf.c | 1 + lc3plus/sns_interpolate_scf.c | 1 + lc3plus/sns_quantize_scf.c | 1 + lc3plus/tns_coder.c | 1 + lc3plus/tns_decoder.c | 1 + scripts/lc3plus_lib_setup/get_lc3plus.sh | 2 +- scripts/lc3plus_lib_setup/lc3plus.patch | 913 +++++++++++++++++++++-- 68 files changed, 912 insertions(+), 94 deletions(-) diff --git a/lc3plus/adjust_global_gain.c b/lc3plus/adjust_global_gain.c index 803240f748..e7674dd710 100644 --- a/lc3plus/adjust_global_gain.c +++ b/lc3plus/adjust_global_gain.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx diff --git a/lc3plus/al_fec_fl.c b/lc3plus/al_fec_fl.c index fd0b55b91e..0cae36dade 100644 --- a/lc3plus/al_fec_fl.c +++ b/lc3plus/al_fec_fl.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "stdint.h" #include #include diff --git a/lc3plus/apply_global_gain.c b/lc3plus/apply_global_gain.c index 45bfae5343..c67432e2c3 100644 --- a/lc3plus/apply_global_gain.c +++ b/lc3plus/apply_global_gain.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) diff --git a/lc3plus/ari_codec.c b/lc3plus/ari_codec.c index 238e2a1268..80c75fcf0c 100644 --- a/lc3plus/ari_codec.c +++ b/lc3plus/ari_codec.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void ac_shift_fl(Encoder_State_fl* st); diff --git a/lc3plus/attack_detector.c b/lc3plus/attack_detector.c index 83643d76c2..c9f7c0a94c 100644 --- a/lc3plus/attack_detector.c +++ b/lc3plus/attack_detector.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, diff --git a/lc3plus/constants.c b/lc3plus/constants.c index b32edab9e6..8189761a04 100644 --- a/lc3plus/constants.c +++ b/lc3plus/constants.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" /* DCT */ diff --git a/lc3plus/cutoff_bandwidth.c b/lc3plus/cutoff_bandwidth.c index ea8ad00c9d..642b2afda2 100644 --- a/lc3plus/cutoff_bandwidth.c +++ b/lc3plus/cutoff_bandwidth.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) diff --git a/lc3plus/dct4.c b/lc3plus/dct4.c index b470430b94..8fd5784b28 100644 --- a/lc3plus/dct4.c +++ b/lc3plus/dct4.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void dct2_init(Dct2* dct, int length) diff --git a/lc3plus/dec_entropy.c b/lc3plus/dec_entropy.c index ec7c09708d..d8512a1068 100644 --- a/lc3plus/dec_entropy.c +++ b/lc3plus/dec_entropy.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); diff --git a/lc3plus/dec_lc3_fl.c b/lc3plus/dec_lc3_fl.c index 51c430060d..88c528b0f6 100644 --- a/lc3plus/dec_lc3_fl.c +++ b/lc3plus/dec_lc3_fl.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/detect_cutoff_warped.c b/lc3plus/detect_cutoff_warped.c index b34a88a4c0..9392867208 100644 --- a/lc3plus/detect_cutoff_warped.c +++ b/lc3plus/detect_cutoff_warped.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) diff --git a/lc3plus/enc_entropy.c b/lc3plus/enc_entropy.c index ed34bca7b8..a7ff8cd700 100644 --- a/lc3plus/enc_entropy.c +++ b/lc3plus/enc_entropy.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, diff --git a/lc3plus/enc_lc3_fl.c b/lc3plus/enc_lc3_fl.c index 5bf05465a4..c89f7244ca 100644 --- a/lc3plus/enc_lc3_fl.c +++ b/lc3plus/enc_lc3_fl.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps diff --git a/lc3plus/estimate_global_gain.c b/lc3plus/estimate_global_gain.c index df4b1bc546..df9b1f5f23 100644 --- a/lc3plus/estimate_global_gain.c +++ b/lc3plus/estimate_global_gain.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/fft/cfft.c b/lc3plus/fft/cfft.c index e1bcc2806f..4bd8d29ade 100644 --- a/lc3plus/fft/cfft.c +++ b/lc3plus/fft/cfft.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "cfft.h" #include "iisfft.h" /* for M_PIl */ #include /* for abs() */ diff --git a/lc3plus/fft/iis_fft.c b/lc3plus/fft/iis_fft.c index 1ff9b8303e..b1f8ab5ab8 100644 --- a/lc3plus/fft/iis_fft.c +++ b/lc3plus/fft/iis_fft.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include #include #include diff --git a/lc3plus/fft/iisfft.c b/lc3plus/fft/iisfft.c index 2b5829b220..227d2b6037 100644 --- a/lc3plus/fft/iisfft.c +++ b/lc3plus/fft/iisfft.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include #include /* for mmove */ diff --git a/lc3plus/imdct.c b/lc3plus/imdct.c index 597c21e0df..5d38aa6cc7 100644 --- a/lc3plus/imdct.c +++ b/lc3plus/imdct.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" /* Function expects already flipped window */ diff --git a/lc3plus/lc3.c b/lc3plus/lc3.c index 8b4ebafaa6..17d2ccb712 100644 --- a/lc3plus/lc3.c +++ b/lc3plus/lc3.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "lc3.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/lc3plus_fft.c b/lc3plus/lc3plus_fft.c index 89c6eff2a2..14f443f860 100644 --- a/lc3plus/lc3plus_fft.c +++ b/lc3plus/lc3plus_fft.c @@ -6,8 +6,9 @@ * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + +#include "options.h" #include "functions.h" #include "fft/iis_fft.c" #include "fft/iisfft.c" @@ -15,14 +16,14 @@ void fft_init(Fft* fft, int length) { - assert(length % 2 == 0); HANDLE_IIS_FFT handle = NULL; IIS_FFT_ERROR error = 0; - + assert(length % 2 == 0); + fft->length = length; - + error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); - + assert(error == IIS_FFT_NO_ERROR); fft->handle = handle; } @@ -30,10 +31,10 @@ void fft_init(Fft* fft, int length) void fft_free(Fft* fft) { IIS_FFT_ERROR error = 0; - + if (fft) { error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); - + assert(error == IIS_FFT_NO_ERROR); memset(fft, 0, sizeof(*fft)); } @@ -53,8 +54,8 @@ void real_fft_free(Fft* fft) void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) { - assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ fft->length = length; @@ -66,8 +67,8 @@ void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) { - assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ fft->length = length; @@ -81,7 +82,7 @@ void fft_apply(Fft* fft, const Complex* input, Complex* output) { IIS_FFT_ERROR error = 0; error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); - + assert(error == IIS_FFT_NO_ERROR); } @@ -89,11 +90,10 @@ void fft_apply(Fft* fft, const Complex* input, Complex* output) void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - + UNUSED(error); - error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); + error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); assert(error == IIS_FFT_NO_ERROR); } - diff --git a/lc3plus/ltpf_coder.c b/lc3plus/ltpf_coder.c index 5f8cff63ac..fac8c481c0 100644 --- a/lc3plus/ltpf_coder.c +++ b/lc3plus/ltpf_coder.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); diff --git a/lc3plus/ltpf_decoder.c b/lc3plus/ltpf_decoder.c index c881801618..a40c85213a 100644 --- a/lc3plus/ltpf_decoder.c +++ b/lc3plus/ltpf_decoder.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, diff --git a/lc3plus/mdct.c b/lc3plus/mdct.c index 8b50397a8e..11618b9465 100644 --- a/lc3plus/mdct.c +++ b/lc3plus/mdct.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode) diff --git a/lc3plus/mdct_shaping.c b/lc3plus/mdct_shaping.c index 1033802ac5..1876192504 100644 --- a/lc3plus/mdct_shaping.c +++ b/lc3plus/mdct_shaping.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) diff --git a/lc3plus/near_nyquist_detector.c b/lc3plus/near_nyquist_detector.c index 215e309e2e..ce94351302 100644 --- a/lc3plus/near_nyquist_detector.c +++ b/lc3plus/near_nyquist_detector.c @@ -8,6 +8,7 @@ ******************************************************************************/ #include "functions.h" +#include "options.h" void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, diff --git a/lc3plus/noise_factor.c b/lc3plus/noise_factor.c index c92a94158c..c5aa582e45 100644 --- a/lc3plus/noise_factor.c +++ b/lc3plus/noise_factor.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, diff --git a/lc3plus/noise_filling.c b/lc3plus/noise_filling.c index a5a6b4b424..7fac5e0f72 100644 --- a/lc3plus/noise_filling.c +++ b/lc3plus/noise_filling.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) diff --git a/lc3plus/olpa.c b/lc3plus/olpa.c index cc6e763716..6bec50952e 100644 --- a/lc3plus/olpa.c +++ b/lc3plus/olpa.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input); diff --git a/lc3plus/pc_apply.c b/lc3plus/pc_apply.c index e9cd3e62b6..1d1bc40005 100644 --- a/lc3plus/pc_apply.c +++ b/lc3plus/pc_apply.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/pc_classify.c b/lc3plus/pc_classify.c index 96be029119..71196edb89 100644 --- a/lc3plus/pc_classify.c +++ b/lc3plus/pc_classify.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/pc_main.c b/lc3plus/pc_main.c index b0d853d6a7..268ee94d2a 100644 --- a/lc3plus/pc_main.c +++ b/lc3plus/pc_main.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/pc_update.c b/lc3plus/pc_update.c index 62b9d3f8dc..57539b5079 100644 --- a/lc3plus/pc_update.c +++ b/lc3plus/pc_update.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/per_band_energy.c b/lc3plus/per_band_energy.c index 538f6e6615..db1b5b2d0f 100644 --- a/lc3plus/per_band_energy.c +++ b/lc3plus/per_band_energy.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) diff --git a/lc3plus/plc_classify.c b/lc3plus/plc_classify.c index 20f577b366..619a1f7419 100644 --- a/lc3plus/plc_classify.c +++ b/lc3plus/plc_classify.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/plc_compute_stab_fac.c b/lc3plus/plc_compute_stab_fac.c index 049c072514..4a1111a2c7 100644 --- a/lc3plus/plc_compute_stab_fac.c +++ b/lc3plus/plc_compute_stab_fac.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/plc_damping_scrambling.c b/lc3plus/plc_damping_scrambling.c index 347276ab1d..ecea32be5f 100644 --- a/lc3plus/plc_damping_scrambling.c +++ b/lc3plus/plc_damping_scrambling.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/plc_main.c b/lc3plus/plc_main.c index 877196b7ff..df3fd184d9 100644 --- a/lc3plus/plc_main.c +++ b/lc3plus/plc_main.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, diff --git a/lc3plus/plc_noise_substitution.c b/lc3plus/plc_noise_substitution.c index 94c3aa37aa..4913ee53e5 100644 --- a/lc3plus/plc_noise_substitution.c +++ b/lc3plus/plc_noise_substitution.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_f0_refine_first.c b/lc3plus/plc_phecu_f0_refine_first.c index 5b2309586d..11ebf276b1 100644 --- a/lc3plus/plc_phecu_f0_refine_first.c +++ b/lc3plus/plc_phecu_f0_refine_first.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_fec_hq.c b/lc3plus/plc_phecu_fec_hq.c index b9d63e36ac..c25466c3e9 100644 --- a/lc3plus/plc_phecu_fec_hq.c +++ b/lc3plus/plc_phecu_fec_hq.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_hq_ecu.c b/lc3plus/plc_phecu_hq_ecu.c index 8429d422c9..5b1978bcab 100644 --- a/lc3plus/plc_phecu_hq_ecu.c +++ b/lc3plus/plc_phecu_hq_ecu.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_lf_peak_analysis.c b/lc3plus/plc_phecu_lf_peak_analysis.c index 6c519071b8..0bcc98d7a4 100644 --- a/lc3plus/plc_phecu_lf_peak_analysis.c +++ b/lc3plus/plc_phecu_lf_peak_analysis.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_rec_frame.c b/lc3plus/plc_phecu_rec_frame.c index 6b86a7a743..0e6570743a 100644 --- a/lc3plus/plc_phecu_rec_frame.c +++ b/lc3plus/plc_phecu_rec_frame.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_setf0hz.c b/lc3plus/plc_phecu_setf0hz.c index b713fd93a8..b14327e2b2 100644 --- a/lc3plus/plc_phecu_setf0hz.c +++ b/lc3plus/plc_phecu_setf0hz.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_spec_ana.c b/lc3plus/plc_phecu_spec_ana.c index 89724d1575..b496900305 100644 --- a/lc3plus/plc_phecu_spec_ana.c +++ b/lc3plus/plc_phecu_spec_ana.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_subst_spec.c b/lc3plus/plc_phecu_subst_spec.c index 7b44ccc78c..43f806339b 100644 --- a/lc3plus/plc_phecu_subst_spec.c +++ b/lc3plus/plc_phecu_subst_spec.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" #include "constants.h" diff --git a/lc3plus/plc_phecu_tba_per_band_gain.c b/lc3plus/plc_phecu_tba_per_band_gain.c index 6cd8168811..9f585f28dd 100644 --- a/lc3plus/plc_phecu_tba_per_band_gain.c +++ b/lc3plus/plc_phecu_tba_per_band_gain.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_tba_spect_Xavg.c b/lc3plus/plc_phecu_tba_spect_Xavg.c index e8cca43309..600b9714e4 100644 --- a/lc3plus/plc_phecu_tba_spect_Xavg.c +++ b/lc3plus/plc_phecu_tba_spect_Xavg.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_tba_trans_dect_gains.c b/lc3plus/plc_phecu_tba_trans_dect_gains.c index 61107dec58..e5f0d3caae 100644 --- a/lc3plus/plc_phecu_tba_trans_dect_gains.c +++ b/lc3plus/plc_phecu_tba_trans_dect_gains.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_phecu_trans_burst_ana_sub.c b/lc3plus/plc_phecu_trans_burst_ana_sub.c index 34eadd7cf7..c860cd6ce3 100644 --- a/lc3plus/plc_phecu_trans_burst_ana_sub.c +++ b/lc3plus/plc_phecu_trans_burst_ana_sub.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" #include "functions.h" diff --git a/lc3plus/plc_tdc.c b/lc3plus/plc_tdc.c index bbee9e0651..1a1a408f4d 100644 --- a/lc3plus/plc_tdc.c +++ b/lc3plus/plc_tdc.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" /***************************************************************************\ * contents/description: Main function for Time domain concealment \***************************************************************************/ diff --git a/lc3plus/plc_tdc_tdac.c b/lc3plus/plc_tdc_tdac.c index 4d36d870ad..329361b14c 100644 --- a/lc3plus/plc_tdc_tdac.c +++ b/lc3plus/plc_tdc_tdac.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/plc_update.c b/lc3plus/plc_update.c index e19515fd7a..a151420eb7 100644 --- a/lc3plus/plc_update.c +++ b/lc3plus/plc_update.c @@ -8,6 +8,7 @@ ******************************************************************************/ #include "functions.h" +#include "options.h" void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, diff --git a/lc3plus/quantize_spec.c b/lc3plus/quantize_spec.c index 95f4433f5a..7886b4586d 100644 --- a/lc3plus/quantize_spec.c +++ b/lc3plus/quantize_spec.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static LC3_INT sign(LC3_FLOAT x); diff --git a/lc3plus/reorder_bitstream.c b/lc3plus/reorder_bitstream.c index e69809eb32..77b50d7a13 100644 --- a/lc3plus/reorder_bitstream.c +++ b/lc3plus/reorder_bitstream.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" diff --git a/lc3plus/resamp12k8.c b/lc3plus/resamp12k8.c index fa8d3c828c..0cab5daae9 100644 --- a/lc3plus/resamp12k8.c +++ b/lc3plus/resamp12k8.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], diff --git a/lc3plus/residual_coding.c b/lc3plus/residual_coding.c index e5d90124c0..42094d275f 100644 --- a/lc3plus/residual_coding.c +++ b/lc3plus/residual_coding.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits diff --git a/lc3plus/residual_decoding.c b/lc3plus/residual_decoding.c index f0b9d64815..97fd94afc3 100644 --- a/lc3plus/residual_decoding.c +++ b/lc3plus/residual_decoding.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits diff --git a/lc3plus/setup_com_lc3.c b/lc3plus/setup_com_lc3.c index ca876eb78d..17054d1ffc 100644 --- a/lc3plus/setup_com_lc3.c +++ b/lc3plus/setup_com_lc3.c @@ -8,6 +8,7 @@ ******************************************************************************/ #include "functions.h" +#include "options.h" LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) { diff --git a/lc3plus/setup_dec_lc3.c b/lc3plus/setup_dec_lc3.c index 8cf92311c9..c14309720e 100644 --- a/lc3plus/setup_dec_lc3.c +++ b/lc3plus/setup_dec_lc3.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "setup_dec_lc3.h" #include "functions.h" #include diff --git a/lc3plus/setup_enc_lc3.c b/lc3plus/setup_enc_lc3.c index 27401aca19..986b43d608 100644 --- a/lc3plus/setup_enc_lc3.c +++ b/lc3plus/setup_enc_lc3.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "setup_enc_lc3.h" #include "functions.h" #include diff --git a/lc3plus/sns_compute_scf.c b/lc3plus/sns_compute_scf.c index 744d9e2d6d..5cb041925b 100644 --- a/lc3plus/sns_compute_scf.c +++ b/lc3plus/sns_compute_scf.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor) diff --git a/lc3plus/sns_interpolate_scf.c b/lc3plus/sns_interpolate_scf.c index 49bf0afe37..4419397890 100644 --- a/lc3plus/sns_interpolate_scf.c +++ b/lc3plus/sns_interpolate_scf.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) diff --git a/lc3plus/sns_quantize_scf.c b/lc3plus/sns_quantize_scf.c index 738738eb32..704127cce7 100644 --- a/lc3plus/sns_quantize_scf.c +++ b/lc3plus/sns_quantize_scf.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); diff --git a/lc3plus/tns_coder.c b/lc3plus/tns_coder.c index 257e2b32ad..ff3883d2b5 100644 --- a/lc3plus/tns_coder.c +++ b/lc3plus/tns_coder.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); diff --git a/lc3plus/tns_decoder.c b/lc3plus/tns_decoder.c index 8b20652e5c..d3aeefc3a3 100644 --- a/lc3plus/tns_decoder.c +++ b/lc3plus/tns_decoder.c @@ -8,6 +8,7 @@ ******************************************************************************/ +#include "options.h" #include "functions.h" void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) diff --git a/scripts/lc3plus_lib_setup/get_lc3plus.sh b/scripts/lc3plus_lib_setup/get_lc3plus.sh index 36faf111bd..01ad362b71 100755 --- a/scripts/lc3plus_lib_setup/get_lc3plus.sh +++ b/scripts/lc3plus_lib_setup/get_lc3plus.sh @@ -12,7 +12,7 @@ unzip lc3plus_sources.zip -d . # Modify LC3plus code to be compatible with IVAS tools (e.g. WMC tool) git apply --ignore-whitespace lc3plus.patch -mv ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft.c ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3plus_fft.c +rm ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft.c rm ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/codec_exe.c # Remove unneeded files diff --git a/scripts/lc3plus_lib_setup/lc3plus.patch b/scripts/lc3plus_lib_setup/lc3plus.patch index fdf8a69f5b..14b81a3972 100644 --- a/scripts/lc3plus_lib_setup/lc3plus.patch +++ b/scripts/lc3plus_lib_setup/lc3plus.patch @@ -1,7 +1,26 @@ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/adjust_global_gain.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/adjust_global_gain.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/adjust_global_gain.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/adjust_global_gain.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/al_fec_fl.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/al_fec_fl.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/al_fec_fl.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/al_fec_fl.c 2023-07-13 12:41:20 -@@ -1010,8 +1010,8 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/al_fec_fl.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "stdint.h" + #include + #include +@@ -1010,8 +1011,8 @@ LC3_UINT8 blacklist[FEC_N_MODES]; LC3_INT32 rop; @@ -11,10 +30,29 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin /* initialization */ blacklist[0] = 0; +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/apply_global_gain.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/apply_global_gain.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/apply_global_gain.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/apply_global_gain.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ari_codec.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ari_codec.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ari_codec.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ari_codec.c 2023-07-13 12:41:20 -@@ -620,7 +620,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ari_codec.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void ac_shift_fl(Encoder_State_fl* st); +@@ -620,7 +621,7 @@ if (st.pc_c_bp_side != 0) { @@ -23,7 +61,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } } -@@ -891,7 +891,7 @@ +@@ -891,7 +892,7 @@ { LC3_INT bits = 0, mask = 0, val = 0, over1 = 0, high = 0, over2 = 0, c = 0, b = 0; @@ -32,7 +70,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin mask = ((LC3_INT)pow(2, 24) - 1) >> bits; val = st->low + mask; over1 = val >> 24; -@@ -1078,8 +1078,8 @@ +@@ -1078,8 +1079,8 @@ } /* Residual bits */ @@ -43,10 +81,51 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (st.cache >= 0) { nbits_ari = nbits_ari + 8; +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/attack_detector.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/attack_detector.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/attack_detector.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/attack_detector.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/constants.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/constants.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/constants.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/constants.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + /* DCT */ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/cutoff_bandwidth.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/cutoff_bandwidth.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/cutoff_bandwidth.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/cutoff_bandwidth.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dct4.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dct4.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dct4.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dct4.c 2023-07-13 12:41:20 -@@ -27,11 +27,11 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dct4.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void dct2_init(Dct2* dct, int length) +@@ -27,11 +28,11 @@ void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) { @@ -59,7 +138,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (i = 0; i < len / 2; i++) { tmp1[i] = cmplx(input[i * 2], 0); -@@ -49,8 +49,8 @@ +@@ -49,8 +50,8 @@ void dct4_init(Dct4* dct, int length) { @@ -69,7 +148,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin dct->length = length; dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); dct->twid2 = calloc(sizeof(*dct->twid2), length / 2); -@@ -73,12 +73,12 @@ +@@ -73,12 +74,12 @@ void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output) { @@ -85,8 +164,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin tmp1[i] = cmul(cmplx(input[i * 2], input[len - i * 2 - 1]), dct->twid1[i]); diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_entropy.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_entropy.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_entropy.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_entropy.c 2023-07-13 12:41:20 -@@ -53,7 +53,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_entropy.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); +@@ -53,7 +54,7 @@ LC3_INT nbbytes = nbbits >> 3; LC3_INT lastnz; LC3_INT bw_cutoff_idx; @@ -95,7 +182,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (nbits > nbbits) { -@@ -173,7 +173,7 @@ +@@ -173,7 +174,7 @@ } /* Last non-zero tuple */ @@ -106,8 +193,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (*lastnz > N) { diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_lc3_fl.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_lc3_fl.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_lc3_fl.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_lc3_fl.c 2023-07-13 12:41:20 -@@ -53,8 +53,8 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/dec_lc3_fl.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +@@ -53,8 +54,8 @@ if (decoder->rframe == 1 && zero_frame == 0 && bfi != 1) { @@ -119,7 +214,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin # ifdef ENABLE_025_DMS_MODE diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/defines.h mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/defines.h --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/defines.h 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/defines.h 2023-07-13 12:41:20 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/defines.h 2023-06-29 12:58:27 @@ -24,13 +24,13 @@ typedef uint32_t LC3_UINT32; @@ -149,8 +244,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin #define LC3_SQRT(x) (sqrtf(x)) diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/detect_cutoff_warped.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/detect_cutoff_warped.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/detect_cutoff_warped.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/detect_cutoff_warped.c 2023-07-13 12:41:20 -@@ -68,7 +68,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/detect_cutoff_warped.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) +@@ -68,7 +69,7 @@ dist = bw_dist[counter]; for (i = stop; i >= stop - dist; i--) { @@ -161,8 +264,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin brickwall = 1; diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_entropy.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_entropy.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_entropy.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_entropy.c 2023-07-13 12:41:20 -@@ -33,11 +33,11 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_entropy.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, +@@ -33,11 +34,11 @@ /* Last non zero touple */ if (bfi_ext == 1) { @@ -176,10 +287,29 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } /* LSB mode bit */ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_lc3_fl.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_lc3_fl.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_lc3_fl.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/enc_lc3_fl.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/estimate_global_gain.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/estimate_global_gain.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/estimate_global_gain.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/estimate_global_gain.c 2023-07-13 12:41:20 -@@ -60,8 +60,8 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/estimate_global_gain.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +@@ -60,8 +61,8 @@ } else { g_min = x_max / (32767 - 0.375); } @@ -190,7 +320,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin ind_min = ceil(ind_min + LC3_FABS(ind_min) * LC3_EPS); -@@ -76,7 +76,7 @@ +@@ -76,7 +77,7 @@ tmp += x[i + 1] * x[i + 1]; tmp += x[i + 2] * x[i + 2]; tmp += x[i + 3] * x[i + 3]; @@ -201,20 +331,24 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/cfft.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/cfft.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/cfft.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/cfft.c 2023-07-13 12:41:20 -@@ -8,7 +8,6 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/cfft.c 2023-06-29 12:58:27 +@@ -8,7 +8,7 @@ ******************************************************************************/ - ++#include "options.h" #include "cfft.h" #include "iisfft.h" /* for M_PIl */ #include /* for abs() */ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.c 2023-07-13 12:41:20 -@@ -10,12 +10,12 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.c 2023-06-29 12:58:27 +@@ -8,14 +8,15 @@ + ******************************************************************************/ + ++#include "options.h" #include #include -#include "iis_fft.h" @@ -228,7 +362,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin /**************************************************************************************************/ /* AFFT uses two fft implementations -@@ -24,9 +24,6 @@ +@@ -24,9 +25,6 @@ fast lengths, check the fft_n function. */ @@ -238,7 +372,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin #define FFT_COMPLEX 1 #define FFT_REAL 2 -@@ -122,12 +119,13 @@ +@@ -122,12 +120,13 @@ IIS_FFT_ERROR LC3_IIS_FFT_Apply_CFFT(HANDLE_IIS_FFT handle, const Complex* input, Complex* output) { @@ -255,7 +389,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } else { diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.h mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.h --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.h 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.h 2023-07-13 12:41:20 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iis_fft.h 2023-06-29 12:58:27 @@ -12,6 +12,7 @@ #define IIS_FFT_H @@ -264,9 +398,20 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin #include "cfft.h" #ifdef __cplusplus +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + + #include + #include /* for mmove */ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.h mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.h --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.h 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.h 2023-07-13 12:41:20 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/fft/iisfft.h 2023-06-29 12:58:27 @@ -11,6 +11,7 @@ #ifndef IISFFT_H #define IISFFT_H @@ -275,10 +420,29 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin #ifndef M_PIl #define M_PIl 3.1415926535897932384626433832795029L /* pi */ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/imdct.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/imdct.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/imdct.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/imdct.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + /* Function expects already flipped window */ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3.c 2023-07-13 12:41:20 -@@ -48,8 +48,9 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "lc3.h" + #include "defines.h" + #include "functions.h" +@@ -48,8 +49,9 @@ case 44100: return 1; case 48000: return 1; case 96000: return 1; @@ -289,7 +453,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) -@@ -58,8 +59,9 @@ +@@ -58,8 +60,9 @@ { case LC3PLUS_PLC_ADVANCED: /* fallthru */ return 1; @@ -300,7 +464,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } static int lc3plus_frame_size_supported(float frame_ms) -@@ -69,8 +71,9 @@ +@@ -69,8 +72,9 @@ case 25: /* fallthru */ case 50: /* fallthru */ case 100: return 1; @@ -311,7 +475,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } static int null_in_list(void **list, int n) -@@ -97,13 +100,14 @@ +@@ -97,13 +101,14 @@ /* encoder functions *********************************************************/ LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]) { @@ -327,7 +491,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (ch = 0; ch < channels; ch++) { RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); -@@ -142,6 +146,7 @@ +@@ -142,6 +147,7 @@ int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) { int ch = 0, totalBytes = 0; @@ -335,7 +499,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin RETURN_IF(encoder == NULL, 0); RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); -@@ -150,7 +155,7 @@ +@@ -150,7 +156,7 @@ totalBytes += encoder->channel_setup[ch]->targetBytes; } @@ -344,7 +508,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (encoder->fs_in == 44100) { -@@ -191,11 +196,13 @@ +@@ -191,11 +197,13 @@ LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) { @@ -359,7 +523,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (encoder->bandwidth != bandwidth) { if (encoder->fs_in > 40000) { effective_fs = 40000; -@@ -338,9 +345,9 @@ +@@ -338,9 +346,9 @@ LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder) { @@ -370,7 +534,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (ch = 0; ch < encoder->channels; ch++) { mdct_free(&encoder->channel_setup[ch]->mdctStruct); dct2_free(&encoder->channel_setup[ch]->dct2StructSNS); -@@ -351,9 +358,9 @@ +@@ -351,9 +359,9 @@ LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder) { @@ -381,7 +545,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (ch = 0; ch < decoder->channels; ch++) { dct4_free(&decoder->channel_setup[ch]->dct4structImdct); real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft); -@@ -378,11 +385,14 @@ +@@ -378,11 +386,14 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode) { @@ -398,10 +562,143 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (error != LC3PLUS_OK) { encoder->epmode = oldEpmode; // preserve old epmode in case of failure +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3plus_fft.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3plus_fft.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3plus_fft.c 1970-01-01 01:00:00 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/lc3plus_fft.c 2023-06-29 12:58:27 +@@ -0,0 +1,99 @@ ++/****************************************************************************** ++* ETSI TS 103 634 V1.4.1 * ++* Low Complexity Communication Codec Plus (LC3plus) * ++* * ++* Copyright licence is solely granted through ETSI Intellectual Property * ++* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * ++* estoppel or otherwise. * ++******************************************************************************/ ++ ++ ++#include "options.h" ++#include "functions.h" ++#include "fft/iis_fft.c" ++#include "fft/iisfft.c" ++#include "fft/cfft.c" ++ ++void fft_init(Fft* fft, int length) ++{ ++ HANDLE_IIS_FFT handle = NULL; ++ IIS_FFT_ERROR error = 0; ++ assert(length % 2 == 0); ++ ++ fft->length = length; ++ ++ error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++ fft->handle = handle; ++} ++ ++void fft_free(Fft* fft) ++{ ++ IIS_FFT_ERROR error = 0; ++ ++ if (fft) { ++ error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++ memset(fft, 0, sizeof(*fft)); ++ } ++} ++ ++void real_fft_free(Fft* fft) ++{ ++ IIS_FFT_ERROR error = 0; ++ ++ if (fft) { ++ error = LC3_IIS_RFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++ memset(fft, 0, sizeof(*fft)); ++ } ++} ++ ++void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) ++{ ++ IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; ++ assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ ++ ++ fft->length = length; ++ ++ error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_FWD); ++ assert(error == IIS_FFT_NO_ERROR); ++ fft->handle = *handle; ++} ++ ++ ++void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) ++{ ++ IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; ++ assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ ++ ++ fft->length = length; ++ ++ error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_BWD); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++ fft->handle = *handle; ++} ++ ++void fft_apply(Fft* fft, const Complex* input, Complex* output) ++{ ++ IIS_FFT_ERROR error = 0; ++ error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++} ++ ++ ++void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) ++{ ++ IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; ++ ++ UNUSED(error); ++ ++ error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); ++ ++ assert(error == IIS_FFT_NO_ERROR); ++} +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_coder.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_coder.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_coder.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_coder.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_decoder.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_decoder.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_decoder.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/ltpf_decoder.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct.c 2023-07-13 12:41:20 -@@ -104,6 +104,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode) +@@ -104,6 +105,7 @@ { LC3_FLOAT tmp[MAX_LEN * 2] = {0}; LC3_INT i = 0; @@ -409,7 +706,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin move_float(tmp, mdct->mem, mdct->mem_length); move_float(tmp + mdct->mem_length, input, mdct->length); -@@ -112,7 +113,7 @@ +@@ -112,7 +114,7 @@ mult_vec(tmp, mdct->window, mdct->length * 2); @@ -418,10 +715,34 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (i = 0; i < hlen; i++) { output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; output[hlen + i] = tmp[i] - tmp[hlen * 2 - i - 1]; +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct_shaping.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct_shaping.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct_shaping.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/mdct_shaping.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/msvc/.gitignore mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/msvc/.gitignore +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/msvc/.gitignore 1970-01-01 01:00:00 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/msvc/.gitignore 2023-06-29 12:58:27 +@@ -0,0 +1 @@ ++Win32/ +\ No newline at end of file diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/near_nyquist_detector.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/near_nyquist_detector.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/near_nyquist_detector.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/near_nyquist_detector.c 2023-07-13 12:50:08 -@@ -14,9 +14,9 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/near_nyquist_detector.c 2023-06-29 12:58:35 +@@ -8,15 +8,16 @@ + ******************************************************************************/ + + #include "functions.h" ++#include "options.h" + + + void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, const LC3_INT bands_number, const LC3_FLOAT* ener) { *near_nyquist_flag = 0; @@ -433,10 +754,139 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin LC3_INT i = 0; LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_factor.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_factor.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_factor.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_factor.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_filling.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_filling.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_filling.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/noise_filling.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/olpa.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/olpa.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/olpa.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/olpa.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_apply.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_apply.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_apply.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_apply.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_classify.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_classify.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_classify.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_classify.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_main.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_main.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_main.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_main.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_update.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_update.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_update.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/pc_update.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/per_band_energy.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/per_band_energy.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/per_band_energy.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/per_band_energy.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_classify.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_classify.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_classify.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_classify.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_compute_stab_fac.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_compute_stab_fac.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_compute_stab_fac.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_compute_stab_fac.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_damping_scrambling.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_damping_scrambling.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_damping_scrambling.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_damping_scrambling.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_main.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_main.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_main.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_main.c 2023-07-13 12:41:20 -@@ -56,6 +56,8 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_main.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, +@@ -56,6 +57,8 @@ { case 2: { @@ -445,7 +895,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin assert(decoder->fs_idx == floor(decoder->fs / 10000)); // phaseECU supports only 10ms framing assert(PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100); -@@ -69,7 +71,7 @@ +@@ -69,7 +72,7 @@ } /* call phaseEcu */ @@ -454,10 +904,106 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (prev_bfi_plc2 == 0) +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution0.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution0.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution0.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_noise_substitution0.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_f0_refine_first.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_f0_refine_first.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_f0_refine_first.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_f0_refine_first.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_fec_hq.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_fec_hq.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_fec_hq.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_fec_hq.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_hq_ecu.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_hq_ecu.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_hq_ecu.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_hq_ecu.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_lf_peak_analysis.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_lf_peak_analysis.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_lf_peak_analysis.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_lf_peak_analysis.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_rec_frame.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_rec_frame.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_rec_frame.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_rec_frame.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_setf0hz.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_setf0hz.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_setf0hz.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_setf0hz.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_spec_ana.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_spec_ana.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_spec_ana.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_spec_ana.c 2023-07-13 12:41:20 -@@ -135,13 +135,13 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_spec_ana.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +@@ -135,13 +136,13 @@ if (max_xfp_abs >= 0.5) { @@ -475,8 +1021,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_subst_spec.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_subst_spec.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_subst_spec.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_subst_spec.c 2023-07-13 12:41:20 -@@ -30,6 +30,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_subst_spec.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + #include "constants.h" +@@ -30,6 +31,7 @@ LC3_INT32 segmentLen, e; LC3_FLOAT Xph; LC3_FLOAT seed_local; @@ -484,7 +1038,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin UNUSED(corr_phase_dbg); UNUSED(X_i_new_re_dbg); -@@ -49,8 +50,8 @@ +@@ -49,8 +51,8 @@ // EVOLVE PHASE ----------------- @@ -495,7 +1049,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin one_peak_flag_mask = -1; if (n_plocs < 3 && n_plocs > 0) { -@@ -219,9 +220,10 @@ +@@ -219,9 +221,10 @@ } static LC3_INT32 own_rand(LC3_INT32 seed) { @@ -511,14 +1065,15 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_per_band_gain.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_per_band_gain.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_per_band_gain.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_per_band_gain.c 2023-07-13 12:50:08 -@@ -6,13 +6,13 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_per_band_gain.c 2023-06-29 12:58:35 +@@ -6,13 +6,14 @@ * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + ++#include "options.h" #include "defines.h" #include "functions.h" @@ -528,7 +1083,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin { LC3_INT32 i; -@@ -34,10 +34,10 @@ +@@ -34,10 +35,10 @@ trans[i] = 1.0; /* 0/0 no transient , no power change */ } } @@ -541,16 +1096,39 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin + return; } +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_spect_Xavg.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_spect_Xavg.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_spect_Xavg.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_spect_Xavg.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_trans_dect_gains.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_trans_dect_gains.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_trans_dect_gains.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_tba_trans_dect_gains.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "defines.h" + #include "functions.h" + diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_trans_burst_ana_sub.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_trans_burst_ana_sub.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_trans_burst_ana_sub.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_trans_burst_ana_sub.c 2023-07-13 12:50:08 -@@ -6,16 +6,16 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_phecu_trans_burst_ana_sub.c 2023-06-29 12:58:35 +@@ -6,16 +6,17 @@ * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + ++#include "options.h" #include "defines.h" #include "functions.h" @@ -565,7 +1143,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin { LC3_FLOAT gr_pow_left[MAX_LGW]; LC3_FLOAT gr_pow_right[MAX_LGW]; -@@ -27,7 +27,7 @@ +@@ -27,7 +28,7 @@ LC3_INT32 attDegreeFrames; LC3_FLOAT thresh_dbg; @@ -574,7 +1152,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin UNUSED(tr_dec_dbg); UNUSED(gpc_dbg); -@@ -39,7 +39,7 @@ +@@ -39,7 +40,7 @@ } @@ -583,10 +1161,73 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg); return; +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + /***************************************************************************\ + * contents/description: Main function for Time domain concealment + \***************************************************************************/ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc_tdac.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc_tdac.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc_tdac.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_tdc_tdac.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_update.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_update.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_update.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/plc_update.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + #include "functions.h" ++#include "options.h" + + + void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/quantize_spec.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/quantize_spec.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/quantize_spec.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/quantize_spec.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static LC3_INT sign(LC3_FLOAT x); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/reorder_bitstream.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/reorder_bitstream.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/reorder_bitstream.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/reorder_bitstream.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/resamp12k8.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/resamp12k8.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/resamp12k8.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/resamp12k8.c 2023-07-13 12:41:20 -@@ -17,6 +17,8 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/resamp12k8.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], +@@ -17,6 +18,8 @@ LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = {0}, bufdown[128] = {0}, buf[120 + MAX_LEN] = {0}; @@ -595,7 +1236,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin const LC3_FLOAT *filter; const LC3_FLOAT *filt_input, *filt_coeff; -@@ -49,12 +51,12 @@ +@@ -49,12 +52,12 @@ /* Upsampling & Low-pass Filtering & Downsampling */ @@ -614,7 +1255,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin k = 0; for (i = 0; i < N12k8; i++) { -@@ -78,9 +80,8 @@ +@@ -78,9 +81,8 @@ /* 50Hz High-Pass */ @@ -626,10 +1267,51 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (i = 0; i < len_12k8; i++) { LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_coding.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_coding.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_coding.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_coding.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_decoding.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_decoding.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_decoding.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/residual_decoding.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_com_lc3.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_com_lc3.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_com_lc3.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_com_lc3.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + #include "functions.h" ++#include "options.h" + + LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) + { diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_dec_lc3.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_dec_lc3.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_dec_lc3.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_dec_lc3.c 2023-07-13 12:41:20 -@@ -32,6 +32,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_dec_lc3.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "setup_dec_lc3.h" + #include "functions.h" + #include +@@ -32,6 +33,7 @@ LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; HANDLE_IIS_FFT handle_fft_phaseecu; HANDLE_IIS_FFT handle_ifft_phaseecu; @@ -637,7 +1319,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (ch = 0; ch < channels; ch++) { DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); -@@ -56,7 +57,7 @@ +@@ -56,7 +58,7 @@ sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); @@ -646,7 +1328,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (decoder) { decoder->channel_setup[ch] = setup; -@@ -346,6 +347,7 @@ +@@ -346,6 +348,7 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) { int totalBits = 0, bitsTmp = 0, channel_bytes = 0, maxBytes = 0, minBytes = 0; @@ -654,7 +1336,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin if (decoder->hrmode) { -@@ -375,7 +377,7 @@ +@@ -375,7 +378,7 @@ channel_bytes = nBytes; @@ -665,8 +1347,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin { diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_enc_lc3.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_enc_lc3.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_enc_lc3.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_enc_lc3.c 2023-07-13 12:41:20 -@@ -33,6 +33,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/setup_enc_lc3.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "setup_enc_lc3.h" + #include "functions.h" + #include +@@ -33,6 +34,7 @@ , int32_t lfe_channel_array[] ) { @@ -674,7 +1364,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin memset(encoder, 0, lc3plus_enc_get_size(samplerate, channels)); alloc_encoder(encoder, channels); -@@ -56,7 +57,6 @@ +@@ -56,7 +58,6 @@ encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; encoder->r12k8_mem_out_len = 24; @@ -682,7 +1372,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin for (ch = 0; ch < encoder->channels; ch++) { encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; -@@ -220,6 +220,7 @@ +@@ -220,6 +221,7 @@ if (encoder->hrmode) { @@ -690,7 +1380,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin switch (encoder->frame_dms) { case 25: -@@ -243,6 +244,7 @@ +@@ -243,6 +245,7 @@ default: return LC3PLUS_HRMODE_ERROR; } @@ -698,7 +1388,7 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } else { -@@ -368,7 +370,7 @@ +@@ -368,7 +371,7 @@ setup->total_bits = setup->targetBytes << 3; setup->targetBitsInit = setup->total_bits - encoder->envelope_bits - encoder->global_gain_bits - encoder->noise_fac_bits - encoder->BW_cutoff_bits - @@ -709,8 +1399,16 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin setup->targetBitsInit = setup->targetBitsInit - 1; diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_compute_scf.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_compute_scf.c --- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_compute_scf.c 2023-02-28 20:25:37 -+++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_compute_scf.c 2023-07-13 12:41:20 -@@ -109,7 +109,7 @@ ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_compute_scf.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor) +@@ -109,7 +110,7 @@ /* Log-domain */ for (i = 0; i < 64; i++) { @@ -719,3 +1417,58 @@ diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_poin } /* Downsampling */ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_interpolate_scf.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_interpolate_scf.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_interpolate_scf.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_interpolate_scf.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_quantize_scf.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_quantize_scf.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_quantize_scf.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/sns_quantize_scf.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tinywavein_c.h mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tinywavein_c.h +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tinywavein_c.h 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tinywavein_c.h 2023-06-29 12:58:27 +@@ -17,6 +17,7 @@ + #include + #include + ++ + #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || defined(__arm__) || \ + defined(__aarch64__) + #define __TWI_LE /* _T_iny _W_ave _I_n _L_ittle _E_ndian */ +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_coder.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_coder.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_coder.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_coder.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); +diff -Naur ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_decoder.c mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_decoder.c +--- ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_decoder.c 2023-02-28 20:25:37 ++++ mod/ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/tns_decoder.c 2023-06-29 12:58:27 +@@ -8,6 +8,7 @@ + ******************************************************************************/ + + ++#include "options.h" + #include "functions.h" + + void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) -- GitLab From 40566c22110a38a4becccf214ae6a2ae100e9a6a Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 14:32:34 +0200 Subject: [PATCH 19/33] [cleanup] validation fixes and some cleanup --- apps/decoder.c | 2 +- lib_com/ivas_cnst.h | 2 +- lib_dec/ivas_dec.c | 25 ++++---- lib_rend/ivas_splitRendererPre.c | 14 ++--- lib_rend/ivas_splitRenderer_utils.c | 37 ++++++++--- lib_rend/lib_rend.c | 58 ++++++++++++++---- lib_util/split_render_file_read_write.c | 2 +- tests/split_rendering/test_split_rendering.py | 61 +++++++++++++------ 8 files changed, 143 insertions(+), 58 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 74aa3d7376..9c94396675 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -83,7 +83,7 @@ static #define MAX_NUM_OUTPUT_CHANNELS 16 #define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE ) #ifdef SPLIT_REND_WITH_HEAD_ROT -#define MAX_SPLIT_REND_BITRATE ( 1792000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ?*/ +#define MAX_SPLIT_REND_BITRATE ( 768000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ? */ #define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) #endif #define IVAS_PUBLIC_ORIENT_TRK_NONE ( 0 ) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 827d7f7b3f..6bf206fb78 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1542,7 +1542,7 @@ typedef enum #define SPLIT_REND_MAX_DOF (3) -#define MAX_HEAD_ROT_POSES (2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES) /* TODO tmu : revisit for harmonization */ +#define MAX_HEAD_ROT_POSES (2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES) #define MAX_SPLIT_REND_MD_BANDS (20) #define MAX_SPLIT_MD_SUBFRAMES (1) #define COMPLEX_MD_BAND_THRESH (MAX_SPLIT_REND_MD_BANDS) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index befac6dcc3..cbecd3c619 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -844,20 +844,23 @@ ivas_error ivas_dec( max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, - st_ivas->hHeadTrackData->Quaternions, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - hSplitBinRend->hSplitRendBits, - hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, - hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, - max_band, output, 1, + if ( ( error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, + st_ivas->hHeadTrackData->Quaternions, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + hSplitBinRend->hSplitRendBits, + hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, + hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, + max_band, output, 1, #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - td_input, + td_input, #else - st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV, + st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV, #endif - pcm_out ); + pcm_out ) ) != IVAS_ERR_OK ) + { + return error; + } free( st_ivas->splitBinRend.hMultiBinCldfbData ); } diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 83159854ed..0d7e1ed19e 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -1900,7 +1900,6 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, { ivas_error error, ch, num_ch; CLDFB_TYPE cldfbMode; - uint8_t useLc3plus; uint8_t isCldfbNeeded = 0; cldfbMode = CLDFB_ANALYSIS; @@ -1909,7 +1908,6 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, return error; } - useLc3plus = pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS; /* TODO(sgi): change "useLc3plus" to "splitCodec" */ error = IVAS_ERR_OK; if ( is_cldfb_in == 0 ) @@ -1972,9 +1970,9 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, if ( is_pcm_out == 0 ) { - if ( !useLc3plus ) + if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS ) { - error = ivas_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, ivas_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ) ); + error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate ); if ( error != IVAS_ERR_OK ) { return error; @@ -1982,7 +1980,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } else { - error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate ); + error = ivas_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, ivas_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ) ); if ( error != IVAS_ERR_OK ) { return error; @@ -2193,7 +2191,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( if ( pcm_out == 0 ) { pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; - pBits->codec = useLc3plus ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; /* TODO(sgi): useLc3plus could be changed to splitCodec */ + pBits->codec = useLc3plus ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; if ( !useLc3plus ) { // available_bits = ivas_get_lcld_bitrate( SplitRendBitRate ) * L_FRAME48k / 48000; @@ -2312,7 +2310,9 @@ ivas_error ivas_renderMultiBinToSplitBinaural( set_pose_types( hSplitBin->hBinHrSplitPreRend->pose_type, &hSplitBin->multiBinPoseData ); } - /*TODO : why should this be called during run time ?*/ + /* Needs to be done at runtime. If this was in another API function, + * there would be no guarantee that the user did not change + * the split rendering config before calling the main rendering function */ ivas_split_rend_choose_default_codec( &splitCodec, td_input, pcm_out ); if ( td_input ) diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index baa5f79139..70c218fb1f 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -539,7 +539,8 @@ int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, IVAS_SPL } default: { - return -1; + bitrate = -1; + break; } } @@ -563,22 +564,44 @@ ivas_error ivas_split_rend_validate_config( const IVAS_SPLIT_REND_CONFIG_DATA *p return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Only CLDFB pose correction supports HQ mode" ); } + /* Split rendering with no pose correction - 0 DOF and pose correction NONE must only ever be set together */ + if ( ( pSplitRendConfig->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof != 0 ) || + ( pSplitRendConfig->poseCorrectionMode != IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof == 0 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "0 DOF and pose correction NONE must only ever be set together" ); + } + /* Validate bitrate */ if ( is_pcm_out == 0 ) { switch ( pSplitRendConfig->splitRendBitRate ) { - case SPLIT_REND_384k: - case SPLIT_REND_512k: - case SPLIT_REND_768k: - /* Always valid */ - break; case SPLIT_REND_256k: + if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LCLD ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Unsupported bitrate for LCLD codec" ); + } + + if ( pSplitRendConfig->dof != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + break; case SPLIT_REND_320k: /* Only valid with 0 DOF */ if ( pSplitRendConfig->dof != 0 ) { - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "bitrates below 320 kpbs are only valid with 0 DOF" ); + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + break; + case SPLIT_REND_384k: + case SPLIT_REND_512k: + /* Always valid */ + break; + case SPLIT_REND_768k: + if ( pSplitRendConfig->dof == 0 && pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrate is too high for LC3plus with 0 DOF" ); } break; default: diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ee9ec89fac..b132f2e343 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3538,7 +3538,7 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN pSplit_rend_config, outputSampleRate, cldfb_in, - ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); + outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); if ( error != IVAS_ERR_OK ) { return error; @@ -4119,6 +4119,7 @@ static void closeSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_Aud if ( pSplitRendEncBuffer->data != NULL ) { free( pSplitRendEncBuffer->data ); + pSplitRendEncBuffer->data = NULL; } pSplitRendEncBuffer->config.numChannels = 0; pSplitRendEncBuffer->config.numSamplesPerChannel = 0; @@ -4160,7 +4161,13 @@ ivas_error IVAS_REND_AddInput( { cldfb_in = 1; } - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in ) ) != IVAS_ERR_OK ) + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, + &hIvasRend->splitRendEncBuffer, + &hIvasRend->hRendererConfig->split_rend_config, + hIvasRend->headRotData, + hIvasRend->sampleRateOut, + hIvasRend->outputConfig, + cldfb_in ) ) != IVAS_ERR_OK ) { return error; } @@ -5032,6 +5039,22 @@ int16_t IVAS_REND_FeedRenderConfig( { return error; } + + /* Must re-initialize split rendering config in case renderer config is updated after adding renderer inputs */ + closeSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); + ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, + 1, + hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, + &hIvasRend->splitRendEncBuffer, + &hIvasRend->hRendererConfig->split_rend_config, + hIvasRend->headRotData, + hIvasRend->sampleRateOut, + hIvasRend->outputConfig, + 0 ) ) != IVAS_ERR_OK ) + { + return error; + } #endif return IVAS_ERR_OK; @@ -6193,10 +6216,11 @@ static ivas_error renderIsmToSplitBinaural( accumulate2dArrayToBuffer( tmpBinaural, &outAudio ); pop_wmops(); + /* Encoding to split rendering bitstream done at a higher level */ return IVAS_ERR_OK; } #endif /* SPLIT_REND_WITH_HEAD_ROT */ -/* Encoding to split rendering bitstream done at a higher level */ + static ivas_error renderIsmToMasa( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -6882,6 +6906,12 @@ static ivas_error renderMcToSplitBinaural( } } + /* temporary buffer for rotation in source format for CREND */ + tmpRotBuffer = mcInput->base.inputBuffer; + if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_REND_AUDIO_CONFIG_5_1 && inConfig != IVAS_REND_AUDIO_CONFIG_7_1 ) + { + tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + } for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { @@ -6942,9 +6972,6 @@ static ivas_error renderMcToSplitBinaural( * 4. LFE mixing * 5. tmpSplitBinBuffer accumulated to outBuffer */ - /* temporary buffer for rotation in source format */ - tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); /* copy input for in-place rotation */ mvr2r( mcInput->base.inputBuffer.data, tmpRotBuffer.data, @@ -6989,8 +7016,6 @@ static ivas_error renderMcToSplitBinaural( * overwrite original audio, which is still needed for rendering next head pose. */ mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); - - free( tmpRotBuffer.data ); } /* restore original headrotation data */ @@ -7000,7 +7025,12 @@ static ivas_error renderMcToSplitBinaural( } } - /* TODO tmu : needs delay compensation */ + if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_REND_AUDIO_CONFIG_5_1 && inConfig != IVAS_REND_AUDIO_CONFIG_7_1 ) + { + /* free temporary buffer for rotation in source format for CREND */ + free( tmpRotBuffer.data ); + } + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; @@ -7235,11 +7265,15 @@ static ivas_error renderSplitBinauralWithPostRot( config.channels = BINAURAL_CHANNELS; config.samplerate = *splitBinInput->base.ctx.pOutSampleRate; - IVAS_LC3PLUS_DEC_Open( config, + error = IVAS_LC3PLUS_DEC_Open( config, #ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - 0 /* caching disabled */, + 0 /* caching disabled */, #endif - &splitBinInput->splitPostRendWrapper.hLc3plusDec ); + &splitBinInput->splitPostRendWrapper.hLc3plusDec ); + if ( error != IVAS_ERR_OK ) + { + return error; + } } for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index b596a5781c..bb75f9fa9d 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -235,7 +235,7 @@ ivas_error split_rend_read_bits_from_file( header_len = strlen( header ); - /*write frame header*/ + /*read frame header*/ for ( i = 0; i < header_len; i++ ) { if ( fread( &header_read[i], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index ecfa875f4a..207c229681 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -30,6 +30,36 @@ import pytest from tests.split_rendering.utils import * + +def check_xfail(test_info, in_fmt, render_config, bitrate=None): + if "768k" in render_config and ( + "lc3plus" in render_config + or (in_fmt in INPUT_FORMATS_ISM or in_fmt in INPUT_FORMATS_MC) + or ( + "external_split" in test_info.node.name and in_fmt in INPUT_FORMATS_AMBI + ) # CREND for external renderer ambisonics rendering uses LC3plus by default + ): + pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + + if "256k" in render_config and ( + "lcld" in render_config + or (in_fmt in INPUT_FORMATS_AMBI or in_fmt in INPUT_FORMATS_MASA) + or ( + "full_chain_split" in test_info.node.name + and in_fmt in INPUT_FORMATS_MC + and bitrate <= IVAS_BITRATES_MC[1] + ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default + ): + pytest.xfail("Unsupported bitrate for LCLD codec") + + if ( + bitrate + and (in_fmt in INPUT_FORMATS_ISM) + and (int(bitrate) > int(IVAS_MAX_ISM_BITRATE[in_fmt[-1]])) + ): + pytest.skip(f"Unsupported configuration with {in_fmt} at {bitrate}bps") + + """ Ambisonics """ @@ -37,9 +67,10 @@ from tests.split_rendering.utils import * @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("bitrate", IVAS_BITRATES_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") +def test_ambisonics_full_chain_split( + test_info, in_fmt, bitrate, render_config, trajectory +): + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -58,8 +89,7 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -80,9 +110,10 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory) @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) -def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") +def test_multichannel_full_chain_split( + test_info, in_fmt, bitrate, render_config, trajectory +): + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -101,8 +132,7 @@ def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) def test_multichannel_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -124,10 +154,7 @@ def test_multichannel_external_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("bitrate", IVAS_BITRATES_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - elif int(bitrate) > int(IVAS_MAX_ISM_BITRATE[in_fmt[-1]]): - pytest.skip(f"Unsupported configuration with {in_fmt} at {bitrate}bps") + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -146,8 +173,7 @@ def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, traject @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -169,8 +195,7 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") -- GitLab From 105cd5659dc3109d614b2beff41e3ec6c1bfefe5 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Mon, 31 Jul 2023 15:13:19 +0200 Subject: [PATCH 20/33] return the prototype of the original function divided in split rendering version under the else path of the switch --- lib_rend/ivas_dirac_dec_binaural_functions.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f0085cee84..5315d5e219 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -95,8 +95,12 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter ); +#else +static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked ); +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t isHeadtracked ); -- GitLab From bc5608f80d18cea91bfd09564a0dd281a88c9665 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 16:01:06 +0200 Subject: [PATCH 21/33] [fix] move split rendering related renderer selection to a subkey of SPLITREND in the renderer config, and restore the original override to be only enabled with DEBUGGING + small readme update --- apps/renderer.c | 2 +- lib_com/common_api_types.h | 14 +++++++++-- lib_dec/lib_dec.c | 1 + lib_rend/ivas_render_config.c | 5 +--- lib_rend/ivas_stat_rend.h | 4 ---- lib_rend/lib_rend.c | 41 ++++++--------------------------- lib_util/render_config_reader.c | 34 +++++++++++++++++++-------- readme.txt | 34 +++++++++++++++++++++++++-- 8 files changed, 79 insertions(+), 56 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 17c84d9b81..817b423383 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -688,7 +688,7 @@ static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER { int16_t cldfb_in; cldfb_in = 0; - if ( renderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) + if ( renderConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { #ifdef DEBUGGING cldfb_in = 1; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 59f6387935..79bda1eaa6 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -115,6 +115,15 @@ typedef enum IVAS_SPLIT_REND_CODEC_NONE } IVAS_SPLIT_REND_CODEC; +typedef enum +{ + IVAS_SPLIT_REND_RENDERER_SELECTION_CREND, + IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV, + IVAS_SPLIT_REND_RENDERER_SELECTION_PARAMBIN, + IVAS_SPLIT_REND_RENDERER_SELECTION_TDREND, + IVAS_SPLIT_REND_RENDERER_SELECTION_DEFAULT, +} IVAS_SPLIT_REND_RENDERER_SELECTION; + typedef struct ivas_split_rend_bits_t { uint8_t *bits_buf; @@ -147,7 +156,7 @@ typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; -#if defined( DEBUGGING ) || defined( SPLIT_REND_WITH_HEAD_ROT ) // TODO needs refactoring to a separate enum for split rendering +#ifdef DEBUGGING typedef enum { IVAS_RENDER_TYPE_OVERRIDE_NONE, @@ -193,12 +202,13 @@ typedef struct _IVAS_SPLIT_REND_CONFIG int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; IVAS_SPLIT_REND_CODEC codec; + IVAS_SPLIT_REND_RENDERER_SELECTION rendererSelection; } IVAS_SPLIT_REND_CONFIG_DATA; #endif typedef struct _IVAS_RENDER_CONFIG { -#if defined( DEBUGGING ) || defined( SPLIT_REND_WITH_HEAD_ROT ) // TODO needs refactoring to a separate enum for split rendering +#ifdef DEBUGGING IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e83e5a7e3c..bbfd0a10d6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1596,6 +1596,7 @@ ivas_error IVAS_DEC_GetRenderConfig( hRCout->split_rend_config.codec_delay_ms = 0; hRCout->split_rend_config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; #endif return IVAS_ERR_OK; diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 9bd86138e1..e4a62d217f 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -106,12 +106,8 @@ ivas_error ivas_render_config_init_from_rom( { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } -#ifndef SPLIT_REND_WITH_HEAD_ROT #ifdef DEBUGGING ( *hRenderConfig )->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; -#endif -#else - ( *hRenderConfig )->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; #endif ( *hRenderConfig )->roomAcoustics.override = FALSE; ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; @@ -135,6 +131,7 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; ( *hRenderConfig )->split_rend_config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT; ( *hRenderConfig )->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_SPLIT_REND_RENDERER_SELECTION_DEFAULT; #endif return IVAS_ERR_OK; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index cf345c1305..5b1971eda3 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -909,12 +909,8 @@ typedef struct ivas_roomAcoustics_t typedef struct ivas_render_config_t { -#ifndef SPLIT_REND_WITH_HEAD_ROT #ifdef DEBUGGING ivas_renderTypeOverride renderer_type_override; -#endif -#else - ivas_renderTypeOverride renderer_type_override; #endif ivas_roomAcoustics_t roomAcoustics; float directivity[3]; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index b132f2e343..7592f9ea1d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2691,7 +2691,7 @@ static ivas_error updateSbaPanGains( case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { - if ( hRendCfg->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + if ( hRendCfg->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { assert( inConfig == IVAS_REND_AUDIO_CONFIG_HOA3 && ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural fast conv mode is currently supported with HOA3 input and 48k sampling rate only" ); @@ -2720,8 +2720,7 @@ static ivas_error updateSbaPanGains( #endif case IVAS_REND_AUDIO_CONFIG_BINAURAL: #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( hRendCfg->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) - + if ( hRendCfg->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, @@ -4157,7 +4156,7 @@ ivas_error IVAS_REND_AddInput( int16_t cldfb_in; cldfb_in = 0; if ( ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) || - ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS && hIvasRend->hRendererConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) ) + ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) { cldfb_in = 1; } @@ -4601,7 +4600,7 @@ ivas_error IVAS_REND_GetDelay( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL ) { - if ( hIvasRend->hRendererConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; } @@ -4919,7 +4918,6 @@ int16_t IVAS_REND_GetRenderConfig( } hRCin = hIvasRend->hRendererConfig; -#ifndef SPLIT_REND_WITH_HEAD_ROT #ifdef DEBUGGING switch ( hRCin->renderer_type_override ) { @@ -4933,20 +4931,6 @@ int16_t IVAS_REND_GetRenderConfig( hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; break; } -#endif -#else - switch ( hRCin->renderer_type_override ) - { - case RENDER_TYPE_OVERRIDE_CREND: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; - break; - case RENDER_TYPE_OVERRIDE_FASTCONV: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; - break; - default: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; - break; - } #endif hRCout->room_acoustics.override = hRCin->roomAcoustics.override; hRCout->room_acoustics.nBands = hRCin->roomAcoustics.nBands; @@ -4965,6 +4949,7 @@ int16_t IVAS_REND_GetRenderConfig( hRCout->split_rend_config.codec_delay_ms = 0; hRCout->split_rend_config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; #endif return IVAS_ERR_OK; @@ -4992,7 +4977,6 @@ int16_t IVAS_REND_FeedRenderConfig( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } hRenderConfig = hIvasRend->hRendererConfig; -#ifndef SPLIT_REND_WITH_HEAD_ROT #ifdef DEBUGGING hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) @@ -5004,17 +4988,6 @@ int16_t IVAS_REND_FeedRenderConfig( hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_CREND; } #endif -#else - hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) - { - hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_FASTCONV; - } - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) - { - hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_CREND; - } -#endif hRenderConfig->roomAcoustics.override = renderConfig.room_acoustics.override; hRenderConfig->roomAcoustics.nBands = renderConfig.room_acoustics.nBands; @@ -7536,7 +7509,7 @@ static ivas_error renderSbaToSplitBinaural( push_wmops( "renderSbaToSplitBinaural" ); error = IVAS_ERR_OK; - if ( sbaInput->base.ctx.hhRendererConfig[0]->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { renderSbaToMultiBinauralCldfb( sbaInput, @@ -7577,7 +7550,7 @@ static ivas_error renderSbaToBinaural( push_wmops( "renderSbaToBinaural" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( sbaInput->base.ctx.hhRendererConfig[0]->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV ) + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index d2941713f7..cf73c78942 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -525,22 +525,17 @@ ivas_error RenderConfigReader_read( } else if ( strcmp( item, "DOF" ) == 0 ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT dofProvided = true; -#endif if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.dof ) ) { errorHandler( item, ERROR_VALUE_INVALID ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* 0 DOF implies no pose correction */ if ( hRenderConfig->split_rend_config.dof == 0 && !poseCorrProvided ) { hRenderConfig->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE; } -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( item, "CODEC" ) == 0 ) { if ( strcmp( pValue, "LCLD" ) == 0 ) @@ -577,8 +572,29 @@ ivas_error RenderConfigReader_read( errorHandler( pValue, ERROR_VALUE_INVALID ); } } -#endif - + else if ( strcmp( item, "RENDERER" ) == 0 ) + { + if ( strcmp( pValue, "CREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_SPLIT_REND_RENDERER_SELECTION_CREND; + } + else if ( strcmp( pValue, "FASTCONV" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV; + } + else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_SPLIT_REND_RENDERER_SELECTION_PARAMBIN; + } + else if ( strcmp( pValue, "TDREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_SPLIT_REND_RENDERER_SELECTION_TDREND; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } #ifdef DEBUGGING else { @@ -588,8 +604,8 @@ ivas_error RenderConfigReader_read( } free( pValue ); } -#endif -#if ( defined DEBUGGING ) || ( defined SPLIT_REND_WITH_HEAD_ROT ) +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#ifdef DEBUGGING else if ( strcmp( chapter, "GENERAL" ) == 0 && strlen( pParams ) != 0 ) { params_idx = 0; diff --git a/readme.txt b/readme.txt index 6ae443abf3..d24e41adf9 100644 --- a/readme.txt +++ b/readme.txt @@ -228,7 +228,7 @@ Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file Mandatory parameters: --------------------- OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA, - HOA2, HOA3, BINAURAL, BINAURAL_ROOM, EXT + HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT By default, channel order and loudspeaker positions are equal to the encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker layout file. See below for details. @@ -274,7 +274,37 @@ Options: The usage of the "IVAS_rend" program is as follows: --------------------------------------------------- -TBD +Usage: IVAS_rend [options] + +Valid options: + --input_file, -i Path to the input file (WAV, raw PCM or scene description file) + --input_format, -if Audio format of input file (e.g. 5_1 or HOA3 or META, use -l for a list) + --input_metadata, -im Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode + --output_file, -o Path to the output file + --output_format, -of Output format to render. + Alternatively, can be a custom loudspeaker layout file + --sample_rate, -fs Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs + --trajectory_file, -tf Head rotation trajectory file for simulation of head tracking (only for binaural outputs) + --output_metadata, -om coded metadata file for BINAURAL_SPLIT_PCM output mode + --post_rend_bfi_file, -prbfi Split rendering option: bfi file + --reference_rotation_file, -rf Reference rotation trajectory file for simulation of head tracking (only for binaural outputs) + --custom_hrtf, -hrtf Custom HRTF file for binaural rendering (only for binaural outputs) + --render_config, -rc Binaural renderer configuration file (only for binaural outputs) + --non_diegetic_pan, -ndp Panning mono non diegetic sound to stereo -90<= pan <= 90 + left or l or 90->left, right or r or -90->right, center or c or 0 ->middle + + --tracking_type, -otr Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for binaural outputs) + --lfe_position, -lp Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees. + If specified, overrides the default behavior which attempts to map input to output LFE channel(s) + --lfe_matrix, -lm LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). + If specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s) + --no_delay_cmp, -ndc [flag] Turn off delay compensation + --quiet, -q [flag] Limit printouts to terminal + --gain, -g Input gain (linear, not in dB) to be applied to input audio file + --list, -l List supported audio formats + --reference_vector_file, -rvf Reference vector trajectory file for simulation of head tracking (only for binaural outputs) + --exterior_orientation_file, -exof External orientation trajectory file for simulation of external orientations + --sync_md_delay, -smd Metadata Synchronization Delay in ms, Default is 0. Quantized by 5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes) MULTICHANNEL LOUDSPEAKER INPUT / OUTPUT CONFIGURATIONS -- GitLab From df6e8f0d8d327844a5f1e7b269632a1bfeb1bf74 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 16:24:48 +0200 Subject: [PATCH 22/33] [cleanup] change some pragma once to include guards --- lib_rend/ivas_lc3plus_common.h | 6 +++++- lib_rend/ivas_lc3plus_dec.h | 5 ++++- lib_rend/ivas_lc3plus_enc.h | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_lc3plus_common.h b/lib_rend/ivas_lc3plus_common.h index eae0a5396b..93a37488cc 100644 --- a/lib_rend/ivas_lc3plus_common.h +++ b/lib_rend/ivas_lc3plus_common.h @@ -30,7 +30,9 @@ *******************************************************************************************************/ -#pragma once +#ifndef IVAS_LC3PLUS_COM_H +#define IVAS_LC3PLUS_COM_H + #include #include "ivas_error.h" @@ -51,3 +53,5 @@ typedef struct LC3PLUS_CONFIG /*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ ivas_error IVAS_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); + +#endif /* IVAS_LC3PLUS_COM_H */ diff --git a/lib_rend/ivas_lc3plus_dec.h b/lib_rend/ivas_lc3plus_dec.h index 572120d499..b7592fd740 100644 --- a/lib_rend/ivas_lc3plus_dec.h +++ b/lib_rend/ivas_lc3plus_dec.h @@ -30,7 +30,8 @@ *******************************************************************************************************/ -#pragma once +#ifndef IVAS_LC3PLUS_DEC_H +#define IVAS_LC3PLUS_DEC_H #include #include "lc3.h" @@ -136,3 +137,5 @@ ivas_error IVAS_LC3PLUS_DEC_Conceal( ivas_error IVAS_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( int16_t ***subframeChannelMatrix, const uint32_t num_decs ); void IVAS_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); + +#endif /* IVAS_LC3PLUS_DEC_H */ diff --git a/lib_rend/ivas_lc3plus_enc.h b/lib_rend/ivas_lc3plus_enc.h index 1eea994a7e..b54f16996b 100644 --- a/lib_rend/ivas_lc3plus_enc.h +++ b/lib_rend/ivas_lc3plus_enc.h @@ -30,7 +30,8 @@ *******************************************************************************************************/ -#pragma once +#ifndef IVAS_LC3PLUS_ENC_H +#define IVAS_LC3PLUS_ENC_H #include #include "lc3.h" @@ -71,3 +72,5 @@ ivas_error IVAS_LC3PLUS_ENC_Encode( float **pcm_in, /* i: pointer input samples */ void *bitstream_out /* o: pointer to bitstream frame */ ); + +#endif /* IVAS_LC3PLUS_ENC_H */ -- GitLab From 4e31bf0b11d3638f9855616345c575ca76a02b39 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 16:46:09 +0200 Subject: [PATCH 23/33] [fix] instrumented build --- lib_util/render_config_reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index cf73c78942..e93baa3c3f 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -294,7 +294,7 @@ static ivas_error RenderConfigReader_checkValues( return IVAS_ERR_WRONG_PARAMS; } -#if ( defined DEBUGGING ) || ( defined SPLIT_REND_WITH_HEAD_ROT ) +#ifdef DEBUGGING /* Specific limits for Jot reverb */ if ( hRenderConfig->renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) { -- GitLab From a1e9bdb8df35d86c97835ab40d4126860f88b898 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 17:01:59 +0200 Subject: [PATCH 24/33] [cleanup] code readability and whitespace --- lib_dec/ivas_binRenderer_internal.c | 6 +++--- lib_dec/ivas_dec.c | 9 ++++----- lib_dec/ivas_init_dec.c | 1 + lib_dec/lib_dec.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 555333785e..babfa29259 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1705,13 +1705,13 @@ void ivas_binRenderer( QuatToRotMat( Quaternions_rel, Rmat_local ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + rotateFrame_sd_cldfb( Rmat_local, RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } else { - rotateFrame_sd_cldfb( Rmat_local, RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[pos_idx], Cldfb_ImagBuffer_Binaural[pos_idx], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, pos_idx ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index cbecd3c619..13db40e8b5 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -125,11 +125,10 @@ ivas_error ivas_dec( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - assert( ( st_ivas->ivas_format == SBA_FORMAT || - st_ivas->ivas_format == MASA_FORMAT || - st_ivas->ivas_format == ISM_FORMAT || - st_ivas->ivas_format == MC_FORMAT ) && - ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, MASA, discrete and parametric ISM, or MC formats and 48 kHz sampling rate only" ); + assert( ( st_ivas->ivas_format != UNDEFINED_FORMAT && + st_ivas->ivas_format != MONO_FORMAT && + st_ivas->ivas_format != STEREO_FORMAT ) && + ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, MASA, ISM, or MC formats and 48 kHz sampling rate only" ); #else assert( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT || diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1bb5ed5e2d..f0f4f0eb57 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -696,6 +696,7 @@ int16_t getNumChanSynthesis( return n; } + /*-------------------------------------------------------------------* * copy_decoder_config() * diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index bbfd0a10d6..0783ec30f2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -288,12 +288,12 @@ void IVAS_DEC_Close( } #ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* - * mapAudioConfig2DecAudoioConfig() + * mapAudioConfig2DecAudioConfig() * * *---------------------------------------------------------------------*/ -static IVAS_DEC_AUDIO_CONFIG mapAudioConfig2DecAudoioConfig( +static IVAS_DEC_AUDIO_CONFIG mapAudioConfig2DecAudioConfig( const AUDIO_CONFIG audio_config ) { IVAS_DEC_AUDIO_CONFIG dec_audio_config; @@ -3352,7 +3352,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( num_samples = 0; if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) { - *audio_config = mapAudioConfig2DecAudoioConfig( st_ivas->splitBinRend.hCldfbDataOut->config ); + *audio_config = mapAudioConfig2DecAudioConfig( st_ivas->splitBinRend.hCldfbDataOut->config ); if ( st_ivas->splitBinRend.hCldfbDataOut->config != AUDIO_CONFIG_INVALID ) { num_chs = audioCfg2channels( st_ivas->splitBinRend.hCldfbDataOut->config ); -- GitLab From 91807c4e1485c4a957d32543e222085d1b1fecc7 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 31 Jul 2023 17:07:28 +0200 Subject: [PATCH 25/33] [tests] update BE comparison test too + formatting (isort && black) --- tests/split_rendering/constants.py | 30 ++++++++++++----- tests/split_rendering/test_split_rendering.py | 2 +- .../test_split_rendering_be_comparison.py | 32 ++++++++----------- tests/split_rendering/utils.py | 20 ++++++------ 4 files changed, 48 insertions(+), 36 deletions(-) diff --git a/tests/split_rendering/constants.py b/tests/split_rendering/constants.py index e500f526d2..c53455f66c 100644 --- a/tests/split_rendering/constants.py +++ b/tests/split_rendering/constants.py @@ -57,14 +57,28 @@ from tests.renderer.constants import ( ) """ Renderer configurations """ -RENDERER_CONFIGS_DEFAULT_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_default.txt")] -RENDERER_CONFIGS_LCLD_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lcld.txt")] -RENDERER_CONFIGS_LC3PLUS_CODEC = [str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lc3plus.txt")] - -RENDERER_CONFIGS_TO_TEST_AMBI = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC -RENDERER_CONFIGS_TO_TEST_MC = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC -RENDERER_CONFIGS_TO_TEST_ISM = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC -RENDERER_CONFIGS_TO_TEST_MASA = RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC +RENDERER_CONFIGS_DEFAULT_CODEC = [ + str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_default.txt") +] +RENDERER_CONFIGS_LCLD_CODEC = [ + str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lcld.txt") +] +RENDERER_CONFIGS_LC3PLUS_CODEC = [ + str(cfg.stem) for cfg in RENDER_CFG_DIR.glob("*_lc3plus.txt") +] + +RENDERER_CONFIGS_TO_TEST_AMBI = ( + RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC +) +RENDERER_CONFIGS_TO_TEST_MC = ( + RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC +) +RENDERER_CONFIGS_TO_TEST_ISM = ( + RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LCLD_CODEC +) +RENDERER_CONFIGS_TO_TEST_MASA = ( + RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC +) """ IVAS specific constants """ FORMAT_TO_IVAS_COD_FORMAT = { diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 207c229681..06fa85e413 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -48,7 +48,7 @@ def check_xfail(test_info, in_fmt, render_config, bitrate=None): "full_chain_split" in test_info.node.name and in_fmt in INPUT_FORMATS_MC and bitrate <= IVAS_BITRATES_MC[1] - ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default + ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default ): pytest.xfail("Unsupported bitrate for LCLD codec") diff --git a/tests/split_rendering/test_split_rendering_be_comparison.py b/tests/split_rendering/test_split_rendering_be_comparison.py index 3cd037233a..c4566c0ced 100644 --- a/tests/split_rendering/test_split_rendering_be_comparison.py +++ b/tests/split_rendering/test_split_rendering_be_comparison.py @@ -28,6 +28,7 @@ import pytest +from tests.split_rendering.test_split_rendering import check_xfail from tests.split_rendering.utils import * """ Ambisonics """ @@ -37,9 +38,10 @@ from tests.split_rendering.utils import * @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("bitrate", IVAS_BITRATES_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") +def test_ambisonics_full_chain_split( + test_info, in_fmt, bitrate, render_config, trajectory +): + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -58,8 +60,7 @@ def test_ambisonics_full_chain_split(test_info, in_fmt, bitrate, render_config, @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_AMBI) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -80,9 +81,10 @@ def test_ambisonics_external_split(test_info, in_fmt, render_config, trajectory) @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) -def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") +def test_multichannel_full_chain_split( + test_info, in_fmt, bitrate, render_config, trajectory +): + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -101,8 +103,7 @@ def test_multichannel_full_chain_split(test_info, in_fmt, bitrate, render_config @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_MC) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC[2:]) def test_multichannel_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -124,10 +125,7 @@ def test_multichannel_external_split(test_info, in_fmt, render_config, trajector @pytest.mark.parametrize("bitrate", IVAS_BITRATES_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - elif int(bitrate) > int(IVAS_MAX_ISM_BITRATE[in_fmt[-1]]): - pytest.skip(f"Unsupported configuration with {in_fmt} at {bitrate}bps") + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -146,8 +144,7 @@ def test_ism_full_chain_split(test_info, in_fmt, bitrate, render_config, traject @pytest.mark.parametrize("render_config", RENDERER_CONFIGS_TO_TEST_ISM) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) def test_ism_external_split(test_info, in_fmt, render_config, trajectory): - if "0dof_768k_default" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") @@ -169,8 +166,7 @@ def test_ism_external_split(test_info, in_fmt, render_config, trajectory): @pytest.mark.parametrize("bitrate", IVAS_BITRATES_MASA) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) def test_masa_full_chain_split(test_info, in_fmt, bitrate, render_config, trajectory): - if "0dof_768k_lc3plus" in render_config: - pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") + check_xfail(test_info, in_fmt, render_config, bitrate) post_trajectory = HR_TRAJECTORY_DIR.joinpath(f"{trajectory}.csv") pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed") diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index 21fe2304ba..d00a65f0c1 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -27,15 +27,15 @@ """ import sys -import numpy as np from pathlib import Path from tempfile import TemporaryDirectory from typing import Tuple -from tests.split_rendering.constants import * +import numpy as np -from tests.renderer.utils import check_BE, run_cmd, test_info from tests.cut_pcm import cut_samples +from tests.renderer.utils import check_BE, run_cmd, test_info +from tests.split_rendering.constants import * sys.path.append(SCRIPTS_DIR) from pyaudio3dtools.audiofile import readfile @@ -80,12 +80,14 @@ def run_full_chain_split_rendering( in_file = FORMAT_TO_FILE_COMPARETEST[in_fmt] in_data, in_fs = readfile(in_file) if len(in_data) > INPUT_DURATION_SEC * in_fs: - cut_samples(in_file=in_file, - out_file=cut_in_file, - num_channels=FORMAT_TO_NCHAN[in_fmt], - sample_rate=in_fs, - start=0, - duration=INPUT_DURATION_SEC) + cut_samples( + in_file=in_file, + out_file=cut_in_file, + num_channels=FORMAT_TO_NCHAN[in_fmt], + sample_rate=in_fs, + start=0, + duration=INPUT_DURATION_SEC, + ) cmd[3] = str(cut_in_file) else: cmd[3] = str(in_file) -- GitLab From 7796d2e8148e9f66cfb45495ffef365834637cd3 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 1 Aug 2023 08:16:12 +0200 Subject: [PATCH 26/33] added the implementation of the divided function into the else path of SPLIT_REND_WITH_HEAD_ROT_PARAMBIN --- lib_rend/ivas_dirac_dec_binaural_functions.c | 412 +++++++++++++++++++ 1 file changed, 412 insertions(+) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 5315d5e219..7fe09ddade 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1018,6 +1018,7 @@ static void ivas_dirac_dec_decorrelate_slot( return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1472,7 +1473,418 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( return; } +#else +static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + PARAMBIN_REND_CONFIG_HANDLE hConfig, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float Rmat[3][3], + const int16_t subframe, + const int16_t isHeadtracked ) +{ + int16_t ch, slot, bin; + int16_t separateCenterChannelRendering; + int16_t nBins, idx; + float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + float IIReneLimiterFactor; + float qualityBasedSmFactor; + float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; + uint8_t applyLowBitRateEQ; + int16_t dirac_read_idx; + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + MC_MODE mc_mode; + int32_t ivas_total_brate; + int16_t nchan_transport; + + separateCenterChannelRendering = hConfig->separateCenterChannelRendering; + ivas_format = hConfig->ivas_format; + mc_mode = hConfig->mc_mode; + ivas_total_brate = hConfig->ivas_total_brate; + nchan_transport = hConfig->nchan_transport; + qualityBasedSmFactor = hConfig->qualityBasedSmFactor; + qualityBasedSmFactor *= qualityBasedSmFactor; + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + + set_zero( hDiracDecBin->ChCrossRe, nBins ); + set_zero( hDiracDecBin->ChCrossIm, nBins ); + set_zero( hDiracDecBin->ChCrossReOut, nBins ); + set_zero( hDiracDecBin->ChCrossImOut, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( hDiracDecBin->ChEne[ch], nBins ); + set_zero( hDiracDecBin->ChEneOut[ch], nBins ); + } + set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); + + set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); + + for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) + { + gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ + } + + /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ + applyLowBitRateEQ = 0; + if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + applyLowBitRateEQ = 1; + if ( ivas_total_brate == IVAS_16k4 ) + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin] * 0.5f + 0.5f; + } + } + else + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin]; + } + } + } + + /* Formulate input and target covariance matrices for this subframe */ + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + + /* Calculate input covariance matrix */ + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float instEne; + + instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); + instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + hDiracDecBin->ChEne[ch][bin] += instEne; + subFrameTotalEne[bin] += instEne; + } + hDiracDecBin->ChCrossRe[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; + hDiracDecBin->ChCrossRe[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] += inRe[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] -= inIm[0][slot][bin] * inRe[1][slot][bin]; + } + } + + /* Apply EQ at low bit rates */ + if ( applyLowBitRateEQ ) + { + int16_t lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; + + for ( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[bin]; + } + for ( ; bin < nBins; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[lastEqBin]; + } + } + if ( ivas_format == SBA_FORMAT && nchan_transport == 2 ) + { + float tempRe, tempIm; + + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + tempRe = inRe[0][slot][bin] + inRe[1][slot][bin]; + tempIm = inIm[0][slot][bin] + inIm[1][slot][bin]; + subFrameTotalEne[bin] += tempRe * tempRe + tempIm * tempIm; + } + } + } + + /* Determine target covariance matrix containing target binaural properties */ + for ( bin = 0; bin < nBins; bin++ ) + { + float diffuseness = 1.0f; /* ratio1 and ratio2 are subtracted from diffuseness further below */ + float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */ + float diffEne, dirEne, meanEnePerCh; + int16_t dirIndex; + + /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. + * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the + * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match + * the early spectrum of the BRIR data, using the spectral correction data in + * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ + meanEnePerCh = hDiracDecBin->earlyPartEneCorrection[bin] * subFrameTotalEne[bin] / 2.0f; + + /* Determine direct part target covariance matrix (for 1 or 2 directions) */ + for ( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) + { + int16_t aziDeg, eleDeg; + float lRealp, lImagp, rRealp, rImagp; + float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; + float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; + + if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ + { + aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; + ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence[dirac_read_idx][bin]; + } + else /* For second of the two simultaneous directions */ + { + if ( ( ratio = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) + { + /* This touches only MASA path where second direction always has smaller ratio and + * for non-2dir it is zero. As the whole direction contribution is multiplied with + * the ratio, a very small ratio does not contribute any energy to output. Thus, + * it is better to save complexity. */ + continue; + } + aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence2[dirac_read_idx][bin]; + } + diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ + + if ( separateCenterChannelRendering ) + { + /* In masa + mono rendering mode, the center directions originate from phantom sources, so the + * spread coherence is increased */ + float aziRad, eleRad, doaVectorX, spatialAngleDeg, altSpreadCoh; + + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + doaVectorX = cosf( aziRad ) * cosf( eleRad ); + spatialAngleDeg = acosf( doaVectorX ) * _180_OVER_PI; + altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); + spreadCoh = max( spreadCoh, altSpreadCoh ); + } + + getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 )], isHeadtracked ); + + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* Synthesizing spread coherence is not needed for stereo loudspeaker output, + * as directional sound is reproduced with two loudspeakers in any case */ + spreadCoh = 0.0f; + } + + if ( spreadCoh > 0.0f ) + { + float centerMul, sidesMul; + float hrtfEneCenter, hrtfEneSides, hrtfEneRealized, eneCorrectionFactor; + float w1, w2, w3, eq; + + hrtfEneCenter = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + + /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. + * The following formulas determine the gains for these sources. + * spreadCoh = 0: Only panning + * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) + * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ + if ( spreadCoh < 0.5f ) + { + /* 0.0f < spreadCoh < 0.5f */ + sidesMul = 0.5774f * spreadCoh * 2.0f; /* sqrt(1/3) = 0.5774f */ + centerMul = 1.0f - ( spreadCoh * 2.0f ) + sidesMul; + } + else + { + /* 0.5f <= spreadCoh < 1.0f */ + centerMul = 2.0f - ( 2.0f * spreadCoh ); + sidesMul = inv_sqrt( centerMul + 2.0f ); + centerMul *= sidesMul; + } + + /* Apply the gain for the center source of the three coherent sources */ + lRealp *= centerMul; + lImagp *= centerMul; + rRealp *= centerMul; + rImagp *= centerMul; + + /* Apply the gain for the left source of the three coherent sources */ + getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 1 )], isHeadtracked ); + + hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Apply the gain for the right source of the three coherent sources. + * -30 degrees to 330 wrapping due to internal functions. */ + getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[( dirIndex * 3 + 2 )], isHeadtracked ); + + hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ + hrtfEneRealized = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + eneCorrectionFactor = ( ( hrtfEneSides * sidesMul * sidesMul ) + + ( hrtfEneCenter * centerMul * centerMul ) ) / + max( 1e-12f, hrtfEneRealized ); + + /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ + if ( spreadCoh < 0.5 ) + { + w1 = 1.0f - 2.0f * spreadCoh; + w2 = 2.0f * spreadCoh; + w3 = 0.0f; + } + else + { + w1 = 0.0f; + w2 = 2.0f - 2.0f * spreadCoh; + w3 = 2.0f * spreadCoh - 1.0f; + } + + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + + /* Apply the target spectrum to the eneCorrectionFactor */ + if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ + { + eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; + } + else + { + eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; + } + } + + /* Equalize the spread coherent combined HRTFs */ + eq = min( 4.0f, sqrtf( eneCorrectionFactor ) ); + lRealp *= eq; + lImagp *= eq; + rRealp *= eq; + rImagp *= eq; + } + + hrtfEne[0] = ( lRealp * lRealp ) + ( lImagp * lImagp ); + hrtfEne[1] = ( rRealp * rRealp ) + ( rImagp * rImagp ); + hrtfCrossRe = ( lRealp * rRealp ) + ( lImagp * rImagp ); + hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); + + /* Add direct part (1 or 2) covariance matrix */ + dirEne = ratio * meanEnePerCh; + hDiracDecBin->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ + hDiracDecBin->ChEneOut[1][bin] += dirEne * hrtfEne[1]; + hDiracDecBin->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ + hDiracDecBin->ChCrossImOut[bin] += dirEne * hrtfCrossIm; /* Dir cross im */ + } + + /* Add diffuse / ambient part covariance matrix */ + diffuseness = max( 0.0f, diffuseness ); + diffEne = diffuseness * meanEnePerCh; + surCoh = hSpatParamRendCom->surroundingCoherence[dirac_read_idx][bin]; + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) + { + if ( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ + diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; + } + } + hDiracDecBin->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ + hDiracDecBin->ChEneOut[1][bin] += diffEne; + + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ + hDiracDecBin->ChCrossReOut[bin] += surCoh * diffEne; + } + else /* When rendering binaural, ambience has frequency dependent ICC. */ + { + if ( ivas_format == SBA_FORMAT && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) + { + float diffuseFieldCoherence; + diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin]; + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * diffuseFieldCoherence + surCoh ) * diffEne; + } + else + { + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * hDiracDecBin->diffuseFieldCoherence[bin] + surCoh ) * diffEne; + } + } + + /* Store parameters for formulating average diffuseness over frame */ + hDiracDecBin->frameMeanDiffuseness[bin] += diffEne; + frameMeanDiffusenessEneWeight[bin] += meanEnePerCh; + } + + /* Formulate average diffuseness over frame */ + for ( bin = 0; bin < nBins; bin++ ) + { + hDiracDecBin->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); + } + + /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ + if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); + } + else + { + IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); + } + for ( bin = 0; bin < nBins; bin++ ) + { + float eneRatio, IIReneLimiter; + + /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that + * the energy history (IIR) must not be more than double of the current frame energy. This provides more + * robust performance at energy offsets when compared to typical IIR averaging. */ + eneRatio = ( hDiracDecBin->ChEne[0][bin] + hDiracDecBin->ChEne[1][bin] ) / fmaxf( 1e-12f, ( hDiracDecBin->ChEnePrev[0][bin] + hDiracDecBin->ChEnePrev[1][bin] ) ); + IIReneLimiter = fminf( 1.0f, eneRatio * IIReneLimiterFactor ); + + hDiracDecBin->ChCrossRe[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossIm[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossReOut[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossImOut[bin] *= qualityBasedSmFactor; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] *= qualityBasedSmFactor; + hDiracDecBin->ChEneOut[ch][bin] *= qualityBasedSmFactor; + } + + hDiracDecBin->ChCrossRe[bin] += IIReneLimiter * hDiracDecBin->ChCrossRePrev[bin]; + hDiracDecBin->ChCrossIm[bin] += IIReneLimiter * hDiracDecBin->ChCrossImPrev[bin]; + hDiracDecBin->ChCrossReOut[bin] += IIReneLimiter * hDiracDecBin->ChCrossReOutPrev[bin]; + hDiracDecBin->ChCrossImOut[bin] += IIReneLimiter * hDiracDecBin->ChCrossImOutPrev[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] += IIReneLimiter * hDiracDecBin->ChEnePrev[ch][bin]; + hDiracDecBin->ChEneOut[ch][bin] += IIReneLimiter * hDiracDecBin->ChEneOutPrev[ch][bin]; + } + + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossRePrev[bin] = hDiracDecBin->ChCrossRe[bin]; + hDiracDecBin->ChCrossImPrev[bin] = hDiracDecBin->ChCrossIm[bin]; + hDiracDecBin->ChCrossReOutPrev[bin] = hDiracDecBin->ChCrossReOut[bin]; + hDiracDecBin->ChCrossImOutPrev[bin] = hDiracDecBin->ChCrossImOut[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEnePrev[ch][bin] = hDiracDecBin->ChEne[ch][bin]; + hDiracDecBin->ChEneOutPrev[ch][bin] = hDiracDecBin->ChEneOut[ch][bin]; + } + } + + return; +} +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, -- GitLab From bd4fa789caa637817ff45af32cffaf0db1c0676c Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Tue, 1 Aug 2023 17:08:41 +1000 Subject: [PATCH 27/33] Add condition for not 0 DoF in check_xfail for 256kbps LCLD codec --- tests/split_rendering/test_split_rendering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 06fa85e413..6bc75b4867 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -41,7 +41,7 @@ def check_xfail(test_info, in_fmt, render_config, bitrate=None): ): pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - if "256k" in render_config and ( + if "256k" in render_config and "0dof" not in render_config and ( "lcld" in render_config or (in_fmt in INPUT_FORMATS_AMBI or in_fmt in INPUT_FORMATS_MASA) or ( -- GitLab From 11041ed3078774a9e42c8b433a111bd4a485ee9b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 1 Aug 2023 10:23:55 +0200 Subject: [PATCH 28/33] [tests] update high bitrate xfail for LC3plus to only fail for 0 DoF --- tests/split_rendering/test_split_rendering.py | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 6bc75b4867..6bcbc42123 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -32,23 +32,31 @@ from tests.split_rendering.utils import * def check_xfail(test_info, in_fmt, render_config, bitrate=None): - if "768k" in render_config and ( - "lc3plus" in render_config - or (in_fmt in INPUT_FORMATS_ISM or in_fmt in INPUT_FORMATS_MC) - or ( - "external_split" in test_info.node.name and in_fmt in INPUT_FORMATS_AMBI - ) # CREND for external renderer ambisonics rendering uses LC3plus by default + if ( + "768k" in render_config + and "0dof" in render_config + and ( + "lc3plus" in render_config + or (in_fmt in INPUT_FORMATS_ISM or in_fmt in INPUT_FORMATS_MC) + or ( + "external_split" in test_info.node.name and in_fmt in INPUT_FORMATS_AMBI + ) # CREND for external renderer ambisonics rendering uses LC3plus by default + ) ): pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") - if "256k" in render_config and "0dof" not in render_config and ( - "lcld" in render_config - or (in_fmt in INPUT_FORMATS_AMBI or in_fmt in INPUT_FORMATS_MASA) - or ( - "full_chain_split" in test_info.node.name - and in_fmt in INPUT_FORMATS_MC - and bitrate <= IVAS_BITRATES_MC[1] - ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default + if ( + "256k" in render_config + and "0dof" not in render_config + and ( + "lcld" in render_config + or (in_fmt in INPUT_FORMATS_AMBI or in_fmt in INPUT_FORMATS_MASA) + or ( + "full_chain_split" in test_info.node.name + and in_fmt in INPUT_FORMATS_MC + and bitrate <= IVAS_BITRATES_MC[1] + ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default + ) ): pytest.xfail("Unsupported bitrate for LCLD codec") -- GitLab From d7ffdab1e5c4154dcb2ca194cc9da46491bae6d9 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 2 Aug 2023 13:02:55 +1000 Subject: [PATCH 29/33] linux warning fix --- lib_dec/ivas_masa_dec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index cbbad15c7c..7027d49250 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1429,8 +1429,11 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ - - if ( st_ivas->hDiracDecBin != NULL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0] != NULL ) +#else + if ( st_ivas->hDiracDecBin != NULL ) +#endif { #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) -- GitLab From 8fd9d8901b30561733d7673b54060f7250ea44ee Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 2 Aug 2023 13:28:25 +1000 Subject: [PATCH 30/33] clang format fix --- lib_dec/ivas_dirac_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 48c4429dff..491d2f48b6 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -985,7 +985,6 @@ ivas_error ivas_dirac_dec_config( #else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); #endif - } } } -- GitLab From 096c3d105a9f631096e35280eaedcf35c9cc02b5 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 2 Aug 2023 09:06:18 +0300 Subject: [PATCH 31/33] Fix sanitizer error in OMASA rate switching due to incorrect check. --- lib_dec/ivas_omasa_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 012f701d64..70cba6176b 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -361,9 +361,9 @@ ivas_error ivas_omasa_dec_config( *-----------------------------------------------------------------*/ #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( st_ivas->hDiracDecBin[0] == NULL ) + if ( st_ivas->hDiracDecBin[0] != NULL ) #else - if ( st_ivas->hDiracDecBin == NULL ) + if ( st_ivas->hDiracDecBin != NULL ) #endif { #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN -- GitLab From 1b7c6fdcc5662c9a1f00ce2e7e4e4fe6352a8061 Mon Sep 17 00:00:00 2001 From: Ke Zhao Date: Wed, 2 Aug 2023 17:06:24 +1000 Subject: [PATCH 32/33] Update pytest xfail check to support <=320kbps with only 0DoF --- tests/split_rendering/test_split_rendering.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/split_rendering/test_split_rendering.py b/tests/split_rendering/test_split_rendering.py index 6bcbc42123..ff35b3fc6e 100644 --- a/tests/split_rendering/test_split_rendering.py +++ b/tests/split_rendering/test_split_rendering.py @@ -46,19 +46,9 @@ def check_xfail(test_info, in_fmt, render_config, bitrate=None): pytest.xfail("0DOF 768kbps LC3plus codec is unsupported") if ( - "256k" in render_config - and "0dof" not in render_config - and ( - "lcld" in render_config - or (in_fmt in INPUT_FORMATS_AMBI or in_fmt in INPUT_FORMATS_MASA) - or ( - "full_chain_split" in test_info.node.name - and in_fmt in INPUT_FORMATS_MC - and bitrate <= IVAS_BITRATES_MC[1] - ) # FastConv for ParamMC/ParamUpmix modes uses LCLD by default - ) - ): - pytest.xfail("Unsupported bitrate for LCLD codec") + "256k" in render_config or "320k" in render_config + ) and "0dof" not in render_config: + pytest.xfail("320kbps and lower are only supported with 0DOF") if ( bitrate -- GitLab From d1edf7a4ccad032e82de7e090c4be68eab70f09f Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 2 Aug 2023 17:25:42 +1000 Subject: [PATCH 33/33] increasing the timeout of SR tests --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc24ab729e..82738a8e51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -587,7 +587,7 @@ split-rendering-pytest-on-merge-request: - .rules-merge-request needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less - timeout: "20 minutes" + timeout: "30 minutes" stage: compare script: - *print-common-info -- GitLab