#include <KIO/NetAccess>
#include <KStandardDirs>
+#include <KApplication>
#include <KDebug>
#include <QCryptographicHash>
#include <QtConcurrentRun>
#include <cstdio>
+#include <kmessagebox.h>
DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) :
QObject(),
} 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());
QList < GenTime > DocClipBase::snapMarkers() const
{
QList < GenTime > markers;
-
for (int count = 0; count < m_snapMarkers.count(); ++count) {
markers.append(m_snapMarkers.at(count).time());
}
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") {
return m_thumbProd->extractImage(frame, width, height);
}
-void DocClipBase::setAnalysisData(const QString &name, const QString &data)
+void DocClipBase::setAnalysisData(const QString &name, const QString &data, int offset)
{
if (data.isEmpty()) m_analysisdata.remove(name);
else {
if (m_analysisdata.contains(name)) {
- int i = 1;
- QString newname = name + " " + QString::number(i);
- while (m_analysisdata.contains(newname)) {
- i++;
- newname = name + " " + QString::number(i);
+ if (KMessageBox::questionYesNo(kapp->activeWindow(), i18n("Clip already contains analysis data %1", name), QString(), KGuiItem(i18n("Merge")), KGuiItem(i18n("Add"))) == KMessageBox::Yes) {
+ // Merge data
+ Mlt::Profile *profile = m_baseTrackProducers.at(0)->profile();
+ Mlt::Geometry geometry(m_analysisdata.value(name).toUtf8().data(), m_properties.value("duration").toInt(), profile->width(), profile->height());
+ Mlt::Geometry newGeometry(data.toUtf8().data(), m_properties.value("duration").toInt(), profile->width(), profile->height());
+ Mlt::GeometryItem item;
+ int pos = 0;
+ while (!newGeometry.next_key(&item, pos)) {
+ pos = item.frame();
+ item.frame(pos + offset);
+ pos++;
+ geometry.insert(item);
+ }
+ m_analysisdata.insert(name, geometry.serialise());
+ }
+ else {
+ // Add data with another name
+ int i = 1;
+ QString newname = name + " " + QString::number(i);
+ while (m_analysisdata.contains(newname)) {
+ i++;
+ newname = name + " " + QString::number(i);
+ }
+ m_analysisdata.insert(newname, geometryWithOffset(data, offset));
}
- m_analysisdata.insert(newname, data);
}
- else m_analysisdata.insert(name, data);
+ else m_analysisdata.insert(name, geometryWithOffset(data, offset));
+ }
+}
+
+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(NULL, m_properties.value("duration").toInt(), profile->width(), profile->height());
+ Mlt::GeometryItem item;
+ int pos = 0;
+ while (!geometry.next_key(&item, pos)) {
+ pos = item.frame();
+ item.frame(pos + offset);
+ pos++;
+ newgeometry.insert(item);
}
+ return newgeometry.serialise();
}
QMap <QString, QString> DocClipBase::analysisData() const