Commit fbc8acdc authored by vaclav's avatar vaclav
Browse files

accept FIX_513_REND_MC_ALLOC

parent 5a369a8a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@
#define FIX_712_713_SPLIT_REND_MASA_MC                 /*Dlb : Fix for issue 712 and 713*/
#endif

#define FIX_513_REND_MC_ALLOC                           /* FhG: issue 513, optimise external renderer allocation for multichannel */
#define FIX_812_DOUBLE_PREC_MCT                         /* FhG: Issue 812: Avoid double precision in MCT */
#define FIX_807_VARIABLE_SPEED_DECODING                 /* FhG: Issue 807: Resolve "Variable Speed Decoding broken" */
#define FIX_818_DOUBLE_PREC_KERNEN_SW                   /* FhG: Issue 818: Avoid double precision in kernel switching */
+72 −135
Original line number Diff line number Diff line
@@ -2165,12 +2165,8 @@ static ivas_error initMcBinauralRendering(
    input_mc *inputMc,
    const AUDIO_CONFIG inConfig,
    const AUDIO_CONFIG outConfig,
    RENDER_CONFIG_DATA *hRendCfg
#ifdef FIX_513_REND_MC_ALLOC
    ,
    uint8_t reconfigureFlag
#endif
)
    RENDER_CONFIG_DATA *hRendCfg,
    uint8_t reconfigureFlag )
{
    ivas_error error;
#ifdef SPLIT_REND_WITH_HEAD_ROT
@@ -2178,7 +2174,6 @@ static ivas_error initMcBinauralRendering(
#endif
    int32_t binauralDelayNs;
    int32_t outSampleRate;
#ifdef FIX_513_REND_MC_ALLOC
    int8_t useTDRend;

    /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation)
@@ -2196,27 +2191,17 @@ static ivas_error initMcBinauralRendering(
            useTDRend = TRUE;
        }
    }
#endif

    /* if TD renderer was open and we need to use CREND, close it */
    if (
#ifdef FIX_513_REND_MC_ALLOC
        !reconfigureFlag || ( !useTDRend &&
#endif
                              inputMc->tdRendWrapper.hBinRendererTd != NULL )
#ifdef FIX_513_REND_MC_ALLOC
    )
#endif
    if ( !reconfigureFlag || ( !useTDRend && inputMc->tdRendWrapper.hBinRendererTd != NULL ) )
    {
        ivas_td_binaural_close( &inputMc->tdRendWrapper.hBinRendererTd );
        inputMc->tdRendWrapper.hHrtfTD = NULL;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef FIX_513_REND_MC_ALLOC
    if ( !reconfigureFlag || !useTDRend )
    {
#endif
        for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
        {
            if ( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL )
@@ -2225,52 +2210,36 @@ static ivas_error initMcBinauralRendering(
                inputMc->splitTdRendWrappers[i].hHrtfTD = NULL;
            }
        }
#ifdef FIX_513_REND_MC_ALLOC
    }
#endif
#endif

#ifdef FIX_513_REND_MC_ALLOC
    /* if we need to use TD renderer and CREND was open, close it */
    if ( useTDRend )
    {
#endif
        ivas_rend_closeCrend( &inputMc->crendWrapper
#ifdef SPLIT_REND_WITH_HEAD_ROT
                              ,
                              inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses
#endif
        );
#ifdef FIX_513_REND_MC_ALLOC
    }
#endif

#ifdef FIX_513_REND_MC_ALLOC
    if ( !reconfigureFlag || ( !useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL ) )
    {
#endif
        ivas_reverb_close( &inputMc->hReverb );
#ifdef FIX_513_REND_MC_ALLOC
    }
#endif

#ifdef FIX_513_REND_MC_ALLOC
    if ( !reconfigureFlag || ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM && !inputMc->base.ctx.pHeadRotData->headRotEnabled ) )
    {
#endif
        if ( inputMc->efapInWrapper.hEfap != NULL )
        {
            efap_free_data( &inputMc->efapInWrapper.hEfap );
        }
#ifdef FIX_513_REND_MC_ALLOC
    }
#endif

    outSampleRate = *inputMc->base.ctx.pOutSampleRate;

