Commit 6f84f648 authored by sagnowski's avatar sagnowski
Browse files

Update external renderer

Updates include:
    - Fix for raw PCM input
    - Fix for build with Make on some platforms
    - Implementation of BINAURAL_ROOM output config
parent 40f3499a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ $(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(L
	$(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 -livascom -livasdebug $(LDLIBS) -o $(CLI_APIREND)
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -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)
+28 −28
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ typedef struct CmdlnArgs
} CmdlnArgs;

static int8_t setInConfig(
    int16_t numChannels,
    AUDIO_CONFIG input_config,
    IVAS_REND_InputConfig *inConfig,
    IsmPositionProvider *positionProvider );
@@ -307,7 +306,6 @@ int32_t main( int32_t argc, char **argv )
    char audioFilePath[FILENAME_MAX];
    char masaMetadataFilePath[FILENAME_MAX];
    AudioFileReader *audioReader = NULL;
    int16_t numInChannels;
    AudioFileWriter *audioWriter;
    int16_t inBufferSize;
    int32_t outBufferSize;
@@ -392,19 +390,12 @@ int32_t main( int32_t argc, char **argv )

    if ( args.inputFormat != AUDIO_CONFIG_INVALID )
    {
        numInChannels = AudioFileReader_getNumChannels( audioReader );
        if ( numInChannels == 0 )
        {
            fprintf( stderr, "File does not contain number of channels metadata, probably a raw file: %s\n", audioFilePath );
            exit( -1 );
        }

        for ( i = 0; i < args.numAudioObjects; i++ )
        {
            positionProvider->ismReaders[i] = IsmFileReader_open( args.metaDataFiles[i] );
        }

        if ( setInConfig( numInChannels, args.inputFormat, &args.inConfig, positionProvider ) != 0 )
        if ( setInConfig( args.inputFormat, &args.inConfig, positionProvider ) != 0 )
        {
            fprintf( stderr, "File cannot be used: %s\n", audioFilePath );
            exit( -1 );
@@ -412,7 +403,7 @@ int32_t main( int32_t argc, char **argv )
    }

    /* === Configure === */
    if ( ( error = IVAS_REND_Configure( hIvasRend, args.inConfig, args.outConfig, args.sampleRate, args.trajectoryFile[0] != '\0' ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_REND_Configure( hIvasRend, args.inConfig, args.outConfig, args.sampleRate, args.trajectoryFile[0] != '\0', args.renderConfigFile[0] != '\0' ) ) != IVAS_ERR_OK )
    {
        exit( -1 );
    }
@@ -422,7 +413,8 @@ int32_t main( int32_t argc, char **argv )
        IVAS_REND_SetNeverDropLfe( hIvasRend, 1 );
    }

    if ( IVAS_REND_GetInChannels( hIvasRend ) != AudioFileReader_getNumChannels( audioReader ) )
    if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */
         && IVAS_REND_GetInChannels( hIvasRend ) != AudioFileReader_getNumChannels( audioReader ) )
    {
        fprintf( stderr, "Number of channels in input file does not match selected configuration\n" );
        exit( -1 );
@@ -645,7 +637,7 @@ int32_t main( int32_t argc, char **argv )
    return 0;
}

static int8_t setInConfig( int16_t numChannels, AUDIO_CONFIG input_config, IVAS_REND_InputConfig *inConfig, IsmPositionProvider *positionProvider )
static int8_t setInConfig( AUDIO_CONFIG input_config, IVAS_REND_InputConfig *inConfig, IsmPositionProvider *positionProvider )
{
    int8_t success; /* flag */
    int16_t i;
@@ -690,10 +682,10 @@ static int8_t setInConfig( int16_t numChannels, AUDIO_CONFIG input_config, IVAS_
        case AUDIO_CONFIG_ISM2:
        case AUDIO_CONFIG_ISM3:
        case AUDIO_CONFIG_ISM4:
            inConfig->numAudioObjects = numChannels;
            positionProvider->numObjects = numChannels;
            inConfig->numAudioObjects = input_config - AUDIO_CONFIG_ISM1 + 1; /* TODO(sgi): Don't do arithemtic on enums, find a better way */
            positionProvider->numObjects = inConfig->numAudioObjects;

            for ( i = 0; i < numChannels; ++i )
            for ( i = 0; i < inConfig->numAudioObjects; ++i )
            {
                inConfig->audioObjects[i].inputChannelIndex = i;
                inConfig->audioObjects[i].gain_dB = 0;
@@ -765,6 +757,20 @@ static IVAS_REND_Ambisonics audioCfgToAmbiEnum( AUDIO_CONFIG cfg )
    return IVAS_REND_AMBISONICS_NONE;
}

static IVAS_REND_BinauralFormat audioCfgToBinauralEnum( AUDIO_CONFIG cfg )
{
    if ( cfg == AUDIO_CONFIG_BINAURAL )
    {
        return IVAS_REND_BINAURAL_DIRECT;
    }
    else if ( cfg == AUDIO_CONFIG_BINAURAL_ROOM )
    {
        return IVAS_REND_BINAURAL_ROOM;
    }

    return IVAS_REND_BINAURAL_NONE;
}

static IVAS_REND_MasaTc audioCfgToMasaEnum( AUDIO_CONFIG cfg )
{
    switch ( cfg )
@@ -895,7 +901,7 @@ static AUDIO_CONFIG parseStrToAudioCfg( char *config_str )
    else if ( strncmp( format, "ISM", 3 ) == 0 )
    {
        parseUint8( &format[3], &numObjects );
        return AUDIO_CONFIG_ISM1 + numObjects - 1;
        return AUDIO_CONFIG_ISM1 + numObjects - 1; /* TODO(sgi): Don't do arithemtic on enums, find a better way */
    }
    else if ( strncmp( format, "MASA", 4 ) == 0 )
    {
@@ -1024,7 +1030,7 @@ static int8_t parseOutConfig( char *configString, IVAS_REND_OutputConfig *outCon
            break;
        case AUDIO_CONFIG_BINAURAL:
        case AUDIO_CONFIG_BINAURAL_ROOM:
            outConfig->binaural = 1;
            outConfig->binauralFormat = audioCfgToBinauralEnum( outCfg );
            break;
        case AUDIO_CONFIG_META:
            /* handled by parseConfigFile() */
@@ -1116,24 +1122,18 @@ static CmdlnArgs defaultArgs( void )
    args.outputFilePath[0] = '\0';
    args.sampleRate = -1;

#ifdef RAM_COUNTING_TOOL
    /* Zero-initialize entire input and output config struct. This is only needed when RAM counting
    is active - when freeing memory, it reads all bytes from these structs, which results in msan
    failures without full initialization. Without RAM counting the uninitialized struct members will
    not be accessed. */
    memset( &args.inConfig, 0, sizeof( args.inConfig ) );
    memset( &args.outConfig, 0, sizeof( args.outConfig ) );
#endif
    args.inConfig.inSetupCustom = NULL;
    args.inConfig.numAudioObjects = 0;
    args.inConfig.numAmbisonicsBuses = 0;
    args.inConfig.numMultiChannelBuses = 0;
    args.inConfig.numMasaBuses = 0;

    args.outConfig.ambisonics = IVAS_REND_AMBISONICS_NONE;
    args.outConfig.speakerLayout = IVAS_REND_SPEAKER_LAYOUT_NONE;
    args.outConfig.outSetupCustom = NULL;

    args.outConfig.binaural = 0;
    args.outConfig.binauralFormat = IVAS_REND_BINAURAL_NONE;

    args.orientationTracking = IVAS_ORIENT_TRK_REF;
    args.trajectoryFile[0] = '\0';
    args.customHrtfFile[0] = '\0';
+10 −0
Original line number Diff line number Diff line
@@ -3099,6 +3099,16 @@ ivas_error ivas_sba_get_hoa_dec_matrix(
    const int16_t ambisonics_order                              /* i  : Ambisonics order                        */
);

#ifdef EXT_RENDERER
void ivas_sba_mtx_mult( 
    float output_f[][L_FRAME48k],                               /* i/o: synthesized core-corder transport channels/DirAC output */
    const int16_t output_frame,                                 /* i  : frame length per channel                                */
    const int16_t nchan_in,                                     /* i  : Number of ambisonic channels                            */
    IVAS_OUTPUT_SETUP output_setup,                             /* i  : Output configuration                                    */
    const float *mtx_hoa_decoder                                /* o  : HOA decoding matrix                                     */
);
#endif

/*----------------------------------------------------------------------------------*
 * DirAC prototypes
 *----------------------------------------------------------------------------------*/
+7 −1
Original line number Diff line number Diff line
@@ -46,7 +46,9 @@
 * Local function prototypes
 *-----------------------------------------------------------------------*/

#ifndef EXT_RENDERER
static void ivas_sba_mtx_mult( float output_f[][L_FRAME48k], const int16_t output_frame, const int16_t nchan_in, IVAS_OUTPUT_SETUP output_setup, const float *mtx_hoa_decoder );
#endif
static void ivas_sba_dmx_dec( float sba_data[][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );

#ifdef DEBUG_MODE_DIRAC
@@ -530,12 +532,16 @@ ivas_error ivas_sba_linear_renderer(
 * HOA decoding with LFE insertion
 *-------------------------------------------------------------------*/

#ifdef EXT_RENDERER
void ivas_sba_mtx_mult(
#else
static void ivas_sba_mtx_mult(
#endif
    float output_f[][L_FRAME48k],   /* i/o: synthesized core-coder transport channels/DirAC output  */
    const int16_t output_frame,     /* i  : output frame length per channel                         */
    const int16_t nchan_in,         /* i  : Number of ambisonic channels                            */
    IVAS_OUTPUT_SETUP output_setup, /* i  : Output configuration                                    */
    const float *mtx_hoa_decoder    /* i  : Hoa decoding mtx                                        */
    const float *mtx_hoa_decoder    /* o  : HOA decoding mtx                                        */
)
{
    int16_t i, k, ch_idx;
+289 −127

File changed.

Preview size limit exceeded, changes collapsed.

Loading