]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.cpp
Fix several DVD wizard monitor issue, might solve:
[kdenlive] / src / renderer.cpp
index 57e2ef85120ef844da7d3423fdb95acc61f37e2f..1c397d3b4aa8b2d4afa663a5cca961cb1a26faae 100644 (file)
@@ -67,7 +67,7 @@ static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr
     }
 }
 
-Render::Render(const QString & rendererName, int winid, int /* extid */, QWidget *parent) :
+Render::Render(const QString & rendererName, int winid, int /* extid */, QString profile, QWidget *parent) :
         QObject(parent),
         m_isBlocked(0),
         m_name(rendererName),
@@ -84,14 +84,12 @@ Render::Render(const QString & rendererName, int winid, int /* extid */, QWidget
         , m_glWidget(0)
 #endif
 {
-    kDebug() << "//////////  USING PROFILE: " << (char*)KdenliveSettings::current_profile().toUtf8().data();
-
     /*if (rendererName == "project") m_monitorId = 10000;
     else m_monitorId = 10001;*/
     /*m_osdTimer = new QTimer(this);
     connect(m_osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()));*/
-
-    buildConsumer();
+    if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
+    buildConsumer(profile);
 
     m_mltProducer = m_blackClip->cut(0, 50);
     m_mltConsumer->connect(*m_mltProducer);
@@ -151,10 +149,10 @@ void Render::closeMlt()
 }
 
 
-void Render::buildConsumer()
+void Render::buildConsumer(const QString profileName)
 {
     char *tmp;
-    m_activeProfile = KdenliveSettings::current_profile();
+    m_activeProfile = profileName;
     tmp = decodedString(m_activeProfile);
     setenv("MLT_PROFILE", tmp, 1);
     delete m_blackClip;
@@ -232,14 +230,14 @@ void Render::buildConsumer()
 
 }
 
-int Render::resetProfile()
+int Render::resetProfile(const QString profileName)
 {
     if (!m_mltConsumer) return 0;
-    if (m_activeProfile == KdenliveSettings::current_profile()) {
+    if (m_activeProfile == profileName) {
         kDebug() << "reset to same profile, nothing to do";
         return 1;
     }
-    kDebug() << "// RESETTING PROFILE FROM: " << m_activeProfile << " TO: " << KdenliveSettings::current_profile();
+    kDebug() << "// RESETTING PROFILE FROM: " << m_activeProfile << " TO: " << profileName; //KdenliveSettings::current_profile();
     if (m_isSplitView) slotSplitView(false);
     if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
     m_mltConsumer->purge();
@@ -270,7 +268,7 @@ int Render::resetProfile()
     }
     m_mltProducer = NULL;
 
-    buildConsumer();
+    buildConsumer(profileName);
     double new_fps = m_mltProfile->fps();
     if (current_fps != new_fps) {
         // fps changed, we must update the scenelist positions
@@ -958,6 +956,7 @@ int Render::setSceneList(QString playlist, int position)
                 if (trackPlaylist.type() == playlist_type) trackPlaylist.clear();
                 trackNb--;
             }
+            delete field;
         }
         mlt_service_unlock(service.get_service());
 
@@ -1709,7 +1708,7 @@ void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr
         }
         ct++;
         filter = sourceService.filter(ct);
-    }    
+    }
     mltRemoveClip(info.track, info.startPos);
     mltInsertClip(info, element, prod);
     if (!filtersList.isEmpty()) {
@@ -2036,6 +2035,7 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int
         }
         Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
         trackPlaylist.consolidate_blanks(0);
+
         // Check that the blank space is long enough for our new duration
         clipIndex = trackPlaylist.get_clip_index_at(startPos);
         int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
@@ -2064,12 +2064,12 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int
         int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
 
         Mlt::Producer *cut;
-        GenTime oldDuration = GenTime(clipLength, m_fps);
-        GenTime newDuration = oldDuration * oldspeed;
-        if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + newDuration).frames(m_fps) > blankEnd) {
+        GenTime duration = info.cropDuration;
+        int originalStart = (int)(info.originalcropStart.frames(m_fps));
+        if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + info.cropDuration).frames(m_fps) > blankEnd) {
             GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
-            cut = prod->cut((int)(info.cropStart.frames(m_fps)), (int)(info.cropStart.frames(m_fps) + maxLength.frames(m_fps) - 1));
-        } else cut = prod->cut((int)(info.cropStart.frames(m_fps)), (int)((info.cropStart + newDuration).frames(m_fps)) - 1);
+            cut = prod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - 1));
+        } else cut = prod->cut(originalStart, (int)(originalStart + info.cropDuration.frames(m_fps)) - 1);
 
         // move all effects to the correct producer
         mltPasteEffects(clip, cut);
@@ -2103,18 +2103,18 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int
         Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
         trackPlaylist.consolidate_blanks(0);
 
-        GenTime oldDuration = GenTime(clipLength, m_fps);
-        GenTime newDuration = oldDuration * (oldspeed / speed);
+        GenTime duration = info.cropDuration / speed;
+        int originalStart = (int)(info.originalcropStart.frames(m_fps) / speed);
 
         // Check that the blank space is long enough for our new duration
         clipIndex = trackPlaylist.get_clip_index_at(startPos);
         int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
 
         Mlt::Producer *cut;
-        if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + newDuration).frames(m_fps) > blankEnd) {
+        if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + duration).frames(m_fps) > blankEnd) {
             GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
-            cut = slowprod->cut((int)(info.cropStart.frames(m_fps) / speed), (int)(info.cropStart.frames(m_fps) / speed + maxLength.frames(m_fps) - 1));
-        } else cut = slowprod->cut((int)(info.cropStart.frames(m_fps) / speed), (int)((info.cropStart / speed + newDuration).frames(m_fps) - 1));
+            cut = slowprod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - 1));
+        } else cut = slowprod->cut(originalStart, (int)(originalStart + duration.frames(m_fps)) - 1);
 
         // move all effects to the correct producer
         mltPasteEffects(clip, cut);
@@ -2762,9 +2762,9 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn
 
             // move all effects to the correct producer
             mltPasteEffects(clipProducer, clip);
-            
+
             int newIndex = destTrackPlaylist.insert_at(moveEnd, clip, 1);
-            
+
             if (clip == clipProducer) {
                 delete clip;
                 clip = NULL;