Mercurial > hg > svcore
comparison data/model/AlignmentModel.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
688:be43b2fe68e8 | 689:573d45e9487b |
---|---|
139 | 139 |
140 size_t | 140 size_t |
141 AlignmentModel::toReference(size_t frame) const | 141 AlignmentModel::toReference(size_t frame) const |
142 { | 142 { |
143 #ifdef DEBUG_ALIGNMENT_MODEL | 143 #ifdef DEBUG_ALIGNMENT_MODEL |
144 std::cerr << "AlignmentModel::toReference(" << frame << ")" << std::endl; | 144 DEBUG << "AlignmentModel::toReference(" << frame << ")" << endl; |
145 #endif | 145 #endif |
146 if (!m_path) { | 146 if (!m_path) { |
147 if (!m_rawPath) return frame; | 147 if (!m_rawPath) return frame; |
148 constructPath(); | 148 constructPath(); |
149 } | 149 } |
152 | 152 |
153 size_t | 153 size_t |
154 AlignmentModel::fromReference(size_t frame) const | 154 AlignmentModel::fromReference(size_t frame) const |
155 { | 155 { |
156 #ifdef DEBUG_ALIGNMENT_MODEL | 156 #ifdef DEBUG_ALIGNMENT_MODEL |
157 std::cerr << "AlignmentModel::fromReference(" << frame << ")" << std::endl; | 157 DEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl; |
158 #endif | 158 #endif |
159 if (!m_reversePath) { | 159 if (!m_reversePath) { |
160 if (!m_rawPath) return frame; | 160 if (!m_rawPath) return frame; |
161 constructReversePath(); | 161 constructReversePath(); |
162 } | 162 } |
192 | 192 |
193 int completion = 0; | 193 int completion = 0; |
194 m_rawPath->isReady(&completion); | 194 m_rawPath->isReady(&completion); |
195 | 195 |
196 #ifdef DEBUG_ALIGNMENT_MODEL | 196 #ifdef DEBUG_ALIGNMENT_MODEL |
197 std::cerr << "AlignmentModel::pathCompletionChanged: completion = " | 197 DEBUG << "AlignmentModel::pathCompletionChanged: completion = " |
198 << completion << std::endl; | 198 << completion << endl; |
199 #endif | 199 #endif |
200 | 200 |
201 m_pathComplete = (completion == 100); | 201 m_pathComplete = (completion == 100); |
202 | 202 |
203 if (m_pathComplete) { | 203 if (m_pathComplete) { |
240 long rframe = lrintf(value * m_aligned->getSampleRate()); | 240 long rframe = lrintf(value * m_aligned->getSampleRate()); |
241 m_path->addPoint(PathPoint(frame, rframe)); | 241 m_path->addPoint(PathPoint(frame, rframe)); |
242 } | 242 } |
243 | 243 |
244 #ifdef DEBUG_ALIGNMENT_MODEL | 244 #ifdef DEBUG_ALIGNMENT_MODEL |
245 std::cerr << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; | 245 DEBUG << "AlignmentModel::constructPath: " << m_path->getPointCount() << " points, at least " << (2 * m_path->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl; |
246 #endif | 246 #endif |
247 } | 247 } |
248 | 248 |
249 void | 249 void |
250 AlignmentModel::constructReversePath() const | 250 AlignmentModel::constructReversePath() const |
271 long rframe = i->mapframe; | 271 long rframe = i->mapframe; |
272 m_reversePath->addPoint(PathPoint(rframe, frame)); | 272 m_reversePath->addPoint(PathPoint(rframe, frame)); |
273 } | 273 } |
274 | 274 |
275 #ifdef DEBUG_ALIGNMENT_MODEL | 275 #ifdef DEBUG_ALIGNMENT_MODEL |
276 std::cerr << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << std::endl; | 276 DEBUG << "AlignmentModel::constructReversePath: " << m_reversePath->getPointCount() << " points, at least " << (2 * m_reversePath->getPointCount() * (3 * sizeof(void *) + sizeof(int) + sizeof(PathPoint))) << " bytes" << endl; |
277 #endif | 277 #endif |
278 } | 278 } |
279 | 279 |
280 size_t | 280 size_t |
281 AlignmentModel::align(PathModel *path, size_t frame) const | 281 AlignmentModel::align(PathModel *path, size_t frame) const |
289 | 289 |
290 const PathModel::PointList &points = path->getPoints(); | 290 const PathModel::PointList &points = path->getPoints(); |
291 | 291 |
292 if (points.empty()) { | 292 if (points.empty()) { |
293 #ifdef DEBUG_ALIGNMENT_MODEL | 293 #ifdef DEBUG_ALIGNMENT_MODEL |
294 std::cerr << "AlignmentModel::align: No points" << std::endl; | 294 DEBUG << "AlignmentModel::align: No points" << endl; |
295 #endif | 295 #endif |
296 return frame; | 296 return frame; |
297 } | 297 } |
298 | 298 |
299 #ifdef DEBUG_ALIGNMENT_MODEL | 299 #ifdef DEBUG_ALIGNMENT_MODEL |
300 std::cerr << "AlignmentModel::align: frame " << frame << " requested" << std::endl; | 300 DEBUG << "AlignmentModel::align: frame " << frame << " requested" << endl; |
301 #endif | 301 #endif |
302 | 302 |
303 PathModel::Point point(frame); | 303 PathModel::Point point(frame); |
304 PathModel::PointList::const_iterator i = points.lower_bound(point); | 304 PathModel::PointList::const_iterator i = points.lower_bound(point); |
305 if (i == points.end()) { | 305 if (i == points.end()) { |
338 float(followingFrame - foundFrame); | 338 float(followingFrame - foundFrame); |
339 resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp); | 339 resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp); |
340 } | 340 } |
341 | 341 |
342 #ifdef DEBUG_ALIGNMENT_MODEL | 342 #ifdef DEBUG_ALIGNMENT_MODEL |
343 std::cerr << "AlignmentModel::align: resultFrame = " << resultFrame << std::endl; | 343 DEBUG << "AlignmentModel::align: resultFrame = " << resultFrame << endl; |
344 #endif | 344 #endif |
345 | 345 |
346 return resultFrame; | 346 return resultFrame; |
347 } | 347 } |
348 | 348 |
351 { | 351 { |
352 if (m_path) m_path->aboutToDelete(); | 352 if (m_path) m_path->aboutToDelete(); |
353 delete m_path; | 353 delete m_path; |
354 m_path = path; | 354 m_path = path; |
355 #ifdef DEBUG_ALIGNMENT_MODEL | 355 #ifdef DEBUG_ALIGNMENT_MODEL |
356 std::cerr << "AlignmentModel::setPath: path = " << m_path << std::endl; | 356 DEBUG << "AlignmentModel::setPath: path = " << m_path << endl; |
357 #endif | 357 #endif |
358 constructReversePath(); | 358 constructReversePath(); |
359 #ifdef DEBUG_ALIGNMENT_MODEL | 359 #ifdef DEBUG_ALIGNMENT_MODEL |
360 std::cerr << "AlignmentModel::setPath: after construction path = " | 360 DEBUG << "AlignmentModel::setPath: after construction path = " |
361 << m_path << ", rpath = " << m_reversePath << std::endl; | 361 << m_path << ", rpath = " << m_reversePath << endl; |
362 #endif | 362 #endif |
363 } | 363 } |
364 | 364 |
365 void | 365 void |
366 AlignmentModel::toXml(QTextStream &stream, | 366 AlignmentModel::toXml(QTextStream &stream, |
367 QString indent, | 367 QString indent, |
368 QString extraAttributes) const | 368 QString extraAttributes) const |
369 { | 369 { |
370 if (!m_path) { | 370 if (!m_path) { |
371 std::cerr << "AlignmentModel::toXml: no path" << std::endl; | 371 DEBUG << "AlignmentModel::toXml: no path" << endl; |
372 return; | 372 return; |
373 } | 373 } |
374 | 374 |
375 m_path->toXml(stream, indent, ""); | 375 m_path->toXml(stream, indent, ""); |
376 | 376 |