moved sequence params into node graph too
Reduces code by reusing more of the existing node infrastructure to synchronize sequence parameters the render backend.
This commit is contained in:
@@ -81,8 +81,8 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
case NodeValue::kShaderJob:
|
||||
case NodeValue::kSampleJob:
|
||||
case NodeValue::kGenerateJob:
|
||||
case NodeValue::kVideoStreamProperties:
|
||||
case NodeValue::kAudioStreamProperties:
|
||||
case NodeValue::kVideoParams:
|
||||
case NodeValue::kAudioParams:
|
||||
break;
|
||||
case NodeValue::kInt:
|
||||
{
|
||||
@@ -252,8 +252,8 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
case NodeValue::kShaderJob:
|
||||
case NodeValue::kSampleJob:
|
||||
case NodeValue::kGenerateJob:
|
||||
case NodeValue::kVideoStreamProperties:
|
||||
case NodeValue::kAudioStreamProperties:
|
||||
case NodeValue::kVideoParams:
|
||||
case NodeValue::kAudioParams:
|
||||
break;
|
||||
case NodeValue::kInt:
|
||||
{
|
||||
@@ -402,8 +402,8 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
||||
case NodeValue::kShaderJob:
|
||||
case NodeValue::kSampleJob:
|
||||
case NodeValue::kGenerateJob:
|
||||
case NodeValue::kVideoStreamProperties:
|
||||
case NodeValue::kAudioStreamProperties:
|
||||
case NodeValue::kVideoParams:
|
||||
case NodeValue::kAudioParams:
|
||||
break;
|
||||
case NodeValue::kInt:
|
||||
{
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
QVariant NodeTableTraverser::ProcessVideoFootage(const Footage::StreamReference &video_stream, const rational &input_time)
|
||||
QVariant NodeTableTraverser::ProcessVideoFootage(const FootageJob &video_stream, const rational &input_time)
|
||||
{
|
||||
return QVariant::fromValue(video_stream.video_params());
|
||||
}
|
||||
|
||||
QVariant NodeTableTraverser::ProcessAudioFootage(const Footage::StreamReference &audio_stream, const TimeRange &input_time)
|
||||
QVariant NodeTableTraverser::ProcessAudioFootage(const FootageJob &audio_stream, const TimeRange &input_time)
|
||||
{
|
||||
return QVariant::fromValue(audio_stream.audio_params());
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public:
|
||||
NodeTableTraverser() = default;
|
||||
|
||||
protected:
|
||||
virtual QVariant ProcessVideoFootage(const Footage::StreamReference&video_stream, const rational &input_time);
|
||||
virtual QVariant ProcessVideoFootage(const FootageJob &video_stream, const rational &input_time);
|
||||
|
||||
virtual QVariant ProcessAudioFootage(const Footage::StreamReference& audio_stream, const TimeRange &input_time);
|
||||
virtual QVariant ProcessAudioFootage(const FootageJob &audio_stream, const TimeRange &input_time);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) :
|
||||
// Add tree view to stacked widget
|
||||
tree_view_ = new ProjectExplorerTreeView(stacked_widget_);
|
||||
tree_view_->setSortingEnabled(true);
|
||||
tree_view_->sortByColumn(0, Qt::AscendingOrder);
|
||||
tree_view_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
AddView(tree_view_);
|
||||
|
||||
@@ -307,7 +308,7 @@ void ProjectExplorer::ShowContextMenu()
|
||||
Footage* footage_cast_test = dynamic_cast<Footage*>(i);
|
||||
Sequence* sequence_cast_test = dynamic_cast<Sequence*>(i);
|
||||
|
||||
if (footage_cast_test && !footage_cast_test->HasEnabledStreamsOfType(Stream::kVideo)) {
|
||||
if (footage_cast_test && !footage_cast_test->HasEnabledVideoStreams()) {
|
||||
all_items_have_video_streams = false;
|
||||
}
|
||||
|
||||
@@ -416,11 +417,11 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a)
|
||||
foreach (Item* i, context_menu_items_) {
|
||||
Footage* f = static_cast<Footage*>(i);
|
||||
|
||||
QVector<int> video_streams = f->GetStreamIndexesOfType(Stream::kVideo);
|
||||
QVector<VideoParams> enabled_streams = f->GetEnabledVideoStreams();
|
||||
|
||||
foreach (int stream, video_streams) {
|
||||
foreach (const VideoParams& stream, enabled_streams) {
|
||||
// Start a background task for proxying
|
||||
PreCacheTask* proxy_task = new PreCacheTask(f, stream, sequence);
|
||||
PreCacheTask* proxy_task = new PreCacheTask(f, stream.stream_index(), sequence);
|
||||
TaskManager::instance()->AddTask(proxy_task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,18 +71,17 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
||||
QStringList mime_formats = event->GetMimeData()->formats();
|
||||
|
||||
// Listen for MIME data from a ProjectViewModel
|
||||
if (mime_formats.contains("application/x-oliveprojectitemdata")) {
|
||||
if (mime_formats.contains(QStringLiteral("application/x-oliveprojectitemdata"))) {
|
||||
|
||||
// Data is drag/drop data from a ProjectViewModel
|
||||
QByteArray model_data = event->GetMimeData()->data("application/x-oliveprojectitemdata");
|
||||
QByteArray model_data = event->GetMimeData()->data(QStringLiteral("application/x-oliveprojectitemdata"));
|
||||
|
||||
// Use QDataStream to deserialize the data
|
||||
QDataStream stream(&model_data, QIODevice::ReadOnly);
|
||||
|
||||
// Variables to deserialize into
|
||||
quintptr item_ptr;
|
||||
int r;
|
||||
quint64 enabled_streams;
|
||||
QVector<Footage::StreamReference> enabled_streams;
|
||||
|
||||
// Set drag start position
|
||||
drag_start_ = event->GetCoordinates();
|
||||
@@ -90,7 +89,7 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
||||
snap_points_.clear();
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
stream >> enabled_streams >> r >> item_ptr;
|
||||
stream >> enabled_streams >> item_ptr;
|
||||
|
||||
// Get Item object
|
||||
Item* item = reinterpret_cast<Item*>(item_ptr);
|
||||
@@ -102,7 +101,7 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
||||
|
||||
if (f->IsValid()) {
|
||||
// If the Item is Footage, we can create a Ghost from it
|
||||
dragged_footage_.append(DraggedFootage(f, enabled_streams));
|
||||
dragged_footage_.insert(f, enabled_streams);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -194,10 +193,16 @@ void ImportTool::DragDrop(TimelineViewMouseEvent *event)
|
||||
|
||||
void ImportTool::PlaceAt(const QVector<Footage *> &footage, const rational &start, bool insert)
|
||||
{
|
||||
PlaceAt(FootageToDraggedFootage(footage), start, insert);
|
||||
QMap<Footage*, QVector<Footage::StreamReference> > refs;
|
||||
|
||||
foreach (Footage* f, footage) {
|
||||
refs.insert(f, f->GetEnabledStreamsAsReferences());
|
||||
}
|
||||
|
||||
PlaceAt(refs, start, insert);
|
||||
}
|
||||
|
||||
void ImportTool::PlaceAt(const QVector<DraggedFootage> &footage, const rational &start, bool insert)
|
||||
void ImportTool::PlaceAt(const QMap<Footage*, QVector<Footage::StreamReference> > &footage, const rational &start, bool insert)
|
||||
{
|
||||
dragged_footage_ = footage;
|
||||
|
||||
@@ -209,10 +214,9 @@ void ImportTool::PlaceAt(const QVector<DraggedFootage> &footage, const rational
|
||||
DropGhosts(insert);
|
||||
}
|
||||
|
||||
void ImportTool::FootageToGhosts(rational ghost_start, const QVector<DraggedFootage> &footage_list, const rational& dest_tb, const int& track_start)
|
||||
void ImportTool::FootageToGhosts(rational ghost_start, const QMap<Footage *, QVector<Footage::StreamReference> > &sorted, const rational& dest_tb, const int& track_start)
|
||||
{
|
||||
foreach (const DraggedFootage& footage, footage_list) {
|
||||
|
||||
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
|
||||
QVector<int> track_offsets(Track::kCount);
|
||||
track_offsets.fill(track_start);
|
||||
@@ -221,40 +225,36 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QVector<DraggedFoot
|
||||
rational footage_duration;
|
||||
bool contains_image_stream = false;
|
||||
|
||||
quint64 enabled_streams = footage.streams();
|
||||
|
||||
// Loop through all streams in footage
|
||||
foreach (const QString& output, footage.footage()->outputs()) {
|
||||
Footage::StreamReference ref = footage.footage()->GetReferenceFromOutput(output);
|
||||
|
||||
foreach (const Footage::StreamReference& ref, it.value()) {
|
||||
Track::Type track_type = TrackTypeFromStreamType(ref.type());
|
||||
|
||||
quint64 cached_enabled_streams = enabled_streams;
|
||||
enabled_streams >>= 1;
|
||||
|
||||
// Check if this stream has a compatible TrackList
|
||||
if (track_type == Track::kNone
|
||||
|| !(cached_enabled_streams & 0x1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TimelineViewGhostItem* ghost = new TimelineViewGhostItem();
|
||||
|
||||
Stream stream = ref.GetStream();
|
||||
|
||||
if (ref.type() == Stream::kVideo
|
||||
&& stream.video_type() == Stream::kVideoTypeStill) {
|
||||
if (ref.type() == Stream::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;
|
||||
} else {
|
||||
// Rescale stream duration to timeline timebase
|
||||
// Convert to rational time
|
||||
if (footage.footage()->workarea()->enabled()) {
|
||||
footage_duration = qMax(footage_duration, footage.footage()->workarea()->range().length());
|
||||
ghost->SetMediaIn(footage.footage()->workarea()->in());
|
||||
if (it.key()->workarea()->enabled()) {
|
||||
footage_duration = qMax(footage_duration, it.key()->workarea()->range().length());
|
||||
ghost->SetMediaIn(it.key()->workarea()->in());
|
||||
} else {
|
||||
int64_t stream_duration = Timecode::rescale_timestamp_ceil(stream.duration(), stream.timebase(), dest_tb);
|
||||
int64_t dur;
|
||||
rational tb;
|
||||
|
||||
if (ref.type() == Stream::kVideo) {
|
||||
VideoParams vp = it.key()->GetVideoParams(ref.index());
|
||||
dur = vp.duration();
|
||||
tb = vp.time_base();
|
||||
} else {
|
||||
AudioParams ap = it.key()->GetAudioParams(ref.index());
|
||||
dur = ap.duration();
|
||||
tb = ap.time_base();
|
||||
}
|
||||
|
||||
int64_t stream_duration = Timecode::rescale_timestamp_ceil(dur, tb, dest_tb);
|
||||
footage_duration = qMax(footage_duration, Timecode::timestamp_to_time(stream_duration, dest_tb));
|
||||
}
|
||||
}
|
||||
@@ -264,11 +264,11 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QVector<DraggedFoot
|
||||
// Increment track count for this track type
|
||||
track_offsets[track_type]++;
|
||||
|
||||
ghost->SetData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(TimelineViewGhostItem::AttachedFootage({footage.footage(), output})));
|
||||
TimelineViewGhostItem::AttachedFootage af = {it.key(), it.key()->GetStringFromReference(ref)};
|
||||
ghost->SetData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(af));
|
||||
ghost->SetMode(Timeline::kMove);
|
||||
|
||||
footage_ghosts.append(ghost);
|
||||
|
||||
}
|
||||
|
||||
if (contains_image_stream && footage_duration.isNull()) {
|
||||
@@ -367,8 +367,10 @@ void ImportTool::DropGhosts(bool insert)
|
||||
|
||||
QVector<Footage*> footage_only;
|
||||
|
||||
foreach (const DraggedFootage& df, dragged_footage_) {
|
||||
footage_only.append(df.footage());
|
||||
for (auto it=dragged_footage_.cbegin(); it!=dragged_footage_.cend(); it++) {
|
||||
if (!footage_only.contains(it.key())) {
|
||||
footage_only.append(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
new_sequence->set_parameters_from_footage(footage_only);
|
||||
@@ -479,20 +481,4 @@ void ImportTool::DropGhosts(bool insert)
|
||||
dragged_footage_.clear();
|
||||
}
|
||||
|
||||
ImportTool::DraggedFootage ImportTool::FootageToDraggedFootage(Footage *f)
|
||||
{
|
||||
return DraggedFootage(f, f->get_enabled_stream_flags());
|
||||
}
|
||||
|
||||
QVector<ImportTool::DraggedFootage> ImportTool::FootageToDraggedFootage(QVector<Footage *> footage)
|
||||
{
|
||||
QVector<DraggedFootage> df;
|
||||
|
||||
foreach (Footage* f, footage) {
|
||||
df.append(FootageToDraggedFootage(f));
|
||||
}
|
||||
|
||||
return df;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,37 +35,8 @@ public:
|
||||
virtual void DragLeave(QDragLeaveEvent *event) override;
|
||||
virtual void DragDrop(TimelineViewMouseEvent *event) override;
|
||||
|
||||
class DraggedFootage {
|
||||
public:
|
||||
DraggedFootage() :
|
||||
footage_(nullptr),
|
||||
streams_(0)
|
||||
{
|
||||
}
|
||||
|
||||
DraggedFootage(Footage* f, quint64 streams) :
|
||||
footage_(f),
|
||||
streams_(streams)
|
||||
{
|
||||
}
|
||||
|
||||
Footage* footage() const {
|
||||
return footage_;
|
||||
}
|
||||
|
||||
const quint64& streams() const {
|
||||
return streams_;
|
||||
}
|
||||
|
||||
private:
|
||||
Footage* footage_;
|
||||
|
||||
quint64 streams_;
|
||||
|
||||
};
|
||||
|
||||
void PlaceAt(const QVector<Footage*> &footage, const rational& start, bool insert);
|
||||
void PlaceAt(const QVector<DraggedFootage> &footage, const rational& start, bool insert);
|
||||
void PlaceAt(const QMap<Footage *, QVector<Footage::StreamReference> > &footage, const rational& start, bool insert);
|
||||
|
||||
enum DropWithoutSequenceBehavior {
|
||||
kDWSAsk,
|
||||
@@ -75,16 +46,13 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
static DraggedFootage FootageToDraggedFootage(Footage* f);
|
||||
static QVector<DraggedFootage> FootageToDraggedFootage(QVector<Footage*> footage);
|
||||
|
||||
void FootageToGhosts(rational ghost_start, const QVector<DraggedFootage> &footage, const rational &dest_tb, const int &track_start);
|
||||
void FootageToGhosts(rational ghost_start, const QMap<Footage*, QVector<Footage::StreamReference> > &footage, const rational &dest_tb, const int &track_start);
|
||||
|
||||
void PrepGhosts(const rational &frame, const int &track_index);
|
||||
|
||||
void DropGhosts(bool insert);
|
||||
|
||||
QVector<DraggedFootage> dragged_footage_;
|
||||
QMap<Footage*, QVector<Footage::StreamReference> > dragged_footage_;
|
||||
|
||||
int import_pre_buffer_;
|
||||
|
||||
|
||||
@@ -99,56 +99,74 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
|
||||
QByteArray encoded_data;
|
||||
QDataStream data_stream(&encoded_data, QIODevice::WriteOnly);
|
||||
|
||||
quint64 enabled_stream_flags = GetFootage()->get_enabled_stream_flags();
|
||||
QVector<Footage::StreamReference> streams = GetFootage()->GetEnabledStreamsAsReferences();
|
||||
|
||||
// Disable streams that have been disabled
|
||||
if (!enable_video || !enable_audio) {
|
||||
quint64 stream_disabler = 0x1;
|
||||
for (int i=0; i<streams.size(); i++) {
|
||||
const Footage::StreamReference& ref = streams.at(i);
|
||||
|
||||
for (int i=0; i<GetFootage()->GetStreamCount(); i++) {
|
||||
Stream stream = GetFootage()->GetStreamAt(i);
|
||||
|
||||
if ((stream.type() == Stream::kVideo && !enable_video)
|
||||
|| (stream.type() == Stream::kAudio && !enable_audio)) {
|
||||
enabled_stream_flags &= ~stream_disabler;
|
||||
if ((ref.type() == Stream::kVideo && !enable_video)
|
||||
|| (ref.type() == Stream::kAudio && !enable_audio)) {
|
||||
streams.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
stream_disabler <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
data_stream << enabled_stream_flags << -1 << reinterpret_cast<quintptr>(GetFootage());
|
||||
if (!streams.isEmpty()) {
|
||||
data_stream << streams << reinterpret_cast<quintptr>(GetFootage());
|
||||
|
||||
mimedata->setData("application/x-oliveprojectitemdata", encoded_data);
|
||||
drag->setMimeData(mimedata);
|
||||
mimedata->setData(QStringLiteral("application/x-oliveprojectitemdata"), encoded_data);
|
||||
drag->setMimeData(mimedata);
|
||||
|
||||
drag->exec();
|
||||
drag->exec();
|
||||
}
|
||||
}
|
||||
|
||||
void FootageViewerWidget::TryConnectingType(Footage *footage, Stream::Type type)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
for (int i=0; ; i++) {
|
||||
Stream stream = footage_->GetStreamAt(type, i);
|
||||
if (type == Stream::kVideo) {
|
||||
VideoParams vp = footage->GetVideoParams(i);
|
||||
|
||||
// Found end of stream list
|
||||
if (!stream.IsValid()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (stream.enabled()) {
|
||||
QString s = Footage::GetStringFromReference(type, i);
|
||||
|
||||
QString input_param;
|
||||
|
||||
if (type == Stream::kVideo) {
|
||||
input_param = ViewerOutput::kTextureInput;
|
||||
} else {
|
||||
input_param = ViewerOutput::kSamplesInput;
|
||||
if (!vp.is_valid()) {
|
||||
break;
|
||||
}
|
||||
|
||||
Node::ConnectEdge(NodeOutput(footage, s), NodeInput(&sequence_, input_param));
|
||||
if (vp.enabled()) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
} else if (type == Stream::kAudio) {
|
||||
AudioParams vp = footage->GetAudioParams(i);
|
||||
|
||||
if (!vp.is_valid()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (vp.enabled()) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
QString s = Footage::GetStringFromReference(type, index);
|
||||
|
||||
QString input_param;
|
||||
|
||||
if (type == Stream::kVideo) {
|
||||
input_param = ViewerOutput::kTextureInput;
|
||||
} else {
|
||||
input_param = ViewerOutput::kSamplesInput;
|
||||
}
|
||||
|
||||
Node::ConnectEdge(NodeOutput(footage, s), NodeInput(&sequence_, input_param));
|
||||
}
|
||||
}
|
||||
|
||||
void FootageViewerWidget::StartFootageDrag()
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
QVariant GizmoTraverser::ProcessVideoFootage(const Footage::StreamReference &ref, const rational &input_time)
|
||||
QVariant GizmoTraverser::ProcessVideoFootage(const FootageJob &ref, const rational &input_time)
|
||||
{
|
||||
Q_UNUSED(input_time)
|
||||
|
||||
Stream stream = ref.GetStream();
|
||||
VideoParams stream = ref.video_params();
|
||||
|
||||
return QVector2D(stream.width() * stream.pixel_aspect_ratio().toDouble(),
|
||||
stream.height());
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual QVariant ProcessVideoFootage(const Footage::StreamReference& stream, const rational &input_time) override;
|
||||
virtual QVariant ProcessVideoFootage(const FootageJob& stream, const rational &input_time) override;
|
||||
|
||||
virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user