Commit 10f83c6d authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_I106_TDREND_5MS

parent b36e9598
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -842,9 +842,7 @@ typedef enum {
 *----------------------------------------------------------------------------------*/
// VE: this should be renamed to e.g. N_SPATIAL_SUBFRAMES
#define MAX_PARAM_SPATIAL_SUBFRAMES             4                           /* Maximum number of subframes for parameteric spatial coding */
#ifdef FIX_I106_TDREND_5MS
#define L_SPATIAL_SUBFR_48k                     (L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES)
#endif


/*----------------------------------------------------------------------------------*
+0 −13
Original line number Diff line number Diff line
@@ -4956,21 +4956,12 @@ void TDREND_HRFILT_SetFiltSet(
#endif

ivas_error TDREND_REND_RenderSourceHRFilt(
#ifdef FIX_I106_TDREND_5MS
    TDREND_SRC_t *Src_p,                                         /* i/o: The source to be rendered               */
#else
    const TDREND_SRC_t *Src_p,                                  /* i/o: The source to be rendered               */
#endif
#ifdef TDREND_HRTF_TABLE_METHODS
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,          /* i/o: TD renderer handle                      */
#endif
#ifdef FIX_I106_TDREND_5MS
    float output_buf[][L_SPATIAL_SUBFR_48k],                    /* o  : Output buffer                           */
    const int16_t subframe_length,                              /* i  : Subframe length in use                  */
#else
    float output_buf[][L_FRAME48k],                             /* o  : Output buffer                           */
    const int16_t output_frame,                                 /* i  : Output frame length in use              */
#endif
    const int32_t output_Fs                                     /* i  : Output sample rate                      */
);

@@ -5110,11 +5101,7 @@ void TDREND_SFX_SpatBin_SetParams(
void TDREND_SFX_SpatBin_Execute_Main(
    SFX_SpatBin_t *SfxSpatBin_p,                                /* i/o: Spatial parameters handle                  */
    const float *InBuffer_p,                                    /* i  : Input buffer                               */
#ifdef FIX_I106_TDREND_5MS
    const int16_t subframe_length,                                 /* i  : subframe length                            */
#else
    const int16_t output_frame,                                 /* i  : frame length                               */
#endif
    float *LeftOutBuffer_p,                                     /* o  : Rendered left channel                      */
    float *RightOutBuffer_p,                                    /* o  : Rendered right channel                     */
    int16_t *NoOfUsedInputSamples_p,                            /* o  : Number of input samples actually used      */
+0 −1
Original line number Diff line number Diff line
@@ -149,7 +149,6 @@
#define SPAR_SCALING_HARMONIZATION                      /* Issue 80: Changes to harmonize scaling in spar */
#define FIX_I98_HANDLES_TO_NULL                         /* Issue 98: do the setting of all handles to NULL in one place */
#define FIX_I102_SWB_TBE_SWITCH                         /* Issue 102: avoid IO->SWB switching code for IVAS, generate SHB ACB mem with lerp in case of switch */
#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 */
+0 −155
Original line number Diff line number Diff line
@@ -46,16 +46,10 @@
 * Local function prototypes
 *---------------------------------------------------------------------*/

#ifdef FIX_I106_TDREND_5MS
static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int32_t output_Fs, const int16_t subframe_idx );
#else
static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t output_frame, const int32_t output_Fs );
#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] );
#endif

