Commit 8dc103b0 authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into 532-md-coding-in-ism-inactive-frames

parents b9ac8068 a24d3b7e
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -202,14 +202,18 @@
    <ClCompile Include="..\lib_rend\ivas_sba_rendering.c" />
    <ClCompile Include="..\lib_rend\ivas_allrad_dec.c" />
    <ClCompile Include="..\lib_rend\ivas_crend.c" />
    <ClCompile Include="..\lib_rend\ivas_dirac_ana.c" />
    <ClCompile Include="..\lib_rend\ivas_efap.c" />
    <ClCompile Include="..\lib_rend\ivas_limiter.c" />
    <ClCompile Include="..\lib_rend\ivas_masa_merge.c" />
    <ClCompile Include="..\lib_rend\ivas_mcmasa_ana.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer_hrFilt.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer_mix.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer_sfx.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer_sources.c" />
    <ClCompile Include="..\lib_rend\ivas_objectRenderer_vec.c" />
    <ClCompile Include="..\lib_rend\ivas_omasa_ana.c" />
    <ClCompile Include="..\lib_rend\ivas_orient_trk.c" />
    <ClCompile Include="..\lib_rend\ivas_output_init.c" />
    <ClCompile Include="..\lib_rend\ivas_render_config.c" />
+174 −1
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@
#include "ism_file_reader.h"
#include "ls_custom_file_reader.h"
#include "masa_file_reader.h"
#ifdef MASA_PREREND
#include "masa_file_writer.h"
#endif
#include "prot.h"
#include "render_config_reader.h"
#include "wmc_auto.h"
@@ -227,7 +230,7 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_sampleRate,
        .match = "sample_rate",
        .matchShort = "fs",
        .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs", /* TODO(sgi): Add sampling rate to scene description files */
        .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs",
    },
    {
        .id = CmdLnOptionId_trajFile,
@@ -443,6 +446,9 @@ static int16_t getTotalNumInChannels(
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }
#ifdef MASA_PREREND
        IVAS_REND_GetNumAllObjects( hIvasRend, &numInputChannels ); /* In case of MASA output, modify the numInputChannels to contain all objects. Otherwise, keep the original value. */
#endif
        totalNumInChannels += numInputChannels;
    }

@@ -571,6 +577,9 @@ int main(
#endif
    RenderConfigReader *renderConfigReader = NULL;
    MasaFileReader *masaReaders[RENDERER_MAX_MASA_INPUTS];
#ifdef MASA_PREREND
    MasaFileWriter *masaWriter = NULL;
#endif
    IVAS_MASA_METADATA_HANDLE hMasaMetadata[RENDERER_MAX_MASA_INPUTS];
    char audioFilePath[FILENAME_MAX];
    AudioFileReader *audioReader = NULL;
@@ -721,6 +730,26 @@ int main(
        setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders );
    }

#ifdef MASA_PREREND
    /* Check that there is allowed configuration for MASA format output */
    if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
    {
        if ( args.inConfig.numMasaBuses == 0 )
        {
            fprintf( stderr, "\nInvalid configuration - Merging to MASA output requires MASA input and at least one another input to be present\n" );
            fprintf( stderr, "\nMASA input is missing\n" );
            exit( -1 );
        }

        if ( args.inConfig.numAudioObjects == 0 && args.inConfig.numMultiChannelBuses == 0 && args.inConfig.numAmbisonicsBuses == 0 )
        {
            fprintf( stderr, "\nInvalid configuration - Merging to MASA output requires MASA input and at least one another input to be present\n" );
            fprintf( stderr, "\nNo object, multi-channel, or Ambisonic input present.\n" );
            exit( -1 );
        }
    }
#endif

    if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening file: %s\n", audioFilePath );
@@ -827,6 +856,25 @@ int main(
        }
    }

#ifdef MASA_PREREND
    /* Set up MASA writer for MASA output */
    if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
    {
        MasaFileWriter_open( args.outputFilePath, true, &masaWriter ); /* No delay for audio in renderer, so calling metadata writer in delayCompensated mode, i.e., no delay applied to meta */
        if ( masaWriter == NULL )
        {
            fprintf( stderr, "Could not open MASA metadata file %s\n", args.outputFilePath );
            exit( -1 );
        }
    }

    /* Set the total number of objects */
    if ( args.inConfig.numAudioObjects > 0 )
    {
        IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects );
    }
#endif

    IVAS_REND_LfePanMtx lfePanMatrix;

    /* parse input LFE panning matrix */
@@ -937,6 +985,14 @@ int main(
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }

#ifdef MASA_PREREND
        /* With MASA output, all objects are handled at once, so add only one input having all objects in it */
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
        {
            break;
        }
#endif
    }

    for ( i = 0; i < args.inConfig.numAmbisonicsBuses; ++i )
