diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 2ffd5bcf58e41358543f1417033f4edcb64729d8..00574f411e793e87d9a2c9fd3a5cefcd1ee7da7a 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -100,6 +100,7 @@ + @@ -126,6 +127,7 @@ + diff --git a/apps/decoder.c b/apps/decoder.c index a4424c92c59210f10c511792c2fdba0ecdc27da1..a63669642ba4e7ff3eee0ac518074d330acc8ba7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -43,6 +43,9 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef FIX_1053_REVERB_RECONFIGURATION +#include "aeid_file_reader.h" +#endif #include "split_render_file_read_write.h" #include "vector3_pair_file_reader.h" #include "wmc_auto.h" @@ -1244,6 +1247,23 @@ static bool parseCmdlIVAS_dec( if ( !is_digits_only( argv[i] ) ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + aeidFileReader *aeidReader = NULL; + if ( aeidFileReader_open( argv[i], &aeidReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open aeid file %s \n", argv[i] ); + usage_dec(); + return false; + } + if ( aeidFileReading( aeidReader, &arg->aeSequence.count, &arg->aeSequence.pID, &arg->aeSequence.pValidity ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError while reading aeid from %s\n", argv[i] ); + usage_dec(); + return false; + } + aeidFileReader_close( &aeidReader ); + i++; +#else uint16_t k; char *s = argv[i]; char *token = argv[i]; @@ -1303,6 +1323,7 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } +#endif } else { diff --git a/apps/renderer.c b/apps/renderer.c index 3a4d4e1287451921d7366b579735826a78d9fceb..e13380191b1c9be282f6b95004c90840cf854ed0 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -45,6 +45,9 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef FIX_1053_REVERB_RECONFIGURATION +#include "aeid_file_reader.h" +#endif #include "split_render_file_read_write.h" #include "split_rend_bfi_file_reader.h" #include "vector3_pair_file_reader.h" @@ -385,7 +388,11 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_acousticEnvironmentId, .match = "acoustic_environment_id", .matchShort = "aeid", +#ifdef FIX_1053_REVERB_RECONFIGURATION + .description = "Acoustic environment ID (number > 0) alternatively, it can be a text file where each line contains \"ID duration\" for BINAURAL_ROOM_REVERB output configuration.", +#else .description = "Acoustic environment ID( number > 0 ) or a sequence thereof in the format [ID1:duration1,ID2:duration2...] without braces and spaces, with ':' character separating ID from duration and ',' separating ID and duration pairs, where duration is specified in frames for BINAURAL_ROOM_REVERB output configuration.", +#endif }, }; @@ -783,6 +790,9 @@ int main( int32_t delayTimeScale = 0; int16_t i, numChannels; uint16_t aeID; +#ifdef FIX_1053_REVERB_RECONFIGURATION + IVAS_RENDER_CONFIG_DATA renderConfig; +#endif ivas_error error = IVAS_ERR_OK; #ifdef WMOPS @@ -1137,7 +1147,10 @@ int main( if ( args.renderConfigFilePath[0] != '\0' ) { + +#ifndef FIX_1053_REVERB_RECONFIGURATION IVAS_RENDER_CONFIG_DATA renderConfig; +#endif /* sanity check */ if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) @@ -1611,8 +1624,9 @@ int main( { if ( ++args.aeSequence.frameCounter >= args.aeSequence.pValidity[args.aeSequence.selected] ) { +#ifndef FIX_1053_REVERB_RECONFIGURATION IVAS_RENDER_CONFIG_DATA renderConfig; - +#endif if ( ++args.aeSequence.selected >= args.aeSequence.count ) { args.aeSequence.selected = 0; @@ -1622,7 +1636,7 @@ int main( { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { - fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); + fprintf( stderr, "Invalid acoustic environment configuration parameters\n\n" ); goto cleanup; } } @@ -2577,6 +2591,25 @@ static bool parseAcousticEnvironmentIds( const char *value, AcousticEnvironmentSequence *aeSequence ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + char config_string[RENDERER_MAX_METADATA_LINE_LENGTH]; + strncpy( config_string, value, RENDERER_MAX_METADATA_LINE_LENGTH ); + if ( !is_digits_only( config_string ) ) + { + aeidFileReader *aeidReader = NULL; + if ( aeidFileReader_open( config_string, &aeidReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open aeid file %s \n", config_string ); + return false; + } + if ( aeidFileReading( aeidReader, &aeSequence->count, &aeSequence->pID, &aeSequence->pValidity ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError while reading aeid from %s\n", config_string ); + return false; + } + aeidFileReader_close( &aeidReader ); + } +#else uint16_t k; char config_string[RENDERER_MAX_METADATA_LINE_LENGTH]; char *s; @@ -2641,6 +2674,7 @@ static bool parseAcousticEnvironmentIds( return false; } } +#endif else { /* A single acoustic environment */ diff --git a/lib_com/options.h b/lib_com/options.h index 889d42845bc7d1c0dfeccddd0d570658921a9210..3eaf90a69ad30eacc657bc9a26ea76651e40dfbd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,6 +120,7 @@ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define ADJUST_MCT_CHANNELS_MAX /* FhG: set correct max mct channels constant*/ +#define FIX_1053_REVERB_RECONFIGURATION /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 61be1a83e30357d267da7da54ec5abe2489f4c5c..ba0d0d6ddbf1d2ffb899fb1a9a7cac1ee090608a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4906,6 +4906,10 @@ Word16 IVAS_REND_GetRenderConfig( move16(); move32(); +#ifdef FIX_1053_REVERB_RECONFIGURATION + Copy32( hRCin->distAtt_fx, hRCout->distAtt_fx, 3 ); +#endif + return IVAS_ERR_OK; } @@ -4946,6 +4950,9 @@ Word16 IVAS_REND_FeedRenderConfig( Copy32( renderConfig.roomAcoustics.pAcoustic_rt60_fx, hRenderConfig->roomAcoustics.pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); Copy32( renderConfig.roomAcoustics.pAcoustic_dsr_fx, hRenderConfig->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); Copy( renderConfig.directivity_fx, hRenderConfig->directivity_fx, 3 * MAX_NUM_OBJECTS ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + Copy32( renderConfig.distAtt_fx, hRenderConfig->distAtt_fx, 3 ); +#endif hRenderConfig->roomAcoustics.use_er = 0; move16(); diff --git a/lib_util/aeid_file_reader.c b/lib_util/aeid_file_reader.c new file mode 100644 index 0000000000000000000000000000000000000000..737c71f0c8934c3cc27d62f98818ce6465855d6d --- /dev/null +++ b/lib_util/aeid_file_reader.c @@ -0,0 +1,187 @@ +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "aeid_file_reader.h" +#ifdef FIX_1053_REVERB_RECONFIGURATION +#include "ivas_error_utils.h" +#include +#include + +struct aeidFileReader +{ + FILE *aeidFile; + char *file_path; +}; + + +/*-----------------------------------------------------------------------* + * aeidFileReader_open() + * + * Allocate and initialize rotation handle + *-----------------------------------------------------------------------*/ + +ivas_error aeidFileReader_open( + char *aeidFilePath, /* i : aeid file name */ + aeidFileReader **aeidReader /* o : aeidFileReader handle */ +) +{ + aeidFileReader *self; + FILE *aeidFile; + + /* Open trajectory file */ + if ( strlen( aeidFilePath ) < 1 ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + aeidFile = fopen( aeidFilePath, "r" ); + + if ( !aeidFile ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + self = calloc( sizeof( aeidFileReader ), 1 ); + self->aeidFile = aeidFile; + self->file_path = calloc( sizeof( char ), strlen( aeidFilePath ) + 1 ); + strcpy( self->file_path, aeidFilePath ); + + *aeidReader = self; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * aeidFileReading() + * + * Read values from the aeid file + *-----------------------------------------------------------------------*/ + +ivas_error aeidFileReading( + aeidFileReader *aeidReader, /* i : aeidFileReader handle */ + uint16_t *count, /* o : number of sequences */ + uint16_t **pID, /* o : acoustic environment ID data */ + uint16_t **pValidity /* o : duration data */ +) +{ + int32_t id; + int32_t duration; + uint16_t k = 0; + + while ( !feof( aeidReader->aeidFile ) ) + { + if ( fscanf( aeidReader->aeidFile, "%d %d", &id, &duration ) == 2 ) + { + k++; + } + else + { + return IVAS_ERROR( IVAS_ERR_FAILED_FILE_PARSE, "Error while parsing acoustic environment sequence" ); + } + } + + if ( k == 0 ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_FILE_PARSE, "No acoustic environment" ); + } + + if ( NULL == ( *pID = malloc( sizeof( uint16_t ) * k ) ) || + NULL == ( *pValidity = malloc( sizeof( uint16_t ) * k ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Unable to allocate memory for acoustic environment sequence" ); + } + + *count = k; + + k = 0; + + fseek( aeidReader->aeidFile, 0, SEEK_SET ); + + while ( !feof( aeidReader->aeidFile ) ) + { + if ( fscanf( aeidReader->aeidFile, "%d %d", &id, &duration ) == 2 ) + { + ( *pID )[k] = (uint16_t) id; + ( *pValidity )[k] = (uint16_t) duration; + k++; + } + else + { + return IVAS_ERROR( IVAS_ERR_FAILED_FILE_PARSE, "Error while parsing acoustic environment sequence" ); + } + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * aeidFileReader_close() + * + * Deallocates memory for the aeid handle + *-----------------------------------------------------------------------*/ + +void aeidFileReader_close( + aeidFileReader **aeidReader /* i/o: aeidFileReader handle */ +) +{ + if ( aeidReader == NULL || *aeidReader == NULL ) + { + return; + } + + fclose( ( *aeidReader )->aeidFile ); + free( ( *aeidReader )->file_path ); + free( *aeidReader ); + *aeidReader = NULL; + + return; +} + +/*-----------------------------------------------------------------------* + * aeidFileReader_getFilePath() + * + * + *-----------------------------------------------------------------------*/ + +const char *aeidFileReader_getFilePath( + aeidFileReader *aeidReader /* i : aeidFileReader handle */ +) +{ + if ( aeidReader == NULL ) + { + return NULL; + } + + return aeidReader->file_path; +} +#endif diff --git a/lib_util/aeid_file_reader.h b/lib_util/aeid_file_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..abd246e594a7eb577683e4d05b854ae93054fd25 --- /dev/null +++ b/lib_util/aeid_file_reader.h @@ -0,0 +1,90 @@ +#pragma once +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_AEID_FILE_READER_H +#define IVAS_AEID_FILE_READER_H + +#include "common_api_types.h" + +#ifdef FIX_1053_REVERB_RECONFIGURATION + +struct aeidFileReader; +typedef struct aeidFileReader aeidFileReader; + +/*-----------------------------------------------------------------------* + * aeidFileReader_open() + * + * Allocate and initialize rotation handle + *-----------------------------------------------------------------------*/ + +ivas_error aeidFileReader_open( + char *aeidFilePath, /* i : aeid file name */ + struct aeidFileReader **aeidReader /* o : aeidFileReader handle */ +); + +/*-----------------------------------------------------------------------* + * aeidFileReading() + * + * Read values from the aeid file + *-----------------------------------------------------------------------*/ + +ivas_error aeidFileReading( + aeidFileReader *aeidReader, /* i : aeidFileReader handle */ + uint16_t *count, /* o : number of sequences */ + uint16_t **pID, /* o : acoustic environment ID data */ + uint16_t **pValidity /* o : duration data */ +); + +/*-----------------------------------------------------------------------* + * aeidFileReader_close() + * + * Deallocates memory for the aeid handle + *-----------------------------------------------------------------------*/ + +void aeidFileReader_close( + aeidFileReader **aeidReader /* i/o: aeidFileReader handle */ +); + +/*-----------------------------------------------------------------------* + * aeidFileReader_getFilePath() + * + * + *-----------------------------------------------------------------------*/ + +const char *aeidFileReader_getFilePath( + aeidFileReader *aeidReader /* i : aeidFileReader handle */ +); + +#endif + +#endif /* IVAS_AEID_FILE_READER_H */