Commit b120d00a authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Merge branch '109-harmonize-head-and-orientation-tracking-xcheck' into...

Merge branch '109-harmonize-head-and-orientation-tracking-xcheck' into 109-harmonize-head-and-orientation-tracking-xcheck-call-order
parents f30e323c 718f59c9
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -165,9 +165,10 @@

#define BINAURALIZATION_DELAY_REPORT                    /* VA: Issue 255 - Changes the way the decoder delay is reported */
#define FIX_351_HRTF_COMMAND                            /* VA: Issue 354 - improve "-hrtf" command-line option */

#define FIX_94_VERIFY_WAV_NUM_CHANNELS                  /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */
#define ISM_HIGHEST_BITRATE                             /* VA: Issue 284: Update highest bitrate limit in ISM format */
#define TUNE_360_OBJECT_WITH_NOISE                      /* VA: issue 360: consider objects being speech+noise for active speech coding */


#ifdef FIX_I109_ORIENTATION_TRACKING
#define OTR_REFERENCE_VECTOR_TRACKING                 /* FhG: enables the reference position orientation tracking mode */
+10 −0
Original line number Diff line number Diff line
@@ -906,7 +906,11 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
    HEAD_TRACK_DATA_HANDLE hHeadTrackData;
    int16_t i;

#ifdef FIX_I109_ORIENTATION_TRACKING
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || orientation == NULL )
#else
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
#endif
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
@@ -922,6 +926,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
    for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
    {
#ifdef FIX_I109_ORIENTATION_TRACKING
        /* check for Euler angle signaling */
        if ( orientation[i].w == -3.0f )
        {
            Euler2Quat( deg2rad( orientation[i].x ), deg2rad( orientation[i].y ), deg2rad( orientation[i].z ), &orientation[i] );
        }

        ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation[i], FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[i] );
#else
        hHeadTrackData->Quaternions[i].w = orientation[i].w;
