Commit 8b6b26e8 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

enable 20 ms rendering as default with head tracking, 5ms framing as an...

enable 20 ms rendering as default with head tracking, 5ms framing as an optional arg. Code compiles but untested
parent d72c4419
Loading
Loading
Loading
Loading
+94 −73
Original line number Diff line number Diff line
@@ -487,16 +487,24 @@ int main(
/*------------------------------------------------------------------------------------------*
 * Configure the decoder
 *------------------------------------------------------------------------------------------*/
#ifndef API_5MS
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED || arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM )
    {
        arg.enableHeadRotation = true;
#ifdef API_5MS_BASELINE
        arg.enable5ms = renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || renderConfig.split_rend_config.dof == 0;
#endif
        if ( arg.enable5ms &&
             ( renderConfigSplit.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ||
               renderConfigSplit.split_rend_config.dof == 0 ) )
        {
            /*TODO : needs to be refined as this wont work with LCLD codec*/
            arg.enable5ms = true;
        }
        else
        {
            arg.enable5ms = false;
        }
#endif
    }
#endif

#ifdef API_5MS
@@ -1304,9 +1312,6 @@ static bool parseCmdlIVAS_dec(
        else if ( strcmp( argv_to_upper, "-T" ) == 0 )
        {
            arg->enableHeadRotation = true;
#ifdef API_5MS_BASELINE
            arg->enable5ms = true;
#endif
            i++;

            if ( argc - i <= 4 || argv[i][0] == '-' )
@@ -1319,6 +1324,13 @@ static bool parseCmdlIVAS_dec(
            arg->headrotTrajFileName = argv[i];
            i++;
        }
#ifdef API_5MS_BASELINE
        else if ( strcmp( argv_to_upper, "-fr5" ) == 0 )
        {
            arg->enable5ms = true;
            i++;
        }
#endif
        else if ( strcmp( argv_to_upper, "-OTR" ) == 0 )
        {

@@ -1387,9 +1399,6 @@ static bool parseCmdlIVAS_dec(
        else if ( strcmp( argv_to_upper, "-EXOF" ) == 0 )
        {
            arg->enableExternalOrientation = true;
#ifdef API_5MS_BASELINE
            arg->enable5ms = true;
#endif
            i++;

            if ( argc - i <= 4 || argv[i][0] == '-' )
@@ -1586,6 +1595,13 @@ static bool parseCmdlIVAS_dec(
        return false;
    }

#ifdef API_5MS_BASELINE
    if ( ( !arg->enableHeadRotation ) && ( !arg->enableExternalOrientation ) )
    {
        arg->enable5ms = false;
    }
#endif

    return true;
}

@@ -2059,7 +2075,7 @@ static ivas_error decodeG192(
#endif
#endif
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    IVAS_VECTOR3 Pos = { 0, 0, 0 };
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
    int16_t vec_pos_update, vec_pos_len;

#ifdef SPLIT_REND_WITH_HEAD_ROT
@@ -2188,40 +2204,55 @@ static ivas_error decodeG192(
                goto cleanup;
            }
        }
#ifdef API_5MS
        int16_t enable5ms, num_subframes;
        IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms );
        arg.enable5ms = enable5ms;
        num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#else
        num_subframes = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#endif

        /* Head-tracking input simulation */
        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
            IVAS_QUATERNION Quaternion;
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( headRotReader == NULL )
            {
                Quaternion.w = -3.0f;
                Quaternion.x = 0.0f;
                Quaternion.y = 0.0f;
                Quaternion.z = 0.0f;

#ifdef API_5MS
                Pos.x = 0.0f;
                Pos.y = 0.0f;
                Pos.z = 0.0f;
#endif
                for ( i = 0; i < num_subframes; i++ )
                {
                    Quaternions[i].w = -3.0f;
                    Quaternions[i].x = 0.0f;
                    Quaternions[i].y = 0.0f;
                    Quaternions[i].z = 0.0f;
                    Pos[i].x = 0.0f;
                    Pos[i].y = 0.0f;
                    Pos[i].z = 0.0f;
                }
            }
            else
            {
#endif
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos ) ) != IVAS_ERR_OK )
                for ( i = 0; i < num_subframes; i++ )
                {
                    fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
                    if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ),
                                 RotationFileReader_getFilePath( headRotReader ) );
                        goto cleanup;
                    }
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif


            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos
#ifdef API_5MS
            for ( i = 0; i < num_subframes; i++ )
            {
                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                           ,
                                                           DEFAULT_AXIS
@@ -2231,65 +2262,55 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#if defined( SPLIT_REND_WITH_HEAD_ROT ) && defined( API_5MS )
            int16_t enable5ms;
            IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms );
            arg.enable5ms = enable5ms;
            }
#else
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, Pos
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                       ,
                                                       DEFAULT_AXIS
#endif
            if ( !arg.enable5ms )
            {
                /* Skip over 3 following head positions - they are given on 5ms grid */
                for ( i = 0; i < 3; ++i )
                {
                    if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos ) ) != IVAS_ERR_OK )
                                                       ) ) != IVAS_ERR_OK )
            {
                        fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    }
                }
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#endif
        }

        if ( arg.enableExternalOrientation )
        {
            IVAS_QUATERNION Quaternion;
            int8_t enableHeadRotation;
            int8_t enableExternalOrientation;
            int8_t enableRotationInterpolation;
            int16_t numFramesToTargetOrientation;
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

            for ( i = 0; i < num_subframes; i++ )
            {

            if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternion, &enableHeadRotation, &enableExternalOrientation, &enableRotationInterpolation, &numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ),
                             RotationFileReader_getFilePath( externalOrientationFileReader ) );
                    goto cleanup;
                }


            if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternion, enableHeadRotation, enableExternalOrientation, enableRotationInterpolation, numFramesToTargetOrientation * vec_pos_len ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedExternalOrientationData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }

