]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.cpp
Add center-crop option to slideshow clip.
[kdenlive] / src / renderer.cpp
index f3002a87bfcb05817038026377fb0e6a7c92f157..47d9bc67aae36aa73405c3beeff363418b72586a 100644 (file)
@@ -732,6 +732,14 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
                 clipService.attach(*filter);
             }
         }
+        if (xml.attribute("crop") == "1") {
+            // user wants to center crop the slides
+            Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "crop");
+            if (filter && filter->is_valid()) {
+                filter->set("center", 1);
+                producer->attach(*filter);
+            }
+        }
     }
 
 
@@ -2433,16 +2441,13 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
         params.removeParam("max");
         params.removeParam("factor");
         int offset = 0;
-        for (int i = 0; i < keyFrames.size() - 1; ++i) {
+        // Special case, only one keyframe, means we want a constant value
+        if (keyFrames.count() == 1) {
             Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterTag);
             if (filter && filter->is_valid()) {
                 filter->set("kdenlive_id", filterId);
-                int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset;
-                double y1 = keyFrames.at(i).section(':', 1, 1).toDouble();
-                int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt();
-                double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble();
-                if (x2 == -1) x2 = duration;
-
+                int x1 = keyFrames.at(0).section(':', 0, 0).toInt();
+                double y1 = keyFrames.at(0).section(':', 1, 1).toDouble();
                 for (int j = 0; j < params.count(); j++) {
                     char *name = decodedString(params.at(j).name());
                     char *value = decodedString(params.at(j).value());
@@ -2450,16 +2455,38 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
                     delete[] name;
                     delete[] value;
                 }
-
                 filter->set("in", x1);
-                filter->set("out", x2);
                 //kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
                 filter->set(starttag, QString::number((min + y1) / factor).toUtf8().data());
-                filter->set(endtag, QString::number((min + y2) / factor).toUtf8().data());
                 service.attach(*filter);
-                offset = 1;
             }
-        }
+        } else for (int i = 0; i < keyFrames.size() - 1; ++i) {
+                Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterTag);
+                if (filter && filter->is_valid()) {
+                    filter->set("kdenlive_id", filterId);
+                    int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset;
+                    double y1 = keyFrames.at(i).section(':', 1, 1).toDouble();
+                    int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt();
+                    double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble();
+                    if (x2 == -1) x2 = duration;
+
+                    for (int j = 0; j < params.count(); j++) {
+                        char *name = decodedString(params.at(j).name());
+                        char *value = decodedString(params.at(j).value());
+                        filter->set(name, value);
+                        delete[] name;
+                        delete[] value;
+                    }
+
+                    filter->set("in", x1);
+                    filter->set("out", x2);
+                    //kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
+                    filter->set(starttag, QString::number((min + y1) / factor).toUtf8().data());
+                    filter->set(endtag, QString::number((min + y2) / factor).toUtf8().data());
+                    service.attach(*filter);
+                    offset = 1;
+                }
+            }
         delete[] starttag;
         delete[] endtag;
     } else {
@@ -2515,6 +2542,9 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int
             delete[] value;
         }
 
+        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);
@@ -2877,16 +2907,17 @@ bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration)
     Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
     int previousStart = clip->get_in();
     int newDuration = (int) clipDuration.frames(m_fps) - 1;
+    int currentOut = (int)(info.cropStart + info.cropDuration).frames(m_fps) - 1;
     int diff = newDuration - (trackPlaylist.clip_length(clipIndex) - 1);
-    if (newDuration > clip->get_length()) {
-        clip->parent().set("length", newDuration + 1);
-        clip->parent().set("out", newDuration);
-        clip->set("length", newDuration + 1);
+    if (currentOut > clip->get_length()) {
+        clip->parent().set("length", currentOut + 1);
+        clip->parent().set("out", currentOut);
+        clip->set("length", currentOut + 1);
     }
-    if (newDuration > clip->get_out()) {
+    /*if (newDuration > clip->get_out()) {
         clip->parent().set_in_and_out(0, newDuration + 1);
         clip->set_in_and_out(0, newDuration + 1);
-    }
+    }*/
     delete clip;
     trackPlaylist.resize_clip(clipIndex, previousStart, newDuration + previousStart);
     trackPlaylist.consolidate_blanks(0);