summaryrefslogtreecommitdiff
path: root/libs/ardour/interpolation.cc
diff options
context:
space:
mode:
authorHans Baier <hansfbaier@googlemail.com>2009-07-22 09:27:13 +0000
committerHans Baier <hansfbaier@googlemail.com>2009-07-22 09:27:13 +0000
commit272c1a40db7c965664b256f7f5487dd224bfd413 (patch)
tree4e8fe9422c27250a7812782dfc1d0e3ddc0383d3 /libs/ardour/interpolation.cc
parentb0bb5342dd0fddf867208ea1e4c4a87a32a7b214 (diff)
spline interpolation: fix crash bugs on negative speed and NULL inputs
git-svn-id: svn://localhost/ardour2/branches/3.0@5411 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/interpolation.cc')
-rw-r--r--libs/ardour/interpolation.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/libs/ardour/interpolation.cc b/libs/ardour/interpolation.cc
index 716ebd4139..e0035ea11b 100644
--- a/libs/ardour/interpolation.cc
+++ b/libs/ardour/interpolation.cc
@@ -146,19 +146,22 @@ SplineInterpolation::interpolate (int channel, nframes_t nframes, Sample *input,
M[0] = 0.0;
M[n - 1] = 0.0;
- // solve L * t = d
- t[0] = 6.0 * (input[0] - 2*input[1] + input[2]);
- for (nframes_t i = 1; i <= n - 3; i++) {
- t[i] = 6.0 * (input[i] - 2*input[i+1] + input[i+2])
- - l(i-1) * t[i-1];
+ if (input) {
+ // solve L * t = d
+ t[0] = 6.0 * (input[0] - 2*input[1] + input[2]);
+ for (nframes_t i = 1; i <= n - 3; i++) {
+ t[i] = 6.0 * (input[i] - 2*input[i+1] + input[i+2])
+ - l(i-1) * t[i-1];
+ }
+
+ // solve U * M = t
+ M[n-2] = t[n-3] / m(n-3);
+ for (nframes_t i = n-4;; i--) {
+ M[i+1] = (t[i]-M[i+2])/m(i);
+ if ( i == 0 ) break;
+ }
}
- // solve U * M = t
- M[n-2] = t[n-3] / m(n-3);
- for (nframes_t i = n-4;; i--) {
- M[i+1] = (t[i]-M[i+2])/m(i);
- if ( i == 0 ) break;
- }
assert (M[0] == 0.0 && M[n-1] == 0.0);
// now interpolate
@@ -185,7 +188,7 @@ SplineInterpolation::interpolate (int channel, nframes_t nframes, Sample *input,
if (x >= 1.0) {
x = 0.0;
i++;
- }
+ }
assert(x >= 0.0 && x < 1.0);