Commit 6b9e3c67 authored by hsd's avatar hsd
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'upstream_3gppforge/109-harmonize-head-and-orientation-tracking-xcheck' into 109-harmonize-head-and-orientation-tracking-refvec-review

# Conflicts:
#	lib_rend/ivas_orient_trk.c
parents ea81af1c 3cf0d186
Loading
Loading
Loading
Loading
Loading
+54 −33
Original line number Diff line number Diff line
@@ -1444,15 +1444,24 @@ static ivas_error initOnFirstGoodFrame(
        /* If outputting MASA, open output file and write metadata for initial bad frames */
        else if ( *pBsFormat == IVAS_DEC_BS_MASA )
        {
#ifdef FIX_350_MASA_DELAY_COMP
            if ( ( error = MasaFileWriter_open( arg.outputWavFilename, arg.delayCompensationEnabled, ppMasaWriter ) ) != IVAS_ERR_OK )
#else
            if ( ( error = MasaFileWriter_open( arg.outputWavFilename, ppMasaWriter ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
                return error;
            }

            /* Duplicate good first frame metadata to fill the beginning of stream. */
#ifdef FIX_350_MASA_DELAY_COMP
            MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL;
            if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
            IVAS_MASA_QMETADATA_HANDLE qMetadata = NULL;
            if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &qMetadata ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
@@ -1460,7 +1469,11 @@ static ivas_error initOnFirstGoodFrame(

            for ( int16_t j = 0; j < numInitialBadFrames; ++j )
            {
#ifdef FIX_350_MASA_DELAY_COMP
                if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
                    return error;
@@ -1584,36 +1597,25 @@ static ivas_error decodeG192(
            goto cleanup;
        }

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

#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i] ) ) != IVAS_ERR_OK )
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        /* reference vector */
        if ( arg.enableReferenceVectorTracking )
        {
                    fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                    goto cleanup;
                }
            }
#else
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
            IVAS_VECTOR3 listenerPosition, referencePosition;
            if ( ( error = Vector3PairFileReader_read( referenceVectorReader, &listenerPosition, &referencePosition ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                fprintf( stderr, "\nError %s while reading listener and reference positions from %s\n", IVAS_DEC_GetErrorMessage( error ), Vector3PairFileReader_getFilePath( referenceVectorReader ) );
                goto cleanup;
            }
#endif

            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_FeedRefVectorData( hIvasDec, listenerPosition, referencePosition ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                fprintf( stderr, "\nIVAS_DEC_FeedRefVectorData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }

#ifdef FIX_I109_ORIENTATION_TRACKING
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
        /* Reference rotation */
        if ( arg.enableReferenceRotation )
        {
@@ -1630,25 +1632,35 @@ static ivas_error decodeG192(
                goto cleanup;
            }
        }
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        /* reference vector */
        if ( arg.enableReferenceVectorTracking )
#endif
        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
            IVAS_VECTOR3 listenerPosition, referencePosition;
            if ( ( error = Vector3PairFileReader_read( referenceVectorReader, &listenerPosition, &referencePosition ) ) != IVAS_ERR_OK )
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
                fprintf( stderr, "\nError %s while reading listener and reference positions from %s\n", IVAS_DEC_GetErrorMessage( error ), Vector3PairFileReader_getFilePath( referenceVectorReader ) );
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                    goto cleanup;
                }
            }
#else
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }
#endif

            if ( ( error = IVAS_DEC_FeedRefVectorData( hIvasDec, listenerPosition, referencePosition ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_FeedRefVectorData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#endif
        /* Run decoder for one frame (get rendered output) */
        if ( ( error = IVAS_DEC_GetSamples( hIvasDec, pcmBuf, &nOutSamples ) ) != IVAS_ERR_OK )
        {
@@ -1746,14 +1758,23 @@ static ivas_error decodeG192(
            }
            else if ( bsFormat == IVAS_DEC_BS_MASA )
            {
#ifdef FIX_350_MASA_DELAY_COMP
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                IVAS_MASA_QMETADATA_HANDLE qMetadata;
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

#ifdef FIX_350_MASA_DELAY_COMP
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
                    goto cleanup;
@@ -1773,8 +1794,8 @@ static ivas_error decodeG192(
#endif
        }
#ifdef WMOPS
        update_wmops();
        update_mem();
        update_wmops();
#endif
    }

@@ -2274,8 +2295,8 @@ static ivas_error decodeVoIP(
        systemTime_ms += 20;

#ifdef WMOPS
        update_wmops();
        update_mem();
        update_wmops();
#endif
    }

+1 −1
Original line number Diff line number Diff line
@@ -778,8 +778,8 @@ int main(
        }

#ifdef WMOPS
        update_wmops();
        update_mem();
        update_wmops();
#endif
    }

+32 −32
Original line number Diff line number Diff line
@@ -979,37 +979,6 @@ int main(
        ObjectPositionBuffer mtdBuffer;
        IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer );

        /* Read from head rotation trajectory file if specified */
        if ( headRotReader != NULL )
        {
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
                if ( HeadRotationFileReading( headRotReader, &quatBuffer[i] ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in Head Rotation File Reading.\r\n" );
                    exit( -1 );
                }
            }
#else
            HeadRotationFileReading( headRotReader, quatBuffer, frame );
#endif
            if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
            }
        }
        else
        {
            if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) )
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
            }
        }

#ifdef FIX_I109_ORIENTATION_TRACKING
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        if ( referenceVectorReader != NULL )
@@ -1044,6 +1013,37 @@ int main(
        }
#endif

        /* Read from head rotation trajectory file if specified */
        if ( headRotReader != NULL )
        {
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
                if ( HeadRotationFileReading( headRotReader, &quatBuffer[i] ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error in Head Rotation File Reading.\r\n" );
                    exit( -1 );
                }
            }
#else
            HeadRotationFileReading( headRotReader, quatBuffer, frame );
#endif
            if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
            }
        }
        else
        {
            if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) )
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
            }
        }

        for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i )
        {
            if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, mcIds[i], &numChannels ) ) != IVAS_ERR_OK )
@@ -1173,8 +1173,8 @@ int main(
        }

#ifdef WMOPS
        update_wmops();
        update_mem();
        update_wmops();
#endif
    }

+3 −6
Original line number Diff line number Diff line
@@ -706,8 +706,7 @@ ivas_error openCldfb(
    HANDLE_CLDFB_FILTER_BANK hs;
    int16_t buf_len;

    hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) );
    if ( hs == NULL )
    if ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
@@ -728,8 +727,7 @@ ivas_error openCldfb(
        buf_len = hs->p_filter_length;
    }

    hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) );
    if ( hs->cldfb_state == NULL )
    if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
@@ -1148,8 +1146,7 @@ ivas_error cldfb_save_memory(
        hs->memory_length = hs->p_filter_length;
    }

    hs->memory = (float *) malloc( hs->memory_length * sizeof( float ) );
    if ( hs->memory == NULL )
    if ( ( hs->memory = (float *) malloc( hs->memory_length * sizeof( float ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
+4 −0
Original line number Diff line number Diff line
@@ -94,7 +94,11 @@ typedef struct
#endif /* OTR_REFERENCE_VECTOR_TRACKING */

typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
#ifdef FIX_350_MASA_DELAY_COMP
typedef struct ivas_masa_decoder_ext_out_meta_struct *MASA_DECODER_EXT_OUT_META_HANDLE;
#else
typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE;
#endif

typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
Loading