]> git.sesse.net Git - kdenlive/commitdiff
Fix broken handling of clips with speed effect
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 3 Oct 2009 12:28:22 +0000 (12:28 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 3 Oct 2009 12:28:22 +0000 (12:28 +0000)
svn path=/trunk/kdenlive/; revision=3983

12 files changed:
src/abstractclipitem.cpp
src/abstractclipitem.h
src/changespeedcommand.cpp
src/changespeedcommand.h
src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/customtrackview.h
src/definitions.h
src/renderer.cpp
src/renderer.h
src/trackview.cpp

index 0e4228659d9fa70970f43d6a68a8410dd526ade5..983d3077ac8f6905ddbb73eeb35e78af6d95165f 100644 (file)
@@ -85,7 +85,7 @@ void AbstractClipItem::updateRectGeometry()
     setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
 }
 
-void AbstractClipItem::resizeStart(int posx, double speed)
+void AbstractClipItem::resizeStart(int posx)
 {
     GenTime durationDiff = GenTime(posx, m_fps) - m_info.startPos;
     if (durationDiff == GenTime()) return;
@@ -100,27 +100,22 @@ void AbstractClipItem::resizeStart(int posx, double speed)
     }
     //kDebug()<<"// DURATION DIFF: "<<durationDiff.frames(25)<<", POS: "<<pos().x();
     m_info.startPos += durationDiff;
-    GenTime originalDiff = GenTime((int)(durationDiff.frames(m_fps) * speed), m_fps);
 
     if (type() == AVWIDGET) {
         m_info.cropStart += durationDiff;
-        m_info.originalcropStart += originalDiff;
     }
-    m_info.cropDuration = m_info.cropDuration - originalDiff;
-
+    m_info.cropDuration = m_info.cropDuration - durationDiff;
     setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
     moveBy(durationDiff.frames(m_fps), 0);
     //setPos(m_startPos.frames(m_fps), pos().y());
     if ((int) scenePos().x() != posx) {
         //kDebug()<<"//////  WARNING, DIFF IN XPOS: "<<pos().x()<<" == "<<m_startPos.frames(m_fps);
         GenTime diff = GenTime((int) pos().x() - posx, m_fps);
-        GenTime originalDiff = GenTime((int)(diff.frames(m_fps) * speed), m_fps);
 
         if (type() == AVWIDGET) {
             m_info.cropStart += diff;
-            m_info.originalcropStart += originalDiff;
         }
-        m_info.cropDuration = m_info.cropDuration - originalDiff;
+        m_info.cropDuration = m_info.cropDuration - diff;
         setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
         //kDebug()<<"// NEW START: "<<m_startPos.frames(25)<<", NW DUR: "<<m_cropDuration.frames(25);
     }
@@ -147,7 +142,7 @@ void AbstractClipItem::resizeStart(int posx, double speed)
         }*/
 }
 
-void AbstractClipItem::resizeEnd(int posx, double speed)
+void AbstractClipItem::resizeEnd(int posx)
 {
     GenTime durationDiff = GenTime(posx, m_fps) - endPos();
     if (durationDiff == GenTime()) return;
@@ -155,7 +150,7 @@ void AbstractClipItem::resizeEnd(int posx, double speed)
         durationDiff = GenTime() - (cropDuration() - GenTime(3, m_fps));
     }
 
-    m_info.cropDuration += GenTime((int)(durationDiff.frames(m_fps) * speed), m_fps);
+    m_info.cropDuration += durationDiff;
 
     setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
     if (durationDiff > GenTime()) {
@@ -167,7 +162,7 @@ void AbstractClipItem::resizeEnd(int posx, double speed)
                 kDebug() << "/////////  CURRENT: " << startPos().frames(25) << "x" << endPos().frames(25) << ", RECT: " << rect() << "-" << pos();
                 kDebug() << "/////////  COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos();*/
                 GenTime diff = ((AbstractClipItem *)item)->startPos() - GenTime(1, m_fps) - startPos();
-                m_info.cropDuration = GenTime((int)(diff.frames(m_fps) * speed), m_fps);
+                m_info.cropDuration = diff;
                 setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
                 break;
             }
index 79072ea5f6ada2dad26879464e40ffb3f4e757e3..eb07f21e03d35fcaff04d4a0f0eaf808b8fdf31f 100644 (file)
@@ -54,8 +54,8 @@ public:
     virtual int track() const ;
     virtual GenTime cropStart() const ;
     virtual GenTime cropDuration() const ;
-    virtual void resizeStart(int posx, double speed = 1.0);
-    virtual void resizeEnd(int posx, double speed = 1.0);
+    virtual void resizeStart(int posx);
+    virtual void resizeEnd(int posx);
     virtual double fps() const;
     virtual void updateFps(double fps);
     virtual GenTime maxDuration() const;
index db488077cca0971833f7be66ad27e490f2406a51..f775c6813c24e0afdd9f211ec319fae0c77c7571 100644 (file)
 
 #include <KLocale>
 
-ChangeSpeedCommand::ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, double old_speed, double new_speed, int old_strobe, int new_strobe, const QString &clipId, QUndoCommand * parent) :
+ChangeSpeedCommand::ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, ItemInfo speedIndependantInfo, double old_speed, double new_speed, int old_strobe, int new_strobe, const QString &clipId, QUndoCommand * parent) :
         QUndoCommand(parent),
         m_view(view),
         m_clipInfo(info),
+        m_speedIndependantInfo(speedIndependantInfo),
         m_clipId(clipId),
         m_old_speed(old_speed),
         m_new_speed(new_speed),
@@ -40,12 +41,12 @@ ChangeSpeedCommand::ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, dou
 // virtual
 void ChangeSpeedCommand::undo()
 {
-    m_view->doChangeClipSpeed(m_clipInfo, m_old_speed, m_new_speed, m_old_strobe, m_clipId);
+    m_view->doChangeClipSpeed(m_clipInfo, m_speedIndependantInfo, m_old_speed, m_new_speed, m_old_strobe, m_clipId);
 }
 // virtual
 void ChangeSpeedCommand::redo()
 {
-    m_view->doChangeClipSpeed(m_clipInfo, m_new_speed, m_old_speed, m_new_strobe, m_clipId);
+    m_view->doChangeClipSpeed(m_clipInfo, m_speedIndependantInfo, m_new_speed, m_old_speed, m_new_strobe, m_clipId);
 }
 
 
index 3f54c8fbe9cf85ce98e6edbe4697b5edad79a9bf..8adb5fc5092c7fde1d508c7f96b9d3546cea6ac5 100644 (file)
@@ -33,13 +33,14 @@ class CustomTrackView;
 class ChangeSpeedCommand : public QUndoCommand
 {
 public:
-    ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, double old_speed, double new_speed, int old_strobe, int new_strobe, const QString &clipId, QUndoCommand * parent = 0);
+    ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, ItemInfo speedIndependantInfo, double old_speed, double new_speed, int old_strobe, int new_strobe, const QString &clipId, QUndoCommand * parent = 0);
     virtual void undo();
     virtual void redo();
 
 private:
     CustomTrackView *m_view;
     ItemInfo m_clipInfo;
+    ItemInfo m_speedIndependantInfo;
     QString m_clipId;
     double m_old_speed;
     double m_new_speed;
index 4ae0514ab1f74460f60d38707366948baf8fdd04..efb4c00c538cc4e28fb54dc04e028a5800376b0b 100644 (file)
@@ -59,6 +59,12 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     setZValue(2);
     setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double)(KdenliveSettings::trackheight() - 2));
     setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1);
+
+    // set speed independant info
+    m_speedIndependantInfo = m_info;
+    m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * m_speed), m_fps);
+    m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * m_speed), m_fps);
+
     m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
     m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
 
@@ -1074,13 +1080,19 @@ void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
 }
 */
 
-void ClipItem::resizeStart(int posx, double /*speed*/)
+void ClipItem::resizeStart(int posx)
 {
     const int min = (startPos() - cropStart()).frames(m_fps);
     if (posx < min) posx = min;
     if (posx == startPos().frames(m_fps)) return;
     const int previous = cropStart().frames(m_fps);
-    AbstractClipItem::resizeStart(posx, m_speed);
+    AbstractClipItem::resizeStart(posx);
+
+    // set speed independant info
+    m_speedIndependantInfo = m_info;
+    m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * m_speed), m_fps);
+    m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * m_speed), m_fps);
+
     if ((int) cropStart().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
             /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
@@ -1089,14 +1101,20 @@ void ClipItem::resizeStart(int posx, double /*speed*/)
     }
 }
 
-void ClipItem::resizeEnd(int posx, double /*speed*/)
+void ClipItem::resizeEnd(int posx)
 {
     const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
     if (posx > max && maxDuration() != GenTime()) posx = max;
     if (posx == endPos().frames(m_fps)) return;
     //kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
     const int previous = cropDuration().frames(m_fps);
-    AbstractClipItem::resizeEnd(posx, m_speed);
+    AbstractClipItem::resizeEnd(posx);
+
+    // set speed independant info
+    m_speedIndependantInfo = m_info;
+    m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * m_speed), m_fps);
+    m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * m_speed), m_fps);
+
     if ((int) cropDuration().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
             /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
@@ -1493,6 +1511,8 @@ void ClipItem::setSpeed(const double speed, const int strobe)
     m_strobe = strobe;
     if (m_speed == 1.0) m_clipName = baseClip()->name();
     else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
+    m_info.cropStart = GenTime((int)(m_speedIndependantInfo.cropStart.frames(m_fps) / m_speed + 0.5), m_fps);
+    m_info.cropDuration = GenTime((int)(m_speedIndependantInfo.cropDuration.frames(m_fps) / m_speed + 0.5), m_fps);
     //update();
 }
 
@@ -1501,19 +1521,20 @@ GenTime ClipItem::maxDuration() const
     return GenTime((int)(m_maxDuration.frames(m_fps) / m_speed + 0.5), m_fps);
 }
 
-GenTime ClipItem::cropStart() const
+GenTime ClipItem::speedIndependantCropStart() const
 {
-    return GenTime((int)(m_info.originalcropStart.frames(m_fps) / m_speed + 0.5), m_fps);
+    return m_speedIndependantInfo.cropStart;
 }
 
-GenTime ClipItem::cropDuration() const
+GenTime ClipItem::speedIndependantCropDuration() const
 {
-    return GenTime((int)(m_info.cropDuration.frames(m_fps) / m_speed + 0.5), m_fps);
+    return m_speedIndependantInfo.cropDuration;
 }
 
-GenTime ClipItem::endPos() const
+
+const ItemInfo ClipItem::speedIndependantInfo() const
 {
-    return m_info.startPos + cropDuration();
+    return m_speedIndependantInfo;
 }
 
 //virtual
index 56bbd77a3b378669f4a4c3dd7645dd438d9bb2cb..70b1aee6cdd90fd3896f1f835b11fe1ace2cf184 100644 (file)
@@ -47,8 +47,8 @@ public:
                        const QStyleOptionGraphicsItem *option,
                        QWidget *);
     virtual int type() const;
-    void resizeStart(int posx, double speed = 1.0);
-    void resizeEnd(int posx, double speed = 1.0);
+    void resizeStart(int posx);
+    void resizeEnd(int posx);
     OPERATIONTYPE operationMode(QPointF pos);
     const QString clipProducer() const;
     int clipType() const;
@@ -101,9 +101,9 @@ public:
     double speed() const;
     int strobe() const;
     GenTime maxDuration() const;
-    GenTime cropStart() const;
-    GenTime endPos() const;
-    GenTime cropDuration() const;
+    GenTime speedIndependantCropStart() const;
+    GenTime speedIndependantCropDuration() const;
+    const ItemInfo speedIndependantInfo() const;
     int hasEffect(const QString &tag, const QString &id) const;
     bool checkKeyFrames();
     QPixmap startThumb() const;
@@ -126,6 +126,7 @@ protected:
 
 private:
     DocClipBase *m_clip;
+    ItemInfo m_speedIndependantInfo;
     QString m_producer;
     CLIPTYPE m_clipType;
     QString m_clipName;
index 51887871eec419637eb78c81808eb63944479923..8ea76bc2bb2e8498217bf07776031c9877d994c6 100644 (file)
@@ -1270,7 +1270,6 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
         info.cropStart = GenTime(list.at(1).toInt(), m_document->fps());
         info.endPos = GenTime(list.at(2).toInt() - list.at(1).toInt(), m_document->fps());
         info.cropDuration = info.endPos - info.startPos;
-        info.originalcropStart = info.cropStart;
         info.track = 0;
 
         // Check if clip can be inserted at that position
@@ -1406,11 +1405,10 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
                 emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
                 return;
             }
-            ItemInfo info = clip->info();
             double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
             int strobe = EffectsList::parameter(effect, "strobe").toInt();
             if (strobe == 0) strobe = 1;
-            doChangeClipSpeed(info, speed, 1.0, strobe, clip->baseClip()->getId());
+            doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, 1.0, strobe, clip->baseClip()->getId());
             EffectsParameterList params = clip->addEffect(effect);
             m_document->renderer()->mltAddEffect(track, pos, params);
             if (clip->isSelected()) emit clipItemSelected(clip);
