]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
*Allow users to choose between SDL and OpenGL for monitor display
[kdenlive] / src / docclipbase.cpp
index 4e26b005f95650ea4786ff89171f3cc196ddcc1a..31c0ca252114371c191a9ae448f878743e57ad9e 100644 (file)
@@ -28,6 +28,7 @@
 #include "kdenlivesettings.h"
 #include "kthumb.h"
 #include "clipmanager.h"
+#include "slideshowclip.h"
 
 #include <KIO/NetAccess>
 #include <KDebug>
@@ -518,9 +519,7 @@ Mlt::Producer *DocClipBase::audioProducer(int track)
         if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt());
         m_audioTrackProducers.at(track)->set("video_index", -1);
         if (m_properties.contains("audio_index")) m_audioTrackProducers.at(track)->set("audio_index", m_properties.value("audio_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
-        m_audioTrackProducers.at(track)->set("id", tmp);
-        delete[] tmp;
+        m_audioTrackProducers.at(track)->set("id", QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
     }
     return m_audioTrackProducers.at(track);
 }
@@ -539,9 +538,7 @@ Mlt::Producer *DocClipBase::videoProducer()
         if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt());
         m_videoOnlyProducer->set("audio_index", -1);
         if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + "_video").toUtf8().data());
-        m_videoOnlyProducer->set("id", tmp);
-        delete[] tmp;
+        m_videoOnlyProducer->set("id", QString(getId() + "_video").toUtf8().data());
     }
     return m_videoOnlyProducer;
 }
@@ -583,9 +580,7 @@ Mlt::Producer *DocClipBase::producer(int track)
         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
         if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
-        m_baseTrackProducers[track]->set("id", tmp);
-        delete[] tmp;
+        m_baseTrackProducers[track]->set("id", QString(getId() + '_' + QString::number(track)).toUtf8().data());
         if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
             m_baseTrackProducers[track]->set("skip_loop_filter", "all");
             m_baseTrackProducers[track]->set("skip_frame", "bidir");
@@ -642,14 +637,54 @@ void DocClipBase::slotRefreshProducer()
     if (m_baseTrackProducers.count() == 0) return;
     kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
     if (m_clipType == SLIDESHOW) {
-        /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
-               Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
-               delete[] tmp;
+        /*Mlt::Producer producer(*(m_clipProducer->profile()), getProperty("resource").toUtf8().data());
         delete m_clipProducer;
         m_clipProducer = new Mlt::Producer(producer.get_producer());
         if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
         setProducerProperty("ttl", getProperty("ttl").toInt());
         //m_clipProducer->set("id", getProperty("id"));
+        if (!getProperty("animation").isEmpty()) {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(ct);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "affine") == 0) {
+                    break;
+                } else if (strcmp(filter->get("mlt_service"), "boxblur") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+
+            if (!filter || strcmp(filter->get("mlt_service"), "affine")) {
+                // filter does not exist, create it.
+                Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "affine");
+                if (filter && filter->is_valid()) {
+                    int cycle = getProperty("ttl").toInt();
+                    QString geometry = SlideshowClip::animationToGeometry(getProperty("animation"), cycle);
+                    if (!geometry.isEmpty()) {
+                        if (getProperty("animation").contains("low-pass")) {
+                            Mlt::Filter *blur = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "boxblur");
+                            if (blur && blur->is_valid())
+                                clipService.attach(*blur);
+                        }
+                        filter->set("transition.geometry", geometry.toUtf8().data());
+                        filter->set("transition.cycle", cycle);
+                        clipService.attach(*filter);
+                    }
+                }
+            }
+        } else {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(0);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "affine") == 0 || strcmp(filter->get("mlt_service"), "boxblur") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+        }
         if (getProperty("fade") == "1") {
             // we want a fade filter effect
             kDebug() << "////////////   FADE WANTED";
@@ -665,12 +700,9 @@ void DocClipBase::slotRefreshProducer()
             }
 
             if (filter && strcmp(filter->get("mlt_service"), "luma") == 0) {
-                filter->set("period", getProperty("ttl").toInt() - 1);
-                filter->set("luma.out", getProperty("luma_duration").toInt());
-                QString resource = getProperty("luma_file");
-                char *tmp = (char *) qstrdup(resource.toUtf8().data());
-                filter->set("luma.resource", tmp);
-                delete[] tmp;
+                filter->set("cycle", getProperty("ttl").toInt());
+                filter->set("duration", getProperty("luma_duration").toInt());
+                filter->set("luma.resource", getProperty("luma_file").toUtf8().data());
                 if (!getProperty("softness").isEmpty()) {
                     int soft = getProperty("softness").toInt();
                     filter->set("luma.softness", (double) soft / 100.0);
@@ -678,12 +710,9 @@ void DocClipBase::slotRefreshProducer()
             } else {
                 // filter does not exist, create it...
                 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
-                filter->set("period", getProperty("ttl").toInt() - 1);
-                filter->set("luma.out", getProperty("luma_duration").toInt());
-                QString resource = getProperty("luma_file");
-                char *tmp = (char *) qstrdup(resource.toUtf8().data());
-                filter->set("luma.resource", tmp);
-                delete[] tmp;
+                filter->set("cycle", getProperty("ttl").toInt());
+                filter->set("duration", getProperty("luma_duration").toInt());
+                filter->set("luma.resource", getProperty("luma_file").toUtf8().data());
                 if (!getProperty("softness").isEmpty()) {
                     int soft = getProperty("softness").toInt();
                     filter->set("luma.softness", (double) soft / 100.0);
@@ -702,6 +731,36 @@ void DocClipBase::slotRefreshProducer()
                 filter = clipService.filter(ct);
             }
         }
+        if (getProperty("crop") == "1") {
+            // we want a center crop filter effect
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(ct);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "crop") == 0) {
+                    break;
+                }
+                ct++;
+                filter = clipService.filter(ct);
+            }
+
+            if (!filter || strcmp(filter->get("mlt_service"), "crop")) {
+                // filter does not exist, create it...
+                Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "crop");
+                filter->set("center", 1);
+                clipService.attach(*filter);
+            }
+        } else {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(0);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "crop") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+        }
     }
 }
 
@@ -712,7 +771,7 @@ void DocClipBase::setProperties(QMap <QString, QString> properties)
     QMapIterator<QString, QString> i(properties);
     bool refreshProducer = false;
     QStringList keys;
-    keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
+    keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness" << "crop" << "animation";
     while (i.hasNext()) {
         i.next();
         setProperty(i.key(), i.value());
@@ -828,18 +887,12 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
     } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
     //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
     else if (key == "colour") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("colour", tmp);
-        delete[] tmp;
+        setProducerProperty("colour", value.toUtf8().data());
     } else if (key == "templatetext") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("templatetext", tmp);
-        delete[] tmp;
+        setProducerProperty("templatetext", value.toUtf8().data());
         setProducerProperty("force_reload", 1);
     } else if (key == "xmldata") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("xmldata", tmp);
-        delete[] tmp;
+        setProducerProperty("xmldata", value.toUtf8().data());
         setProducerProperty("force_reload", 1);
     } else if (key == "force_aspect_ratio") {
         if (value.isEmpty()) {
@@ -881,7 +934,7 @@ QMap <QString, QString> DocClipBase::properties() const
 
 bool DocClipBase::slotGetAudioThumbs()
 {
-    if (m_thumbProd == NULL) return false;
+    if (m_thumbProd == NULL || isPlaceHolder()) return false;
     if (!KdenliveSettings::audiothumbnails() || m_audioTimer == NULL) {
         if (m_audioTimer != NULL) m_audioTimer->stop();
         return false;