📄 gauss_main.cpp
字号:
/*
//
// 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) 1999-2006 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives Gaussian Mixture 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.
//
//
// Test of Vector Gaussian Mixture Calculation
//
//
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ipps.h>
#include <ippsr.h>
#include <ippcore.h>
#include "len_stat.h"
#include "fake_decoder.h"
#include "prob_cache.h"
#include "prob_calc.h"
#include "feat_calc.h"
static int frequency = 500;
static int TypeTest = 0;
static int num_err = 0;
#if defined( _WIN32 ) || defined( _WIN64 )
#define IPP_MAX_64U ( 0xffffffffffffffffL ) //18446744073709551615
#else
#define IPP_MAX_64U ( 0xffffffffffffffffLL ) //18446744073709551615
#endif
float getUSec(Ipp64u s, Ipp64u e) { // returns (CPU_Frequency * time_in_sec)
#if defined __ICL
Ipp64f b=((s<e)?(e-s):((IPP_MAX_64U-s)+e))/1000000.0;
#else // MSVC 6.0 could not divide int64 by double
Ipp64u a=(s<e)?(e-s):((IPP_MAX_64U-s)+e);
Ipp64f b=((Ipp32u)(a>>32)*((Ipp64f)IPP_MAX_32U+1.0)+(Ipp32u)(a&IPP_MAX_32U))/1000000.0;
#endif
return (float)b;
}
static bool ParseCommLine (int argc, char *argv[])
{
if (argc < 2) return false;
while (argc>=2)
{
if (strcmp(*argv,"-f")==0) {
frequency = atoi(*(argv+1));
if(0 == frequency) frequency=500;
argc-=2;
argv+=2;
continue;
}
if (strcmp(*argv,"-t")==0) {
TypeTest = atoi(*(argv+1));
argc-=2;
argv+=2;
continue;
}
printf("WARNING:unrecognised parameter %s \n",*argv);
argc--;
argv++;
}
return true;
}
struct CalcStreamParm{
unsigned long Hdl_Id;
Calc_Hint hint;
char *paramfile;
char *featfile;
int mixnum;
int gaussnum;
int dimension;
int calcmax;
int calcmin;
int framenum;
int delay;
char *featlogfile;
int model;
Prob_Calc *calc;
Feat_Calc *feat;
char *res;
};
unsigned long __stdcall CalcStream(void *parm1){
// MSG MyMsg;
CalcStreamParm* parm=(CalcStreamParm*)parm1;
parm->calc= new Prob_Calc(parm->hint);
if (parm->paramfile[0]==0) {
if (parm->calc->Init_Calc(parm->mixnum,parm->gaussnum,parm->dimension,parm->calcmax,parm->calcmin)<0){
num_err++;
parm->res="ERROR! Could not create fake mixture calculator\n";
ExitThread(1);
return 1;
}
parm->model=0;
} else {
if (parm->calc->Init_Calc(parm->paramfile,parm->calcmax,parm->calcmin)<0){
num_err++;
parm->res="ERROR! Could not create SDT mixture calculator\n";
ExitThread(2);
return 2;
}
parm->mixnum=parm->calc->State_Number();
parm->dimension=parm->calc->Feature_Length();
parm->gaussnum=parm->calc->Max_Gauss();
parm->model=1;
}
if (parm->calc->Init_LogFile(parm->featlogfile)<0){
num_err++;
parm->res="ERROR! Could not open feature log file\n";
ExitThread(3);
return 3;
}
parm->feat= new Feat_Calc(parm->dimension,parm->delay);
if (parm->featfile[0]==0) {
if (parm->feat->Init_Feat(parm->framenum)<0){
num_err++;
parm->res="ERROR! Could not create fake feature producer\n";
ExitThread(4);
return 4;
}
} else {
if (parm->feat->Init_Feat(parm->featfile)<0){
num_err++;
parm->res="ERROR! Could not create HTK file feature producer\n";
ExitThread(5);
return 5;
}
}
if (!parm->calc->Attach_Feat(parm->feat)){
num_err++;
parm->res="ERROR! Could not attach feature producer\n";
ExitThread(6);
return 6;
}
parm->res=NULL;
PostThreadMessage(parm->Hdl_Id,START_WORKING,0,0);
parm->calc->CalcState();
delete parm->calc;
delete parm->feat;
ExitThread(0);
return 0;
}
char* Fake_Decoder_Test
(Calc_Hint hint, // probability calculation method:
// calcNone - no calculations
// calcVect - LogGauss & LogAdd calculations
// calcVecM - LogGauss & LogMax calculations
// calcMix - LogGaussMixture calculations
char *paramfile, // SDT param file name or "" for fake model
char *featfile, // HTK feature file name or "" for fake features
int mixnum, // state (mixture) number for fake model
int gaussnum, // Gaussian number per mixture for fake model
int dimension, // feature space dimension for fake model or features
int calcmax, // maximal probability vector length for calculator
int calcmin, // minimal probability vector length (except end)
int framenum, // frame number for fake features
int delay, // maximal portion of features
int cachelen, // cache length (frames)
int veclen, // probability vector length in cache
int actlen, // maximal state activity interval
int avrmix, // average active states per frame
char *problogfile, // HTK feature file name or "" for fake features
char *featlogfile) // HTK feature file name or "" for fake features
{
int t,num,avl;
Ipp64u m_clocks;
double sec_time;
double speech_sec;
float freq=(float)frequency;
int model=0;
Len_Stat stat_dec;
Len_Stat stat_cache;
Prob_Calc *calc;
Feat_Calc *feat;
CalcStreamParm parm;
HANDLE Hdl1;
unsigned long Hdl1_Id;
MSG MyMsg;
parm.Hdl_Id=GetCurrentThreadId();
parm.hint=hint;
parm.paramfile=paramfile;
parm.featfile=featfile;
parm.mixnum=mixnum;
parm.gaussnum=gaussnum;
parm.dimension=dimension;
parm.calcmax=calcmax;
parm.calcmin=calcmin;
parm.framenum=framenum;
parm.delay=delay;
parm.featlogfile=featlogfile;
Hdl1 =(HANDLE)CreateThread(NULL,0,CalcStream,&parm,0,&Hdl1_Id);
while(PeekMessage(&MyMsg,NULL,0,0,PM_REMOVE) == 0);
if(MyMsg.message!=START_WORKING)
return "Error in create thread!!!";
if(parm.res!=0)
return parm.res;
calc=parm.calc;
feat=parm.feat;
mixnum=parm.mixnum;
dimension=parm.dimension;
gaussnum=parm.gaussnum;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -