footage: clamp to last frame rather than length

Fixes #1604
This commit is contained in:
itsmattkc
2021-05-03 22:18:40 +10:00
parent a15ae63c7d
commit 32e11bb6a1
3 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -350,7 +350,7 @@ void Footage::Hash(const QString& output, QCryptographicHash &hash, const ration
// Footage timestamp // Footage timestamp
if (params.video_type() != VideoParams::kVideoTypeStill) { if (params.video_type() != VideoParams::kVideoTypeStill) {
rational adjusted_time = AdjustTimeByLoopMode(time, loop_mode(), GetLength(), params.video_type()); rational adjusted_time = AdjustTimeByLoopMode(time, loop_mode(), GetLength(), params.video_type(), params.frame_rate_as_time_base());
if (!adjusted_time.isNaN()) { if (!adjusted_time.isNaN()) {
int64_t video_ts = Timecode::time_to_timestamp(adjusted_time, params.time_base()); int64_t video_ts = Timecode::time_to_timestamp(adjusted_time, params.time_base());
@@ -446,7 +446,7 @@ bool TimeIsOutOfBounds(const rational& time, const rational& length)
return time < 0 || time >= length; return time < 0 || time >= length;
} }
rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mode, const rational &length, VideoParams::Type type) rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mode, const rational &length, VideoParams::Type type, const rational& timebase)
{ {
if (type == VideoParams::kVideoTypeStill) { if (type == VideoParams::kVideoTypeStill) {
// No looping for still images // No looping for still images
@@ -461,7 +461,7 @@ rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mod
break; break;
case kLoopModeClamp: case kLoopModeClamp:
// Clamp footage time to length // Clamp footage time to length
time = clamp(time, rational(0), length); time = clamp(time, rational(0), length - timebase);
break; break;
case kLoopModeLoop: case kLoopModeLoop:
// Loop footage time around job length // Loop footage time around job length
+1 -1
View File
@@ -191,7 +191,7 @@ public:
virtual NodeOutput GetConnectedSampleOutput() override; virtual NodeOutput GetConnectedSampleOutput() override;
static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type); static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type, const rational &timebase);
static const QString kFilenameInput; static const QString kFilenameInput;
static const QString kLoopModeInput; static const QString kLoopModeInput;
+1 -1
View File
@@ -286,7 +286,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const QString& output, co
FootageJob job = v.data().value<FootageJob>(); FootageJob job = v.data().value<FootageJob>();
if (job.type() == Track::kVideo) { if (job.type() == Track::kVideo) {
rational footage_time = Footage::AdjustTimeByLoopMode(range.in(), job.loop_mode(), job.length(), job.video_params().video_type()); rational footage_time = Footage::AdjustTimeByLoopMode(range.in(), job.loop_mode(), job.length(), job.video_params().video_type(), job.video_params().frame_rate_as_time_base());
if (!footage_time.isNaN()) { if (!footage_time.isNaN()) {
QVariant value = ProcessVideoFootage(job, footage_time); QVariant value = ProcessVideoFootage(job, footage_time);