]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.cpp
Remember & save monitor zone for each clip:
[kdenlive] / src / renderer.cpp
index 40dfc4c9e74a87a78a5c702511ef59ac38857d9a..d237cf71d4f84806756e709bc1e6e1d6ac1f3ca7 100644 (file)
@@ -1022,7 +1022,7 @@ void Render::stop() {
     if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
         kDebug() << "/////////////   RENDER STOPPED: " << m_name;
         m_isBlocked = true;
-        m_mltConsumer->set("refresh", 0);
+        //m_mltConsumer->set("refresh", 0);
         m_mltConsumer->stop();
         // delete m_mltConsumer;
         // m_mltConsumer = NULL;
@@ -1128,6 +1128,7 @@ void Render::playZone(const GenTime & startTime, const GenTime & stopTime) {
     if (!m_mltProducer || !m_mltConsumer)
         return;
     m_isBlocked = false;
+    if (!m_isZoneMode) m_originalOut = m_mltProducer->get_playtime() - 1;
     m_mltProducer->set("out", stopTime.frames(m_fps));
     m_mltProducer->seek((int)(startTime.frames(m_fps)));
     m_mltProducer->set_speed(1.0);
@@ -1136,7 +1137,8 @@ void Render::playZone(const GenTime & startTime, const GenTime & stopTime) {
 }
 
 void Render::resetZoneMode() {
-    m_mltProducer->set("out", m_mltProducer->get_length() - 1);
+    if (!m_isZoneMode && !m_isLoopMode) return;
+    m_mltProducer->set("out", m_originalOut);
     //m_mltProducer->set("eof", "pause");
     m_isZoneMode = false;
     m_isLoopMode = false;
@@ -1742,8 +1744,8 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, Mlt
     return newLength;
 }
 
-bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh) {
-
+bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool updateIndex, bool doRefresh) {
+    kDebug() << "// TRYing to remove effect at: " << index;
     Mlt::Service service(m_mltProducer->parent().get_service());
     bool success = false;
     Mlt::Tractor tractor(service);
@@ -1764,10 +1766,11 @@ bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool do
         if ((index == "-1" && filter->get("kdenlive_id") != "")  || filter->get("kdenlive_ix") == index) {// && filter->get("kdenlive_id") == id) {
             if (clipService.detach(*filter) == 0) success = true;
             kDebug() << " / / / DLEETED EFFECT: " << ct;
-        } else {
+        } else if (updateIndex) {
+            // Adjust the other effects index
             if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
             ct++;
-        }
+        } else ct++;
         filter = clipService.filter(ct);
     }
     m_isBlocked = false;
@@ -1919,7 +1922,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par
 
     if (!params.paramValue("keyframes").isEmpty() || /*it.key().startsWith("#") || */tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
         // This is a keyframe effect, to edit it, we remove it and re-add it.
-        mltRemoveEffect(track, position, index);
+        mltRemoveEffect(track, position, index, true);
         bool success = mltAddEffect(track, position, params);
         return success;
     }
@@ -2717,10 +2720,10 @@ QList <Mlt::Producer *> Render::producersList() {
         int clipNb = trackPlaylist.count();
         //kDebug() << "// PARSING SCENE TRACK: " << t << ", CLIPS: " << clipNb;
         for (int i = 0; i < clipNb; i++) {
-            Mlt::Producer nprod(trackPlaylist.get_clip(i)->get_parent());
-            if (nprod.is_valid() && !nprod.is_blank() && !ids.contains(nprod.get("id"))) {
-                ids.append(nprod.get("id"));
-                prods.append(&nprod);
+            Mlt::Producer *nprod = new Mlt::Producer(trackPlaylist.get_clip(i)->get_parent());
+            if (nprod && !nprod->is_blank() && !ids.contains(nprod->get("id"))) {
+                ids.append(nprod->get("id"));
+                prods.append(nprod);
             }
         }
     }
@@ -2739,14 +2742,14 @@ void Render::fillSlowMotionProducers() {
         Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
         int clipNb = trackPlaylist.count();
         for (int i = 0; i < clipNb; i++) {
-            Mlt::Producer nprod(trackPlaylist.get_clip(i)->get_parent());
-            if (nprod.is_valid() && !nprod.is_blank()) {
-                QString id = nprod.get("id");
+            Mlt::Producer *nprod = new Mlt::Producer(trackPlaylist.get_clip(i)->get_parent());
+            if (nprod && !nprod->is_blank()) {
+                QString id = nprod->get("id");
                 if (id.startsWith("slowmotion:")) {
                     // this is a slowmotion producer, add it to the list
-                    QString url = nprod.get("resource");
+                    QString url = nprod->get("resource");
                     if (!m_slowmotionProducers.contains(url)) {
-                        m_slowmotionProducers.insert(url, &nprod);
+                        m_slowmotionProducers.insert(url, nprod);
                     }
                 }
             }
@@ -2939,10 +2942,11 @@ void Render::mltDeleteTrack(int ix) {
 void Render::updatePreviewSettings() {
     kDebug() << "////// RESTARTING CONSUMER";
     if (!m_mltConsumer || !m_mltProducer) return;
+    if (m_mltProducer->get_playtime() == 0) return;
     Mlt::Service service(m_mltProducer->parent().get_service());
     if (service.type() != tractor_type) return;
 
-    m_mltConsumer->set("refresh", 0);
+    //m_mltConsumer->set("refresh", 0);
     if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
     m_mltConsumer->purge();
     QString scene = sceneList();