Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/hostext/PluginSummarisingAdapter.cpp @ 186:8311695c13f9
* segmentation for results being summarised -- I need to come up with a
good way to test this before going any further!
author | cannam |
---|---|
date | Thu, 11 Sep 2008 16:11:34 +0000 |
parents | 701505ac170c |
children | ed8aa954e72f |
comparison
equal
deleted
inserted
replaced
185:701505ac170c | 186:8311695c13f9 |
---|---|
126 RealTime m_lastTimestamp; | 126 RealTime m_lastTimestamp; |
127 | 127 |
128 void accumulate(const FeatureSet &fs, RealTime, bool final); | 128 void accumulate(const FeatureSet &fs, RealTime, bool final); |
129 void accumulate(int output, const Feature &f, RealTime, bool final); | 129 void accumulate(int output, const Feature &f, RealTime, bool final); |
130 void accumulateFinalDurations(); | 130 void accumulateFinalDurations(); |
131 void findSegmentBounds(RealTime t, RealTime &start, RealTime &end); | |
131 void segment(); | 132 void segment(); |
132 void reduce(); | 133 void reduce(); |
133 }; | 134 }; |
134 | 135 |
135 static RealTime INVALID_DURATION(INT_MIN, INT_MIN); | 136 static RealTime INVALID_DURATION(INT_MIN, INT_MIN); |
468 } | 469 } |
469 } | 470 } |
470 } | 471 } |
471 | 472 |
472 void | 473 void |
474 PluginSummarisingAdapter::Impl::findSegmentBounds(RealTime t, | |
475 RealTime &start, | |
476 RealTime &end) | |
477 { | |
478 std::cerr << "findSegmentBounds: t = " << t << std::endl; | |
479 | |
480 SegmentBoundaries::const_iterator i = std::lower_bound | |
481 (m_boundaries.begin(), m_boundaries.end(), t); | |
482 | |
483 start = RealTime::zeroTime; | |
484 end = m_lastTimestamp; | |
485 | |
486 if (i != m_boundaries.end()) { | |
487 | |
488 start = *i; | |
489 | |
490 if (++i != m_boundaries.end()) { | |
491 end = *i; | |
492 } | |
493 } | |
494 | |
495 std::cerr << "findSegmentBounds: " << t << " is in segment " << start << " -> " << end << std::endl; | |
496 } | |
497 | |
498 void | |
473 PluginSummarisingAdapter::Impl::segment() | 499 PluginSummarisingAdapter::Impl::segment() |
474 { | 500 { |
475 /* | |
476 SegmentBoundaries::iterator boundaryitr = m_boundaries.begin(); | 501 SegmentBoundaries::iterator boundaryitr = m_boundaries.begin(); |
477 RealTime segmentStart = RealTime::zeroTime; | 502 RealTime segmentStart = RealTime::zeroTime; |
478 | 503 |
479 for (OutputAccumulatorMap::iterator i = m_accumulators.begin(); | 504 for (OutputAccumulatorMap::iterator i = m_accumulators.begin(); |
480 i != m_accumulators.end(); ++i) { | 505 i != m_accumulators.end(); ++i) { |
481 | 506 |
482 int output = i->first; | 507 int output = i->first; |
483 OutputAccumulator &source = i->second; | 508 OutputAccumulator &source = i->second; |
484 RealTime accumulatedTime = RealTime::zeroTime; | 509 |
485 | 510 for (int n = 0; n < source.results.size(); ++n) { |
486 for (int n = 0; n < source.durations.size(); ++n) { | 511 |
487 */ | 512 // This result spans source.results[n].time to |
513 // source.results[n].time + source.results[n].duration. | |
514 // We need to dispose it into segments appropriately | |
515 | |
516 RealTime resultStart = source.results[n].time; | |
517 RealTime resultEnd = resultStart + source.results[n].duration; | |
518 | |
519 RealTime segmentStart = RealTime::zeroTime; | |
520 RealTime segmentEnd = resultEnd - RealTime(1, 0); | |
521 | |
522 while (segmentEnd < resultEnd) { | |
523 | |
524 findSegmentBounds(resultStart, segmentStart, segmentEnd); | |
525 | |
526 RealTime chunkStart = resultStart; | |
527 if (chunkStart < segmentStart) chunkStart = segmentStart; | |
528 | |
529 RealTime chunkEnd = resultEnd; | |
530 if (chunkEnd > segmentEnd) chunkEnd = segmentEnd; | |
531 | |
532 m_segmentedAccumulators[output][segmentStart].bins = source.bins; | |
533 | |
534 Result chunk; | |
535 chunk.time = chunkStart; | |
536 chunk.duration = chunkEnd - chunkStart; | |
537 chunk.values = source.results[n].values; | |
538 | |
539 std::cerr << "chunk for segment " << segmentStart << ": from " << chunk.time << ", duration " << chunk.duration << std::endl; | |
540 | |
541 m_segmentedAccumulators[output][segmentStart].results | |
542 .push_back(chunk); | |
543 | |
544 resultStart = chunkEnd; | |
545 } | |
546 } | |
547 } | |
548 | |
488 | 549 |
489 | 550 |
490 /* | 551 /* |
491 if (boundaryitr == m_boundaries.end()) { | 552 if (boundaryitr == m_boundaries.end()) { |
492 m_segmentedAccumulators[output][segmentStart] = source; | 553 m_segmentedAccumulators[output][segmentStart] = source; |