?? util.c
字號:
/*////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2005 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives
//
// USC Echo Canceller sample
//
// By downloading and installing this sample, you hereby agree that the
// accompanying Materials are being provided to you under the terms and
// conditions of the End User License Agreement for the Intel(R) Integrated
// Performance Primitives product previously accepted by you. Please refer
// to the file ipplic.htm located in the root directory of your Intel(R) IPP
// product installation for more information.
//
// Purpose: Auxiliary functions file.
//
////////////////////////////////////////////////////////////////////////*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "util.h"
#include "ipps.h"
#include "ippsc.h"
int OutputInfoString(int flConsole, FILE *fptrLog, const char *string)
{
int count;
if(fptrLog == NULL) count = printf("%s", string);
else {
if(flConsole == 0) count = printf("%s", string);
count = fprintf(fptrLog, "%s", string);
}
return count;
}
void SetCommandLineByDefault(CommandLineParams *params)
{
memset((void*)params,0,sizeof(CommandLineParams));
strcpy(params->ECName, "EC_INT");
params->alg = 2;
params->freq = 8000;
params->tail = 16;
params->ah_mode = 0;
params->nRepeat = 1;
params->puttolog = 0;
params->puttocsv = 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,"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,"Algorithm specificator must be fb (fullband), sb (subband) or sbf (subbandfast)\n");
usage = 1;
}
}
continue;
}else if(!strcmp("-l",*argv)) {
if(argc-->0){
int eplen = atoi(*++argv);
if (eplen >= 1 && eplen <= 200)
params->tail = eplen;
else {
OutputInfoString(1, NULL,"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,"-delay")){
if(argc-->0){
fdelay = atof(*++argv);
if(fdelay < 0) fdelay=0;
}
}*/
else if (!strcmp(*argv,"-ah")){
params->ah_mode = 1;
continue;
}else if (!strcmp(*argv,"-s")){
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)) {
if(argc-->0){
argv++;
strcpy(params->logFileName, *argv);
params->puttolog = 1;
}
continue;
}else if (!strcmp(*argv,"-list")){ /* check enumerate formats mode */
params->enumerate = 1;
usage=1;
return usage;
} else if (!strcmp(*argv,"-c")){ /* check if 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,"Echo tail length for fullband algorithm must be in range [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;
}
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>] Sample frequency, kHz: 8 or 16. Default 8.\n");
OutputInfoString(1, fptrLog," [-a <algortihm>] Algorithm specificator: fb (fullband), sb (subband) or sbf (subbandfast). \n");
OutputInfoString(1, fptrLog," Default subband.\n");
OutputInfoString(1, fptrLog," [-ah] enable anti-howling mode\n");
OutputInfoString(1, fptrLog," [-l <num>] echo tail length, ms: in range [1, 200] for subband algorithm,\n");
OutputInfoString(1, fptrLog," [1, 16] for fullband algorithm. Default 16.\n");
OutputInfoString(1, fptrLog," [-delay <val>] Determines the delay in receive-in PCM file, sec (floating point value). \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>] Repeater, how many times to repeat an operation (optional).\n");
OutputInfoString(1, fptrLog," [-c <csv filename>] Print out performance info line to specified file (optional).\n");
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -