]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Progress on stopmotion widget (make it possible to switch between HDMI and V4L)
[kdenlive] / src / clipitem.cpp
index f05103fc281bf973883d0ab79ab48396ccfd864f..b5791614e831521330c41372cb969fc936ae16dc 100644 (file)
@@ -61,7 +61,8 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1);
 
     // set speed independant info
-    if (m_speed <= 0 && m_speed > -1) m_speed = 1.0;
+    if (m_speed <= 0 && m_speed > -1)
+        m_speed = -1.0;
     m_speedIndependantInfo = m_info;
     m_speedIndependantInfo.cropStart = GenTime((int)(m_info.cropStart.frames(m_fps) * qAbs(m_speed)), m_fps);
     m_speedIndependantInfo.cropDuration = GenTime((int)(m_info.cropDuration.frames(m_fps) * qAbs(m_speed)), m_fps);
@@ -69,10 +70,11 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
     m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
 
-    if (m_speed == 1.0) m_clipName = m_clip->name();
-    else {
+    if (m_speed == 1.0)
+        m_clipName = m_clip->name();
+    else
         m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
-    }
+
     m_producer = m_clip->getId();
     m_clipType = m_clip->clipType();
     //m_cropStart = info.cropStart;
@@ -1420,14 +1422,8 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
 
     // special case: the affine effect needs in / out points
     if (effectId == "pan_zoom") {
-        int start = cropStart().frames(m_fps);
-        int end = (cropStart() + cropDuration()).frames(m_fps);
-        if (start < 0) {
-            end -= start;
-            start = 0;
-        }
-        parameters.addParam("in", QString::number(start));
-        parameters.addParam("out", QString::number(end));
+        parameters.addParam("in", QString::number(cropStart().frames(m_fps)));
+        parameters.addParam("out", QString::number((cropStart() + cropDuration()).frames(m_fps)));
     }
 
     QDomNodeList params = effect.elementsByTagName("parameter");
@@ -1440,8 +1436,8 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
                 double factor = e.attribute("factor", "1").toDouble();
                 if (factor != 1) {
                     for (int j = 0; j < values.count(); j++) {
-                        QString pos = values.at(j).section(":", 0, 0);
-                        double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+                        QString pos = values.at(j).section(':', 0, 0);
+                        double val = values.at(j).section(':', 1, 1).toDouble() / factor;
                         values[j] = pos + "=" + QString::number(val);
                     }
                 }
@@ -1584,7 +1580,7 @@ void ClipItem::setSpeed(const double speed, const int strobe)
 {
     m_speed = speed;
     if (m_speed <= 0 && m_speed > -1)
-        m_speed = 1.0;
+        m_speed = -1.0;
     m_strobe = strobe;
     if (m_speed == 1.0) m_clipName = baseClip()->name();
     else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
@@ -1790,10 +1786,6 @@ QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
 
                 int in = cropStart().frames(fps());
                 int out = in + cropDuration().frames(fps());
-                if (in < 0) {
-                    out -= in;
-                    in = 0;
-                }
                 int dur = out - in - 1;
 
                 effect.setAttribute("in", in);
@@ -1852,4 +1844,14 @@ QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
     return effectPositions;
 }
 
+Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
+{
+    if (isAudioOnly())
+        return m_clip->audioProducer(track);
+    else if (isVideoOnly())
+        return m_clip->videoProducer();
+    else
+        return m_clip->producer(trackSpecific ? track : -1);
+}
+
 #include "clipitem.moc"