Esempio n. 1
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{
/*
    if(argc < 5) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }
*/
    if(strlen(opt_inputfile) == 0 || strlen(opt_outputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;

    }

    if(opt_framelen > 8192) {
        FA_PRINT_ERR("FAIL: the frame length is too large, should <= 8192\n");
        return -1;
    }

    if(opt_fftwintype < HAMMING || opt_fftwintype > KAISER) {
        FA_PRINT_ERR("FAIL: fft window type wrong, only 0,1,2,3 active\n");
        return -1;
    }

    if(opt_mdctwintype < MDCT_SINE || opt_mdctwintype > MDCT_KBD) {
        FA_PRINT_ERR("FAIL: mdct window type wrong, only 0,1 active\n");
        return -1;
    }

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 2
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{
    if(argc < 5) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    if(strlen(opt_inputfile) == 0 || strlen(opt_outputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;

    }

    if(opt_framelen > 8192) {
        FA_PRINT_ERR("FAIL: the frame length is too large, should <= 8192\n");
        return -1;
    }

    if(opt_winlen > 2048) {
        FA_PRINT_ERR("FAIL: the window length is too large, should <= 2048\n");
        return -1;
    }

    if(opt_wintype < HAMMING || opt_wintype > KAISER) {
        FA_PRINT_ERR("FAIL: window type wrong, only 0,1,2 active\n");
        return -1;
    }

    if(opt_fc <= 0 || opt_fc >=1) {
        FA_PRINT_ERR("FAIL: cutoff freqency should be in (0,1)\n");
        return -1;
    }

    if(opt_fc1 <= 0 || opt_fc1 >=1) {
        FA_PRINT_ERR("FAIL: cutoff start freqency should be in (0,1)\n");
        return -1;
    }

    if(opt_fc2 <= 0 || opt_fc2 >=1) {
        FA_PRINT_ERR("FAIL: cutoff stop freqency should be in (0,1)\n");
        return -1;
    }

    if(opt_fc1 >= opt_fc2) {
        FA_PRINT_ERR("FAIL: cutoff start freqency should < stop freqency\n");
        return -1;
    }

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 3
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{

    if(argc < 3) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    if (strlen(opt_outputfile) == 0) {
        char tmp[256];
        char *t = strrchr(opt_inputfile, '.');
        int l = t ? strlen(opt_inputfile) - strlen(t) : strlen(opt_inputfile);

        memset(tmp, 0, 256);
        memset(opt_outputfile, 0, 256);

        strncpy(tmp, opt_inputfile, l);
        sprintf(opt_outputfile, "%s.aac", tmp);
    }

    if(strlen(opt_inputfile) == 0 || strlen(opt_outputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;

    }
/*
    if(opt_bitrate > 256 || opt_bitrate < 32)  {
        FA_PRINT_ERR("FAIL: the bitrate is too large or too short, should be in [32000, 256000]\n");
        return -1;
    }
*/
    if(opt_speedlevel > 6 || opt_speedlevel < 1)  {
        FA_PRINT_ERR("FAIL: out of range, should be in [1,6]\n");
        return -1;
    }
 
    if(opt_bandwidth > 20 || opt_bandwidth < 5)  {
        FA_PRINT_ERR("FAIL: out of range, should be in [5,20] kHz\n");
        return -1;
    }
         

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 4
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{
    if(argc < 5) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    if(strlen(opt_inputfile) == 0 || strlen(opt_outputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;

    }
    if(opt_framelen > 8192) {
        FA_PRINT_ERR("FAIL: the frame length is too large\n");
        return -1;
    }

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 5
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{

    if(argc < 5) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    if(strlen(opt_inputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    if(strlen(opt_video_outputfile) == 0 && strlen(opt_audio_outputfile) == 0) {
        FA_PRINT_ERR("FAIL: input and output file should input\n");
        return -1;
    }

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 6
0
/**
 * @brief: check the input value valid, should check the valid scope
 *
 * @return: 0 if success, -1 if error
 */
static int fa_checkopt(int argc)
{
    if(argc < 2) {
        FA_PRINT("%s\n", default_set);
        return 0;
    }

    /*this is just example*/
    if(opt_samplerate > 48000) {
        FA_PRINT_ERR("FAIL: the samplerate is not right\n");
        return -1;
    }

    FA_PRINT("SUCC: check option ok\n");
    return 0;
}
Esempio n. 7
0
int main(int argc, char *argv[])  
{  
    int ret;

    FA_PRINT_INIT(FA_PRINT_ENABLE,
                  FA_PRINT_FILE_ENABLE,FA_PRINT_STDOUT_ENABLE,FA_PRINT_STDERR_ENABLE,
                  /*FA_PRINT_FILE_DISABLE,FA_PRINT_STDOUT_ENABLE,FA_PRINT_STDERR_ENABLE,*/
                  FA_PRINT_PID_ENABLE,
                  "/tmp", "testlog", "TS");

    ret = fa_parseopt(argc, argv);
    if(ret)
        FA_PRINT_ERR("FAIL: now doing the abnormal things\n");
    else
        FA_PRINT("SUCC: now doing the normal thing\n");

    FA_PRINT_DBG("TEST: now test debug info\n");

    FA_PRINT_UNINIT();
    return 0;  
}  
Esempio n. 8
0
/**
 * @brief: parse the command line
 *         this is the simple template which will be used by falab projects
 *
 * @param:argc
 * @param:argv[]
 *
 * @return: 0 if success, -1 if error(input value maybe not right)
 */
int fa_parseopt(int argc, char *argv[])
{
    int ret;
    const char *die_msg = NULL;

    while (1) {
        static char * const     short_options = "hHLi:o:l:t:";  
        static struct option    long_options[] = 
                                {
                                    { "help"       , 0, 0, 'h'}, 
                                    { "long-help"  , 0, 0, 'H'},
                                    { "license"    , 0, 0, 'L'},
                                    { "input"      , 1, 0, 'i'},                 
                                    { "output"     , 1, 0, 'o'},                 
                                    { "framelen"   , 1, 0, 'l'},        
                                    { "wintype"    , 1, 0, 't'},        
                                    { "winlen"     , 1, 0, OPT_WINLEN},
                                    { "firtype"    , 1, 0, OPT_FIRTYPE},
                                    { "cutoff"     , 1, 0, OPT_CUTOFF},
                                    { "cutoff1"    , 1, 0, OPT_CUTOFF1},
                                    { "cutoff2"    , 1, 0, OPT_CUTOFF2},
                                    {0             , 0, 0,  0},
                                };
        int c = -1;
        int option_index = 0;

        c = getopt_long(argc, argv, 
                        short_options, long_options, &option_index);

        if (c == -1) {
            break;
        }

        if (!c) {
            die_msg = usage;
            break;
        }

        switch (c) {
            case 'h': {
                          die_msg = short_help;
                          break;
                      }

            case 'H': {
                          die_msg = long_help;
                          break;
                      }
                      
            case 'L': {
                          die_msg = license;
                          break;
                      }

            case 'i': {
                          if (sscanf(optarg, "%s", opt_inputfile) > 0) {
                              FA_PRINT("SUCC: inputfile is %s\n", opt_inputfile);
                          }else {
                              FA_PRINT_ERR("FAIL: no inputfile\n");
                          }
                          break;
                      }

            case 'o': {
                          if (sscanf(optarg, "%s", opt_outputfile) > 0) {
                              FA_PRINT("SUCC: outputfile is %s\n", opt_outputfile);
                          }else {
                              FA_PRINT_ERR("FAIL: no outputfile\n");
                          }
                          break;
                      }

            case 'l': {
                          unsigned int i;
                          if (sscanf(optarg, "%u", &i) > 0) {
                              opt_framelen = i;
                              FA_PRINT("SUCC: set frame length = %u\n", opt_framelen);
                          }
                          break;
                      }

            case 't': {
                          unsigned int i;
                          if (sscanf(optarg, "%u", &i) > 0) {
                              opt_wintype = i;
                              FA_PRINT("SUCC: set win type = %u\n", opt_wintype);
                          }
                          break;
                      }
                      
            case OPT_WINLEN: {
                                  unsigned int i;
                                  if (sscanf(optarg, "%u", &i) > 0) {
                                      opt_winlen = i;
                                      FA_PRINT("SUCC: set window length = %u\n", opt_winlen);
                                  }
                                  break;
                             }
                             
            case OPT_FIRTYPE: {
                                  unsigned int i;
                                  if (sscanf(optarg, "%u", &i) > 0) {
                                      opt_firtype = i;
                                      FA_PRINT("SUCC: set fir type = %u\n", opt_firtype);
                                  }
                                  break;
                              }
                             
            case OPT_CUTOFF: {
                                  float i;
                                  if (sscanf(optarg, "%f", &i) > 0) {
                                      opt_fc = i;
                                      FA_PRINT("SUCC: set fir cutoff freqency = %f\n", opt_fc);
                                  }
                                  break;
                              }
                             
            case OPT_CUTOFF1:{
                                  float i;
                                  if (sscanf(optarg, "%f", &i) > 0) {
                                      opt_fc1 = i;
                                      FA_PRINT("SUCC: set fir cutoff start freqency = %f\n", opt_fc1);
                                  }
                                  break;
                              }
                             
            case OPT_CUTOFF2:{
                                  float i;
                                  if (sscanf(optarg, "%f", &i) > 0) {
                                      opt_fc2 = i;
                                      FA_PRINT("SUCC: set fir cutoff stop freqency = %f\n", opt_fc2);
                                  }
                                  break;
                              }

            case '?':
            default:
                      die_msg = usage;
                      break;
        }
    }

    if(die_msg) {
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*check the input validity*/
    ret = fa_checkopt(argc);
    if(ret) {
        die_msg = usage;
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*print the settings*/
    fa_printopt();

    return 0;
fail:
    return -1;
}
Esempio n. 9
0
/**
 * @brief: parse the command line
 *         this is the simple template which will be used by falab projects
 *
 * @param:argc
 * @param:argv[]
 *
 * @return: 0 if success, -1 if error(input value maybe not right)
 */
int fa_parseopt(int argc, char *argv[])
{
    int ret;
    const char *die_msg = NULL;

    while (1) {
        static char * const     short_options = "hHLi:o:l:";  
        static struct option    long_options[] = 
                                {
                                    { "help"       , 0, 0, 'h'}, 
                                    { "long-help"  , 0, 0, 'H'},
                                    { "license"    , 0, 0, 'L'},
                                    { "input"      , 1, 0, 'i'},                 
                                    { "output"     , 1, 0, 'o'},                 
                                    { "framelen"   , 1, 0, 'l'},        
                                    {0             , 0, 0,  0},
                                };
        int c = -1;
        int option_index = 0;

        c = getopt_long(argc, argv, 
                        short_options, long_options, &option_index);

        if (c == -1) {
            break;
        }

        if (!c) {
            die_msg = usage;
            break;
        }

        switch (c) {
            case 'h': {
                          die_msg = short_help;
                          break;
                      }

            case 'H': {
                          die_msg = long_help;
                          break;
                      }
                      
            case 'L': {
                          die_msg = license;
                          break;
                      }

            case 'i': {
                          if (sscanf(optarg, "%s", opt_inputfile) > 0) {
                              FA_PRINT("SUCC: inputfile is %s\n", opt_inputfile);
                          }else {
                              FA_PRINT_ERR("FAIL: no inputfile\n");
                          }
                          break;
                      }

            case 'o': {
                          if (sscanf(optarg, "%s", opt_outputfile) > 0) {
                              FA_PRINT("SUCC: outputfile is %s\n", opt_outputfile);
                          }else {
                              FA_PRINT_ERR("FAIL: no outputfile\n");
                          }
                          break;
                      }

            case 'l': {
                          unsigned int i;
                          if (sscanf(optarg, "%u", &i) > 0) {
                              opt_framelen = i;
                              FA_PRINT("SUCC: set frame length = %u\n", opt_framelen);
                          }
                          break;
                      }

            case '?':
            default:
                      die_msg = usage;
                      break;
        }
    }

    if(die_msg) {
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*check the input validity*/
    ret = fa_checkopt(argc);
    if(ret) {
        die_msg = usage;
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*print the settings*/
    fa_printopt();

    return 0;
fail:
    return -1;
}
Esempio n. 10
0
/**
 * @brief: parse the command line
 *         this is the simple template which will be used by falab projects
 *
 * @param:argc
 * @param:argv[]
 *
 * @return: 0 if success, -1 if error(input value maybe not right)
 */
int fa_parseopt(int argc, char *argv[])
{
    int ret;
    const char *die_msg = NULL;

    while (1) {
        static char * const     short_options = "hHLli:v:a:";
        static struct option    long_options[] =
        {
            { "help"           , 0, 0, 'h'},
            { "help"           , 0, 0, 'H'},
            { "license"        , 0, 0, 'L'},
            { "license"        , 0, 0, 'l'},
            { "input"          , 1, 0, 'i'},
            { "video output"   , 1, 0, 'v'},
            { "audio output"   , 1, 0, 'a'},
            {0                 , 0, 0,  0},
        };
        int c = -1;
        int option_index = 0;

        c = getopt_long(argc, argv, short_options, long_options, &option_index);

        if (c == -1) {
            break;
        }

        if (!c) {
            die_msg = usage;
            break;
        }

        switch (c) {
        case 'h': {
            die_msg = help;
            break;
        }

        case 'H': {
            die_msg = help;
            break;
        }

        case 'L': {
            die_msg = license;
            break;
        }

        case 'l': {
            die_msg = license;
            break;
        }

        case 'i': {
            if (sscanf(optarg, "%s", opt_inputfile) > 0) {
                FA_PRINT("SUCC: inputfile is %s\n", opt_inputfile);
            } else {
                FA_PRINT_ERR("FAIL: no inputfile\n");
            }
            break;
        }

        case 'v': {
            if (sscanf(optarg, "%s", opt_video_outputfile) > 0) {
                FA_PRINT("SUCC: video outputfile is %s\n", opt_video_outputfile);
            } else {
                FA_PRINT_ERR("FAIL: no video outputfile\n");
            }
            break;
        }

        case 'a': {
            if (sscanf(optarg, "%s", opt_audio_outputfile) > 0) {
                FA_PRINT("SUCC: audio outputfile is %s\n", opt_audio_outputfile);
            } else {
                FA_PRINT_ERR("FAIL: no audio outputfile\n");
            }
            break;
        }

        case '?':
        default:
            die_msg = usage;
            break;
        }
    }

    if(die_msg) {
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*check the input validity*/
    ret = fa_checkopt(argc);
    if(ret) {
        die_msg = usage;
        FA_PRINT("%s\n", die_msg);
        goto fail;
    }

    /*print the settings*/
    fa_printopt();

    return 0;
fail:
    return -1;
}