# HG changeset patch # User Chris Cannam # Date 1416306697 0 # Node ID 61c7d11ba86d589acde16e32ae37672849f5e0c2 # Parent a540137d393bd094785f5ae1ddb67b1a0669eeee Fix handling of path lookup in case where the expected end point (end of silence in both files) is not available diff -r a540137d393b -r 61c7d11ba86d src/Finder.cpp --- a/src/Finder.cpp Tue Nov 18 10:03:36 2014 +0000 +++ b/src/Finder.cpp Tue Nov 18 10:31:37 2014 +0000 @@ -258,8 +258,13 @@ int Finder::retrievePath(bool smooth, vector &pathx, vector &pathy) { - int x = pm2->getFrameCount() - 1; - int y = pm1->getFrameCount() - 1; + int ex = pm2->getFrameCount() - 1; + int ey = pm1->getFrameCount() - 1; + + int x = ex; + int y = ey; + +// cerr << "before: x = " << x << ", y = " << y << endl; if (duration2 > 0 && duration2 < pm2->getFrameCount()) { x = duration2 - 1; @@ -268,11 +273,23 @@ y = duration1 - 1; } + if (!find(y, x)) { + // Path did not pass through the expected end point -- + // probably means the pieces are substantially different in + // the later bits. Reset the expected end point to the end of + // both files including any trailing silence. + cerr << "NOTE: Path did not pass through expected end point, inputs are probably significantly different" << endl; + x = ex; + y = ey; + } + recalculatePathCostMatrix(0, 0, y, x); pathx.clear(); pathy.clear(); +// cerr << "start: x = " << x << ", y = " << y << endl; + while (find(y, x) && ((x > 0) || (y > 0))) { // cerr << "x = " << x << ", y = " << y;