Commit 5a3e89cd authored by TYAGIRIS's avatar TYAGIRIS
Browse files

addressing review comments

parent ce47e6f5
Loading
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ int main( int argc, char **argv )
{
    (void) argc;
    (void) argv;
    isar_void_func();
    ISAR_POST_REND_void_func();
    return 0;
}

@@ -68,10 +68,6 @@ int main( int argc, char **argv )
 *------------------------------------------------------------------------------------------*/

#define POST_REND_MAX_CLI_ARG_LENGTH ( FILENAME_MAX )
#define POST_REND_MAX_METADATA_LENGTH      8192
#define POST_REND_MAX_METADATA_LINE_LENGTH 1024

#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ )

#define ISAR_MAX16B_FLT 32767.0f
#define ISAR_MIN16B_FLT ( -32768.0f )
@@ -117,7 +113,7 @@ typedef struct
    int32_t sampleRate;
    InputConfig inConfig;
    OutputConfig outConfig;
    char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH];
    char inMetadataFilePaths[RENDERER_MAX_ISAR_MD_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH];
    int16_t numInMetadataFiles;
    char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH];
    char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH];
@@ -456,7 +452,7 @@ static CmdlnArgs defaultArgs(

    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;

    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    for ( int32_t i = 0; i < RENDERER_MAX_ISAR_MD_INPUTS; ++i )
    {
        clearString( args.inMetadataFilePaths[i] );
    }
@@ -500,7 +496,7 @@ static void parseOption(
            }
            break;
        case CmdLnOptionId_inputMetadata:
            assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS );
            assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS );
            for ( int16_t i = 0; i < numOptionValues; ++i )
            {
                strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
+19 −240
Original line number Diff line number Diff line
@@ -66,10 +66,6 @@
#define RENDERER_MAX_METADATA_LENGTH      8192
#define RENDERER_MAX_METADATA_LINE_LENGTH 1024

#ifdef SPLIT_REND_WITH_HEAD_ROT
#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ )
#endif

#define IVAS_MAX16B_FLT 32767.0f
#define IVAS_MIN16B_FLT ( -32768.0f )

@@ -138,10 +134,6 @@ typedef struct
    IVAS_CUSTOM_LS_DATA inSetupCustom;
    RendererInput masaBuses[RENDERER_MAX_MASA_INPUTS];
    uint16_t numMasaBuses;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    RendererInput binBuses[RENDERER_MAX_BIN_INPUTS];
    uint16_t numBinBuses;
#endif
} InputConfig;

typedef struct
@@ -478,13 +470,7 @@ static int16_t getTotalNumInChannels(
    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS],
    IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS],
    IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS],
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS],
    IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS]
#else
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS]
#endif
)
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS] )
{
    int16_t totalNumInChannels = 0;
    int16_t i, numInputChannels;
@@ -561,24 +547,6 @@ static int16_t getTotalNumInChannels(
        totalNumInChannels += numInputChannels;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i )
    {
        if ( splitBinIds[i] == 0 )
        {
            /* Skip inactive inputs */
            continue;
        }

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

    return totalNumInChannels;
}

@@ -587,15 +555,7 @@ static void setupWithSingleFormatInput(
    CmdlnArgs args,
    char *audioFilePath,
    IsmPositionProvider *positionProvider,
#ifdef SPLIT_REND_WITH_HEAD_ROT
    MasaFileReader **masaReaders,
    SplitFileReadWrite **hhSplitRendFileReadWrite,
    IVAS_REND_BitstreamBuffer *hBitsBuffer

#else
    MasaFileReader **masaReaders
#endif
)
    MasaFileReader **masaReaders )
{
    /* With single-format input, inputFilePath is the path to input audio file. */
    strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 );
@@ -642,22 +602,6 @@ static void setupWithSingleFormatInput(
            }
        }
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    else if ( args.inConfig.numBinBuses != 0 )
    {
        *hhSplitRendFileReadWrite = NULL;
        if ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            ivas_error error;
            error = split_rend_reader_open( hhSplitRendFileReadWrite, args.inMetadataFilePaths[0], &hBitsBuffer->config.codec, &hBitsBuffer->config.poseCorrection, &hBitsBuffer->config.codec_frame_size_ms );
            if ( error != IVAS_ERR_OK )
            {
                fprintf( stderr, "Could not open split rend metadata file %s\n", args.inMetadataFilePaths[0] );
                exit( -1 );
            }
        }
    }
