From 4c52d6e806f671841738ae83023badb10601ce57 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 5 Nov 2025 12:42:59 +0100 Subject: [PATCH] add FIX_1419_SPATIAL_UMX - incremental switch on top of FIX_1419_MONO_STEREO_UMX to enable spatial upmix --- lib_com/common_api_types.h | 15 +++ lib_com/options.h | 3 + lib_dec/ivas_init_dec.c | 25 +++++ lib_dec/ivas_jbm_dec.c | 50 +++++++++ lib_dec/ivas_objectRenderer_internal.c | 17 +++ lib_dec/ivas_output_config.c | 44 ++++++-- lib_dec/lib_dec.c | 104 ++++++++++++++++-- lib_rend/ivas_crend.c | 65 ++++++++++- lib_rend/ivas_objectRenderer.c | 59 ++++++++-- lib_rend/ivas_output_init.c | 142 +++++++++++++++++++++++++ lib_rend/ivas_prot_rend.h | 10 ++ lib_rend/ivas_render_config.c | 9 ++ lib_rend/ivas_rom_rend.c | 5 + lib_rend/ivas_rom_rend.h | 5 + lib_rend/ivas_rotation.c | 20 ++++ lib_util/render_config_reader.c | 48 +++++++++ 16 files changed, 596 insertions(+), 25 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 80c90d6b31..99f6c4652c 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -222,6 +222,18 @@ typedef enum _ivas_binaural_renderer_type IVAS_BIN_RENDERER_TYPE_DEFAULT, } IVAS_BIN_RENDERER_TYPE; +#ifdef FIX_1419_SPATIAL_UMX + +typedef struct _IVAS_MS_UMX_CONF_DATA +{ + int16_t spatialEnabled; /* internal flag for spatial rendering */ + int16_t stereoLR; /* internal flag to use ±90 for BRIRs */ + float radius; + float azi[2]; + float ele[2]; + +} IVAS_MS_UMX_CONF_DATA, *IVAS_MS_UMX_CONF_HANDLE; +#endif /*----------------------------------------------------------------------------------* * Split rendering API constants, structures, and enums @@ -335,6 +347,9 @@ typedef struct _IVAS_RENDER_CONFIG #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics; ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; +#ifdef FIX_1419_SPATIAL_UMX + IVAS_MS_UMX_CONF_DATA mono_stereo_upmix_config; +#endif float directivity[IVAS_MAX_NUM_OBJECTS * 3]; float distAtt[3]; diff --git a/lib_com/options.h b/lib_com/options.h index efe5864382..9e4947255d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,6 +172,9 @@ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define RENDERER_MD_SYNC_DELAY_TO_INTEGER /* FhG: change data type of metadata sync delay in ext renderer to int16_t for better BASOP portability (and nicer code) */ #define FIX_1419_MONO_STEREO_UMX /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */ +#ifdef FIX_1419_MONO_STEREO_UMX +#define FIX_1419_SPATIAL_UMX /* FhG: issue 1419: enable spatial upmix for mono/stereo; configurable via renderer config. NOTE: requires FIX_1119_SPLIT_RENDERING_VOIP */ +#endif /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 71d89e77da..7c93ac49d0 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1353,6 +1353,17 @@ ivas_error ivas_init_decoder( { ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); } +#ifdef FIX_1419_SPATIAL_UMX + + /* Override transport config values from render config */ + if ( ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT ) && + st_ivas->hRenderConfig != NULL && + st_ivas->hRenderConfig->mono_stereo_upmix_config.spatialEnabled ) + { + st_ivas->hTransSetup.ls_azimuth = st_ivas->hRenderConfig->mono_stereo_upmix_config.azi; + st_ivas->hTransSetup.ls_elevation = st_ivas->hRenderConfig->mono_stereo_upmix_config.ele; + } +#endif if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -2166,9 +2177,21 @@ ivas_error ivas_init_decoder( else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { #ifdef IVAS_RTPDUMP +#ifdef FIX_1419_SPATIAL_UMX + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) && + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && + ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT || st_ivas->ivas_format == MC_FORMAT ) ) ) +#else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#endif +#else +#ifdef FIX_1419_SPATIAL_UMX + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && + ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT || st_ivas->ivas_format == MC_FORMAT ) ) ) #else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) +#endif #endif { if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) @@ -3183,11 +3206,13 @@ static ivas_error doSanityChecks_IVAS( { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); } +#ifndef FIX_1419_SPATIAL_UMX if ( ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT ) && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); } +#endif #ifndef FIX_1419_MONO_STEREO_UMX } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2f247ec70d..73604c164f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -971,6 +971,56 @@ ivas_error ivas_jbm_dec_render( } } } +#ifdef FIX_1419_SPATIAL_UMX + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { + /* Rendering for BINAURAL, BINAURAL_ROOM_REVERB and split rendering */ + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + /* Rendering for BINAURAL_ROOM_IR */ + if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->ivas_format == MONO_FORMAT ) + { + /* Since rotation is performed on 7.1+4, we treat mono as 7.1+4 with other channels zero + * so move the mono content in index 0 to index 2 (center channel) */ + float *tmp; + tmp = p_output[2]; + p_output[2] = p_output[0]; + p_output[0] = tmp; + } + + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, + st_ivas->intern_config, + st_ivas->hOutSetup.output_config, + st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, + st_ivas->hEFAPdata, + st_ivas->hTcBuffer, + p_output, + p_output, + *nSamplesRendered, + output_Fs, + 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /* FIX_1419_SPATIAL_UMX */ #endif /* FIX_1419_MONO_STEREO_UMX */ } else if ( st_ivas->ivas_format == ISM_FORMAT ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ff47b1b9a7..5c7808874e 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -66,8 +66,22 @@ ivas_error ivas_td_binaural_open( return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); } +#ifdef FIX_1419_SPATIAL_UMX + return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + num_src, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, + st_ivas->hRenderConfig->distAtt, + ( st_ivas->hRenderConfig != NULL ) ? &st_ivas->hRenderConfig->mono_stereo_upmix_config.radius : NULL, + st_ivas->hTransSetup, + &st_ivas->hBinRendererTd, + &st_ivas->binaural_latency_ns ); +#else return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hRenderConfig->distAtt, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); +#endif } @@ -312,6 +326,9 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hRenderConfig->distAtt, +#ifdef FIX_1419_SPATIAL_UMX + ( st_ivas->hRenderConfig != NULL ) ? &st_ivas->hRenderConfig->mono_stereo_upmix_config.radius : NULL, +#endif st_ivas->hTransSetup, &st_ivas->hTdRendHandles[i], &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index f5b4d577b1..129b61a853 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -44,7 +44,12 @@ #ifdef FIX_1419_MONO_STEREO_UMX static void ms_bin_upmix_renderer_select( - const IVAS_FORMAT ivas_format, /* i : Decoder format */ + const IVAS_FORMAT ivas_format, /* i : Decoder format */ +#ifdef FIX_1419_SPATIAL_UMX + const IVAS_AUDIO_CONFIG output_config, /* i : Decoder output configuration */ + const IVAS_MS_UMX_CONF_HANDLE pMsUpmix_config, /* i : Mono/stereo upmix rendering configuration */ + const bool headrotation_enabled, /* i : Flag to signal headrotation is enabled */ +#endif IVAS_AUDIO_CONFIG *internal_config, /* o : Internal configuration for rendering */ RENDERER_TYPE *renderer_type /* o : Selected renderer type */ ) @@ -52,15 +57,37 @@ static void ms_bin_upmix_renderer_select( *internal_config = ( ivas_format == MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; - if ( ivas_format == MONO_FORMAT ) +#ifdef FIX_1419_SPATIAL_UMX + /* spatial rendering disabled */ + if ( !pMsUpmix_config->spatialEnabled ) { - *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; +#endif + if ( ivas_format == MONO_FORMAT ) + { + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + } + else + { + *renderer_type = RENDERER_DISABLE; + } + return; +#ifdef FIX_1419_SPATIAL_UMX } - else + + /* spatial rendering configuration */ + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { - *renderer_type = RENDERER_DISABLE; + if ( headrotation_enabled ) + { + *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + } + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; } - return; + else /* HRIR based formats and split rendering */ + { + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } +#endif } #endif @@ -108,6 +135,11 @@ void ivas_renderer_select( if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT ) { ms_bin_upmix_renderer_select( st_ivas->ivas_format, +#ifdef FIX_1419_SPATIAL_UMX + output_config, + &st_ivas->hRenderConfig->mono_stereo_upmix_config, + ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ), +#endif internal_config, renderer_type ); } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index be69344904..91e6f5d3f2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -274,14 +274,21 @@ static ivas_error isar_set_split_rend_setup( ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { - splitRendBits->bits_read = 0; - splitRendBits->bits_written = 0; - splitRendBits->buf_len = ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES; - splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; - splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; - splitRendBits->codec_frame_size_ms = 0; - splitRendBits->isar_frame_size_ms = 0; - splitRendBits->lc3plus_highres = 0; +#ifdef FIX_1419_SPATIAL_UMX + if ( splitRendBits != NULL ) + { +#endif + splitRendBits->bits_read = 0; + splitRendBits->bits_written = 0; + splitRendBits->buf_len = ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES; + splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + splitRendBits->codec_frame_size_ms = 0; + splitRendBits->isar_frame_size_ms = 0; + splitRendBits->lc3plus_highres = 0; +#ifdef FIX_1419_SPATIAL_UMX + } +#endif ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); @@ -481,8 +488,10 @@ ivas_error IVAS_DEC_Configure( outputConfig == IVAS_AUDIO_CONFIG_ISM2 || outputConfig == IVAS_AUDIO_CONFIG_ISM3 || outputConfig == IVAS_AUDIO_CONFIG_ISM4 || +#ifndef FIX_1419_SPATIAL_UMX outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || +#endif outputConfig == IVAS_AUDIO_CONFIG_MASA1 || outputConfig == IVAS_AUDIO_CONFIG_MASA2 ) ) #else /* we now support all output formats, so this validation is redundant */ @@ -889,6 +898,21 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = ACELP_8k00; +#ifdef FIX_1419_SPATIAL_UMX + if ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + /* necessary to set up correct amount of memory for rendering; remaining setup happens in ivas_dec_setup_all() */ + /* Setup IVAS split rendering */ + if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, + &hIvasDec->st_ivas->hRenderConfig->split_rend_config, + hIvasDec->st_ivas->hCombinedOrientationData, + NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif if ( ( error = ivas_init_decoder( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -1734,6 +1758,10 @@ ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ) { +#ifdef FIX_1419_SPATIAL_UMX + ivas_error error; + +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -1743,6 +1771,18 @@ ivas_error IVAS_DEC_PrepareRenderer( { ivas_dec_prepare_renderer( hIvasDec->st_ivas ); } +#ifdef FIX_1419_SPATIAL_UMX + + if ( hIvasDec->st_ivas->hRenderConfig != NULL ) + { + if ( ( error = ms_upmix_validate_config( &hIvasDec->st_ivas->hRenderConfig->mono_stereo_upmix_config, + hIvasDec->st_ivas->ivas_format, + hIvasDec->st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif hIvasDec->hasBeenPreparedRendering = true; @@ -2362,7 +2402,12 @@ static ivas_error ivas_dec_setup_all( { ivas_error error; +#ifdef FIX_1419_SPATIAL_UMX + /* split rendering related functions in else are required also for mono SR */ + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && splitRendBits == NULL ) +#else if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) +#endif { if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { @@ -2400,7 +2445,11 @@ static ivas_error ivas_dec_setup_all( * - reconfigure the decoder when the number of TC or IVAS total bitrate change *----------------------------------------------------------------*/ +#ifdef FIX_1419_SPATIAL_UMX + if ( st_ivas->bfi == 0 && hIvasDec->mode != IVAS_DEC_MODE_EVS ) +#else if ( st_ivas->bfi == 0 ) +#endif { if ( ( error = ivas_dec_setup( st_ivas ) ) != IVAS_ERR_OK ) { @@ -2417,7 +2466,13 @@ static ivas_error ivas_dec_setup_all( *-----------------------------------------------------------------*/ #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef FIX_1419_SPATIAL_UMX + if ( ( ( hIvasDec->mode == IVAS_DEC_MODE_EVS && st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame == 0 ) || + ( hIvasDec->mode == IVAS_DEC_MODE_IVAS && st_ivas->ini_frame == 0 ) ) && + splitRendBits != NULL ) +#else if ( st_ivas->ini_frame == 0 && splitRendBits != NULL ) +#endif #else if ( st_ivas->ini_frame == 0 && isSplitRend ) #endif @@ -3233,6 +3288,11 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); mvr2r( hRCin->distAtt, hRCout->distAtt, 3 ); +#ifdef FIX_1419_SPATIAL_UMX + + /* Mono/Stereo upmix configuration */ + hRCout->mono_stereo_upmix_config = hRCin->mono_stereo_upmix_config; +#endif hRCout->split_rend_config = hRCin->split_rend_config; @@ -3386,6 +3446,28 @@ ivas_error IVAS_DEC_FeedRenderConfig( mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 ); +#ifdef FIX_1419_SPATIAL_UMX + + /* Mono/Stereo upmix configuration */ + if ( renderConfig.mono_stereo_upmix_config.spatialEnabled ) + { + /* copy data */ + hRenderConfig->mono_stereo_upmix_config.spatialEnabled = renderConfig.mono_stereo_upmix_config.spatialEnabled; + hRenderConfig->mono_stereo_upmix_config.radius = renderConfig.mono_stereo_upmix_config.radius; + hRenderConfig->mono_stereo_upmix_config.stereoLR = renderConfig.mono_stereo_upmix_config.stereoLR; + + mvr2r( renderConfig.mono_stereo_upmix_config.azi, hRenderConfig->mono_stereo_upmix_config.azi, 2 ); + mvr2r( renderConfig.mono_stereo_upmix_config.ele, hRenderConfig->mono_stereo_upmix_config.ele, 2 ); + + /* validate configuration early - repeated in IVAS_DEC_PrepareRenderer when input format is available */ + if ( ( error = ms_upmix_validate_config( &hRenderConfig->mono_stereo_upmix_config, + st_ivas->ivas_format, + st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif hRenderConfig->split_rend_config = renderConfig.split_rend_config; @@ -4014,7 +4096,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples } #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef FIX_1419_SPATIAL_UMX + if ( splitRendBits != NULL && + ( ( hIvasDec->mode == IVAS_DEC_MODE_EVS && hIvasDec->needNewFrame ) || + ( hIvasDec->mode == IVAS_DEC_MODE_IVAS && hIvasDec->hasDecodedFirstGoodFrame ) ) ) +#else if ( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) +#endif { /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 9134667502..2306d49a6b 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -167,6 +167,9 @@ static ivas_error ivas_rend_initCrend( const AUDIO_CONFIG outConfig, HRTFS_CREND_HANDLE hHrtfCrend, const int16_t ext_rend_flag, +#ifdef FIX_1419_SPATIAL_UMX + const int16_t bin_upmix_stereolr_flag, +#endif const int32_t output_Fs ) { int16_t i, j, tmp, tmp2; @@ -228,8 +231,15 @@ static ivas_error ivas_rend_initCrend( { if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; +#ifdef FIX_1419_SPATIAL_UMX + if ( inConfig != IVAS_AUDIO_CONFIG_MONO && inConfig != IVAS_AUDIO_CONFIG_STEREO ) + { +#endif + hHrtf->max_num_ir -= 1; /* subtract LFE */ + hHrtf->gain_lfe = GAIN_LFE; +#ifdef FIX_1419_SPATIAL_UMX + } +#endif if ( output_Fs == 48000 ) { @@ -338,7 +348,20 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifdef FIX_1419_SPATIAL_UMX + if ( inConfig == IVAS_AUDIO_CONFIG_MONO ) + { + tmp = channelIndex_CICP1[i]; + } + else if ( inConfig == IVAS_AUDIO_CONFIG_STEREO ) + { + /* flag to select ±90 loudspeakers instead of ±30 */ + tmp = ( bin_upmix_stereolr_flag ) ? channelIndex_LR[i] : channelIndex_CICP2[i]; + } + else if ( inConfig == IVAS_AUDIO_CONFIG_5_1 ) +#else if ( inConfig == IVAS_AUDIO_CONFIG_5_1 ) +#endif { tmp = channelIndex_CICP6[i]; } @@ -360,7 +383,11 @@ static ivas_error ivas_rend_initCrend( } else { +#ifdef FIX_1419_SPATIAL_UMX + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Invalid channel configuration for Crend!\n\n" ); +#else return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); +#endif } if ( output_Fs == 48000 ) @@ -703,8 +730,15 @@ static ivas_error ivas_rend_initCrend( { if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; +#ifdef FIX_1419_SPATIAL_UMX + if ( inConfig != IVAS_AUDIO_CONFIG_MONO && inConfig != IVAS_AUDIO_CONFIG_STEREO ) + { +#endif + hHrtf->max_num_ir -= 1; /* subtract LFE */ + hHrtf->gain_lfe = GAIN_LFE; +#ifdef FIX_1419_SPATIAL_UMX + } +#endif } if ( ext_rend_flag == 1 ) @@ -747,7 +781,20 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifdef FIX_1419_SPATIAL_UMX + if ( inConfig == IVAS_AUDIO_CONFIG_MONO ) + { + tmp = channelIndex_CICP1[i]; + } + else if ( inConfig == IVAS_AUDIO_CONFIG_STEREO ) + { + /* flag to select ±90 loudspeakers instead of ±30 */ + tmp = ( bin_upmix_stereolr_flag ) ? channelIndex_LR[i] : channelIndex_CICP2[i]; + } + else if ( inConfig == IVAS_AUDIO_CONFIG_5_1 ) +#else if ( inConfig == IVAS_AUDIO_CONFIG_5_1 ) +#endif { tmp = channelIndex_CICP6[i]; } @@ -1172,7 +1219,17 @@ ivas_error ivas_rend_openCrend( if ( ( *pCrend )->hHrtfCrend == NULL ) { +#ifdef FIX_1419_SPATIAL_UMX + if ( ( error = ivas_rend_initCrend( *pCrend, + inConfig, + outConfig, + hHrtfCrend, + ext_rend_flag, + ( hRendCfg != NULL ) ? hRendCfg->mono_stereo_upmix_config.stereoLR : 0, + output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hHrtfCrend, ext_rend_flag, output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index a4e15c79de..bd48335925 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -60,13 +60,16 @@ static void angles_to_vec( const float radius, const float azimuth, const float *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_open_unwrap( - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ - const int32_t output_Fs, /* i : Output sampling rate */ - const int16_t nchan_transport, /* i : Number of channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ - const AUDIO_CONFIG transport_config, /* i : Transport configuration */ - const float *directivity, /* i : Directivity pattern (used for ISM) */ - const float *distAtt, /* i : Distance attenuation (used for ISM) */ + TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ + const int32_t output_Fs, /* i : Output sampling rate */ + const int16_t nchan_transport, /* i : Number of channels */ + const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ + const float *directivity, /* i : Directivity pattern (used for ISM) */ + const float *distAtt, /* i : Distance attenuation (used for ISM) */ +#ifdef FIX_1419_SPATIAL_UMX + const float *radius_ms_umx, /* i : Radius (used for mono/stereo upmix) */ +#endif const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ int32_t *binaural_latency_ns /* i : Binauralization delay */ @@ -77,6 +80,9 @@ ivas_error ivas_td_binaural_open_unwrap( int16_t nS; int16_t SrcInd[MAX_NUM_TDREND_CHANNELS]; const float *ls_azimuth, *ls_elevation; +#ifdef FIX_1419_SPATIAL_UMX + float radius; +#endif float Pos[3]; float Dir[3]; TDREND_DirAtten_t *DirAtten_p; @@ -138,10 +144,22 @@ ivas_error ivas_td_binaural_open_unwrap( } } +#ifdef FIX_1419_SPATIAL_UMX + if ( ivas_format == MONO_FORMAT || ivas_format == STEREO_FORMAT || ivas_format == MC_FORMAT ) +#else if ( ivas_format == MC_FORMAT ) +#endif { switch ( transport_config ) { +#ifdef FIX_1419_SPATIAL_UMX + case IVAS_AUDIO_CONFIG_MONO: + case IVAS_AUDIO_CONFIG_STEREO: + /* appropriate values are set in ivas_init_decoder() */ + ls_azimuth = hTransSetup.ls_azimuth; + ls_elevation = hTransSetup.ls_elevation; + break; +#endif case IVAS_AUDIO_CONFIG_5_1: ls_azimuth = ls_azimuth_CICP6; ls_elevation = ls_elevation_CICP6; @@ -175,8 +193,21 @@ ivas_error ivas_td_binaural_open_unwrap( for ( nS = 0; nS < nchan_rend; nS++ ) { +#ifdef FIX_1419_SPATIAL_UMX + /* set radius from render configuration file for mono/stereo upmix; otherwise 1.f */ + radius = 1.f; + if ( ( transport_config == IVAS_AUDIO_CONFIG_MONO || transport_config == IVAS_AUDIO_CONFIG_STEREO ) && + radius_ms_umx != NULL ) + { + radius = *radius_ms_umx; + } + + /* Set source positions according to loudspeaker layout */ + angles_to_vec( radius, ls_azimuth[nS], ls_elevation[nS], Pos ); +#else /* Set source positions according to loudspeaker layout */ angles_to_vec( 1.0f, ls_azimuth[nS], ls_elevation[nS], Pos ); +#endif Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; @@ -710,7 +741,21 @@ ivas_error ivas_td_binaural_open_ext( distAtt = hRendCfg->distAtt; } +#ifdef FIX_1419_SPATIAL_UMX + return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, + outFs, + nchan_transport, + ivas_format, + transport_config, + directivity, + distAtt, + ( hRendCfg != NULL ) ? &hRendCfg->mono_stereo_upmix_config.radius : NULL, + hTransSetup, + &pTDRend->hBinRendererTd, + &pTDRend->binaural_latency_ns ); +#else return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, distAtt, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); +#endif } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 01e1d77231..62403aa8dd 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -36,7 +36,13 @@ #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" +#ifdef FIX_1419_SPATIAL_UMX +#include "ivas_rom_rend.h" +#endif #include "ivas_prot.h" +#ifdef FIX_1419_SPATIAL_UMX +#include +#endif #include #ifdef DEBUGGING #include "debug.h" @@ -166,9 +172,17 @@ void ivas_output_init( { case IVAS_AUDIO_CONFIG_MONO: hOutSetup->is_loudspeaker_setup = 1; +#ifdef FIX_1419_SPATIAL_UMX + hOutSetup->is_planar_setup = 1; + hOutSetup->ls_azimuth = ls_azimuth_CICP1; + hOutSetup->ls_elevation = ls_elevation_CICP1; +#endif break; case IVAS_AUDIO_CONFIG_STEREO: hOutSetup->is_loudspeaker_setup = 1; +#ifdef FIX_1419_SPATIAL_UMX + hOutSetup->is_planar_setup = 1; +#endif hOutSetup->ls_azimuth = ls_azimuth_CICP2; hOutSetup->ls_elevation = ls_elevation_CICP2; break; @@ -276,10 +290,24 @@ int16_t ivas_get_nchan_buffers_dec( if ( st_ivas->ivas_format == MONO_FORMAT ) { nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; +#ifdef FIX_1419_SPATIAL_UMX + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && + ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); + } +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS ); +#ifdef FIX_1419_SPATIAL_UMX + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && + ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); + } +#endif } else if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -435,6 +463,120 @@ ivas_error ivas_output_buff_dec( return IVAS_ERR_OK; } +#ifdef FIX_1419_SPATIAL_UMX + +/*---------------------------------------------------------------------* + * ms_upmix_validate_config() + * + * + *---------------------------------------------------------------------*/ + +ivas_error ms_upmix_validate_config( + IVAS_MS_UMX_CONF_HANDLE pMsUpmixConfig, /* i/o: Mono/Stereo upmix configuration */ + const IVAS_FORMAT ivasFormat, /* i : IVAS Decoder input configuration */ + const IVAS_AUDIO_CONFIG outConfig /* i : IVAS Decoder output configuration */ +) +{ + int16_t i; + float azi_abs[2]; + float ele_abs[2]; + + if ( pMsUpmixConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* skip validation if non spatial; values aren't used */ + if ( !pMsUpmixConfig->spatialEnabled ) + { + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Configuring mono/stereo upmix for split rendering requires a spatial upmix" ); + } + + return IVAS_ERR_OK; + } + + /* validate radius */ + if ( pMsUpmixConfig->radius < 0.f || pMsUpmixConfig->radius > 15.75f ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Radius must be between 0 and 15.75" ); + } + + /* zero radius corresponds to non-spatial */ + if ( pMsUpmixConfig->radius == 0.f ) + { + pMsUpmixConfig->spatialEnabled = FALSE; + return IVAS_ERR_OK; + } + + /* obtain absolute values */ + for ( i = 0; i < 2; i++ ) + { + azi_abs[i] = fabsf( pMsUpmixConfig->azi[i] ); + ele_abs[i] = fabsf( pMsUpmixConfig->ele[i] ); + } + + /* validate speaker positions */ + if ( ivasFormat == MONO_FORMAT ) + { + if ( azi_abs[0] != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Mono cannot be panned" ); + } + if ( ele_abs[0] != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Mono cannot be panned" ); + } + } + else if ( ivasFormat == STEREO_FORMAT ) + { + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + /* validate provided positions match BRIR */ + if ( ( azi_abs[0] != 30 && azi_abs[0] != 90 ) || + ( azi_abs[1] != 30 && azi_abs[1] != 90 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "BINAURAL_ROOM_IR only supports ±30 and ±90 degree azimuth" ); + } + if ( ele_abs[0] != 0 || ele_abs[1] != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "BINAURAL_ROOM_IR does not allow nonzero elevation" ); + } + + /* flag to select ±90 azi loudspeakers */ + if ( azi_abs[0] == 90 && azi_abs[1] == 90 ) + { + pMsUpmixConfig->stereoLR = TRUE; + } + } + else /* HRIR based formats and split rendering */ + { + /* enforce symmetry */ + if ( pMsUpmixConfig->azi[0] != -pMsUpmixConfig->azi[1] ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Panning stereo pair with asymmetric azimuth is not allowed" ); + } + if ( pMsUpmixConfig->ele[0] != pMsUpmixConfig->ele[1] ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Panning stereo pair with differring elevation is not allowed" ); + } + + /* restrict values */ + if ( ( azi_abs[0] > 90 ) || ( azi_abs[1] > 90 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Panning stereo pair beyond |90| degrees azimuth is not allowed" ); + } + if ( ( ele_abs[0] > 45 ) || ( ele_abs[1] > 45 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_RENDER_CONFIG, "Panning stereo pair beyond |45| degrees of elevation is not allowed" ); + } + } + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * is_split_rendering_enabled() diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 56cd7bed4d..6e659e43c3 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -651,6 +651,9 @@ ivas_error ivas_td_binaural_open_unwrap( const AUDIO_CONFIG transport_config, /* i : Transport configuration */ const float *directivity, /* i : Directivity pattern (used for ISM) */ const float *distAtt, /* i : Distance attenuation (used for ISM) */ +#ifdef FIX_1419_SPATIAL_UMX + const float *radius_ms_umx, /* i : Radius (used for mono/stereo upmix) */ +#endif const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ int32_t *binaural_latency_ns /* i : Binauralization delay */ @@ -1343,6 +1346,13 @@ ivas_error ivas_render_config_init_from_rom( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); +#ifdef FIX_1419_SPATIAL_UMX +ivas_error ms_upmix_validate_config( + IVAS_MS_UMX_CONF_HANDLE pMsUpmixConfig, /* i/o: Mono/Stereo upmix configuration */ + const IVAS_FORMAT ivasFormat, /* i : IVAS Decoder input configuration */ + const IVAS_AUDIO_CONFIG outConfig /* i : IVAS Decoder output configuration */ +); +#endif /*----------------------------------------------------------------------------------* * Quaternion operations diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index c3a39b426e..22a3e86cfe 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -135,6 +135,15 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */ ( *hRenderConfig )->distAtt[1] = 1.0f; /* Default ref dist */ ( *hRenderConfig )->distAtt[2] = 1.0f; /* Default rolloff factor */ +#ifdef FIX_1419_SPATIAL_UMX + + /* Mono/Stereo upmix configuration */ + ( *hRenderConfig )->mono_stereo_upmix_config.spatialEnabled = FALSE; + ( *hRenderConfig )->mono_stereo_upmix_config.stereoLR = FALSE; + ( *hRenderConfig )->mono_stereo_upmix_config.radius = 0.f; + set_zero( &( *hRenderConfig )->mono_stereo_upmix_config.azi[0], 2 ); + set_zero( &( *hRenderConfig )->mono_stereo_upmix_config.ele[0], 2 ); +#endif /* ISAR-related parameters */ ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 0fad5fae2f..411abbb7ce 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -205,6 +205,11 @@ const int16_t sba_map_tc_512[11] = * 13 = 135, 35 * 14 = -135, 35 */ +#ifdef FIX_1419_SPATIAL_UMX +const int16_t channelIndex_CICP1[1] = { 2 }; +const int16_t channelIndex_CICP2[2] = { 0, 1 }; +const int16_t channelIndex_LR[2] = { 7, 8 }; +#endif const int16_t channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 }; const int16_t channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 }; const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 927287ecd9..f547b15e58 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -67,6 +67,11 @@ extern const int16_t sba_map_tc_512[11]; * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ +#ifdef FIX_1419_SPATIAL_UMX +extern const int16_t channelIndex_CICP1[1]; +extern const int16_t channelIndex_CICP2[2]; +extern const int16_t channelIndex_LR[2]; +#endif extern const int16_t channelIndex_CICP6[5]; extern const int16_t channelIndex_CICP12[7]; extern const int16_t channelIndex_CICP14[7]; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 95361e116a..98484833d1 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -361,7 +361,11 @@ void rotateFrame_sd( ) { int16_t i, j; +#ifdef FIX_1419_SPATIAL_UMX + int16_t nchan, num_lfe, index_lfe; +#else int16_t nchan, index_lfe; +#endif int16_t ch_in, ch_in_woLFE, ch_out, ch_out_woLFE; int16_t azimuth, elevation; @@ -374,6 +378,9 @@ void rotateFrame_sd( push_wmops( "rotateFrame_sd" ); nchan = hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe; +#ifdef FIX_1419_SPATIAL_UMX + num_lfe = hTransSetup.num_lfe; +#endif index_lfe = hTransSetup.index_lfe[0]; tmp = 1.0f / ( subframe_len - 1 ); @@ -400,7 +407,11 @@ void rotateFrame_sd( } /* input channel index without LFE */ +#ifdef FIX_1419_SPATIAL_UMX + ch_in_woLFE = ( ( num_lfe > 0 ) && ( ch_in >= index_lfe ) ) ? ch_in - 1 : ch_in; +#else ch_in_woLFE = ( ch_in >= index_lfe ) ? ch_in - 1 : ch_in; +#endif /* gains for previous subframe rotation */ rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat_prev[0], hTransSetup.is_planar_setup ); @@ -417,7 +428,12 @@ void rotateFrame_sd( } /* output channel index without LFE */ +#ifdef FIX_1419_SPATIAL_UMX + ch_out_woLFE = ( ( num_lfe > 0 ) && ( ch_out >= index_lfe ) ) ? ch_out - 1 : ch_out; +#else ch_out_woLFE = ( ch_out >= index_lfe ) ? ch_out - 1 : ch_out; +#endif + gains_prev[ch_in][ch_out] = tmp_gains[ch_out_woLFE]; } @@ -439,7 +455,11 @@ void rotateFrame_sd( } /* output channel index without LFE */ +#ifdef FIX_1419_SPATIAL_UMX + ch_out_woLFE = ( ( num_lfe > 0 ) && ( ch_out >= index_lfe ) ) ? ch_out - 1 : ch_out; +#else ch_out_woLFE = ( ch_out >= index_lfe ) ? ch_out - 1 : ch_out; +#endif gains[ch_in][ch_out] = tmp_gains[ch_out_woLFE]; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 7729efbc7c..67807b9847 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2591,6 +2591,46 @@ ivas_error RenderConfigReader_read( free( pValue ); acIdx++; } +#ifdef FIX_1419_SPATIAL_UMX + else if ( strcmp( chapter, "MSUPMIX" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + if ( strcmp( item, "AZIMUTH" ) == 0 ) + { + if ( read_txt_vector( pValue, 2, &hRenderConfig->mono_stereo_upmix_config.azi[0] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* set flag to signal that spatial rendering is enabled */ + hRenderConfig->mono_stereo_upmix_config.spatialEnabled = 1; + } + else if ( strcmp( item, "ELEVATION" ) == 0 ) + { + if ( read_txt_vector( pValue, 2, &hRenderConfig->mono_stereo_upmix_config.ele[0] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* set flag to signal that spatial rendering is enabled */ + hRenderConfig->mono_stereo_upmix_config.spatialEnabled = 1; + } + else if ( strcmp( item, "RADIUS" ) == 0 ) + { + if ( !sscanf( pValue, "%f", &hRenderConfig->mono_stereo_upmix_config.radius ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + /* set flag to signal that spatial rendering is enabled */ + hRenderConfig->mono_stereo_upmix_config.spatialEnabled = 1; + } + } + } +#endif else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) { params_idx = 0; @@ -2976,6 +3016,14 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_1419_SPATIAL_UMX + + /* case when config file contains no acoustic environment, the defaults are already set from ROM */ + if ( id == 65535 && pRenderConfigReader->nAE == 0 ) + { + return IVAS_ERR_OK; + } +#endif /* case when -aeid is not specified, select first ID from config file */ if ( id == 65535 && pRenderConfigReader->nAE > 0 ) -- GitLab