Commit bf668044 authored by vaclav's avatar vaclav
Browse files

Issue 233: Improve robustness of command-line parameters; under IMPROVE_CMDLINE_ROBUSTNESS

parent ae0c7a44
Loading
Loading
Loading
Loading
Loading
+50 −1
Original line number Diff line number Diff line
@@ -1273,8 +1273,21 @@ static bool parseCmdlIVAS_enc(
            arg->inputFormat = IVAS_ENC_INPUT_ISM;
            i++;

#ifdef IMPROVE_CMDLINE_ROBUSTNESS
            if ( i < argc - 4 )
#else
            if ( i < argc - 5 )
#endif
            {
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                if ( !is_digits_only( argv[i] ) )
                {
                    fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" );
                    usage_enc();
                    return false;
                }
#endif

                if ( sscanf( argv[i], "%d", &tmp ) > 0 )
                {
                    i++;
@@ -1286,6 +1299,14 @@ static bool parseCmdlIVAS_enc(
                    usage_enc();
                    return false;
                }
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                else if ( tmp > IVAS_MAX_NUM_OBJECTS )
                {
                    fprintf( stderr, "Error: Too high number of ISM channels specified!\n\n" );
                    usage_enc();
                    return false;
                }
#endif
                else
                {
                    arg->inputFormatConfig.ism.numObjects = (int16_t) tmp;
@@ -1317,7 +1338,11 @@ static bool parseCmdlIVAS_enc(
                }
                else
                {
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                    fprintf( stderr, "Error: not enough metadata arguments specified!\n\n" );
#else
                    fprintf( stderr, "Error: not enough arguments\n\n" );
#endif
                    usage_enc();
                    return false;
                }
@@ -1359,7 +1384,19 @@ static bool parseCmdlIVAS_enc(
                    arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_HOA3;
                    break;
                default:

#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                    if ( is_number( argv[i - 1] ) )
                    {
                        fprintf( stderr, "Error: Wrong SBA order specified!\n\n" );
                    }
                    else
                    {
                        fprintf( stderr, "Error: SBA order specified must be a number!\n\n" );
                    }
#else
                    fprintf( stderr, "Error: Wrong SBA order specified!\n\n" );
#endif
                    usage_enc();
                    return false;
            }
@@ -1371,6 +1408,15 @@ static bool parseCmdlIVAS_enc(

            if ( i < argc - 4 )
            {
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                if ( !is_digits_only( argv[i] ) )
                {
                    fprintf( stderr, "Error: Number of MASA channels must be an integer number!\n\n" );
                    usage_enc();
                    return false;
                }
#endif

                if ( sscanf( argv[i], "%d", &tmp ) > 0 )
                {
                    i++;
@@ -1385,7 +1431,11 @@ static bool parseCmdlIVAS_enc(
                        arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_2CH;
                        break;
                    default:
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                        fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" );
#else
                        fprintf( stderr, "Error: MASA channels must for the moment be 1 or 2.\n\n" );
#endif
                        usage_enc();
                        return false;
                }
@@ -1410,7 +1460,6 @@ static bool parseCmdlIVAS_enc(

            if ( i < argc - 4 )
            {

                if ( strcmp( to_upper( argv[i] ), "5_1" ) == 0 )
                {
                    arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1;
+2 −0
Original line number Diff line number Diff line
@@ -175,6 +175,8 @@
#define FIX_GET_DELAY_RETURN                            /* Issue 223: change return data type in function get_delay() */
#define NTT_REDUC_COMP_POC                              /* NTT Contribution 10: Complexity reduction of phase spectrum in stereo downmix*/
#define FIX_ISM_DECODER_PRINTOUT                        /* Issue 229: fix ISM decoder printout */
#define IMPROVE_CMDLINE_ROBUSTNESS                      /* Issue 233: Improve robustness of command-line parameters */



/* ################## End DEVELOPMENT switches ######################### */