Mercurial > hg > svcore
changeset 862:786ee8d1f30e
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)
author | Chris Cannam |
---|---|
date | Wed, 11 Dec 2013 21:40:27 +0000 |
parents | 0f363d0fbdc3 |
children | 862fe7b20df7 eb6b6a88faed c475940aba79 |
files | transform/FeatureExtractionModelTransformer.cpp |
diffstat | 1 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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