# HG changeset patch # User Chris Cannam # Date 1417093163 0 # Node ID 7785bb8a1be64fce3074b34b970d419e7eba7217 # Parent 1f5291760ed9ed98322275937ded48d07932be34 Fix diagonal handling: there was an implicit fixed diagonal weight of 2 in comparison of diagmin+distance to othermin directly diff -r 1f5291760ed9 -r 7785bb8a1be6 src/Matcher.cpp --- a/src/Matcher.cpp Thu Nov 27 12:57:59 2014 +0000 +++ b/src/Matcher.cpp Thu Nov 27 12:59:23 2014 +0000 @@ -278,6 +278,8 @@ (m_frames[frameIndex], m_otherMatcher->m_frames[index % m_blockSize]); + float diagDistance = distance * m_params.diagonalWeight; + if ((m_frameCount == 0) && (index == 0)) { // first element updateValue(0, 0, AdvanceNone, @@ -317,7 +319,7 @@ } else { double min1 = getPathCost(m_frameCount - 1, index - 1); - if (min1 + distance <= min2) { + if (min1 + diagDistance <= min2 + distance) { updateValue(m_frameCount, index, AdvanceBoth, min1, distance); } else { @@ -338,9 +340,13 @@ << " min2 = " << min2 << ", " << " min3 = " << min3 << endl; } + + double cost1 = min1 + distance; + double cost2 = min2 + distance; + double cost3 = min3 + diagDistance; - if (min1 <= min2) { - if (min3 + distance <= min1) { + if (cost1 <= cost2) { + if (cost3 <= cost1) { updateValue(m_frameCount, index, AdvanceBoth, min3, distance); } else { @@ -348,7 +354,7 @@ min1, distance); } } else { - if (min3 + distance <= min2) { + if (cost3 <= cost2) { updateValue(m_frameCount, index, AdvanceBoth, min3, distance); } else {