Commit 10f1ad41 authored by vaclav's avatar vaclav
Browse files

- update wrt. cmdl_tools

- cleaning of to-do comments
parent 0df12434
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -72,3 +72,4 @@ Externals/

# coan output files that are created when cleaning out switches
coan_out_*
/lib_rend/ivas_hrtf_destroy.c
+58 −129
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@
#include "wmc_auto.h"


/*------------------------------------------------------------------------------------------*
 * Local constants
 *------------------------------------------------------------------------------------------*/

#define RENDERER_MAX_CLI_ARG_LENGTH       ( FILENAME_MAX )
#define RENDERER_MAX_METADATA_LENGTH      8192
#define RENDERER_MAX_METADATA_LINE_LENGTH 1024
@@ -69,6 +73,11 @@ static
#define SEP_FOLDER '/'
#endif


/*------------------------------------------------------------------------------------------*
 * Local structures
 *------------------------------------------------------------------------------------------*/

typedef struct
{
    uint32_t frameCounter;
@@ -264,96 +273,48 @@ static const CmdLnParser_Option cliOptions[] = {
    },
};

static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option );

static IVAS_REND_AudioConfig ambisonicsOrderToEnum(
    const int16_t order );

static void parseSceneDescriptionFile(
    char *path,
    char *audioFilePath,
    InputConfig *inConfig,
    IsmPositionProvider *positionProvider,
    MasaFileReader **masaReaders );
/*------------------------------------------------------------------------------------------*
 * Local function prototypes
 *------------------------------------------------------------------------------------------*/

static ivas_error parseCustomLayoutFile(
    const char *filePath,
    IVAS_CUSTOM_LS_DATA *pLsSetupCustom );
static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option );

static CmdlnArgs parseCmdlnArgs(
    const int argc,
    char **argv );
static IVAS_REND_AudioConfig ambisonicsOrderToEnum( const int16_t order );

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

static void IsmPositionProvider_getNextFrame(
    IsmPositionProvider *positionProvider,
    ObjectPositionBuffer *objectMetadataBuffer );
static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom );

static void IsmPositionProvider_close(
    IsmPositionProvider *positionProvider );
static CmdlnArgs parseCmdlnArgs( const int argc, char **argv );

static void readFromShorthandMetadata(
    IsmPositionProvider *positionProvider,
    ObjectPositionBuffer *objectMetadataBuffer,
    const uint32_t objIdx );

void getMetadataFromFileReader(
    IsmFileReader *ismReader,
    ObjectPositionBuffer *objectMetadataBuffer,
    const uint32_t objIdx );
static IsmPositionProvider *IsmPositionProvider_open( void );

static void splitConfigFile(
    const char *mdfFilePath,
    char *metadataString,
    uint32_t *metadataStringLength,
    char *wavFileName,
    uint32_t *wavFileNameLength );
static void IsmPositionProvider_getNextFrame( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer );

static char *readNextMetadataChunk(
    char *line,
    const char *delimiter );
static void IsmPositionProvider_close( IsmPositionProvider *positionProvider );

static void parseUint8(
    const char *line,
    uint8_t *ret );
static void readFromShorthandMetadata( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx );

static void parseUint16(
    const char *line,
    uint16_t *ret );
void getMetadataFromFileReader( IsmFileReader *ismReader, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx );

static int8_t parseUint32(
    const char *line,
    uint32_t *ret );
static void splitConfigFile( const char *mdfFilePath, char *metadataString, uint32_t *metadataStringLength, char *wavFileName, uint32_t *wavFileNameLength );

static int8_t parseInt32(
    const char *line,
    int32_t *ret );
static char *readNextMetadataChunk( char *line, const char *delimiter );

static void parseObjectPosition(
    char *line,
    IVAS_REND_AudioObjectPosition *position,
    uint16_t *positionDuration );
static void parseUint8( const char *line, uint8_t *ret );

static void parseMetadata(
    char *metadataString,
    char *inDir,
    InputConfig *inConfig,
    IsmPositionProvider *positionProvider,
    MasaFileReader **masaReaders );
static void parseUint16( const char *line, uint16_t *ret );

static ivas_error parseLfePanMtxFile(
    const char *lfeRoutingMatrixFilePath,
    IVAS_REND_LfePanMtx *lfePanMtx );
static int8_t parseUint32( const char *line, uint32_t *ret );

static void convert_backslash( char *str );
static int8_t parseInt32( const char *line, int32_t *ret );

static void remove_cr( char *str );
static void parseObjectPosition( char *line, IVAS_REND_AudioObjectPosition *position, uint16_t *positionDuration );

static void clearString( char *str );
static void parseMetadata( char *metadataString, char *inDir, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders );

static bool isEmptyString( const char *str );
static ivas_error parseLfePanMtxFile( const char *lfeRoutingMatrixFilePath, IVAS_REND_LfePanMtx *lfePanMtx );

static void printSupportedAudioConfigs( void );

@@ -364,7 +325,14 @@ static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSa
static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer );


static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer buffer, const int16_t chBeginIdx, const int16_t numChannels )
/*------------------------------------------------------------------------------------------*
 * Local functions
 *------------------------------------------------------------------------------------------*/

static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer(
    IVAS_REND_AudioBuffer buffer,
    const int16_t chBeginIdx,
    const int16_t numChannels )
{
    IVAS_REND_ReadOnlyAudioBuffer subBuffer;

@@ -375,6 +343,7 @@ static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer
    return subBuffer;
}


