?? encoder_main.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) 2003-2006 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives Advanced Aurora Sample for Windows*
//
// 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 ippEULA.rtf located in the root directory of your Intel(R) IPP
// product installation for more information.
//
// ES 202 050 v1.1.1 is the international standard promoted by ETSI
// and other organizations. Implementations of these standards, or the standard
// enabled platforms may require licenses from various entities, including
// Intel Corporation.
//
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include "encoderapi.h"
typedef struct
{
char fileType[4]; // 4
int lenfile; // 8
char codingType[4]; // 12
char strIdFormat[4]; // 16
int lenChunk; // 20
short idCoding; // 22
short channel; // 24
int frec; // 28
int nByteInSec; // 32
short nbytes; // 34
short bits; // 36
char strIdData[4]; // 40
int lenFact; // 44
int lenSampInCh; // 48
char strIdData2[4]; // 52
int lenData; // 56
} wWaveHeader;
wWaveHeader header;
#define BOOLEAN int
#define FALSE 0
#define TRUE (!FALSE)
int n_repeat;
AuroraDataType EncoderOut;
AuroraDataType EncoderIn;
FILE *fpIn = NULL;
FILE *fpOut = NULL;
FILE *fpVAD = NULL;
AuroraRate SFrequency = r16KHz; /* SamplingFrequency */
int SamplingFrequency = 16000; /* SamplingFrequency */
int puttocsv = 0;
int stepTest=100;
typedef struct{
long SamplesNumber;
long SamplePeriod;
short SampleSize;
short SampleKind;
}
HTKHeader;
void WriteHTKHeader (FILE * out, int SamplesNumber){
long tmpl[2];
short tmps[2];
fseek (out, 0L, SEEK_SET);
tmpl[0] = SamplesNumber; tmpl[1] = 100000;
tmps[0] = (short)(NUM_CEP_COEFF + 1 )*4; tmps[1] = 8262;
fwrite (tmpl, sizeof (long), 2, out);
fwrite (tmps, sizeof (short), 2, out);
}
void SaveWaveFile(FILE *fptr, short *data){
char c[]={" "};
fwrite(&header.fileType, sizeof(char), 4, fptr);
fwrite(&header.lenfile, sizeof(int), 1, fptr);
fwrite(&header.codingType, sizeof(char), 4, fptr);
fwrite(&header.strIdFormat, sizeof(char), 4, fptr);
fwrite(&header.lenChunk, sizeof(int), 1, fptr);
fwrite(&header.idCoding, sizeof(short), 1, fptr);
fwrite(&header.channel, sizeof(short), 1, fptr);
fwrite(&header.frec, sizeof(int), 1, fptr);
fwrite(&header.nByteInSec, sizeof(int), 1, fptr);
fwrite(&header.nbytes, sizeof(short), 1, fptr);
fwrite(&header.bits, sizeof(short), 1, fptr);
fwrite(&c,sizeof(char),(header.lenChunk-16),fptr);
fwrite(&header.strIdData, sizeof(char), 4, fptr);
fwrite(&header.lenFact, sizeof(int), 1, fptr);
fwrite(&header.lenSampInCh, sizeof(int), 1, fptr);
fwrite(&c,sizeof(char),(header.lenFact - 4),fptr);
fwrite(&header.strIdData2, sizeof(char), 4, fptr);
fwrite(&header.lenData, sizeof(int), 1, fptr);
fwrite(data, sizeof(short), header.lenSampInCh, fptr);
}
short *ReadWaveFile(FILE *fptr, int *size){
short *tmp;
fread(&header.fileType, sizeof(char), 4, fptr);
fread(&header.lenfile, sizeof(int), 1, fptr);
fread(&header.codingType, sizeof(char), 4, fptr);
fread(&header.strIdFormat, sizeof(char), 4, fptr);
fread(&header.lenChunk, sizeof(int), 1, fptr);
fread(&header.idCoding, sizeof(short), 1, fptr);
fread(&header.channel, sizeof(short), 1, fptr);
fread(&header.frec, sizeof(int), 1, fptr);
fread(&header.nByteInSec, sizeof(int), 1, fptr);
fread(&header.nbytes, sizeof(short), 1, fptr);
fread(&header.bits, sizeof(short), 1, fptr);
fseek(fptr,(long)(header.lenChunk-16),SEEK_CUR);
fread(&header.strIdData, sizeof(char), 4, fptr);
fread(&header.lenFact, sizeof(int), 1, fptr);
fread(&header.lenSampInCh, sizeof(int), 1, fptr);
fseek(fptr, (long)(header.lenFact - 4), SEEK_CUR);
fread(&header.strIdData2, sizeof(char), 4, fptr);
fread(&header.lenData, sizeof(int), 1, fptr);
tmp = ippsMalloc_16s(header.lenSampInCh);
*size = header.lenSampInCh;
fread(tmp, sizeof(short), header.lenSampInCh, fptr);
return tmp;
}
char vadname[256];
static BOOLEAN
ParseCommLine (int argc, char *argv[])
{
int rep;
n_repeat = 1;
if (argc < 2) return FALSE;
EncoderOut = FEATURE;
EncoderIn = WAVEFORM;
while (argc-2)
{
if(strcmp(*argv,"-o")==0){
if(strcmp(*(argv+1),"f")==0)
EncoderOut = FEATURE;
else if(strcmp(*(argv+1),"m")==0)
EncoderOut = MULTIFRAME;
else if(strcmp(*(argv+1),"q")==0)
EncoderOut = QUANTIZED;
else if(strcmp(*(argv+1),"w")==0)
EncoderOut = WAVEFORM;
argc-=2;
argv+=2;
continue;
}
if(strcmp(*argv,"-i")==0){
if(strcmp(*(argv+1),"f")==0)
EncoderIn = FEATURE;
else if(strcmp(*(argv+1),"w")==0)
EncoderIn = WAVEFORM;
argc-=2;
argv+=2;
continue;
}
else if(strcmp(*argv,"-step")==0){
rep = atoi(*(argv+1));
if(0 == rep) rep=1;
stepTest=rep;
argc-=2;
argv+=2;
continue;
}
else if(strcmp(*argv,"-s")==0){
rep = atoi(*(argv+1));
if(0 == rep) rep=1;
if(rep > n_repeat) n_repeat=rep;
argc-=2;
argv+=2;
continue;
}
else if(strcmp(*argv,"-vad")==0){
sprintf(vadname,"%s",*(argv+1));
argc-=2;
argv+=2;
continue;
}
else if (strcmp (*argv, "-f") == 0)
{
SamplingFrequency = 1000 * atoi (*(argv+1));
switch(SamplingFrequency){
case 16000: SFrequency = r16KHz;break;
case 11000: SFrequency = r11KHz;break;
case 8000: SFrequency = r8KHz;break;
default:
printf("WARNING:unrecognised frequancy %s \n",*(argv+1));
return FALSE;
}
argc-=2;
argv+=2;
continue;
}
else if (strcmp (*argv, "-c") == 0)
{
puttocsv = 1;
argc--;
argv++;
continue;
}
printf("WARNING:unrecognised parameter %s \n",*argv);
argc--;
argv++;
return FALSE;
}
if ( (fpIn = fopen(*argv, "rb")) == NULL) {
printf("File %s could not be open.\n", *argv);
return FALSE;
}
argv++; argc--;
if ( (fpOut = fopen(*argv, "wb")) == NULL) {
printf("File %s could not be open.\n", *argv);
return FALSE;
}
argv++; argc--;
return TRUE;
}
int main(int argc, char *argv[] ){
/*-----------------------*/
long FrameCounter = 0,SizeBuffer;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -