Mercurial > hg > svcore
diff data/model/AlignmentModel.cpp @ 383:94fc0591ea43 1.2-stable
* merge from trunk (1.2 ended up being tracked from trunk, but we may want
this branch for fixes later)
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 10:32:45 +0000 |
parents | ba30f4a3e3be |
children |
line wrap: on
line diff
--- a/data/model/AlignmentModel.cpp Fri Nov 30 17:36:14 2007 +0000 +++ b/data/model/AlignmentModel.cpp Wed Feb 27 10:32:45 2008 +0000 @@ -17,6 +17,8 @@ #include "SparseTimeValueModel.h" +//#define DEBUG_ALIGNMENT_MODEL 1 + AlignmentModel::AlignmentModel(Model *reference, Model *aligned, Model *inputModel, @@ -30,14 +32,17 @@ m_pathBegun(false), m_pathComplete(false) { - connect(m_rawPath, SIGNAL(modelChanged()), - this, SLOT(pathChanged())); + if (m_rawPath) { - connect(m_rawPath, SIGNAL(modelChanged(size_t, size_t)), - this, SLOT(pathChanged(size_t, size_t))); + connect(m_rawPath, SIGNAL(modelChanged()), + this, SLOT(pathChanged())); - connect(m_rawPath, SIGNAL(completionChanged()), - this, SLOT(pathCompletionChanged())); + connect(m_rawPath, SIGNAL(modelChanged(size_t, size_t)), + this, SLOT(pathChanged(size_t, size_t))); + + connect(m_rawPath, SIGNAL(completionChanged()), + this, SLOT(pathCompletionChanged())); + } constructPath(); constructReversePath(); @@ -124,16 +129,26 @@ size_t AlignmentModel::toReference(size_t frame) const { -// std::cerr << "AlignmentModel::toReference(" << frame << ")" << std::endl; - if (!m_path) constructPath(); +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::toReference(" << frame << ")" << std::endl; +#endif + if (!m_path) { + if (!m_rawPath) return frame; + constructPath(); + } return align(m_path, frame); } size_t AlignmentModel::fromReference(size_t frame) const { -// std::cerr << "AlignmentModel::fromReference(" << frame << ")" << std::endl; - if (!m_reversePath) constructReversePath(); +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::fromReference(" << frame << ")" << std::endl; +#endif + if (!m_reversePath) { + if (!m_rawPath) return frame; + constructReversePath(); + } return align(m_reversePath, frame); } @@ -166,8 +181,10 @@ int completion = 0; m_rawPath->isReady(&completion); -// std::cerr << "AlignmentModel::pathCompletionChanged: completion = " -// << completion << std::endl; +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::pathCompletionChanged: completion = " + << completion << std::endl; +#endif m_pathComplete = (completion == 100); @@ -211,7 +228,9 @@ m_path->addPoint(PathPoint(frame, rframe)); } -// std::cerr << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; +#endif } void @@ -241,7 +260,9 @@ m_reversePath->addPoint(PathPoint(rframe, frame)); } -// std::cerr << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; +#endif } size_t @@ -257,13 +278,24 @@ const PathModel::PointList &points = path->getPoints(); if (points.empty()) { -// std::cerr << "AlignmentModel::align: No points" << std::endl; +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::align: No points" << std::endl; +#endif return frame; } +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::align: frame " << frame << " requested" << std::endl; +#endif + PathModel::Point point(frame); PathModel::PointList::const_iterator i = points.lower_bound(point); - if (i == points.end()) --i; + if (i == points.end()) { +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "Note: i == points.end()" << std::endl; +#endif + --i; + } while (i != points.begin() && i->frame > long(frame)) --i; long foundFrame = i->frame; @@ -273,9 +305,16 @@ long followingMapFrame = foundMapFrame; if (++i != points.end()) { +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "another point available" << std::endl; +#endif followingFrame = i->frame; followingMapFrame = i->mapframe; - } + } else { +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "no other point available" << std::endl; +#endif + } if (foundMapFrame < 0) return 0; @@ -288,7 +327,9 @@ resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp); } -// std::cerr << "AlignmentModel::align: resultFrame = " << resultFrame << std::endl; +#ifdef DEBUG_ALIGNMENT_MODEL + std::cerr << "AlignmentModel::align: resultFrame = " << resultFrame << std::endl; +#endif return resultFrame; }