Commit 7c9787b8 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix 1 frame offset in clip duration after speed change

parent 38f48b65
Pipeline #3734 passed with stage
in 14 minutes and 4 seconds
......@@ -415,7 +415,7 @@ bool ClipModel::useTimewarpProducer(double speed, Fun &undo, Fun &redo)
std::function<bool(void)> local_redo = []() { return true; };
double previousSpeed = getSpeed();
int oldDuration = getPlaytime();
int newDuration = int(double(oldDuration) * std::abs(previousSpeed / speed));
int newDuration = int(double(oldDuration) * std::abs(previousSpeed / speed) + 0.5);
int oldOut = getOut();
int oldIn = getIn();
auto operation = useTimewarpProducer_lambda(speed);
......@@ -432,7 +432,8 @@ bool ClipModel::useTimewarpProducer(double speed, Fun &undo, Fun &redo)
}
if (operation()) {
UPDATE_UNDO_REDO(operation, reverse, local_undo, local_redo);
bool res = requestResize(newDuration, true, local_undo, local_redo, true);
// When calculating duration, result can be a few frames longer than possible duration so adjust
bool res = requestResize(qMin(newDuration, getMaxDuration()), true, local_undo, local_redo, true);
if (!res) {
local_undo();
return false;
......
......@@ -3012,7 +3012,8 @@ bool TimelineModel::requestClipTimeWarp(int clipId, double speed)
}
if (result) {
result = requestClipTimeWarp(clipId, speed / 100.0, undo, redo);
} else {
}
if (!result) {
pCore->displayMessage(i18n("Change speed failed"), ErrorMessage);
undo();
TRACE_RES(false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment