Commit 1e1670bb authored by haeussler's avatar haeussler
Browse files

Merge branch '109-harmonize-head-and-orientation-tracking-merge' into...

Merge branch '109-harmonize-head-and-orientation-tracking-merge' into '109-harmonize-head-and-orientation-tracking'

Merging the main branch down to 109-harmonize-and-orientation-tracking

See merge request !503
parents 4e377afd ebf161d4
Loading
Loading
Loading
Loading
Loading
+27 −41
Original line number Diff line number Diff line
@@ -124,9 +124,6 @@ typedef struct
    char *renderConfigFilename;

#ifdef DEBUGGING
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    bool forceSubframeBinauralization;
#endif
    IVAS_DEC_FORCED_REND_MODE forcedRendMode;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -256,7 +253,6 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
@@ -264,13 +260,10 @@ int main(
            fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_351_HRTF_COMMAND
            arg.hrtfReaderEnabled = false;
#endif
            fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName );
            goto cleanup;
        }
@@ -282,14 +275,12 @@ int main(

    if ( arg.enableHeadRotation )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = HeadRotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK )
        {
@@ -344,14 +335,12 @@ int main(

    if ( arg.renderConfigEnabled )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK )
        {
@@ -364,23 +353,7 @@ int main(
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/

#ifdef REMOVE_FORCE_SUBFRAME_BIN
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK )
#else
#ifdef DEBUGGING
#ifdef FIX_351_HRTF_COMMAND
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef FIX_351_HRTF_COMMAND
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK )
#endif
#endif
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -486,9 +459,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef TD5
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
#ifdef TD5
            fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL and BINAURAL_ROOM. Exiting. \n\n" );
#else
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n\n" );
#endif
            goto cleanup;
        }

@@ -784,9 +765,6 @@ static bool parseCmdlIVAS_dec(
    float ftmp;

    arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED;
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    arg->forceSubframeBinauralization = false;
#endif
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
#endif
@@ -948,13 +926,6 @@ static bool parseCmdlIVAS_dec(
                i++;
            }
        }
#ifndef REMOVE_FORCE_SUBFRAME_BIN
        else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */
        {
            arg->forceSubframeBinauralization = true;
            i++;
        }
#endif
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
        /*-----------------------------------------------------------------*
@@ -1257,10 +1228,6 @@ static void usage_dec( void )
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
    fprintf( stdout, "-hrtf File          : HRTF filter File used in BINAURAL output configuration\n" );
#ifdef DEBUGGING
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    fprintf( stdout, "-force_subframe_bin : Forces parametric binauralizer code to use 5 ms time resolution even when\n" );
    fprintf( stdout, "                      output time resolution is larger.\n" );
#endif
    fprintf( stdout, "-FEC X              : Insert frame erasures, X = 0-10 is the percentage\n" );
    fprintf( stdout, "                      of erased frames, or X may be the name of binary file or \n" );
    fprintf( stdout, "                      file with G192 headers indicating GOOD FRAME or BAD FRAME\n" );
@@ -1528,6 +1495,9 @@ static ivas_error decodeG192(
    ivas_error error = IVAS_ERR_UNKNOWN;
    uint16_t numObj = 0;
    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
#ifdef TD5
    IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#endif

    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
@@ -1620,7 +1590,11 @@ static ivas_error decodeG192(
        if ( arg.enableReferenceRotation )
        {
            IVAS_QUATERNION quaternion;
#ifdef TD5
            if ( ( error = HeadRotationFileReading( refRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK )
#else
            if ( ( error = HeadRotationFileReading( refRotReader, &quaternion ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError %s while reading reference rotation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( refRotReader ) );
                goto cleanup;
@@ -1641,21 +1615,33 @@ static ivas_error decodeG192(
#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
#ifdef TD5
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
#else
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i] ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                    goto cleanup;
                }
            }
#else
#ifdef TD5
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, Pos ) ) != IVAS_ERR_OK )
#else
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }
#endif

#ifdef TD5
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, Pos ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
+23 −24
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ typedef struct
#endif
#endif
    bool pca;
#ifdef TD5
    bool ism_extended_metadata;
#endif

} EncArguments;

@@ -213,23 +216,6 @@ int main(
        goto cleanup;
    }

#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS
    /*------------------------------------------------------------------------------------------*
     * Open input audio file
     *------------------------------------------------------------------------------------------*/
    int32_t inFileSampleRate = 0;
    if ( AudioFileReader_open( &audioReader, arg.inputWavFilename, &inFileSampleRate ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename );
        goto cleanup;
    }
    if ( inFileSampleRate != 0 && /* inFileSampleRate will remain zero if input file is raw PCM */
         inFileSampleRate != arg.inputFs )
    {
        fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename );
        goto cleanup;
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Open output bitstream file
@@ -395,7 +381,11 @@ int main(
            }
            break;
        case IVAS_ENC_INPUT_ISM:
