Commit 4020bc58 authored by norvell's avatar norvell
Browse files

Merge branch 'ericsson/td-renderer-with-radius-and-orientation' into 'main'

[Non BE][Rend Non BE] 17 - TD Object renderer with radius and orientation

See merge request !499
parents f06bf0be a6d6cf44
Loading
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -398,9 +398,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;
        }

@@ -1334,6 +1342,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 )
@@ -1408,13 +1419,21 @@ static ivas_error decodeG192(
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#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;
            }

#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 −0
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;

@@ -378,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;
@@ -876,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;
@@ -1263,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" );
@@ -1643,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" );
+93 −23
Original line number Diff line number Diff line
@@ -517,6 +517,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();
@@ -622,19 +625,31 @@ 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 )
    {
        exit( -1 );
    }
#endif

        if ( args.renderConfigFilePath[0] != '\0' )
        {
            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 );
            }

@@ -860,12 +875,21 @@ int main(
        if ( headRotReader != NULL )
        {
            IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME];
#ifdef TD5
            HeadRotationFileReading( headRotReader, quatBuffer, Pos );
            IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos );
#else
            HeadRotationFileReading( headRotReader, quatBuffer, frame );
            IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer );
#endif
        }
        else
        {
#ifdef TD5
            IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL );
#else
            IVAS_REND_SetHeadRotation( hIvasRend, NULL );
#endif
        }

        for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i )
@@ -1687,6 +1711,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;
}
@@ -1741,6 +1770,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 */
@@ -1755,6 +1789,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;
@@ -1989,6 +2037,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 );
@@ -2015,7 +2085,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
@@ -86,6 +90,14 @@ typedef struct

} IVAS_QUATERNION;

#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;
@@ -111,6 +123,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
@@ -132,6 +149,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 −0
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
@@ -349,7 +357,12 @@ 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,
    IND_ISM_SCE_ID_DTX = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS,
    IND_ISM_NOISY_SPEECH_FLAG,
@@ -361,6 +374,10 @@ enum
    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