Commit dc1ecdb5 authored by Stephane Ragot's avatar Stephane Ragot
Browse files

initial support of -binaural command line option

parent 9a35b738
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -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 ) // VE: 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" );
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@

#define FIX_481_UNUSED_VARIABLES                        /* Nokia: Fix issue #481: Unused debug variables */

#define BINAURAL_AUDIO_CMDLINE
                                                        /* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+3 −0
Original line number Diff line number Diff line
@@ -1048,6 +1048,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 */
+30 −2
Original line number Diff line number Diff line
@@ -267,7 +267,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() */
#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;
@@ -280,6 +285,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 )
    {
@@ -305,7 +313,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                                                                                */
#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                                                                */
@@ -326,6 +339,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 )
@@ -1528,6 +1544,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
        {
@@ -1562,6 +1584,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 )