/*---------------------------------------------------------------------*
 * ivas_td_binaural_open()
@@ -227,120 +221,20 @@ void ObjRenderIVASFrame(
    const int16_t output_frame  /* i  : output frame length               */
)
{
#ifndef FIX_I106_TDREND_5MS
    TDREND_DirAtten_t *DirAtten_p;
    int16_t nS;
    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;
#endif
    int16_t subframe_idx;
    float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k];

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

    /* Update the listener's location/orientation */
    /* Listener at the origin   */
    Pos[0] = 0.0f;
    Pos[1] = 0.0f;
    Pos[2] = 0.0f;

    if ( st_ivas->hHeadTrackData != NULL )
    {
        /* Obtain head rotation matrix */
        QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[0], Rmat );
        /* Apply rotation matrix to looking vector [1;0;0] */
        FrontVec[0] = Rmat[0][0];
        FrontVec[1] = Rmat[0][1];
        FrontVec[2] = Rmat[0][2];
        /* Apply rotation matrix to up vector [0;0;1] */
        UpVec[0] = Rmat[2][0];
        UpVec[1] = Rmat[2][1];
        UpVec[2] = Rmat[2][2];
    }
    else
    {
        /* Oriented with looking vector along the x axis */
        FrontVec[0] = 1.0f;
        FrontVec[1] = 0.0f;
        FrontVec[2] = 0.0f;
        /* Oriented with up vector along the z axis      */
        UpVec[0] = 0.0f;
        UpVec[1] = 0.0f;
        UpVec[2] = 1.0f;
    }

    /* Set the listener position and orientation:*/
    TDREND_MIX_LIST_SetPos( st_ivas->hBinRendererTd, Pos );
    TDREND_MIX_LIST_SetOrient( st_ivas->hBinRendererTd, FrontVec, UpVec );

    /* For each source, write the frame data to the source object*/
    c_indx = 0;
    for ( nS = 0; nS < st_ivas->nchan_transport; nS++ )
    {
        if ( !( st_ivas->ivas_format == MC_FORMAT && nS == LFE_CHANNEL ) ) /* Skip LFE for MC */
        {
            st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p = output[nS];
            st_ivas->hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE;
            c_indx++;
        }

        if ( st_ivas->ivas_format == ISM_FORMAT )
        {

            /* Update the source positions */
            /* Source position and direction */
            Pos[0] = cosf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 ) * cosf( st_ivas->hIsmMetaData[nS]->azimuth * PI_OVER_180 );
            Pos[1] = cosf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 ) * sinf( st_ivas->hIsmMetaData[nS]->azimuth * PI_OVER_180 );
            Pos[2] = sinf( st_ivas->hIsmMetaData[nS]->elevation * PI_OVER_180 );
            Dir[0] = 1.0f;
            Dir[1] = 0.0f;
            Dir[2] = 0.0f;

            /* Source directivity info */
            DirAtten_p->ConeInnerAngle = 360.0f;
            DirAtten_p->ConeOuterAngle = 360.0f;
            DirAtten_p->ConeOuterGain = 1.0f;

            TDREND_MIX_SRC_SetPos( st_ivas->hBinRendererTd, nS, Pos );
            TDREND_MIX_SRC_SetDir( st_ivas->hBinRendererTd, nS, Dir );
            TDREND_MIX_SRC_SetDirAtten( st_ivas->hBinRendererTd, nS, DirAtten_p );
            TDREND_MIX_SRC_SetPlayState( st_ivas->hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING );
        }
    }
#endif
    if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
    {

#ifdef FIX_I106_TDREND_5MS
        if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) )
        {
            ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
        }
#else
        if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
        {
            if ( st_ivas->ini_frame == 0 )
            {
                ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
            }
            for ( subframe_idx = 0; subframe_idx < 4; subframe_idx++ )
            {
                ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx );
            }
        }
#endif
    }

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

@@ -359,10 +253,6 @@ void ObjRenderIVASFrame(
        /* Render subframe */
        TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, st_ivas->hDecoderConfig->output_Fs, subframe_idx );
    }
#else
    /* Call the renderer */
    TDREND_GetMix( st_ivas->hBinRendererTd, output, output_frame, st_ivas->hDecoderConfig->output_Fs );
