Commit f9d9ee00 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add external renderer support for mono/stereo upmix

parent 6d33396b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@
#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 */
#define FIX_1419_EXTREND                                /* FhG: issue 1419, 1xxx: enable rendering of mono/stereo to other formats in the external renderer */
#endif
#define FIX_1437_LC3PLUS_EXTREND_HIRES                  /* FhG: fix external renderer split bitstream header writing causing a crash for LC3plus High-res mode */

+9 −0
Original line number Diff line number Diff line
@@ -1352,6 +1352,15 @@ ivas_error ivas_render_config_change_defaults(
    IVAS_DefaultReverbSize reverbDefault                        /* i:   Reverb default size                     */
);

#endif
#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

/*----------------------------------------------------------------------------------*
+100 −0
Original line number Diff line number Diff line
@@ -1273,11 +1273,16 @@ static bool isIoConfigPairSupported(
    const AUDIO_CONFIG inConfig,
    const AUDIO_CONFIG outConfig )
{
#ifdef FIX_1419_EXTREND
    (void) inConfig;  // TODO tmp
    (void) outConfig; // TODO tmp
#else
    /* Rendering mono or stereo to binaural is not supported */
    if ( ( inConfig == IVAS_AUDIO_CONFIG_MONO || inConfig == IVAS_AUDIO_CONFIG_STEREO ) && getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL )
    {
        return false;
    }
#endif

    /* If not returned so far, config pair is supported */
    return true;
