[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src: Fix various error corrupting project when changing profile's framerate
From:       Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date:       2016-01-01 1:42:17
Message-ID: E1aEojR-0000yS-EE () scm ! kde ! org
[Download RAW message or body]

Git commit 66eea0af8b418c42ac1768e9ab90537404010367 by Jean-Baptiste Mardelle.
Committed on 01/01/2016 at 01:10.
Pushed by mardelle into branch 'master'.

Fix various error corrupting project when changing profile's framerate
CCBUG: 354940

M  +1    -0    src/doc/kdenlivedoc.cpp
M  +2    -0    src/doc/kdenlivedoc.h
M  +1    -0    src/mainwindow.cpp
M  +2    -2    src/monitor/monitor.cpp
M  +2    -2    src/renderer.cpp
M  +1    -1    src/renderer.h
M  +1    -0    src/timeline/customruler.cpp
M  +4    -1    src/timeline/timeline.cpp
M  +1    -1    src/timeline/timeline.h
M  +21   -27   src/timeline/track.cpp
M  +1    -3    src/timeline/track.h

http://commits.kde.org/kdenlive/66eea0af8b418c42ac1768e9ab90537404010367

diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp
index 3d0b366..7c63ccf 100644
--- a/src/doc/kdenlivedoc.cpp
+++ b/src/doc/kdenlivedoc.cpp
@@ -1552,6 +1552,7 @@ void KdenliveDoc::updateProjectProfile()
     m_timecode.setFormat(fps);
     KdenliveSettings::setCurrent_profile(m_profile.path);
     pCore->monitorManager()->resetProfiles(m_profile, m_timecode);
+    emit updateFps();
 }
 
 void KdenliveDoc::resetProfile()
diff --git a/src/doc/kdenlivedoc.h b/src/doc/kdenlivedoc.h
index b8a679e..8a8043b 100644
--- a/src/doc/kdenlivedoc.h
+++ b/src/doc/kdenlivedoc.h
@@ -238,6 +238,8 @@ signals:
     void startAutoSave();
     /** @brief Current doc created effects, reload list */
     void reloadEffects();
+    /** @brief Fps was changed, update timeline */
+    void updateFps();
 };
 
 #endif
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7b88f8a..2240341 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1662,6 +1662,7 @@ void MainWindow::connectDocument()
     connect(m_effectStack->transitionConfig(), SIGNAL(seekTimeline(int)), \
trackView->projectView() , SLOT(seekCursorPos(int)));  
     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), \
m_projectMonitor, SLOT(slotActivateMonitor())); +    connect(project, \
                &KdenliveDoc::updateFps, trackView, &Timeline::updateProjectFps);
     connect(trackView, SIGNAL(zoneMoved(int,int)), this, \
SLOT(slotZoneMoved(int,int)));  \
trackView->projectView()->setContextMenu(m_timelineContextMenu, \
m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, \
static_cast<QMenu*>(factory()->container(QStringLiteral("marker_menu"), this)));  if \
                (m_renderWidget) {
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 419d949..6991e55 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -1337,7 +1337,7 @@ void Monitor::setCustomProfile(const QString &profile, const \
Timecode &tc)  m_timePos->updateTimeCode(tc);
     if (render == NULL) return;
     slotActivateMonitor();
-    render->prepareProfileReset();
+    render->prepareProfileReset(tc.fps());
     m_glMonitor->resetProfile(ProfilesDialog::getVideoProfile(profile));
 }
 
@@ -1346,7 +1346,7 @@ void Monitor::resetProfile(MltVideoProfile profile)
     m_timePos->updateTimeCode(m_monitorManager->timecode());
     if (render == NULL) return;
 
-    render->prepareProfileReset();
+    render->prepareProfileReset(m_monitorManager->timecode().fps());
     m_glMonitor->resetProfile(profile);
 
     if (m_rootItem && m_rootItem->objectName() == QLatin1String("rooteffectscene")) \
                {
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 52925cc..a34f601 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -153,7 +153,7 @@ Mlt::Producer *Render::invalidProducer(const QString &id)
     return clip;
 }
 
