Mercurial > hg > match-vamp
comparison src/Matcher.cpp @ 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 | aa795f660b2b |
children | 175c8f044e7c |
comparison
equal
deleted
inserted
replaced
219:f5fdc397975a | 220:edd9c1c769a0 |
---|---|
22 #include <cassert> | 22 #include <cassert> |
23 | 23 |
24 using namespace std; | 24 using namespace std; |
25 | 25 |
26 //#define DEBUG_MATCHER 1 | 26 //#define DEBUG_MATCHER 1 |
27 //#define PERFORM_ERROR_CHECKS 1 | |
27 | 28 |
28 Matcher::Matcher(Parameters parameters, DistanceMetric::Parameters dparams, | 29 Matcher::Matcher(Parameters parameters, DistanceMetric::Parameters dparams, |
29 Matcher *p) : | 30 Matcher *p) : |
30 m_params(parameters), | 31 m_params(parameters), |
31 m_metric(dparams) | 32 m_metric(dparams) |
348 0, | 349 0, |
349 distance); | 350 distance); |
350 | 351 |
351 } else if (m_frameCount == 0) { // first row | 352 } else if (m_frameCount == 0) { // first row |
352 | 353 |
353 updateValue(0, index, AdvanceOther, | 354 pathcost_t cost {}; |
354 getPathCost(0, index-1), | 355 |
355 distance); | 356 if (isInRange(0, index - 1)) { |
357 cost = getPathCost(0, index - 1); | |
358 } | |
359 | |
360 updateValue(0, index, AdvanceOther, cost, distance); | |
356 | 361 |
357 } else if (index == 0) { // first column | 362 } else if (index == 0) { // first column |
358 | 363 |
359 updateValue(m_frameCount, index, AdvanceThis, | 364 pathcost_t cost {}; |
360 getPathCost(m_frameCount - 1, 0), | 365 |
361 distance); | 366 if (isInRange(m_frameCount - 1, 0)) { |
367 cost = getPathCost(m_frameCount - 1, 0); | |
368 } | |
369 | |
370 updateValue(m_frameCount, index, AdvanceThis, cost, distance); | |
362 | 371 |
363 } else if (index == m_otherMatcher->m_frameCount - m_blockSize) { | 372 } else if (index == m_otherMatcher->m_frameCount - m_blockSize) { |
364 | 373 |
365 // missing value(s) due to cutoff | 374 // missing value(s) due to cutoff |
366 // - no previous value in current row (resp. column) | 375 // - no previous value in current row (resp. column) |