Commit 937e5c42 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

all changes lib_rend.c

parent c90af971
Loading
Loading
Loading
Loading
+90 −7
Original line number Diff line number Diff line
@@ -2920,8 +2920,11 @@ static ivas_error setRendInputActiveMasa(
    const IVAS_REND_InputId id,
    RENDER_CONFIG_DATA *hRendCfg,
    hrtf_handles *hrtfs

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
)
#else
    ) /* Todo: This is not used at all within MASA. Support might be better to do after refactoring. */
#endif
{
    ivas_error error;
    rendering_context rendCtx;
@@ -2932,7 +2935,9 @@ static ivas_error setRendInputActiveMasa(
    inputMasa = (input_masa *) input;
    rendCtx = inputMasa->base.ctx;
    outConfig = *rendCtx.pOutConfig;
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    (void) hRendCfg; /* Suppress warning */
#endif

    if ( !isIoConfigPairSupported( inConfig, outConfig ) )
    {
@@ -2960,7 +2965,11 @@ static ivas_error setRendInputActiveMasa(
    }
    else
    {
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ) != IVAS_ERR_OK )
#else
        if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ) != IVAS_ERR_OK )
#endif
		{
            return error;
        }
@@ -3157,6 +3166,9 @@ ivas_error IVAS_REND_Open(
    hIvasRend->hHrtfs.hHrtfParambin = NULL;
    hIvasRend->hHrtfs.hHrtfTD = NULL;
    hIvasRend->hHrtfs.hSetOfHRTF = NULL;
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    hIvasRend->hHrtfs.hHrtfStatistics = NULL;
#endif
    if ( asHrtfBinary )
    {
        if ( ( error = ivas_HRTF_binary_open( &( hIvasRend->hHrtfs.hHrtfTD ) ) ) != IVAS_ERR_OK )
@@ -3175,7 +3187,20 @@ ivas_error IVAS_REND_Open(
        {
            return error;
        }

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        if ( ( error = ivas_HRTF_statistics_binary_open( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif

    return IVAS_ERR_OK;
}
@@ -3320,7 +3345,11 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(
            /* Input inactive, skip. */
            continue;
        }
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL, NULL ) ) != IVAS_ERR_OK )
#else
        if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ) != IVAS_ERR_OK )
#endif
		{
            return error;
        }
@@ -3799,6 +3828,10 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout(
                                                hIvasRend->outputConfig,
                                                hIvasRend->hRendererConfig,
                                                hIvasRend->hHrtfs.hSetOfHRTF,

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
                                                hIvasRend->hHrtfs.hHrtfStatistics,
#endif
                                                FALSE ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -4582,6 +4615,9 @@ ivas_error IVAS_REND_SetHeadRotation(
                                                    hIvasRend->outputConfig,
                                                    hIvasRend->hRendererConfig,
                                                    hIvasRend->hHrtfs.hSetOfHRTF,
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
                                                    hIvasRend->hHrtfs.hHrtfStatistics,
#endif
                                                    TRUE ) ) != IVAS_ERR_OK )
            {
                return error;
@@ -4647,6 +4683,10 @@ ivas_error IVAS_REND_DisableHeadRotation(
                                                        hIvasRend->outputConfig,
                                                        hIvasRend->hRendererConfig,
                                                        hIvasRend->hHrtfs.hSetOfHRTF,

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
                                                        hIvasRend->hHrtfs.hHrtfStatistics,
#endif
                                                        TRUE ) ) != IVAS_ERR_OK )
                {

@@ -7967,6 +8007,9 @@ void IVAS_REND_Close(
    ivas_HRTF_CRend_binary_close( &( hIvasRend->hHrtfs.hSetOfHRTF ) );
    ivas_HRTF_fastconv_binary_close( &( hIvasRend->hHrtfs.hHrtfFastConv ) );
    ivas_HRTF_parambin_binary_close( &( hIvasRend->hHrtfs.hHrtfParambin ) );
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    ivas_HRTF_statistics_close( &( hIvasRend->hHrtfs.hHrtfStatistics ) );
#endif

    free( hIvasRend );
    *phIvasRend = NULL;
@@ -8208,6 +8251,30 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle(
    return IVAS_ERR_OK;
}


#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
/*---------------------------------------------------------------------*
 * IVAS_REND_GetHrtfStatisticsHandle( )
 *
 *
 *---------------------------------------------------------------------*/

ivas_error IVAS_REND_GetHrtfStatisticsHandle(
    IVAS_REND_HANDLE hIvasRend,                       /* i/o: IVAS decoder handle     */
    IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o  : HRTF statistics handle  */
)
{
    if ( hIvasRend == NULL || hIvasRend->hHrtfs.hHrtfStatistics == NULL )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }

    *hHrtfStatistics = &hIvasRend->hHrtfs.hHrtfStatistics;

    return IVAS_ERR_OK;
}
#endif

static ivas_error ivas_masa_ext_rend_dirac_rend_init(
    input_masa *inputMasa )
{
@@ -8569,7 +8636,13 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init(
}

static ivas_error ivas_masa_ext_rend_parambin_init(
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    input_masa *inputMasa,                  /* i/o: MASA external renderer structure        */
    const RENDER_CONFIG_DATA *hRendCfg,     /* i  : Renderer configuration data handle      */
    HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i  : HRTF statistics                         */
#else
    input_masa *inputMasa /* i/o: MASA external renderer structure        */
#endif
)
{
    DIRAC_DEC_BIN_HANDLE hDiracDecBin;
@@ -8665,8 +8738,12 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
        if ( hDiracDecBin->hReverb == NULL )
#endif
            {
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
#else
            /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */
            if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
@@ -8720,6 +8797,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
static ivas_error initMasaExtRenderer(
    input_masa *inputMasa,
    const AUDIO_CONFIG outConfig,
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    const RENDER_CONFIG_DATA *hRendCfg,
#endif
    hrtf_handles *hrtfs )
{
    int16_t i;
@@ -8844,8 +8924,11 @@ static ivas_error initMasaExtRenderer(
                return error;
            }
        }

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK )
#endif        
		{
            return error;
        }