@@ -2234,15 +2239,47 @@ static ivas_error updateMcPanGainsForAmbiOut(
{
    int16_t ch_in, ch_out, lfeIdx;
    int16_t numNonLfeInChannels, outAmbiOrder;
#ifdef FIX_1419_MONO_STEREO_UMX
    AUDIO_CONFIG inConfig;
#endif
    const float *spkAzi, *spkEle;
    ivas_error error;

#ifdef FIX_1419_MONO_STEREO_UMX
    inConfig = inputMc->base.inConfig;

#endif
    if ( ( error = getAmbisonicsOrder( outConfig, &outAmbiOrder ) ) != IVAS_ERR_OK )
    {
        return error;
    }

#ifdef FIX_1419_MONO_STEREO_UMX
    if ( inConfig == IVAS_AUDIO_CONFIG_MONO ||
         inConfig == IVAS_AUDIO_CONFIG_STEREO )
    {
        setZeroPanMatrix( inputMc->panGains );
        if ( inConfig == IVAS_AUDIO_CONFIG_MONO )
        {
            /* W = Mono */
            inputMc->panGains[0][0] = 1.f;
        }
        else
        {
            /* W = 0.5 * ( L + R ) */
            inputMc->panGains[0][0] = 0.5f;
            inputMc->panGains[0][1] = 0.5f;
            /* Y = 0.5 * ( L - R ) */
            inputMc->panGains[1][0] = 0.5f;
            inputMc->panGains[1][1] = -0.5f;
        }

        return IVAS_ERR_OK;
    }
    else if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM )
#else
    if ( inputMc->base.inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM )
#endif
    {
        if ( ( error = getNumNonLfeChannelsInSpeakerLayout( inputMc->base.inConfig, &numNonLfeInChannels ) ) != IVAS_ERR_OK )
        {
@@ -2298,6 +2335,29 @@ static ivas_error updateMcPanGainsForAmbiOut(
    return IVAS_ERR_OK;
}

#ifdef FIX_1419_MONO_STEREO_UMX
static ivas_error updateMcPanGainsForBinauralOut(
    input_mc *inputMc,
    const AUDIO_CONFIG outConfig )
{
    setZeroPanMatrix( inputMc->panGains );
    if ( inputMc->base.inConfig == IVAS_AUDIO_CONFIG_MONO )
    {
        (void)inputMc->nonDiegeticPanGain;//TODO
        /* same as non-diegetic panning to C */
        inputMc->panGains[0][0] = 0.5f;
        inputMc->panGains[0][1] = 0.5f;
    }
    else
    {
        /* stereo passthrough */
        inputMc->panGains[0][0] = 1.f;
        inputMc->panGains[1][1] = 1.f;
    }

    return IVAS_ERR_OK;
}
#endif

static ivas_error updateMcPanGains(
    input_mc *inputMc,
@@ -2319,6 +2379,15 @@ static ivas_error updateMcPanGains(
            error = updateMcPanGainsForAmbiOut( inputMc, outConfig );
            break;
        case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL:
#ifdef FIX_1419_MONO_STEREO_UMX
            if ( inputMc->base.inConfig == IVAS_AUDIO_CONFIG_MONO || inputMc->base.inConfig == IVAS_AUDIO_CONFIG_STEREO )
            {
                error = updateMcPanGainsForBinauralOut( inputMc, outConfig );
                break;
            }

            /* not mono or stereo */
#endif
            switch ( outConfig )
            {
                case IVAS_AUDIO_CONFIG_BINAURAL:
@@ -6300,6 +6369,28 @@ static ivas_error renderActiveInputsIsm(
    return IVAS_ERR_OK;
}

#ifdef FIX_1419_MONO_STEREO_UMX
static void renderMonoStereoToBinaural(
    const input_mc *mcInput,
    const AUDIO_CONFIG outConfig,
    IVAS_REND_AudioBuffer outAudio )
{
    int16_t i;
    IVAS_REND_AudioBuffer inAudio;

    push_wmops( "renderMonoStereoToBinaural" );
    inAudio = mcInput->base.inputBuffer;

    for ( i = 0; i < inAudio.config.numChannels; ++i )
    {
        renderBufferChannel( inAudio, i, mcInput->panGains[i], outAudio );
    }

    pop_wmops();

    return;
}
#endif

static ivas_error renderLfeToBinaural(
    const input_mc *mcInput,
@@ -6900,6 +6991,15 @@ static ivas_error renderInputMc(
            renderMcToSba( mcInput, outAudio );
            break;
        case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL:
#ifdef FIX_1419_MONO_STEREO_UMX
            if ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_MONO || mcInput->base.inConfig == IVAS_AUDIO_CONFIG_STEREO )
            {
                renderMonoStereoToBinaural( mcInput, outConfig, outAudio );
                break;
            }

            /* not mono or stereo */
#endif
            switch ( outConfig )
            {
                case IVAS_AUDIO_CONFIG_BINAURAL:
+0 −15
Original line number Diff line number Diff line
@@ -208,9 +208,6 @@ def test_dynamic_acoustic_environment(
    aeid,
    split_comparison,
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    rend_config_path = TEST_VECTOR_DIR.joinpath("rend_config_combined.cfg")
    rend_config_path.with_stem("rend_config")

@@ -263,9 +260,6 @@ def test_dynamic_acoustic_environment_file(
    get_odg_bin,
    split_comparison,
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    rend_config_path = TEST_VECTOR_DIR.joinpath("rend_config_combined.cfg")
    rend_config_path.with_stem("rend_config")

@@ -350,9 +344,6 @@ def test_multichannel_binaural_static(
    get_odg_bin,
    split_comparison,
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    run_renderer(
        record_property,
        props_to_record,
@@ -392,9 +383,6 @@ def test_multichannel_binaural_headrotation(
    get_odg_bin,
    split_comparison,
):
    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    run_renderer(
        record_property,
        props_to_record,
@@ -1569,9 +1557,6 @@ def test_multichannel_binaural_headrotation_refvec_rotating(
    if test_info.config.option.create_ref or test_info.config.option.create_cut:
        pytest.skip("OTR tests only run for smoke test")

    if in_fmt in ["MONO", "STEREO"]:
        pytest.skip("MONO or STEREO to Binaural rendering unsupported")

    compare_renderer_args(
        record_property,
        props_to_record,