#endif

    if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
    {
@@ -378,30 +268,17 @@ void ObjRenderIVASFrame(
}


#ifdef FIX_I106_TDREND_5MS
/*---------------------------------------------------------------------*
 * TDREND_GetMix()
 *
 * Render one 5 ms subframe from the mixer
 *---------------------------------------------------------------------*/
#else
/*---------------------------------------------------------------------*
 * TDREND_GetMix()
 *
 * Render one output frame from the mixer
 *---------------------------------------------------------------------*/
#endif
static ivas_error TDREND_GetMix(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
    float output[][L_FRAME48k],                        /* i/o: ISm object synth / rendered output in 0,1 */
#ifdef FIX_I106_TDREND_5MS
    const int16_t subframe_length, /* i/o: subframe length                       */
    const int32_t output_Fs,       /* i  : Output sampling rate                      */
    const int16_t subframe_idx     /* i  : Subframe index to 5 ms subframe                      */
#else
    const int16_t output_frame,      /* i/o: Output frame length                       */
    const int32_t output_Fs          /* i  : Output sampling rate                      */
#endif
)
{
    int16_t i;
@@ -409,22 +286,12 @@ static ivas_error TDREND_GetMix(
    TDREND_SRC_SPATIAL_t *SrcSpatial_p;
    TDREND_SRC_REND_t *SrcRend_p;
    ivas_error error;
#ifdef FIX_I106_TDREND_5MS
    float output_buf[2][L_SPATIAL_SUBFR_48k]; /* Temp buffer for left/right rendered signal */
#else
    float output_buf[2][L_FRAME48k]; /* Temp buffer for left/right rendered signal */
#endif
    error = IVAS_ERR_OK;

#ifdef FIX_I106_TDREND_5MS
    /* Clear the output buffer to accumulate rendered sources */
    set_f( output_buf[0], 0.0f, subframe_length );
    set_f( output_buf[1], 0.0f, subframe_length );
#else
    /* Zero out the output buffer since objects are accumulated.  */
    set_f( output_buf[0], 0.0f, output_frame );
    set_f( output_buf[1], 0.0f, output_frame );
#endif

    /* Create the mix */
    /* Loop through the source list and render each source */
@@ -443,39 +310,19 @@ static ivas_error TDREND_GetMix(
        /* Render source if needed */
        if ( ( SrcRend_p->InputAvailable == TRUE ) && ( SrcRend_p->PlayStatus == TDREND_PLAYSTATUS_PLAYING ) )
        {
#ifdef FIX_I106_TDREND_5MS
#ifdef TDREND_HRTF_TABLE_METHODS
            error = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, subframe_length, output_Fs );
#else
            error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, subframe_length, output_Fs );
#endif
#else
#ifdef TDREND_HRTF_TABLE_METHODS
            error = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, output_frame, output_Fs );
#else
            error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, output_frame, output_Fs );
#endif
#endif
        }
#ifndef FIX_I106_TDREND_5MS
        SrcRend_p->InputAvailable = FALSE;
#endif
    }

    /* Populate output variable */
#ifdef FIX_I106_TDREND_5MS
    mvr2r( output_buf[0], output[0] + subframe_idx * subframe_length, subframe_length ); /* Left */
    mvr2r( output_buf[1], output[1] + subframe_idx * subframe_length, subframe_length ); /* Right */
#else
    mvr2r( output_buf[0], output[0], output_frame ); /* Left */
    mvr2r( output_buf[1], output[1], output_frame ); /* Right */
#endif

#ifdef FIX_I106_TDREND_5MS
    /* Clear the PoseUpdated and Source position update flags */
#else
                                                     /* Clear the mixer update flags */
#endif
    TDREND_Clear_Update_flags( hBinRendererTd );

    return error;
@@ -504,7 +351,6 @@ static void TDREND_Clear_Update_flags(
    return;
}

#ifdef FIX_I106_TDREND_5MS
/*---------------------------------------------------------------------*
 * TDREND_Update_object_positions()
 *
@@ -620,4 +466,3 @@ static void TDREND_Update_listener_orientation(

    return;
}
#endif
+0 −38
Original line number Diff line number Diff line
@@ -343,42 +343,21 @@ void TDREND_HRFILT_SetFiltSet(
 --------------------------------------------------------------------*/

