]> git.sesse.net Git - kdenlive/blob - src/timecode.h
Fix label
[kdenlive] / src / timecode.h
1 /***************************************************************************
2                         timecode  -  description
3                            -------------------
4   begin                : Wed Dec 17 2003
5   copyright            : (C) 2003 by Jason Wood
6   email                : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 #ifndef TIMECODE_H
18 #define TIMECODE_H
19
20 #include <QString>
21
22 #include "gentime.h"
23
24 /**
25 Handles the conversion of a GenTime into a nicely formatted string, taking into account things such as drop frame if necessary. Handles multiple formats, such as HH:MM:SS:FF, HH:MM:SS:F, All Frames, All Seconds, etc.
26
27 @author Jason Wood
28 */
29 class Timecode
30 {
31 public:
32     enum Formats { HH_MM_SS_FF, HH_MM_SS_HH, Frames, Seconds };
33
34     explicit Timecode(Formats format = HH_MM_SS_FF, double framesPerSecond = 25);
35
36     /**
37      * Set the current timecode format; this is the output format for this timecode.
38      */
39     void setFormat(double framesPerSecond, Formats format = HH_MM_SS_FF);
40
41     Formats format() const {
42         return m_format;
43     }
44
45     ~Timecode();
46
47     /** Returns the timecode for a given time */
48     QString getDisplayTimecode(const GenTime & time, bool frameDisplay) const;
49     QString getTimecode(const GenTime & time) const;
50     int getDisplayFrameCount(const QString &duration, bool frameDisplay) const;
51     int getFrameCount(const QString &duration) const;
52     static QString getEasyTimecode(const GenTime & time, const double &fps);
53     static QString getStringTimecode(int frames, const double &fps, bool showFrames = false);
54     const QString getDisplayTimecodeFromFrames(int frames, bool frameDisplay) const;
55     const QString getTimecodeFromFrames(int frames) const;
56     double fps() const;
57     bool df() const;
58     const QString mask(const GenTime &t = GenTime()) const;
59     QString reformatSeparators(QString duration) const;
60
61 private:
62     Formats m_format;
63     bool m_dropFrameTimecode;
64     int m_displayedFramesPerSecond;
65     double m_realFps;
66     double m_dropFrames;
67     int m_framesPer10Minutes;
68
69     const QString getTimecodeHH_MM_SS_FF(const GenTime & time) const;
70     const QString getTimecodeHH_MM_SS_FF(int frames) const;
71
72     const QString getTimecodeHH_MM_SS_HH(const GenTime & time) const;
73     const QString getTimecodeFrames(const GenTime & time) const;
74     const QString getTimecodeSeconds(const GenTime & time) const;
75     const QString getTimecodeDropFrame(const GenTime & time) const;
76     const QString getTimecodeDropFrame(int framenumber) const;
77 };
78
79 #endif