]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Render dialog: control 2 pass option with a checkbox.
[kdenlive] / src / clipitem.cpp
index 5e4cf6f6656cbf19707ff17cb229e1547009c983..d7d9819c0458cfcf15604249ca9369dbbad2132f 100644 (file)
@@ -248,6 +248,12 @@ void ClipItem::initEffect(QDomElement effect, int diff)
             }
         }
 
+        if (effect.attribute("id") == "crop") {
+            // default use_profile to 1 for clips with proxies to avoid problems when rendering
+            if (e.attribute("name") == "use_profile" && !(m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-"))
+                e.setAttribute("value", "1");
+        }
+
         if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) {
             // Effect has a keyframe type parameter, we need to set the values
             e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default"));
@@ -1731,7 +1737,7 @@ QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
                 continue;
             if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
                 effectPositions << i;
-                updateGeometryKeyframes(effect, j, width, height, cut);
+//                 updateGeometryKeyframes(effect, j, width, height, cut);
             }
         }
     }
@@ -1749,7 +1755,7 @@ Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
         return m_clip->producer(trackSpecific ? track : -1);
 }
 
-QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, int previous, int current, bool fromStart)
+QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
 {
     QMap<int, QDomElement> effects;
     for (int i = 0; i < m_effectList.count(); i++) {
@@ -1794,9 +1800,9 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
                     setFadeOut(out - in);
             }
             continue;
-        } else if (fromStart && effect.attribute("id") == "freeze") {
+        } else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
             effects[i] = effect.cloneNode().toElement();
-            int diff = previous - current;
+            int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
             int frame = EffectsList::parameter(effect, "frame").toInt();
             EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
             continue;
@@ -1810,7 +1816,7 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
             if (type == "geometry" && !param.hasAttribute("fixed")) {
                 if (!effects.contains(i))
                     effects[i] = effect.cloneNode().toElement();
-                updateGeometryKeyframes(effect, j, width, height, 0);
+                updateGeometryKeyframes(effect, j, width, height, oldInfo);
             } else if (type == "simplekeyframe" || type == "keyframe") {
                 if (!effects.contains(i))
                     effects[i] = effect.cloneNode().toElement();
@@ -1903,64 +1909,13 @@ bool ClipItem::updateNormalKeyframes(QDomElement parameter)
     return false;
 }
 
-void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, int cut)
+void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
 {
-    // TODO: properly update when clip resized from start
-
     QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
 
-    int in = cropStart().frames(fps());
-    int out = in + cropDuration().frames(fps());
-    int dur = out - in - 1;
-
-    effect.setAttribute("in", in);
-    effect.setAttribute("out", out);
-
-    Mlt::Geometry geometry(param.attribute("value").toUtf8().data(), dur, width, height);
-    Mlt::GeometryItem item;
-    bool endFrameAdded = false;
-    if (cut == 0) {
-        while (!geometry.next_key(&item, dur)) {
-            if (!endFrameAdded) {
-                // add keyframe at the end with interpolated value
-
-                // but only once ;)
-                endFrameAdded = true;
-
-                Mlt::GeometryItem endItem;
-                Mlt::GeometryItem interp;
-                geometry.fetch(&interp, dur - 1);
-                endItem.frame(dur - 1);
-                endItem.x(interp.x());
-                endItem.y(interp.y());
-                endItem.w(interp.w());
-                endItem.h(interp.h());
-                endItem.mix(interp.mix());
-                geometry.insert(&endItem);
-            }
-            geometry.remove(item.frame());
-        }
-    } else {
-        Mlt::Geometry origGeometry(param.attribute("value").toUtf8().data(), dur, width, height);
-        // remove keyframes before cut point
-        while (!geometry.prev_key(&item, cut - 1) && item.frame() < cut)
-            geometry.remove(item.frame());
-
-        // add a keyframe at new pos 0
-        origGeometry.fetch(&item, cut);
-        item.frame(0);
-        geometry.insert(&item);
-
-        // move exisiting keyframes by -cut
-        while (!origGeometry.next_key(&item, cut)) {
-            geometry.remove(item.frame());
-            origGeometry.remove(item.frame());
-            item.frame(item.frame() - cut);
-            geometry.insert(&item);
-        }
-    }
+    Mlt::Geometry geometry(param.attribute("value").toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
 
-    param.setAttribute("value", geometry.serialise());
+    param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
 }
 
 #include "clipitem.moc"