From 41e89d4ba9e1146ef93842409d99cc5d6b3f13a5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 17 Jun 2025 14:21:53 +0200 Subject: [PATCH 1/2] port FIX_1052_EXT_OUTPUT --- lib_com/options.h | 2 ++ lib_dec/ivas_init_dec.c | 40 ++++++++++++++++++++++++++++++++---- lib_dec/ivas_jbm_dec.c | 4 ++++ lib_dec/ivas_masa_dec.c | 29 ++++++++++++++++++-------- lib_dec/ivas_mc_param_dec.c | 4 ++++ lib_dec/ivas_mct_dec.c | 13 ++++++++++++ lib_dec/ivas_output_config.c | 15 ++++++++++++++ lib_rend/ivas_output_init.c | 4 ++++ 8 files changed, 98 insertions(+), 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 94f061010..e49795243 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -210,6 +210,8 @@ #define FIX_998_UNUSED_FUNCTION /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ #define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ +#define FIX_1052_EXT_OUTPUT /* VA: issue 1052: define EXT decoder output configuration for stereo and MC formats */ + /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a9ec15a79..a9e88428f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1059,7 +1059,19 @@ ivas_error ivas_init_decoder( if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + hDecoderConfig->nchan_out = CPE_CHANNELS; + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->transport_config ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; @@ -1082,7 +1094,19 @@ ivas_error ivas_init_decoder( st_ivas->intern_config = output_config; +#ifdef FIX_1052_EXT_OUTPUT + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == MC_FORMAT ) + { + ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->transport_config ); + st_ivas->intern_config = st_ivas->transport_config; + } + else + { + ivas_output_init( &( st_ivas->hOutSetup ), output_config ); + } +#else ivas_output_init( &( st_ivas->hOutSetup ), output_config ); +#endif if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { @@ -2920,11 +2944,18 @@ static ivas_error doSanityChecks_IVAS( /* Verify stereo output configuration */ if ( st_ivas->ivas_format == STEREO_FORMAT ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" ); } } +#ifdef FIX_1052_EXT_OUTPUT + if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Verify ISM output configuration */ @@ -2956,11 +2987,12 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" ); } } +#endif - if ( ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && output_Fs != 48000 ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); - } + if ( ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && output_Fs != 48000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); + } if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2ce6d0620..10a19b509 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -660,7 +660,11 @@ ivas_error ivas_jbm_dec_tc( /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || +#ifdef FIX_1052_EXT_OUTPUT + output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) || output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#else output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) +#endif { ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, p_output, output_frame, n, LFE_CHANNEL ); } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 6344ba340..37ca6b786 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -388,20 +388,24 @@ ivas_error ivas_masa_decode( hMasa->config.coherencePresent = !hQMetaData->all_coherence_zero; +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) +#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { index_16bits( hQMetaData, hMasa->data.sph_grid16 ); } +#endif - /* If LBR mode is not disabled, then we restore metadata to 5 bands and 4 subframes based on the LBR mode. */ - if ( low_bitrate_mode != -1 ) - { - restore_lowbitrate_masa( hQMetaData, low_bitrate_mode, hMasa->config.numCodingBands ); - } - else if ( hMasa->config.joinedSubframes == TRUE ) - { - replicate_subframes( hQMetaData ); - } + /* If LBR mode is not disabled, then we restore metadata to 5 bands and 4 subframes based on the LBR mode. */ + if ( low_bitrate_mode != -1 ) + { + restore_lowbitrate_masa( hQMetaData, low_bitrate_mode, hMasa->config.numCodingBands ); + } + else if ( hMasa->config.joinedSubframes == TRUE ) + { + replicate_subframes( hQMetaData ); + } } else if ( !st->bfi && ivas_format == MASA_FORMAT && ivas_total_brate == IVAS_SID_5k2 ) { @@ -598,7 +602,11 @@ ivas_error ivas_masa_dec_open( hMasa->config.joinedSubframes = FALSE; /* Create spherical grid only for external output */ +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) +#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#endif { if ( ( hMasa->data.sph_grid16 = (SPHERICAL_GRID_DATA *) malloc( sizeof( SPHERICAL_GRID_DATA ) ) ) == NULL ) { @@ -1024,6 +1032,9 @@ static ivas_error init_lfe_synth_data( ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || +#ifdef FIX_1052_EXT_OUTPUT + output_config == IVAS_AUDIO_CONFIG_EXTERNAL || +#endif output_config == IVAS_AUDIO_CONFIG_FOA || output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_HOA3 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 22ad5e34b..cf97f2fca 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -150,7 +150,11 @@ ivas_error ivas_param_mc_dec_open( hParamMC->hoa_encoder = NULL; /* determine the synthesis config */ +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->transport_config == output_config || output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->transport_config == output_config ) +#endif { hParamMC->synthesis_conf = PARAM_MC_SYNTH_DIRECT; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 12b1fc711..cdd922533 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -685,6 +685,15 @@ ivas_error ivas_mc_dec_config( { st_ivas->transport_config = signaled_config; } +#ifdef FIX_1052_EXT_OUTPUT + else if ( st_ivas->transport_config != signaled_config ) + { +#ifdef DEBUGGING + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); +#endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + } +#endif /* select MC format mode */ st_ivas->mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate ); @@ -692,7 +701,11 @@ ivas_error ivas_mc_dec_config( /* MC format switching */ if ( st_ivas->ini_frame != 0 ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || last_mc_mode != st_ivas->mc_mode ) +#else if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) +#endif { if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index dbdb0df16..da86a9afc 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -394,7 +394,11 @@ void ivas_renderer_select( else if ( st_ivas->ivas_format == MC_FORMAT ) { *internal_config = transport_config; +#ifdef FIX_1052_EXT_OUTPUT + if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config && output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config ) +#endif { if ( output_config != IVAS_AUDIO_CONFIG_FOA && output_config != IVAS_AUDIO_CONFIG_HOA2 && output_config != IVAS_AUDIO_CONFIG_HOA3 ) { @@ -408,7 +412,11 @@ void ivas_renderer_select( else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { *internal_config = transport_config; +#ifdef FIX_1052_EXT_OUTPUT + if ( *internal_config != output_config && output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else if ( *internal_config != output_config ) +#endif { if ( output_config != IVAS_AUDIO_CONFIG_FOA && output_config != IVAS_AUDIO_CONFIG_HOA2 && output_config != IVAS_AUDIO_CONFIG_HOA3 ) { @@ -433,7 +441,14 @@ void ivas_renderer_select( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + { + *internal_config = output_config; + } +#else *internal_config = output_config; +#endif /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 24e619722..9fd4a4e5f 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -396,7 +396,11 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); } +#ifdef FIX_1052_EXT_OUTPUT + else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else else +#endif { nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) ); -- GitLab From d0aa2fe418652ad1a04d0d2c9315608e4164feea Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 3 Aug 2025 20:29:59 +0200 Subject: [PATCH 2/2] fix merge --- lib_dec/ivas_masa_dec.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 86a674221..156a8ce77 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -419,20 +419,20 @@ ivas_error ivas_masa_decode( if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) #else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#endif { index_16bits( hQMetaData, hMasa->data.sph_grid16 ); } -#endif - /* If LBR mode is not disabled, then we restore metadata to 5 bands and 4 subframes based on the LBR mode. */ - if ( low_bitrate_mode != -1 ) - { - restore_lowbitrate_masa( hQMetaData, low_bitrate_mode, hMasa->config.numCodingBands ); - } - else if ( hMasa->config.joinedSubframes == TRUE ) - { - replicate_subframes( hQMetaData ); - } + /* If LBR mode is not disabled, then we restore metadata to 5 bands and 4 subframes based on the LBR mode. */ + if ( low_bitrate_mode != -1 ) + { + restore_lowbitrate_masa( hQMetaData, low_bitrate_mode, hMasa->config.numCodingBands ); + } + else if ( hMasa->config.joinedSubframes == TRUE ) + { + replicate_subframes( hQMetaData ); + } } else if ( !st->bfi && ivas_format == MASA_FORMAT && ivas_total_brate == IVAS_SID_5k2 ) { -- GitLab