#endif

    return;
}
@@ -692,21 +636,6 @@ static int16_t get_cldfb_in_flag(
    return cldfb_in_flag;
}


static int16_t is_split_post_rend_mode(
    CmdlnArgs *args )
{
    int16_t flag;

    flag = 0;
    if ( args->inConfig.numBinBuses > 0 && ( args->inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        flag = 1;
    }

    return flag;
}

static int16_t is_split_pre_rend_mode(
    CmdlnArgs *args )
{
@@ -787,7 +716,6 @@ int main(
    int32_t delayTimeScale = 0;
    int16_t i, numChannels;
    ivas_error error = IVAS_ERR_OK;
    bool splitBinNeedsNewFrame = true;

#ifdef WMOPS
    reset_wmops();
@@ -903,11 +831,7 @@ int main(
    else
    {
        /* With single-format input, all information is given on command line. */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders, &hSplitRendFileReadWrite, &bitsBuffer );
#else
        setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders );
#endif
    }

    /* Check that there is allowed configuration for MASA format output */
@@ -928,45 +852,14 @@ int main(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*if split renderer is running in post renderer mode*/
    if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
    {
        error = split_rend_reader_open( &hSplitRendFileReadWrite, args.inputFilePath, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection,
                                        &bitsBuffer.config.codec_frame_size_ms );
        if ( error != IVAS_ERR_OK )
        {
            fprintf( stderr, "Could not open split rend metadata file %s\n", args.inputFilePath );
            exit( -1 );
        }
        audioReader = NULL;
    }
    else
    {
#endif
    if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening file: %s\n", audioFilePath );
        exit( -1 );
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    int32_t inFileSampleRate = 0;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( audioReader != NULL )
    {
#endif
    error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
    else
    {
        inFileSampleRate = args.sampleRate;
    }
#endif

    switch ( error )
    {
        case IVAS_ERR_OK:
@@ -995,19 +888,13 @@ int main(
    }

    int16_t inFileNumChannels = 0;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( audioReader != NULL )
    {
#endif
    error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels );
    if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN )
    {
        fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) );

    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
@@ -1197,11 +1084,8 @@ int main(
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( !is_split_post_rend_mode( &args ) )
        {
        CLDFBframeSize_smpls = frameSize_smpls * 2;
        cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig );
        }
#endif
    }

@@ -1264,9 +1148,6 @@ int main(
    IVAS_REND_InputId ismIds[RENDERER_MAX_ISM_INPUTS];
    IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS];
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS];
#endif

    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ )
    {
@@ -1284,12 +1165,6 @@ int main(
    {
        masaIds[i] = 0u;
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ )
    {
        splitBinIds[i] = 0u;
    }
#endif

    for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i )
    {
@@ -1407,23 +1282,6 @@ int main(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( i = 0; i < args.inConfig.numBinBuses; ++i )
    {
        if ( ( error = IVAS_REND_AddInput( hIvasRend, args.inConfig.binBuses[i].audioConfig, &splitBinIds[i] ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
        }

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

    for ( i = 0; i < args.inConfig.numMasaBuses; ++i )
    {
        if ( ( error = IVAS_REND_AddInput( hIvasRend, args.inConfig.masaBuses[i].audioConfig, &masaIds[i] ) ) != IVAS_ERR_OK )
@@ -1439,11 +1297,7 @@ int main(
        }
    }

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

    if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels )
    {
@@ -1555,7 +1409,7 @@ int main(

    memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) );

    if ( is_split_pre_rend_mode( &args ) || is_split_post_rend_mode( &args ) )
    if ( is_split_pre_rend_mode( &args ) )
    {
        bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE;
    }
@@ -1614,42 +1468,15 @@ int main(
        num_in_channels = inBuffer.config.numChannels;
        const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0;

#ifdef SPLIT_REND_WITH_HEAD_ROT
        numSamplesRead = 0;
        if ( ( hSplitRendFileReadWrite != NULL ) && is_split_post_rend_mode( &args ) && splitBinNeedsNewFrame )
        {
            ivas_error error_tmp;
            numSamplesRead = (int16_t) inBufferSize;
            error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead,
                                                        &bitsBuffer.config.bitsWritten );
            if ( error_tmp != IVAS_ERR_OK )
            {
                if ( error_tmp == IVAS_ERR_END_OF_FILE )
                {
        numSamplesRead = 0;
                }
                else
                {
                    fprintf( stderr, "\nUnable to read from bitstream file!\n" );
                    exit( -1 );
                }
            }
        }

        if ( audioReader != NULL )
        {
#endif
        /* Read the input data */
        if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError reading from file %s\n", audioFilePath );
            exit( -1 );
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        }
#endif

        if ( numSamplesRead == 0 && splitBinNeedsNewFrame )
        if ( numSamplesRead == 0 )
        {
            /* end of input data */
            break;
@@ -1738,25 +1565,6 @@ int main(
            }
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        /* Read from split renderer bfi file if specified */
        if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame )
        {
            int16_t bfi;
            if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }

            if ( ( error = IVAS_REND_SetSplitRendBFI( hIvasRend, bfi ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in IVAS_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) );
                exit( -1 );
            }
        }
#endif

        /* Read from external orientation file if specified */
        if ( externalOrientationFileReader != NULL )
        {
@@ -1947,15 +1755,6 @@ int main(
                    exit( -1 );
                }

#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( is_split_post_rend_mode( &args ) && ( hSplitRendFileReadWrite != NULL ) )
                {
                    uint32_t pre_rend_delay_ns;
                    split_rend_read_pre_rend_delay_ns( hSplitRendFileReadWrite, &pre_rend_delay_ns );
                    delayNumSamples += (int16_t) roundf( (float) pre_rend_delay_ns * delayTimeScale / 1000000000.f );
                }
#endif

                delayNumSamples_orig = delayNumSamples;
            }
            else
@@ -2258,9 +2057,6 @@ static bool parseInConfig(
    inConfig->numAmbisonicsBuses = 0;
    inConfig->numMultiChannelBuses = 0;
    inConfig->numMasaBuses = 0;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    inConfig->numBinBuses = 0;
#endif

    /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */
    strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 );
@@ -2298,15 +2094,6 @@ static bool parseInConfig(
            inConfig->ambisonicsBuses[0].inputChannelIndex = 0;
            inConfig->ambisonicsBuses[0].gain_dB = 0.0f;
            break;
#ifdef SPLIT_REND_WITH_HEAD_ROT
        case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
        case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
            inConfig->numBinBuses = 1;
            inConfig->binBuses[0].audioConfig = audioConfig;
            inConfig->binBuses[0].inputChannelIndex = 0;
            inConfig->binBuses[0].gain_dB = 0.0f;
            break;
#endif
        case IVAS_AUDIO_CONFIG_MASA1:
        case IVAS_AUDIO_CONFIG_MASA2:
            inConfig->numMasaBuses = 1;
@@ -2660,18 +2447,10 @@ static bool checkRequiredArgs(
        missingRequiredArg = true;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 ||
                                      args.inConfig.numAmbisonicsBuses != 0 ||
                                      args.inConfig.numMultiChannelBuses != 0 ||
                                      args.inConfig.numMasaBuses != 0 ||
                                      args.inConfig.numBinBuses != 0;
#else
    const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 ||
                                      args.inConfig.numAmbisonicsBuses != 0 ||
                                      args.inConfig.numMultiChannelBuses != 0 ||
                                      args.inConfig.numMasaBuses != 0;
#endif

    if ( !args.sceneDescriptionInput && !singleInputSpecified )
    {
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ typedef struct _IVAS_JBM_TRACE_DATA
#define ISAR_MAX_SPLIT_REND_BITRATE                   768000
#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 )
#define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ      1
#define SPLIT_REND_BITS_BUFF_SIZE                     ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ )

typedef enum
{
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "isar_stat.h"
#include "prot.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "common_api_types.h"
#include "lib_isar_pre_rend.h"
#endif
#include <assert.h>
+0 −3
Original line number Diff line number Diff line
@@ -65,15 +65,12 @@ typedef enum

#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */

#define SPLIT_REND_DECOR_ALPHA           0.25f
#define SPLIT_REND_MAX_YAW_ONLY_POSES    2
#define SPLIT_REND_MAX_PITCH_ONLY_POSES  2
#define SPLIT_REND_MAX_ROLL_ONLY_POSES   2
#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2
#define MAX_EXTRAPOLATION_ANGLE          15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/

#define SPLIT_REND_MAX_DOF 3

#define MAX_HEAD_ROT_POSES           ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES )
#define MAX_SPLIT_REND_MD_BANDS      20
#define MAX_SPLIT_MD_SUBFRAMES       1
Loading