comparison src/vamp-hostsdk/PluginSummarisingAdapter.cpp @ 274:33feff966de3

* Fix an infinite loop that occurs with some features
author cannam
date Fri, 12 Dec 2008 14:28:42 +0000
parents de3e865f92c8
children ecfb41a370aa
comparison
equal deleted inserted replaced
273:de3e865f92c8 274:33feff966de3
611 PluginSummarisingAdapter::Impl::segment() 611 PluginSummarisingAdapter::Impl::segment()
612 { 612 {
613 SegmentBoundaries::iterator boundaryitr = m_boundaries.begin(); 613 SegmentBoundaries::iterator boundaryitr = m_boundaries.begin();
614 RealTime segmentStart = RealTime::zeroTime; 614 RealTime segmentStart = RealTime::zeroTime;
615 615
616 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER_SEGMENT
617 std::cerr << "segment: starting" << std::endl;
618 #endif
619
616 for (OutputAccumulatorMap::iterator i = m_accumulators.begin(); 620 for (OutputAccumulatorMap::iterator i = m_accumulators.begin();
617 i != m_accumulators.end(); ++i) { 621 i != m_accumulators.end(); ++i) {
618 622
619 int output = i->first; 623 int output = i->first;
620 OutputAccumulator &source = i->second; 624 OutputAccumulator &source = i->second;
643 #endif 647 #endif
644 648
645 RealTime segmentStart = RealTime::zeroTime; 649 RealTime segmentStart = RealTime::zeroTime;
646 RealTime segmentEnd = resultEnd - RealTime(1, 0); 650 RealTime segmentEnd = resultEnd - RealTime(1, 0);
647 651
652 RealTime prevSegmentStart = segmentStart - RealTime(1, 0);
653
648 while (segmentEnd < resultEnd) { 654 while (segmentEnd < resultEnd) {
649 655
656 #ifdef DEBUG_PLUGIN_SUMMARISING_ADAPTER_SEGMENT
657 std::cerr << "segment end " << segmentEnd << " < result end "
658 << resultEnd << " (with result start " << resultStart << ")" << std::endl;
659 #endif
660
650 findSegmentBounds(resultStart, segmentStart, segmentEnd); 661 findSegmentBounds(resultStart, segmentStart, segmentEnd);
662
663 if (segmentStart == prevSegmentStart) {
664 // This can happen when we reach the end of the
665 // input, if a feature's end time overruns the
666 // input audio end time
667 break;
668 }
669 prevSegmentStart = segmentStart;
651 670
652 RealTime chunkStart = resultStart; 671 RealTime chunkStart = resultStart;
653 if (chunkStart < segmentStart) chunkStart = segmentStart; 672 if (chunkStart < segmentStart) chunkStart = segmentStart;
654 673
655 RealTime chunkEnd = resultEnd; 674 RealTime chunkEnd = resultEnd;