Commit 29e5e99b authored by emerit's avatar emerit
Browse files

Merge branch 'main' into fix_hrtf_processing_scripts_for_3rd_party_sofa_support

parents 619f60a4 97140f25
Loading
Loading
Loading
Loading
+124 −30
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ typedef struct
    int32_t sampleRate;
    InputConfig inConfig;
    OutputConfig outConfig;
    char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH];
    char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH];
    int16_t numInMetadataFiles;
    char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
@@ -238,7 +238,7 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_inputMetadata,
        .match = "input_metadata",
        .matchShort = "im",
        .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode",
        .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode. For OMASA, ISM files must be specified first.",
    },
    {
        .id = CmdLnOptionId_outputFile,
@@ -397,6 +397,8 @@ static IVAS_AUDIO_CONFIG ambisonicsOrderToEnum( const int16_t order );

static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders, LfeRoutingConfig **lfeRoutingConfigs );

static void parseCombinedFormatInput( InputConfig *inConfig, char **configString );

static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom );

static CmdlnArgs parseCmdlnArgs( const int argc, char **argv );
@@ -555,25 +557,7 @@ static void setupWithSingleFormatInput(
    strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 );

    /* Depending on input format, prepare metadata reading for ISM or MASA */
    if ( args.inConfig.numMasaBuses != 0 )
    {
        if ( args.inConfig.numMasaBuses != args.numInMetadataFiles )
        {
            fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" );
            exit( -1 );
        }

        for ( int16_t i = 0; i < args.numInMetadataFiles; ++i )
        {
            masaReaders[i] = MasaFileReader_open( args.inMetadataFilePaths[i] );
            if ( masaReaders[i] == NULL )
            {
                fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] );
                exit( -1 );
            }
        }
    }
    else if ( args.inConfig.numAudioObjects != 0 )
    if ( args.inConfig.numAudioObjects != 0 )
    {
        positionProvider->numObjects = args.inConfig.numAudioObjects;
        for ( int16_t i = 0; i < positionProvider->numObjects; ++i )
@@ -596,6 +580,26 @@ static void setupWithSingleFormatInput(
            }
        }
    }
    if ( args.inConfig.numMasaBuses != 0 )
    {
        if ( args.inConfig.numMasaBuses != ( args.numInMetadataFiles - args.inConfig.numAudioObjects ) )
        {
            fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" );
            exit( -1 );
        }

        int16_t reader_idx = 0;
        for ( int16_t i = args.inConfig.numAudioObjects; i < args.numInMetadataFiles; ++i )
        {
            reader_idx = i - args.inConfig.numAudioObjects;
            masaReaders[reader_idx] = MasaFileReader_open( args.inMetadataFilePaths[i] );
            if ( masaReaders[reader_idx] == NULL )
            {
                fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] );
                exit( -1 );
            }
        }
    }

    return;
}
@@ -733,6 +737,10 @@ int main(
        lfeRoutingConfigs[i] = NULL;
    }

#ifdef FIX_1225_DISCLAIMER
    IVAS_REND_PrintDisclaimer();

#endif
    CmdlnArgs args = parseCmdlnArgs( argc, argv );

    if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) ||
@@ -890,6 +898,49 @@ int main(
        exit( -1 );
    }