#ifdef TD5
            if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects, arg.ism_extended_metadata ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
@@ -452,7 +442,6 @@ int main(
        goto cleanup;
    }

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    /*------------------------------------------------------------------------------------------*
     * Open input audio file
     *------------------------------------------------------------------------------------------*/
@@ -511,7 +500,6 @@ int main(
            fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) );
            goto cleanup;
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Open input metadata files
@@ -895,6 +883,9 @@ static void initArgStruct( EncArguments *arg )
    arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig();
    arg->ca_config_file = NULL;
    arg->mimeOutput = false;
#ifdef TD5
    arg->ism_extended_metadata = false;
#endif

#ifdef DEBUGGING
    arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
@@ -1282,6 +1273,13 @@ static bool parseCmdlIVAS_enc(

            if ( i < argc - 4 )
            {
#ifdef TD5
                if ( argv[i][0] == '+' )
                {
                    argv[i]++;
                    arg->ism_extended_metadata = true;
                }
#endif
                if ( !is_digits_only( argv[i] ) )
                {
                    fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" );
@@ -1640,7 +1638,6 @@ static void usage_enc( void )
    fprintf( stdout, "                                                *VBR mode (average bitrate),\n" );
    fprintf( stdout, "                      for AMR-WB IO modes R =  (6600, 8850, 12650, 14250, 15850, 18250,\n" );
    fprintf( stdout, "                                                19850, 23050, 23850) \n" );
#ifdef ISM_HIGHEST_BITRATE
    fprintf( stdout, "                      for IVAS stereo R =      (13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" );
    fprintf( stdout, "                                                96000, 128000, 160000, 192000, 256000) \n" );
    fprintf( stdout, "                      for IVAS ISM R =          13200 for 1 ISM, 16400 for 1 ISM and 2 ISM, \n" );
@@ -1648,10 +1645,6 @@ static void usage_enc( void )
    fprintf( stdout, "                                                for 2 ISM, 3 ISM and 4 ISM also 160000, 192000, 256000) \n" );
    fprintf( stdout, "                                                for 3 ISM and 4 ISM also 384000 \n" );
    fprintf( stdout, "                                                for 4 ISM also 512000 \n" );
#else
    fprintf( stdout, "                      for IVAS stereo & ISm R =(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" );
    fprintf( stdout, "                                                96000, 128000, 160000, 192000, 256000) \n" );
#endif
    fprintf( stdout, "                      for IVAS SBA, MASA, MC R=(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" );
    fprintf( stdout, "                                                96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" );
    fprintf( stdout, "                      Alternatively, R can be a bitrate switching file which consists of R values\n" );
@@ -1667,8 +1660,14 @@ static void usage_enc( void )
    fprintf( stdout, "EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -masa, -mc\n" );
    fprintf( stdout, "-stereo [Mode]      : Stereo format, default is unified stereo \n" );
    fprintf( stdout, "                      optional for Mode: 1: DFT Stereo, 2: TD Stereo, 3: MDCT Stereo\n" );
#ifdef TD5
    fprintf( stdout, "-ism (+)Ch Files    : ISM format \n" );
    fprintf( stdout, "                      where Ch specifies the number of ISMs (1-4)\n" );
    fprintf( stdout, "                      where positive (+) means extended metadata format is used (including orientation and radius) \n" );
#else
    fprintf( stdout, "-ism Channels Files : ISM format \n" );
    fprintf( stdout, "                      where Channels specifies the number of ISMs (1-4)\n" );
#endif
    fprintf( stdout, "                      and Files specify input files containing metadata, one file per object\n" );
    fprintf( stdout, "                      (use NULL for no input metadata)\n" );
    fprintf( stdout, "-sba +/-Order       : Scene Based Audio input format (Ambisonics ACN/SN3D),\n" );
+82 −29
Original line number Diff line number Diff line
@@ -558,6 +558,9 @@ int main(
    int32_t delayTimeScale = 0;
    int16_t i, numChannels;
    ivas_error error = IVAS_ERR_OK;
#ifdef TD5
    IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME];
#endif

#ifdef WMOPS
    reset_wmops();
@@ -652,7 +655,6 @@ int main(
        setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders );
    }

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening file: %s\n", audioFilePath );
@@ -696,28 +698,6 @@ int main(
        fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }
#else
    int32_t inFileSampleRate = 0;
    if ( AudioFileReader_open( &audioReader, audioFilePath, &inFileSampleRate ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening file: %s\n", audioFilePath );
        exit( -1 );
    }
    if ( args.sampleRate == 0 && inFileSampleRate == 0 )
    {
        fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" );
        exit( -1 );
    }
    if ( args.sampleRate != 0 && inFileSampleRate != 0 && args.sampleRate != inFileSampleRate )
    {
        fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath );
        exit( -1 );
    }
    if ( args.sampleRate == 0 )
    {
        args.sampleRate = inFileSampleRate;
    }
#endif
    const int16_t frameSize_smpls = (int16_t) ( 20 * args.sampleRate / 1000 );

    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 };
@@ -732,7 +712,11 @@ int main(
    }

    /* === Configure === */
#ifdef TD5
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, strlen( args.renderConfigFilePath ) != 0 ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Error in Renderer Config Init\n" );
        exit( -1 );
@@ -743,9 +727,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef TD5
        if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) )
