1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
25 #include "effectslist.h"
30 #include <QTreeWidgetItem>
31 #include <QtCore/QString>
33 const int MAXCLIPDURATION = 15000;
36 enum MONITORID { noMonitor, clipMonitor, projectMonitor, recordMonitor, stopmotionMonitor, dvdMonitor };
37 /*const QString clipMonitor("clipMonitor");
38 const QString recordMonitor("recordMonitor");
39 const QString projectMonitor("projectMonitor");
40 const QString stopmotionMonitor("stopmotionMonitor");*/
43 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};
44 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
46 enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
48 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET , GROUPWIDGET};
50 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
53 /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
55 COMPOSITE_TRANSITION = 1,
57 LUMAFILE_TRANSITION = 3,
63 OperationCompletedMessage,
69 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
71 enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5};
79 EffectsList effectsList;
83 typedef QMap<QString, QString> stringMap;
84 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
88 /** startPos is the position where the clip starts on the track */
90 /** endPos is the duration where the clip ends on the track */
92 /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
94 /** cropDuration is the duration of the clip */
97 ItemInfo() : track(0) {};
100 struct TransitionInfo {
101 /** startPos is the position where the clip starts on the track */
103 /** endPos is the duration where the clip ends on the track */
105 /** the track on which the transition is (b_track)*/
107 /** the track on which the transition is applied (a_track)*/
109 /** Does the user request for a special a_track */
113 class MltVideoProfile {
122 int sample_aspect_num;
123 int sample_aspect_den;
124 int display_aspect_num;
125 int display_aspect_den;
133 sample_aspect_num(0),
134 sample_aspect_den(0),
135 display_aspect_num(0),
136 display_aspect_den(0),
138 bool operator==(const MltVideoProfile& point) const
140 if (!description.isEmpty() && point.description == description) return true;
141 return point.frame_rate_num == frame_rate_num &&
142 point.frame_rate_den == frame_rate_den &&
143 point.width == width &&
144 point.height == height &&
145 point.progressive == progressive &&
146 point.sample_aspect_num == sample_aspect_num &&
147 point.sample_aspect_den == sample_aspect_den &&
148 point.display_aspect_den == display_aspect_den &&
149 point.colorspace == colorspace;
151 bool operator!=(const MltVideoProfile &other) const {
152 return !(*this == other);
158 * @brief A class holding some meta info for effects widgets, like state (collapsed or not, ...)
159 * @author Jean-Baptiste Mardelle
165 EffectInfo() {isCollapsed = false; groupIndex = -1; groupIsCollapsed = false;}
167 bool groupIsCollapsed;
170 QString toString() const {
172 // effect collapsed state: 0 = effect not collapsed, 1 = effect collapsed,
173 // 2 = group collapsed - effect not, 3 = group and effect collapsed
174 int collapsedState = (int) isCollapsed;
175 if (groupIsCollapsed) collapsedState += 2;
176 data << QString::number(collapsedState) << QString::number(groupIndex) << groupName;
177 return data.join("/");
179 void fromString(QString value) {
180 if (value.isEmpty()) return;
181 QStringList data = value.split("/");
182 isCollapsed = data.at(0).toInt() == 1 || data.at(0).toInt() == 3;
183 groupIsCollapsed = data.at(0).toInt() >= 2;
184 if (data.count() > 1) groupIndex = data.at(1).toInt();
185 if (data.count() > 2) groupName = data.at(2);
189 class EffectParameter
192 EffectParameter(const QString &name, const QString &value): m_name(name), m_value(value) {}
193 QString name() const {
196 QString value() const {
199 void setValue(const QString &value) {
208 /** Use our own list for effect parameters so that they are not sorted in any ways, because
209 some effects like sox need a precise order
211 class EffectsParameterList: public QList < EffectParameter >
214 EffectsParameterList(): QList < EffectParameter >() {}
215 bool hasParam(const QString &name) const {
216 for (int i = 0; i < size(); i++)
217 if (at(i).name() == name) return true;
220 void setParamValue(const QString &name, const QString &value) {
222 for (int i = 0; i < size(); i++)
223 if (at(i).name() == name) {
225 replace(i, EffectParameter(name, value));
228 if (!found) addParam(name, value);
231 QString paramValue(const QString &name, QString defaultValue = QString()) const {
232 for (int i = 0; i < size(); i++) {
233 if (at(i).name() == name) return at(i).value();
237 void addParam(const QString &name, const QString &value) {
238 if (name.isEmpty()) return;
239 append(EffectParameter(name, value));
241 void removeParam(const QString &name) {
242 for (int i = 0; i < size(); i++)
243 if (at(i).name() == name) {
253 CommentedTime(): t(GenTime(0)) {}
254 CommentedTime(const GenTime &time, QString comment)
255 : t(time), c(comment) { }
257 QString comment() const {
258 return (c.isEmpty() ? i18n("Marker") : c);
260 GenTime time() const {
263 void setComment(QString comm) {
267 /* Implementation of > operator; Works identically as with basic types. */
268 bool operator>(CommentedTime op) const {
269 return t > op.time();
271 /* Implementation of < operator; Works identically as with basic types. */
272 bool operator<(CommentedTime op) const {
273 return t < op.time();
275 /* Implementation of >= operator; Works identically as with basic types. */
276 bool operator>=(CommentedTime op) const {
277 return t >= op.time();
279 /* Implementation of <= operator; Works identically as with basic types. */
280 bool operator<=(CommentedTime op) const {
281 return t <= op.time();
283 /* Implementation of == operator; Works identically as with basic types. */
284 bool operator==(CommentedTime op) const {
285 return t == op.time();
287 /* Implementation of != operator; Works identically as with basic types. */
288 bool operator!=(CommentedTime op) const {
289 return t != op.time();
299 QDebug operator << (QDebug qd, const ItemInfo &info);