Mercurial > hg > match-vamp
changeset 220:edd9c1c769a0
Fix crash in looking up expand direction, when the entire reference audio has been fed before any performance has (a pathological case)
author | Chris Cannam |
---|---|
date | Thu, 11 Jun 2015 12:30:51 +0100 |
parents | f5fdc397975a |
children | cb3098285a52 |
files | src/Finder.cpp src/Matcher.cpp |
diffstat | 2 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Finder.cpp Thu Apr 23 13:47:48 2015 +0100 +++ b/src/Finder.cpp Thu Jun 11 12:30:51 2015 +0100 @@ -14,6 +14,9 @@ COPYING included with this distribution for more information. */ +//#define DEBUG_FINDER 1 +//#define PERFORM_ERROR_CHECKS 1 + #include "Finder.h" #include "Path.h" @@ -23,9 +26,6 @@ using namespace std; -//#define DEBUG_FINDER 1 -//#define PERFORM_ERROR_CHECKS 1 - Finder::Finder(Matcher *pm) { m_m = pm;
--- a/src/Matcher.cpp Thu Apr 23 13:47:48 2015 +0100 +++ b/src/Matcher.cpp Thu Jun 11 12:30:51 2015 +0100 @@ -24,6 +24,7 @@ using namespace std; //#define DEBUG_MATCHER 1 +//#define PERFORM_ERROR_CHECKS 1 Matcher::Matcher(Parameters parameters, DistanceMetric::Parameters dparams, Matcher *p) : @@ -350,15 +351,23 @@ } else if (m_frameCount == 0) { // first row - updateValue(0, index, AdvanceOther, - getPathCost(0, index-1), - distance); + pathcost_t cost {}; + + if (isInRange(0, index - 1)) { + cost = getPathCost(0, index - 1); + } + + updateValue(0, index, AdvanceOther, cost, distance); } else if (index == 0) { // first column - updateValue(m_frameCount, index, AdvanceThis, - getPathCost(m_frameCount - 1, 0), - distance); + pathcost_t cost {}; + + if (isInRange(m_frameCount - 1, 0)) { + cost = getPathCost(m_frameCount - 1, 0); + } + + updateValue(m_frameCount, index, AdvanceThis, cost, distance); } else if (index == m_otherMatcher->m_frameCount - m_blockSize) {