[SCM] soundtouch/master: Fix assertion in findCrossingLevel
hyperair at users.alioth.debian.org
hyperair at users.alioth.debian.org
Tue Dec 10 12:41:36 UTC 2013
The following commit has been merged in the master branch:
commit c299192f4d26a3b6935134a0378cefc7fc0c80c2
Author: Chow Loong Jin <hyperair at debian.org>
Date: Tue Dec 10 12:06:10 2013 +0800
Fix assertion in findCrossingLevel
LP: #1193667
diff --git a/debian/patches/fix-fp-rounding-error.patch b/debian/patches/fix-fp-rounding-error.patch
new file mode 100644
index 0000000..4f98f5f
--- /dev/null
+++ b/debian/patches/fix-fp-rounding-error.patch
@@ -0,0 +1,40 @@
+From: Chow Loong Jin <hyperair at debian.org>
+Date: Tue, 10 Dec 2013 11:56:20 +0800
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1193667
+Subject: Fix rounding error in PeakFinder::getPeakCenter
+ Avoid recalculating cutLevel and groundLevel when all of them are equal to
+ peakLevel, as this can result in floating point rounding differences that can
+ cause cutLevel to exceed peakLevel, resulting in an assertion error in
+ PeakFinder::findCrossingLevel.
+diff --git a/source/SoundTouch/PeakFinder.cpp b/source/SoundTouch/PeakFinder.cpp
+index dbc44e7..8d7199f 100644
+--- a/source/SoundTouch/PeakFinder.cpp
++++ b/source/SoundTouch/PeakFinder.cpp
+@@ -192,11 +192,21 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const
+ gp1 = findGround(data, peakpos, -1);
+ gp2 = findGround(data, peakpos, 1);
+
+- groundLevel = 0.5f * (data[gp1] + data[gp2]);
+ peakLevel = data[peakpos];
+
+- // calculate 70%-level of the peak
+- cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
++ if (gp1 == gp2) {
++ // avoid rounding errors when all are equal
++ assert(gp1 == peakpos);
++
++ cutLevel = groundLevel = peakLevel;
++ } else {
++ // get average of the ground levels
++ groundLevel = 0.5f * (data[gp1] + data[gp2]);
++
++ // calculate 70%-level of the peak
++ cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
++ }
++
+ // find mid-level crossings
+ crosspos1 = findCrossingLevel(data, cutLevel, peakpos, -1);
+ crosspos2 = findCrossingLevel(data, cutLevel, peakpos, 1);
+--
+1.8.3.2
+
diff --git a/debian/patches/series b/debian/patches/series
index 2ec919f..5b8f59f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
dont-use-integers-if-softfp.patch
+fix-fp-rounding-error.patch
--
soundtouch packaging
More information about the pkg-multimedia-commits
mailing list