diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-03-26 23:57:19 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-03-26 23:57:19 +0300 |
commit | 1a7e9e8b6b800c24e175370c0fa97e1d1f1585cc (patch) | |
tree | c47bf8ee6ede06a329cf00a005b9cf4adf31e09e /speexbuild | |
parent | 1718cde75e4c0db7b74376b847d58559d646ce1e (diff) |
Indent, changelog and submodule update
Diffstat (limited to 'speexbuild')
-rw-r--r-- | speexbuild/AGC.cpp | 102 | ||||
-rw-r--r-- | speexbuild/ResampMark.cpp | 138 | ||||
-rw-r--r-- | speexbuild/SpeexMark.cpp | 20 | ||||
-rw-r--r-- | speexbuild/config.h | 4 | ||||
-rw-r--r-- | speexbuild/speexbuild.pro | 4 |
5 files changed, 136 insertions, 132 deletions
diff --git a/speexbuild/AGC.cpp b/speexbuild/AGC.cpp index 96b7060a4..06595b51d 100644 --- a/speexbuild/AGC.cpp +++ b/speexbuild/AGC.cpp @@ -19,32 +19,34 @@ template<class T> static inline double veccomp(const QVector<T> &a, const QVector<T> &b, const char *n) { - long double rms = 0.0; - long double gdiff = 0.0; - if (a.size() != b.size()) { - qFatal("%s: %d <=> %d", n, a.size(), b.size()); - } - for(int i=0;i<a.size();++i) { - double diff = fabs(a[i] - b[i]); - rms += diff * diff; - if (diff > gdiff) - gdiff = diff; + long double rms = 0.0; + long double gdiff = 0.0; + if (a.size() != b.size()) { + qFatal("%s: %d <=> %d", n, a.size(), b.size()); + } + for (int i=0;i<a.size();++i) { + double diff = fabs(a[i] - b[i]); + rms += diff * diff; + if (diff > gdiff) + gdiff = diff; #ifdef EXACT - if (a[i] != b[i]) { + if (a[i] != b[i]) { #else - union { T tv; uint32_t uv; } v1, v2; - v1.uv = v2.uv = 0; - v1.tv = a[i]; - v2.tv = b[i]; - if (fabsf(a[i] - b[i]) > 1000) { - qWarning("%08x %08x %08x", v1.uv, v2.uv, v1.uv ^ v2.uv); + union { T tv; + uint32_t uv; + } v1, v2; + v1.uv = v2.uv = 0; + v1.tv = a[i]; + v2.tv = b[i]; + if (fabsf(a[i] - b[i]) > 1000) { + qWarning("%08x %08x %08x", v1.uv, v2.uv, v1.uv ^ v2.uv); #endif - qFatal("%s: Offset %d: %.10g <=> %.10g", n, i, static_cast<double>(a[i]), static_cast<double>(b[i])); - } - } - return gdiff; - return sqrt(rms / a.size()); + qFatal("%s: Offset %d: %.10g <=> %.10g", n, i, static_cast<double>(a[i]), static_cast<double>(b[i])); + } + } + return gdiff; + return sqrt(rms / a.size()); } int main(int argc, char **argv) { @@ -59,15 +61,15 @@ int main(int argc, char **argv) { qFatal("Failed to open file!"); } f.seek(36 + 8); - + QFile o("output.agc"); if (! o.open(QIODevice::WriteOnly)) qFatal("Failed to open out file!"); - + QFile vf("verify.agc"); - if (! vf.open(QIODevice::ReadOnly)) + if (! vf.open(QIODevice::ReadOnly)) qWarning("No verify!"); - + QDataStream out(&o); QDataStream verify(&vf); @@ -80,15 +82,15 @@ int main(int argc, char **argv) { speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_DENOISE, &iarg); speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_AGC, &iarg); speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_DEREVERB, &iarg); - + iarg = 1; speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_AGC, &iarg); iarg = 21747; speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_AGC_TARGET, &iarg); - + QVector<QByteArray> v; - while(1) { + while (1) { QByteArray qba = f.read(iFrameSize * sizeof(short)); if (qba.size() != iFrameSize * sizeof(short)) break; @@ -101,18 +103,18 @@ int main(int argc, char **argv) { QVector<short *> qvIn; QVector<short> sIn(nframes * iFrameSize); - - for(int i=0;i<nframes;i++) { + + for (int i=0;i<nframes;i++) { const short *ptr = reinterpret_cast<const short *>(v[i].constData()); short *s = sIn.data() + i * iFrameSize; - for(int j=0;j<iFrameSize;++j) + for (int j=0;j<iFrameSize;++j) s[j] = ptr[j]; qvIn.append(s); } - + #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) - qWarning("Application: Failed to set priority!"); + if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) + qWarning("Application: Failed to set priority!"); #endif Timer t; @@ -120,36 +122,36 @@ int main(int argc, char **argv) { CALLGRIND_START_INSTRUMENTATION; - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { speex_preprocess_run(spp, qvIn[i]); - + int v; speex_preprocess_ctl(spp, SPEEX_PREPROCESS_GET_AGC_GAIN, &v); qWarning("%d %d", i, v); - + } CALLGRIND_STOP_INSTRUMENTATION; quint64 e = t.elapsed(); #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) - qWarning("Application: Failed to reset priority!"); + if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) + qWarning("Application: Failed to reset priority!"); #endif qWarning("Used %llu usec", e); qWarning("%.2f times realtime", (20000ULL * nframes) / (e * 1.0)); - - if (! RUNNING_ON_VALGRIND) { - - out << sIn; - - if (vf.isOpen()) { - QVector<short> vIn; - verify >> vIn; - veccomp(vIn, sIn, "AGC"); + + if (! RUNNING_ON_VALGRIND) { + + out << sIn; + + if (vf.isOpen()) { + QVector<short> vIn; + verify >> vIn; + veccomp(vIn, sIn, "AGC"); + } } -} return 0; } diff --git a/speexbuild/ResampMark.cpp b/speexbuild/ResampMark.cpp index 195486d2a..ea26fe350 100644 --- a/speexbuild/ResampMark.cpp +++ b/speexbuild/ResampMark.cpp @@ -38,7 +38,7 @@ static inline double veccomp(const QVector<T> &a, const QVector<T> &b, const cha if (a.size() != b.size()) { qFatal("%s: %d <=> %d", n, a.size(), b.size()); } - for(int i=0;i<a.size();++i) { + for (int i=0;i<a.size();++i) { double diff = fabs(a[i] - b[i]); rms += diff * diff; if (diff > gdiff) @@ -47,7 +47,9 @@ static inline double veccomp(const QVector<T> &a, const QVector<T> &b, const cha if (a[i] != b[i]) { #else - union { T tv; quint32 uv; } v1, v2; + union { T tv; + quint32 uv; + } v1, v2; v1.uv = v2.uv = 0; v1.tv = a[i]; v2.tv = b[i]; @@ -63,23 +65,23 @@ static inline double veccomp(const QVector<T> &a, const QVector<T> &b, const cha template<class T> QPair<T, T> confint(const QVector<T> &vecin) { - long double avg = 0.0; - long double stddev = 0.0; - QVector<T> vec = vecin; - qSort(vec.begin(), vec.end()); - for(int i=0;i<vec.count() / 20;++i) { - vec.pop_front(); - vec.pop_back(); - } - - foreach(T v, vec) - avg += v; - avg /= vec.count(); - - foreach(T v, vec) - stddev += (v-avg)*(v-avg); - stddev = sqrtl(stddev / vec.count()); - return QPair<T,T>(static_cast<T>(avg), static_cast<T>(1.96 * stddev)); + long double avg = 0.0; + long double stddev = 0.0; + QVector<T> vec = vecin; + qSort(vec.begin(), vec.end()); + for (int i=0;i<vec.count() / 20;++i) { + vec.pop_front(); + vec.pop_back(); + } + + foreach(T v, vec) + avg += v; + avg /= vec.count(); + + foreach(T v, vec) + stddev += (v-avg)*(v-avg); + stddev = sqrtl(stddev / vec.count()); + return QPair<T,T>(static_cast<T>(avg), static_cast<T>(1.96 * stddev)); } int main(int argc, char **argv) { @@ -111,7 +113,7 @@ int main(int argc, char **argv) { const int iFrameSize = 320; QVector<QByteArray> v; - while(1) { + while (1) { QByteArray qba = f.read(iFrameSize * 2); if (qba.size() != iFrameSize * 2) break; @@ -154,11 +156,11 @@ int main(int argc, char **argv) { QVector<float> f96(nframes * iOutSize96); QVector<float> f8(nframes *iOutSize8); - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { short *s = reinterpret_cast<short *>(v[i].data()); float *f = fInput.data() + i * iFrameSize; - for(int j=0;j<iFrameSize;j++) + for (int j=0;j<iFrameSize;j++) f[j]=s[j]+20; qvInShort.append(s); @@ -183,8 +185,8 @@ int main(int argc, char **argv) { #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) - qWarning("Application: Failed to set priority!"); + if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) + qWarning("Application: Failed to set priority!"); #endif int len; @@ -213,7 +215,7 @@ int main(int argc, char **argv) { sched_yield(); #endif - for(int i=0;i<nframes;++i) { + for (int i=0;i<nframes;++i) { inlen = iFrameSize; outlen = iOutSize96; speex_resampler_process_float(srsto96, 0, qvIn[i], &inlen, qv96[i], &outlen); @@ -222,9 +224,9 @@ int main(int argc, char **argv) { QVector<unsigned long long> qvTimes; QPair<unsigned long long, unsigned long long> ci; - for(int j=0;j<loops;j++) { + for (int j=0;j<loops;j++) { t.restart(); - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { inlen = iFrameSize; outlen = iOutSize1; speex_resampler_process_float(srs1, 0, qvIn[i], &inlen, qvDirect[i], &outlen); @@ -234,12 +236,12 @@ int main(int argc, char **argv) { } ci = confint(qvTimes); qWarning("Direct: %8llu +/- %3llu usec (%d)", ci.first, ci.second, qvTimes.count(), qvTimes.count()); - + qvTimes.clear(); - for(int j=0;j<loops;j++) { + for (int j=0;j<loops;j++) { t.restart(); - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { inlen = iFrameSize; outlen = iOutSize2; speex_resampler_process_float(srs2, 0, qvIn[i], &inlen, qvInterpolate[i], &outlen); @@ -251,9 +253,9 @@ int main(int argc, char **argv) { qWarning("Interpolate: %8llu +/- %3llu usec (%d)", ci.first, ci.second, qvTimes.count()); qvTimes.clear(); - for(int j=0;j<loops;j++) { + for (int j=0;j<loops;j++) { t.restart(); - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { inlen = iOutSize96; outlen = iOutSize8; speex_resampler_process_float(srs96to8, 0, qv96[i], &inlen, qv8[i], &outlen); @@ -266,9 +268,9 @@ int main(int argc, char **argv) { qvTimes.clear(); t.restart(); - for(int j=0;j<loops;j++) { + for (int j=0;j<loops;j++) { t.restart(); - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { inlen = iOutSize8; outlen = iOutSize96; speex_resampler_process_float(srs8to96, 0, qv8[i], &inlen, qv96[i], &outlen); @@ -279,14 +281,14 @@ int main(int argc, char **argv) { ci = confint(qvTimes); qWarning("8 => 96: %8llu +/- %3llu usec (%d)", ci.first, ci.second, qvTimes.count()); - speex_resampler_reset_mem(srs1); - speex_resampler_reset_mem(srs2); + speex_resampler_reset_mem(srs1); + speex_resampler_reset_mem(srs2); } t.restart(); CALLGRIND_START_INSTRUMENTATION; - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { inlen = iFrameSize; outlen = iOutSize1; speex_resampler_process_float(srs1, 0, qvIn[i], &inlen, qvDirect[i], &outlen); @@ -306,48 +308,48 @@ int main(int argc, char **argv) { e = t.elapsed(); #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) - qWarning("Application: Failed to reset priority!"); + if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) + qWarning("Application: Failed to reset priority!"); #endif const int freq[10] = { 22050, 32000, 11025, 16000, 48000, 41000, 8000, 96000, 11025, 1600 }; QVector<float> fMagic; - for(int f=0;f<10;f++) { + for (int f=0;f<10;f++) { float fbuff[32767]; speex_resampler_set_rate(srs1, 16000, freq[f]); - for(int q = 0;q < 10;q++) { + for (int q = 0;q < 10;q++) { speex_resampler_set_quality(srs1, (3*q) % 7); inlen = iFrameSize; outlen = 32767; speex_resampler_process_float(srs1, 0, qvIn[(f*10+q) % nframes], &inlen, fbuff, &outlen); - for(int j=0;j<outlen;j++) + for (int j=0;j<outlen;j++) fMagic.append(fbuff[j]); } inlen = iFrameSize; outlen = 32767; speex_resampler_process_float(srs1, 0, NULL, &inlen, fbuff, &outlen); - for(int j=0;j<outlen;j++) + for (int j=0;j<outlen;j++) fMagic.append(fbuff[j]); } // Cropped magic test - for(int f=0;f<10;f++) { + for (int f=0;f<10;f++) { float fbuff[32767]; speex_resampler_set_rate(srs1, 16000, freq[f]); - for(int q = 0;q < 10;q++) { + for (int q = 0;q < 10;q++) { speex_resampler_set_quality(srs1, (3*q) % 7); inlen = iFrameSize; outlen = 16; speex_resampler_process_float(srs1, 0, qvIn[(f*10+q) % nframes], &inlen, fbuff, &outlen); - for(int j=0;j<outlen;j++) + for (int j=0;j<outlen;j++) fMagic.append(fbuff[j]); } inlen = iFrameSize; outlen = 32767; speex_resampler_process_float(srs1, 0, NULL, &inlen, fbuff, &outlen); - for(int j=0;j<outlen;j++) + for (int j=0;j<outlen;j++) fMagic.append(fbuff[j]); } @@ -358,27 +360,27 @@ int main(int argc, char **argv) { qWarning("%.2f times realtime", (20000ULL * nframes) / (e * 1.0)); if (! RUNNING_ON_VALGRIND) { - QVector<float> vDirect; - QVector<float> vInterpolate; - QVector<short> vsInterpolate; - QVector<float> vMagic; - QVector<float> vInterpolateMC; - - out << fDirect << fInterpolate << sInterpolate << fMagic << fInterpolateMC; - - if (vf.isOpen()) { - verify >> vDirect >> vInterpolate >> vsInterpolate >> vMagic >> vInterpolateMC; - - double rmsd = veccomp(vDirect, fDirect, "SRS1"); - double rmsi = veccomp(vInterpolate, fInterpolate, "SRS2"); - veccomp(vsInterpolate, sInterpolate, "SRS2i"); - veccomp(vMagic, fMagic, "Magic"); - veccomp(vInterpolateMC, fInterpolateMC, "MC"); - qWarning("Direct: %g", rmsd); - qWarning("Interp: %g", rmsi); - } else { - qWarning("No verification!"); - } + QVector<float> vDirect; + QVector<float> vInterpolate; + QVector<short> vsInterpolate; + QVector<float> vMagic; + QVector<float> vInterpolateMC; + + out << fDirect << fInterpolate << sInterpolate << fMagic << fInterpolateMC; + + if (vf.isOpen()) { + verify >> vDirect >> vInterpolate >> vsInterpolate >> vMagic >> vInterpolateMC; + + double rmsd = veccomp(vDirect, fDirect, "SRS1"); + double rmsi = veccomp(vInterpolate, fInterpolate, "SRS2"); + veccomp(vsInterpolate, sInterpolate, "SRS2i"); + veccomp(vMagic, fMagic, "Magic"); + veccomp(vInterpolateMC, fInterpolateMC, "MC"); + qWarning("Direct: %g", rmsd); + qWarning("Interp: %g", rmsi); + } else { + qWarning("No verification!"); + } } return 0; diff --git a/speexbuild/SpeexMark.cpp b/speexbuild/SpeexMark.cpp index c23d6533e..cf997ef6e 100644 --- a/speexbuild/SpeexMark.cpp +++ b/speexbuild/SpeexMark.cpp @@ -66,7 +66,7 @@ int main(int argc, char **argv) { void *dec = speex_decoder_init(&speex_wb_mode); iarg = 1; - speex_decoder_ctl(dec, SPEEX_SET_ENH, &iarg); + speex_decoder_ctl(dec, SPEEX_SET_ENH, &iarg); SpeexPreprocessState *spp = speex_preprocess_state_init(iFrameSize, 16000); iarg = 1; @@ -81,7 +81,7 @@ int main(int argc, char **argv) { speex_preprocess_ctl(spp, SPEEX_PREPROCESS_SET_ECHO_STATE, ses); QVector<QByteArray> v; - while(1) { + while (1) { QByteArray qba = f.read(iFrameSize * 2); if (qba.size() != iFrameSize * 2) break; @@ -95,10 +95,10 @@ int main(int argc, char **argv) { QVector<short *> sv; short tframe[2048]; - for(int i=0;i<iFrameSize;i++) + for (int i=0;i<iFrameSize;i++) tframe[i] = 0; - for(int i=0;i<nframes;i++) { + for (int i=0;i<nframes;i++) { sv.append(reinterpret_cast<short *>(v[i].data())); } @@ -122,8 +122,8 @@ int main(int argc, char **argv) { speex_bits_init(&sb); #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) - qWarning("Application: Failed to set priority!"); + if (!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) + qWarning("Application: Failed to set priority!"); #endif int len; @@ -140,8 +140,8 @@ int main(int argc, char **argv) { CALLGRIND_START_INSTRUMENTATION; - for(int j=0;j<iter;j++) { - for(int i=0;i<nframes-2;i++) { + for (int j=0;j<iter;j++) { + for (int i=0;i<nframes-2;i++) { speex_bits_reset(&sb); speex_echo_cancellation(ses, sv[i], sv[i+2], tframe); @@ -170,8 +170,8 @@ int main(int argc, char **argv) { quint64 e = t.elapsed(); #ifdef Q_OS_WIN - if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) - qWarning("Application: Failed to reset priority!"); + if (!SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS)) + qWarning("Application: Failed to reset priority!"); #endif qWarning("Used %llu usec", e); diff --git a/speexbuild/config.h b/speexbuild/config.h index 9792b9d10..7b3f42b68 100644 --- a/speexbuild/config.h +++ b/speexbuild/config.h @@ -20,7 +20,7 @@ /* #undef FIXED_POINT */ /* Compile as floating-point */ -#define FLOATING_POINT +#define FLOATING_POINT /* Define to 1 if you have the <alloca.h> header file. */ #define HAVE_ALLOCA_H 1 @@ -119,7 +119,7 @@ /* #undef USE_ALLOCA */ /* Use C99 variable-size arrays */ -#define VAR_ARRAYS +#define VAR_ARRAYS /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ diff --git a/speexbuild/speexbuild.pro b/speexbuild/speexbuild.pro index ef63befe7..de3c42aa3 100644 --- a/speexbuild/speexbuild.pro +++ b/speexbuild/speexbuild.pro @@ -23,7 +23,7 @@ DEFINES += NDEBUG HAVE_CONFIG_H INCLUDEPATH = ../speex/include ../speex/libspeex win32 { - INCLUDEPATH += ../speex/win32 + INCLUDEPATH += ../speex/win32 DEFINES+=WIN32 _WINDOWS _USE_SSE _USE_MATH_DEFINES } @@ -44,5 +44,5 @@ CONFIG(debug, debug|release) { CONFIG(release, debug|release) { DESTDIR = ../release } - + |