+6 −1
Original line number Diff line number Diff line
@@ -210,6 +210,9 @@ ivas_error ivas_ism_metadata_enc(
        }
        else if ( ism_mode == ISM_MODE_DISC )
        {
#ifdef TUNE_360_OBJECT_WITH_NOISE
            hIsmMeta[ch]->ism_metadata_flag = localVAD[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10;
#else
            hIsmMeta[ch]->ism_metadata_flag = localVAD[ch];

            if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
@@ -223,6 +226,7 @@ ivas_error ivas_ism_metadata_enc(
                    hIsmMeta[ch]->ism_metadata_flag = 1;
                }
            }
#endif

            if ( hSCE[ch]->hCoreCoder[0]->tcxonly )
            {
@@ -238,6 +242,7 @@ ivas_error ivas_ism_metadata_enc(

    rate_ism_importance( nchan_transport, hIsmMeta, hSCE, ism_imp );

#ifndef TUNE_360_OBJECT_WITH_NOISE
    /* relax the importance decision in "stereo" coding for noisy audio */
    if ( ism_mode == ISM_MODE_DISC && num_obj == 2 )
    {
@@ -257,7 +262,7 @@ ivas_error ivas_ism_metadata_enc(
            }
        }
    }

#endif
    /*----------------------------------------------------------------*
     * Write ISm common signaling
     *----------------------------------------------------------------*/
+13 −40
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ void VectorRotationToQuaternion(
        r->x = cross_product.x;
        r->y = cross_product.y;
        r->z = cross_product.z;
        r->w = 1.0 + dot_product;
        r->w = 1.0f + dot_product;
    }
    QuaternionNormalize( *r, r );
}
@@ -665,57 +665,45 @@ ivas_error ivas_orient_trk_Process(
    float alpha = pOTR->alpha;
    float ang;
    ivas_error result;
    IVAS_QUATERNION absQuat, trkQuat;
    IVAS_QUATERNION trkEuler;

    if ( pOTR == NULL || pTrkRot == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    /* check for Euler angle signaling */
    if ( absRot.w == -3.0f )
    {
        Euler2Quat( deg2rad( absRot.x ), deg2rad( absRot.y ), deg2rad( absRot.z ), &absQuat );
    }
    else
    {
        absQuat = absRot;
    }

    result = IVAS_ERR_OK;

    switch ( pOTR->trackingType )
    {
        case OTR_TRACKING_NONE:
            trkQuat = absQuat;
            pOTR->trkRot = absRot;
            break;

        case OTR_TRACKING_REF_ORIENT:
            /* Reset average orientation   */
            pOTR->absAvgRot = absQuat;
            pOTR->absAvgRot = absRot;

            /* Reset adaptation filter - start adaptation at center rate */
            pOTR->alpha = sinf( 2.0f * EVS_PI * pOTR->centerAdaptationRate / updateRate );

            /* Compute relative orientation = (absolute orientation) - (reference orientation) */
            QuaternionInverse( pOTR->refRot, &trkQuat );
            QuaternionProduct( trkQuat, absQuat, &trkQuat );
            QuaternionInverse( pOTR->refRot, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absRot, &pOTR->trkRot );
            break;

        case OTR_TRACKING_AVG_ORIENT:
            /* Compute average (low-pass filtered) absolute orientation */
            QuaternionSlerp( pOTR->absAvgRot, absQuat, alpha, &pOTR->absAvgRot );
            QuaternionSlerp( pOTR->absAvgRot, absRot, alpha, &pOTR->absAvgRot );

            /* Compute relative orientation = (absolute orientation) - (average absolute orientation) */
            QuaternionInverse( pOTR->absAvgRot, &trkQuat );
            QuaternionProduct( trkQuat, absQuat, &trkQuat );
            QuaternionInverse( pOTR->absAvgRot, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absRot, &pOTR->trkRot );

            /* Adapt LPF constant based on orientation excursion relative to current mean:
            - low  cutoff (slow adaptation) for small excursions (around center)
            - high cutoff (fast adaptation) for large excursions (off-center)
            */
            ang = QuaternionAngle( absQuat, trkQuat );
            ang = QuaternionAngle( absRot, pOTR->trkRot );
            normalizedOrientation = ang * ang;

            relativeOrientationRate = sqrtf( normalizedOrientation ) / pOTR->adaptationAngle;
@@ -744,7 +732,7 @@ ivas_error ivas_orient_trk_Process(
        case OTR_TRACKING_REF_VEC_LEV:
        {
            /* This processing step of the OTR_TRACKING_REF_VEC/OTR_TRACKING_REF_VEC_LEVEL is identical */
            QuaternionProduct( pOTR->refRot, absQuat, &trkQuat );
            QuaternionProduct( pOTR->refRot, absRot, &pOTR->trkRot );
            break;
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
@@ -755,23 +743,8 @@ ivas_error ivas_orient_trk_Process(

    if ( result == IVAS_ERR_OK )
    {
        pOTR->trkRot = trkQuat;

        if ( absRot.w == -3.0f )
        {
            Quat2Euler( trkQuat, &trkEuler.z, &trkEuler.y, &trkEuler.x );
            trkEuler.x = rad2deg( trkEuler.x );
            trkEuler.y = rad2deg( trkEuler.y );
            trkEuler.z = rad2deg( trkEuler.z );
            trkEuler.w = -3.0f;
            *pTrkRot = trkEuler;
        *pTrkRot = pOTR->trkRot;
    }
        else
        {
            *pTrkRot = trkQuat;
        }
    }

    return result;
}
#else
+8 −10
Original line number Diff line number Diff line
@@ -799,16 +799,7 @@ ivas_error ivas_headTrack_open(
void ivas_headTrack_close(
    HEAD_TRACK_DATA_HANDLE *hHeadTrackData                      /* i/o: head track handle                                       */
);
#endif

void Quat2Euler(
    const IVAS_QUATERNION quat,                                 /* i  : quaternion describing the rotation  */
    float *yaw,                                                 /* o  : yaw   (z)                           */
    float *pitch,                                               /* o  : pitch (y)                           */
    float *roll                                                 /* o  : roll  (x)                           */
);

#ifdef FIX_I109_ORIENTATION_TRACKING
void Euler2Quat(
    const float roll,                                           /* i  : roll  (x)                           */
    const float pitch,                                          /* i  : pitch (y)                           */
@@ -818,9 +809,16 @@ void Euler2Quat(

float deg2rad( float degrees );

float rad2deg( float radians );
#else
void Quat2Euler(
    const IVAS_QUATERNION quat,                                 /* i  : quaternion describing the rotation  */
    float *yaw,                                                 /* o  : yaw   (z)                           */
    float *pitch,                                               /* o  : pitch (y)                           */
    float *roll                                                 /* o  : roll  (x)                           */
);
#endif


void QuatToRotMat(
    const IVAS_QUATERNION quat,                                 /* i  : quaternion describing the rotation              */
    float Rmat[3][3]                                            /* o  : real-space rotation matrix for this rotation    */
Loading