@@ -1165,6 +1221,43 @@ int main(

        for ( i = 0; i < args.inConfig.numAudioObjects; ++i )
        {
#ifdef MASA_PREREND
            if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
            {
                if ( i == 0 )
                {
                    IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects );

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

                if ( ( error = IVAS_REND_FeedInputObjectMetadataToOMasa( hIvasRend, i, mtdBuffer.positions[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
            else
            {
                IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 );

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

                if ( ( error = IVAS_REND_FeedInputObjectMetadata( hIvasRend, ismIds[i], mtdBuffer.positions[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                    exit( -1 );
                }
            }
#else
            IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 );

            if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK )
@@ -1178,6 +1271,7 @@ int main(
                fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
#endif
        }

        for ( i = 0; i < args.inConfig.numAmbisonicsBuses; ++i )
@@ -1269,6 +1363,82 @@ int main(
            delayNumSamples -= (int16_t) outBufferSize;
        }

#ifdef MASA_PREREND
        /* Write MASA metadata for MASA outputs */
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
        {
            IVAS_REND_AudioConfigType inputType1;
            IVAS_REND_AudioConfigType inputType2;
            MASA_DECODER_EXT_OUT_META_HANDLE hMetaOutput;
            int16_t numInputFormats;

            inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN;
            inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN;
            hMetaOutput = NULL;

            numInputFormats = 0;
            if ( args.inConfig.numAmbisonicsBuses > 0 )
            {
                numInputFormats++;
                inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS;
            }
            if ( args.inConfig.numMultiChannelBuses > 0 )
            {
                numInputFormats++;
                if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN )
                {
                    inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED;
                }
            }
            if ( args.inConfig.numMasaBuses > 0 )
            {
                numInputFormats++;
                if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN )
                {
                    inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA;
                }
            }
            if ( args.inConfig.numAudioObjects > 0 )
            {
                numInputFormats++;
                if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN )
                {
                    inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED;
                }
            }

            if ( numInputFormats == 1 )
            {
                IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 );
            }
            else
            {
                if ( args.inConfig.numAmbisonicsBuses > 0 && args.inConfig.numMultiChannelBuses > 0 )
                {
                    inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED;
                    IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 );
                }

                if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 ) && args.inConfig.numMasaBuses > 0 )
                {
                    inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA;
                    IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 );
                }

                if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 )
                {
                    inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED;
                    IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 );
                }
            }

            if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMetaOutput ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
            }
        }
#endif

        frame++;
        if ( !args.quietModeEnabled )
        {
@@ -1322,6 +1492,9 @@ int main(
    {
        LfeRoutingConfig_close( lfeRoutingConfigs[i] );
    }
#endif
#ifdef MASA_PREREND
    MasaFileWriter_close( &masaWriter );
#endif
    AudioFileReader_close( &audioReader );
    AudioFileWriter_close( &audioWriter );
+0 −1
Original line number Diff line number Diff line
@@ -742,7 +742,6 @@ void init_tcx_window_cfg(
    hTcxCfg->tcx_mdct_window_min_length = (int16_t) ( sr_core * INV_CLDFB_BANDWIDTH );
    hTcxCfg->tcx_mdct_window_min_lengthFB = (int16_t) ( input_Fs * INV_CLDFB_BANDWIDTH );
    /* save complexity by copying the small windows if they have the same length */
    /* TODO: is this always the case ? */
    if ( hTcxCfg->tcx_mdct_window_min_length == hTcxCfg->tcx_mdct_window_trans_length )
    {
        mvr2r( hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_min_length );
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ typedef enum
    IVAS_ERR_INVALID_SAMPLING_RATE,
    IVAS_ERR_NOT_CONFIGURED,
    IVAS_ERR_INVALID_STEREO_MODE,
    IVAS_ERR_INVALID_CICP_INDEX, /* ToDo: rename, CICP not used in IVAS anymore */
    IVAS_ERR_INVALID_MC_LAYOUT,
    IVAS_ERR_INVALID_BITRATE,
    IVAS_ERR_INVALID_MASA_CONFIG,
    IVAS_ERR_TOO_MANY_INPUTS,
@@ -193,7 +193,7 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
            return "Handle has not been configured";
        case IVAS_ERR_INVALID_STEREO_MODE:
            return "Invalid stereo mode";
        case IVAS_ERR_INVALID_CICP_INDEX:
        case IVAS_ERR_INVALID_MC_LAYOUT:
            return "Invalid speaker layout";
        case IVAS_ERR_INVALID_BITRATE:
            return "Invalid bitrate";
+4 −0
Original line number Diff line number Diff line
@@ -406,7 +406,11 @@ static int16_t ivas_param_mc_get_num_param_bands(
            switch ( ivas_total_brate )
            {
                case IVAS_128k:
#ifdef FIX_122_MC_DECODER_COMPLEXITY
                    num_parameter_bands = 14;
#else
                    num_parameter_bands = 20;
#endif
                    break;
                case IVAS_160k:
                    num_parameter_bands = 20;
Loading