- return (int)((duration.section(':', 0, 0).toInt()*3600.0 + duration.section(':', 1, 1).toInt()*60.0 + duration.section(':', 2, 2).toInt()) * fps + duration.section(':', 3, 3).toInt());
+ int hours, minutes, seconds, frames;
+ int offset = 0;
+ if (duration.at(0) == '-') {
+ offset = 1;
+ hours = duration.mid(1, 2).toInt();
+ } else {
+ hours = duration.left(2).toInt();
+ }
+ minutes = duration.mid(3 + offset, 2).toInt();
+ seconds = duration.mid(6 + offset, 2).toInt();
+ frames = duration.right(2).toInt();
+ if (m_dropFrameTimecode) {
+ //CONVERT DROP FRAME TIMECODE TO A FRAME NUMBER
+ //Code by David Heidelberger, adapted from Andrew Duncan
+ //Given ints called hours, minutes, seconds, frames, and a double called framerate
+
+ int totalMinutes = (60 * hours) + minutes; //Total number of minutes
+ int frameNumber = ((m_displayedFramesPerSecond * 3600 * hours) + (m_displayedFramesPerSecond * 60 * minutes) + (m_displayedFramesPerSecond * seconds) + frames) - (m_dropFrames * (totalMinutes - floor(totalMinutes / 10)));
+ return frameNumber;
+ }
+ return (int)((hours * 3600.0 + minutes * 60.0 + seconds) * m_realFps + frames);
+}
+
+QString Timecode::getDisplayTimecode(const GenTime & time, bool frameDisplay) const
+{
+ if (frameDisplay) return QString::number((int) time.frames(m_realFps));
+ return getTimecode(time);