From b701392c717554e8f259625308853dd7d74bdc99 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 12 May 2023 17:09:50 +0200 Subject: [PATCH 1/5] [wip] groundwork for issue 296 --- apps/renderer.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++ lib_com/options.h | 2 ++ 2 files changed, 89 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index 9045bbeaa0..5128e3629c 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1624,8 +1624,13 @@ 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 ); @@ -2090,6 +2095,12 @@ 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; @@ -2101,6 +2112,24 @@ 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; + } + if ( lfe_pos_azi != NULL ) + { + *lfe_pos_azi = 0.f; + } + if ( lfe_pos_ele != NULL ) + { + *lfe_pos_ele = 0.f; + } + if ( lfe_pan_mtx_filename != NULL ) + { + *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" ); @@ -2117,10 +2146,50 @@ 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 ); + + if ( *endptr != '\0' ) + { + fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value ); + exit( -1 ); + } + } + else if ( ( strcmp( key, "lfe_azi" ) == 0 ) && lfe_pos_azi != NULL ) + { + *lfe_pos_azi = (float) strtod( value, &endptr ); + + if ( *endptr != '\0' ) + { + fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value ); + exit( -1 ); + } + } + else if ( ( strcmp( key, "lfe_ele" ) == 0 ) && lfe_pos_ele != NULL ) + { + *lfe_pos_ele = (float) strtod( value, &endptr ); + + if ( *endptr != '\0' ) + { + fprintf( stderr, "Cannot parse string \"%s\" as a float value\n", value ); exit( -1 ); } } + else if ( strcmp( key, "lfe_matrix" ) == 0 ) + { + strncpy( lfe_pan_mtx_filename, value, FILENAME_MAX - 1 ); + } +#endif else { fprintf( stderr, "Unsupported optional key: %s\n", key ); @@ -2204,7 +2273,11 @@ 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; } @@ -2225,7 +2298,11 @@ 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; } @@ -2251,7 +2328,13 @@ static void parseMc( } /* Read optional values */ +#ifdef FIX_296_CFG_LFE_SCENE_DESC + float lg, la, le; + char tmpfile[FILENAME_MAX]; + parseOptionalInputValues( line, &lg, &la, &le, tmpfile, &inConfig->multiChannelBuses[idx].gain_dB ); +#else parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB ); +#endif return; } @@ -2292,7 +2375,11 @@ 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; } diff --git a/lib_com/options.h b/lib_com/options.h index dfe0f53d07..9401787863 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -213,6 +213,8 @@ //#define HODIRAC_READ_PARAMS #endif +#define FIX_296_CFG_LFE_SCENE_DESC /* FhG: Fix issue 296 - add configurable LFE handling to the scene description file */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ -- GitLab From e2326bb1da50db940ebc41790a6bee2abdfbf5d4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 30 May 2023 16:50:47 +0200 Subject: [PATCH 2/5] finish implementation for FIX_296_CFG_LFE_SCENE_DESC + remove two TODOs; needs testing --- apps/renderer.c | 155 +++++++++++++++++- .../data/renderer_config_format_readme.txt | 4 + 2 files changed, 153 insertions(+), 6 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index edafa29db8..853ae31dd9 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -88,6 +88,15 @@ 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; + float lfe_ele; + float lfe_gain_dB; + char lfe_pan_mtx[FILENAME_MAX]; +} LfeRoutingConfig; +#endif typedef struct { IVAS_REND_AudioConfig audioConfig; @@ -301,7 +310,11 @@ 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 ); @@ -313,6 +326,11 @@ 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 ); void getMetadataFromFileReader( IsmFileReader *ismReader, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx ); @@ -331,7 +349,11 @@ 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 ); @@ -520,6 +542,9 @@ int main( HeadRotFileReader *referenceRotReader = 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]; IVAS_MASA_METADATA_HANDLE hMasaMetadata[RENDERER_MAX_MASA_INPUTS]; @@ -554,6 +579,13 @@ 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 ); if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_MONO ) || @@ -626,7 +658,16 @@ 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 { @@ -749,7 +790,6 @@ int main( /* parse input LFE panning matrix */ if ( args.lfeCustomRoutingEnabled && !isEmptyString( args.inLfePanningMatrixFile ) ) { - /* TODO tmu: how should we handle this on CLI for multiple MC inputs? */ if ( ( error = parseLfePanMtxFile( args.inLfePanningMatrixFile, &lfePanMatrix ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); @@ -771,7 +811,6 @@ int main( exit( -1 ); } - /* TODO(sgi): Command line only supports one custom LS input for now, extend */ if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) @@ -804,6 +843,39 @@ int main( exit( -1 ); } } +#ifdef FIX_296_CFG_LFE_SCENE_DESC + else + { + /* check for configuration from scene description file */ + if ( lfeRoutingConfigs[i] != NULL ) + { + /* prioritise panning matrix if configured */ + if ( lfeRoutingConfigs[i]->lfe_pan_mtx[0] != '\0' ) + { + if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_pan_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = IVAS_REND_SetInputLfeMtx( hIvasRend, mcIds[i], (const IVAS_REND_LfePanMtx *) &lfePanMatrix ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + /* set position based gains */ + else + { + if ( ( error = IVAS_REND_SetInputLfePos( hIvasRend, mcIds[i], lfeRoutingConfigs[i]->lfe_gain_dB, lfeRoutingConfigs[i]->lfe_azi, lfeRoutingConfigs[i]->lfe_ele ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + } + } +#endif } for ( i = 0; i < args.inConfig.numAudioObjects; ++i ) @@ -1164,6 +1236,12 @@ 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 AudioFileReader_close( &audioReader ); AudioFileWriter_close( &audioWriter ); HeadRotationFileReader_close( &headRotReader ); @@ -1864,6 +1942,35 @@ IsmPositionProvider *IsmPositionProvider_open( return ipp; } +#ifdef FIX_296_CFG_LFE_SCENE_DESC +LfeRoutingConfig *LfeRoutingConfig_open( + void ) +{ + LfeRoutingConfig *lrc; + + lrc = (LfeRoutingConfig *) malloc( sizeof( LfeRoutingConfig ) ); + lrc->lfe_azi = 0; + lrc->lfe_ele = 0; + lrc->lfe_gain_dB = 0; + lrc->lfe_pan_mtx[0] = '\0'; + + return lrc; +} + +void LfeRoutingConfig_close( + LfeRoutingConfig *lfeRoutingCfg ) +{ + if ( lfeRoutingCfg == NULL ) + { + assert( !"Can't close LfeRoutingConfig - pointer is NULL" ); + } + + free( lfeRoutingCfg ); + + return; +} +#endif + void getMetadataFromFileReader( IsmFileReader *ismReader, ObjectPositionBuffer *objectMetadataBuffer, @@ -2370,6 +2477,9 @@ 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" ); @@ -2378,7 +2488,7 @@ static void parseMc( readNextMetadataChunk( line, "\n" ); IVAS_REND_AudioConfig cfg = parseAudioConfig( line ); - if ( cfg == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) + if ( cfg == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) // TODO tmu : cfg is never parsed as custom LS? { parseCustomLayoutFile( line, &inConfig->inSetupCustom ); } @@ -2389,9 +2499,24 @@ static void parseMc( /* Read optional values */ #ifdef FIX_296_CFG_LFE_SCENE_DESC - float lg, la, le; - char tmpfile[FILENAME_MAX]; - parseOptionalInputValues( line, &lg, &la, &le, tmpfile, &inConfig->multiChannelBuses[idx].gain_dB ); + float lfe_gain_dB, lfe_azi, lfe_ele; + char lfe_pan_mtx[FILENAME_MAX]; + + parseOptionalInputValues( line, &lfe_gain_dB, &lfe_azi, &lfe_ele, lfe_pan_mtx, &inConfig->multiChannelBuses[idx].gain_dB ); + + if ( ( lfe_gain_dB != 0.f || lfe_azi != 0.f || lfe_ele != 0.f ) || + ( lfe_pan_mtx[0] != '\0' ) ) + { + /* a configuration was specified, set the values */ + lfeRoutingConfigs[idx] = LfeRoutingConfig_open(); + + lfeRoutingConfigs[idx]->lfe_gain_dB = lfe_gain_dB; + lfeRoutingConfigs[idx]->lfe_azi = lfe_azi; + lfeRoutingConfigs[idx]->lfe_ele = lfe_ele; + + strncpy( lfeRoutingConfigs[idx]->lfe_pan_mtx, lfe_pan_mtx, FILENAME_MAX ); + convert_backslash( lfeRoutingConfigs[idx]->lfe_pan_mtx ); + } #else parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB ); #endif @@ -2480,7 +2605,12 @@ 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; @@ -2532,7 +2662,11 @@ 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 ) { @@ -2600,7 +2734,12 @@ 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]; @@ -2629,7 +2768,11 @@ 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; } diff --git a/tests/renderer/data/renderer_config_format_readme.txt b/tests/renderer/data/renderer_config_format_readme.txt index 1fe493b279..dffb6c6317 100644 --- a/tests/renderer/data/renderer_config_format_readme.txt +++ b/tests/renderer/data/renderer_config_format_readme.txt @@ -109,6 +109,10 @@ Currently the following key-value pairs are supported: | key | value type | |---------------------|--------------------------------------| | gain_dB | float | +| lfe_matrix | str | +| lfe_gain_dB | float | +| lfe_azi | float | +| lfe_ele | float | ================================ Example config ================================= -- GitLab From 3c89c7fe609ad96242d35bdcc7d013795b09290b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 30 May 2023 18:50:05 +0200 Subject: [PATCH 3/5] [fix] bug with LFE pan matrix file reading --- apps/renderer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index 853ae31dd9..5407eb6c33 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2835,8 +2835,16 @@ 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 ) ) { -- GitLab From 8591a629a6e06b3cb54ba9b9ec0a1afdd6f4a090 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 30 May 2023 19:17:14 +0200 Subject: [PATCH 4/5] [fix] bug with parsing custom layout files specified in the scene description file (addresses TODO added in e2326bb1) --- apps/renderer.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 5407eb6c33..17087227a8 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1960,12 +1960,11 @@ LfeRoutingConfig *LfeRoutingConfig_open( void LfeRoutingConfig_close( LfeRoutingConfig *lfeRoutingCfg ) { - if ( lfeRoutingCfg == NULL ) + if ( lfeRoutingCfg != NULL ) { - assert( !"Can't close LfeRoutingConfig - pointer is NULL" ); - } - free( lfeRoutingCfg ); + free( lfeRoutingCfg ); + } return; } @@ -2488,10 +2487,28 @@ static void parseMc( readNextMetadataChunk( line, "\n" ); IVAS_REND_AudioConfig cfg = parseAudioConfig( line ); - if ( cfg == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) // TODO tmu : cfg is never parsed as custom LS? +#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 ) + { + ivas_error error = parseCustomLayoutFile( line, &inConfig->inSetupCustom ); + + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "Error while parsing input format %s\n", line ); + exit( -1 ); + } + inConfig->numMultiChannelBuses = 1; + inConfig->multiChannelBuses[idx].audioConfig = IVAS_REND_AUDIO_CONFIG_LS_CUSTOM; + 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; -- GitLab From 1f5ccf62fc061aff3a4d95777b4f3696129bfe27 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 6 Jun 2023 11:27:36 +0200 Subject: [PATCH 5/5] [fix] minor improvements and add a warning when both LFE position and matrix are configured as on CLI --- apps/renderer.c | 50 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index b00a5c01af..84d616af1e 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -94,7 +94,7 @@ typedef struct float lfe_azi; float lfe_ele; float lfe_gain_dB; - char lfe_pan_mtx[FILENAME_MAX]; + char lfe_routing_mtx[FILENAME_MAX]; } LfeRoutingConfig; #endif typedef struct @@ -828,7 +828,11 @@ 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; } @@ -854,9 +858,9 @@ int main( if ( lfeRoutingConfigs[i] != NULL ) { /* prioritise panning matrix if configured */ - if ( lfeRoutingConfigs[i]->lfe_pan_mtx[0] != '\0' ) + if ( !isEmptyString( lfeRoutingConfigs[i]->lfe_routing_mtx ) ) { - if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_pan_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK ) + if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_routing_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1953,10 +1957,10 @@ LfeRoutingConfig *LfeRoutingConfig_open( LfeRoutingConfig *lrc; lrc = (LfeRoutingConfig *) malloc( sizeof( LfeRoutingConfig ) ); - lrc->lfe_azi = 0; - lrc->lfe_ele = 0; - lrc->lfe_gain_dB = 0; - lrc->lfe_pan_mtx[0] = '\0'; + lrc->lfe_azi = 0.f; + lrc->lfe_ele = 0.f; + lrc->lfe_gain_dB = 0.f; + lrc->lfe_routing_mtx[0] = '\0'; return lrc; } @@ -2520,23 +2524,37 @@ static void parseMc( /* Read optional values */ #ifdef FIX_296_CFG_LFE_SCENE_DESC + bool lfe_panningEnabled; float lfe_gain_dB, lfe_azi, lfe_ele; - char lfe_pan_mtx[FILENAME_MAX]; + char lfe_routing_mtx[FILENAME_MAX]; - parseOptionalInputValues( line, &lfe_gain_dB, &lfe_azi, &lfe_ele, lfe_pan_mtx, &inConfig->multiChannelBuses[idx].gain_dB ); + parseOptionalInputValues( line, &lfe_gain_dB, &lfe_azi, &lfe_ele, lfe_routing_mtx, &inConfig->multiChannelBuses[idx].gain_dB ); - if ( ( lfe_gain_dB != 0.f || lfe_azi != 0.f || lfe_ele != 0.f ) || - ( lfe_pan_mtx[0] != '\0' ) ) + lfe_panningEnabled = ( lfe_gain_dB != 0.f || lfe_azi != 0.f || lfe_ele != 0.f ) ? true : false; + + if ( lfe_panningEnabled && !isEmptyString( lfe_routing_mtx ) ) + { + fprintf( stderr, "Warning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" ); + lfe_panningEnabled = false; + } + + if ( lfe_panningEnabled || !isEmptyString( lfe_routing_mtx ) ) { /* a configuration was specified, set the values */ lfeRoutingConfigs[idx] = LfeRoutingConfig_open(); - lfeRoutingConfigs[idx]->lfe_gain_dB = lfe_gain_dB; - lfeRoutingConfigs[idx]->lfe_azi = lfe_azi; - lfeRoutingConfigs[idx]->lfe_ele = lfe_ele; + if ( lfe_panningEnabled ) + { + lfeRoutingConfigs[idx]->lfe_gain_dB = lfe_gain_dB; + lfeRoutingConfigs[idx]->lfe_azi = lfe_azi; + lfeRoutingConfigs[idx]->lfe_ele = lfe_ele; + } - strncpy( lfeRoutingConfigs[idx]->lfe_pan_mtx, lfe_pan_mtx, FILENAME_MAX ); - convert_backslash( lfeRoutingConfigs[idx]->lfe_pan_mtx ); + if ( !isEmptyString( lfe_routing_mtx ) ) + { + strncpy( lfeRoutingConfigs[idx]->lfe_routing_mtx, lfe_routing_mtx, FILENAME_MAX ); + convert_backslash( lfeRoutingConfigs[idx]->lfe_routing_mtx ); + } } #else parseOptionalInputValues( line, &inConfig->multiChannelBuses[idx].gain_dB ); -- GitLab