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

add fixes to enable FIX_I106_TDREND_5MS

parent eed8fa6b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@
#define FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS
/*#define FIX_I1_113*/                                  /* under review : MCT bit distribution optimization for SBA high bitrates*/

// #define FIX_I106_TDREND_5MS                             /* Issue 106: 5 ms update rate in TD object renderer */
#define FIX_I106_TDREND_5MS                             /* Issue 106: 5 ms update rate in TD object renderer */
#define ALIGN_SID_SIZE                                  /* Issue 111: make all DTX modes use one SID frame bitrate (5.2 kbps) */
#define FIX_135_MDCT_STEREO_MODE_UNINITIALIZED          /* Issue 135: fix uninitialized value usage in SBA MDCT-Stereo core with PLC */
#define FIX_CONTROLLABLE_SID_UPDATE_RATE                /* Issue 117: fix controllable SID update rate mechanism */
+121 −29
Original line number Diff line number Diff line
@@ -57,8 +57,22 @@ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRenderer
#endif
static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd );
#ifdef FIX_I106_TDREND_5MS
static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t headRotEnabled, const Quaternion *headPosition );
static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t numSources, const IVAS_FORMAT in_format, const ISM_METADATA_HANDLE *hIsmMetaData, float output[][L_FRAME48k] );
static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,
                                                const int16_t headRotEnabled,
#ifdef EXT_RENDERER
                                                const IVAS_QUATERNION *headPosition
#else
                                                const Quaternion *headPosition
#endif
);
static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,
                                            const int16_t numSources,
#ifdef EXT_RENDERER
                                            const int16_t lfe_idx,
#endif
                                            const IVAS_FORMAT in_format,
                                            const ISM_METADATA_HANDLE *hIsmMetaData,
                                            float output[][L_FRAME48k] );
#endif

/*---------------------------------------------------------------------*
@@ -358,7 +372,11 @@ void ObjRenderIVASFrame(

#ifdef FIX_I106_TDREND_5MS
/* Update object position(s) */
#ifdef EXT_RENDERER
    TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output );
#else
    TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->hIsmMetaData, output );
