From a5bbf9738297c3c38ec268abd52274865912391f Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 4 Nov 2025 15:36:22 +0100 Subject: [PATCH 1/2] Command line option for room size selection --- apps/decoder.c | 47 ++++++++++++++++++++++++++++++++++++++ lib_com/common_api_types.h | 10 ++++++++ lib_com/options.h | 2 +- lib_dec/ivas_init_dec.c | 43 ++++++++++++++++++++++++++++++++-- lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec.c | 9 ++++++++ lib_dec/lib_dec.h | 3 +++ 7 files changed, 114 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 59689807f6..05584fcb5f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -152,6 +152,9 @@ typedef struct uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; bool objEditEnabled; char *objEditFileName; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_ROOM_SIZE_T roomSize; +#endif } DecArguments; @@ -452,9 +455,15 @@ int main( #ifdef IVAS_RTPDUMP arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; #endif +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, + arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.roomSize, arg.non_diegetic_pan_enabled, + arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1033,6 +1042,10 @@ static bool parseCmdlIVAS_dec( arg->objEditEnabled = false; arg->objEditFileName = NULL; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + arg->roomSize = IVAS_ROOM_SIZE_AUTO; +#endif + /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1521,6 +1534,36 @@ static bool parseCmdlIVAS_dec( } i++; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + else if ( strcmp( argv_to_upper, "-ROOM_SIZE" ) == 0 ) + { + i++; + if ( argc - i <= 3 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Room size selector not specified!\n\n" ); + usage_dec(); + return false; + } + + if ( strcmp( argv[i], "S" ) == 0 || strcmp( argv[i], "s" ) == 0 ) + { + arg->roomSize = IVAS_ROOM_SIZE_SMALL; + } + else if ( strcmp( argv[i], "M" ) == 0 || strcmp( argv[i], "m" ) == 0 ) + { + arg->roomSize = IVAS_ROOM_SIZE_MEDIUM; + } + else if ( strcmp( argv[i], "L" ) == 0 || strcmp( argv[i], "l" ) == 0 ) + { + arg->roomSize = IVAS_ROOM_SIZE_LARGE; + } + else + { + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", argv[i] ); + } + i++; + } +#endif /*-----------------------------------------------------------------* * Option not recognized @@ -1749,6 +1792,10 @@ static void usage_dec( void ) fprintf( stdout, "-obj_edit File : Object editing instructions file or NULL for built-in example\n" ); fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); +#endif fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); #ifdef DEBUG_MODE_INFO diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 80c90d6b31..b8b3c93e3d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -173,6 +173,16 @@ typedef enum } IVAS_RENDER_FRAMESIZE; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +typedef enum +{ + IVAS_ROOM_SIZE_AUTO = -1, + IVAS_ROOM_SIZE_SMALL, + IVAS_ROOM_SIZE_MEDIUM, + IVAS_ROOM_SIZE_LARGE +} IVAS_ROOM_SIZE_T; +#endif + typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index b72be74b4f..3d752edfff 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define RENDERER_MD_SYNC_DELAY_TO_INTEGER /* FhG: change data type of metadata sync delay in ext renderer to int16_t for better BASOP portability (and nicer code) */ - +#define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia: Default room sizes support */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 284aae854d..57d21c5e84 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1397,7 +1397,46 @@ ivas_error ivas_init_decoder( if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom == 0 ) { IVAS_DefaultReverbSize defaultReverbSize; - +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + switch ( st_ivas->hDecoderConfig->Opt_RoomSize ) + { + case IVAS_ROOM_SIZE_AUTO: + switch ( st_ivas->ivas_format ) + { + case ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + break; + case SBA_FORMAT: + defaultReverbSize = DEFAULT_REVERB_SMALL; + break; + case MASA_FORMAT: + defaultReverbSize = DEFAULT_REVERB_SMALL; + break; + case MC_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + break; + case MASA_ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + break; + case SBA_ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + break; + default: + defaultReverbSize = DEFAULT_REVERB_LARGE; + } + break; + case IVAS_ROOM_SIZE_SMALL: + defaultReverbSize = DEFAULT_REVERB_SMALL; + break; + case IVAS_ROOM_SIZE_MEDIUM: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + break; + case IVAS_ROOM_SIZE_LARGE: + default: + defaultReverbSize = DEFAULT_REVERB_LARGE; + break; + } +#else switch ( st_ivas->ivas_format ) { case ISM_FORMAT: @@ -1421,7 +1460,7 @@ ivas_error ivas_init_decoder( default: defaultReverbSize = DEFAULT_REVERB_LARGE; } - +#endif if ( ( error = ivas_render_config_change_defaults( st_ivas->hRenderConfig, defaultReverbSize ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index f1efb32a10..777082e635 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1016,6 +1016,9 @@ typedef struct decoder_config_structure int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_ROOM_SIZE_T Opt_RoomSize; /* Selected room size */ +#endif IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ float non_diegetic_pan_gain; /* non diegetic panning gain*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d8a602beb0..9863143c95 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -310,6 +310,9 @@ static void init_decoder_config( hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; hDecoderConfig->Opt_RendConfigCustom = 0; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + hDecoderConfig->Opt_RoomSize = IVAS_ROOM_SIZE_AUTO; +#endif hDecoderConfig->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain = 0; @@ -452,6 +455,9 @@ ivas_error IVAS_DEC_Configure( const bool enableExternalOrientation, /* i : enable external orientations */ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ +#endif const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ @@ -508,6 +514,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->Opt_HRTF_binary = (int16_t) hrtfReaderEnabled; hDecoderConfig->Opt_RendConfigCustom = (int16_t) renderConfigEnabled; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + hDecoderConfig->Opt_RoomSize = roomSize; +#endif hDecoderConfig->Opt_non_diegetic_pan = (int16_t) non_diegetic_pan_enabled; hDecoderConfig->non_diegetic_pan_gain = non_diegetic_pan_gain; hDecoderConfig->Opt_delay_comp = (int16_t) delayCompensationEnabled; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d0d2b501d8..5aef9034ed 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -119,6 +119,9 @@ ivas_error IVAS_DEC_Configure( const bool enableExternalOrientation, /* i : enable external orientations */ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ +#endif const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ -- GitLab From 2f3c020d43144833c87b8a5414b933fac0bdae84 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 5 Nov 2025 20:59:38 +0100 Subject: [PATCH 2/2] Cleanup related to -room_size command line option --- apps/decoder.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0955f278ef..6e3c6e5fbe 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1548,21 +1548,30 @@ static bool parseCmdlIVAS_dec( return false; } - if ( strcmp( argv[i], "S" ) == 0 || strcmp( argv[i], "s" ) == 0 ) - { - arg->roomSize = IVAS_ROOM_SIZE_SMALL; - } - else if ( strcmp( argv[i], "M" ) == 0 || strcmp( argv[i], "m" ) == 0 ) - { - arg->roomSize = IVAS_ROOM_SIZE_MEDIUM; - } - else if ( strcmp( argv[i], "L" ) == 0 || strcmp( argv[i], "l" ) == 0 ) - { - arg->roomSize = IVAS_ROOM_SIZE_LARGE; - } - else + if ( strlen( argv[i] ) != 1 ) { fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", argv[i] ); + usage_dec(); + return false; + } + switch ( argv[i][0] ) + { + case 'S': + case 's': + arg->roomSize = IVAS_ROOM_SIZE_SMALL; + break; + case 'M': + case 'm': + arg->roomSize = IVAS_ROOM_SIZE_MEDIUM; + break; + case 'L': + case 'l': + arg->roomSize = IVAS_ROOM_SIZE_LARGE; + break; + default: + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", argv[i] ); + usage_dec(); + return false; } i++; } -- GitLab