From 477a5852e8176a8dbb32dfa6e295ec01faffa6b6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jun 2023 09:44:18 +0200 Subject: [PATCH 1/2] address issues reported in #543; under BINAURAL_AUDIO_CMDLINE --- apps/encoder.c | 23 ++++++++++------------- lib_com/options.h | 2 +- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/lib_enc.c | 30 ++++++++++++++++-------------- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 1dc0aead51..10fd12a94b 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1225,16 +1225,6 @@ static bool parseCmdlIVAS_enc( * IVAS Formats *-----------------------------------------------------------------*/ -#ifdef BINAURAL_AUDIO_CMDLINE - else if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 ) - { - i++; - if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 ) - { - arg->is_binaural = true; - } - } -#endif else if ( strcmp( argv_to_upper, "-STEREO" ) == 0 ) { i++; @@ -1312,6 +1302,13 @@ static bool parseCmdlIVAS_enc( } #endif /* DEBUGGING */ } +#ifdef BINAURAL_AUDIO_CMDLINE + else if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 ) + { + arg->is_binaural = true; + i++; + } +#endif else if ( strcmp( argv_to_upper, "-ISM" ) == 0 ) { arg->inputFormat = IVAS_ENC_INPUT_ISM; @@ -1703,9 +1700,6 @@ static void usage_enc( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); fprintf( stdout, "EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -masa, -mc\n" ); -#ifdef BINAURAL_AUDIO_CMDLINE - fprintf( stdout, "-binaural : Optional indication that input is binaural audio (to be used with -stereo or -stereo_dmx_evs)\n" ); -#endif fprintf( stdout, "-stereo : Stereo format \n" ); fprintf( stdout, "-ism (+)Ch Files : ISM format \n" ); fprintf( stdout, " where Ch specifies the number of ISMs (1-4)\n" ); @@ -1737,6 +1731,9 @@ static void usage_enc( void ) fprintf( stdout, " alternatively, B can be a text file where each line contains \"nb_frames B\"\n" ); fprintf( stdout, "-no_delay_cmp : Turn off delay compensation\n" ); fprintf( stdout, "-stereo_dmx_evs : Activate stereo downmix function for EVS.\n" ); +#ifdef BINAURAL_AUDIO_CMDLINE + fprintf( stdout, "-binaural : Optional indication that input is binaural audio (to be used with -stereo or -stereo_dmx_evs)\n" ); +#endif fprintf( stdout, "-mime : Mime output bitstream file format\n" ); fprintf( stdout, " The encoder produces TS26.445 Annex.2.6 Mime Storage Format, (not RFC4867 Mime Format).\n" ); fprintf( stdout, " default output bitstream file format is G.192\n" ); diff --git a/lib_com/options.h b/lib_com/options.h index 4328602f5a..223c6a6404 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,7 +163,7 @@ #define FIX_TODO_FD_CNG_SBA_CLEANUP /* FhG: BE, address TODO comment in fd_cng_enc */ #define ENHANCED_STEREO_DMX /* Orange : Contribution 48 - Enhanced stereo downmix. */ -#define BINAURAL_AUDIO_CMDLINE +#define BINAURAL_AUDIO_CMDLINE /* issue 491: Implement Commandline-Option for Binaural Audio */ #define FIX_570_TCX_LPC_WRITE /* FhG: fix issue 570: LPC bitstream writer in TCX */ #define FIX_506 /* FhG: Compiler warnings */ #define FIX_511_OPTIMIZE_PARAMBIN_GAIN_FETCH /* Nokia: Issue 511, significant optimization of parametric binauralizer gain fetching. */ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 4f2f375af7..23d0acbe93 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1084,7 +1084,7 @@ typedef struct encoder_config_structure int16_t max_bwidth; /* maximum encoded bandwidth */ IVAS_FORMAT ivas_format; /* IVAS format */ #ifdef BINAURAL_AUDIO_CMDLINE - bool is_binaural; /* flag indicating if input is binaural audio */ + int16_t is_binaural; /* flag indicating if input is binaural audio */ #endif int16_t element_mode_init; /* element mode used at initialization */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 472497bea5..2eb9e6ec3c 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -283,7 +283,7 @@ ivas_error IVAS_ENC_ConfigureForMono( hIvasEnc->st_ivas->hEncoderConfig->ivas_format = MONO_FORMAT; #ifdef BINAURAL_AUDIO_CMDLINE - hIvasEnc->st_ivas->hEncoderConfig->is_binaural = is_binaural; + hIvasEnc->st_ivas->hEncoderConfig->is_binaural = (int16_t) is_binaural; #endif if ( downmixFromStereo ) @@ -337,7 +337,7 @@ ivas_error IVAS_ENC_ConfigureForStereo( hEncoderConfig->nchan_inp = 2; hEncoderConfig->ivas_format = STEREO_FORMAT; #ifdef BINAURAL_AUDIO_CMDLINE - hEncoderConfig->is_binaural = is_binaural; + hEncoderConfig->is_binaural = (int16_t) is_binaural; #endif #ifdef DEBUGGING @@ -933,6 +933,13 @@ static ivas_error configureEncoder( return error; } +#ifdef BINAURAL_AUDIO_CMDLINE + if ( hEncoderConfig->is_binaural && !( ( hEncoderConfig->ivas_format == MONO_FORMAT && hEncoderConfig->stereo_dmx_evs ) || hEncoderConfig->ivas_format == STEREO_FORMAT ) ) + { + return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "'-binaural' option is supported only with '-stereo' or '-stereo_dmx_evs'" ); + } +#endif + /*-----------------------------------------------------------------* * Finalize initialization *-----------------------------------------------------------------*/ @@ -1540,12 +1547,6 @@ static ivas_error printConfigInfo_enc( if ( hEncoderConfig->stereo_dmx_evs ) { fprintf( stdout, "IVAS format: stereo downmix to bit-exact EVS mono\n" ); -#ifdef BINAURAL_AUDIO_CMDLINE - if ( hEncoderConfig->is_binaural ) - { - fprintf( stdout, "Optional indication: binaural audio\n" ); - } -#endif } else { @@ -1580,12 +1581,6 @@ static ivas_error printConfigInfo_enc( { fprintf( stdout, "IVAS format: stereo - MDCT stereo\n" ); } -#endif -#ifdef BINAURAL_AUDIO_CMDLINE - if ( hEncoderConfig->is_binaural ) - { - fprintf( stdout, "Optional indication: binaural audio\n" ); - } #endif } else if ( hEncoderConfig->ivas_format == ISM_FORMAT ) @@ -1654,6 +1649,13 @@ static ivas_error printConfigInfo_enc( } } +#ifdef BINAURAL_AUDIO_CMDLINE + if ( hEncoderConfig->is_binaural ) + { + fprintf( stdout, "Optional indication: binaural audio\n" ); + } +#endif + /*-----------------------------------------------------------------* * Print CNG update interval, if DTX is activated *-----------------------------------------------------------------*/ -- GitLab From fa225a5faade0f49ca83ae402cef4094ef2e9417 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jun 2023 10:00:56 +0200 Subject: [PATCH 2/2] add initialization of 'hEncoderConfig->is_binaural' parameter --- lib_enc/lib_enc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 2eb9e6ec3c..2668eed044 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2325,6 +2325,9 @@ static void init_encoder_config( hEncoderConfig->nchan_inp = 1; hEncoderConfig->element_mode_init = EVS_MONO; hEncoderConfig->ivas_format = UNDEFINED_FORMAT; +#ifdef BINAURAL_AUDIO_CMDLINE + hEncoderConfig->is_binaural = 0; +#endif hEncoderConfig->Opt_SC_VBR = 0; hEncoderConfig->last_Opt_SC_VBR = 0; hEncoderConfig->Opt_AMR_WB = 0; -- GitLab