diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2008-04-27 17:24:43 +0400 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2008-04-27 17:24:43 +0400 |
commit | f4a9042143b168e3bbc794dfd81eb3a965cda8d8 (patch) | |
tree | 59086ff8c57053ce4bde1c069b207114090cf0e2 /speexbuild | |
parent | 72f70e465e0cddb16dfd96261f0f2650d7f52a20 (diff) |
Yet more resampler fixes
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@1119 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'speexbuild')
-rw-r--r-- | speexbuild/ResampMark.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/speexbuild/ResampMark.cpp b/speexbuild/ResampMark.cpp index c86453451..8fe02d8e8 100644 --- a/speexbuild/ResampMark.cpp +++ b/speexbuild/ResampMark.cpp @@ -2,7 +2,7 @@ static const float tfreq1 = 48000.f; static const float tfreq2 = 44100.f; -static const int qual = 3; +static const int qual = 5; static const int loops = 100 / qual; #define SM_VERIFY // #define EXACT @@ -28,11 +28,17 @@ static const int loops = 100 / qual; #include "Timer.h" template<class T> -static inline void veccomp(const QVector<T> &a, const QVector<T> &b, const char *n) { +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; #ifdef EXACT if (a[i] != b[i]) { @@ -41,12 +47,14 @@ static inline void veccomp(const QVector<T> &a, const QVector<T> &b, const char v1.uv = v2.uv = 0; v1.tv = a[i]; v2.tv = b[i]; - if (fabsf(a[i] - b[i]) > 2) { + if (fabsf(a[i] - b[i]) > 1) { 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()); } int main(int argc, char **argv) { @@ -258,11 +266,13 @@ int main(int argc, char **argv) { if (vf.isOpen()) { verify >> vDirect >> vInterpolate >> vsInterpolate >> vMagic >> vInterpolateMC; - veccomp(vDirect, fDirect, "SRS1"); - veccomp(vInterpolate, fInterpolate, "SRS2"); + 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!"); } |