#else
        if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
#endif
        {
#ifdef TD5
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" );
#else
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" );
#endif
            exit( -1 );
        }

@@ -893,12 +885,7 @@ int main(

    const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds );

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels )
#else
    if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */
         && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) )
#endif
    {
        fprintf( stderr, "Number of channels in input file does not match selected configuration\n" );
        exit( -1 );
@@ -1000,7 +987,11 @@ int main(
        if ( referenceRotReader != NULL )
        {
            IVAS_QUATERNION quaternion;
#ifdef TD5
            if ( HeadRotationFileReading( referenceRotReader, &quaternion, NULL ) != IVAS_ERR_OK )
#else
            if ( HeadRotationFileReading( referenceRotReader, &quaternion ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "Error in Head Rotation File Reading.\r\n" );
                exit( -1 );
@@ -1020,16 +1011,28 @@ int main(
#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ )
            {
#ifdef TD5
                if ( HeadRotationFileReading( headRotReader, &quatBuffer[i], &Pos[i] ) != IVAS_ERR_OK )
#else
                if ( HeadRotationFileReading( headRotReader, &quatBuffer[i] ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "Error in Head Rotation File Reading.\r\n" );
                    exit( -1 );
                }
            }
#else
#ifdef TD5
            HeadRotationFileReading( headRotReader, quatBuffer, Pos );
#else
            HeadRotationFileReading( headRotReader, quatBuffer, frame );
#endif
#endif
#ifdef TD5
            if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos ) != IVAS_ERR_OK )
#else
            if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
@@ -1037,7 +1040,11 @@ int main(
        }
        else
        {
#ifdef TD5
            if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) )
#else
            if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) )
#endif
            {
                fprintf( stderr, "Error setting Head Rotation\n" );
                exit( -1 );
@@ -1915,6 +1922,11 @@ void getMetadataFromFileReader(

    objectMetadataBuffer->positions[objIdx].azimuth = ismMetadata.azimuth;
    objectMetadataBuffer->positions[objIdx].elevation = ismMetadata.elevation;
#ifdef TD5
    objectMetadataBuffer->positions[objIdx].radius = ismMetadata.radius;
    objectMetadataBuffer->positions[objIdx].yaw = ismMetadata.yaw;
    objectMetadataBuffer->positions[objIdx].pitch = ismMetadata.pitch;
#endif

    return;
}
@@ -1969,6 +1981,11 @@ static void IsmPositionProvider_getNextFrame(
        {
            objectMetadataBuffer->positions[objIdx].azimuth = 0.0f;
            objectMetadataBuffer->positions[objIdx].elevation = 0.0f;
#ifdef TD5
            objectMetadataBuffer->positions[objIdx].radius = 1.0f;
            objectMetadataBuffer->positions[objIdx].yaw = 0.0f;
            objectMetadataBuffer->positions[objIdx].pitch = 0.0f;
#endif
        }

        /* Wrap azimuth to lie within (-180, 180] range */
@@ -1983,6 +2000,20 @@ static void IsmPositionProvider_getNextFrame(

        /* Clamp elevation to lie within [-90, 90] range (can't be wrapped easily) */
        objectMetadataBuffer->positions[objIdx].elevation = min( max( objectMetadataBuffer->positions[objIdx].elevation, -90 ), 90 );
#ifdef TD5
        /* Wrap yaw to lie within (-180, 180] range */
        while ( objectMetadataBuffer->positions[objIdx].yaw < 0.0f )
        {
            objectMetadataBuffer->positions[objIdx].yaw += 360.0f;
        }
        while ( objectMetadataBuffer->positions[objIdx].yaw >= 360.0f )
        {
            objectMetadataBuffer->positions[objIdx].yaw -= 360.0f;
        }

        /* Clamp pitch to lie within [-90, 90] range (can't be wrapped easily) */
        objectMetadataBuffer->positions[objIdx].pitch = min( max( objectMetadataBuffer->positions[objIdx].pitch, -90 ), 90 );
#endif
    }

    ++positionProvider->frameCounter;
@@ -2217,6 +2248,28 @@ static void parseObjectPosition(
    uint16_t *positionDuration )
{
    char *endptr;
#ifdef TD5
    int16_t read_values;
    float meta_prm[7] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f };

    readNextMetadataChunk( line, "," );
    *positionDuration = (uint16_t) strtol( line, &endptr, 10 );
    readNextMetadataChunk( line, "\n" );

    read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6] );

    if ( read_values < 2 )
    {
        fprintf( stderr, "Error reading metadata\n" );
        exit( -1 );
    }

    position->azimuth = meta_prm[0];
    position->elevation = meta_prm[1];
    position->radius = meta_prm[2];
    position->yaw = meta_prm[5];
    position->pitch = meta_prm[6];
