From: Jean-Baptiste M. <jb...@kd...> - 2012-05-27 10:18:40
|
Git commit 65d0c1f96a92a0446e3c0746e950d04a1133b249 by Jean-Baptiste Mardelle. Committed on 27/05/2012 at 12:16. Pushed by mardelle into branch 'v0.9'. Fix editing clip crop start and fade effects lost when resizing clip: http://kdenlive.org/mantis/view.php?id=2570 M +3 -3 src/clipitem.cpp M +2 -4 src/customtrackview.cpp M +11 -0 src/definitions.h M +10 -4 src/renderer.cpp M +1 -1 src/renderer.h http://commits.kde.org/kdenlive/65d0c1f96a92a0446e3c0746e950d04a1133b249 diff --git a/src/clipitem.cpp b/src/clipitem.cpp index e164959..f672cd8 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -1856,9 +1856,9 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, if (id == "fade_from_black" || id == "fadein") { if (in != cropStart().frames(m_fps)) { effects[i] = effect.cloneNode().toElement(); - int diff = in - cropStart().frames(m_fps); - in -= diff; - out -= diff; + int duration = out - in; + in = cropStart().frames(m_fps); + out = in + duration; EffectsList::setParameter(effect, "in", QString::number(in)); EffectsList::setParameter(effect, "out", QString::number(out)); } diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index b4c14fc..96f45d6 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -4702,7 +4702,7 @@ void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, boo kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25); ItemInfo clipinfo = end; clipinfo.track = m_document->tracksCount() - end.track; - bool success = m_document->renderer()->mltResizeClipCrop(clipinfo, end.cropStart - start.cropStart); + bool success = m_document->renderer()->mltResizeClipCrop(clipinfo, end.cropStart); if (success) { item->setCropStart(end.cropStart); item->resetThumbs(true); @@ -4777,7 +4777,6 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol new ResizeClipCommand(this, oldInfo, info, false, true, command); adjustEffects(clip, oldInfo, command); new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeStart((int) oldInfo.startPos.frames(m_document->fps())); @@ -4872,7 +4871,6 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI new ResizeClipCommand(this, oldInfo, info, false, true, command); adjustEffects(clip, oldInfo, command); new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps())); @@ -7143,7 +7141,7 @@ void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoComma if (effects.count()) { QMap<int, QDomElement>::const_iterator i = effects.constBegin(); while (i != effects.constEnd()) { - new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effect(i.key()), i.key(), false, false, command); + new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effect(i.key()), i.value().attribute("kdenlive_ix").toInt(), true, true, command); ++i; } } diff --git a/src/definitions.h b/src/definitions.h index e3e5c44..5b6c254 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -203,6 +203,17 @@ public: if (at(i).name() == name) return true; return false; } + void setParamValue(const QString &name, const QString &value) { + bool found = false; + for (int i = 0; i < size(); i++) + if (at(i).name() == name) { + // update value + replace(i, EffectParameter(name, value)); + found = true; + } + if (!found) addParam(name, value); + } + QString paramValue(const QString &name, QString defaultValue = QString()) const { for (int i = 0; i < size(); i++) { if (at(i).name() == name) return at(i).value(); diff --git a/src/renderer.cpp b/src/renderer.cpp index 0f45748..f4075c1 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -2871,7 +2871,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par } for (int j = 0; j < params.count(); j++) { - filter->set((params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData()); + filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData()); } for (int j = 0; j < filtersList.count(); j++) { @@ -3289,10 +3289,10 @@ void Render::fixAudioMixing(Mlt::Tractor tractor) mlt_service_unlock(serv); } -bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) +bool Render::mltResizeClipCrop(ItemInfo info, GenTime newCropStart) { Mlt::Service service(m_mltProducer->parent().get_service()); - int frameOffset = (int) diff.frames(m_fps); + int newCropFrame = (int) newCropStart.frames(m_fps); Mlt::Tractor tractor(service); Mlt::Producer trackProducer(tractor.track(info.track)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); @@ -3311,7 +3311,13 @@ bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) int previousStart = clip->get_in(); int previousOut = clip->get_out(); delete clip; - trackPlaylist.resize_clip(clipIndex, previousStart + frameOffset, previousOut + frameOffset); + if (previousStart == newCropFrame) { + kDebug() << "//////// No ReSIZING Required"; + service.unlock(); + return true; + } + int frameOffset = newCropFrame - previousStart; + trackPlaylist.resize_clip(clipIndex, newCropFrame, previousOut + frameOffset); service.unlock(); m_mltConsumer->set("refresh", 1); return true; diff --git a/src/renderer.h b/src/renderer.h index 45b889d..637ba0c 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -215,7 +215,7 @@ Q_OBJECT public: bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration); bool mltResizeClipStart(ItemInfo info, GenTime diff); - bool mltResizeClipCrop(ItemInfo info, GenTime diff); + bool mltResizeClipCrop(ItemInfo info, GenTime newCropStart); bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod, bool overwrite = false, bool insert = false); bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart, Mlt::Producer *prod, bool overwrite = false, bool insert = false); bool mltRemoveClip(int track, GenTime position); |