static int16_t getTotalNumInChannels(
    IVAS_REND_HANDLE hIvasRend,
    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS],
@@ -454,6 +423,7 @@ static int16_t getTotalNumInChannels(
    return totalNumInChannels;
}


static void setupWithSingleFormatInput(
    CmdlnArgs args,
    char *audioFilePath,
@@ -506,6 +476,7 @@ static void setupWithSingleFormatInput(
    }
}


static float dBToLin(
    const float gain_dB )
{
@@ -513,7 +484,11 @@ static float dBToLin(
}


/* ============================================================================ */
/*------------------------------------------------------------------------------------------*
 * main()
 *
 * Main External renderer function for command-line interface
 *------------------------------------------------------------------------------------------*/

int main(
    int argc,
@@ -1055,6 +1030,11 @@ int main(
    return 0;
}


/*------------------------------------------------------------------------------------------*
 * Local functions
 *------------------------------------------------------------------------------------------*/

static IVAS_REND_AudioConfig ambisonicsOrderToEnum(
    const int16_t order )
{
@@ -1714,7 +1694,7 @@ void readFromShorthandMetadata(
    return;
}

void IsmPositionProvider_getNextFrame(
static void IsmPositionProvider_getNextFrame(
    IsmPositionProvider *positionProvider,
    ObjectPositionBuffer *objectMetadataBuffer )
{
@@ -1760,7 +1740,8 @@ void IsmPositionProvider_getNextFrame(
    return;
}

void IsmPositionProvider_close( IsmPositionProvider *positionProvider )
static void IsmPositionProvider_close(
    IsmPositionProvider *positionProvider )
{
    uint32_t i;

@@ -2337,6 +2318,8 @@ static void parseSceneDescriptionFile(
    strncat( audioFilePath, inAudioFilePath, inAudioFilePathLen );

    parseMetadata( mtdStr, inDir, inConfig, positionProvider, masaReaders );

    return;
}

static void printSupportedAudioConfigs()
@@ -2430,64 +2413,10 @@ static ivas_error parseLfePanMtxFile(
    }

    fclose( mtxFile );
    return IVAS_ERR_OK;
}

// VE2AT: possibly move these functions to cmdln_parser.c ?
static void convert_backslash(
    char *str )
{
    int16_t i, len;

    /* check that all backslashes are correct on the given platform */
    len = (int16_t) strlen( str );

    for ( i = 0; i < len; i++ )
    {
#ifdef _WIN32
        if ( str[i] == '/' )
        {
            str[i] = '\\';
        }
#else
        if ( str[i] == '\\' )
        {
            str[i] = '/';
        }
#endif
    }

    return;
}

static void remove_cr( char *str )
{
    char *pos;

    /* remove all \r characters from the string */
    pos = strchr( str, '\r' );
    while ( pos != NULL )
    {
        strcpy( pos, pos + 1 );
        pos = strchr( pos, '\r' );
    }

    return;
}

static void clearString(
    char *str )
{
    str[0] = '\0';

    return;
    return IVAS_ERR_OK;
}

static bool isEmptyString(
    const char *str )
{
    return str[0] == '\0';
}

/*--------------------------------------------------------------------------*
 * convertInputBuffer()
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
#endif
#include "wmc_auto.h"

//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file; Could common_api_types.h be included here while "IVAS_REND_AudioObjectPosition" is part of it?
//VE2AT: dependency on "IVAS_REND_AudioObjectPosition" needs to be solved in this file


/*---------------------------------------------------------------------*
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
   the United Nations Convention on Contracts on the International Sales of Goods.

*******************************************************************************************************/
// VE2AT: move these low-level functions to lib_com?

#include <stdint.h>
#include "options.h"
#include "ivas_cnst.h"
+84 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
*******************************************************************************************************/

#include "cmdl_tools.h"
#include <string.h>

/*---------------------------------------------------------------------*
 * to_upper()
@@ -141,3 +142,86 @@ bool is_number( const char *str )

    return true;
}


/*---------------------------------------------------------------------*
 * convert_backslash()
 *
 * 
 *---------------------------------------------------------------------*/

void convert_backslash(
    char *str )
{
    int16_t i, len;

    /* check that all backslashes are correct on the given platform */
    len = (int16_t) strlen( str );

    for ( i = 0; i < len; i++ )
    {
#ifdef _WIN32
        if ( str[i] == '/' )
        {
            str[i] = '\\';
        }
#else
        if ( str[i] == '\\' )
        {
            str[i] = '/';
        }
#endif
    }

    return;
}

/*---------------------------------------------------------------------*
 * remove_cr()
 *
 *
 *---------------------------------------------------------------------*/

void remove_cr(
    char *str )
{
    char *pos;

    /* remove all \r characters from the string */
    pos = strchr( str, '\r' );
    while ( pos != NULL )
    {
        strcpy( pos, pos + 1 );
        pos = strchr( pos, '\r' );
    }

    return;
}


/*---------------------------------------------------------------------*
 * clearString()
 *
 *
 *---------------------------------------------------------------------*/

void clearString(
    char *str )
{
    str[0] = '\0';

    return;
}


/*---------------------------------------------------------------------*
 * isEmptyString()
 *
 *
 *---------------------------------------------------------------------*/

bool isEmptyString(
    const char *str )
{
    return str[0] == '\0';
}
Loading