]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Fix broken producer incorrectly handled when using proxy, corrupting project:
[kdenlive] / src / clipitem.cpp
index 4bf64cb155bd449d2aba629ac8a765bc050f52e6..62f71b42726ec2780ad02dcaff7883abc8388a17 100644 (file)
@@ -57,7 +57,8 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
         //m_hover(false),
         m_speed(speed),
         m_strobe(strobe),
-        m_framePixelWidth(0)
+        m_framePixelWidth(0),
+        m_limitedKeyFrames(false)
 {
     setZValue(2);
     setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
@@ -240,7 +241,7 @@ void ClipItem::initEffect(QDomElement effect, int diff)
             continue;
 
         // Check if this effect has a variable parameter
-        if (e.attribute("default").startsWith('%')) {
+        if (e.attribute("default").contains('%')) {
             double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
             e.setAttribute("default", evaluatedValue);
             if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
@@ -433,6 +434,7 @@ void ClipItem::setSelectedEffect(const int ix)
             QDomElement e = params.item(i).toElement();
             if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
                 m_keyframes.clear();
+                m_limitedKeyFrames = e.attribute("type") == "keyframe";
                 m_visibleParam = i;
                 double max = e.attribute("max").toDouble();
                 double min = e.attribute("min").toDouble();
@@ -940,7 +942,7 @@ void ClipItem::paint(QPainter *painter,
 
     painter->setPen(QPen(Qt::lightGray));
     // draw effect or transition keyframes
-    if (mapped.width() > 20) drawKeyFrames(painter, exposed);
+    if (mapped.width() > 20) drawKeyFrames(painter, m_limitedKeyFrames);
 
     //painter->setMatrixEnabled(true);
 
@@ -1459,7 +1461,7 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
                 }
             } else {
                 double fact;
-                if (e.attribute("factor").startsWith('%')) {
+                if (e.attribute("factor").contains('%')) {
                     fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
                 } else fact = e.attribute("factor", "1").toDouble();
                 parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
@@ -1716,6 +1718,7 @@ void ClipItem::updateKeyframes(QDomElement effect)
         setSelectedEffect(m_selectedEffect);
         return;
     }
+    m_limitedKeyFrames = e.attribute("type") == "keyframe";
     const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
     foreach(const QString &str, keyframes) {
         int pos = str.section(':', 0, 0).toInt();
@@ -1747,26 +1750,6 @@ void ClipItem::updateKeyframes(QDomElement effect)
     update();
 }*/
 
-QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
-{
-    QList <int> effectPositions;
-    for (int i = 0; i < m_effectList.count(); i++) {
-        QDomElement effect = m_effectList.at(i);
-        QDomNodeList params = effect.elementsByTagName("parameter");
-        for (int j = 0; j < params.count(); j++) {
-            QDomElement e = params.item(j).toElement();
-            if (e.isNull())
-                continue;
-            if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
-                effectPositions << i;
-//                 updateGeometryKeyframes(effect, j, width, height, cut);
-            }
-        }
-    }
-
-    return effectPositions;
-}
-
 Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
 {
     if (isAudioOnly())
@@ -1933,10 +1916,23 @@ bool ClipItem::updateNormalKeyframes(QDomElement parameter)
 
 void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
 {
-    QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
-
-    Mlt::Geometry geometry(param.attribute("value").toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
 
+    QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
+    int offset = oldInfo.cropStart.frames(m_fps);
+    QString data = param.attribute("value");
+    if (offset > 0) {
+        QStringList kfrs = data.split(';');
+        data.clear();
+        foreach (QString keyframe, kfrs) {
+            if (keyframe.contains('=')) {
+                int pos = keyframe.section('=', 0, 0).toInt();
+                pos += offset;
+                data.append(QString::number(pos) + "=" + keyframe.section('=', 1) + ";");
+            }
+            else data.append(keyframe + ";");
+        }
+    }
+    Mlt::Geometry geometry(data.toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
     param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
 }