]> git.sesse.net Git - kdenlive/commitdiff
Cleanup producer loading, make pan_zoom specific code generic for all effects with...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 6 Jul 2011 10:20:55 +0000 (10:20 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 6 Jul 2011 10:20:55 +0000 (10:20 +0000)
svn path=/trunk/kdenlive/; revision=5768

src/clipitem.cpp
src/customtrackview.cpp
src/renderer.cpp

index 62f71b42726ec2780ad02dcaff7883abc8388a17..08c0371993fd572c9aacc4f3c47aa49f1ad6e7e8 100644 (file)
@@ -1383,16 +1383,17 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
     parameters.addParam("id", effectId);
 
     // special case: the affine effect needs in / out points
-    if (effectId == "pan_zoom") {
-        parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
-        parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps)));
-    }
 
     QDomNodeList params = effect.elementsByTagName("parameter");
     int fade = 0;
+    bool needInOutSync = false;
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull()) {
+            if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
+                // Effects with a geometry parameter need to sync in / out with parent clip
+                needInOutSync = true;
+            }
             if (e.attribute("type") == "simplekeyframe") {
                 QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
                 double factor = e.attribute("factor", "1").toDouble();
@@ -1468,6 +1469,11 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
             }
         }
     }
+    if (needInOutSync) {
+        parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
+        parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps) - 1));
+        parameters.addParam("_sync_in_out", "1");
+    }
     m_effectNames = m_effectList.effectNames().join(" / ");
     if (fade > 0) m_startFade = fade;
     else if (fade < 0) m_endFade = -fade;
@@ -1770,7 +1776,7 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
             QString id = effect.attribute("id");
             int in = EffectsList::parameter(effect, "in").toInt();
             int out = EffectsList::parameter(effect, "out").toInt();
-            int clipEnd = (cropStart() + cropDuration()).frames(m_fps);
+            int clipEnd = (cropStart() + cropDuration()).frames(m_fps) - 1;
             if (id == "fade_from_black" || id == "fadein") {
                 if (in != cropStart().frames(m_fps)) {
                     effects[i] = effect.cloneNode().toElement();
@@ -1791,7 +1797,7 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
                 if (out != clipEnd) {
                     effects[i] = effect.cloneNode().toElement();
                     int diff = out - clipEnd;
-                    in -= diff;
+                    in = qMax(in - diff, (int) cropStart().frames(m_fps));
                     out -= diff;
                     EffectsList::setParameter(effect, "in", QString::number(in));
                     EffectsList::setParameter(effect, "out", QString::number(out));
index 1910e67e036d8c8392648c7118af9fc34b7da2db..4fddc3a67b922a0fac09108a7d94cb2379723f3e 100644 (file)
@@ -6543,7 +6543,10 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
+        if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
+            // effects with geometry param need in / out synced with the clip, request it...
+            parameters.addParam("_sync_in_out", "1");
+        }
         if (e.attribute("type") == "simplekeyframe") {
 
             QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
index bc8e14c89ba0c6d494b0fccdc0b233c8dc9f541d..b96f1f6be913fc5ecc1e7bf4a7a16df2bf8c64c1 100644 (file)
@@ -1650,7 +1650,7 @@ Mlt::Producer *Render::checkSlowMotionProducer(Mlt::Producer *prod, QDomElement
     if (!slowprod || slowprod->get_producer() == NULL) {
         slowprod = new Mlt::Producer(*m_mltProfile, 0, ("framebuffer:" + url).toUtf8().constData());
         if (strobe > 1) slowprod->set("strobe", strobe);
-        QString id = prod->get("id");
+        QString id = prod->parent().get("id");
         if (id.contains('_')) id = id.section('_', 0, 0);
         QString producerid = "slowmotion:" + id + ':' + QString::number(speed);
         if (strobe > 1) producerid.append(':' + QString::number(strobe));
@@ -2562,6 +2562,11 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
             return false;
         }
         params.removeParam("kdenlive_id");
+        if (params.hasParam("_sync_in_out")) {
+            // This effect must sync in / out with parent clip
+            params.removeParam("_sync_in_out");
+            filter->set_in_and_out(service.get_int("in"), service.get_int("out"));
+        }
 
         for (int j = 0; j < params.count(); j++) {
             filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData());
@@ -2583,10 +2588,6 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
             filter->set("effect", effectArgs.simplified().toUtf8().constData());
         }
 
-        if (params.paramValue("id") == "pan_zoom") {
-            filter->set_in_and_out(service.get_int("in"), service.get_int("out") + 1);
-        }
-
         // attach filter to the clip
         service.attach(*filter);
     }
@@ -2711,13 +2712,15 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par
     QString prefix;
     QString ser = filter->get("mlt_service");
     if (ser == "region") prefix = "filter0.";
+    if (params.hasParam("_sync_in_out")) {
+        // This effect must sync in / out with parent clip
+        params.removeParam("_sync_in_out");
+        filter->set_in_and_out(clip->get_in(), clip->get_out());
+    }
     mlt_service_lock(service.get_service());
     for (int j = 0; j < params.count(); j++) {
         filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData());
-    }
-
-    if (params.paramValue("id") == "pan_zoom")
-        filter->set_in_and_out(clip->get_in(), clip->get_out() + 1);
+    }   
 
     delete clip;
     mlt_service_unlock(service.get_service());
@@ -3195,7 +3198,6 @@ bool Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod)
         kDebug() << "// Warning, CLIP on track " << track << ", at: " << pos << " is invalid, cannot update it!!!";
         return false;
     }
-    kDebug() << "NEW PROD ID: " << prod->get("id");
     m_isBlocked++;
     kDebug() << "// TRYING TO UPDATE CLIP at: " << pos << ", TK: " << track;
     Mlt::Service service(m_mltProducer->parent().get_service());
@@ -3850,13 +3852,14 @@ const QList <Mlt::Producer *> Render::producersList()
         int clipNb = trackPlaylist.count();
         for (int i = 0; i < clipNb; i++) {
             Mlt::Producer *c = trackPlaylist.get_clip(i);
-            Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
-            if (nprod) {
-                QString prodId = nprod->get("id");
-                if (!prodId.startsWith("slowmotion") && !prodId.isEmpty() && !nprod->is_blank() && !ids.contains(prodId)) {
+            if (c == NULL) continue;
+            QString prodId = c->parent().get("id");
+            if (!c->is_blank() && !ids.contains(prodId) && !prodId.startsWith("slowmotion") && !prodId.isEmpty()) {
+                Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
+                if (nprod) {
                     ids.append(prodId);
                     prods.append(nprod);
-                } else delete nprod;
+                }
             }
             delete c;
         }
@@ -3883,7 +3886,7 @@ void Render::fillSlowMotionProducers()
             Mlt::Producer *c = trackPlaylist.get_clip(i);
             Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
             if (nprod) {
-                QString id = nprod->get("id");
+                QString id = nprod->parent().get("id");
                 if (id.startsWith("slowmotion:") && !nprod->is_blank()) {
                     // this is a slowmotion producer, add it to the list
                     QString url = QString::fromUtf8(nprod->get("resource"));