Beispiel #1
0
Ipp32s  PrepareInput(FILE* pFile, Ipp8s* comment, Ipp8u** pBuff, FILE *fptrLog)
{
   Ipp8s pString[MAX_LEN_STRING];
   Ipp32s lenFile;
   Ipp8u *buff = NULL;
   fseek(pFile,0,SEEK_END);
   lenFile = ftell(pFile); /* size of file*/
   buff=ippsMalloc_8u(lenFile);
   if(!buff){
      sprintf(pString, "\nNo memory to load %d bytes from %s file",lenFile,comment);
      OutputInfoString(1, fptrLog, (const Ipp8s*)pString);
      return MEMORY_FAIL;
   }
//   rewind(pFile);
   fseek(pFile,0,SEEK_SET);

   lenFile = (Ipp32s)fread(buff,1,lenFile,pFile);
   if (PreProcessBitstream((Ipp8s *)buff, lenFile)) {
       OutputInfoString(1, fptrLog,"\nUnknown format bitstream.\n");
       return UNKNOWN_FORMAT;
   }

   *pBuff = buff;
   return lenFile;
}
Beispiel #2
0
static void measure_output(FILE *f_log, MeasureIt *m, double speech_sec)
{
    Ipp8s pString[MAX_LEN_STRING];

    m->speed_in_mhz = getUSec(m->p_start,m->p_end)/speech_sec;
    sprintf(pString, "%4.2f MHz per channel\n", m->speed_in_mhz);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
}
Beispiel #3
0
int ReadCommandLine(CommandLineParams *params, int argc, char *argv[])
{
   int usage = 0;


   argc--;
   while(argc-- > 0){
      argv++;
      if ('-' == (*argv)[0]) {
         if (!strncmp("-f",*argv,2)){
            if(argc-->0){
               int f = atoi(*++argv);
               if (f == 8)
                  params->freq = 8000;
               else if (f == 16) {
                  params->freq = 16000;
               } else {
                  OutputInfoString(1, NULL,"The sample frequency must be 8 or 16 kHz\n");
                  usage = 1;
               }
            }
            continue;
         } else if(!strcmp("-type",*argv)) {
            if(argc-->0){
              argv ++;
              strcpy(params->ECName, *argv);
            }
            continue;
         } else if(!strcmp("-a",*argv)) {
            if(argc-->0){
                argv ++;
                if (!strcmp("fb",*argv) || !strcmp("fullband",*argv)) {
                    params->alg = 1;
                } else if (!strcmp("sb",*argv) || !strcmp("subband",*argv)) {
                    params->alg = 2;
                } else if (!strcmp("sbf",*argv) || !strcmp("subbandfast",*argv)) {
                    params->alg = 3;
                } else {
                  OutputInfoString(1, NULL,"The algorithm specifier must be fb (fullband), sb (subband) or sbf (subband fast)\n");
                  usage = 1;
               }
            }
            continue;
         } else if(!strcmp("-ad",*argv)) {
             if(argc-->0){
                 argv ++;
                 if (!strcmp("full",*argv)) {
                     params->adapt = 1;
                 } else if (!strcmp("lite",*argv)) {
                     params->adapt = 2;
                 } else {
                     OutputInfoString(1, NULL,"The adaptation specifier must be full or lite.\n");
                     usage = 1;
                 }
             }
             continue;
         }else if(!strcmp("-l",*argv)) {/* set the echo tail length */
            if(argc-->0){
               int eplen = atoi(*++argv);
               if (eplen >= 1 && eplen <= 200)
                  params->tail = eplen;
               else {
                  OutputInfoString(1, NULL,"The echo tail length must be in the range [1, 200] ms for subband algorithm, [1, 16] for fullband algorithm\n");
                  usage = 1;
               }
            }
            continue;
         }else if (!strcmp(*argv,"-sys")){/* set the option to print the system information */
            params->printSysInfo=1;
            continue;
         }else if (!strcmp(*argv,"-delay")){
             if(argc-->0){
                 params->fdelay = atoi(*++argv);
                 if(params->fdelay < 0) params->fdelay=0;
             }
         }else if (!strcmp(*argv,"-ah")){/* set the anti-howling device on and set the howling detector device mode*/
             if(argc-->0){
                 int hdmode = atoi(*++argv);
                 if(hdmode==1)
                     params->ah_mode=1;
                 else
                     if(hdmode==2)
                         params->ah_mode=2;
                     else{
                         OutputInfoString(1, NULL,"The anti-howler mode must be set to 1 or 2\n");
                         usage = 1;
                     }
             }
             continue;
         }else if (!strcmp(*argv,"-sh")){/* Set the frequency shift number.
                                         Set the anti-howling device on.*/
             if(argc-->0){
                 params->freq_shift = atoi(*++argv);
             }
             continue;
         }else if (!strcmp(*argv,"-hp")){/* set the number of
                                         frames to be filtered after the howling has
                                         been detected.*/
             if(argc-->0){
                 params->hd_period = atoi(*++argv);
             }
             continue;
         }else if (!strcmp(*argv,"-s")){/* set the number of repeats */
            if(argc-->0){
               int rep = atoi(*++argv);
               if(0 == rep) rep=1;
               if(rep > params->nRepeat) params->nRepeat=rep;
            }
            continue;
         }else if(!strcmp("-o",*argv)) {/* the log file is specified */
            if(argc-->0){
              argv++;
              strcpy(params->logFileName, *argv);
              params->puttolog = 1;
            }
            continue;
         }else if (!strcmp(*argv,"-list")){ /* Print out the modes list */
            params->enumerate = 1;
            usage=1;
            return usage;
         } else if (!strcmp(*argv,"-c")){ /* the "csv" output is specified */
             if(argc-->0){
                 params->puttocsv=1;
                 argv++;
                 strcpy(params->csvFileName, *argv);
             }else{
                 OutputInfoString(1, NULL,"Unknown csv file name.\n");
                 usage=1;
             }
             continue;
         }
      }else{
         argc++;
         argv--;
         break;
      }
   }


   if ((params->alg == 1) && (params->tail > 16)) {
       OutputInfoString(1, NULL,"The echo tail length for fullband algorithm must be in the range of [1, 16] ms\n");
       usage = 1;
   }
   if(argc-->0){
      argv++;
      strcpy(params->rinFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown r-in input file.\n");
      usage=1;
   }
   if(argc-->0){
      argv++;
      strcpy(params->sinFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown s-in input file.\n");
      usage=1;
   }
   if(argc-->0){
      argv++;
      strcpy(params->soutFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown output file.\n");
      usage=1;
   }

   return usage;
}
Beispiel #4
0
void PrintUsage(const char * pAppName, FILE *fptrLog)
{
   char pString[MAX_LEN_STRING];

   sprintf(pString, "Usage: %s [options] <receive-in 16-bit PCM file> <send-in 16-bit PCM file> <send-out 16-bit PCM file>\n", pAppName);
   OutputInfoString(1, fptrLog, (const char*)pString);
   OutputInfoString(1, fptrLog,"   [-type EC type ] Set the type of Echo Canceller [EC_INT or EC_FP].\n");
   OutputInfoString(1, fptrLog,"   [-f <frequency>] Set the sampling frequency, kHz: 8 or 16. Default 8.\n");
   OutputInfoString(1, fptrLog,"   [-a <algorithm>] Algorithm specifier: fb (fullband), sb (subband) or sbf (subband fast). \n");
   OutputInfoString(1, fptrLog,"                    Default subband.\n");
   OutputInfoString(1, fptrLog,"   [-ad <algorithm>] Adaptation specifier: full or lite. Default full.\n");
   OutputInfoString(1, fptrLog,"   [-hp <num>]      Set the number of frames to be filtered after the howling has been detected.\n");
   OutputInfoString(1, fptrLog,"   [-ah <mode>]     Set the anti-howling device on. Mode=[1,2] defines the howling detector\n");
   OutputInfoString(1, fptrLog,"                    device algorithm. 1-spectra-based,2- energy-based.\n");
   OutputInfoString(1, fptrLog,"   [-sh <num>]      Set the frequency shift number.\n");
   OutputInfoString(1, fptrLog,"   [-l <num>]       Set the echo tail length, ms: in the range [1, 200] for subband algorithm.\n");
   OutputInfoString(1, fptrLog,"                    [1, 16] for fullband algorithm. Default 16.\n");
   OutputInfoString(1, fptrLog,"   [-delay <val>]   Set the delay in receive-in PCM file,  integer number of milliseconds. \n");
   OutputInfoString(1, fptrLog,"                    Leading end of receive-in PCM will be cut off prior to echo cancel. Default:no delay.\n");
   OutputInfoString(1, fptrLog,"   [-s <num>]       Set the number of times file to be processed (optional).\n");
   OutputInfoString(1, fptrLog,"   [-c <csv filename>] Set the csv file name for the performance info to be print to (optional).\n");
   OutputInfoString(1, fptrLog,"   [-o <log filename>] Set the log file name for the functional parameters to be print to (optional).\n");
   OutputInfoString(1, fptrLog,"   [-list] Print out the modes list(optional).\n");
   OutputInfoString(1, fptrLog,"   [-sys] Print out system information.\n");

   return;
}
Beispiel #5
0
Ipp32s WINAPI WinMain( HINSTANCE hinst, HINSTANCE xxx, LPWSTR lpCmdLine, Ipp32s yyy )
{
   Ipp8s line[WINCE_CMDLINE_SIZE];                     /* to copy command line */
   Ipp8s* argvv[WINCE_NCMD_PARAMS];
   Ipp8s** argv=argvv;

   wchar_t wexename[WINCE_EXENAME_SIZE];
   Ipp8s exename[WINCE_EXENAME_SIZE];
   Ipp8s cmdline[WINCE_CMDLINE_SIZE];

   /* simulate argc and argv parameters */
   Ipp32s argc;
#else /*Other OS*/
Ipp32s main(Ipp32s argc, Ipp8s *argv[])
{
#endif /*_WIN32_WCE*/
   CommandLineParams clParams;
   USC_EC_Params ecParams;
   USC_Status USCStatus;
   MeasureIt measure;
   FILE *fp_rin = NULL;
   FILE *fp_sin = NULL;
   FILE *fp_sout = NULL;
   FILE *f_log = NULL;
   vm_file *f_csv = NULL;        /* csv File    */
   Ipp8u *in1_buff_cur, *in2_buff_cur, *out_buff_cur;
   Ipp8u *in1_buff=NULL, *in2_buff=NULL, *out_buff=NULL;

   Ipp32s flen, in_len, lCallResult;
   Ipp32s i, frameNum, tailNum;
   Ipp32s usage=0, n_repeat=1;
   double speech_sec;
   Ipp32s delay=0;
   Ipp8s* appName=argv[0];
   Ipp8s pString[MAX_LEN_STRING];
   const  IppLibraryVersion *ver = NULL;
#if defined( _WIN32_WCE )

   GetModuleFileName( hinst, wexename, WINCE_EXENAME_SIZE );
   sprintf( exename, "%ls", wexename );
   sprintf( cmdline, "%ls", lpCmdLine );
   argc = parseCmndLine( exename, cmdline, line, WINCE_CMDLINE_SIZE, argv, WINCE_NCMD_PARAMS );

#endif

   ippStaticInit();

   SetCommandLineByDefault(&clParams);
   strcpy(clParams.csvFileName, "ec_speed.csv");

   usage = ReadCommandLine(&clParams, argc, argv);
   if(clParams.puttolog == 1) {
     if((f_log = fopen(clParams.logFileName, "a")) == NULL) return FOPEN_FAIL;
   } else f_log = NULL;
   if(usage) {
      if(clParams.enumerate == 1) {
         EnumerateStaticLinkedEC(f_log);
         if(f_log) fclose(f_log);
         return 0;
      } else {
        PrintUsage((const Ipp8s *)appName, f_log);
        return USAGE;
      }
   }

   lCallResult = LoadECByName((const Ipp8s *)clParams.ECName, &ecParams, f_log);
   if(lCallResult < 0) {
      sprintf(pString, "Cannot find %s echo canceller.\n", clParams.ECName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return LOAD_EC_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.GetInfo((USC_Handle)NULL, &ecParams.pInfo);
   ecParams.objEC = NULL;
   ecParams.pBanks = NULL;
   ecParams.nBanks = 0;

   if((fp_rin = fopen(clParams.rinFileName,"rb")) == NULL)  {
      sprintf(pString, "echo canceller: File %s [r-in] could not be open.\n", clParams.rinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sin = fopen(clParams.sinFileName,"rb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-in] could not be open.\n", clParams.sinFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if((fp_sout = fopen(clParams.soutFileName,"wb")) == NULL) {
      sprintf(pString, "echo canceller: File %s [s-out] could not be open.\n", clParams.soutFileName);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return FOPEN_FAIL;
   }
   if(clParams.puttocsv) { /* open the csv file */
      if((f_csv = vm_file_open(clParams.csvFileName, "a")) == NULL) {
         sprintf(pString, "\nFile %s could not be open.\n", clParams.csvFileName);
         OutputInfoString(1, f_log, (const Ipp8s*)pString);
         if(f_log) fclose(f_log);
         return FOPEN_FAIL;
      }
   }
    if(clParams.printSysInfo){
        OutputInfoString(0, f_log,"The Intel(R) echo canceller conformant to ITU G167 and G168,\n");
        ver = ippscGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSC library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
        ver = ippsGetLibVersion();
        sprintf(pString, "The Intel(R) IPPSP library used:  %d.%d.%d Build %d, name %s\n",
            ver->major,ver->minor,ver->majorBuild,ver->build,ver->Name);
        OutputInfoString(0, f_log, (const Ipp8s*)pString);
    }
    sprintf(pString, "Input  rin file: %s\n", clParams.rinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Input  sin file: %s\n", clParams.sinFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    sprintf(pString, "Output sout file: %s\n", clParams.soutFileName);
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.nlp) {
     case 0:
         sprintf(pString, "NLP disabled\n");
         break;
     case 1:
         sprintf(pString, "NLP type 1 enabled\n");
         break;
     default:
         sprintf(pString, "NLP  type 2 enabled\n");
    }

    switch(clParams.alg) {
     case EC_FULLBAND:
            ecParams.pInfo.params.algType = EC_FULLBAND;
            sprintf(pString, "mode : fullband \n");
            break;
     case EC_SUBBAND:
            ecParams.pInfo.params.algType = EC_SUBBAND;
            sprintf(pString, "mode : subband \n");
            break;
     case EC_AFFINESUBBAND:
         ecParams.pInfo.params.algType = EC_AFFINESUBBAND;
         sprintf(pString, "mode : subband affine projection \n");
         break;
     case EC_FASTSUBBAND:
            ecParams.pInfo.params.algType = EC_FASTSUBBAND;
            sprintf(pString, "mode : fast subband \n");
            break;
     default: return UNKNOWN_FORMAT;
   }
    OutputInfoString(1, f_log, (const Ipp8s*)pString);
    switch(clParams.adapt) {
        case 0:
            sprintf(pString, "adaptation : disable \n");
            ecParams.pInfo.params.modes.adapt = AD_OFF;
            break;
        case 2:
            sprintf(pString, "adaptation : lite \n");
            ecParams.pInfo.params.modes.adapt = AD_LITEADAPT;
            break;
        default:
            ecParams.pInfo.params.modes.adapt = AD_FULLADAPT;
            sprintf(pString, "adaptation : full \n");
    }
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   sprintf(pString, "echo tail length : %d\n", clParams.tail);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);
   if(clParams.puttocsv) {
    if(clParams.printSysInfo){
        sysInfoToCSV(f_csv);
    }
   }
   ecParams.pInfo.params.pcmType.sample_frequency = clParams.freq;
   ecParams.pInfo.params.pcmType.bitPerSample = 16;
   ecParams.pInfo.params.echotail = clParams.tail;
   ecParams.pInfo.params.modes.zeroCoeff = 1;///???
   ecParams.pInfo.params.modes.nlp = clParams.nlp;
   ecParams.pInfo.params.modes.cng = clParams.cng;
   ecParams.pInfo.params.modes.td = 1;
   ecParams.pInfo.params.modes.ah = clParams.ah_mode;

   ecParams.pUSC_EC_Fxns->std.NumAlloc((const USC_EC_Option *)&ecParams.pInfo.params, &ecParams.nBanks);
   ecParams.pBanks = (USC_MemBank*)ippsMalloc_8u(sizeof(USC_MemBank)*ecParams.nBanks);
   if(!ecParams.pBanks) {
      sprintf(pString, "\nLow memory: %d bytes not allocated\n", (int)(sizeof(USC_MemBank)*ecParams.nBanks));
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(fp_rin) fclose(fp_rin);
      if(fp_sin) fclose(fp_sin);
      if(fp_sout) fclose(fp_sout);
      if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }
   ecParams.pUSC_EC_Fxns->std.MemAlloc((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks);
   for(i=0;i<ecParams.nBanks;i++) {
     ecParams.pBanks[i].pMem = (Ipp8s *)ippsMalloc_8u(ecParams.pBanks[i].nbytes);//375d60,377420
     if(!ecParams.pBanks[i].pMem) {
       sprintf(pString, "\nLow memory: %d bytes not allocated\n", ecParams.pBanks[i].nbytes);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(ecParams.pBanks) ippsFree(ecParams.pBanks);
       if(fp_rin) fclose(fp_rin);
       if(fp_sin) fclose(fp_sin);
       if(fp_sout) fclose(fp_sout);
       if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
     }
   }

   flen = PrepareInput(fp_rin, " receive-in input ", &in1_buff, f_log);
   in_len = PrepareInput(fp_sin, " send-in input ", &in2_buff, f_log);

   if(ecParams.pInfo.params.pcmType.sample_frequency == 8000){ /* 8 KHz */
      delay = (Ipp32s) (clParams.fdelay * 8000 * 2/1000);
   }else{ /* 16 KHz */
      delay = (Ipp32s) (clParams.fdelay * 16000 * 2/1000);
   }
   flen -= delay;
   if(flen < 0)  flen = 0;
   if (flen < in_len)
       in_len = flen;

   out_buff=(Ipp8u*)ippsMalloc_8u(in_len);/* allocate output buffer */
   if(!out_buff){ /* allocate output buffer */
      sprintf(pString, "\nNo memory for buffering of %d output bytes", in_len);
      OutputInfoString(1, f_log, (const Ipp8s*)pString);
      if(f_log) fclose(f_log);
      return MEMORY_FAIL;
   }

   /* time stamp prior to threads creation, creation and running time may overlap. */
   measure_start(&measure);

   n_repeat = clParams.nRepeat;
   while(n_repeat--) {
      USCStatus = ecParams.pUSC_EC_Fxns->std.Init((const USC_EC_Option *)&ecParams.pInfo.params, ecParams.pBanks, &ecParams.objEC);
      if(USCStatus!=USC_NoError) {
        OutputInfoString(1, f_log,"\nCan not initialize the EC object!");
        if(ecParams.pBanks) ippsFree(ecParams.pBanks);
        if(fp_rin) fclose(fp_rin);
        if(fp_sin) fclose(fp_sin);
        if(fp_sout) fclose(fp_sout);
        if(clParams.puttocsv) { if(f_csv) vm_file_fclose(f_csv); }
        if(f_log) fclose(f_log);
        return ERROR_INIT;
      }
      ecParams.pUSC_EC_Fxns->std.GetInfo(ecParams.objEC, (USC_EC_Info *)&ecParams.pInfo);
      frameNum = in_len/ecParams.pInfo.params.framesize;
      tailNum = (in_len/sizeof(Ipp16s)) - (ecParams.pInfo.params.framesize/sizeof(Ipp16s))*frameNum;

      out_buff_cur = out_buff;
      in1_buff_cur = in1_buff;
      in2_buff_cur = in2_buff+ delay; /* shift forward the sin at delay */

      for (i = 0; i < frameNum; i++) {
          ecParams.pUSC_EC_Fxns->CancelEcho(ecParams.objEC, (Ipp16s *)in2_buff_cur,
              (Ipp16s *)in1_buff_cur, (Ipp16s *)out_buff_cur);//4,6,9,11,14,19,21,26,29,31,34,36,39,41,44,46,49,51
          in1_buff_cur += ecParams.pInfo.params.framesize;
          in2_buff_cur += ecParams.pInfo.params.framesize;
          out_buff_cur += ecParams.pInfo.params.framesize;
      }
      for (i = 0; i < tailNum; i++) {
          ippsZero_16s((Ipp16s *)out_buff_cur, tailNum);
      }
   }

   measure_end(&measure);

   if (PostProcessPCMstream((Ipp8s *)out_buff, in_len)) {
       sprintf(pString, "No memory for load of %d bytes convert from linear PCM to special pack value.",in_len);
       OutputInfoString(1, f_log, (const Ipp8s*)pString);
       if(f_log) fclose(f_log);
       return MEMORY_FAIL;
   }
   /* Write output PCM to the output file */
   fwrite(out_buff, 1, in_len, fp_sout);

   for(i=0; i<ecParams.nBanks;i++){
     if(ecParams.pBanks[i].pMem) ippsFree(ecParams.pBanks[i].pMem);
     ecParams.pBanks[i].pMem = NULL;
   }
   if(ecParams.pBanks) { ippsFree(ecParams.pBanks); ecParams.pBanks = NULL; }
   ippsFree(out_buff);

   speech_sec = (in_len / 2 * clParams.nRepeat)/(double)ecParams.pInfo.params.pcmType.sample_frequency;
   measure_output(f_log, &measure, speech_sec);
   sprintf(pString, "Done %d samples of %d Hz PCM wave file (%g sec)\n",
       (in_len>>1) * clParams.nRepeat, ecParams.pInfo.params.pcmType.sample_frequency, speech_sec);
   OutputInfoString(1, f_log, (const Ipp8s*)pString);

   if(clParams.puttocsv) {
       Ipp8s* rinFile;
       Ipp8s* sinFile;
       if ((rinFile = strrchr(clParams.rinFileName, '/')) != NULL) {
           rinFile += 1;
       } else if ((rinFile = strrchr(clParams.rinFileName, '\\')) != NULL) {
           rinFile += 1;
       } else
           rinFile = clParams.rinFileName;
       if ((sinFile = strrchr(clParams.sinFileName, '/')) != NULL) {
           sinFile += 1;
       } else if ((sinFile = strrchr(clParams.sinFileName, '\\')) != NULL) {
           sinFile += 1;
       } else
           sinFile = clParams.sinFileName;
       i=sprintf(pString, clParams.ECName);
       i += sprintf(pString + i,",");
       switch(clParams.alg) {
            case EC_FULLBAND:
                i += sprintf(pString + i,"fullband,");
                break;
            case EC_SUBBAND:
                i += sprintf(pString + i,"subband,");
                break;
            case EC_FASTSUBBAND:
                i += sprintf(pString + i,"fast subband,");
                break;
            default:
                i += sprintf(pString + i,"subband,");
       }
       switch(clParams.adapt) {
            case 2:
                i += sprintf(pString + i,"lite,");
                break;
            default:
                i += sprintf(pString + i,"full,");
       }
       i += sprintf(pString + i,"%d,",clParams.tail);
       i += sprintf(pString + i,"%d,%s,%s,%4.2f,%4.2f",
            ecParams.pInfo.params.pcmType.sample_frequency, rinFile, sinFile, speech_sec,
            measure.speed_in_mhz);
       vm_string_fprintf(f_csv,VM_STRING("%s\n"),pString);
       vm_file_fclose(f_csv);
   }

   ippsFree(in1_buff);
   ippsFree(in2_buff);

   fclose(fp_rin);
   fclose(fp_sin);
   fclose(fp_sout);

   OutputInfoString(1, f_log,"Completed !\n");
   if(f_log) fclose(f_log);
   return 0;
}
Beispiel #6
0
int ReadCommandLine(CommandLineParams *params, int argc, char *argv[])
{
   int usage = 0;


   argc--;
   while(argc-- > 0){
      argv++;
      if ('-' == (*argv)[0]) {
         if (!strncmp("-f",*argv,2)){
            if(argc-->0){
               int f = atoi(*++argv);
               if (f == 8)
                  params->freq = 8000;
               else if (f == 16) {
                  params->freq = 16000;
               } else {
                  OutputInfoString(1, NULL,"The sample frequency must be 8 or 16 kHz\n");
                  usage = 1;
               }
            }
            continue;
         } else if(!strcmp("-a",*argv)) {
            if(argc-->0){
                argv ++;
                if (!strcmp("fb",*argv) || !strcmp("fullband",*argv)) {
                    params->alg = EC_FULLBAND;
                } else if (!strcmp("sb",*argv) || !strcmp("subband",*argv)) {
                    params->alg = EC_SUBBAND;
                } else if (!strcmp("sbf",*argv) || !strcmp("subbandfast",*argv)) {
                    params->alg = EC_FASTSUBBAND;
                } else {
                  OutputInfoString(1, NULL,"The algorithm specifier must be fb (fullband), sb (subband) or sbf (subband fast)\n");
                  usage = 1;
               }
            }
            continue;
         } else if(!strcmp("-ad",*argv)) {
             if(argc-->0){
                 argv ++;
                 if (!strcmp("full",*argv)) {
                     params->adapt = AD_FULLADAPT;
                 } else if (!strcmp("lite",*argv)) {
                     params->adapt = AD_LITEADAPT;
                 } else {
                     OutputInfoString(1, NULL,"The adaptation specifier must be full or lite.\n");
                     usage = 1;
                 }
             }
             continue;
         }else if(!strcmp("-l",*argv)) {/* set the echo tail length */
            if(argc-->0){
               int eplen = atoi(*++argv);
               if (eplen >= 1 && eplen <= 200)
                  params->tail = eplen;
               else {
                  OutputInfoString(1, NULL,"The echo tail length must be in the range [1, 200] ms for subband algorithm, [1, 16] for fullband algorithm\n");
                  usage = 1;
               }
            }
            continue;
         }else if (!strcmp(*argv,"-sys")){/* set the option to print the system information */
            params->printSysInfo=1;
            continue;
         }else if (!strcmp(*argv,"-delay")){
             if(argc-->0){
                 params->fdelay = atoi(*++argv);
                 if(params->fdelay < 0) params->fdelay=0;
             }
             continue;
         }else if (!strcmp(*argv,"-ah")){/* set the anti-howling device on and set the howling detector device mode*/
             if(argc-->0){
                 int hdmode = atoi(*++argv);
                 if(hdmode==0)
                     params->ah_mode=0;
                 else
                     if(hdmode==1)
                         params->ah_mode=1;
                     else{
                         OutputInfoString(1, NULL,"The anti-howler mode must be set to 0 or 1\n");
                         usage = 1;
                     }
             }
             continue;
         }else if (!strcmp(*argv,"-s")){/* set the number of repeats */
            if(argc-->0){
               int rep = atoi(*++argv);
               if(0 == rep) rep=1;
               if(rep > params->nRepeat) params->nRepeat=rep;
            }
            continue;
         }else if(!strcmp("-o",*argv)) {/* the log file is specified */
            if(argc-->0){
              argv++;
              strcpy(params->logFileName, *argv);
              params->puttolog = 1;
            }
            continue;
         }else if (!strcmp(*argv,"-list")){ /* Print out the modes list */
            params->enumerate = 1;
            usage=1;
            return usage;
         }else if (!strcmp(*argv,"-nlp")){ /* set NLP on */
             if(argc-->0){
                 params->nlp = atoi(*++argv);
                 if(params->nlp<0 || params->nlp>2){
                     OutputInfoString(1, NULL,"The NLP mode must be set to 0, 1 or 2\n");
                    usage = 1;
                 }
             }
            continue;
         }else if (!strcmp(*argv,"-cng")){ /* set cng on */
             if(argc-->0){
                 params->cng = atoi(*++argv);
                 if(params->cng<0 || params->cng>2){
                     OutputInfoString(1, NULL,"The CNG mode must be set to 0, 1 or 2\n");
                     usage = 1;
                 }
             }
             continue;
         } else if (!strcmp(*argv,"-c")){ /* the "csv" output is specified */
             if(argc-->0){
                 params->puttocsv=1;
                 argv++;
                 strcpy(params->csvFileName, *argv);
             }else{
                 OutputInfoString(1, NULL,"Unknown csv file name.\n");
                 usage=1;
             }
             continue;
         }
      }else{
         argc++;
         argv--;
         break;
      }
   }
   if(argc-->0){
      argv++;
      strcpy(params->rinFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown r-in input file.\n");
      usage=1;
   }
   if(argc-->0){
      argv++;
      strcpy(params->sinFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown s-in input file.\n");
      usage=1;
   }
   if(argc-->0){
      argv++;
      strcpy(params->soutFileName, *argv);
   }else{
      OutputInfoString(1, NULL,"Unknown output file.\n");
      usage=1;
   }
   return usage;
}
Beispiel #7
0
void PrintUsage(const char * pAppName, FILE *fptrLog)
{
   char pString[MAX_LEN_STRING];

   sprintf(pString, "Usage: %s [options] <receive-in 16-bit PCM file> <send-in 16-bit PCM file> <send-out 16-bit PCM file>\n", pAppName);
   OutputInfoString(1, fptrLog, (const char*)pString);
   OutputInfoString(1, fptrLog,"   [-f <frequency>] Set the sampling frequency, kHz: 8 or 16. Default 8.\n");
   OutputInfoString(1, fptrLog,"   [-a <algorithm>] Algorithm specifier: fb (fullband), sb (subband type 1) or sbf (subband type 2). \n");
   OutputInfoString(1, fptrLog,"                    Default sb.\n");
   OutputInfoString(1, fptrLog,"   [-ad <algorithm>] Adaptation specifier: full or lite. Default full.\n");
   OutputInfoString(1, fptrLog,"   [-ah <mode>]     Set the anti-howling device mode:1 - on (cos shift up. Exclude sb modes). 0 - off. 0 as default.\n");
   OutputInfoString(1, fptrLog,"   [-l <num>]       Set the echo tail length, ms: in the range [1, 200].\n");
   OutputInfoString(1, fptrLog,"   [-delay <val>]   Set the delay in send-in PCM file,  integer number of milliseconds. \n");
   OutputInfoString(1, fptrLog,"                    Leading end of send-in PCM will be cut off prior to echo cancel. Default:no delay.\n");
   OutputInfoString(1, fptrLog,"   [-s <num>]       Set the number of times file to be processed (optional).\n");
   OutputInfoString(1, fptrLog,"   [-c <csv filename>] Set the csv file name for the performance info to be print to (optional).\n");
   OutputInfoString(1, fptrLog,"   [-o <log filename>] Set the log file name for the functional parameters to be print to (optional).\n");
   OutputInfoString(1, fptrLog,"   [-list] Print out the modes list(optional).\n");
   OutputInfoString(1, fptrLog,"   [-sys] Print out system information.\n");
   OutputInfoString(1, fptrLog,"   [-nlp <num>]  0- Set NLP off.1 as default\n");
   OutputInfoString(1, fptrLog,"                 1- NLP type actual for all modes,\n");
   OutputInfoString(1, fptrLog,"                 2- NLP type actual for sbf only\n");
   OutputInfoString(1, fptrLog,"   [-cng <num>]  0-Set CNG off. 1 as default. Active when NLP is on only.\n");
   OutputInfoString(1, fptrLog,"                 1- CNG type actual for all modes.\n");
   OutputInfoString(1, fptrLog,"                 2- CNG type actual for sbf only (actual with -nlp type 2 only).\n");
}