]> git.sesse.net Git - kdenlive/blobdiff - src/timecode.cpp
code cleanup
[kdenlive] / src / timecode.cpp
index 12f5bff3bf0c00ffbaf3b8dcfa31253f3d16460c..1b25df21f13adaf5a5de50bd488ab890d36c4cab 100644 (file)
@@ -37,6 +37,12 @@ double Timecode::fps() const
 }
 
 
+int Timecode::getDisplayFrameCount(const QString duration, bool frameDisplay) const
+{
+    if (frameDisplay) return duration.toInt();
+    return getFrameCount(duration);
+}
+
 int Timecode::getFrameCount(const QString duration) const
 {
     if (m_dropFrame) {
@@ -69,6 +75,12 @@ int Timecode::getFrameCount(const QString duration) const
     return (int)((duration.section(':', 0, 0).toInt()*3600.0 + duration.section(':', 1, 1).toInt()*60.0 + duration.section(':', 2, 2).toInt()) * m_realFps + duration.section(':', 3, 3).toInt());
 }
 
+QString Timecode::getDisplayTimecode(const GenTime & time, bool frameDisplay) const
+{
+    if (frameDisplay) return QString::number((int) time.frames(m_realFps));
+    return getTimecode(time);
+}
+
 QString Timecode::getTimecode(const GenTime & time) const
 {
     switch (m_format) {
@@ -92,6 +104,12 @@ QString Timecode::getTimecode(const GenTime & time) const
     }
 }
 
+const QString Timecode::getDisplayTimecodeFromFrames(int frames, bool frameDisplay) const
+{
+    if (frameDisplay) return QString::number(frames);
+    return getTimecodeHH_MM_SS_FF(frames);
+}
+
 const QString Timecode::getTimecodeFromFrames(int frames) const
 {
     return getTimecodeHH_MM_SS_FF(frames);
@@ -102,7 +120,7 @@ const QString Timecode::getTimecodeFromFrames(int frames) const
 QString Timecode::getStringTimecode(int frames, const double &fps)
 {
     // Returns the timecode in an hh:mm:ss format
-    int seconds = (int) (frames / fps);
+    int seconds = (int)(frames / fps);
     int minutes = seconds / 60;
     seconds = seconds % 60;
     int hours = minutes / 60;
@@ -122,8 +140,8 @@ QString Timecode::getEasyTimecode(const GenTime & time, const double &fps)
 {
     // Returns the timecode in an easily read display, like 3 min. 5 sec.
     int frames = (int) time.frames(fps);
-    int seconds = (int) (frames / fps);
-    frames = frames - ((int) (fps * seconds));
+    int seconds = (int)(frames / fps);
+    frames = frames - ((int)(fps * seconds));
 
     int minutes = seconds / 60;
     seconds = seconds % 60;