comparison 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
comparison
equal deleted inserted replaced
57:47f7649ab9d5 60:faa523be20f9
36 // stream. When the match-feeder function is entered, it knows 36 // stream. When the match-feeder function is entered, it knows
37 // that it has at least one feature in each queue. It loops, 37 // that it has at least one feature in each queue. It loops,
38 // processing up to one feature per matcher, until a queue is 38 // processing up to one feature per matcher, until a queue is
39 // empty. Then it returns, to be called again with more data. 39 // empty. Then it returns, to be called again with more data.
40 40
41 q1.push(f1); 41 if (!f1.empty()) {
42 q2.push(f2); 42 q1.push(f1);
43 }
44
45 if (!f2.empty()) {
46 q2.push(f2);
47 }
43 48
44 while (!q1.empty() && !q2.empty()) { 49 while (!q1.empty() || !q2.empty()) {
45 feedBlock(); 50 feedBlock();
46 } 51 }
47 } 52 }
48 53
49 void 54 void
50 MatchFeatureFeeder::feedBlock() 55 MatchFeatureFeeder::feedBlock()
51 { 56 {
52 if (pm1->m_frameCount < pm1->m_blockSize) { // fill initial block 57 if (q1.empty()) { // ended
58 feed2();
59 } else if (q2.empty()) { // ended
60 feed1();
61 } else if (pm1->m_frameCount < pm1->m_blockSize) { // fill initial block
53 feed1(); 62 feed1();
54 feed2(); 63 feed2();
55 } 64 } else if (pm1->m_runCount >= pm1->m_params.maxRunCount) { // slope constraints
56 else if (pm1->m_runCount >= pm1->m_params.maxRunCount) { // slope constraints
57 feed2(); 65 feed2();
58 } else if (pm2->m_runCount >= pm2->m_params.maxRunCount) { 66 } else if (pm2->m_runCount >= pm2->m_params.maxRunCount) {
59 feed1(); 67 feed1();
60 } else { 68 } else {
61 switch (finder->getExpandDirection 69 switch (finder->getExpandDirection