Commit 20deaa6f authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_296_CFG_LFE_SCENE_DESC

parent c1632b94
Loading
Loading
Loading
Loading
+0 −92
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ typedef struct
    uint16_t durationCounters[RENDERER_MAX_ISM_INPUTS];                /* Number of frames spent at current position */
} IsmPositionProvider;

#ifdef FIX_296_CFG_LFE_SCENE_DESC
typedef struct
{
    float lfe_azi;
@@ -103,7 +102,6 @@ typedef struct
    float lfe_gain_dB;
    char lfe_routing_mtx[FILENAME_MAX];
} LfeRoutingConfig;
#endif
typedef struct
{
    IVAS_REND_AudioConfig audioConfig;
@@ -355,11 +353,7 @@ static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_

static IVAS_REND_AudioConfig ambisonicsOrderToEnum( const int16_t order );

#ifdef FIX_296_CFG_LFE_SCENE_DESC
static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders, LfeRoutingConfig **lfeRoutingConfigs );
#else
static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders );
#endif

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

@@ -371,10 +365,8 @@ static void IsmPositionProvider_getNextFrame( IsmPositionProvider *positionProvi

static void IsmPositionProvider_close( IsmPositionProvider *positionProvider );

#ifdef FIX_296_CFG_LFE_SCENE_DESC
static LfeRoutingConfig *LfeRoutingConfig_open( void );
static void LfeRoutingConfig_close( LfeRoutingConfig *lfeRoutingCfg );
#endif

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

@@ -394,11 +386,7 @@ static int8_t parseInt32( const char *line, int32_t *ret );

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

#ifdef FIX_296_CFG_LFE_SCENE_DESC
static void parseMetadata( char *metadataString, char *inDir, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders, LfeRoutingConfig **lfeRoutingConfigs );
#else
static void parseMetadata( char *metadataString, char *inDir, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders );
#endif

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

@@ -596,9 +584,7 @@ int main(
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
    IsmPositionProvider *positionProvider;
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS];
#endif
    RenderConfigReader *renderConfigReader = NULL;
    MasaFileReader *masaReaders[RENDERER_MAX_MASA_INPUTS];
#ifdef MASA_PREREND
@@ -636,12 +622,10 @@ int main(
        hMasaMetadata[i] = NULL;
    }

#ifdef FIX_296_CFG_LFE_SCENE_DESC
    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i )
    {
        lfeRoutingConfigs[i] = NULL;
    }
#endif

    CmdlnArgs args = parseCmdlnArgs( argc, argv );