#ifdef FIX_1225_DISCLAIMER
    fprintf( stdout, "Input audio file:       %s\n", args.inputFilePath );
    fprintf( stdout, "Output audio file:      %s\n\n", args.outputFilePath );

    if ( args.inConfig.numAudioObjects > 0 )
    {
        if ( args.inConfig.numAudioObjects == 1 )
        {
            IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM1 );
        }
        else if ( args.inConfig.numAudioObjects == 2 )
        {
            IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM2 );
        }
        else if ( args.inConfig.numAudioObjects == 3 )
        {
            IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM3 );
        }
        else if ( args.inConfig.numAudioObjects == 4 )
        {
            IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM4 );
        }
    }
    for ( i = 0; i < args.inConfig.numMultiChannelBuses; i++ )
    {
        IVAS_REND_PrintInputConfig( args.inConfig.multiChannelBuses[i].audioConfig );
    }
    for ( i = 0; i < args.inConfig.numMasaBuses; i++ )
    {
        IVAS_REND_PrintInputConfig( args.inConfig.masaBuses[i].audioConfig );
    }
    for ( i = 0; i < args.inConfig.numAmbisonicsBuses; i++ )
    {
        IVAS_REND_PrintInputConfig( args.inConfig.ambisonicsBuses[i].audioConfig );
    }

    if ( ( error = IVAS_REND_PrintConfig( hIvasRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\n IVAS_REND_PrintConfig failed: %s\n\n", ivas_error_to_string( error ) );
        goto cleanup;
    }

#endif
    if ( !isEmptyString( args.customHrtfFilePath ) )
    {
        if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
@@ -2070,16 +2121,11 @@ static bool parseInConfig(
            inConfig->masaBuses[0].gain_dB = 0.0f;
            break;
        case IVAS_AUDIO_CONFIG_OBA:
            /* If input format is objects, parse the characters after "ISM" to get number of objects */
            /* If input format is objects, parse the characters after "ISM" to get
             * number of objects and check for combined formats. */
            {
                char *ptr = NULL;
                inConfig->numAudioObjects = (uint16_t) strtol( inFormatStr + 3, &ptr, 10 );
                if ( ptr == NULL || *ptr != '\0' )
                {
                    /* Failed to parse string as a number */
                    fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr );
                    return false;
                }
                if ( inConfig->numAudioObjects > RENDERER_MAX_ISM_INPUTS )
                {
                    fprintf( stderr, "Too many objects at input. Max %d supported.", RENDERER_MAX_ISM_INPUTS );
@@ -2091,6 +2137,17 @@ static bool parseInConfig(
                    inConfig->audioObjects[i].inputChannelIndex = i;
                    inConfig->audioObjects[i].gain_dB = 0.0f;
                }
                if ( *ptr != '\0' )
                {
                    /* Try to parse combined format */
                    parseCombinedFormatInput( inConfig, &ptr );
                }
                if ( ptr == NULL || *ptr != '\0' )
                {
                    /* Failed to parse string as a number */
                    fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr );
                    return false;
                }
            }
            break;
        case IVAS_AUDIO_CONFIG_INVALID:
@@ -2583,7 +2640,7 @@ static void parseOption(
            }
            break;
        case CmdLnOptionId_inputMetadata:
            assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS );
            assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS );
            for ( int16_t i = 0; i < numOptionValues; ++i )
            {
                strncpy( args->inMetadataFilePaths[i], optionValues[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
@@ -3411,6 +3468,41 @@ static void parseMasa(
    return;
}

static void parseCombinedFormatInput(
    InputConfig *inConfig,
    char **configString )
{
    IVAS_AUDIO_CONFIG audioConfig;
    audioConfig = parseAudioConfig( *configString );

    if ( audioConfig == IVAS_AUDIO_CONFIG_FOA || audioConfig == IVAS_AUDIO_CONFIG_HOA2 || audioConfig == IVAS_AUDIO_CONFIG_HOA3 )
    {
        /* OSBA */
        inConfig->numAmbisonicsBuses = 1;
        inConfig->ambisonicsBuses[0].audioConfig = audioConfig;
        inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects;
        inConfig->ambisonicsBuses[0].gain_dB = -6.f;
        *configString += 4;

        /* Modify input gain for objects too */
        for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i )
        {
            inConfig->audioObjects[i].gain_dB = -6.f;
        }
    }
    else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 )
    {
        /* OMASA */
        inConfig->numMasaBuses = 1;
        inConfig->masaBuses[0].audioConfig = audioConfig;
        inConfig->masaBuses[0].inputChannelIndex = inConfig->numAudioObjects;
        inConfig->masaBuses[0].gain_dB = 0.0f;
        *configString += 5;
    }

    return;
}

static ivas_error parseCustomLayoutFile(
    const char *filePath,
    IVAS_CUSTOM_LS_DATA *pLsSetupCustom )
@@ -3627,6 +3719,8 @@ static void printSupportedAudioConfigs( void )
        "HOA2",
        "HOA3",
        "ISMx (input only)",
        "ISMxSBAy (OSBA, input only)",
        "ISMxMASAy (OMASA, input only)",
        "MASAx",
        "BINAURAL (output only)",
        "BINAURAL_SPLIT_PCM",
+4 −0
Original line number Diff line number Diff line
@@ -47,7 +47,11 @@ int16_t print_disclaimer( FILE *fPtr )
{

    fprintf( fPtr, "\n==================================================================================================\n" );
#ifdef FIX_1225_DISCLAIMER
    fprintf( fPtr, " \n IVAS Codec Version IVAS-FL-2.0\n" );
#else
    fprintf( fPtr, " IVAS Codec Baseline\n" );
#endif
    fprintf( fPtr, " \n" );
    fprintf( fPtr, " Based on EVS Codec (Floating Point) 3GPP TS26.443 Nov 04, 2021,\n" );
    fprintf( fPtr, " Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0\n" );
+2 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */
#define FIX_1228_SAMPLING_RATE_MISMATCH_IN_HRTF_FILE    /* VA: issue 1228: Exit the processing when a HRTF binary file with wrong sampling rate is provided */

#define FIX_1225_DISCLAIMER                             /* VA: issue 1225: Add disclaimer for external renderer + Add info about IVAS reference version */

/* #################### End BE switches ################################## */

@@ -171,6 +171,7 @@
/* all switches in this category should start with "NONBE_" */

#define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR       /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */
#define NONBE_1240_FIX_CORE_SELECTION_ISM_SW            /* VA: issue 1240: Remove the forcing of the TCX core in ISM when switching from a high bitarte to a low one */

/* ##################### End NON-BE switches ########################### */

+4 −2
Original line number Diff line number Diff line
@@ -43,7 +43,9 @@
#include "jbm_pcmdsp_fifo.h"
#include <math.h>
#include <assert.h>
#ifndef FIX_1225_DISCLAIMER
#include <string.h>
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -3883,7 +3885,7 @@ const char *IVAS_DEC_GetErrorMessage(
    return ivas_error_to_string( error );
}


#ifndef FIX_1225_DISCLAIMER
/*---------------------------------------------------------------------*
 * get_channel_config()
 *
@@ -3969,7 +3971,7 @@ static ivas_error get_channel_config(

    return IVAS_ERR_OK;
}

#endif

/*---------------------------------------------------------------------*
 * printConfigInfo_dec( )
+5 −0
Original line number Diff line number Diff line
@@ -172,7 +172,12 @@ void ivas_decision_matrix_enc(
        st->core = ACELP_CORE;
    }

#ifdef NONBE_1240_FIX_CORE_SELECTION_ISM_SW
    /* sanity check: highest bitrates in ISM */
    if ( st->is_ism_format && st->tcxonly && st->total_brate > MAX_ACELP_BRATE_ISM )
#else
    if ( st->is_ism_format && st->tcxonly )
#endif
    {
        st->core = TCX_20_CORE;
    }
Loading