Commit 5ee66fa9 authored by stoutjesdijk's avatar stoutjesdijk 🎧
Browse files

added writing calls in main()

parent 8059b1f3
Loading
Loading
Loading
Loading
+62 −7
Original line number Diff line number Diff line
@@ -235,15 +235,15 @@ static const CmdLnParser_Option cliOptions[] = {
#ifdef FIX_319_ADD_OTR_EXPORT
    {
        .id = CmdLnOptionId_mainOrientFile,
        .match = "main_orientation_file",
        .matchShort = "mo",
        .description = "Main Orientation output file",
        .match = "main_orientation_output",
        .matchShort = "moo",
        .description = "Main orientation output file",
    },
    {
        .id = CmdLnOptionId_refRotFile,
        .match = "reference_rotation_file",
        .matchShort = "rr",
        .description = "Reference rotation output file",
        .id = CmdLnOptionId_trkRotFile,
        .match = "tracked_rotation_output",
        .matchShort = "tro",
        .description = "Tracked rotation output file",
    },
#endif
    {
@@ -585,6 +585,10 @@ int main(
    convert_backslash( args.inputFilePath );
    convert_backslash( args.outputFilePath );
    convert_backslash( args.headRotationFilePath );
#ifdef FIX_319_ADD_OTR_EXPORT
    convert_backslash( args.mainOrientationFilePath );
    convert_backslash( args.trkRotationFilePath );
#endif
    convert_backslash( args.referenceVectorFilePath );
    convert_backslash( args.referenceRotationFilePath );
    convert_backslash( args.inLfePanningMatrixFile );
@@ -598,6 +602,25 @@ int main(
        }
    }

#ifdef FIX_319_ADD_OTR_EXPORT
    if ( !isEmptyString( args.mainOrientationFilePath ) )
    {
        if ( HeadRotationFileWriter_open( args.mainOrientationFilePath, &mainOrientWriter ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error opening file: %s\n", args.mainOrientationFilePath );
            exit( -1 );
        }
    }
    if ( !isEmptyString( args.trkRotationFilePath ) )
    {
        if ( HeadRotationFileWriter_open( args.trkRotationFilePath, &trkRotWriter ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error opening file: %s\n", args.trkRotationFilePath );
            exit( -1 );
        }
    }
#endif

    if ( !isEmptyString( args.referenceRotationFilePath ) )
    {
        if ( HeadRotationFileReader_open( args.referenceRotationFilePath, &referenceRotReader ) != IVAS_ERR_OK )
@@ -1001,6 +1024,38 @@ int main(
            }
        }

#ifdef FIX_319_ADD_OTR_EXPORT
        /* Write to main rotation trajectory file if specified */
        if ( mainOrientWriter != NULL )
        {
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
            IVAS_REND_GetMainOrientation(hIvasRend, quatBuffer);

            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
                if ( ( error = HeadRotationFileWriting( mainOrientWriter, quatBuffer) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in Main Orientation File Writing: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
        }
        if ( trkRotWriter != NULL )
        {
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
            IVAS_REND_GetTrackedRotation(hIvasRend, quatBuffer);

            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
                if ( ( error = HeadRotationFileWriting( trkRotWriter, quatBuffer) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in Tracked Rotation File Writing: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
        }
#endif

        for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i )
        {
            if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, mcIds[i], &numChannels ) ) != IVAS_ERR_OK )
+3 −10
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ ivas_error HeadRotationFileWriter_open(
        return IVAS_ERR_FAILED_FILE_OPEN;
    }

    trajFile = fopen( trajFilePath, "r" );
    trajFile = fopen( trajFilePath, "w" );

    if ( !trajFile )
    {
@@ -93,8 +93,7 @@ ivas_error HeadRotationFileWriter_open(

ivas_error HeadRotationFileWriting(
    HeadRotFileWriter *headRotWriter, /* i/o: HeadRotFileReader handle       */
    IVAS_QUATERNION *pQuaternion,     /* o  : head-tracking data             */
    IVAS_POSITION *pPos               /* o  : listener position              */
    IVAS_QUATERNION *pQuaternion      /* i  : head-tracking data             */
)
{
    float w, x, y, z;
@@ -112,7 +111,7 @@ ivas_error HeadRotationFileWriting(
        {
            rewind( headRotWriter->trajFile );
            headRotWriter->fileRewind = true;
            return HeadRotationFileWriting( headRotWriter, pQuaternion, pPos );
            return HeadRotationFileWriting( headRotWriter, pQuaternion );
        }
        return IVAS_ERR_FAILED_FILE_PARSE;
    }
@@ -123,12 +122,6 @@ ivas_error HeadRotationFileWriting(
    pQuaternion->x = x;
    pQuaternion->y = y;
    pQuaternion->z = z;
    if ( pPos != NULL )
    {
        pPos->x = posx;
        pPos->y = posy;
        pPos->z = posz;
    }

    return IVAS_ERR_OK;
}
+1 −2
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ ivas_error HeadRotationFileWriter_open(

ivas_error HeadRotationFileWriting(
    HeadRotFileWriter *headRotWriter, /* i/o: HeadRotFileReader handle       */
    IVAS_QUATERNION *pQuaternion,     /* o  : head-tracking data             */
    IVAS_POSITION *pPos               /* o  : listener position              */
    IVAS_QUATERNION *pQuaternion      /* i  : head-tracking data             */
);

/*-----------------------------------------------------------------------*