-void Render::prepareProfileReset()
+void Render::prepareProfileReset(double fps)
 {
     m_refreshTimer.stop();
     if (m_isSplitView)
@@ -162,9 +162,9 @@ void Render::prepareProfileReset()
     m_requestList.clear();
     m_infoMutex.unlock();
     m_infoThread.waitForFinished();
+    m_fps = fps;
 }
 
-
 void Render::seek(const GenTime &time)
 {
     if (!m_mltProducer || !m_isActive)
diff --git a/src/renderer.h b/src/renderer.h
index 5e44ce0..9e619b4 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -301,7 +301,7 @@ class Render: public AbstractRender
     const QString getBinProperty(const QString &name);
     void setVolume(double volume);
     /** @brief Stop all activities in preparation for a change in profile */
-    void prepareProfileReset();
+    void prepareProfileReset(double fps);
     void updateSlowMotionProducers(const QString &id, QMap <QString, QString> \
                passProperties);
     static QMap<QString, QString> mltGetTransitionParamsFromXml(const QDomElement \
                &xml);
     /** @brief Make sure to close running threads before closing document */
diff --git a/src/timeline/customruler.cpp b/src/timeline/customruler.cpp
index 7e8a3e7..e63a971 100644
--- a/src/timeline/customruler.cpp
+++ b/src/timeline/customruler.cpp
@@ -100,6 +100,7 @@ void CustomRuler::updateProjectFps(const Timecode &t)
     m_timecode = t;
     mediumMarkDistance = FRAME_SIZE * m_timecode.fps();
     bigMarkDistance = FRAME_SIZE * m_timecode.fps() * 60;
+    setPixelPerMark(m_rate);
     update();
 }
 
