diff --git a/apps/encoder.c b/apps/encoder.c index dc97a1acfdde0e74d68c60c5fafda488e4352864..1dc0aead517c33f79a1a282ca6d40b4745143074 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -98,6 +98,9 @@ typedef struct char *outputBitstreamFilename; int32_t inputFs; IVAS_ENC_INPUT_FORMAT inputFormat; +#ifdef BINAURAL_AUDIO_CMDLINE + bool is_binaural; +#endif EncInputFormatConfig inputFormatConfig; bool max_bwidth_user; IVAS_ENC_BANDWIDTH maxBandwidth; @@ -362,17 +365,29 @@ int main( switch ( arg.inputFormat ) { case IVAS_ENC_INPUT_MONO: +#ifdef BINAURAL_AUDIO_CMDLINE + if ( ( error = IVAS_ENC_ConfigureForMono( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, caConfig, arg.inputFormatConfig.stereoToMonoDownmix, arg.is_binaural ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_ENC_ConfigureForMono( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, caConfig, arg.inputFormatConfig.stereoToMonoDownmix ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_ENC_ConfigureForMono failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; } break; case IVAS_ENC_INPUT_STEREO: +#ifdef BINAURAL_AUDIO_CMDLINE +#ifdef DEBUGGING + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural ) ) != IVAS_ERR_OK ) +#endif +#else #ifdef DEBUGGING if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig ) ) != IVAS_ERR_OK ) +#endif #endif { fprintf( stderr, "\nIVAS_ENC_ConfigureForStereo failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); @@ -865,6 +880,9 @@ static void initArgStruct( EncArguments *arg ) arg->outputBitstreamFilename = NULL; arg->inputFs = 0; arg->inputFormat = IVAS_ENC_INPUT_MONO; +#ifdef BINAURAL_AUDIO_CMDLINE + arg->is_binaural = false; +#endif arg->inputFormatConfig.stereoToMonoDownmix = false; arg->max_bwidth_user = false; arg->maxBandwidth = IVAS_ENC_BANDWIDTH_UNDEFINED; @@ -1207,6 +1225,16 @@ 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++; @@ -1487,6 +1515,7 @@ static bool parseCmdlIVAS_enc( { arg->inputFormat = IVAS_ENC_INPUT_MONO; arg->inputFormatConfig.stereoToMonoDownmix = true; + i++; } else if ( strcmp( argv_to_upper, "-BYPASS" ) == 0 ) // TODO: should be renamed to "-pca" @@ -1674,6 +1703,9 @@ 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" ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f455c552a5d039a93848d74ceffbe6811b7ea141..2804668e0f12101898459a08cdde318d4945f633 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -61,7 +61,12 @@ void stereo_dmx_evs_enc( STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ +#ifdef BINAURAL_AUDIO_CMDLINE + const int16_t n_samples, /* i : number of input samples */ + const bool is_binaural /* i : indication that input is binaural audio */ +#else const int16_t n_samples /* i : number of input samples */ +#endif ); /*! r: number of channels to be analysed */ diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index d7f39aab3d2f4f042badcea4492d55033ce80628..369eb91f249bc50cca322b989491bde49da96c88 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -236,6 +236,8 @@ #define ENHANCED_STEREO_DMX /* Orange : Contribution 48 - Enhanced stereo downmix. */ +#define BINAURAL_AUDIO_CMDLINE + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 7caab6da6afcdc655995e281c2453e0a02cdd8fc..a4bd36207db192df2b52e3c769ecfa5880631342 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1096,6 +1096,9 @@ typedef struct encoder_config_structure int16_t nchan_inp; /* number of input audio channels */ 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 */ +#endif int16_t element_mode_init; /* element mode used at initialization */ int16_t stereo_dmx_evs; /* flag to indicate that stereo downmix for EVS encoder */ diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index ddb94525b3b4a2cd4c5f14701ee8c170bbd5badb..e479e28cdbb87882e1510447c1ae0ab5617d8939 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -1137,7 +1137,12 @@ void stereo_dmx_evs_enc( STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ - const int16_t n_samples /* i : number of input samples */ +#ifdef BINAURAL_AUDIO_CMDLINE + const int16_t n_samples, /* i : number of input samples */ + const bool is_binaural /* i : indication that input is binaural audio */ +#else + const int16_t n_samples /* i : number of input samples */ +#endif ) { int16_t n; @@ -1158,6 +1163,13 @@ void stereo_dmx_evs_enc( int16_t input_frame; +#ifdef BINAURAL_AUDIO_CMDLINE + if ( is_binaural ) + { + /* use of is_binaural flag is to be considered */ + } +#endif + input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); for ( n = 0; n < input_frame; n++ ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 37c3e57ab5c31a317b1223714d9b17e98e1b09b6..28b954c841901eff829b1682ec74aeced1d65fae 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -269,7 +269,12 @@ ivas_error IVAS_ENC_ConfigureForMono( const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig, /* i : configuration of channel-aware mode, can by set to default by using IVAS_ENC_GetDefaultChannelAwareConfig() */ - const bool downmixFromStereo /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ +#ifdef BINAURAL_AUDIO_CMDLINE + const bool downmixFromStereo, /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ + const bool is_binaural /* i : if true, the input is binaural audio */ +#else + const bool downmixFromStereo /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ +#endif ) { ivas_error error; @@ -282,6 +287,9 @@ 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; +#endif if ( downmixFromStereo ) { @@ -307,7 +315,12 @@ ivas_error IVAS_ENC_ConfigureForStereo( const int32_t bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ +#ifdef BINAURAL_AUDIO_CMDLINE + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const bool is_binaural /* i : flag indicating if input is binaural audio */ +#else + const IVAS_ENC_DTX_CONFIG dtxConfig /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ +#endif #ifdef DEBUGGING , const IVAS_ENC_STEREO_MODE stereoMode /* i : forces a specific stereo coding mode */ @@ -328,6 +341,9 @@ ivas_error IVAS_ENC_ConfigureForStereo( hEncoderConfig = st_ivas->hEncoderConfig; hEncoderConfig->nchan_inp = 2; hEncoderConfig->ivas_format = STEREO_FORMAT; +#ifdef BINAURAL_AUDIO_CMDLINE + hEncoderConfig->is_binaural = is_binaural; +#endif #ifdef DEBUGGING switch ( stereoMode ) @@ -1257,7 +1273,11 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( if ( hEncoderConfig->stereo_dmx_evs == 1 ) { inputBufferSize /= 2; +#ifdef BINAURAL_AUDIO_CMDLINE + stereo_dmx_evs_enc( st_ivas->hStereoDmxEVS, hEncoderConfig->input_Fs, inputBuffer, inputBufferSize, hEncoderConfig->is_binaural ); +#else stereo_dmx_evs_enc( st_ivas->hStereoDmxEVS, hEncoderConfig->input_Fs, inputBuffer, inputBufferSize ); +#endif } if ( hEncoderConfig->Opt_AMR_WB ) @@ -1539,6 +1559,12 @@ 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 { @@ -1573,6 +1599,12 @@ 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 ) diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index a4a3726b45003fba91b8c9163cc77f0876216be6..8d8ede4d77a534370aed3835b9b965d6de86f683 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -161,8 +161,13 @@ ivas_error IVAS_ENC_ConfigureForMono( const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig, /* i : configuration of channel-aware mode, can by set to default by using IVAS_ENC_GetDefaultChannelAwareConfig() */ + const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig, /* i : configuration of channel-aware mode, can by set to default by using IVAS_ENC_GetDefaultChannelAwareConfig() */ +#ifdef BINAURAL_AUDIO_CMDLINE + const bool downmixFromStereo, /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ + const bool is_binaural /* i : if true, the input is binaural audio */ +#else const bool downmixFromStereo /* i : if true, the encoder accepts a stereo input and internally downmixes it to mono before encoding */ +#endif ); /*! r: error code */ @@ -172,10 +177,15 @@ ivas_error IVAS_ENC_ConfigureForStereo( const int32_t bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ +#ifdef BINAURAL_AUDIO_CMDLINE + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const bool is_binaural /* i : flag indicating if input is binaural audio */ +#else const IVAS_ENC_DTX_CONFIG dtxConfig /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ +#endif #ifdef DEBUGGING , - const IVAS_ENC_STEREO_MODE stereoMode /* i : forces a specific stereo coding mode */ + const IVAS_ENC_STEREO_MODE stereoMode /* i : forces a specific stereo coding mode */ #endif );