Commit 830ab066 authored by Stephane Ragot's avatar Stephane Ragot
Browse files

Merge branch 'binaural_audio_cmdline' into 'main'

handling binaural in cmd line

See merge request !699
parents d2976d42 9b967796
Loading
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 ) // 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" );
+5 −0
Original line number Diff line number Diff line
@@ -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 */

lib_com/options.h

100644 → 100755
+2 −0
Original line number Diff line number Diff line
@@ -236,6 +236,8 @@

#define ENHANCED_STEREO_DMX                             /* Orange : Contribution 48 - Enhanced stereo downmix. */

#define BINAURAL_AUDIO_CMDLINE

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

+3 −0
Original line number Diff line number Diff line
@@ -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 */
+13 −1
Original line number Diff line number Diff line
@@ -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                           */
#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++ )
Loading