#ifdef FIX_513_REND_MC_ALLOC
    if ( useTDRend && inputMc->tdRendWrapper.hBinRendererTd == NULL )
#endif
    {
        if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK )
        {
@@ -2294,11 +2263,7 @@ static ivas_error initMcBinauralRendering(
        }

#endif
        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef FIX_513_REND_MC_ALLOC
             && inputMc->hReverb == NULL
#endif
        )
        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL )
        {
            if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK )
            {
@@ -2306,29 +2271,21 @@ static ivas_error initMcBinauralRendering(
            }
        }
    }
#ifdef FIX_513_REND_MC_ALLOC
    else if ( !useTDRend && inputMc->crendWrapper == NULL ) /* open CREND */
#endif
    else if ( !useTDRend && inputMc->crendWrapper == NULL )
    {
        /* open CREND */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK )
#endif

        {
            return error;
        }
#ifdef FIX_513_REND_MC_ALLOC
    }
#endif

    /* Initialise the EFAP handle for rotation on input layout */
    if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled
#ifdef FIX_513_REND_MC_ALLOC
         && inputMc->efapInWrapper.hEfap == NULL
#endif
    )
    if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL )
    {
        if ( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ) != IVAS_ERR_OK )
        {
@@ -2497,9 +2454,7 @@ static ivas_error setRendInputActiveMc(
#endif
    inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut );
    set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES );
#ifdef FIX_513_REND_MC_ALLOC
    inputMc->binauralDelaySmp = 0;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( i = 0; i < (int16_t) ( sizeof( inputMc->splitTdRendWrappers ) / sizeof( *inputMc->splitTdRendWrappers ) ); ++i )
@@ -2512,12 +2467,7 @@ static ivas_error setRendInputActiveMc(
    if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
#endif
    {
        if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg
#ifdef FIX_513_REND_MC_ALLOC
                                                ,
                                                FALSE
#endif
                                                ) ) != IVAS_ERR_OK )
        if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -4420,15 +4370,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout(
    if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
#endif
    {
        if ( ( error = initMcBinauralRendering( inputMc,
                                                inputMc->base.inConfig,
                                                hIvasRend->outputConfig,
                                                hIvasRend->hRendererConfig
#ifdef FIX_513_REND_MC_ALLOC
                                                ,
                                                FALSE
#endif
                                                ) ) != IVAS_ERR_OK )
        if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, FALSE ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -5244,9 +5186,7 @@ ivas_error IVAS_REND_SetHeadRotation(
#endif
    const int16_t sf_idx )
{
#ifdef FIX_513_REND_MC_ALLOC
    int16_t i;
#endif
    IVAS_QUATERNION rotQuat;
    ivas_error error;

@@ -5262,7 +5202,6 @@ ivas_error IVAS_REND_SetHeadRotation(
        return IVAS_ERR_INVALID_OUTPUT_FORMAT;
    }

#ifdef FIX_513_REND_MC_ALLOC
    hIvasRend->headRotData.headRotEnabled = 1;

    /* reconfigure binaural rendering to allocate
@@ -5278,7 +5217,7 @@ ivas_error IVAS_REND_SetHeadRotation(
                                     TRUE );
        }
    }
#endif

    /* check for Euler angle signaling */
    if ( headRot.w == -3.0f )
    {
@@ -5314,9 +5253,8 @@ ivas_error IVAS_REND_DisableHeadRotation(
    IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle  */
)
{
#ifdef FIX_513_REND_MC_ALLOC
    int16_t i;
#endif

    /* Validate function arguments */
    if ( hIvasRend == NULL )
    {
@@ -5324,7 +5262,7 @@ ivas_error IVAS_REND_DisableHeadRotation(
    }

    hIvasRend->headRotData.headRotEnabled = 0;
#ifdef FIX_513_REND_MC_ALLOC

    /* reconfigure binaural rendering to allocate
       the necessary renderers and free unused ones */
    if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL )
@@ -5342,7 +5280,6 @@ ivas_error IVAS_REND_DisableHeadRotation(
        }
    }

#endif
    return IVAS_ERR_OK;
}