decoder/timeline: improve decoding of still images

This commit is contained in:
itsmattkc
2020-07-12 18:25:51 +10:00
parent 4d6003bb55
commit 11afdf32fe
8 changed files with 313 additions and 197 deletions
+20 -7
View File
@@ -216,7 +216,9 @@ void TimelineWidget::ImportTool::FootageToGhosts(rational ghost_start, const QLi
QVector<int> track_offsets(Timeline::kTrackTypeCount);
track_offsets.fill(track_start);
QVector<TimelineViewGhostItem*> footage_ghosts;
rational footage_duration;
bool contains_image_stream = false;
quint64 enabled_streams = footage.streams();
@@ -236,22 +238,21 @@ void TimelineWidget::ImportTool::FootageToGhosts(rational ghost_start, const QLi
TimelineViewGhostItem* ghost = new TimelineViewGhostItem();
if (stream->type() == Stream::kImage) {
// Stream is essentially length-less - use config's default image length
footage_duration = Config::Current()["DefaultStillLength"].value<rational>();
// Stream is essentially length-less - we may use the default still image length in config,
// or we may use another stream's length depending on the circumstance
contains_image_stream = true;
} else {
// Rescale stream duration to timeline timebase
// Convert to rational time
if (footage.footage()->workarea()->enabled()) {
footage_duration = footage.footage()->workarea()->range().length();
footage_duration = qMax(footage_duration, footage.footage()->workarea()->range().length());
ghost->SetMediaIn(footage.footage()->workarea()->in());
} else {
int64_t stream_duration = Timecode::rescale_timestamp_ceil(stream->duration(), stream->timebase(), dest_tb);
footage_duration = Timecode::timestamp_to_time(stream_duration, dest_tb);
footage_duration = qMax(footage_duration, Timecode::timestamp_to_time(stream_duration, dest_tb));
}
}
ghost->SetIn(ghost_start);
ghost->SetOut(ghost_start + footage_duration);
ghost->SetTrack(TrackReference(track_type, track_offsets.at(track_type)));
// Increment track count for this track type
@@ -263,10 +264,22 @@ void TimelineWidget::ImportTool::FootageToGhosts(rational ghost_start, const QLi
ghost->setData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(stream));
ghost->SetMode(Timeline::kMove);
parent()->AddGhost(ghost);
footage_ghosts.append(ghost);
}
if (contains_image_stream && footage_duration.isNull()) {
// Footage must ONLY be image streams so no duration value was found, use default in config
footage_duration = Config::Current()["DefaultStillLength"].value<rational>();
}
foreach (TimelineViewGhostItem* ghost, footage_ghosts) {
ghost->SetIn(ghost_start);
ghost->SetOut(ghost_start + footage_duration);
parent()->AddGhost(ghost);
}
// Stack each ghost one after the other
ghost_start += footage_duration;