Commit c9148f12 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge branch 'shared/external-renderer-masa' into 'main'

Adds MASA format for external renderer

See merge request !255
parents 47d5fc30 8d4acdfb
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ target_link_libraries(lib_enc lib_com lib_debug)
file(GLOB libRendSrcs "lib_rend/*.c")
file(GLOB libRendHeaders "lib_rend/*.h")
add_library(lib_rend ${libRendSrcs} ${libRendHeaders})
target_link_libraries(lib_rend lib_com lib_debug)
target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed.

file(GLOB libDecSrcs "lib_dec/*.c")
file(GLOB libDecHeaders "lib_dec/*.h")
+2 −2
Original line number Diff line number Diff line
@@ -184,8 +184,8 @@ $(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(L
$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG)
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIDEC)

$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG)
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND)
$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC)
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -livasdec -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND)

$(CLI_UTESTS_CREND): $(OBJS_CLI_UTESTS_CREND) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG)
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_UTESTS_CREND) -L. -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(UTESTS_CREND_DIR)/$(CLI_UTESTS_CREND)
+84 −1
Original line number Diff line number Diff line
@@ -424,7 +424,12 @@ static int16_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
)
{
    int16_t totalNumInChannels = 0;
    int16_t i, numInputChannels;
@@ -479,6 +484,24 @@ static int16_t getTotalNumInChannels(
        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;
        }

        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 +674,9 @@ int main(
    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 )
    {
@@ -759,7 +785,29 @@ int main(
        }
    }

#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    for ( 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

#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds );
#else
    const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds );
#endif

    if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */
         && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) )
    {
@@ -855,6 +903,7 @@ int main(
        }
#endif

#ifndef NOKIA_MASA_EXTERNAL_RENDERER
        for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
        {
            if ( masaReaders[i] != NULL )
@@ -865,6 +914,7 @@ int main(
                (void) hMasaMetadata;
            }
        }
#endif

        ObjectPositionBuffer mtdBuffer;
        IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer );
@@ -930,6 +980,37 @@ int main(
            }
        }

#ifdef NOKIA_MASA_EXTERNAL_RENDERER
        for ( i = 0; i < args.inConfig.numMasaBuses; ++i )
        {
            int16_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 );

        int16_t num_out_channels;
@@ -1307,6 +1388,8 @@ static IVAS_REND_AudioConfig parseAudioConfig(
        switch ( charBuf[4] )
        {
            case '1':
                fprintf( stderr, "1TC MASA support is not functional and is pending on DirAC renderer refactoring.\n" );
                exit( EXIT_FAILURE );
                return IVAS_REND_AUDIO_CONFIG_MASA1;
            case '2':
                return IVAS_REND_AUDIO_CONFIG_MASA2;
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ typedef enum
    IVAS_ERR_TOO_MANY_INPUTS,
#else
    IVAS_ERR_TOO_MANY_OBJECT_INPUTS,
#endif
#ifdef NOKIA_MASA_EXTERNAL_RENDERER
    IVAS_ERR_MISSING_METADATA,
#endif
    IVAS_ERR_INDEX_OUT_OF_BOUNDS,
    IVAS_ERR_RECONFIGURE_NOT_SUPPORTED,
+2 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@
#define FIX_I1_113                                      /* under review : MCT bit distribution optimization for SBA high bitrates*/
#define PRINT_SBA_ORDER                                 /* Issue 179: print-out also the SBA order of IVAS SBA format to stdout */
#define EXT_RENDERER                                    /* FhG: external renderer library and standalone application */
#define NOKIA_MASA_EXTERNAL_RENDERER                    /* Nokia: MASA support for external renderer */
#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 FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS              /* Issue 124: do not allocate unused plc struct in IVAS modes which is only used in EVS mono */
#define FIX_MCT_PLC_RECOVERY                            /* Issue 184: scale the old synthesis part correctly in the first good frame after lost frames in MCT modes - to be activated after previous switch is merged */
@@ -154,6 +155,7 @@
#define REMOVE_SID_HARM_LEFTOVERS                       /* Issue 192: remove leftovers from the SID bitrate harmonization */



/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
Loading