]> git.sesse.net Git - kdenlive/commitdiff
Fix rendering when using proxies with speed effect:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 25 Apr 2011 17:08:52 +0000 (17:08 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 25 Apr 2011 17:08:52 +0000 (17:08 +0000)
http://kdenlive.org/mantis/view.php?id=2103

svn path=/trunk/kdenlive/; revision=5555

src/effectslist.cpp
src/effectslist.h
src/mainwindow.cpp

index d048e6d9aac7c74e98202f6637512303e1cc5563..91b7693647aed91b7e7c9942200f8d87c543bf3b 100644 (file)
@@ -241,6 +241,19 @@ QString EffectsList::property(QDomElement effect, const QString &name)
     return QString();
 }
 
+// static
+void EffectsList::removeProperty(QDomElement effect, const QString &name)
+{
+    QDomNodeList params = effect.elementsByTagName("property");
+    for (int i = 0; i < params.count(); i++) {
+        QDomElement e = params.item(i).toElement();
+        if (e.attribute("name") == name) {
+            effect.removeChild(params.item(i));
+            break;
+        }
+    }
+}
+
 void EffectsList::append(QDomElement e)
 {
     m_baseElement.appendChild(importNode(e, true));
index 17d7f9a532c6c56868a8ecc6380a9c4e32cbb3c4..b30c2ee2a9b04b09d55fe5da76b607218e05bf88 100644 (file)
@@ -72,8 +72,12 @@ public:
     static bool hasGeometryKeyFrames(QDomElement effect);
     static void setParameter(QDomElement effect, const QString &name, const QString &value);
     static QString parameter(QDomElement effect, const QString &name);
+    /** @brief Change the value of a 'property' element from the effect node. */
     static void setProperty(QDomElement effect, const QString &name, const QString &value);
+    /** @brief Get the value of a 'property' element from the effect node. */
     static QString property(QDomElement effect, const QString &name);
+    /** @brief Delete a 'property' element from the effect node. */
+    static void removeProperty(QDomElement effect, const QString &name);
     void clearList();
 
 private:
index 61eab3d0022de37a77b9d15705830bc36b7edd61..4013073ffabe9b3b7f3d7a447ca936b8536f13a0 100644 (file)
@@ -3821,18 +3821,48 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
 
         // replace proxy clips with originals
         QMap <QString, QString> proxies = m_projectList->getProxies();
-        QMapIterator<QString, QString> i(proxies);
+
+
+        QDomNodeList producers = doc.elementsByTagName("producer");
+        QString producerResource;
+        QString suffix;
+        for (uint n = 0; n < producers.length(); n++) {
+            QDomElement e = producers.item(n).toElement();
+            producerResource = EffectsList::property(e, "resource");
+            if (producerResource.contains('?')) {
+                suffix = "?" + producerResource.section('?', 1);
+                producerResource = producerResource.section('?', 0, 0);
+            }
+            else suffix.clear();
+            if (!producerResource.isEmpty()) {
+                if (proxies.contains(producerResource)) {
+                    EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
+                    // We need to delete the "aspect_ratio" property because proxy clips
+                    // sometimes have different ratio than original clips
+                    EffectsList::removeProperty(e, "aspect_ratio");
+                }
+                else if (!root.isEmpty() && producerResource.startsWith(root) && proxies.contains(producerResource.remove(0, root.count() + 1))) {
+                    EffectsList::setProperty(e, "resource", proxies.value(producerResource.remove(0, root.count() + 1)) + suffix);
+                    // We need to delete the "aspect_ratio" property because proxy clips
+                    // sometimes have different ratio than original clips
+                    EffectsList::removeProperty(e, "aspect_ratio");
+                }
+            }
+        }
+        
+        /*QMapIterator<QString, QString> i(proxies);
         while (i.hasNext()) {
             i.next();
             // Replace all keys with their values (proxy path with original path)
             QString key = i.key();
             playlistContent.replace(key, i.value());
             if (!root.isEmpty() && key.startsWith(root)) {
-                // in case ther resource path in MLT playlist is relative
+                // in case the resource path in MLT playlist is relative
                 key.remove(0, root.count() + 1);
                 playlistContent.replace(key, i.value());
             }
-        }
+        }*/
+        playlistContent = doc.toString();
     }
     
     // Do save scenelist