diff src/MatchFeatureFeeder.cpp @ 60:faa523be20f9 refactors_no_float

Update both Feeders so as to recognise the end of one input before the other has ended. MatchFeeder does this by detecting trailing silence (as both its inputs are technically the same length since the shorter is zero-padded) and reporting that to Finder. MatchFeatureFeeder simply recognises missing features at the end and won't queue them.
author Chris Cannam
date Fri, 14 Nov 2014 13:53:58 +0000
parents c2e152d8a9d4
children 19a93b15fcc3 a540137d393b
line wrap: on
line diff
--- a/src/MatchFeatureFeeder.cpp	Fri Nov 14 10:25:57 2014 +0000
+++ b/src/MatchFeatureFeeder.cpp	Fri Nov 14 13:53:58 2014 +0000
@@ -38,10 +38,15 @@
     // processing up to one feature per matcher, until a queue is
     // empty.  Then it returns, to be called again with more data.
 
-    q1.push(f1);
-    q2.push(f2);
+    if (!f1.empty()) {
+        q1.push(f1);
+    }
+    
+    if (!f2.empty()) {
+        q2.push(f2);
+    }
 
-    while (!q1.empty() && !q2.empty()) {
+    while (!q1.empty() || !q2.empty()) {
         feedBlock();
     }
 }
@@ -49,11 +54,14 @@
 void
 MatchFeatureFeeder::feedBlock()
 {
-    if (pm1->m_frameCount < pm1->m_blockSize) {		// fill initial block
+    if (q1.empty()) { // ended
+        feed2();
+    } else if (q2.empty()) { // ended
+        feed1();
+    } else if (pm1->m_frameCount < pm1->m_blockSize) {		// fill initial block
         feed1();
         feed2();
-    }
-    else if (pm1->m_runCount >= pm1->m_params.maxRunCount) {  // slope constraints
+    } else if (pm1->m_runCount >= pm1->m_params.maxRunCount) {  // slope constraints
         feed2();
     } else if (pm2->m_runCount >= pm2->m_params.maxRunCount) {
         feed1();