Commit 6e1fe92f authored by sagnowski's avatar sagnowski
Browse files

[tmp] Revert "Remove RENDERER_HEAD_POSITIONS_PER_FRAME - code compiles, but untested"

This reverts commit 7fb10d40.
parent 7fb10d40
Loading
Loading
Loading
Loading
+27 −143
Original line number Diff line number Diff line
@@ -157,9 +157,6 @@ typedef struct
    float lfeConfigElevation;
    bool lfeCustomRoutingEnabled;
    char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH];
#ifdef LIB_REND_API_5MS
    bool framing_5ms;
#endif
} CmdlnArgs;

typedef enum
@@ -184,9 +181,6 @@ typedef enum
    CmdLnOptionId_inputGain,
    CmdLnOptionId_referenceVectorFile,
    CmdLnOptionId_exteriorOrientationFile,
#ifdef LIB_REND_API_5MS
    CmdLnOptionId_framing5ms,
#endif
} CmdLnOptionId;

static const CmdLnParser_Option cliOptions[] = {
@@ -308,14 +302,6 @@ static const CmdLnParser_Option cliOptions[] = {
        .matchShort = "exof",
        .description = "External orientation trajectory file for simulation of external orientations",
    },
#ifdef LIB_REND_API_5MS
    {
        .id = CmdLnOptionId_framing5ms,
        .match = "framing_5ms",
        .matchShort = "fr5",
        .description = "Process audio with 5 ms framing. Time resolution of metadata (e.g. ISM positions) remains unchanged w.r.t. 20 ms framing",
    },
#endif
};


@@ -574,9 +560,7 @@ int main(
    int32_t delayTimeScale = 0;
    int16_t i, numChannels;
    ivas_error error = IVAS_ERR_OK;
#ifndef LIB_REND_API_5MS
    IVAS_VECTOR3 Pos[RENDERER_HEAD_POSITIONS_PER_FRAME];
#endif

#ifdef WMOPS
    reset_wmops();
@@ -749,13 +733,7 @@ int main(
        fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }
    const int16_t frameSize_smpls = (int16_t) (
#ifdef LIB_REND_API_5MS
        ( args.framing_5ms ? 5 : 20 )
#else
        20
#endif
        * args.sampleRate / 1000 );
    const int16_t frameSize_smpls = (int16_t) ( 20 * args.sampleRate / 1000 );

    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 };
    IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS] = { 0 };
@@ -1041,17 +1019,10 @@ int main(
        fprintf( stdout, "\n\n-- Start the renderer (quiet mode) --\n\n" );
    }

#ifdef LIB_REND_API_5MS
    ObjectPositionBuffer mtdBuffer;
#endif

    while ( 1 )
    {
        int16_t num_in_channels;
        num_in_channels = inBuffer.config.numChannels;
#ifdef LIB_REND_API_5MS
        const bool isCurrentFrameMultipleOf20ms = !args.framing_5ms || frame % 4 == 0;
#endif

        /* Read the input data */
        if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK )
@@ -1069,12 +1040,8 @@ int main(
        /* Convert from int to float and from interleaved to packed */
        convertInputBuffer( inpInt16Buffer, numSamplesRead, frameSize_smpls, num_in_channels, inFloatBuffer );

#ifdef LIB_REND_API_5MS
        if ( isCurrentFrameMultipleOf20ms )
        {
#else

        ObjectPositionBuffer mtdBuffer;
#endif
        IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer );

        if ( referenceVectorReader != NULL )
@@ -1107,41 +1074,10 @@ int main(
                exit( -1 );
            }
        }
#ifdef LIB_REND_API_5MS
        }