#endif

    for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ )
    {
@@ -530,6 +548,9 @@ static void TDREND_Clear_Update_flags(
static void TDREND_Update_object_positions(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle              */
    const int16_t numSources,                          /* i  : Number of sources to render      */
#ifdef EXT_RENDERER
    const int16_t lfe_idx, /* i  : Input LFE index                  */
#endif
    const IVAS_FORMAT in_format,             /* i  : Format of input sources          */
    const ISM_METADATA_HANDLE *hIsmMetaData, /* i  : Input metadata for ISM objects   */
    float output[][L_FRAME48k]               /* i/o: SCE/MC channels                  */
@@ -547,7 +568,11 @@ static void TDREND_Update_object_positions(
    c_indx = 0;
    for ( nS = 0; nS < numSources; nS++ )
    {
#ifdef EXT_RENDERER
        if ( !( in_format == MC_FORMAT && nS == lfe_idx ) ) /* Skip LFE for MC */
#else
        if ( !( in_format == MC_FORMAT && nS == LFE_CHANNEL ) ) /* Skip LFE for MC */
#endif
        {
            hBinRendererTd->Sources[c_indx]->InputFrame_p = output[nS];
            hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE;
@@ -591,7 +616,11 @@ static void TDREND_Update_object_positions(
static void TDREND_Update_listener_orientation(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle    */
    const int16_t headRotEnabled,                      /* i  : Headrotation flag     */
#ifdef EXT_RENDERER
    const IVAS_QUATERNION *headPosition /* i  : Head Position         */
#else
    const Quaternion *headPosition                              /* i  : Head Position         */
#endif
)
{
    float Pos[3];
@@ -800,32 +829,54 @@ ivas_error ivas_rend_TDObjRenderFrame(
    float output[][L_FRAME48k]                       /* i/o: SCE channels / Binaural synthesis */
)
{
#ifndef FIX_I106_TDREND_5MS
    TDREND_DirAtten_t *DirAtten_p;
    int16_t nS;
    int16_t lfe_idx;
    int16_t c_indx;
    int32_t nchan_in;
    float Pos[3];
    float Dir[3];
    float FrontVec[3];
    float UpVec[3];
    float Rmat[3][3];
    int16_t c_indx;
#else
    int16_t subframe_length;
    int16_t subframe_idx;
    ISM_METADATA_HANDLE hIsmMetaData[1];
#endif
    int16_t lfe_idx;
    int32_t num_src;
    /* TODO tmu : pass down renderer config struct */
    // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k];
    IVAS_FORMAT ivas_format;
    IVAS_REND_AudioConfigType inConfigType;

    inConfigType = getAudioConfigType( inConfig );
    lfe_idx = LFE_CHANNEL;
    if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
    {
        ivas_format = MC_FORMAT;
        if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
        {
        lfe_idx = LFE_CHANNEL;
        getAudioConfigNumChannels( inConfig, &nchan_in );
            getAudioConfigNumChannels( inConfig, &num_src );
        }
        else
        {
            lfe_idx = ( customLsInput->num_lfe > 0 ) ? customLsInput->lfe_idx[0] : -1;
        nchan_in = customLsInput->num_spk + customLsInput->num_lfe;
            num_src = customLsInput->num_spk + customLsInput->num_lfe;
        }
    }
    else
    {
        ivas_format = ISM_FORMAT;
        num_src = 1;
        hIsmMetaData[0] = count_malloc( sizeof( ISM_METADATA_FRAME ) );
        hIsmMetaData[0]->azimuth = currentPos->azimuth;
        hIsmMetaData[0]->elevation = currentPos->elevation;
    }

#ifdef FIX_I106_TDREND_5MS
    subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
#else
    DirAtten_p = pTDRend->hBinRendererTd->DirAtten_p;

    /* Update the listener's location/orientation */
@@ -865,7 +916,7 @@ ivas_error ivas_rend_TDObjRenderFrame(

    /* For each source, write the frame data to the source object*/
    c_indx = 0;
    for ( nS = 0; nS < nchan_in; nS++ )
    for ( nS = 0; nS < num_src; nS++ )
    {
        if ( !( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED && nS == lfe_idx ) ) /* Skip LFE for MC */
        {
@@ -897,10 +948,17 @@ ivas_error ivas_rend_TDObjRenderFrame(
            TDREND_MIX_SRC_SetPlayState( pTDRend->hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING );
        }
    }
#endif

    /* TODO tmu : pass down renderer config struct */
    // if ( pTDRend->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
    /* TODO tmu : pass down renderer config struct and decide what to do about ini_frame ? */
    // if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
    // {
#ifdef FIX_I106_TDREND_5MS
//     if ( hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) )
//     {
//             ivas_reverb_open( &pTDRend->hCrend->hReverb, pTDRend->transport_config, NULL, pTDRend->hRenderConfig, pTDRend->hDecoderConfig->output_Fs );
//     }
#else
//     if ( pTDRend->hRenderConfig->roomAcoustics.late_reverb_on )
//     {
//         if ( pTDRend->ini_frame == 0 )
@@ -912,10 +970,44 @@ ivas_error ivas_rend_TDObjRenderFrame(
//             ivas_reverb_process( pTDRend->hCrend->hReverb, pTDRend->transport_config, 0, output, reverb_signal, subframe_idx );
//         }
//     }
#endif
    // }

#ifdef FIX_I106_TDREND_5MS
    /* Update object position(s) */
    TDREND_Update_object_positions( pTDRend->hBinRendererTd,
                                    num_src,
                                    lfe_idx,
                                    ivas_format,
                                    hIsmMetaData,
                                    output );

    /* TODO tmu : needs a refactor / better approach */
    if ( ivas_format == ISM_FORMAT )
    {
        count_free( hIsmMetaData[0] );
    }

    for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ )
    {
        /* Update the listener's location/orientation */
        TDREND_Update_listener_orientation( pTDRend->hBinRendererTd,
                                            headRotData->headRotEnabled,
                                            ( headRotData != NULL ) ? &headRotData->headPositions[subframe_idx] : NULL );

        /* TODO tmu : pass down renderer config struct */
        // if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) )
        // {
        //     ivas_reverb_process( hCrend->hReverb, transport_config, 0, output, reverb_signal, subframe_idx );
        // }

        /* Render subframe */
        TDREND_GetMix( pTDRend->hBinRendererTd, output, subframe_length, output_Fs, subframe_idx );
    }
#else
    /* Call the renderer */
    TDREND_GetMix( pTDRend->hBinRendererTd, output, output_frame, output_Fs );
#endif

    /* TODO tmu : pass down renderer config struct */
    // if ( pTDRend->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */