Mercurial > hg > match-vamp
changeset 75:e1a5f3095ba6 cheap_diagonals
Merge from branch refactors
author | Chris Cannam |
---|---|
date | Wed, 19 Nov 2014 12:13:28 +0000 |
parents | 7aa1ab3db7c9 (diff) b9aa663a607b (current diff) |
children | 0042b4d42167 |
files | src/Finder.cpp src/Finder.h src/MatchFeeder.cpp src/MatchFeeder.h src/Matcher.cpp |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Finder.cpp Wed Nov 19 11:59:03 2014 +0000 +++ b/src/Finder.cpp Wed Nov 19 12:13:28 2014 +0000 @@ -96,6 +96,8 @@ void Finder::recalculatePathCostMatrix(int r1, int c1, int r2, int c2) { + float diagonalWeight = sqrtf(2.f); + int prevRowStart = 0, prevRowStop = 0; for (int r = r1; r <= r2; r++) { @@ -114,7 +116,7 @@ double min = -1; if ((c > prevRowStart) && (c <= prevRowStop)) { // diagonal from (r-1,c-1) - min = m_m->getPathCost(r-1, c-1) + newCost * 2; + min = m_m->getPathCost(r-1, c-1) + newCost * diagonalWeight; dir = Matcher::AdvanceBoth; } if ((c >= prevRowStart) && (c < prevRowStop)) {
--- a/src/Finder.h Wed Nov 19 11:59:03 2014 +0000 +++ b/src/Finder.h Wed Nov 19 12:13:28 2014 +0000 @@ -70,6 +70,6 @@ Matcher *m_m; int m_duration1; int m_duration2; -}; // class Finder +}; #endif
--- a/src/Matcher.cpp Wed Nov 19 11:59:03 2014 +0000 +++ b/src/Matcher.cpp Wed Nov 19 12:13:28 2014 +0000 @@ -339,10 +339,17 @@ void Matcher::updateValue(int i, int j, Advance dir, double value, float dMN) { + float diagonalWeight = sqrtf(2.f); + + float weight = 1.f; + if (dir == AdvanceBoth) { + weight *= diagonalWeight; + } + if (m_firstPM) { m_distance[i][j - m_first[i]] = dMN; - setPathCost(i, j, dir, value + (dir == AdvanceBoth ? dMN*2: dMN)); + setPathCost(i, j, dir, value + weight * dMN); } else { @@ -359,7 +366,7 @@ } m_otherMatcher->m_distance[j][idx] = dMN; - m_otherMatcher->setPathCost(j, i, dir, value + (dir == AdvanceBoth ? dMN*2: dMN)); + m_otherMatcher->setPathCost(j, i, dir, value + weight * dMN); } }