# HG changeset patch # User Chris Cannam # Date 1386798027 0 # Node ID 786ee8d1f30e4920f361419a75eafa079ec0160d # Parent 0f363d0fbdc3e3e5c7f1b394def3458e98730b9b Fix handling of negative frame times in returned features from plugin -- we don't handle them, so don't insert them into the model (instead of blowing up) diff -r 0f363d0fbdc3 -r 786ee8d1f30e transform/FeatureExtractionModelTransformer.cpp --- a/transform/FeatureExtractionModelTransformer.cpp Wed Dec 11 21:39:54 2013 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Wed Dec 11 21:40:27 2013 +0000 @@ -638,7 +638,7 @@ void FeatureExtractionModelTransformer::addFeature(size_t blockFrame, - const Vamp::Plugin::Feature &feature) + const Vamp::Plugin::Feature &feature) { size_t inputRate = m_input.getModel()->getSampleRate(); @@ -653,7 +653,7 @@ binCount = m_descriptor->binCount; } - size_t frame = blockFrame; + int frame = blockFrame; if (m_descriptor->sampleType == Vamp::Plugin::OutputDescriptor::VariableSampleRate) { @@ -678,11 +678,28 @@ m_fixedRateFeatureNo = lrint(ts.toDouble() * m_descriptor->sampleRate); } + +// cerr << "m_fixedRateFeatureNo = " << m_fixedRateFeatureNo +// << ", m_descriptor->sampleRate = " << m_descriptor->sampleRate +// << ", inputRate = " << inputRate +// << " giving frame = "; frame = lrintf((m_fixedRateFeatureNo / m_descriptor->sampleRate) - * inputRate); + * int(inputRate)); + +// cerr << frame << endl; } - + + if (frame < 0) { + cerr + << "WARNING: FeatureExtractionModelTransformer::addFeature: " + << "Negative frame counts are not supported (frame = " << frame + << " from timestamp " << feature.timestamp + << "), dropping feature" + << endl; + return; + } + // Rather than repeat the complicated tests from the constructor // to determine what sort of model we must be adding the features // to, we instead test what sort of model the constructor decided