finished merge of viewer and footage

This commit is contained in:
itsmattkc
2021-04-06 13:08:56 +10:00
parent 57ddae8920
commit 898ea25e89
58 changed files with 783 additions and 719 deletions
+6 -6
View File
@@ -228,7 +228,7 @@ void TimelineWidget::ConnectNodeInternal(ViewerOutput *n)
ruler()->SetPlaybackCache(n->video_frame_cache());
SetTimebase(n->video_params().time_base());
SetTimebase(n->GetVideoParams().time_base());
for (int i=0;i<views_.size();i++) {
Track::Type track_type = static_cast<Track::Type>(i);
@@ -522,12 +522,12 @@ void TimelineWidget::DecreaseTrackHeight()
}
}
void TimelineWidget::InsertFootageAtPlayhead(const QVector<Footage*>& footage)
void TimelineWidget::InsertFootageAtPlayhead(const QVector<ViewerOutput*>& footage)
{
import_tool_->PlaceAt(footage, GetTime(), true);
}
void TimelineWidget::OverwriteFootageAtPlayhead(const QVector<Footage *> &footage)
void TimelineWidget::OverwriteFootageAtPlayhead(const QVector<ViewerOutput *> &footage)
{
import_tool_->PlaceAt(footage, GetTime(), false);
}
@@ -1005,7 +1005,7 @@ void TimelineWidget::SetViewTimestamp(const int64_t &ts)
if (use_audio_time_units_ && i == Track::kAudio) {
view->view()->SetTime(Timecode::rescale_timestamp(ts,
timebase(),
GetConnectedNode()->audio_params().time_base()));
GetConnectedNode()->GetAudioParams().time_base()));
} else {
view->view()->SetTime(ts);
}
@@ -1016,7 +1016,7 @@ void TimelineWidget::ViewTimestampChanged(int64_t ts)
{
if (use_audio_time_units_ && sender() == views_.at(Track::kAudio)) {
ts = Timecode::rescale_timestamp(ts,
GetConnectedNode()->audio_params().time_base(),
GetConnectedNode()->GetAudioParams().time_base(),
timebase());
}
@@ -1050,7 +1050,7 @@ void TimelineWidget::UpdateViewTimebases()
TimelineAndTrackView* view = views_.at(i);
if (use_audio_time_units_ && i == Track::kAudio) {
view->view()->SetTimebase(GetConnectedNode()->audio_params().time_base());
view->view()->SetTimebase(GetConnectedNode()->GetAudioParams().time_base());
} else {
view->view()->SetTimebase(timebase());
}
+2 -2
View File
@@ -75,9 +75,9 @@ public:
void DecreaseTrackHeight();
void InsertFootageAtPlayhead(const QVector<Footage *> &footage);
void InsertFootageAtPlayhead(const QVector<ViewerOutput *> &footage);
void OverwriteFootageAtPlayhead(const QVector<Footage *> &footage);
void OverwriteFootageAtPlayhead(const QVector<ViewerOutput *> &footage);
void ToggleLinksOnSelected();
+20 -43
View File
@@ -40,25 +40,6 @@
namespace olive {
Track::Type TrackTypeFromStreamType(Stream::Type stream_type)
{
switch (stream_type) {
case Stream::kVideo:
return Track::kVideo;
case Stream::kAudio:
return Track::kAudio;
case Stream::kSubtitle:
// Temporarily disabled until we figure out a better thing to do with this
//return Track::kSubtitle;
case Stream::kUnknown:
case Stream::kData:
case Stream::kAttachment:
break;
}
return Track::kNone;
}
ImportTool::ImportTool(TimelineWidget *parent) :
TimelineTool(parent)
{
@@ -81,7 +62,7 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
// Variables to deserialize into
quintptr item_ptr;
QVector<Footage::StreamReference> enabled_streams;
QVector<Track::Reference> enabled_streams;
// Set drag start position
drag_start_ = event->GetCoordinates();
@@ -95,15 +76,11 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
Node* item = reinterpret_cast<Node*>(item_ptr);
// Check if Item is Footage
if (dynamic_cast<Footage*>(item)) {
Footage* f = static_cast<Footage*>(item);
if (f->IsValid()) {
// If the Item is Footage, we can create a Ghost from it
dragged_footage_.insert(f, enabled_streams);
}
ViewerOutput* f = dynamic_cast<ViewerOutput*>(item);
if (f && f->GetTotalStreamCount()) {
// If the Item is Footage, we can create a Ghost from it
dragged_footage_.insert(f, enabled_streams);
}
}
@@ -191,18 +168,18 @@ void ImportTool::DragDrop(TimelineViewMouseEvent *event)
}
}
void ImportTool::PlaceAt(const QVector<Footage *> &footage, const rational &start, bool insert)
void ImportTool::PlaceAt(const QVector<ViewerOutput *> &footage, const rational &start, bool insert)
{
QMap<Footage*, QVector<Footage::StreamReference> > refs;
QMap<ViewerOutput*, QVector<Track::Reference> > refs;
foreach (Footage* f, footage) {
foreach (ViewerOutput* f, footage) {
refs.insert(f, f->GetEnabledStreamsAsReferences());
}
PlaceAt(refs, start, insert);
}
void ImportTool::PlaceAt(const QMap<Footage*, QVector<Footage::StreamReference> > &footage, const rational &start, bool insert)
void ImportTool::PlaceAt(const QMap<ViewerOutput*, QVector<Track::Reference> > &footage, const rational &start, bool insert)
{
dragged_footage_ = footage;
@@ -214,7 +191,7 @@ void ImportTool::PlaceAt(const QMap<Footage*, QVector<Footage::StreamReference>
DropGhosts(insert);
}
void ImportTool::FootageToGhosts(rational ghost_start, const QMap<Footage *, QVector<Footage::StreamReference> > &sorted, const rational& dest_tb, const int& track_start)
void ImportTool::FootageToGhosts(rational ghost_start, const QMap<ViewerOutput *, QVector<Track::Reference> > &sorted, const rational& dest_tb, const int& track_start)
{
for (auto it=sorted.cbegin(); it!=sorted.cend(); it++) {
// Each stream is offset by one track per track "type", we keep track of them in this vector
@@ -225,12 +202,12 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QMap<Footage *, QVe
rational footage_duration;
bool contains_image_stream = false;
foreach (const Footage::StreamReference& ref, it.value()) {
Track::Type track_type = TrackTypeFromStreamType(ref.type());
foreach (const Track::Reference& ref, it.value()) {
Track::Type track_type = ref.type();
TimelineViewGhostItem* ghost = new TimelineViewGhostItem();
if (ref.type() == Stream::kVideo && it.key()->GetVideoParams(ref.index()).video_type() == VideoParams::kVideoTypeStill) {
if (ref.type() == Track::kVideo && it.key()->GetVideoParams(ref.index()).video_type() == VideoParams::kVideoTypeStill) {
// 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;
@@ -245,7 +222,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QMap<Footage *, QVe
int64_t dur;
rational tb;
if (ref.type() == Stream::kVideo) {
if (ref.type() == Track::kVideo) {
VideoParams vp = it.key()->GetVideoParams(ref.index());
dur = vp.duration();
tb = vp.time_base();
@@ -265,7 +242,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QMap<Footage *, QVe
// Increment track count for this track type
track_offsets[track_type]++;
TimelineViewGhostItem::AttachedFootage af = {it.key(), it.key()->GetStringFromReference(ref)};
TimelineViewGhostItem::AttachedFootage af = {it.key(), ref.ToString()};
ghost->SetData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(af));
ghost->SetMode(Timeline::kMove);
@@ -365,7 +342,7 @@ void ImportTool::DropGhosts(bool insert)
if (behavior == kDWSAuto) {
QVector<Footage*> footage_only;
QVector<ViewerOutput*> footage_only;
for (auto it=dragged_footage_.cbegin(); it!=dragged_footage_.cend(); it++) {
if (!footage_only.contains(it.key())) {
@@ -393,7 +370,7 @@ void ImportTool::DropGhosts(bool insert)
command->add_child(new FolderAddChild(Core::instance()->GetSelectedFolderInActiveProject(), new_sequence));
new_sequence->add_default_nodes(command);
FootageToGhosts(0, dragged_footage_, new_sequence->video_params().time_base(), 0);
FootageToGhosts(0, dragged_footage_, new_sequence->GetVideoParams().time_base(), 0);
sequence = new_sequence;
@@ -431,8 +408,8 @@ void ImportTool::DropGhosts(bool insert)
command->add_child(new NodeAddCommand(dst_graph, clip));
command->add_child(new NodeSetPositionToOffsetOfAnotherNodeCommand(clip, footage_stream.footage, QPointF(2, 0)));
switch (footage_stream.footage->GetTypeFromOutput(footage_stream.output)) {
case Stream::kVideo:
switch (Track::Reference::TypeFromString(footage_stream.output)) {
case Track::kVideo:
{
TransformDistortNode* transform = new TransformDistortNode();
command->add_child(new NodeAddCommand(dst_graph, transform));
@@ -442,7 +419,7 @@ void ImportTool::DropGhosts(bool insert)
command->add_child(new NodeSetPositionToOffsetOfAnotherNodeCommand(transform, clip, QPointF(-1, 0)));
break;
}
case Stream::kAudio:
case Track::kAudio:
{
VolumeNode* volume_node = new VolumeNode();
command->add_child(new NodeAddCommand(dst_graph, volume_node));
+4 -4
View File
@@ -35,8 +35,8 @@ public:
virtual void DragLeave(QDragLeaveEvent *event) override;
virtual void DragDrop(TimelineViewMouseEvent *event) override;
void PlaceAt(const QVector<Footage*> &footage, const rational& start, bool insert);
void PlaceAt(const QMap<Footage *, QVector<Footage::StreamReference> > &footage, const rational& start, bool insert);
void PlaceAt(const QVector<ViewerOutput *> &footage, const rational& start, bool insert);
void PlaceAt(const QMap<ViewerOutput *, QVector<Track::Reference> > &footage, const rational& start, bool insert);
enum DropWithoutSequenceBehavior {
kDWSAsk,
@@ -46,13 +46,13 @@ public:
};
private:
void FootageToGhosts(rational ghost_start, const QMap<Footage*, QVector<Footage::StreamReference> > &footage, const rational &dest_tb, const int &track_start);
void FootageToGhosts(rational ghost_start, const QMap<ViewerOutput *, QVector<Track::Reference> > &footage, const rational &dest_tb, const int &track_start);
void PrepGhosts(const rational &frame, const int &track_index);
void DropGhosts(bool insert);
QMap<Footage*, QVector<Footage::StreamReference> > dragged_footage_;
QMap<ViewerOutput*, QVector<Track::Reference> > dragged_footage_;
int import_pre_buffer_;
@@ -344,23 +344,6 @@ Track::Type TimelineView::ConnectedTrackType()
return Track::kNone;
}
Stream::Type TimelineView::TrackTypeToStreamType(Track::Type track_type)
{
switch (track_type) {
case Track::kNone:
case Track::kCount:
break;
case Track::kVideo:
return Stream::kVideo;
case Track::kAudio:
return Stream::kAudio;
case Track::kSubtitle:
return Stream::kSubtitle;
}
return Stream::kUnknown;
}
TimelineCoordinate TimelineView::ScreenToCoordinate(const QPoint& pt)
{
return SceneToCoordinate(mapToScene(pt));
@@ -114,7 +114,6 @@ protected:
private:
Track::Type ConnectedTrackType();
Stream::Type TrackTypeToStreamType(Track::Type track_type);
TimelineCoordinate ScreenToCoordinate(const QPoint& pt);
TimelineCoordinate SceneToCoordinate(const QPointF& pt);
@@ -44,7 +44,7 @@ public:
};
struct AttachedFootage {
Footage* footage;
ViewerOutput* footage;
QString output;
};