Commit 71da9eaa authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_orient_trk_fxd_conv_4' into 'main'

Few functions in ivas_orient_trk.c converted to fixed point

See merge request !120
parents 35d129c0 27b07d3b
Loading
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -1512,7 +1512,27 @@ ivas_error IVAS_DEC_FeedRefVectorData(

    hIvasDec->updateOrientation = true;

#ifdef IVAS_FLOAT_FIXED
    ivas_orient_trk_state_t_fx *pOTR_fx = malloc(sizeof(ivas_orient_trk_state_t_fx));
    IVAS_VECTOR3_FX listenerPos_fx, refPos_fx;
    listenerPos_fx.x_qfact = listenerPos_fx.y_qfact = listenerPos_fx.z_qfact = Q27;
    refPos_fx.x_qfact = refPos_fx.y_qfact = refPos_fx.z_qfact = Q27;
    listenerPos_fx.x_fx = float_to_fix( listenerPos.x, listenerPos_fx.x_qfact );
    listenerPos_fx.y_fx = float_to_fix( listenerPos.y, listenerPos_fx.y_qfact );
    listenerPos_fx.z_fx = float_to_fix( listenerPos.z, listenerPos_fx.z_qfact );
    refPos_fx.x_fx = float_to_fix( refPos.x, refPos_fx.x_qfact );
    refPos_fx.y_fx = float_to_fix( refPos.y, refPos_fx.y_qfact );
    refPos_fx.z_fx = float_to_fix( refPos.z, refPos_fx.z_qfact );
    pOTR_fx->orientation_tracking_fx = pOtr->orientation_tracking;
    ivas_orient_trk_SetReferenceVector_fx( pOTR_fx, listenerPos_fx, refPos_fx );
    pOtr->refRot.w = me2f( pOTR_fx->refRot_fx.w_fx, 31- pOTR_fx->refRot_fx.w_qfact );
    pOtr->refRot.x = me2f( pOTR_fx->refRot_fx.x_fx, 31 -pOTR_fx->refRot_fx.x_qfact );
    pOtr->refRot.y = me2f( pOTR_fx->refRot_fx.y_fx, 31- pOTR_fx->refRot_fx.y_qfact );
    pOtr->refRot.z = me2f( pOTR_fx->refRot_fx.z_fx, 31 -pOTR_fx->refRot_fx.z_qfact );
    free(pOTR_fx);
#else
    return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos );
#endif
}


@@ -1546,8 +1566,27 @@ ivas_error IVAS_DEC_FeedExternalOrientationData(
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

#ifdef IVAS_FLOAT_FIXED
    IVAS_QUATERNION_FX orientation_fx = { 0 };
    orientation_fx.w_qfact = orientation_fx.x_qfact = orientation_fx.y_qfact = orientation_fx.z_qfact = Q29;
    orientation_fx.w_fx = float_to_fix(orientation.w, orientation_fx.w_qfact);
    orientation_fx.x_fx = float_to_fix(orientation.x, orientation_fx.x_qfact);
    orientation_fx.y_fx = float_to_fix(orientation.y, orientation_fx.y_qfact);
    orientation_fx.z_fx = float_to_fix(orientation.z, orientation_fx.z_qfact);
    /* Move external orientation data to the decoder handle (invert orientations) */
    QuaternionInverse_fx(orientation_fx, &hExternalOrientationData->Quaternions_fx[subframe_idx]);
    hExternalOrientationData->Quaternions[subframe_idx].w = me2f(hExternalOrientationData->Quaternions_fx[subframe_idx].w_fx,
      31 - hExternalOrientationData->Quaternions_fx[subframe_idx].w_qfact);
    hExternalOrientationData->Quaternions[subframe_idx].x = me2f(hExternalOrientationData->Quaternions_fx[subframe_idx].x_fx,
      31 - hExternalOrientationData->Quaternions_fx[subframe_idx].x_qfact);
    hExternalOrientationData->Quaternions[subframe_idx].y = me2f(hExternalOrientationData->Quaternions_fx[subframe_idx].y_fx,
      31 - hExternalOrientationData->Quaternions_fx[subframe_idx].y_qfact);
    hExternalOrientationData->Quaternions[subframe_idx].z = me2f(hExternalOrientationData->Quaternions_fx[subframe_idx].z_fx,
      31 - hExternalOrientationData->Quaternions_fx[subframe_idx].z_qfact);
#else
    /* Move external orientation data to the decoder handle (invert orientations) */
    QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] );
#endif

    hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation;
    hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation;
+378 −210

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -1763,6 +1763,12 @@ void QuaternionSlerp(
    IVAS_QUATERNION *const r
);

#ifdef IVAS_FLOAT_FIXED
void QuaternionInverse_fx(
  const IVAS_QUATERNION_FX q,
  IVAS_QUATERNION_FX *const r
);
#endif

/*----------------------------------------------------------------------------------*
 * Orientation tracking
@@ -1807,6 +1813,12 @@ ivas_error ivas_orient_trk_Process(

#ifdef IVAS_FLOAT_FIXED

ivas_error ivas_orient_trk_SetReferenceVector_fx(
  ivas_orient_trk_state_t_fx *pOTR,                              /* i/o: orientation tracker handle              */
  const IVAS_VECTOR3_FX listenerPos,                             /* i  : Listener position                       */
  const IVAS_VECTOR3_FX refPos                                   /* i  : Reference position                      */
);

ivas_error ivas_orient_trk_SetTrackingType_fx(
  ivas_orient_trk_state_t_fx *pOTR,                              /* i/o: orientation tracker handle              */
  const IVAS_HEAD_ORIENT_TRK_T orientation_tracking           /* i  : orientation tracking type               */