Commit 5060f758 authored by sagnowski's avatar sagnowski
Browse files

Extend framework to include MASA rendering

parent d5f00f39
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ if(WIN32)
endif()

add_executable(IVAS_rend apps/renderer.c)
target_link_libraries(IVAS_rend lib_rend lib_util)
target_link_libraries(IVAS_rend lib_rend lib_util lib_dec) # Todo refactor: dependency to lib_dec should be removed

if(COPY_EXECUTABLES_TO_ROOT)
  # Optionally copy executables to root directory after build
+86 −9
Original line number Diff line number Diff line
@@ -431,7 +431,12 @@ static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer
static int32_t getTotalNumInChannels( IVAS_REND_HANDLE hIvasRend,
                                      IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS],
                                      IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS],
                                      IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS] )
                                      IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS]
#ifdef NOKIA_MASA_EXTERNAL_RENDERER
                                      ,
                                      IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS]
#endif
)
{
    int32_t totalNumInChannels = 0;
    ivas_error error;
@@ -487,6 +492,25 @@ static int32_t getTotalNumInChannels( IVAS_REND_HANDLE hIvasRend,
        totalNumInChannels += numInputChannels;
    }

#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    for ( int32_t i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
    {
        if ( masaIds[i] == 0 )
        {
            /* Skip inactive inputs */
            continue;
        }

        int32_t numInputChannels;
        if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, masaIds[i], &numInputChannels ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }
        totalNumInChannels += numInputChannels;
    }
#endif

    return totalNumInChannels;
}

@@ -651,6 +675,9 @@ int32_t main( int32_t argc, char **argv )
    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 };
    IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS] = { 0 };
    IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS] = { 0 };
#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS] = { 0 };
#endif

    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
    {
@@ -723,7 +750,24 @@ int32_t main( int32_t argc, char **argv )
        }
    }

    const int32_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds );
#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    for ( int32_t i = 0; i < args.inConfig.numMasaBuses; ++i )
    {
        if ( ( error = IVAS_REND_AddInput( hIvasRend, args.inConfig.masaBuses[i].audioConfig, &masaIds[i] ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }

        if ( ( error = IVAS_REND_SetInputGain( hIvasRend, masaIds[i], args.inputGainGlobal * dBToLin( args.inConfig.masaBuses[i].gain_dB ) ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }
    }
#endif

    const int32_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds );
    if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */
         && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) )
    {
@@ -801,6 +845,7 @@ int32_t main( int32_t argc, char **argv )
        /* Convert from int to float and from interleaved to packed */
        convertInputBuffer( inpInt16Buffer, numSamplesRead, frameSize_smpls, num_in_channels, inFloatBuffer );

#ifndef NOKIA_MASA_EXTERNAL_RENDERER
        for ( int32_t i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
        {
            if ( masaReaders[i] != NULL )
@@ -811,6 +856,7 @@ int32_t main( int32_t argc, char **argv )
                (void) hMasaMetadata;
            }
        }
#endif

        ObjectPositionBuffer mtdBuffer;
        IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer );
@@ -878,6 +924,37 @@ int32_t main( int32_t argc, char **argv )
            }
        }

#ifdef NOKIA_MASA_EXTERNAL_RENDERER
        for ( int32_t i = 0; i < args.inConfig.numMasaBuses; ++i )
        {
            int32_t numChannels;
            if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, masaIds[i], &numChannels ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
            IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, args.inConfig.masaBuses[i].inputChannelIndex, numChannels );

            if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

            if ( masaReaders[i] != NULL )
            {
                /* This will update data in hMasaMetadata[i] */
                MasaFileReader_readNextFrame( masaReaders[i] );

                if ( ( error = IVAS_REND_FeedInputMasaMetadata( hIvasRend, masaIds[i], hMasaMetadata[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
        }
#endif

        IVAS_REND_GetSamples( hIvasRend, outBuffer );

        int32_t num_out_channels;
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@

#define EXT_RENDERER                                    /* FhG: external renderer library and standalone application */
#define FIX_EFAP_MATH                                   /* fix for EFAP: remove angle quantization and a bug in polygon lookup causing incorrect gains. minor tweak for ALLRAD. non-BE for modes using EFAP */
#define NOKIA_MASA_EXTERNAL_RENDERER                    /* Nokia: MASA support for external renderer */
/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
+647 −8

File changed.

Preview size limit exceeded, changes collapsed.

+1 −2
Original line number Diff line number Diff line
@@ -227,11 +227,10 @@ ivas_error IVAS_REND_FeedInputObjectMetadata(
    IVAS_REND_AudioObjectPosition objectPosition    /* i  : object position struct                              */
);

/* Support for MASA input will be added in the future. */
ivas_error IVAS_REND_FeedInputMasaMetadata(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
    IVAS_REND_InputId inputId,                      /* i  : ID of the input                                     */
    void* TODO
    IVAS_MASA_METADATA_HANDLE masaMetadata          /* i  : MASA metadata frame                                 */
);

ivas_error IVAS_REND_SetHeadRotation(
Loading