#if defined( SPLIT_REND_WITH_HEAD_ROT ) && defined( API_5MS )
            int16_t enable5ms;
            IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms );
            arg.enable5ms = enable5ms;
#endif
            if ( !arg.enable5ms )
            {
                /* Skip over 3 following entries in file - they are given on 5ms grid */
                for ( i = 0; i < 3; ++i )
#ifdef API_5MS
            for ( i = 0; i < num_subframes; i++ )
            {
                    if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternion, &enableHeadRotation, &enableExternalOrientation, &enableRotationInterpolation, &numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK )
                {
                        fprintf( stderr, "Error in External Orientation File Reading: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    fprintf( stderr, "\nIVAS_DEC_FeedExternalOrientationData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }
#else
            if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions, enableHeadRotation, enableExternalOrientation, enableRotationInterpolation, numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedExternalOrientationData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#endif
        }

        /* decode and get samples */
@@ -2610,14 +2631,14 @@ static ivas_error decodeG192(
            IVAS_QUATERNION Quaternion;


            if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos ) ) != IVAS_ERR_OK )
            if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos[0] ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }


            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                       ,
                                                       DEFAULT_AXIS
+72 −78
Original line number Diff line number Diff line
@@ -1054,7 +1054,12 @@ int main(
    IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] = { 0 };
#endif

    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain
#ifdef API_5MS
                                   ,
                                   ( args.framing_5ms ) ? 1 : 4
#endif
                                   ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
@@ -1560,6 +1565,13 @@ int main(
#endif
        );

#ifdef API_5MS
        int16_t num_subframes, sf_idx;
        num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#else
        num_subframes = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
#endif

#ifdef API_5MS
        if ( isCurrentFrameMultipleOf20ms )
        {
@@ -1585,19 +1597,22 @@ int main(
            /* Read from reference rotation trajectory file if specified */
            if ( referenceRotReader != NULL )
            {
                IVAS_QUATERNION quaternion;
                if ( ( error = HeadRotationFileReading( referenceRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK )
                for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
                {
                    IVAS_QUATERNION quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
                    if ( ( error = HeadRotationFileReading( referenceRotReader, &quaternions[sf_idx], NULL ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    }

                if ( ( error = IVAS_REND_SetReferenceRotation( hIvasRend, quaternion ) ) != IVAS_ERR_OK )
                    if ( ( error = IVAS_REND_SetReferenceRotation( hIvasRend, quaternions[sf_idx] ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "Error setting Reference Rotation: %s\n", ivas_error_to_string( error ) );
                        exit( -1 );
                    }
                }
            }
#ifdef API_5MS
        }
#endif
@@ -1606,6 +1621,8 @@ int main(
        if ( headRotReader != NULL )
        {
#ifdef API_5MS
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
            {
                IVAS_QUATERNION headRot;
                IVAS_VECTOR3 Pos;

@@ -1618,24 +1635,16 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                          ,
                                                          DEFAULT_AXIS
#endif
#ifdef API_5MS
                                                          ,
                                                          sf_idx
#endif
                                                          ) ) != 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 ( 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];
@@ -1699,53 +1708,38 @@ int main(
        /* Read from external orientation file if specified */
        if ( externalOrientationFileReader != NULL )
        {
            IVAS_QUATERNION quatBuffer[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#ifdef 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 ( i = 0; i < 3; ++i )
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
#else
            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
#endif
            {
                    if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quat, &enableHeadRotation, &enableExternalOrientation, &enableRotationInterpolation, &numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != 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];
            int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
#ifdef API_5MS
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
            {
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx]
#ifdef API_5MS
                                                                 ,
                                                                 sf_idx
#endif
                                                                 ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in External Orientation File Reading: %s\n", ivas_error_to_string( error ) );
                    fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }

#else
            if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, quatBuffer, enableHeadRotation, enableExternalOrientation, enableRotationInterpolation, numFramesToTargetOrientation ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) );
+0 −2
Original line number Diff line number Diff line
@@ -5470,9 +5470,7 @@ void ivas_binRenderer(
    HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData,
#endif
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,       /* i  : combined head and external orientation handle           */
#ifndef API_5MS
    int16_t subframe_idx,                                       /* i  : subframe index                                          */
#endif
    const int16_t numTimeSlots,                                 /* i: : number of time slots to process                         */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o  : Rotated Binaural signals */
+2 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@
/*#define DEBUG_AGC_ENCODER_CMD_OPTION*/        /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */
/*#define DEBUG_JBM_CMD_OPTION*/                /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */
/*#define VARIABLE_SPEED_DECODING*/                 /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */
#define DISABLE_LIMITER                         /* disable the limiter to aid BE debugging */
//#define DISABLE_LIMITER                         /* disable the limiter to aid BE debugging */
#define DEBUG_SIMULATE_EXTORIENTATION_MAIN_FOR_BE /* simulate the problem discussed in*/

/*Split Rendering Debug switches*/
@@ -156,6 +156,7 @@
#define API_5MS                                         /* FhG: 5ms rendering capability */
#ifdef API_5MS 
#define API_5MS_BASELINE                                /* FhG: baseline with 20ms rendering and split rendering through 20ms branch */
#define APLIT_5MS_FIX_TODO
#endif
/* NON-BE Fixes */
#define FIX_551_HEADTRACKER_INIT                        /* FhG: move setting of orientation tracking type to earlier    */
+3 −37

File changed.

Preview size limit exceeded, changes collapsed.

Loading