diff --git a/src/timeline/timeline.cpp b/src/timeline/timeline.cpp
index d8dffb6..343438a 100644
--- a/src/timeline/timeline.cpp
+++ b/src/timeline/timeline.cpp
@@ -255,7 +255,7 @@ int Timeline::getTracks() {
         frame->setFrameStyle(QFrame::HLine);
         frame->setFixedHeight(1);
         headerLayout->insertWidget(0, frame);
-        Track *tk = new Track(i, m_trackActions, playlist, audio == 1 ? AudioTrack : \
VideoTrack, m_doc->fps(), this); +        Track *tk = new Track(i, m_trackActions, \
playlist, audio == 1 ? AudioTrack : VideoTrack, this);  m_tracks.append(tk);
         if (audio == 0 && !isBackgroundBlackTrack) {
             // Check if we have a composite transition for this track
@@ -1121,8 +1121,11 @@ void Timeline::slotVerticalZoomUp()
 
 void Timeline::updateProjectFps()
 {
+    qDebug()<<"Requesting FPS UPDATE: "<<m_doc->timecode().fps();
+    m_ruler->updateFrameSize();
     m_ruler->updateProjectFps(m_doc->timecode());
     m_trackview->updateProjectFps();
+    slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
 }
 
 void Timeline::slotRenameTrack(int ix, const QString &name)
diff --git a/src/timeline/timeline.h b/src/timeline/timeline.h
index 1b46574..21fe434 100644
--- a/src/timeline/timeline.h
+++ b/src/timeline/timeline.h
@@ -64,7 +64,6 @@ public:
     int duration() const;
     KdenliveDoc *document();
     void refresh() ;
-    void updateProjectFps();
     int outPoint() const;
     int inPoint() const;
     int fitZoom() const;
@@ -157,6 +156,7 @@ public slots:
     void slotSaveTimelinePreview(const QString &path);
     void checkDuration(int duration);
     void slotShowTrackEffects(int);
+    void updateProjectFps();
 
 private:
     Mlt::Tractor *m_tractor;
diff --git a/src/timeline/track.cpp b/src/timeline/track.cpp
index cf2428d..49ceaac 100644
--- a/src/timeline/track.cpp
+++ b/src/timeline/track.cpp
@@ -28,13 +28,12 @@
 #include <QDebug>
 #include <math.h>
 
-Track::Track(int index, const QList<QAction *> &actions, Mlt::Playlist &playlist, \
TrackType type, qreal fps, QWidget *parent) : +Track::Track(int index, const \
QList<QAction *> &actions, Mlt::Playlist &playlist, TrackType type, QWidget *parent) \
:  effectsList(EffectsList(true)),
     type(type),
     trackHeader(NULL),
     m_index(index),
-    m_playlist(playlist),
-    m_fps(fps)
+    m_playlist(playlist)
 {
     QString playlist_name = playlist.get("id");
     if (playlist_name != "black_track") {
@@ -62,21 +61,16 @@ void Track::setPlaylist(Mlt::Playlist &playlist)
 
 qreal Track::fps()
 {
-    return m_fps;
+    return m_playlist.get_fps();
 }
 
 int Track::frame(qreal t)
 {
-    return round(t * m_fps);
+    return round(t * fps());
 }
 
 qreal Track::length() {
-    return m_playlist.get_playtime() / m_fps;
-}
-
-void Track::setFps(qreal fps)
-{
-    m_fps = fps;
+    return m_playlist.get_playtime() / fps();
 }
 
 // basic clip operations
@@ -602,7 +596,7 @@ void Track::updateClipProperties(const QString &id, QMap \
<QString, QString> prop  int Track::changeClipSpeed(ItemInfo info, ItemInfo \
speedIndependantInfo, PlaylistState::ClipState state, double speed, int strobe, \
Mlt::Producer *prod, Mlt::Properties passProps, bool removeEffect)  {
     int newLength = 0;
-    int startPos = info.startPos.frames(m_fps);
+    int startPos = info.startPos.frames(fps());
     int clipIndex = m_playlist.get_clip_index_at(startPos);
     int clipLength = m_playlist.clip_length(clipIndex);
 
@@ -680,9 +674,9 @@ int Track::changeClipSpeed(ItemInfo info, ItemInfo \
                speedIndependantInfo, Playlis
 	    int blankEnd = m_playlist.clip_start(clipIndex) + \
m_playlist.clip_length(clipIndex);  Mlt::Producer *cut;
 	    if (clipIndex + 1 < m_playlist.count() && (startPos + clipLength / speed > \
                blankEnd)) {
-		GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
-		cut = prod->cut((int)(info.cropStart.frames(m_fps) / speed), \
                (int)(info.cropStart.frames(m_fps) / speed + maxLength.frames(m_fps) \
                - 1));
-	    } else cut = prod->cut((int)(info.cropStart.frames(m_fps) / speed), \
(int)((info.cropStart.frames(m_fps) + clipLength) / speed - 1)); +		GenTime maxLength \
= GenTime(blankEnd, fps()) - info.startPos; +		cut = \
prod->cut((int)(info.cropStart.frames(fps()) / speed), \
(int)(info.cropStart.frames(fps()) / speed + maxLength.frames(fps()) - 1)); +	    } \
else cut = prod->cut((int)(info.cropStart.frames(fps()) / speed), \
(int)((info.cropStart.frames(fps()) + clipLength) / speed - 1));  
 	    // move all effects to the correct producer
 	    Clip(*cut).addEffects(*clip);
@@ -718,12 +712,12 @@ int Track::changeClipSpeed(ItemInfo info, ItemInfo \
speedIndependantInfo, Playlis  emit storeSlowMotion(url, prod);
 	    }
 
-	    int originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps));
-	    if (clipIndex + 1 < m_playlist.count() && (info.startPos + \
                speedIndependantInfo.cropDuration).frames(m_fps) > blankEnd) {
-		GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
-		cut = prod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - \
1)); +	    int originalStart = (int)(speedIndependantInfo.cropStart.frames(fps()));
+	    if (clipIndex + 1 < m_playlist.count() && (info.startPos + \
speedIndependantInfo.cropDuration).frames(fps()) > blankEnd) { +		GenTime maxLength = \
GenTime(blankEnd, fps()) - info.startPos; +		cut = prod->cut(originalStart, \
(int)(originalStart + maxLength.frames(fps()) - 1));  } else {
-		cut = prod->cut(originalStart, (int)(originalStart + \
speedIndependantInfo.cropDuration.frames(m_fps)) - 1); +		cut = \
prod->cut(originalStart, (int)(originalStart + \
speedIndependantInfo.cropDuration.frames(fps())) - 1);  }
 
 	    // move all effects to the correct producer
@@ -760,21 +754,21 @@ int Track::changeClipSpeed(ItemInfo info, ItemInfo \
speedIndependantInfo, Playlis  int duration;
         int originalStart;
         if (speed == 1.0) {
-          duration = speedIndependantInfo.cropDuration.frames(m_fps);
-          originalStart = speedIndependantInfo.cropStart.frames(m_fps);
+          duration = speedIndependantInfo.cropDuration.frames(fps());
+          originalStart = speedIndependantInfo.cropStart.frames(fps());
         } else {
-          duration = (int) (speedIndependantInfo.cropDuration.frames(m_fps) / speed \
                + 0.5);
-          originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps) / speed \
+ 0.5); +          duration = (int) (speedIndependantInfo.cropDuration.frames(fps()) \
/ speed + 0.5); +          originalStart = \
(int)(speedIndependantInfo.cropStart.frames(fps()) / speed + 0.5);  }
-        qDebug()<<"/ / /UPDATE SPEED: "<<speed<<", \
"<<speedIndependantInfo.cropStart.frames(m_fps)<<":"<<originalStart; +        \
qDebug()<<"/ / /UPDATE SPEED: "<<speed<<", \
"<<speedIndependantInfo.cropStart.frames(fps())<<":"<<originalStart;  // Check that \
the blank space is long enough for our new duration  clipIndex = \
                m_playlist.get_clip_index_at(startPos);
         int blankEnd = m_playlist.clip_start(clipIndex) + \
m_playlist.clip_length(clipIndex);  
         Mlt::Producer *cut;
         if (clipIndex + 1 < m_playlist.count() && (startPos + duration > blankEnd)) \
                {
-            GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
-            cut = prod->cut(originalStart, (int)(originalStart + \
maxLength.frames(m_fps) - 1)); +            GenTime maxLength = GenTime(blankEnd, \
fps()) - info.startPos; +            cut = prod->cut(originalStart, \
(int)(originalStart + maxLength.frames(fps()) - 1));  } else {
 	      cut = prod->cut(originalStart, originalStart + duration - 1);
 	}
diff --git a/src/timeline/track.h b/src/timeline/track.h
index 8dbe707..f688115 100644
--- a/src/timeline/track.h
+++ b/src/timeline/track.h
@@ -47,13 +47,12 @@ class Track : public QObject
 {
     Q_OBJECT
     Q_PROPERTY(Mlt::Playlist playlist READ playlist WRITE setPlaylist)
-    Q_PROPERTY(qreal fps READ fps WRITE setFps)
 
 public:
     /** @brief Track constructor
      * @param playlist is the MLT object used for monitor/render
      * @param fps is the read speed (frames per seconds) */
-    explicit Track(int index, const QList<QAction *> &actions, Mlt::Playlist \
&playlist, TrackType type, qreal fps, QWidget *parent = 0); +    explicit Track(int \
index, const QList<QAction *> &actions, Mlt::Playlist &playlist, TrackType type, \
QWidget *parent = 0);  ~Track();
 
     /// Property access function
@@ -177,7 +176,6 @@ public:
 
 public Q_SLOTS:
     void setPlaylist(Mlt::Playlist &playlist);
-    void setFps(qreal fps);
 
 signals:
     /** @brief notify track length change to update background


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic