Commit 59f3c4ab authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add IVAS_REND_SetInputLfeMtx() API function

parent 10293bc8
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -695,7 +695,7 @@ int main(
#ifdef REND_CFG_LFE
        if ( args.pan_lfe )
        {
            if ( ( error = IVAS_REND_SetInputLfePan( hIvasRend, mcIds[i], args.lfeConfigGain, args.lfeConfigAzimuth, args.lfeConfigElevation ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_REND_SetInputLfePos( hIvasRend, mcIds[i], args.lfeConfigGain, args.lfeConfigAzimuth, args.lfeConfigElevation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
+58 −13
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ typedef struct
    float lfeInputGain;
    float lfeOutputAzimuth;
    float lfeOutputElevation;
    float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
    IVAS_REND_LfePanMtx lfePanMtx;
} lfe_routing;
#endif

@@ -1414,15 +1414,15 @@ static ivas_error updateLfePanGainsForMcOut(
        if ( ( error = getEfapGains( *inputMc->base.ctx.pEfapOutWrapper,
                                     inputMc->lfeRouting.lfeOutputAzimuth,
                                     inputMc->lfeRouting.lfeOutputElevation,
                                     inputMc->lfeRouting.lfeOutputGains[i] ) ) != IVAS_ERR_OK )
                                     inputMc->lfeRouting.lfePanMtx[i] ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /* linear input gain */
        v_multc( inputMc->lfeRouting.lfeOutputGains[i],
        v_multc( inputMc->lfeRouting.lfePanMtx[i],
                 inputMc->lfeRouting.lfeInputGain,
                 inputMc->lfeRouting.lfeOutputGains[i],
                 inputMc->lfeRouting.lfePanMtx[i],
                 numOutChannels );
    }

@@ -1456,13 +1456,13 @@ static ivas_error updateLfePanGainsForAmbiOut(
        /* panning gains */
        ivas_dirac_dec_get_response( inputMc->lfeRouting.lfeOutputAzimuth,
                                     inputMc->lfeRouting.lfeOutputElevation,
                                     inputMc->lfeRouting.lfeOutputGains[i],
                                     inputMc->lfeRouting.lfePanMtx[i],
                                     outAmbiOrder );

        /* linear input gain */
        v_multc( inputMc->lfeRouting.lfeOutputGains[i],
        v_multc( inputMc->lfeRouting.lfePanMtx[i],
                 inputMc->lfeRouting.lfeInputGain,
                 inputMc->lfeRouting.lfeOutputGains[i],
                 inputMc->lfeRouting.lfePanMtx[i],
                 IVAS_MAX_OUTPUT_CHANNELS );
    }

@@ -1641,13 +1641,13 @@ static ivas_error updateMcPanGains(
    {
        for ( i = 0; i < inputMc->customLsInput.num_lfe; ++i )
        {
            mvr2r( inputMc->lfeRouting.lfeOutputGains[i], inputMc->panGains[inputMc->customLsInput.lfe_idx[i]], IVAS_MAX_OUTPUT_CHANNELS );
            mvr2r( inputMc->lfeRouting.lfePanMtx[i], inputMc->panGains[inputMc->customLsInput.lfe_idx[i]], IVAS_MAX_OUTPUT_CHANNELS );
        }
    }
    else
    {
        /* For code simplicity, always copy LFE gains. If config has no LFE, gains will be zero anyway. */
        mvr2r( inputMc->lfeRouting.lfeOutputGains[0], inputMc->panGains[LFE_CHANNEL], IVAS_MAX_OUTPUT_CHANNELS );
        mvr2r( inputMc->lfeRouting.lfePanMtx[0], inputMc->panGains[LFE_CHANNEL], IVAS_MAX_OUTPUT_CHANNELS );
    }

    return IVAS_ERR_OK;
@@ -1745,7 +1745,7 @@ static IVAS_REND_LfeRouting defaultLfeRouting(

    for ( i = 0; i < IVAS_MAX_INPUT_LFE_CHANNELS; ++i )
    {
        set_zero( routing.lfeOutputGains[i], IVAS_MAX_OUTPUT_CHANNELS );
        set_zero( routing.lfePanMtx[i], IVAS_MAX_OUTPUT_CHANNELS );
    }

#ifdef REND_CFG_LFE
@@ -1776,12 +1776,12 @@ static IVAS_REND_LfeRouting defaultLfeRouting(
        case IVAS_REND_AUDIO_CONFIG_5_1_4:
        case IVAS_REND_AUDIO_CONFIG_7_1:
        case IVAS_REND_AUDIO_CONFIG_7_1_4:
            routing.lfeOutputGains[0][LFE_CHANNEL] = 1.0f;
            routing.lfePanMtx[0][LFE_CHANNEL] = 1.0f;
            break;
        case IVAS_REND_AUDIO_CONFIG_LS_CUSTOM:
            for ( i = 0; i < routing.numLfeChannels && i < customLsOut.num_lfe; ++i )
            {
                routing.lfeOutputGains[i][customLsOut.lfe_idx[i]] = 1.0f;
                routing.lfePanMtx[i][customLsOut.lfe_idx[i]] = 1.0f;
            }
            break;
        default:
@@ -3044,7 +3044,52 @@ ivas_error IVAS_REND_SetInputGain(
}

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePan(
ivas_error IVAS_REND_SetInputLfeMtx(
    IVAS_REND_HANDLE hIvasRend,
    const IVAS_REND_InputId inputId,
    const IVAS_REND_LfePanMtx lfePanMtx )
{
    int16_t i;
    input_base *pInputBase;
    input_mc *pInputMc;
    ivas_error error;

    /*-----------------------------------------------------------------*
     * Validate function arguments
     *-----------------------------------------------------------------*/

    if ( hIvasRend == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
    if ( ( error = getInputById( hIvasRend, inputId, (void **) &pInputBase ) ) != IVAS_ERR_OK )
    {
        return error;
    }
    if ( getAudioConfigType( pInputBase->inConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
    {
        /* Custom LFE panning matrix only makes sense with channel-based input */
        return IVAS_ERR_INVALID_INPUT_FORMAT;
    }
    pInputMc = (input_mc *) pInputBase;

    /* copy LFE panning matrix */
    for ( i = 0; i < IVAS_MAX_INPUT_LFE_CHANNELS; i++ )
    {
        mvr2r( lfePanMtx[i], pInputMc->lfeRouting.lfePanMtx[i], IVAS_MAX_OUTPUT_CHANNELS );
    }

    if ( ( error = updateMcPanGains( pInputMc, hIvasRend->outputConfig ) ) != IVAS_ERR_OK )
    {
        return error;
    }

    return IVAS_ERR_OK;
}
#endif

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePos(
#else
ivas_error IVAS_REND_SetInputLfeRouting(
#endif
+13 −1
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@

#define RENDERER_HEAD_POSITIONS_PER_FRAME 4

#ifdef REND_CFG_LFE
typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
#endif

typedef struct
{
    int16_t numSamplesPerChannel;
@@ -194,7 +198,15 @@ ivas_error IVAS_REND_SetInputGain(
);

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePan(
ivas_error IVAS_REND_SetInputLfeMtx(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
    const IVAS_REND_InputId inputId,                /* i  : ID of the input                                     */
    const IVAS_REND_LfePanMtx lfePanMtx             /* i  : LFE panning matrix                                  */
);
#endif

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePos(
#else
ivas_error IVAS_REND_SetInputLfeRouting(
#endif