ivas_error TDREND_REND_RenderSourceHRFilt(
#ifdef FIX_I106_TDREND_5MS
    TDREND_SRC_t *Src_p, /* i/o: The source to be rendered               */
#else
    const TDREND_SRC_t *Src_p,      /* i/o: The source to be rendered  */
#endif
#ifdef TDREND_HRTF_TABLE_METHODS
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle                      */
#endif
#ifdef FIX_I106_TDREND_5MS
    float output_buf[][L_SPATIAL_SUBFR_48k], /* o  : Output buffer              */
    const int16_t subframe_length,           /* i  : Subframe length in use */
#else
    float output_buf[][L_FRAME48k], /* o  : Output buffer              */
    const int16_t output_frame,     /* i  : Output frame length in use */
#endif

    const int32_t output_Fs /* i  : Output sample rate         */
)
{
    TDREND_SRC_REND_t *SrcRend_p;
#ifdef FIX_I106_TDREND_5MS
    const float *InFrame_nIC_p;
#else
    int16_t nS;
    float *InFrame_nIC_p;
#endif
    int16_t NoOfUsedInputSamples, NoOfDeliveredOutputSamples;
#ifdef FIX_I106_TDREND_5MS
    float LeftOutputFrame[L_SPATIAL_SUBFR_48k];
    float RightOutputFrame[L_SPATIAL_SUBFR_48k];
#else
    float LeftOutputFrame[L_FRAME48k];
    float RightOutputFrame[L_FRAME48k];
    float *LeftOutputFrame_p, *RightOutputFrame_p;
    float *LeftAccOutputFrame_p, *RightAccOutputFrame_p;
#endif

    /* Input channel rendering loop */
    InFrame_nIC_p = Src_p->InputFrame_p;
@@ -388,11 +367,7 @@ ivas_error TDREND_REND_RenderSourceHRFilt(
    /* SrcGain = Mix_p->Gain * ( *SrcRend_p->SrcGain_p ); */
    /* SrcGain *= ( *SrcRend_p->DirGain_p ) * ( *SrcRend_p->DistGain_p ); */

#ifdef FIX_I106_TDREND_5MS
    TDREND_SFX_SpatBin_Execute_Main( SrcRend_p->SfxSpatBin_p, InFrame_nIC_p, subframe_length, LeftOutputFrame, RightOutputFrame, &NoOfUsedInputSamples, &NoOfDeliveredOutputSamples, output_Fs );
#else
    TDREND_SFX_SpatBin_Execute_Main( SrcRend_p->SfxSpatBin_p, InFrame_nIC_p, output_frame, LeftOutputFrame, RightOutputFrame, &NoOfUsedInputSamples, &NoOfDeliveredOutputSamples, output_Fs );
#endif

#ifdef TDREND_HRTF_TABLE_METHODS
    if ( hBinRendererTd->HrFiltSet_p->FilterMethod != TDREND_HRFILT_Method_BSplineModel )
@@ -402,24 +377,11 @@ ivas_error TDREND_REND_RenderSourceHRFilt(
#endif

    /* Copy to accumulative output frame */
#ifdef FIX_I106_TDREND_5MS
    v_add( LeftOutputFrame, output_buf[0], output_buf[0], subframe_length );
    v_add( RightOutputFrame, output_buf[1], output_buf[1], subframe_length );

    Src_p->InputFrame_p += subframe_length; /* Increment input pointer -- todo: should we remove this and input the current subframe instead? */

#else
    LeftOutputFrame_p = LeftOutputFrame;
    RightOutputFrame_p = RightOutputFrame;
    LeftAccOutputFrame_p = output_buf[0];
    RightAccOutputFrame_p = output_buf[1];

    for ( nS = 0; nS < output_frame; nS++ )
    {
        *LeftAccOutputFrame_p++ += *LeftOutputFrame_p++;
        *RightAccOutputFrame_p++ += *RightOutputFrame_p++;
    }
#endif


    return IVAS_ERR_OK;
Loading