diff --git a/lib_com/options.h b/lib_com/options.h index 10149a1c8a0f52bd2514fc9dc347817c6df120b8..c71be15d676c5ac0e01b37da5efde6895540429a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -185,6 +185,7 @@ #define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nok: issue 1497 - porting OMASA EXT MR */ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ +#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 a03acffe1dd20b30d10daf7377c45fe75ffd3320..c7df954dbc461bb37da1e889df151e97725e0761 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1086,7 +1086,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; @@ -1113,7 +1125,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 ) { @@ -2996,11 +3020,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 */ @@ -3032,11 +3063,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 4a7d76917bd65815d94093ea49e4758792ab447b..2577f324cf5bf4b35c56d8d135c26e989d56569f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -691,7 +691,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 722edf53e88c29e78bf23fde29da903353eed474..156a8ce77d589d2e28430bf12a56a28b1e1222cf 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -415,7 +415,11 @@ 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 ) +#endif { index_16bits( hQMetaData, hMasa->data.sph_grid16 ); } @@ -638,7 +642,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 ) { @@ -1071,6 +1079,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 a2cf2351a21cf3803e391f36459f9adb07cef7d0..3cd98b9ca2264f33548b7f66a08beae9b79c9d94 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -148,7 +148,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 40cb9e49623babbeb114d27ed613b92c8b751ab5..e337f32f42537c1ce7ffda34ca3550b3f2925204 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_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 699343c1da5f80a7bd03e883f9f31dc7b4a9d404..ce0172a869f7466f250b2ea302c3a5e4c3cbb1b7 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -223,9 +223,6 @@ static ivas_error get_ls_conversion_matrix( int16_t index; float value; const LS_CONVERSION_MATRIX *conversion_matrix; - ivas_error error; - - error = IVAS_ERR_OK; conversion_matrix = NULL; @@ -260,7 +257,7 @@ static ivas_error get_ls_conversion_matrix( } } } - return error; + return IVAS_ERR_OK; } else { @@ -273,7 +270,7 @@ static ivas_error get_ls_conversion_matrix( { hLsSetUpConversion->dmxMtx[k][k] = 1.0f; } - return error; + return IVAS_ERR_OK; } else { @@ -288,7 +285,7 @@ static ivas_error get_ls_conversion_matrix( hLsSetUpConversion->dmxMtx[ch_in][ch_out] = value; } } - return error; + return IVAS_ERR_OK; } } } @@ -311,8 +308,10 @@ ivas_error ivas_ls_setup_conversion_open( int16_t chIdx, inChannels, outChannels; int16_t output_frame; int32_t output_Fs; - int16_t nchan_out; int16_t paramUpmixMonoStereo; +#ifdef FIX_1052_EXT_OUTPUT + ivas_error error; +#endif if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) { @@ -323,7 +322,7 @@ ivas_error ivas_ls_setup_conversion_open( paramUpmixMonoStereo = FALSE; } output_Fs = st_ivas->hDecoderConfig->output_Fs; - nchan_out = st_ivas->hDecoderConfig->nchan_out; + outChannels = st_ivas->hDecoderConfig->nchan_out; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); /* Allocate memory to the handle */ @@ -332,9 +331,8 @@ ivas_error ivas_ls_setup_conversion_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } - assert( nchan_out <= MAX_OUTPUT_CHANNELS ); + assert( outChannels <= MAX_OUTPUT_CHANNELS ); - outChannels = nchan_out; if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC ) { inChannels = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; @@ -423,16 +421,37 @@ ivas_error ivas_ls_setup_conversion_open( { if ( paramUpmixMonoStereo == TRUE ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) + { + return error; + } +#else get_ls_conversion_matrix( hLsSetUpConversion, IVAS_AUDIO_CONFIG_5_1_2, st_ivas->hDecoderConfig->output_config ); +#endif } else { +#ifdef FIX_1052_EXT_OUTPUT + if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) + { + return error; + } +#else get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->transport_config, st_ivas->hDecoderConfig->output_config ); +#endif } } else { +#ifdef FIX_1052_EXT_OUTPUT + if ( ( error = get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config ) ) != IVAS_ERR_OK ) + { + return error; + } +#else get_ls_conversion_matrix( hLsSetUpConversion, st_ivas->intern_config, st_ivas->hDecoderConfig->output_config ); +#endif } } @@ -633,9 +652,7 @@ void ivas_ls_setup_conversion_process_mdct( { dmxCoeff = hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx]; - if ( - chInIdx != LFE_CHANNEL && - mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( chInIdx != LFE_CHANNEL && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) { /* Step 1: Compute the target energy and DMX signal (possible since we have all signals in TCX20 resolution) */ if ( dmxCoeff ) @@ -728,9 +745,7 @@ void ivas_ls_setup_conversion_process_mdct( /* Step 4: Perform equalization */ for ( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) { - if ( - chInIdx != LFE_CHANNEL && - mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) + if ( chInIdx != LFE_CHANNEL && mct_chan_mode[chInIdx] != MCT_CHAN_MODE_IGNORE ) { if ( transform_type[chInIdx][0] == TCX_20 ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index c44b59e8c93f0791b8db9148d2fbe113ec01df1e..4d7f9acfe9781338d62922d54bee70aed46455a2 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -262,7 +262,11 @@ void ivas_renderer_select( } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { +#ifdef FIX_1052_EXT_OUTPUT + if ( output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) +#else if ( output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_MONO ) +#endif { *renderer_type = RENDERER_MC; } @@ -410,7 +414,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 ) { @@ -424,7 +432,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 ) { @@ -449,7 +461,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 39ff3d95bc0ca92503f0b217d91ba73717c23db6..87df5d6df5a630039e1d9180961eefd9de69604d 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -402,7 +402,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 ) );