]> git.sesse.net Git - kdenlive/blob - src/definitions.h
Fix broken handling of clips with speed effect
[kdenlive] / src / definitions.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef DEFINITIONS_H
22 #define DEFINITIONS_H
23
24 #include "gentime.h"
25
26 #include <KLocale>
27
28 const int FRAME_SIZE = 90;
29 const int MAXCLIPDURATION = 15000;
30
31 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
32 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9, FOLDER = 10};
33 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};
34
35 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
36
37 enum TRANSITIONTYPE {
38     /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
39     LUMA_TRANSITION = 0,
40     COMPOSITE_TRANSITION = 1,
41     PIP_TRANSITION = 2,
42     LUMAFILE_TRANSITION = 3,
43     MIX_TRANSITION = 200
44 };
45
46 enum MessageType {
47     DefaultMessage,
48     OperationCompletedMessage,
49     InformationMessage,
50     ErrorMessage,
51     MltError
52 };
53
54 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
55
56 struct TrackInfo {
57     TRACKTYPE type;
58     QString trackName;
59     bool isMute;
60     bool isBlind;
61     bool isLocked;
62 };
63
64 struct ItemInfo {
65     /** startPos is the position where the clip starts on the track */
66     GenTime startPos;
67     /** endPos is the duration where the clip ends on the track */
68     GenTime endPos;
69     /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
70     GenTime cropStart;
71     /** cropDuration is the duration of the clip */
72     GenTime cropDuration;
73     int track;
74 };
75
76 struct MltVideoProfile {
77     QString path;
78     QString description;
79     int frame_rate_num;
80     int frame_rate_den;
81     int width;
82     int height;
83     bool progressive;
84     int sample_aspect_num;
85     int sample_aspect_den;
86     int display_aspect_num;
87     int display_aspect_den;
88 };
89
90
91 class EffectParameter
92 {
93 public:
94     EffectParameter(const QString name, const QString value): m_name(name), m_value(value) {}
95     QString name()   const          {
96         return m_name;
97     }
98     QString value() const          {
99         return m_value;
100     }
101     void setValue(const QString value) {
102         m_value = value;
103     }
104
105 private:
106     QString m_name;
107     QString m_value;
108 };
109
110 /** Use our own list for effect parameters so that they are not sorted in any ways, because
111     some effects like sox need a precise order
112 */
113 class EffectsParameterList: public QList < EffectParameter >
114 {
115 public:
116     EffectsParameterList(): QList < EffectParameter >() {}
117     bool hasParam(const QString name) const {
118         for (int i = 0; i < size(); i++)
119             if (at(i).name() == name) return true;
120         return false;
121     }
122     QString paramValue(const QString name, QString defaultValue = QString()) const {
123         for (int i = 0; i < size(); i++) {
124             if (at(i).name() == name) return at(i).value();
125         }
126         return defaultValue;
127     }
128     void addParam(const QString &name, const QString &value) {
129         if (name.isEmpty()) return;
130         append(EffectParameter(name, value));
131     }
132     void removeParam(const QString name) {
133         for (int i = 0; i < size(); i++)
134             if (at(i).name() == name) {
135                 removeAt(i);
136                 break;
137             }
138     }
139 };
140
141 class CommentedTime
142 {
143 public:
144     CommentedTime(): t(GenTime(0)) {}
145     CommentedTime(const GenTime time, QString comment)
146             : t(time), c(comment) { }
147
148     QString comment()   const          {
149         return (c.isEmpty() ? i18n("Marker") : c);
150     }
151     GenTime time() const          {
152         return t;
153     }
154     void    setComment(QString comm) {
155         c = comm;
156     }
157
158     /* Implementation of > operator; Works identically as with basic types. */
159     bool operator>(CommentedTime op) const {
160         return t > op.time();
161     }
162     /* Implementation of < operator; Works identically as with basic types. */
163     bool operator<(CommentedTime op) const {
164         return t < op.time();
165     }
166     /* Implementation of >= operator; Works identically as with basic types. */
167     bool operator>=(CommentedTime op) const {
168         return t >= op.time();
169     }
170     /* Implementation of <= operator; Works identically as with basic types. */
171     bool operator<=(CommentedTime op) const {
172         return t <= op.time();
173     }
174     /* Implementation of == operator; Works identically as with basic types. */
175     bool operator==(CommentedTime op) const {
176         return t == op.time();
177     }
178     /* Implementation of != operator; Works identically as with basic types. */
179     bool operator!=(CommentedTime op) const {
180         return t != op.time();
181     }
182
183 private:
184     GenTime t;
185     QString c;
186
187
188 };
189
190
191 #endif