From 0afc8ed1eb6eecdb6623acde765b5e24b01e2c8b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 22 Dec 2012 22:28:51 +0100 Subject: [PATCH] Fix 1 frame offset in image / color clips, fix changing duration of image/color clips --- src/clipmanager.cpp | 6 +++--- src/docclipbase.cpp | 8 +++++--- src/projectitem.cpp | 1 + src/projectlist.cpp | 9 +++++---- src/renderer.cpp | 15 +++++++++++---- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 48605009..8ae95fbf 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -574,7 +574,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, QMap if (type->name().startsWith("image/")) { prod.setAttribute("type", (int) IMAGE); prod.setAttribute("in", 0); - prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration())); + prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()) - 1); if (KdenliveSettings::autoimagetransparency()) prod.setAttribute("transparency", 1); // Read EXIF metadata for JPEG if (type->is("image/jpeg")) { @@ -612,7 +612,7 @@ void ClipManager::slotAddClipList(const KUrl::List urls, QMap if (out > 0) prod.setAttribute("out", out); else - prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration())); + prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::title_duration()) - 1); } else txtfile.close(); } @@ -659,7 +659,7 @@ void ClipManager::slotAddColorClipFile(const QString &name, const QString &color uint id = m_clipIdCounter++; prod.setAttribute("id", QString::number(id)); prod.setAttribute("in", "0"); - prod.setAttribute("out", m_doc->getFramePos(duration)); + prod.setAttribute("out", m_doc->getFramePos(duration) - 1); prod.setAttribute("name", name); if (!group.isEmpty()) { prod.setAttribute("groupname", group); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index daeb6a57..a96f7f28 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -90,7 +90,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin } else { int out = xml.attribute("out").toInt(); int in = xml.attribute("in").toInt(); - setDuration(GenTime(out - in, KdenliveSettings::project_fps())); + setDuration(GenTime(out - in + 1, KdenliveSettings::project_fps())); } if (!m_properties.contains("name")) m_properties.insert("name", url.fileName()); @@ -1084,8 +1084,10 @@ void DocClipBase::setProperty(const QString &key, const QString &value) if (key == "resource") { getFileHash(value); if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash")); - } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps())); //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt()); + } else if (key == "out") { + setDuration(GenTime(value.toInt() + 1, KdenliveSettings::project_fps())); + } else if (key == "colour") { setProducerProperty("colour", value.toUtf8().data()); } else if (key == "templatetext") { @@ -1317,7 +1319,7 @@ const QString DocClipBase::geometryWithOffset(QString data, int offset) if (offset == 0) return data; Mlt::Profile *profile = m_baseTrackProducers.at(0)->profile(); Mlt::Geometry geometry(data.toUtf8().data(), m_properties.value("duration").toInt(), profile->width(), profile->height()); - Mlt::Geometry newgeometry("", m_properties.value("duration").toInt(), profile->width(), profile->height()); + Mlt::Geometry newgeometry(NULL, m_properties.value("duration").toInt(), profile->width(), profile->height()); Mlt::GeometryItem item; int pos = 0; while (!geometry.next_key(&item, pos)) { diff --git a/src/projectitem.cpp b/src/projectitem.cpp index c26f5ce9..d1508f2e 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -74,6 +74,7 @@ void ProjectItem::buildItem(QSize pixmapSize) default: setData(0, Qt::DecorationRole, KIcon("video-x-generic").pixmap(pixmapSize)); } + if (m_clipType != UNKNOWN) slotSetToolTip(); setText(0, name); setText(1, m_clip->description()); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 12b19abe..35f02b11 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -715,10 +715,11 @@ void ProjectList::slotReloadClip(const QString &id) QDomElement e = item->toXml(); // Make sure we get the correct producer length if it was adjusted in timeline if (t == COLOR || t == IMAGE || t == SLIDESHOW || t == TEXT) { - int length = QString(clip->producerProperty("length")).toInt(); - if (length > 0 && !e.hasAttribute("length")) { - e.setAttribute("length", length); - } + int length = QString(clip->producerProperty("length")).toInt(); + if (length > 0 && !e.hasAttribute("length")) { + e.setAttribute("length", length); + } + e.setAttribute("duration", clip->getProperty("duration")); } resetThumbsProducer(clip); m_render->getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true); diff --git a/src/renderer.cpp b/src/renderer.cpp index 849dd873..85ee9276 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -815,9 +815,17 @@ void Render::processFileProperties() length = info.xml.attribute("length").toInt(); clipOut = length - 1; } - else length = info.xml.attribute("out").toInt() - info.xml.attribute("in").toInt(); - producer->set("length", length); - duration = length; + else length = info.xml.attribute("out").toInt() - info.xml.attribute("in").toInt() + 1; + // Pass duration if it was forced + if (info.xml.hasAttribute("duration")) { + duration = info.xml.attribute("duration").toInt(); + if (length < duration) { + length = duration; + if (clipOut > 0) clipOut = length - 1; + } + } + if (duration == 0) duration = length; + producer->set("length", length); } if (clipOut > 0) producer->set_in_and_out(info.xml.attribute("in").toInt(), clipOut); @@ -1590,7 +1598,6 @@ void Render::switchPlay(bool play) } else if (!play) { m_paused = true; m_mltProducer->set_speed(0.0); - //m_mltProducer->pause(); } } -- 2.39.2