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
This commit is contained in:
Hans Baier
2009-07-22 09:27:13 +00:00
parent b0bb5342dd
commit 272c1a40db
2 changed files with 19 additions and 16 deletions

View File

@@ -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);

View File

@@ -325,8 +325,8 @@ Session::process_with_events (nframes_t nframes)
if (_transport_speed == 1.0) {
frames_moved = (long) nframes;
} else {
interpolation.set_target_speed (_target_transport_speed);
interpolation.set_speed (_transport_speed);
interpolation.set_target_speed (fabs(_target_transport_speed));
interpolation.set_speed (fabs(_transport_speed));
frames_moved = (long) interpolation.interpolate (0, nframes, 0, 0);
}
@@ -846,8 +846,8 @@ Session::process_without_events (nframes_t nframes)
if (_transport_speed == 1.0) {
frames_moved = (long) nframes;
} else {
interpolation.set_target_speed (_target_transport_speed);
interpolation.set_speed (_transport_speed);
interpolation.set_target_speed (fabs(_target_transport_speed));
interpolation.set_speed (fabs(_transport_speed));
frames_moved = (long) interpolation.interpolate (0, nframes, 0, 0);
}