From 1b28a1f6120bc1c38750aab05c059bc8210b6418 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 16 Jan 2014 21:43:54 +0100 Subject: [PATCH] Use = instead of : as position/value separator in keyframes. The reason is simple; MLT interprets colons as part of the timecode, so this messes up keyframing for some effects. --- src/clipitem.cpp | 58 ++++++++++++++++++++--------------------- src/customtrackview.cpp | 18 ++++++------- src/keyframeedit.cpp | 12 ++++----- src/renderer.cpp | 12 ++++----- src/trackview.cpp | 8 +++--- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index a4d582ff..0e94f1bf 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -263,7 +263,7 @@ void ClipItem::initEffect(QDomElement effect, int diff, int offset) if (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") { if (e.attribute("keyframes").isEmpty()) { // Effect has a keyframe type parameter, we need to set the values - e.setAttribute("keyframes", QString::number((int) cropStart().frames(m_fps)) + ':' + e.attribute("default")); + e.setAttribute("keyframes", QString::number((int) cropStart().frames(m_fps)) + '=' + e.attribute("default")); } else if (offset != 0) { // adjust keyframes to this clip @@ -344,8 +344,8 @@ const QString ClipItem::adjustKeyframes(const QString &keyframes, int offset) // Simple keyframes const QStringList list = keyframes.split(QLatin1Char(';'), QString::SkipEmptyParts); foreach(const QString &keyframe, list) { - const int pos = keyframe.section(':', 0, 0).toInt() - offset; - const QString newKey = QString::number(pos) + ":" + keyframe.section(':', 1); + const int pos = keyframe.section('=', 0, 0).toInt() - offset; + const QString newKey = QString::number(pos) + "=" + keyframe.section('=', 1); result.append(newKey); } return result.join(";"); @@ -378,8 +378,8 @@ bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int c // go through all keyframes for one param foreach(const QString &str, keyframes) { - int pos = str.section(':', 0, 0).toInt(); - double val = locale.toDouble(str.section(':', 1, 1)); + int pos = str.section('=', 0, 0).toInt(); + double val = locale.toDouble(str.section('=', 1, 1)); if (pos - start < 0) { // a keyframe is defined before the start of the clip cutKeyFrame = true; @@ -389,7 +389,7 @@ bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int c int diff = pos - lastPos; double ratio = (double)(start - lastPos) / diff; int newValue = lastValue + (val - lastValue) * ratio; - newKeyFrames.append(QString::number(start) + ':' + QString::number(newValue)); + newKeyFrames.append(QString::number(start) + '=' + QString::number(newValue)); modified = true; } cutKeyFrame = false; @@ -401,12 +401,12 @@ bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int c if (diff != 0) { double ratio = (double)(end - lastPos) / diff; int newValue = lastValue + (val - lastValue) * ratio; - newKeyFrames.append(QString::number(end) + ':' + QString::number(newValue)); + newKeyFrames.append(QString::number(end) + '=' + QString::number(newValue)); modified = true; } break; } else { - newKeyFrames.append(QString::number(pos) + ':' + QString::number(val)); + newKeyFrames.append(QString::number(pos) + '=' + QString::number(val)); } } lastPos = pos; @@ -450,8 +450,8 @@ void ClipItem::setKeyframes(const int ix, const QStringList &keyframes) // parse keyframes const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); foreach(const QString &str, keyframes) { - int pos = str.section(':', 0, 0).toInt(); - double val = locale.toDouble(str.section(':', 1, 1)); + int pos = str.section('=', 0, 0).toInt(); + double val = locale.toDouble(str.section('=', 1, 1)); m_keyframes[pos] = val; } if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1; @@ -487,8 +487,8 @@ void ClipItem::setSelectedEffect(const int ix) // parse keyframes const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); foreach(const QString &str, keyframes) { - int pos = str.section(':', 0, 0).toInt(); - double val = locale.toDouble(str.section(':', 1, 1)); + int pos = str.section('=', 0, 0).toInt(); + double val = locale.toDouble(str.section('=', 1, 1)); m_keyframes[pos] = val; } if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) @@ -548,7 +548,7 @@ void ClipItem::updateKeyframeEffect() if (m_keyframes.count() > 0) { QMap::const_iterator i = m_keyframes.constBegin(); while (i != m_keyframes.constEnd()) { - keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';'); + keyframes.append(QString::number(i.key()) + '=' + QString::number(i.value()) + ';'); ++i; } } @@ -1654,8 +1654,8 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/) double offset = e.attribute("offset", "0").toDouble(); if (factor != 1 || offset != 0) { for (int j = 0; j < values.count(); j++) { - QString pos = values.at(j).section(':', 0, 0); - double val = (locale.toDouble(values.at(j).section(':', 1, 1)) - offset) / factor; + QString pos = values.at(j).section('=', 0, 0); + double val = (locale.toDouble(values.at(j).section('=', 1, 1)) - offset) / factor; values[j] = pos + '=' + locale.toString(val); } } @@ -1906,24 +1906,24 @@ void ClipItem::insertKeyframe(QDomElement effect, int pos, int val) QStringList newkfr; bool added = false; foreach(const QString &str, keyframes) { - int kpos = str.section(':', 0, 0).toInt(); - double newval = locale.toDouble(str.section(':', 1, 1)); + int kpos = str.section('=', 0, 0).toInt(); + double newval = locale.toDouble(str.section('=', 1, 1)); if (kpos < pos) { newkfr.append(str); } else if (!added) { if (i == m_visibleParam) - newkfr.append(QString::number(pos) + ':' + QString::number(val)); + newkfr.append(QString::number(pos) + '=' + QString::number(val)); else - newkfr.append(QString::number(pos) + ':' + locale.toString(newval)); + newkfr.append(QString::number(pos) + '=' + locale.toString(newval)); if (kpos > pos) newkfr.append(str); added = true; } else newkfr.append(str); } if (!added) { if (i == m_visibleParam) - newkfr.append(QString::number(pos) + ':' + QString::number(val)); + newkfr.append(QString::number(pos) + '=' + QString::number(val)); else - newkfr.append(QString::number(pos) + ':' + e.attribute("default")); + newkfr.append(QString::number(pos) + '=' + e.attribute("default")); } e.setAttribute("keyframes", newkfr.join(";")); } @@ -1945,15 +1945,15 @@ void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts); QStringList newkfr; foreach(const QString &str, keyframes) { - if (str.section(':', 0, 0).toInt() != oldpos) { + if (str.section('=', 0, 0).toInt() != oldpos) { newkfr.append(str); } else if (newpos != -1) { newpos = qMax(newpos, start); newpos = qMin(newpos, end); if (i == m_visibleParam) - newkfr.append(QString::number(newpos) + ':' + locale.toString(value)); + newkfr.append(QString::number(newpos) + '=' + locale.toString(value)); else - newkfr.append(QString::number(newpos) + ':' + str.section(':', 1, 1)); + newkfr.append(QString::number(newpos) + '=' + str.section('=', 1, 1)); } } e.setAttribute("keyframes", newkfr.join(";")); @@ -1978,8 +1978,8 @@ void ClipItem::updateKeyframes(QDomElement effect) m_limitedKeyFrames = e.attribute("type") == "keyframe"; const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); foreach(const QString &str, keyframes) { - int pos = str.section(':', 0, 0).toInt(); - double val = locale.toDouble(str.section(':', 1, 1)); + int pos = str.section('=', 0, 0).toInt(); + double val = locale.toDouble(str.section('=', 1, 1)); m_keyframes[pos] = val; } if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1; @@ -2090,13 +2090,13 @@ bool ClipItem::updateNormalKeyframes(QDomElement parameter, ItemInfo oldInfo) const QStringList data = parameter.attribute("keyframes").split(';', QString::SkipEmptyParts); QMap keyframes; foreach (QString keyframe, data) { - int keyframepos = keyframe.section(':', 0, 0).toInt(); + int keyframepos = keyframe.section('=', 0, 0).toInt(); // if keyframe was at clip start, update it if (keyframepos == oldin) { keyframepos = in; keyFrameUpdated = true; } - keyframes[keyframepos] = locale.toDouble(keyframe.section(':', 1, 1)); + keyframes[keyframepos] = locale.toDouble(keyframe.section('=', 1, 1)); } @@ -2153,7 +2153,7 @@ bool ClipItem::updateNormalKeyframes(QDomElement parameter, ItemInfo oldInfo) QString newkfr; QMap::const_iterator k = keyframes.constBegin(); while (k != keyframes.constEnd()) { - newkfr.append(QString::number(k.key()) + ':' + QString::number(qRound(k.value())) + ';'); + newkfr.append(QString::number(k.key()) + '=' + QString::number(qRound(k.value())) + ';'); ++k; } parameter.setAttribute("keyframes", newkfr); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 8786d494..51e119a1 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -6271,13 +6271,13 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime QStringList keys = e.attribute("keyframes").split(';', QString::SkipEmptyParts); QStringList newKeyFrames; foreach(const QString &str, keys) { - int pos = str.section(':', 0, 0).toInt(); - double val = str.section(':', 1, 1).toDouble(); + int pos = str.section('=', 0, 0).toInt(); + double val = str.section('=', 1, 1).toDouble(); pos += diff; if (pos > max) { - newKeyFrames.append(QString::number(max) + ':' + locale.toString(val)); + newKeyFrames.append(QString::number(max) + '=' + locale.toString(val)); break; - } else newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val)); + } else newKeyFrames.append(QString::number(pos) + '=' + locale.toString(val)); } //kDebug()<<"ORIGIN: "< 1) result.append(key.section(':', 0, 1)); + if (key.count('=') > 1) result.append(key.section('=', 0, 1)); else result.append(key); result.append(';'); } } else { foreach(QString key, keyframeList) { - result.append(key.section(':', 0, 0)); + result.append(key.section('=', 0, 0)); result.append(';'); } } } else if (ui.import_size->isChecked()) { foreach(QString key, keyframeList) { - result.append(key.section(':', 1, 1)); + result.append(key.section('=', 1, 1)); result.append(';'); } } diff --git a/src/keyframeedit.cpp b/src/keyframeedit.cpp index a7e157ff..85965c34 100644 --- a/src/keyframeedit.cpp +++ b/src/keyframeedit.cpp @@ -128,13 +128,13 @@ void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe) QStringList frames = e.attribute("keyframes").split(';', QString::SkipEmptyParts); for (int i = 0; i < frames.count(); ++i) { - int frame = frames.at(i).section(':', 0, 0).toInt(); + int frame = frames.at(i).section('=', 0, 0).toInt(); bool found = false; int j; for (j = 0; j < keyframe_list->rowCount(); j++) { int currentPos = getPos(j); if (frame == currentPos) { - keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1))); + keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); found = true; break; } else if (currentPos > frame) { @@ -144,7 +144,7 @@ void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe) if (!found) { keyframe_list->insertRow(j); keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(getPosString(frame))); - keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section(':', 1, 1))); + keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); keyframe_list->resizeRowToContents(j); } if ((activeKeyframe > -1) && (activeKeyframe == frame)) { @@ -251,7 +251,7 @@ void KeyframeEdit::slotGenerateParams(int row, int column) QString keyframes; for (int i = 0; i < keyframe_list->rowCount(); ++i) { if (keyframe_list->item(i, col)) - keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, col)->text() + ';'); + keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, col)->text() + ';'); } m_params[col].setAttribute("keyframes", keyframes); } @@ -289,7 +289,7 @@ void KeyframeEdit::slotGenerateParams(int row, int column) QString keyframes; for (int i = 0; i < keyframe_list->rowCount(); ++i) { if (keyframe_list->item(i, column)) - keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, column)->text() + ';'); + keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, column)->text() + ';'); } m_params[column].setAttribute("keyframes", keyframes); emit parameterChanged(); @@ -301,7 +301,7 @@ void KeyframeEdit::generateAllParams() QString keyframes; for (int i = 0; i < keyframe_list->rowCount(); ++i) { if (keyframe_list->item(i, col)) - keyframes.append(QString::number(getPos(i)) + ':' + keyframe_list->item(i, col)->text() + ';'); + keyframes.append(QString::number(getPos(i)) + '=' + keyframe_list->item(i, col)->text() + ';'); } m_params[col].setAttribute("keyframes", keyframes); } diff --git a/src/renderer.cpp b/src/renderer.cpp index 880a9653..75cfa7e6 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -2963,8 +2963,8 @@ bool Render::addFilterToService(Mlt::Service service, EffectsParameterList param Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, qstrdup(tag.toUtf8().constData())); if (filter && filter->is_valid()) { filter->set("kdenlive_id", qstrdup(params.paramValue("id").toUtf8().constData())); - int x1 = keyFrames.at(0).section(':', 0, 0).toInt(); - double y1 = keyFrames.at(0).section(':', 1, 1).toDouble(); + int x1 = keyFrames.at(0).section('=', 0, 0).toInt(); + double y1 = keyFrames.at(0).section('=', 1, 1).toDouble(); for (int j = 0; j < params.count(); j++) { filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData()); } @@ -2983,10 +2983,10 @@ bool Render::addFilterToService(Mlt::Service service, EffectsParameterList param Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, qstrdup(tag.toUtf8().constData())); if (filter && filter->is_valid()) { filter->set("kdenlive_id", qstrdup(params.paramValue("id").toUtf8().constData())); - int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset; - double y1 = keyFrames.at(i).section(':', 1, 1).toDouble(); - int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt(); - double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble(); + int x1 = keyFrames.at(i).section('=', 0, 0).toInt() + offset; + double y1 = keyFrames.at(i).section('=', 1, 1).toDouble(); + int x2 = keyFrames.at(i + 1).section('=', 0, 0).toInt(); + double y2 = keyFrames.at(i + 1).section('=', 1, 1).toDouble(); if (x2 == -1) x2 = duration; for (int j = 0; j < params.count(); j++) { diff --git a/src/trackview.cpp b/src/trackview.cpp index 6209421c..cffa2a52 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -854,8 +854,8 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo // add first keyframe if (effectout <= effectin) { // there is only one keyframe - keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';'); - } else keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';'); + keyframes.append(QString::number(effectin) + '=' + locale.toString(startvalue) + ';'); + } else keyframes.append(QString::number(effectin) + '=' + locale.toString(startvalue) + ';' + QString::number(effectout) + '=' + QString::number(endvalue) + ';'); QDomNode lastParsedEffect; ix++; QDomNode n2 = effects.at(ix); @@ -880,7 +880,7 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo } } if (continueParsing) { - keyframes.append(QString::number(effectout) + ':' + locale.toString(endvalue) + ';'); + keyframes.append(QString::number(effectout) + '=' + locale.toString(endvalue) + ';'); ix++; } } @@ -981,7 +981,7 @@ void TrackView::adjustparameterValue(QDomNodeList clipeffectparams, const QStrin QString fr = kfrs.at(l).section('=', 0, 0); double val = locale.toDouble(kfrs.at(l).section('=', 1, 1)); //kfrs[l] = fr + ":" + locale.toString((int)(val * fact)); - kfrs[l] = fr + ':' + QString::number((int) (offset + val * fact)); + kfrs[l] = fr + '=' + QString::number((int) (offset + val * fact)); } e.setAttribute("keyframes", kfrs.join(";")); } else if (type == "double" || type == "constant") { -- 2.39.2