\doxysection{main\+\_\+cepview.\+c}
\label{main__cepview_8c_source}\index{src/sphinx\_cepview/main\_cepview.c@{src/sphinx\_cepview/main\_cepview.c}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1994-\/2001\ Carnegie\ Mellon\ University.\ \ All\ rights}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.}}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced}}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the}}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND}}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,}}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT}}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,}}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY}}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT}}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE}}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#ifdef\ \_WIN32}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#pragma\ warning\ (disable:\ 4996)\ }}
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00044\ }
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#include\ <config.h>}}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#include\ <sphinxbase/strfuncs.h>}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#include\ <sphinxbase/prim\_type.h>}}
\DoxyCodeLine{00051\ \textcolor{preprocessor}{\#include\ <sphinxbase/cmd\_ln.h>}}
\DoxyCodeLine{00052\ \textcolor{preprocessor}{\#include\ <sphinxbase/ckd\_alloc.h>}}
\DoxyCodeLine{00053\ \textcolor{preprocessor}{\#include\ <sphinxbase/info.h>}}
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#include\ <sphinxbase/err.h>}}
\DoxyCodeLine{00055\ \textcolor{preprocessor}{\#include\ <sphinxbase/bio.h>}}
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#include\ <sphinxbase/pio.h>}}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00061\ \textcolor{preprocessor}{\#define\ IO\_ERR\ \ (-\/1)}}
\DoxyCodeLine{00062\ \textcolor{preprocessor}{\#define\ IO\_SUCCESS\ \ (0)}}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \textcolor{preprocessor}{\#define\ SHOW\_ALL\ "{}-\/1"{}}}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \textcolor{comment}{/*\ Default\ cepstral\ vector\ size\ */}}
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\#define\ NUM\_COEFF\ \ "{}13"{}}}
\DoxyCodeLine{00068\ }
\DoxyCodeLine{00069\ \textcolor{comment}{/*\ Default\ display\ size,\ i.e.,\ number\ of\ coefficients\ displayed,\ less}}
\DoxyCodeLine{00070\ \textcolor{comment}{\ *\ than\ the\ vector\ size\ so\ we\ display\ one\ frame\ per\ line.}}
\DoxyCodeLine{00071\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\#define\ DISPLAY\_SIZE\ "{}10"{}}}
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\#define\ STR\_MAX\_INT\ "{}2147483647"{}}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \textcolor{keyword}{static}\ arg\_t\ arg[]\ =\ \{}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/logfn"{}},}
\DoxyCodeLine{00078\ \ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00079\ \ \ \ \ \ NULL,}
\DoxyCodeLine{00080\ \ \ \ \ \ \textcolor{stringliteral}{"{}Log\ file\ (default\ stdout/stderr)"{}}\},}
\DoxyCodeLine{00081\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/i"{}},}
\DoxyCodeLine{00082\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00083\ \ \ \ \ \ NUM\_COEFF,}
\DoxyCodeLine{00084\ \ \ \ \ \ \textcolor{stringliteral}{"{}Number\ of\ coefficients\ in\ the\ feature\ vector."{}}\},}
\DoxyCodeLine{00085\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/d"{}},}
\DoxyCodeLine{00086\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00087\ \ \ \ \ \ DISPLAY\_SIZE,}
\DoxyCodeLine{00088\ \ \ \ \ \ \textcolor{stringliteral}{"{}Number\ of\ displayed\ coefficients."{}}\},}
\DoxyCodeLine{00089\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/header"{}},}
\DoxyCodeLine{00090\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00091\ \ \ \ \ \ \textcolor{stringliteral}{"{}0"{}},}
\DoxyCodeLine{00092\ \ \ \ \ \ \textcolor{stringliteral}{"{}Whether\ header\ is\ shown."{}}\},}
\DoxyCodeLine{00093\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/describe"{}},}
\DoxyCodeLine{00094\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00095\ \ \ \ \ \ \textcolor{stringliteral}{"{}0"{}},}
\DoxyCodeLine{00096\ \ \ \ \ \ \textcolor{stringliteral}{"{}Whether\ description\ will\ be\ shown."{}}\},}
\DoxyCodeLine{00097\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/b"{}},}
\DoxyCodeLine{00098\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00099\ \ \ \ \ \ \textcolor{stringliteral}{"{}0"{}},}
\DoxyCodeLine{00100\ \ \ \ \ \ \textcolor{stringliteral}{"{}The\ beginning\ frame\ 0-\/based."{}}\},}
\DoxyCodeLine{00101\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/e"{}},}
\DoxyCodeLine{00102\ \ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00103\ \ \ \ \ \ \textcolor{stringliteral}{"{}2147483647"{}},}
\DoxyCodeLine{00104\ \ \ \ \ \ \textcolor{stringliteral}{"{}The\ ending\ frame."{}}\},}
\DoxyCodeLine{00105\ \ \ \ \ \{\textcolor{stringliteral}{"{}-\/f"{}},}
\DoxyCodeLine{00106\ \ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00107\ \ \ \ \ \ NULL,}
\DoxyCodeLine{00108\ \ \ \ \ \ \textcolor{stringliteral}{"{}Input\ feature\ file."{}}\},}
\DoxyCodeLine{00109\ \ \ \ \ \{NULL,\ ARG\_INT32,\ NULL,\ NULL\}}
\DoxyCodeLine{00110\ \};}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \textcolor{keywordtype}{int}\ read\_cep(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *file,\ \textcolor{keywordtype}{float}\ ***cep,\ \textcolor{keywordtype}{int}\ *nframes,\ \textcolor{keywordtype}{int}\ numcep);}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00114\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00115\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00116\ \{}
\DoxyCodeLine{00117\ \ \ \ \ \textcolor{keywordtype}{int}\ i,\ j,\ offset;}
\DoxyCodeLine{00118\ \ \ \ \ int32\ noframe,\ vsize,\ dsize,\ column;}
\DoxyCodeLine{00119\ \ \ \ \ int32\ frm\_begin,\ frm\_end;}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{keywordtype}{int}\ is\_header,\ is\_describe;}
\DoxyCodeLine{00121\ \ \ \ \ \textcolor{keywordtype}{float}\ *z,\ **cep;}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *cepfile;}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \ \ \ \ print\_appl\_info(argv[0]);}
\DoxyCodeLine{00125\ \ \ \ \ cmd\_ln\_appl\_enter(argc,\ argv,\ \textcolor{stringliteral}{"{}default.arg"{}},\ arg);}
\DoxyCodeLine{00126\ }
\DoxyCodeLine{00127\ \ \ \ \ vsize\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/i"{}});}
\DoxyCodeLine{00128\ \ \ \ \ dsize\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/d"{}});}
\DoxyCodeLine{00129\ \ \ \ \ frm\_begin\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/b"{}});}
\DoxyCodeLine{00130\ \ \ \ \ frm\_end\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/e"{}});}
\DoxyCodeLine{00131\ \ \ \ \ is\_header\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/header"{}});}
\DoxyCodeLine{00132\ \ \ \ \ is\_describe\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/describe"{}});}
\DoxyCodeLine{00133\ }
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{keywordflow}{if}\ (vsize\ <\ 0)}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ E\_FATAL(\textcolor{stringliteral}{"{}-\/i\ :\ Input\ vector\ size\ should\ be\ larger\ than\ 0.\(\backslash\)n"{}});}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keywordflow}{if}\ (dsize\ <\ 0)}
\DoxyCodeLine{00137\ \ \ \ \ \ \ \ \ E\_FATAL(\textcolor{stringliteral}{"{}-\/d\ :\ Column\ size\ should\ be\ larger\ than\ 0\(\backslash\)n"{}});}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keywordflow}{if}\ (frm\_begin\ <\ 0)}
\DoxyCodeLine{00139\ \ \ \ \ \ \ \ \ E\_FATAL(\textcolor{stringliteral}{"{}-\/b\ :\ Beginning\ frame\ should\ be\ larger\ than\ 0\(\backslash\)n"{}});}
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{comment}{/*\ The\ following\ condition\ is\ redundant}}
\DoxyCodeLine{00141\ \textcolor{comment}{\ \ \ \ \ *\ if\ (frm\_end\ <\ 0)\ E\_FATAL("{}-\/e\ :\ Ending\ frame\ should\ be\ larger\ than\ 0\(\backslash\)n"{});}}
\DoxyCodeLine{00142\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keywordflow}{if}\ (frm\_begin\ >=\ frm\_end)}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ E\_FATAL}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Ending\ frame\ (-\/e)\ should\ be\ larger\ than\ beginning\ frame\ (-\/b).\(\backslash\)n"{}});}
\DoxyCodeLine{00146\ }
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{keywordflow}{if}\ ((cepfile\ =\ cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/f"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ E\_FATAL(\textcolor{stringliteral}{"{}Input\ file\ was\ not\ specified\ with\ (-\/f)\(\backslash\)n"{}});}
\DoxyCodeLine{00149\ \ \ \ \ \}}
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{keywordflow}{if}\ (read\_cep(cepfile,\ \&cep,\ \&noframe,\ vsize)\ ==\ IO\_ERR)}
\DoxyCodeLine{00151\ \ \ \ \ \ \ \ \ E\_FATAL\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ '\%s'\ for\ reading"{}},\ cepfile);}
\DoxyCodeLine{00152\ }
\DoxyCodeLine{00153\ \ \ \ \ z\ =\ cep[0];}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \ \ \ \ offset\ =\ 0;}
\DoxyCodeLine{00156\ \ \ \ \ column\ =\ (vsize\ >\ dsize)\ ?\ dsize\ :\ vsize;}
\DoxyCodeLine{00157\ \ \ \ \ frm\_end\ =\ (frm\_end\ >\ noframe)\ ?\ noframe\ :\ frm\_end;}
\DoxyCodeLine{00158\ }
\DoxyCodeLine{00159\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Displaying\ \%d\ out\ of\ \%d\ columns\ per\ frame\(\backslash\)n"{}},\ column,\ vsize);}
\DoxyCodeLine{00160\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Total\ \%d\ frames\(\backslash\)n\(\backslash\)n"{}},\ noframe);}
\DoxyCodeLine{00161\ }
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{comment}{/*\ This\ part\ should\ be\ moved\ to\ a\ special\ library\ if\ this\ file\ is}}
\DoxyCodeLine{00163\ \textcolor{comment}{\ \ \ \ \ \ \ longer\ than\ 300\ lines.\ */}}
\DoxyCodeLine{00164\ }
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{keywordflow}{if}\ (is\_header)\ \{}
\DoxyCodeLine{00166\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (is\_describe)\ \{}
\DoxyCodeLine{00167\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n\%6s"{}},\ \textcolor{stringliteral}{"{}frame\#:"{}});}
\DoxyCodeLine{00168\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00169\ }
\DoxyCodeLine{00170\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ column;\ ++j)\ \{}
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\%3s\%3d\%s\ "{}},\ \textcolor{stringliteral}{"{}c["{}},\ j,\ \textcolor{stringliteral}{"{}]"{}});}
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00174\ \ \ \ \ \}}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ \ \ \ \ offset\ +=\ frm\_begin\ *\ vsize;}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ frm\_begin;\ i\ <\ frm\_end;\ ++i)\ \{}
\DoxyCodeLine{00178\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (is\_describe)\ \{}
\DoxyCodeLine{00179\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\%6d:"{}},\ i);}
\DoxyCodeLine{00180\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00181\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ column;\ ++j)}
\DoxyCodeLine{00182\ \ \ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\%7.3f\ "{}},\ z[offset\ +\ j]);}
\DoxyCodeLine{00183\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00185\ \ \ \ \ \ \ \ \ offset\ +=\ vsize;}
\DoxyCodeLine{00186\ \ \ \ \ \}}
\DoxyCodeLine{00187\ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{00188\ \ \ \ \ cmd\_ln\_appl\_exit();}
\DoxyCodeLine{00189\ \ \ \ \ ckd\_free\_2d(cep);}
\DoxyCodeLine{00190\ }
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{keywordflow}{return}\ (IO\_SUCCESS);}
\DoxyCodeLine{00192\ }
\DoxyCodeLine{00193\ \}}
\DoxyCodeLine{00194\ }
\DoxyCodeLine{00195\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00196\ read\_cep(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *file,\ \textcolor{keywordtype}{float}\ ***cep,\ \textcolor{keywordtype}{int}\ *numframes,\ \textcolor{keywordtype}{int}\ cepsize)}
\DoxyCodeLine{00197\ \{}
\DoxyCodeLine{00198\ \ \ \ \ FILE\ *fp;}
\DoxyCodeLine{00199\ \ \ \ \ \textcolor{keywordtype}{int}\ n\_float;}
\DoxyCodeLine{00200\ \ \ \ \ \textcolor{keyword}{struct\ }stat\ statbuf;}
\DoxyCodeLine{00201\ \ \ \ \ \textcolor{keywordtype}{int}\ i,\ n,\ byterev;}
\DoxyCodeLine{00202\ \ \ \ \ float32\ **mfcbuf;}
\DoxyCodeLine{00203\ }
\DoxyCodeLine{00204\ \ \ \ \ \textcolor{keywordflow}{if}\ (stat\_retry(file,\ \&statbuf)\ <\ 0)\ \{}
\DoxyCodeLine{00205\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ get\ file\ size\ '\%s'"{}},\ file);}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00207\ \ \ \ \ \}}
\DoxyCodeLine{00208\ }
\DoxyCodeLine{00209\ \ \ \ \ \textcolor{keywordflow}{if}\ ((fp\ =\ fopen(file,\ \textcolor{stringliteral}{"{}rb"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00210\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ '\%s'\ for\ reading"{}},\ file);}
\DoxyCodeLine{00211\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00212\ \ \ \ \ \}}
\DoxyCodeLine{00213\ }
\DoxyCodeLine{00214\ \ \ \ \ \textcolor{comment}{/*\ Read\ \#floats\ in\ header\ */}}
\DoxyCodeLine{00215\ \ \ \ \ \textcolor{keywordflow}{if}\ (fread(\&n\_float,\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}),\ 1,\ fp)\ !=\ 1)\ \{}
\DoxyCodeLine{00216\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00217\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00218\ \ \ \ \ \}}
\DoxyCodeLine{00219\ }
\DoxyCodeLine{00220\ \ \ \ \ \textcolor{comment}{/*\ Check\ if\ n\_float\ matches\ file\ size\ */}}
\DoxyCodeLine{00221\ \ \ \ \ byterev\ =\ FALSE;}
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{keywordflow}{if}\ ((\textcolor{keywordtype}{int})\ (n\_float\ *\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{float})\ +\ 4)\ !=\ statbuf.st\_size)\ \{}
\DoxyCodeLine{00223\ \ \ \ \ \ \ \ \ n\ =\ n\_float;}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ SWAP\_INT32(\&n);}
\DoxyCodeLine{00225\ }
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((\textcolor{keywordtype}{int})\ (n\ *\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{float})\ +\ 4)\ !=\ statbuf.st\_size)\ \{}
\DoxyCodeLine{00227\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Header\ size\ field:\ \%d(\%08x);\ filesize:\ \%d(\%08x)\(\backslash\)n"{}},}
\DoxyCodeLine{00228\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n\_float,\ n\_float,\ (\textcolor{keywordtype}{int})\ statbuf.st\_size,}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{int})\ statbuf.st\_size);}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00231\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00232\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00233\ }
\DoxyCodeLine{00234\ \ \ \ \ \ \ \ \ n\_float\ =\ n;}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ byterev\ =\ TRUE;}
\DoxyCodeLine{00236\ \ \ \ \ \}}
\DoxyCodeLine{00237\ \ \ \ \ \textcolor{keywordflow}{if}\ (n\_float\ <=\ 0)\ \{}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Header\ size\ field:\ \%d\(\backslash\)n"{}},\ n\_float);}
\DoxyCodeLine{00239\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00240\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00241\ \ \ \ \ \}}
\DoxyCodeLine{00242\ }
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{comment}{/*\ n\ =\ \#frames\ of\ input\ */}}
\DoxyCodeLine{00244\ \ \ \ \ n\ =\ n\_float\ /\ cepsize;}
\DoxyCodeLine{00245\ \ \ \ \ \textcolor{keywordflow}{if}\ (n\ *\ cepsize\ !=\ n\_float)\ \{}
\DoxyCodeLine{00246\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Header\ size\ field:\ \%d;\ not\ multiple\ of\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n\_float,\ cepsize);}
\DoxyCodeLine{00248\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00249\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00250\ \ \ \ \ \}}
\DoxyCodeLine{00251\ }
\DoxyCodeLine{00252\ \ \ \ \ mfcbuf\ =\ (\textcolor{keywordtype}{float}\ **)\ ckd\_calloc\_2d(n,\ cepsize,\ \textcolor{keyword}{sizeof}(float32));}
\DoxyCodeLine{00253\ }
\DoxyCodeLine{00254\ \ \ \ \ \textcolor{comment}{/*\ Read\ mfc\ data\ and\ byteswap\ if\ necessary\ */}}
\DoxyCodeLine{00255\ \ \ \ \ n\_float\ =\ n\ *\ cepsize;}
\DoxyCodeLine{00256\ \ \ \ \ \textcolor{keywordflow}{if}\ ((\textcolor{keywordtype}{int})\ fread(mfcbuf[0],\ \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{float}),\ n\_float,\ fp)\ !=\ n\_float)\ \{}
\DoxyCodeLine{00257\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Error\ reading\ mfc\ data\ from\ the\ file\ '\%s'"{}},\ file);}
\DoxyCodeLine{00258\ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00259\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_ERR;}
\DoxyCodeLine{00260\ \ \ \ \ \}}
\DoxyCodeLine{00261\ \ \ \ \ \textcolor{keywordflow}{if}\ (byterev)\ \{}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n\_float;\ i++)}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ \ \ \ \ SWAP\_FLOAT32(\&(mfcbuf[0][i]));}
\DoxyCodeLine{00264\ \ \ \ \ \}}
\DoxyCodeLine{00265\ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00266\ }
\DoxyCodeLine{00267\ \ \ \ \ *numframes\ =\ n;}
\DoxyCodeLine{00268\ \ \ \ \ *cep\ =\ mfcbuf;}
\DoxyCodeLine{00269\ \ \ \ \ \textcolor{keywordflow}{return}\ IO\_SUCCESS;}
\DoxyCodeLine{00270\ \}}
\DoxyCodeLine{00271\ }
\DoxyCodeLine{00273\ \textcolor{preprocessor}{\#if\ defined(\_WIN32\_WCE)}}
\DoxyCodeLine{00274\ \textcolor{preprocessor}{\#pragma\ comment(linker,"{}/entry:mainWCRTStartup"{})}}
\DoxyCodeLine{00275\ }
\DoxyCodeLine{00276\ \textcolor{comment}{//Windows\ Mobile\ has\ the\ Unicode\ main\ only}}
\DoxyCodeLine{00277\ \textcolor{keywordtype}{int}\ wmain(int32\ argc,\ \textcolor{keywordtype}{wchar\_t}\ *wargv[])\ \{}
\DoxyCodeLine{00278\ \ \ \ \ \textcolor{keywordtype}{char}**\ argv;}
\DoxyCodeLine{00279\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ wlen;}
\DoxyCodeLine{00280\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ len;}
\DoxyCodeLine{00281\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00282\ }
\DoxyCodeLine{00283\ \ \ \ \ argv\ =\ malloc(argc*\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}*));}
\DoxyCodeLine{00284\ \ \ \ \ \textcolor{keywordflow}{for}\ (i=0;\ i<argc;\ i++)\{}
\DoxyCodeLine{00285\ \ \ \ \ \ \ \ \ wlen\ =\ lstrlenW(wargv[i]);}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ len\ =\ wcstombs(NULL,\ wargv[i],\ wlen);}
\DoxyCodeLine{00287\ \ \ \ \ \ \ \ \ argv[i]\ =\ malloc(len+1);}
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ wcstombs(argv[i],\ wargv[i],\ wlen);}
\DoxyCodeLine{00289\ \ \ \ \ \}}
\DoxyCodeLine{00290\ }
\DoxyCodeLine{00291\ \ \ \ \ \textcolor{comment}{//assuming\ ASCII\ parameters}}
\DoxyCodeLine{00292\ \ \ \ \ \textcolor{keywordflow}{return}\ main(argc,\ argv);}
\DoxyCodeLine{00293\ \}}
\DoxyCodeLine{00294\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