#endif

        /* Read from head rotation trajectory file if specified */
        if ( headRotReader != NULL )
        {
#ifdef LIB_REND_API_5MS
            IVAS_QUATERNION headRot;
            IVAS_VECTOR3 Pos;

            if ( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
            if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

            if ( !args.framing_5ms )
            {
                /* Skip over 3 following head positions - they are given on 5ms grid */
                for ( int16_t i = 0; i < 3; ++i )
                {
                    if ( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    }
                }
            }
#else
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];

            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
@@ -1157,61 +1093,20 @@ int main(
                fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }
        else
        {
#ifdef LIB_REND_API_5MS
            if ( ( error = IVAS_REND_DisableHeadRotation( hIvasRend ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error disabling head rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#else
            error = IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL );
            if ( error != IVAS_ERR_OK && error != IVAS_ERR_INVALID_OUTPUT_FORMAT )
            {
                fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }

        /* Read from external orientation file if specified */
        if ( externalOrientationFileReader != NULL )
        {
#ifdef LIB_REND_API_5MS
            IVAS_QUATERNION quat;
            int8_t enableHeadRotation;
            int8_t enableExternalOrientation;
            int8_t enableRotationInterpolation;
            int16_t numFramesToTargetOrientation;

            if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quat, &enableHeadRotation, &enableExternalOrientation, &enableRotationInterpolation, &numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in External Orientation File Reading: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

            if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quat, enableHeadRotation, enableExternalOrientation, enableRotationInterpolation, numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

            if ( !args.framing_5ms )
            {
                /* Skip over 3 following entries in file - they are given on 5ms grid */
                for ( int16_t i = 0; i < 3; ++i )
                {
                    if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quat, &enableHeadRotation, &enableExternalOrientation, &enableRotationInterpolation, &numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "Error in External Orientation File Reading: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    }
                }
            }
#else
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
            int8_t enableHeadRotation[RENDERER_HEAD_POSITIONS_PER_FRAME];
            int8_t enableExternalOrientation[RENDERER_HEAD_POSITIONS_PER_FRAME];
@@ -1232,7 +1127,6 @@ int main(
                fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }

        /* Combine external orientations and head rotation */
@@ -1387,7 +1281,6 @@ int main(
            delayNumSamples -= (int16_t) outBufferSize;
        }

        /* TODO(sgi): Masa output most likely broken with 5ms framing */
        /* Write MASA metadata for MASA outputs */
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
        {
@@ -2007,9 +1900,6 @@ static CmdlnArgs defaultArgs(

    args.lfeCustomRoutingEnabled = false;
    clearString( args.inLfePanningMatrixFile );
#ifdef LIB_REND_API_5MS
    args.framing_5ms = false;
#endif
    return args;
}

@@ -2139,12 +2029,6 @@ static void parseOption(
                exit( -1 );
            }
            break;
#ifdef LIB_REND_API_5MS
        case CmdLnOptionId_framing5ms:
            assert( numOptionValues == 0 );
            args->framing_5ms = false;
            break;
#endif
        default:
            assert( 0 && "This should be unreachable - all command line options should be explicitly handled." );
            break;
+0 −2
Original line number Diff line number Diff line
@@ -50,9 +50,7 @@
#define IVAS_CLDFB_NO_CHANNELS_MAX  ( 60 )
#define IVAS_MAX_INPUT_LFE_CHANNELS 4

#ifndef LIB_REND_API_5MS
#define RENDERER_HEAD_POSITIONS_PER_FRAME 4
#endif


/*----------------------------------------------------------------------------------*
+0 −1
Original line number Diff line number Diff line
@@ -157,7 +157,6 @@
#define FIX_XXX_JITTER_SBA_BINAURAL_GAIN
#define FIX_XXX_HEADTRACKER_INIT
#define API_5MS
#define LIB_REND_API_5MS                            /* FhG: Adds 5ms framing capability to lib_rend */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+0 −4
Original line number Diff line number Diff line
@@ -857,11 +857,7 @@ ivas_error combine_external_and_head_orientations_rend(
);

ivas_error combine_external_and_head_orientations(
#ifdef LIB_REND_API_5MS
    IVAS_QUATERNION *headRotQuaternion,                                           /* i  : quaternion for head rotation                             */
#else
    IVAS_QUATERNION *headRotQuaternions,                                          /* i  : quaternions for head rotation                            */
#endif
    IVAS_VECTOR3 *listenerPos,                                                    /* i  : listener position                                        */
#ifndef API_5MS
    int16_t numHeadRotQuaternions, /* i  : number of head rotation quaternions                      */
+0 −69
Original line number Diff line number Diff line
@@ -902,11 +902,7 @@ ivas_error combine_external_and_head_orientations_dec(
#endif
    }
#ifdef API_5MS
#ifdef LIB_REND_API_5MS
    return combine_external_and_head_orientations( headRotQuaternions, listenerPos, hExtOrientationData, hCombinedOrientationData );
#else
    return combine_external_and_head_orientations( headRotQuaternions, listenerPos, hExtOrientationData, hCombinedOrientationData );
#endif
#else
    return combine_external_and_head_orientations( headRotQuaternions, listenerPos, numHeadRotQuaternions, hExtOrientationData, hCombinedOrientationData );
#endif
@@ -936,13 +932,8 @@ ivas_error combine_external_and_head_orientations_rend(
    {
        if ( hHeadTrackData->headRotEnabled )
        {
#ifdef LIB_REND_API_5MS
            headRotQuaternions = &hHeadTrackData->headPosition;
            listenerPos = &hHeadTrackData->Pos;
#else
            headRotQuaternions = hHeadTrackData->headPositions;
            listenerPos = hHeadTrackData->Pos;
#endif
        }
    }
    else if ( hExtOrientationData != NULL )
@@ -980,11 +971,7 @@ ivas_error combine_external_and_head_orientations_rend(
 *------------------------------------------------------------------------*/

ivas_error combine_external_and_head_orientations(
#ifdef LIB_REND_API_5MS
    IVAS_QUATERNION *headRotQuaternion,  /* i  : quaternion for head rotation                             */
#else
    IVAS_QUATERNION *headRotQuaternions, /* i  : quaternions for head rotation                            */
#endif
    IVAS_VECTOR3 *listenerPos,           /* i  : listener position                                        */
#ifndef API_5MS
    int16_t numHeadRotQuaternions, /* i  : number of head rotation quaternions                      */
@@ -1007,11 +994,7 @@ ivas_error combine_external_and_head_orientations(
    /* Form combined orientations or return if no data available */
    if ( hCombinedOrientationData == NULL )
    {
#ifdef LIB_REND_API_5MS
        if ( headRotQuaternion != NULL || hExtOrientationData != NULL )
#else
        if ( headRotQuaternions != NULL || hExtOrientationData != NULL )
#endif
        {
            return IVAS_ERR_UNEXPECTED_NULL_POINTER;
        }
@@ -1020,11 +1003,7 @@ ivas_error combine_external_and_head_orientations(
            return IVAS_ERR_OK;
        }
    }
#ifdef LIB_REND_API_5MS
    else if ( headRotQuaternion == NULL && hExtOrientationData == NULL )
#else
    else if ( headRotQuaternions == NULL && hExtOrientationData == NULL )
#endif
    {
        /* Reset the combined orientations and rotations */
        hCombinedOrientationData->isInterpolationOngoing = FALSE;
@@ -1058,19 +1037,11 @@ ivas_error combine_external_and_head_orientations(
        }
#endif
    }
#ifdef LIB_REND_API_5MS
    else if ( hExtOrientationData == NULL && headRotQuaternion != NULL )
#else
    else if ( hExtOrientationData == NULL && headRotQuaternions != NULL )
#endif
    {
        /* Head rotation only */
#ifdef API_5MS
#ifdef LIB_REND_API_5MS
        hCombinedOrientationData->Quaternion = *headRotQuaternion;
#else
        hCombinedOrientationData->Quaternion = *headRotQuaternions;
#endif

#else
        if ( numHeadRotQuaternions >= 0 )
@@ -1159,11 +1130,7 @@ ivas_error combine_external_and_head_orientations(
#endif
    }

#ifdef LIB_REND_API_5MS
    if ( hExtOrientationData != NULL && headRotQuaternion != NULL )
#else
    if ( hExtOrientationData != NULL && headRotQuaternions != NULL )
#endif
    {
        /* Combine head and external orientations */
#ifdef API_5MS
@@ -1173,19 +1140,11 @@ ivas_error combine_external_and_head_orientations(
        {
            if ( hExtOrientationData->enableExternalOrientation > 0 )
            {
#ifdef LIB_REND_API_5MS
                QuaternionProduct( hCombinedOrientationData->Quaternion, *headRotQuaternion, &hCombinedOrientationData->Quaternion );
#else
                QuaternionProduct( hCombinedOrientationData->Quaternion, *headRotQuaternions, &hCombinedOrientationData->Quaternion );
#endif
            }
            else
            {
#ifdef LIB_REND_API_5MS
                hCombinedOrientationData->Quaternion = *headRotQuaternion;
#else
                hCombinedOrientationData->Quaternion = *headRotQuaternions;
#endif
            }
        }
        /* Use the freezed head rotation */
@@ -1244,11 +1203,7 @@ ivas_error combine_external_and_head_orientations(
#endif
    }

#ifdef LIB_REND_API_5MS
    if ( headRotQuaternion != NULL || hExtOrientationData != NULL )
#else
    if ( headRotQuaternions != NULL || hExtOrientationData != NULL )
#endif
    {
        /* Calculate the combined rotation matrix */
#ifdef API_5MS
@@ -1288,22 +1243,14 @@ ivas_error combine_external_and_head_orientations(
        }
#endif
    }
#ifdef LIB_REND_API_5MS
    if ( headRotQuaternion != NULL )
#else
    if ( headRotQuaternions != NULL )
#endif
    {
#ifdef API_5MS
        if ( hExtOrientationData != NULL )
        {
            if ( hExtOrientationData->enableHeadRotation > 0 )
            {
#ifdef LIB_REND_API_5MS
                hCombinedOrientationData->Quaternion_prev_headRot = *headRotQuaternion;
#else
                hCombinedOrientationData->Quaternion_prev_headRot = *headRotQuaternions;
#endif
            }
            else
            {
@@ -1312,11 +1259,7 @@ ivas_error combine_external_and_head_orientations(
        }
        else
        {
#ifdef LIB_REND_API_5MS
            hCombinedOrientationData->Quaternion_prev_headRot = *headRotQuaternion;
#else
            hCombinedOrientationData->Quaternion_prev_headRot = *headRotQuaternions;
#endif
        }
        hCombinedOrientationData->listenerPos = *listenerPos;

@@ -1351,11 +1294,7 @@ ivas_error combine_external_and_head_orientations(
    }

    /* Check if combined orientation is enabled */
#ifdef LIB_REND_API_5MS
    if ( headRotQuaternion != NULL && hExtOrientationData == NULL )
#else
    if ( headRotQuaternions != NULL && hExtOrientationData == NULL )
#endif
    {
#ifdef API_5MS
        hCombinedOrientationData->enableCombinedOrientation = 1;
@@ -1374,11 +1313,7 @@ ivas_error combine_external_and_head_orientations(
        }
#endif
    }
#ifdef LIB_REND_API_5MS
    else if ( headRotQuaternion == NULL && hExtOrientationData != NULL )
#else
    else if ( headRotQuaternions == NULL && hExtOrientationData != NULL )
#endif
    {
#ifdef API_5MS
        if ( hExtOrientationData->enableExternalOrientation > 0 )
@@ -1403,11 +1338,7 @@ ivas_error combine_external_and_head_orientations(
        }
#endif
    }
#ifdef LIB_REND_API_5MS
    else if ( headRotQuaternion != NULL && hExtOrientationData != NULL )
#else
    else if ( headRotQuaternions != NULL && hExtOrientationData != NULL )
#endif
    {
#ifdef API_5MS
        if ( hExtOrientationData->enableExternalOrientation > 0 || hExtOrientationData->enableHeadRotation > 0 )
Loading