]> git.sesse.net Git - kdenlive/blob - src/timecode.h
Undo files that should not have been part of last commit
[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.h>
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, int framesPerSecond =
35                           25, bool dropFrame = false);
36
37     /** Set the current timecode format; this is the output format for this timecode. */
38     void setFormat(int framesPerSecond, bool dropFrame = false, Formats format = HH_MM_SS_FF) {
39         m_displayedFramesPerSecond = framesPerSecond;
40         m_dropFrame = dropFrame;
41         m_format = format;
42     }
43
44     Formats format() const {
45         return m_format;
46     }
47
48     ~Timecode();
49
50     /** Returns the timecode for a given time */
51     QString getTimecode(const GenTime & time, double fps) const;
52     int getFrameCount(const QString duration, double fps) const;
53     static QString getEasyTimecode(const GenTime & time, const double &fps);
54     static QString getStringTimecode(int frames, const double &fps);
55     QString getTimecodeFromFrames(int frames) const;
56     int fps() const;
57
58 private:
59     Formats m_format;
60     bool m_dropFrame;
61     int m_displayedFramesPerSecond;
62
63     QString getTimecodeHH_MM_SS_FF(const GenTime & time, double fps) const;
64     QString getTimecodeHH_MM_SS_FF(int frames) const;
65     QString getTimecodeHH_MM_SS_HH(const GenTime & time) const;
66     QString getTimecodeFrames(const GenTime & time, double fps) const;
67     QString getTimecodeSeconds(const GenTime & time) const;
68     QString getTimecodeDropFrame(const GenTime & time, double fps) const;
69 };
70
71 #endif