Commit 919f879c authored by vaclav's avatar vaclav
Browse files

Merge branch '233-improve-robustness-of-command-line-parameters' of...

Merge branch '233-improve-robustness-of-command-line-parameters' of https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec into 233-improve-robustness-of-command-line-parameters
parents 586ba628 36f5a1fc
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -1354,12 +1354,20 @@ static bool parseCmdlIVAS_enc(
            arg->inputFormat = IVAS_ENC_INPUT_SBA;

            /* SBA configuration */
            if ( i < argc - 4 )
            if ( i < argc - 4
#ifdef IMPROVE_CMDLINE_ROBUSTNESS
                 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0
#endif
            )
            {
#ifndef IMPROVE_CMDLINE_ROBUSTNESS
                if ( sscanf( argv[i], "%d", &tmp ) > 0 )
                {
#endif
                    i++;
#ifndef IMPROVE_CMDLINE_ROBUSTNESS
                }
#endif
            }
            else
            {
@@ -1384,19 +1392,7 @@ 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;
            }
+0 −3
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ def collect_for_sanitizer_test(file):
    )
    files_to_archive = find_failed_files_for_sanitizer_test(console_log, "logs")

    print("files_to_archive_noPLC:", files_to_archive_noPLC)
    print("files_to_archive:", files_to_archive)

    log_folder = pathlib.Path("./LOGS_PLC")
    log_folder.mkdir()
    for test in files_to_archive.keys():
+11 −0
Original line number Diff line number Diff line
@@ -1614,6 +1614,17 @@ static void ivas_param_mc_get_mixing_matrices(

        matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag );

#ifdef FIX_I220_PARAMMC_CPROTO
        /* make sure we have no negative entries in Cproto_diag due to rounding errors */
        for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ )
        {
            if ( Cproto_diag[ch_idx1] < 0.0f )
            {
                Cproto_diag[ch_idx1] = 0.0f;
            }
        }
#endif

        /* Computing the mixing matrices */

        /* bands with decorr */
+43 −4
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ char *to_upper( char *str )
 * Check if a string contains only digits.
 *---------------------------------------------------------------------*/

bool is_digits_only( char *str )
bool is_digits_only( const char *str )
{
    int16_t i;

@@ -86,19 +86,58 @@ bool is_digits_only( char *str )
 * Check if a string is a number.
 *---------------------------------------------------------------------*/

bool is_number( char *str )
bool is_number( const char *str )
{
    bool decimal_separator_found;
    int16_t i;
    int16_t numeric_len;

    decimal_separator_found = false;
    i = 0;
    numeric_len = 0;

    /* Check for null string or sign character */
    if ( str[i] == '\0' )
    {
        return false;
    }
    else if ( str[i] == '+' || str[i] == '-' )
    {
        i++;
    }

    /* Ensure rest of string is numeric and only one decimal separator is present */
    while ( str[i] != 0 )
    {
        if ( ( str[i] < '0' || str[i] > '9' ) && str[i] != '.' && str[i] != '-' && str[i] != '\n' && str[i] != '\r' )
        if ( str[i] < '0' || str[i] > '9' )
        {
            if ( str[i] == '.' )
            {
                if ( decimal_separator_found )
                {
                    return false;
                }
                else
                {
                    decimal_separator_found = true;
                }
            }
            else if ( str[i] != '\r' && str[i] != '\n' )
            {
                return false;
            }
        }
        else
        {
            numeric_len++;
        }
        i++;
    }

    if ( numeric_len == 0 )
    {
        return false;
    }

    return true;
}
+2 −2
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@
#include <stdbool.h>
#include <stdint.h>

bool is_digits_only( char *str );
bool is_digits_only( const char *str );

bool is_number( char *str );
bool is_number( const char *str );

char *to_upper( char *str );