@@ -737,16 +721,12 @@ int main(
    if ( args.sceneDescriptionInput )
    {
        /* With scene description input, inputFilePath is the path to the scene description file. Parse it. */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
        parseSceneDescriptionFile( args.inputFilePath,
                                   audioFilePath,
                                   &args.inConfig,
                                   positionProvider,
                                   masaReaders,
                                   lfeRoutingConfigs );
#else
        parseSceneDescriptionFile( args.inputFilePath, audioFilePath, &args.inConfig, positionProvider, masaReaders );
#endif
    }
    else
    {
@@ -953,11 +933,7 @@ int main(
        {
            if ( args.lfePanningEnabled )
            {
#ifdef FIX_296_CFG_LFE_SCENE_DESC
                fprintf( stderr, "Warning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" );
#else
                fprintf( stdout, "Warning LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" );
#endif
                args.lfePanningEnabled = false;
            }

@@ -976,7 +952,6 @@ int main(
                exit( -1 );
            }
        }
#ifdef FIX_296_CFG_LFE_SCENE_DESC
        else
        {
            /* check for configuration from scene description file */
@@ -1008,7 +983,6 @@ int main(
                }
            }
        }
#endif
    }

    for ( i = 0; i < args.inConfig.numAudioObjects; ++i )
@@ -1526,12 +1500,10 @@ int main(
    {
        MasaFileReader_close( &masaReaders[i] );
    }
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i )
    {
        LfeRoutingConfig_close( lfeRoutingConfigs[i] );
    }
#endif
#ifdef MASA_PREREND
    MasaFileWriter_close( &masaWriter );
#endif
@@ -2045,13 +2017,8 @@ static CmdlnArgs defaultArgs(

    args.lfePanningEnabled = false;
    args.lfeConfigGain = 1.0f;
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    args.lfeConfigAzimuth = 0.f;
    args.lfeConfigElevation = 0.f;
#else
    args.lfeConfigAzimuth = 0;
    args.lfeConfigElevation = 0;
#endif

    args.lfeCustomRoutingEnabled = false;
    clearString( args.inLfePanningMatrixFile );
@@ -2236,7 +2203,6 @@ IsmPositionProvider *IsmPositionProvider_open(
    return ipp;
}

#ifdef FIX_296_CFG_LFE_SCENE_DESC
LfeRoutingConfig *LfeRoutingConfig_open(
    void )
{
@@ -2262,7 +2228,6 @@ void LfeRoutingConfig_close(

    return;
}
#endif

void getMetadataFromFileReader(
    IsmFileReader *ismReader,
@@ -2553,12 +2518,10 @@ static int8_t parseInt32(

static void parseOptionalInputValues(
    char *line,
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    float *lfe_gain_dB,
    float *lfe_pos_azi,
    float *lfe_pos_ele,
    char *lfe_pan_mtx_filename,
#endif
    float *gain_dB )
{
    char *parse_pos;
@@ -2570,7 +2533,6 @@ static void parseOptionalInputValues(

    /* Set default values, in case some values are not specified */
    *gain_dB = 0.f;
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    if ( lfe_gain_dB != NULL )
    {
        *lfe_gain_dB = 0.f;
@@ -2587,7 +2549,6 @@ static void parseOptionalInputValues(
    {
        *lfe_pan_mtx_filename = '\0';
    }
#endif

    /* Save parsing position - will have to be passed to strtok to resume parsing after using strtok with non-NULL value below */
    parse_pos = readNextMetadataChunk( line, "\n" );
@@ -2604,15 +2565,10 @@ static void parseOptionalInputValues(

            if ( *endptr != '\0' )
            {
#ifdef FIX_296_CFG_LFE_SCENE_DESC
                fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value );
#else
                fprintf( stderr, "Cannot parse string string \"%s\" as a float value\n", value );
#endif
                exit( -1 );
            }
        }
#ifdef FIX_296_CFG_LFE_SCENE_DESC
        else if ( ( strcmp( key, "lfe_gain_dB" ) == 0 ) && lfe_gain_dB != NULL )
        {
            *lfe_gain_dB = (float) strtod( value, &endptr );
@@ -2647,7 +2603,6 @@ static void parseOptionalInputValues(
        {
            strncpy( lfe_pan_mtx_filename, value, FILENAME_MAX - 1 );
        }
#endif
        else
        {
            fprintf( stderr, "Unsupported optional key: %s\n", key );
@@ -2733,11 +2688,7 @@ static void parseIsm(
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->audioObjects[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->audioObjects[idx].gain_dB );
#endif

    return;
}
@@ -2758,11 +2709,7 @@ static void parseSba(
    inConfig->ambisonicsBuses[idx].audioConfig = ambisonicsOrderToEnum( ambiOrder );

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->ambisonicsBuses[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->ambisonicsBuses[idx].gain_dB );
#endif

    return;
}
@@ -2770,9 +2717,7 @@ static void parseSba(
static void parseMc(
    char *line,
    InputConfig *inConfig,
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    LfeRoutingConfig **lfeRoutingConfigs,
#endif
    const int32_t idx )
{
    readNextMetadataChunk( line, "\n" );
@@ -2781,7 +2726,6 @@ static void parseMc(

    readNextMetadataChunk( line, "\n" );
    IVAS_REND_AudioConfig cfg = parseAudioConfig( line );
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    /* Try to use the given string as a path to a custom loudspeaker layout file. */
    if ( cfg == IVAS_REND_AUDIO_CONFIG_UNKNOWN )
    {
@@ -2797,19 +2741,12 @@ static void parseMc(
        inConfig->multiChannelBuses[idx].inputChannelIndex = 0;
        inConfig->multiChannelBuses[idx].gain_dB = 0.0f;
    }
#else
    if ( cfg == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
    {
        parseCustomLayoutFile( line, &inConfig->inSetupCustom );
    }
#endif
    else
    {
        inConfig->multiChannelBuses[idx].audioConfig = cfg;
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    bool lfe_panningEnabled;
    float lfe_gain_dB, lfe_azi, lfe_ele;
    char lfe_routing_mtx[FILENAME_MAX];
@@ -2842,9 +2779,6 @@ static void parseMc(
            convert_backslash( lfeRoutingConfigs[idx]->lfe_routing_mtx );
        }
    }
#else
    parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB );
#endif

    return;
}
@@ -2885,11 +2819,7 @@ static void parseMasa(
    }

    /* Read optional values */
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseOptionalInputValues( line, NULL, NULL, NULL, NULL, &inConfig->masaBuses[idx].gain_dB );
#else
    parseOptionalInputValues( line, &inConfig->masaBuses[idx].gain_dB );
#endif

    return;
}
@@ -2930,12 +2860,8 @@ static void parseMetadata(
    char *inDir,
    InputConfig *inConfig,
    IsmPositionProvider *positionProvider,
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    MasaFileReader **masaReaders,
    LfeRoutingConfig **lfeRoutingConfigs )
#else
    MasaFileReader **masaReaders )
#endif
{
    char line[RENDERER_MAX_METADATA_LINE_LENGTH];
    char *delimiter;
@@ -2987,11 +2913,7 @@ static void parseMetadata(
                fprintf( stderr, "Metadata exceeds the supported number of MC inputs\n" );
                exit( -1 );
            }
#ifdef FIX_296_CFG_LFE_SCENE_DESC
            parseMc( line, inConfig, lfeRoutingConfigs, counterChannelAudioObjects - 1 );
#else
            parseMc( line, inConfig, counterChannelAudioObjects - 1 );
#endif
        }
        else if ( strcmp( line, "SBA" ) == 0 )
        {
@@ -3059,12 +2981,8 @@ static void parseSceneDescriptionFile(
    char *audioFilePath,
    InputConfig *inConfig,
    IsmPositionProvider *positionProvider,
#ifdef FIX_296_CFG_LFE_SCENE_DESC
    MasaFileReader **masaReaders,
    LfeRoutingConfig **lfeRoutingConfigs )
#else
    MasaFileReader **masaReaders )
#endif
{
    uint32_t inAudioFilePathLen;
    char inAudioFilePath[FILENAME_MAX];
@@ -3093,11 +3011,7 @@ static void parseSceneDescriptionFile(
    strcpy( audioFilePath, inDir );
    strncat( audioFilePath, inAudioFilePath, inAudioFilePathLen );

#ifdef FIX_296_CFG_LFE_SCENE_DESC
    parseMetadata( mtdStr, inDir, inConfig, positionProvider, masaReaders, lfeRoutingConfigs );
#else
    parseMetadata( mtdStr, inDir, inConfig, positionProvider, masaReaders );
#endif

    return;
}
@@ -3166,16 +3080,10 @@ static ivas_error parseLfePanMtxFile(
        set_zero( ( *lfePanMtx )[lfe_in], IVAS_MAX_OUTPUT_CHANNELS );
    }

#ifdef FIX_296_CFG_LFE_SCENE_DESC
    for ( lfe_in = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ )
#else
    for ( lfe_in = 0, ch_out = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ )
#endif
    {
#ifdef FIX_296_CFG_LFE_SCENE_DESC
        ch_out = 0;

#endif
        /* if EOF or a blank line is encountered, simply return */
        if ( ( fgets( line, 200, mtxFile ) == NULL ) && ( strcmp( line, "\n" ) == 0 ) && ( strcmp( line, "\r\n" ) == 0 ) )
        {
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

#define FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG         /* Phi: issue 196 - refactoring renderer output configuration */
#define FIX_296_CFG_LFE_SCENE_DESC                       /* FhG: Fix issue 296 - add configurable LFE handling to the scene description file */
#define FIX_519_JBM_ACCESS_NULL_TC_BUFFER               /* FhG: fix issue 519, accessing a yet uninitialized TC Buffer in frame 0*/
#ifdef IND_LIST_DYN
#define FIX_545_ASSERT                                  /* VA: fix issue 545, replace assert() with warning message when hitting memory limit in the buffer of indices */