]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Fix up a busted preprocessor check [PATCH by Ray Lehtiniemi]
[kdenlive] / src / docclipbase.cpp
index ade305e491d3a808c189a716d6b3d4681bc3f53e..0984f9232d32ecb4c2881f5a52c67e0f25b3ba01 100644 (file)
@@ -1,29 +1,38 @@
-/**************************1*************************************************
-                          DocClipBase.cpp  -  description
-                             -------------------
-    begin                : Fri Apr 12 2002
-    copyright            : (C) 2002 by Jason Wood
-    email                : jasonwood@blueyonder.co.uk
- ***************************************************************************/
-
 /***************************************************************************
+ *                         DocClipBase.cpp  -  description                *
+ *                           -------------------                          *
+ *   begin                : Fri Apr 12 2002                               *
+ *   Copyright (C) 2002 by Jason Wood (jasonwood@blueyonder.co.uk)         *
+ *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#include <QCryptographicHash>
 
-#include <KDebug>
 
-#include "kdenlivesettings.h"
+
 #include "docclipbase.h"
+#include "kdenlivesettings.h"
 #include "kthumb.h"
 #include "clipmanager.h"
 
+#include <KDebug>
+
+#include <QCryptographicHash>
+
 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id):
         m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_properties(QMap <QString, QString> ()), audioFrameChache(QMap<int, QMap<int, QByteArray> > ()), m_baseTrackProducers(QList <Mlt::Producer *>()), m_snapMarkers(QList < CommentedTime > ())  {
     int type = xml.attribute("type").toInt();
@@ -36,13 +45,15 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
 
     KUrl url = KUrl(xml.attribute("resource"));
     if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path());
-    int out = xml.attribute("out").toInt();
-    if (out != 0) {
-        setDuration(GenTime(out, KdenliveSettings::project_fps()));
+
+    if (xml.hasAttribute("duration")) {
+        setDuration(GenTime(xml.attribute("duration").toInt(), KdenliveSettings::project_fps()));
     } else {
-        out = xml.attribute("duration").toInt();
-        if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
+        int out = xml.attribute("out").toInt();
+        int in = xml.attribute("in").toInt();
+        setDuration(GenTime(out - in, KdenliveSettings::project_fps()));
     }
+
     if (!m_properties.contains("name")) m_properties.insert("name", url.fileName());
 
     //if (!url.isEmpty() && QFile::exists(url.path()))
@@ -118,7 +129,7 @@ bool DocClipBase::audioThumbCreated() const {
     return m_audioThumbCreated;
 }
 
-const QString DocClipBase::name() const {
+const QString DocClipBase::name() const {
 
     return m_properties.value("name");
 }
@@ -178,7 +189,7 @@ const GenTime &DocClipBase::duration() const {
     return m_duration;
 }
 
-const GenTime &DocClipBase::maxDuration() const {
+const GenTime DocClipBase::maxDuration() const {
     if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW &&  m_properties.value("loop") == "1")) {
         const GenTime dur(15000, KdenliveSettings::project_fps());
         return dur;
@@ -207,7 +218,7 @@ QDomElement DocClipBase::toXML() const {
 }
 
 DocClipBase *DocClipBase::
-createClip(KdenliveDoc *doc, const QDomElement & element) {
+createClip(KdenliveDoc */*doc*/, const QDomElement & element) {
     DocClipBase *clip = 0;
     QString description;
     QDomNode node = element;
@@ -414,7 +425,6 @@ Mlt::Producer *DocClipBase::producer(int track) {
     }*/
     if (track == -1 || (m_clipType != AUDIO && m_clipType != AV)) {
         if (m_baseTrackProducers.count() == 0) return NULL;
-        int i;
         for (int i = 0; i < m_baseTrackProducers.count(); i++) {
             if (m_baseTrackProducers.at(i) != NULL)
                 return m_baseTrackProducers.at(i);