@@ -1435,8 +1433,7 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect)
     if (effect.attribute("id") == "speed") {
         ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
         if (clip) {
-            ItemInfo info = clip->info();
-            doChangeClipSpeed(info, 1.0, clip->speed(), 1, clip->baseClip()->getId());
+            doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
             clip->deleteEffect(index);
             emit clipItemSelected(clip);
             m_document->renderer()->mltRemoveEffect(track, pos, index, true);
@@ -1571,13 +1568,12 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (clip) {
         // Special case: speed effect
         if (effect.attribute("id") == "speed") {
-            ItemInfo info = clip->info();
-            if (effect.attribute("disabled") == "1") doChangeClipSpeed(info, 1.0, clip->speed(), 1, clip->baseClip()->getId());
+            if (effect.attribute("disabled") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
             else {
                 double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
                 int strobe = EffectsList::parameter(effect, "strobe").toInt();
                 if (strobe == 0) strobe = 1;
-                doChangeClipSpeed(info, speed, clip->speed(), strobe, clip->baseClip()->getId());
+                doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
             }
             clip->setEffectAt(ix, effect);
             if (ix == clip->selectedEffectIndex()) {
@@ -1692,8 +1688,7 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut)
         newPos.endPos = info.endPos;
         newPos.cropStart = item->info().cropStart + (cutTime - info.startPos);
         newPos.track = info.track;
-        newPos.cropDuration = GenTime((int)((newPos.endPos - newPos.startPos).frames(m_document->fps()) * speed), m_document->fps());
-        newPos.originalcropStart = GenTime((int)(newPos.cropStart .frames(m_document->fps()) * speed), m_document->fps());
+        newPos.cropDuration = newPos.endPos - newPos.startPos;
 
 
         ClipItem *dup = item->clone(newPos);
@@ -1708,7 +1703,7 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut)
             QDomElement oldeffect = item->effectAt(ix);
             dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
         }
-        item->resizeEnd(cutPos, false);
+        item->resizeEnd(cutPos);
         scene()->addItem(dup);
         if (item->checkKeyFrames()) slotRefreshEffects(item);
         if (dup->checkKeyFrames()) slotRefreshEffects(dup);
@@ -3205,7 +3200,7 @@ void CustomTrackView::changeClipSpeed()
     else delete changeSelected;
 }
 
-void CustomTrackView::doChangeClipSpeed(ItemInfo info, const double speed, const double oldspeed, int strobe, const QString &id)
+void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
 {
     DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
     ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
@@ -3215,12 +3210,13 @@ void CustomTrackView::doChangeClipSpeed(ItemInfo info, const double speed, const
         return;
     }
     info.track = m_document->tracksCount() - item->track();
-    int endPos = m_document->renderer()->mltChangeClipSpeed(info, speed, oldspeed, strobe, baseclip->producer());
+    int endPos = m_document->renderer()->mltChangeClipSpeed(info, speedIndependantInfo, speed, oldspeed, strobe, baseclip->producer());
     if (endPos >= 0) {
         item->setSpeed(speed, strobe);
         item->updateRectGeometry();
-        if (item->cropDuration().frames(m_document->fps()) > endPos)
-            item->AbstractClipItem::resizeEnd(info.startPos.frames(m_document->fps()) + endPos, speed);
+        if (item->cropDuration().frames(m_document->fps()) != endPos) {
+            item->resizeEnd((int) info.startPos.frames(m_document->fps()) + endPos - 1);
+        }
         updatePositionEffects(item, info);
         setDocumentModified();
     } else emit displayMessage(i18n("Invalid clip"), ErrorMessage);
@@ -4507,7 +4503,7 @@ void CustomTrackView::setOutPoint()
     ItemInfo startInfo = clip->info();
     ItemInfo endInfo = clip->info();
     endInfo.endPos = GenTime(m_cursorPos, m_document->fps());
-    CLIPTYPE type = (CLIPTYPE) static_cast <ClipItem *> (clip)->clipType();
+    CLIPTYPE type = (CLIPTYPE) static_cast <ClipItem *>(clip)->clipType();
     if (endInfo.endPos <= startInfo.startPos || (type != IMAGE && type != COLOR && type != TEXT && endInfo.endPos > startInfo.startPos + clip->maxDuration() - startInfo.cropStart)) {
         // Check for invalid resize
         emit displayMessage(i18n("Invalid action"), ErrorMessage);
@@ -4515,7 +4511,7 @@ void CustomTrackView::setOutPoint()
     } else if (endInfo.endPos > startInfo.endPos) {
         int length = m_document->renderer()->mltGetSpaceLength(startInfo.endPos, m_document->tracksCount() - startInfo.track, false);
         if ((clip->type() == TRANSITIONWIDGET && itemCollision(clip, endInfo) == true) || (clip->type() == AVWIDGET && length != -1 && length < (endInfo.endPos - startInfo.endPos).frames(m_document->fps()))) {
-            kDebug()<<" RESIZE ERROR, BLNK: "<<length<<", RESIZE: "<<(endInfo.endPos - startInfo.endPos).frames(m_document->fps());
+            kDebug() << " RESIZE ERROR, BLNK: " << length << ", RESIZE: " << (endInfo.endPos - startInfo.endPos).frames(m_document->fps());
             emit displayMessage(i18n("Invalid action"), ErrorMessage);
             return;
         }
index e62b15d77e1e59c7ef7bb17979128fa843b596cf..2e1633f059402900664e3b4b2df276d5b2b749f0 100644 (file)
@@ -96,7 +96,7 @@ public:
     void clipStart();
     void clipEnd();
     void changeClipSpeed();
-    void doChangeClipSpeed(ItemInfo info, const double speed, const double oldspeed, int strobe, const QString &id);
+    void doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id);
     void setDocumentModified();
     void setInPoint();
     void setOutPoint();
index 57f67c7077c30cd2f46e3e79c73d01dae16338f7..7b72a88adc108083b6aee7bb74c9ba85f6b4ef02 100644 (file)
@@ -66,11 +66,9 @@ struct ItemInfo {
     GenTime startPos;
     /** endPos is the duration where the clip ends on the track */
     GenTime endPos;
-    /** originalcropStart is the position where the sub-clip starts, relative to the clip's 0 position. Doe not depend on speed */
-    GenTime originalcropStart;
-    /** cropStart is the position where the sub-clip starts, depend on effects (speed,...) */
+    /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
     GenTime cropStart;
-    /** cropDuration is the duration of the clip, does not depend on speed */
+    /** cropDuration is the duration of the clip */
     GenTime cropDuration;
     int track;
 };
index 93d2a2b8633ef0edb159f3285d772dc0f215e71e..908472ed2bbeb0a11fb386e7547c7144a1f349e9 100644 (file)
@@ -1991,7 +1991,7 @@ void Render::mltPasteEffects(Mlt::Producer *source, Mlt::Producer *dest)
     }
 }
 
-int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int strobe, Mlt::Producer *prod)
+int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, double speed, double oldspeed, int strobe, Mlt::Producer *prod)
 {
     m_isBlocked = true;
     int newLength = 0;
@@ -2077,12 +2077,11 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int
         int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
 
         Mlt::Producer *cut;
-        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) {
+        int originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps));
+        if (clipIndex + 1 < trackPlaylist.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));
-        } else cut = prod->cut(originalStart, (int)(originalStart + info.cropDuration.frames(m_fps)) - 1);
+        } else cut = prod->cut(originalStart, (int)(originalStart + speedIndependantInfo.cropDuration.frames(m_fps)) - 1);
 
         // move all effects to the correct producer
         mltPasteEffects(clip, cut);
