Mercurial > hg > match-vamp
comparison src/MatchFeeder.cpp @ 63:a540137d393b refactors_no_float
Fix handling of empty queues -- we should continue processing when a queue is empty only if we've reached end of file on both
author | Chris Cannam |
---|---|
date | Tue, 18 Nov 2014 10:03:36 +0000 |
parents | faa523be20f9 |
children | da9ead46abe9 |
comparison
equal
deleted
inserted
replaced
60:faa523be20f9 | 63:a540137d393b |
---|---|
51 // It loops, processing up to one block per matcher, until a queue | 51 // It loops, processing up to one block per matcher, until a queue |
52 // is empty. Then it returns, to be called again with more data. | 52 // is empty. Then it returns, to be called again with more data. |
53 | 53 |
54 prepare(input); | 54 prepare(input); |
55 | 55 |
56 while (!q1.empty() || !q2.empty()) { | 56 while (!q1.empty() && !q2.empty()) { |
57 // std::cerr << "MatchFeeder::feed: q1 " << q1.size() << " q2 " << q2.size() << std::endl; | |
58 (void)feedBlock(); | 57 (void)feedBlock(); |
59 } | 58 } |
60 } | 59 } |
61 | 60 |
62 MatchFeeder::Features | 61 MatchFeeder::Features |
63 MatchFeeder::feedAndGetFeatures(const float *const *input) | 62 MatchFeeder::feedAndGetFeatures(const float *const *input) |
64 { | 63 { |
65 prepare(input); | 64 prepare(input); |
66 | 65 |
66 Features all; | |
67 | |
68 while (!q1.empty() && !q2.empty()) { | |
69 Features ff = feedBlock(); | |
70 all.f1.insert(all.f1.end(), ff.f1.begin(), ff.f1.end()); | |
71 all.f2.insert(all.f2.end(), ff.f2.begin(), ff.f2.end()); | |
72 } | |
73 | |
74 return all; | |
75 } | |
76 | |
77 void | |
78 MatchFeeder::finish() | |
79 { | |
80 while (!q1.empty() || !q2.empty()) { | |
81 (void)feedBlock(); | |
82 } | |
83 } | |
84 | |
85 MatchFeeder::Features | |
86 MatchFeeder::finishAndGetFeatures() | |
87 { | |
67 Features all; | 88 Features all; |
68 | 89 |
69 while (!q1.empty() || !q2.empty()) { | 90 while (!q1.empty() || !q2.empty()) { |
70 Features ff = feedBlock(); | 91 Features ff = feedBlock(); |
71 all.f1.insert(all.f1.end(), ff.f1.begin(), ff.f1.end()); | 92 all.f1.insert(all.f1.end(), ff.f1.begin(), ff.f1.end()); |
115 { | 136 { |
116 Features ff; | 137 Features ff; |
117 vector<double> f1, f2; | 138 vector<double> f1, f2; |
118 | 139 |
119 if (q1.empty()) { | 140 if (q1.empty()) { |
120 feed2(); | 141 f2 = feed2(); |
121 } else if (q2.empty()) { | 142 } else if (q2.empty()) { |
122 feed1(); | 143 f1 = feed1(); |
123 } else if (pm1->m_frameCount < pm1->m_blockSize) { // fill initial block | 144 } else if (pm1->m_frameCount < pm1->m_blockSize) { // fill initial block |
124 // std::cerr << "feeding initial block" << std::endl; | 145 // std::cerr << "feeding initial block" << std::endl; |
125 f1 = feed1(); | 146 f1 = feed1(); |
126 f2 = feed2(); | 147 f2 = feed2(); |
127 } else if (pm1->m_runCount >= pm1->m_params.maxRunCount) { // slope constraints | 148 } else if (pm1->m_runCount >= pm1->m_params.maxRunCount) { // slope constraints |