#else

    readNextMetadataChunk( line, "," );
    *positionDuration = (uint16_t) strtol( line, &endptr, 10 );
@@ -2243,7 +2296,7 @@ static void parseObjectPosition(
        fprintf( stderr, "Error reading metadata\n" );
        exit( -1 );
    }

#endif
    return;
}

+20 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ typedef struct _IVAS_ISM_METADATA
    float radius;
    float spread;
    float gainFactor;
#ifdef TD5
    float yaw;
    float pitch;
#endif
} IVAS_ISM_METADATA;

typedef struct
@@ -93,6 +97,14 @@ typedef struct
} IVAS_VECTOR3;
#endif /* OTR_REFERENCE_VECTOR_TRACKING */

#ifdef TD5
typedef struct
{
    float x, y, z;

} IVAS_POSITION;
#endif

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;
@@ -118,6 +130,11 @@ typedef struct
{
    float azimuth;
    float elevation;
#ifdef TD5
    float radius;
    float yaw;
    float pitch;
#endif
} IVAS_REND_AudioObjectPosition;

typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
@@ -139,6 +156,9 @@ typedef struct _IVAS_RENDER_CONFIG
    IVAS_RENDER_TYPE_OVERRIDE renderer_type_override;
#endif
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics;
#ifdef TD5
    float directivity[3];
#endif
} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

typedef struct _IVAS_LS_CUSTOM_LAYOUT
+17 −8
Original line number Diff line number Diff line
@@ -320,6 +320,14 @@ typedef enum
#define ISM_Q_STEP                              2.5f
#define ISM_Q_STEP_BORDER                       5.0f

#ifdef TD5
#define ISM_RADIUS_NBITS                       6 
#define ISM_RADIUS_MIN                         0.0f
#define ISM_RADIUS_DELTA                       0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
#define ISM_EXTENDED_METADATA_BRATE            IVAS_64k
#define ISM_EXTENDED_METADATA_BITS             1
#endif 

/* Parametric ISM */
#define MAX_PARAM_ISM_NBANDS                    11
#define MAX_PARAM_ISM_NBANDS_WB                 9
@@ -333,11 +341,9 @@ typedef enum
#define PARAM_ISM_MAX_CHAN                      16
#define PARAM_ISM_HYS_BUF_SIZE                  10

#ifdef PARAM_ISM_DTX_CNG
#define PARAM_ISM_DTX_COH_SCA_BITS              4
#define PARAM_ISM_DTX_AZI_BITS                  5 
#define PARAM_ISM_DTX_ELE_BITS                  4
#endif

typedef enum 
{
@@ -351,24 +357,27 @@ typedef enum
enum
{
    IND_ISM_NUM_OBJECTS,
#ifdef TD5
    IND_ISM_EXTENDED_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS,
    IND_ISM_METADATA_FLAG = IND_ISM_EXTENDED_FLAG + MAX_NUM_OBJECTS, /* EN2VE: Is this not supposed to be in the loop part below, since it is one per ISm? */
#else
    IND_ISM_METADATA_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS,
#endif
    IND_ISM_VAD_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS,
#ifdef PARAM_ISM_DTX_CNG
    IND_ISM_SCE_ID_DTX = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS,
    IND_ISM_NOISY_SPEECH_FLAG,
    IND_ISM_DTX_COH_SCA,
#endif

    /* ------------- loop for objects -------------- */
#ifdef PARAM_ISM_DTX_CNG
    TAG_ISM_LOOP_START = IND_ISM_DTX_COH_SCA + MAX_NUM_OBJECTS,
#else
    TAG_ISM_LOOP_START = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS,
    #endif
    IND_ISM_AZIMUTH_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_AZIMUTH = TAG_ISM_LOOP_START,
    IND_ISM_ELEVATION_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_ELEVATION = TAG_ISM_LOOP_START,
#ifdef TD5
    IND_ISM_RADIUS_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_RADIUS = TAG_ISM_LOOP_START,
#endif 
    TAG_ISM_LOOP_END = TAG_ISM_LOOP_START + 100, /* IVAS_fmToDo: to be reviewed once the final metadata are defined */
    /* --------- end of loop for objects ----------- */

Loading