@@ -2116,8 +2115,8 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int
         Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
         trackPlaylist.consolidate_blanks(0);
 
-        GenTime duration = info.cropDuration / speed;
-        int originalStart = (int)(info.originalcropStart.frames(m_fps) / speed);
+        GenTime duration = speedIndependantInfo.cropDuration / speed;
+        int originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps) / speed);
 
         // Check that the blank space is long enough for our new duration
         clipIndex = trackPlaylist.get_clip_index_at(startPos);
index c4d683efbaa1c5c6c62703ed11f11afe7685a519..c7d308ea6a3bc0209a9de497c9d7c83544ef5b98 100644 (file)
@@ -211,7 +211,7 @@ Q_OBJECT public:
     to the clip and 0.6 is the speed in percents. The newly created producer will have it's
     "id" parameter set to: "slowmotion:parentid:speed", where parentid is the id of the original clip
     in the ClipManager list and speed is the current speed */
-    int mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int strobe, Mlt::Producer *prod);
+    int mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, double speed, double oldspeed, int strobe, Mlt::Producer *prod);
 
     const QList <Mlt::Producer *> producersList();
     void updatePreviewSettings();
index c18b1678baf96c9b0b5fe3885d32271bde75bc45..5d852ec5cb043a6cb92ebf0075726eab00f79811 100644 (file)
@@ -570,8 +570,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                 clipinfo.startPos = GenTime(position, m_doc->fps());
                 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
                 clipinfo.cropStart = GenTime(in, m_doc->fps());
-                clipinfo.cropDuration = GenTime((int)((clipinfo.endPos - clipinfo.startPos).frames(m_doc->fps()) * speed + 0.5), m_doc->fps());
-                clipinfo.originalcropStart = GenTime((int)((clipinfo.cropStart).frames(m_doc->fps()) * speed + 0.5), m_doc->fps());
+                clipinfo.cropDuration = clipinfo.endPos - clipinfo.startPos;
 
                 clipinfo.track = ix;
                 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();