diff --git a/app/codec/decoder.cpp b/app/codec/decoder.cpp index 26efa8ccc..0a4b441cc 100644 --- a/app/codec/decoder.cpp +++ b/app/codec/decoder.cpp @@ -48,7 +48,7 @@ Decoder::Decoder() : { } -bool Decoder::Open(StreamPtr fs) +bool Decoder::Open(Stream *fs) { QMutexLocker locker(&mutex_); @@ -203,7 +203,7 @@ QVector ReceiveListOfAllDecoders() return decoders; } -FootagePtr Decoder::Probe(Project* project, const QString &filename, const QAtomicInt* cancelled) +Footage* Decoder::Probe(Project* project, const QString &filename, const QAtomicInt* cancelled) { // Check for a valid filename if (filename.isEmpty()) { @@ -229,7 +229,7 @@ FootagePtr Decoder::Probe(Project* project, const QString &filename, const QAtom DecoderPtr decoder = decoder_list.at(i); - FootagePtr footage = decoder->Probe(filename, cancelled); + Footage* footage = decoder->Probe(filename, cancelled); if (footage) { QFileInfo file_info(filename); diff --git a/app/codec/decoder.h b/app/codec/decoder.h index 74137e33b..79e1a986b 100644 --- a/app/codec/decoder.h +++ b/app/codec/decoder.h @@ -86,7 +86,7 @@ public: * already open and the stream == the stream provided. Returns FALSE if the stream couldn't * be opened OR if already open and the stream is NOT the same. */ - bool Open(StreamPtr fs); + bool Open(Stream* fs); /** * @brief Retrieves a video frame from footage @@ -129,7 +129,7 @@ public: * * TRUE if a Decoder was successfully able to parse and probe this file. FALSE if not. */ - static FootagePtr Probe(Project *project, const QString& filename, const QAtomicInt *cancelled); + static Footage *Probe(Project *project, const QString& filename, const QAtomicInt *cancelled); /** * @brief Generate a Footage object from a file @@ -142,7 +142,7 @@ public: * * This function is re-entrant. */ - virtual FootagePtr Probe(const QString& filename, const QAtomicInt* cancelled) const = 0; + virtual Footage *Probe(const QString& filename, const QAtomicInt* cancelled) const = 0; /** * @brief Closes media/deallocates memory @@ -209,7 +209,7 @@ protected: QString GetIndexFilename(); struct CurrentlyConforming { - StreamPtr stream; + Stream* stream; AudioParams params; bool operator==(const CurrentlyConforming& rhs) const @@ -223,7 +223,7 @@ protected: * * This function is NOT thread safe and should therefore only be called by thread safe functions. */ - StreamPtr stream() const + Stream* stream() const { return stream_; } @@ -242,7 +242,7 @@ signals: private: SampleBufferPtr RetrieveAudioFromConform(const QString& conform_filename, const TimeRange &range); - StreamPtr stream_; + Stream* stream_; QMutex mutex_; diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index bfafa2b2f..acb7625c7 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -95,7 +95,7 @@ bool FFmpegDecoder::OpenInternal() FramePtr FFmpegDecoder::RetrieveStillImage(const rational &timecode, const int ÷r) { // This is a still image - VideoStreamPtr is = std::static_pointer_cast(stream()); + VideoStream* is = static_cast(stream()); QString img_filename = stream()->footage()->filename(); @@ -103,7 +103,7 @@ FramePtr FFmpegDecoder::RetrieveStillImage(const rational &timecode, const int & // If it's an image sequence, we'll probably need to transform the filename if (is->video_type() == VideoStream::kVideoTypeImageSequence) { - ts = std::static_pointer_cast(stream())->get_time_in_timebase_units(timecode); + ts = static_cast(stream())->get_time_in_timebase_units(timecode); img_filename = TransformImageSequenceFileName(stream()->footage()->filename(), ts); } else { @@ -126,8 +126,8 @@ FramePtr FFmpegDecoder::RetrieveStillImage(const rational &timecode, const int & frame->height, native_pix_fmt_, native_channel_count_, - std::static_pointer_cast(stream())->pixel_aspect_ratio(), - std::static_pointer_cast(stream())->interlacing(), + is->pixel_aspect_ratio(), + is->interlacing(), divider)); output_frame->set_timestamp(timecode); output_frame->allocate(); @@ -150,7 +150,7 @@ FramePtr FFmpegDecoder::RetrieveStillImage(const rational &timecode, const int & FramePtr FFmpegDecoder::RetrieveVideoInternal(const rational &timecode, const int ÷r) { - VideoStreamPtr vs = std::static_pointer_cast(stream()); + VideoStream* vs = static_cast(stream()); if (scale_divider_ != divider) { FreeScaler(); @@ -187,8 +187,8 @@ FramePtr FFmpegDecoder::RetrieveVideoInternal(const rational &timecode, const in vs->height(), native_pix_fmt_, native_channel_count_, - std::static_pointer_cast(stream())->pixel_aspect_ratio(), - std::static_pointer_cast(stream())->interlacing(), + vs->pixel_aspect_ratio(), + vs->interlacing(), divider)); copy->set_timestamp(timecode); copy->allocate(); @@ -218,13 +218,13 @@ QString FFmpegDecoder::id() return QStringLiteral("ffmpeg"); } -FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancelled) const +Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancelled) const { // Variable for receiving errors from FFmpeg int error_code; // Result to return - FootagePtr footage = nullptr; + Footage* footage = nullptr; // Convert QString to a C string QByteArray ba = filename.toUtf8(); @@ -242,7 +242,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance int64_t footage_duration = fmt_ctx->duration; - QVector streams(fmt_ctx->nb_streams); + QVector streams(fmt_ctx->nb_streams); // Dump it into the Footage object for (unsigned int i=0;inb_streams;i++) { @@ -252,7 +252,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance // Find decoder for this stream, if it exists we can proceed AVCodec* decoder = avcodec_find_decoder(avstream->codecpar->codec_id); - StreamPtr str; + Stream* str; if (decoder && (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO @@ -330,7 +330,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance av_packet_free(&pkt); } - VideoStreamPtr video_stream = std::make_shared(); + VideoStream* video_stream = new VideoStream(); if (image_is_still) { video_stream->set_video_type(VideoStream::kVideoTypeStill); @@ -355,7 +355,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance } else { // Create an audio stream object - AudioStreamPtr audio_stream = std::make_shared(); + AudioStream* audio_stream = new AudioStream(); uint64_t channel_layout = avstream->codecpar->channel_layout; if (!channel_layout) { @@ -401,7 +401,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance } else { // This is data we can't utilize at the moment, but we make a Stream object anyway to keep parity with the file - str = std::make_shared(); + str = new Stream(); // Set the correct codec type based on FFmpeg's result switch (avstream->codecpar->codec_type) { @@ -435,7 +435,7 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance // Check if we could pick up any streams in this file bool found_valid_streams = false; - foreach (StreamPtr stream, streams) { + foreach (Stream* stream, streams) { if (stream->type() != Stream::kUnknown) { found_valid_streams = true; break; @@ -444,12 +444,10 @@ FootagePtr FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cance if (found_valid_streams) { // We actually have footage we can return instead of nullptr - footage = std::make_shared(); + footage = new Footage(); - // Copy streams over - foreach (StreamPtr stream, streams) { - footage->add_stream(stream); - } + // Add streams + footage->add_streams(streams); } } @@ -469,7 +467,6 @@ QString FFmpegDecoder::FFmpegError(int error_code) bool FFmpegDecoder::ConformAudioInternal(const QString &filename, const AudioParams ¶ms, const QAtomicInt *cancelled) { // Iterate through each audio frame and extract the PCM data - AudioStreamPtr audio_stream = std::static_pointer_cast(stream()); // Seek to starting point instance_.Seek(0); @@ -810,7 +807,7 @@ FFmpegFramePool::ElementPtr FFmpegDecoder::RetrieveFrame(const int64_t& target_t void FFmpegDecoder::InitScaler(int divider) { - VideoStream* vs = static_cast(stream().get()); + VideoStream* vs = static_cast(stream()); int scaled_width = VideoParams::GetScaledDimension(vs->width(), divider); int scaled_height = VideoParams::GetScaledDimension(vs->height(), divider); diff --git a/app/codec/ffmpeg/ffmpegdecoder.h b/app/codec/ffmpeg/ffmpegdecoder.h index 6bbf80b1e..154e446e0 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.h +++ b/app/codec/ffmpeg/ffmpegdecoder.h @@ -57,7 +57,7 @@ public: virtual bool SupportsVideo() override{return true;} virtual bool SupportsAudio() override{return true;} - virtual FootagePtr Probe(const QString& filename, const QAtomicInt* cancelled) const override; + virtual Footage* Probe(const QString& filename, const QAtomicInt* cancelled) const override; protected: virtual bool OpenInternal() override; diff --git a/app/codec/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index f3fc5eb6c..dc00aaa40 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -51,7 +51,7 @@ QString OIIODecoder::id() return QStringLiteral("oiio"); } -FootagePtr OIIODecoder::Probe(const QString& filename, const QAtomicInt* cancelled) const +Footage *OIIODecoder::Probe(const QString& filename, const QAtomicInt* cancelled) const { Q_UNUSED(cancelled) @@ -75,9 +75,9 @@ FootagePtr OIIODecoder::Probe(const QString& filename, const QAtomicInt* cancell return nullptr; } - FootagePtr footage = std::make_shared(); + Footage* footage = new Footage(); - VideoStreamPtr image_stream = std::make_shared(); + VideoStream* image_stream = new VideoStream(); image_stream->set_width(in->spec().width); image_stream->set_height(in->spec().height); @@ -108,7 +108,7 @@ bool OIIODecoder::OpenInternal() // If we can open the filename provided, assume everything is working (even if this is an image // sequence with potentially missing frame) if (OpenImageHandler(stream()->footage()->filename())) { - VideoStreamPtr video_stream = std::static_pointer_cast(stream()); + VideoStream* video_stream = static_cast(stream()); if (video_stream->video_type() == VideoStream::kVideoTypeStill) { last_sequence_index_ = 0; @@ -123,7 +123,7 @@ bool OIIODecoder::OpenInternal() FramePtr OIIODecoder::RetrieveVideoInternal(const rational &timecode, const int& divider) { - VideoStreamPtr video_stream = std::static_pointer_cast(stream()); + VideoStream* video_stream = static_cast(stream()); int64_t sequence_index; diff --git a/app/codec/oiio/oiiodecoder.h b/app/codec/oiio/oiiodecoder.h index 9b06df1d6..04a1397b1 100644 --- a/app/codec/oiio/oiiodecoder.h +++ b/app/codec/oiio/oiiodecoder.h @@ -40,7 +40,7 @@ public: virtual bool SupportsVideo() override{return true;} - virtual FootagePtr Probe(const QString& filename, const QAtomicInt* cancelled) const override; + virtual Footage* Probe(const QString& filename, const QAtomicInt* cancelled) const override; protected: virtual bool OpenInternal() override; diff --git a/app/common/xmlutils.h b/app/common/xmlutils.h index 40a029732..25a67c56c 100644 --- a/app/common/xmlutils.h +++ b/app/common/xmlutils.h @@ -58,7 +58,7 @@ struct XMLNodeData { QHash node_ptrs; QHash output_ptrs; QList desired_connections; - QHash footage_ptrs; + QHash footage_ptrs; QList footage_connections; QList block_links; QHash item_ptrs; diff --git a/app/core.cpp b/app/core.cpp index 937a48c72..f9846885c 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -378,7 +378,7 @@ void Core::CreateNewFolder() Folder* folder = active_project_panel->GetSelectedFolder(); // Create new folder - ItemPtr new_folder = std::make_shared(); + Folder* new_folder = new Folder(); // Set a default name new_folder->set_name(tr("New Folder")); @@ -391,7 +391,7 @@ void Core::CreateNewFolder() Core::instance()->undo_stack()->push(aic); // Trigger an automatic rename so users can enter the folder name - active_project_panel->Edit(new_folder.get()); + active_project_panel->Edit(new_folder); } void Core::CreateNewSequence() @@ -404,18 +404,19 @@ void Core::CreateNewSequence() } // Create new sequence - SequencePtr new_sequence = CreateNewSequenceForProject(active_project); + Sequence* new_sequence = CreateNewSequenceForProject(active_project); // Set all defaults for the sequence new_sequence->set_default_parameters(); - SequenceDialog sd(new_sequence.get(), SequenceDialog::kNew, main_window_); + SequenceDialog sd(new_sequence, SequenceDialog::kNew, main_window_); // Make sure SequenceDialog doesn't make an undo command for editing the sequence, since we make an undo command for // adding it later on sd.SetUndoable(false); if (sd.exec() == QDialog::Accepted) { + // Create an undoable command ProjectViewModel::AddItemCommand* aic = new ProjectViewModel::AddItemCommand(GetActiveProjectModel(), GetSelectedFolderInActiveProject(), @@ -425,7 +426,13 @@ void Core::CreateNewSequence() Core::instance()->undo_stack()->push(aic); - Core::instance()->main_window()->OpenSequence(new_sequence.get()); + Core::instance()->main_window()->OpenSequence(new_sequence); + + } else { + + // If the dialog was accepted, ownership goes to the AddItemCommand. But if we get here, just delete + delete new_sequence; + } } @@ -538,7 +545,7 @@ bool Core::StartHeadlessExport() if (task_dialog.Run()) { std::unique_ptr p = std::unique_ptr(plm.GetLoadedProject()); - QList items = p->get_items_of_type(Item::kSequence); + QVector items = p->get_items_of_type(Item::kSequence); // Check if this project contains sequences if (items.isEmpty()) { @@ -546,7 +553,7 @@ bool Core::StartHeadlessExport() return false; } - SequencePtr sequence = nullptr; + Sequence* sequence = nullptr; // Check if this project contains multiple sequences if (items.size() > 1) { @@ -579,9 +586,9 @@ bool Core::StartHeadlessExport() } } - sequence = std::static_pointer_cast(items.at(sequence_index)); + sequence = static_cast(items.at(sequence_index)); } else { - sequence = std::static_pointer_cast(items.first()); + sequence = static_cast(items.first()); } ExportParams params; @@ -1087,9 +1094,9 @@ void Core::LabelNodes(const QVector &nodes) const } } -SequencePtr Core::CreateNewSequenceForProject(Project* project) const +Sequence *Core::CreateNewSequenceForProject(Project* project) const { - SequencePtr new_sequence = std::make_shared(); + Sequence* new_sequence = new Sequence(); // Get default name for this sequence (in the format "Sequence N", the first that doesn't exist) int sequence_number = 1; @@ -1282,12 +1289,12 @@ void Core::CacheActiveSequence(bool in_out_only) bool Core::ValidateFootageInLoadedProject(Project* project, const QString& project_saved_url) { - QList footage_we_couldnt_validate; + QVector footage_we_couldnt_validate; - QList project_footage = project->get_items_of_type(Item::kFootage); + QVector project_footage = project->get_items_of_type(Item::kFootage); - foreach (ItemPtr item, project_footage) { - FootagePtr footage = std::static_pointer_cast(item); + foreach (Item* item, project_footage) { + Footage* footage = static_cast(item); if (!QFileInfo::exists(footage->filename()) && !project_saved_url.isEmpty()) { // If the footage doesn't exist, it might have moved with the project diff --git a/app/core.h b/app/core.h index da6c2d9d2..c05fb5a23 100644 --- a/app/core.h +++ b/app/core.h @@ -246,7 +246,7 @@ public: /** * @brief Create a new sequence named appropriately for the active project */ - SequencePtr CreateNewSequenceForProject(Project *project) const; + Sequence* CreateNewSequenceForProject(Project *project) const; /** * @brief Opens a project from the recently opened list diff --git a/app/dialog/footageproperties/footageproperties.cpp b/app/dialog/footageproperties/footageproperties.cpp index e08da2564..5f00f0514 100644 --- a/app/dialog/footageproperties/footageproperties.cpp +++ b/app/dialog/footageproperties/footageproperties.cpp @@ -69,7 +69,7 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *foota int first_usable_stream = -1; for (int i=0;istreams().size();i++) { - StreamPtr stream = footage_->stream(i); + Stream* stream = footage_->stream(i); QListWidgetItem* item = new QListWidgetItem(stream->description(), track_list); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); @@ -78,10 +78,10 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *foota switch (stream->type()) { case Stream::kVideo: - stacked_widget_->addWidget(new VideoStreamProperties(std::static_pointer_cast(stream))); + stacked_widget_->addWidget(new VideoStreamProperties(static_cast(stream))); break; case Stream::kAudio: - stacked_widget_->addWidget(new AudioStreamProperties(std::static_pointer_cast(stream))); + stacked_widget_->addWidget(new AudioStreamProperties(static_cast(stream))); break; default: stacked_widget_->addWidget(new StreamProperties()); @@ -175,7 +175,7 @@ void FootagePropertiesDialog::FootageChangeCommand::undo_internal() footage_->set_name(old_name_); } -FootagePropertiesDialog::StreamEnableChangeCommand::StreamEnableChangeCommand(StreamPtr stream, bool enabled, QUndoCommand *command) : +FootagePropertiesDialog::StreamEnableChangeCommand::StreamEnableChangeCommand(Stream *stream, bool enabled, QUndoCommand *command) : UndoCommand(command), stream_(stream), old_enabled_(stream->enabled()), diff --git a/app/dialog/footageproperties/footageproperties.h b/app/dialog/footageproperties/footageproperties.h index 614fb8800..b0284de74 100644 --- a/app/dialog/footageproperties/footageproperties.h +++ b/app/dialog/footageproperties/footageproperties.h @@ -77,7 +77,7 @@ private: class StreamEnableChangeCommand : public UndoCommand { public: - StreamEnableChangeCommand(StreamPtr stream, + StreamEnableChangeCommand(Stream* stream, bool enabled, QUndoCommand* command = nullptr); @@ -88,7 +88,7 @@ private: virtual void undo_internal() override; private: - StreamPtr stream_; + Stream* stream_; bool old_enabled_; bool new_enabled_; diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp index 9f52c0e3e..19e8351bd 100644 --- a/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp @@ -22,7 +22,7 @@ namespace olive { -AudioStreamProperties::AudioStreamProperties(AudioStreamPtr stream) : +AudioStreamProperties::AudioStreamProperties(AudioStream *stream) : stream_(stream) { } diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.h b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h index f3a77c4b9..5997fdb6b 100644 --- a/app/dialog/footageproperties/streamproperties/audiostreamproperties.h +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h @@ -29,12 +29,12 @@ namespace olive { class AudioStreamProperties : public StreamProperties { public: - AudioStreamProperties(AudioStreamPtr stream); + AudioStreamProperties(AudioStream* stream); virtual void Accept(QUndoCommand* parent) override; private: - AudioStreamPtr stream_; + AudioStream* stream_; }; } diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp index c97b011c0..0df54a1e1 100644 --- a/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp @@ -34,7 +34,7 @@ namespace olive { -VideoStreamProperties::VideoStreamProperties(VideoStreamPtr stream) : +VideoStreamProperties::VideoStreamProperties(VideoStream *stream) : stream_(stream), video_premultiply_alpha_(nullptr) { @@ -94,7 +94,7 @@ VideoStreamProperties::VideoStreamProperties(VideoStreamPtr stream) : int imgseq_row = 0; - VideoStream* video_stream = static_cast(stream.get()); + VideoStream* video_stream = static_cast(stream); imgseq_layout->addWidget(new QLabel(tr("Start Index:")), imgseq_row, 0); @@ -146,7 +146,7 @@ void VideoStreamProperties::Accept(QUndoCommand *parent) } if (stream_->video_type() == VideoStream::kVideoTypeImageSequence) { - VideoStreamPtr video_stream = std::static_pointer_cast(stream_); + VideoStream* video_stream = static_cast(stream_); int64_t new_dur = imgseq_end_time_->GetValue() - imgseq_start_time_->GetValue() + 1; @@ -177,7 +177,7 @@ bool VideoStreamProperties::SanityCheck() return true; } -VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand(VideoStreamPtr stream, +VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand(VideoStream *stream, bool premultiplied, QString colorspace, VideoParams::Interlacing interlacing, @@ -218,7 +218,7 @@ void VideoStreamProperties::VideoStreamChangeCommand::undo_internal() stream_->set_pixel_aspect_ratio(old_pixel_ar_); } -VideoStreamProperties::ImageSequenceChangeCommand::ImageSequenceChangeCommand(VideoStreamPtr video_stream, int64_t start_index, int64_t duration, const rational &frame_rate, QUndoCommand *parent) : +VideoStreamProperties::ImageSequenceChangeCommand::ImageSequenceChangeCommand(VideoStream *video_stream, int64_t start_index, int64_t duration, const rational &frame_rate, QUndoCommand *parent) : UndoCommand(parent), video_stream_(video_stream), new_start_index_(start_index), diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.h b/app/dialog/footageproperties/streamproperties/videostreamproperties.h index 96416f596..8087f1949 100644 --- a/app/dialog/footageproperties/streamproperties/videostreamproperties.h +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.h @@ -36,7 +36,7 @@ class VideoStreamProperties : public StreamProperties { Q_OBJECT public: - VideoStreamProperties(VideoStreamPtr stream); + VideoStreamProperties(VideoStream* stream); virtual void Accept(QUndoCommand* parent) override; @@ -46,7 +46,7 @@ private: /** * @brief Attached video stream */ - VideoStreamPtr stream_; + VideoStream* stream_; /** * @brief Setting for associated/premultiplied alpha @@ -85,7 +85,7 @@ private: class VideoStreamChangeCommand : public UndoCommand { public: - VideoStreamChangeCommand(VideoStreamPtr stream, + VideoStreamChangeCommand(VideoStream* stream, bool premultiplied, QString colorspace, VideoParams::Interlacing interlacing, @@ -99,7 +99,7 @@ private: virtual void undo_internal() override; private: - VideoStreamPtr stream_; + VideoStream* stream_; bool new_premultiplied_; QString new_colorspace_; @@ -115,7 +115,7 @@ private: class ImageSequenceChangeCommand : public UndoCommand { public: - ImageSequenceChangeCommand(VideoStreamPtr video_stream, + ImageSequenceChangeCommand(VideoStream* video_stream, int64_t start_index, int64_t duration, const rational& frame_rate, @@ -128,7 +128,7 @@ private: virtual void undo_internal() override; private: - VideoStreamPtr video_stream_; + VideoStream* video_stream_; int64_t new_start_index_; int64_t old_start_index_; diff --git a/app/dialog/footagerelink/footagerelinkdialog.cpp b/app/dialog/footagerelink/footagerelinkdialog.cpp index cc8b149fb..1a840b6aa 100644 --- a/app/dialog/footagerelink/footagerelinkdialog.cpp +++ b/app/dialog/footagerelink/footagerelinkdialog.cpp @@ -31,7 +31,7 @@ namespace olive { -FootageRelinkDialog::FootageRelinkDialog(const QList& footage, QWidget* parent) : +FootageRelinkDialog::FootageRelinkDialog(const QVector &footage, QWidget* parent) : QDialog(parent), footage_(footage) { @@ -54,7 +54,7 @@ FootageRelinkDialog::FootageRelinkDialog(const QList& footage, QWidg table_->header()->setStretchLastSection(false); for (int i=0; i& footage, QWidg void FootageRelinkDialog::UpdateFootageItem(int index) { - FootagePtr f = footage_.at(index); + Footage* f = footage_.at(index); QTreeWidgetItem* item = table_->topLevelItem(index); item->setIcon(0, f->icon()); item->setText(1, f->filename()); @@ -96,7 +96,7 @@ void FootageRelinkDialog::UpdateFootageItem(int index) void FootageRelinkDialog::BrowseForFootage() { int index = sender()->property("index").toInt(); - FootagePtr f = footage_.at(index); + Footage* f = footage_.at(index); QFileInfo info(f->filename()); @@ -124,7 +124,7 @@ void FootageRelinkDialog::BrowseForFootage() // Check all other footage files for matches for (int it=0; itIsValid()) { diff --git a/app/dialog/footagerelink/footagerelinkdialog.h b/app/dialog/footagerelink/footagerelinkdialog.h index 91999ffc2..d1c04cd56 100644 --- a/app/dialog/footagerelink/footagerelinkdialog.h +++ b/app/dialog/footagerelink/footagerelinkdialog.h @@ -32,14 +32,14 @@ class FootageRelinkDialog : public QDialog { Q_OBJECT public: - FootageRelinkDialog(const QList& footage, QWidget* parent = nullptr); + FootageRelinkDialog(const QVector& footage, QWidget* parent = nullptr); private: void UpdateFootageItem(int index); QTreeWidget* table_; - QList footage_; + QVector footage_; private slots: void BrowseForFootage(); diff --git a/app/node/CMakeLists.txt b/app/node/CMakeLists.txt index a39950a51..e74c12f5b 100644 --- a/app/node/CMakeLists.txt +++ b/app/node/CMakeLists.txt @@ -41,6 +41,8 @@ set(OLIVE_SOURCES node/keyframe.cpp node/node.h node/node.cpp + node/nodecopypaste.h + node/nodecopypaste.cpp node/output.h node/output.cpp node/param.h diff --git a/app/node/graph.h b/app/node/graph.h index e722403d7..36d431a13 100644 --- a/app/node/graph.h +++ b/app/node/graph.h @@ -21,16 +21,18 @@ #ifndef NODEGRAPH_H #define NODEGRAPH_H -#include - #include "node/node.h" +#include "project/item/item.h" namespace olive { /** * @brief A collection of nodes + * + * This doesn't technically need to be a derivative of Item, but since both Item and NodeGraph need + * to be QObject derivatives, this simplifies Sequence. */ -class NodeGraph : public QObject +class NodeGraph : public Item { Q_OBJECT public: diff --git a/app/node/input.cpp b/app/node/input.cpp index b1ac562b8..c49b85d63 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -371,7 +371,7 @@ QString NodeInput::ValueToString(const DataType& data_type, const QVariant &valu } else if (data_type == kRational) { return value.value().toString(); } else if (data_type == kFootage) { - return QString::number(reinterpret_cast(value.value().get())); + return QString::number(value.value()); } else if (data_type == kTexture || data_type == kSamples || data_type == kBuffer) { diff --git a/app/node/input/media/media.cpp b/app/node/input/media/media.cpp index ea9aefb6e..ed80a6582 100644 --- a/app/node/input/media/media.cpp +++ b/app/node/input/media/media.cpp @@ -40,14 +40,14 @@ QVector MediaInput::Category() const return {kCategoryInput}; } -StreamPtr MediaInput::stream() +Stream *MediaInput::stream() const { - return footage_input_->get_standard_value().value(); + return Node::ValueToPtr(footage_input_->get_standard_value()); } -void MediaInput::SetStream(StreamPtr s) +void MediaInput::SetStream(Stream* s) { - footage_input_->set_standard_value(QVariant::fromValue(s)); + footage_input_->set_standard_value(Node::PtrToValue(s)); } bool MediaInput::IsMedia() const @@ -76,20 +76,20 @@ NodeValueTable MediaInput::Value(NodeValueDatabase &value) const void MediaInput::FootageChanged() { - StreamPtr new_footage = footage_input_->get_standard_value().value(); + Stream* new_footage = footage_input_->get_standard_value().value(); if (new_footage == connected_footage_) { return; } if (connected_footage_) { - disconnect(connected_footage_.get(), &Stream::ParametersChanged, this, &MediaInput::FootageParametersChanged); + disconnect(connected_footage_, &Stream::ParametersChanged, this, &MediaInput::FootageParametersChanged); } connected_footage_ = new_footage; if (connected_footage_) { - connect(connected_footage_.get(), &Stream::ParametersChanged, this, &MediaInput::FootageParametersChanged); + connect(connected_footage_, &Stream::ParametersChanged, this, &MediaInput::FootageParametersChanged); } } diff --git a/app/node/input/media/media.h b/app/node/input/media/media.h index 4a84a7d3d..2767e4f0b 100644 --- a/app/node/input/media/media.h +++ b/app/node/input/media/media.h @@ -58,8 +58,8 @@ public: virtual QVector Category() const override; - StreamPtr stream(); - void SetStream(StreamPtr s); + Stream* stream() const; + void SetStream(Stream *s); virtual bool IsMedia() const override; @@ -70,7 +70,7 @@ public: protected: NodeInput* footage_input_; - StreamPtr connected_footage_; + Stream* connected_footage_; private slots: void FootageChanged(); diff --git a/app/node/node.cpp b/app/node/node.cpp index 760da846b..fd198ebbb 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -430,7 +430,7 @@ void Node::Hash(QCryptographicHash &hash, const rational& time) const // We have one exception for FOOTAGE types, since we resolve the footage into a frame in the renderer if (input->data_type() == NodeParam::kFootage) { - StreamPtr stream = input->get_standard_value().value(); + Stream* stream = Node::ValueToPtr(input->get_standard_value()); if (stream) { // Add footage details to hash @@ -445,7 +445,7 @@ void Node::Hash(QCryptographicHash &hash, const rational& time) const hash.addData(QString::number(stream->index()).toUtf8()); if (stream->type() == Stream::kVideo) { - VideoStreamPtr image_stream = std::static_pointer_cast(stream); + VideoStream* image_stream = static_cast(stream); // Current color config and space hash.addData(image_stream->footage()->project()->color_manager()->GetConfigFilename().toUtf8()); @@ -460,7 +460,7 @@ void Node::Hash(QCryptographicHash &hash, const rational& time) const // Footage timestamp if (stream->type() == Stream::kVideo) { - VideoStreamPtr video_stream = std::static_pointer_cast(stream); + VideoStream* video_stream = static_cast(stream); int64_t video_ts = Timecode::time_to_timestamp(input_time, video_stream->timebase()); diff --git a/app/widget/nodecopypaste/nodecopypaste.cpp b/app/node/nodecopypaste.cpp similarity index 85% rename from app/widget/nodecopypaste/nodecopypaste.cpp rename to app/node/nodecopypaste.cpp index ccc6c235a..f78db63ff 100644 --- a/app/widget/nodecopypaste/nodecopypaste.cpp +++ b/app/node/nodecopypaste.cpp @@ -29,7 +29,7 @@ namespace olive { -void NodeCopyPasteWidget::CopyNodesToClipboard(const QVector &nodes, void *userdata) +void NodeCopyPasteService::CopyNodesToClipboard(const QVector &nodes, void *userdata) { QString copy_str; @@ -56,7 +56,7 @@ void NodeCopyPasteWidget::CopyNodesToClipboard(const QVector &nodes, voi Core::CopyStringToClipboard(copy_str); } -QVector NodeCopyPasteWidget::PasteNodesFromClipboard(Sequence *graph, QUndoCommand* command, void *userdata) +QVector NodeCopyPasteService::PasteNodesFromClipboard(Sequence *graph, QUndoCommand* command, void *userdata) { QString clipboard = Core::PasteStringFromClipboard(); @@ -135,7 +135,7 @@ QVector NodeCopyPasteWidget::PasteNodesFromClipboard(Sequence *graph, QU // Connect footage to existing footage if it exists if (!xml_node_data.footage_connections.isEmpty()) { // Get list of all footage from project - QList footage = graph->project()->get_items_of_type(Item::kFootage); + QVector footage = graph->project()->get_items_of_type(Item::kFootage); if (!footage.isEmpty()) { foreach (const XMLNodeData::FootageConnection& con, xml_node_data.footage_connections) { @@ -145,12 +145,10 @@ QVector NodeCopyPasteWidget::PasteNodesFromClipboard(Sequence *graph, QU bool found = false; - foreach (ItemPtr item, footage) { - const QList& streams = std::static_pointer_cast(item)->streams(); - - foreach (StreamPtr s, streams) { - if (s.get() == loaded_stream) { - con.input->set_standard_value(QVariant::fromValue(s)); + foreach (Item* item, footage) { + foreach (Stream* s, static_cast(item)->streams()) { + if (s == loaded_stream) { + con.input->set_standard_value(Node::PtrToValue(s)); found = true; break; } @@ -168,11 +166,11 @@ QVector NodeCopyPasteWidget::PasteNodesFromClipboard(Sequence *graph, QU return pasted_nodes; } -void NodeCopyPasteWidget::CopyNodesToClipboardInternal(QXmlStreamWriter*, void*) +void NodeCopyPasteService::CopyNodesToClipboardInternal(QXmlStreamWriter*, void*) { } -void NodeCopyPasteWidget::PasteNodesFromClipboardInternal(QXmlStreamReader* reader, XMLNodeData &xml_node_data, void*) +void NodeCopyPasteService::PasteNodesFromClipboardInternal(QXmlStreamReader* reader, XMLNodeData &xml_node_data, void*) { reader->skipCurrentElement(); } diff --git a/app/widget/nodecopypaste/nodecopypaste.h b/app/node/nodecopypaste.h similarity index 95% rename from app/widget/nodecopypaste/nodecopypaste.h rename to app/node/nodecopypaste.h index 00b7c30a0..456e46bb9 100644 --- a/app/widget/nodecopypaste/nodecopypaste.h +++ b/app/node/nodecopypaste.h @@ -29,10 +29,10 @@ namespace olive { -class NodeCopyPasteWidget +class NodeCopyPasteService { public: - NodeCopyPasteWidget() = default; + NodeCopyPasteService() = default; protected: void CopyNodesToClipboard(const QVector &nodes, void* userdata = nullptr); diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 5e3108fa7..7aa6face0 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -102,7 +102,7 @@ NodeValueTable NodeTraverser::GenerateBlockTable(const TrackOutput *track, const return table; } -QVariant NodeTraverser::ProcessVideoFootage(StreamPtr stream, const rational &input_time) +QVariant NodeTraverser::ProcessVideoFootage(VideoStream *stream, const rational &input_time) { Q_UNUSED(stream) Q_UNUSED(input_time) @@ -110,7 +110,7 @@ QVariant NodeTraverser::ProcessVideoFootage(StreamPtr stream, const rational &in return QVariant(); } -QVariant NodeTraverser::ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time) +QVariant NodeTraverser::ProcessAudioFootage(AudioStream *stream, const TimeRange &input_time) { Q_UNUSED(stream) Q_UNUSED(input_time) @@ -188,7 +188,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N QList* take_this_value_list = nullptr; if (v.type() == NodeParam::kFootage) { - StreamPtr s = v.data().value(); + Stream* s = Node::ValueToPtr(v.data()); if (s) { if (s->type() == Stream::kVideo) { @@ -214,7 +214,8 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N if (!got_cached_frame) { // Retrieve video frames foreach (const NodeValue& v, video_footage_to_retrieve) { - StreamPtr stream = v.data().value(); + // Assume this is a VideoStream, we did a type check earlier in the function + VideoStream* stream = Node::ValueToPtr(v.data()); if (stream->footage()->IsValid()) { QVariant value = ProcessVideoFootage(stream, range.in()); @@ -246,10 +247,11 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N // Retrieve audio samples foreach (const NodeValue& v, audio_footage_to_retrieve) { - StreamPtr stream = v.data().value(); + // Assume this is an AudioStream, we did a type check earlier in the function + AudioStream* stream = Node::ValueToPtr(v.data()); if (stream->footage()->IsValid()) { - QVariant value = ProcessAudioFootage(v.data().value(), range); + QVariant value = ProcessAudioFootage(stream, range); if (!value.isNull()) { output_params.Push(NodeParam::kSamples, value, node); diff --git a/app/node/traverser.h b/app/node/traverser.h index 097fb7e66..d9b29f0ac 100644 --- a/app/node/traverser.h +++ b/app/node/traverser.h @@ -46,9 +46,9 @@ protected: virtual NodeValueTable GenerateBlockTable(const TrackOutput *track, const TimeRange& range); - virtual QVariant ProcessVideoFootage(StreamPtr stream, const rational &input_time); + virtual QVariant ProcessVideoFootage(VideoStream* stream, const rational &input_time); - virtual QVariant ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time); + virtual QVariant ProcessAudioFootage(AudioStream* stream, const TimeRange &input_time); virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job); diff --git a/app/panel/project/project.cpp b/app/panel/project/project.cpp index 5a8318e93..5fbbd7a3c 100644 --- a/app/panel/project/project.cpp +++ b/app/panel/project/project.cpp @@ -215,7 +215,7 @@ void ProjectPanel::UpdateSubtitle() do { folder_path.prepend(QStringLiteral("/%1").arg(item->name())); - item = item->parent(); + item = item->item_parent(); } while (item != project()->root()); project_title.append(folder_path); diff --git a/app/panel/timebased/timebased.h b/app/panel/timebased/timebased.h index ef0690652..2484a3183 100644 --- a/app/panel/timebased/timebased.h +++ b/app/panel/timebased/timebased.h @@ -22,7 +22,7 @@ #define TIMEBASEDPANEL_H #include "widget/panel/panel.h" -#include "widget/timebased/timebased.h" +#include "widget/timebased/timebasedwidget.h" namespace olive { diff --git a/app/project/item/folder/folder.cpp b/app/project/item/folder/folder.cpp index 69c0aaa82..0618e4f3b 100644 --- a/app/project/item/folder/folder.cpp +++ b/app/project/item/folder/folder.cpp @@ -61,20 +61,20 @@ void Folder::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, uint ver return; } - ItemPtr child; + Item* child; if (reader->name() == QStringLiteral("folder")) { - child = std::make_shared(); + child = new Folder(); } else if (reader->name() == QStringLiteral("footage")) { - child = std::make_shared(); + child = new Footage(); } else if (reader->name() == QStringLiteral("sequence")) { - child = std::make_shared(); + child = new Sequence(); } else { reader->skipCurrentElement(); continue; } - add_child(child); + child->setParent(this); child->Load(reader, xml_node_data, version, cancelled); } } @@ -85,7 +85,7 @@ void Folder::Save(QXmlStreamWriter *writer) const writer->writeAttribute(QStringLiteral("ptr"), QString::number(reinterpret_cast(this))); - foreach (ItemPtr child, children()) { + foreach (Item* child, children()) { switch (child->type()) { case Item::kFootage: writer->writeStartElement(QStringLiteral("footage")); diff --git a/app/project/item/footage/audiostream.h b/app/project/item/footage/audiostream.h index 6941c8177..b0f53ee25 100644 --- a/app/project/item/footage/audiostream.h +++ b/app/project/item/footage/audiostream.h @@ -63,8 +63,6 @@ private: }; -using AudioStreamPtr = std::shared_ptr; - } #endif // AUDIOSTREAM_H diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index 08c358208..137b94127 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -78,7 +78,7 @@ void Footage::Save(QXmlStreamWriter *writer) const TimelinePoints::Save(writer); writer->writeEndElement(); // points - foreach (StreamPtr stream, streams_) { + foreach (Stream* stream, streams_) { writer->writeStartElement(QStringLiteral("stream")); stream->Save(writer); writer->writeEndElement(); // stream @@ -119,23 +119,27 @@ void Footage::set_timestamp(const qint64 &t) timestamp_ = t; } -void Footage::add_stream(StreamPtr s) +void Footage::add_stream(Stream* s) { // Set its footage parent to this - s->set_footage(this); + s->setParent(this); // Add a copy of this stream to the list streams_.append(s); } -StreamPtr Footage::stream(int index) const +void Footage::add_streams(const QVector &streams) { - return streams_.at(index); + foreach (Stream* s, streams) { + s->setParent(this); + } + + streams_.append(streams); } -const QList &Footage::streams() const +Stream* Footage::stream(int index) const { - return streams_; + return streams_.at(index); } int Footage::stream_count() const @@ -161,16 +165,15 @@ void Footage::set_decoder(const QString &id) QIcon Footage::icon() { if (valid_ && !streams_.isEmpty()) { - StreamPtr first_stream = streams_.first(); + // Prioritize video > audio > image + Stream* s = get_first_enabled_stream_of_type(Stream::kVideo); - if (first_stream->type() == Stream::kVideo) { - if (std::static_pointer_cast(first_stream)->video_type() == VideoStream::kVideoTypeStill) { - return icon::Image; - } else { - return icon::Video; - } - } else if (first_stream->type() == Stream::kAudio) { + if (s && static_cast(s)->video_type() != VideoStream::kVideoTypeStill) { + return icon::Video; + } else if (HasEnabledStreamsOfType(Stream::kAudio)) { return icon::Audio; + } else if (s && static_cast(s)->video_type() == VideoStream::kVideoTypeStill) { + return icon::Image; } } @@ -180,10 +183,10 @@ QIcon Footage::icon() QString Footage::duration() { // Find longest stream duration - StreamPtr longest_stream = nullptr; + Stream* longest_stream = nullptr; rational longest; - foreach (StreamPtr stream, streams_) { + foreach (Stream* stream, streams_) { if (stream->enabled() && (stream->type() == Stream::kVideo || stream->type() == Stream::kAudio)) { rational this_stream_dur = Timecode::timestamp_to_time(stream->duration(), stream->timebase()); @@ -197,7 +200,7 @@ QString Footage::duration() if (longest_stream) { if (longest_stream->type() == Stream::kVideo) { - VideoStreamPtr video_stream = std::static_pointer_cast(longest_stream); + VideoStream* video_stream = static_cast(longest_stream); if (video_stream->video_type() != VideoStream::kVideoTypeStill) { int64_t duration = video_stream->duration(); @@ -214,8 +217,6 @@ QString Footage::duration() Core::instance()->GetTimecodeDisplay()); } } else if (longest_stream->type() == Stream::kAudio) { - AudioStreamPtr audio_stream = std::static_pointer_cast(longest_stream); - // If we're showing in a timecode, we prefer showing audio in seconds instead Timecode::Display display = Core::instance()->GetTimecodeDisplay(); if (display == Timecode::kTimecodeDropFrame @@ -238,16 +239,16 @@ QString Footage::rate() return QString(); } - if (HasStreamsOfType(Stream::kVideo)) { + if (HasEnabledStreamsOfType(Stream::kVideo)) { // This is a video editor, prioritize video streams - VideoStreamPtr video_stream = std::static_pointer_cast(get_first_stream_of_type(Stream::kVideo)); + VideoStream* video_stream = static_cast(get_first_enabled_stream_of_type(Stream::kVideo)); if (video_stream->video_type() != VideoStream::kVideoTypeStill) { return QCoreApplication::translate("Footage", "%1 FPS").arg(video_stream->frame_rate().toDouble()); } - } else if (HasStreamsOfType(Stream::kAudio)) { + } else if (HasEnabledStreamsOfType(Stream::kAudio)) { // No video streams, return audio - AudioStreamPtr audio_stream = std::static_pointer_cast(streams_.first()); + AudioStream* audio_stream = static_cast(streams_.first()); return QCoreApplication::translate("Footage", "%1 Hz").arg(audio_stream->sample_rate()); } @@ -259,7 +260,7 @@ quint64 Footage::get_enabled_stream_flags() const quint64 enabled_streams = 0; quint64 stream_enabler = 1; - foreach (StreamPtr s, streams_) { + foreach (Stream* s, streams_) { if (s->enabled()) { enabled_streams |= stream_enabler; } @@ -276,10 +277,10 @@ void Footage::ClearStreams() streams_.clear(); } -bool Footage::HasStreamsOfType(const Stream::Type &type) const +bool Footage::HasEnabledStreamsOfType(const Stream::Type &type) const { // Return true if any streams are video streams - foreach (StreamPtr stream, streams_) { + foreach (Stream* stream, streams_) { if (stream->enabled() && stream->type() == type) { return true; } @@ -288,9 +289,9 @@ bool Footage::HasStreamsOfType(const Stream::Type &type) const return false; } -StreamPtr Footage::get_first_stream_of_type(const Stream::Type &type) const +Stream *Footage::get_first_enabled_stream_of_type(const Stream::Type &type) const { - foreach (StreamPtr stream, streams_) { + foreach (Stream* stream, streams_) { if (stream->enabled() && stream->type() == type) { return stream; } @@ -299,7 +300,7 @@ StreamPtr Footage::get_first_stream_of_type(const Stream::Type &type) const return nullptr; } -bool Footage::CompareFootageToFile(FootagePtr footage, const QString &filename) +bool Footage::CompareFootageToFile(Footage *footage, const QString &filename) { // Heuristic to determine if file has changed QFileInfo info(filename); @@ -311,9 +312,9 @@ bool Footage::CompareFootageToFile(FootagePtr footage, const QString &filename) } else { // Footage may have changed and we'll have to re-probe it. It also may not have, in which // case nothing needs to change. - ItemPtr item = Decoder::Probe(footage->project(), filename, nullptr); + std::unique_ptr item(Decoder::Probe(footage->project(), filename, nullptr)); - if (item && item->type() == footage->type()) { + if (item) { // Item is the same type, that's a good sign. Let's look for any differences. // FIXME: Implement this return true; @@ -325,7 +326,7 @@ bool Footage::CompareFootageToFile(FootagePtr footage, const QString &filename) return false; } -bool Footage::CompareFootageToItsFilename(FootagePtr footage) +bool Footage::CompareFootageToItsFilename(Footage *footage) { return CompareFootageToFile(footage, footage->filename()); } @@ -336,7 +337,7 @@ void Footage::UpdateTooltip() QString tip = QCoreApplication::translate("Footage", "Filename: %1").arg(filename()); if (!streams_.isEmpty()) { - foreach (StreamPtr s, streams_) { + foreach (Stream* s, streams_) { if (s->enabled()) { tip.append("\n"); tip.append(s->description()); diff --git a/app/project/item/footage/footage.h b/app/project/item/footage/footage.h index a01c35600..71ec994ea 100644 --- a/app/project/item/footage/footage.h +++ b/app/project/item/footage/footage.h @@ -32,9 +32,6 @@ namespace olive { -class Footage; -using FootagePtr = std::shared_ptr; - /** * @brief A reference to an external media file with metadata in a project structure * @@ -44,6 +41,7 @@ using FootagePtr = std::shared_ptr; */ class Footage : public Item, public TimelinePoints { + Q_OBJECT public: /** * @brief Footage Constructor @@ -136,7 +134,9 @@ public: * * A pointer to a stream object. The Footage takes ownership of this object and will free it when it's deleted. */ - void add_stream(StreamPtr s); + void add_stream(Stream *s); + + void add_streams(const QVector& streams); /** * @brief Retrieve a stream at the given index. @@ -150,12 +150,15 @@ public: * * The stream at the index provided */ - StreamPtr stream(int index) const; + Stream *stream(int index) const; /** * @brief Returns a list of the streams in this Footage */ - const QList& streams() const; + const QVector& streams() const + { + return streams_; + } /** * @brief Retrieve total number of streams in this Footage file @@ -198,12 +201,12 @@ public: * * The stream type to check for */ - bool HasStreamsOfType(const Stream::Type& type) const; + bool HasEnabledStreamsOfType(const Stream::Type& type) const; - StreamPtr get_first_stream_of_type(const Stream::Type& type) const; + Stream* get_first_enabled_stream_of_type(const Stream::Type& type) const; - static bool CompareFootageToFile(FootagePtr footage, const QString& filename); - static bool CompareFootageToItsFilename(FootagePtr footage); + static bool CompareFootageToFile(Footage* footage, const QString& filename); + static bool CompareFootageToItsFilename(Footage* footage); private: /** @@ -240,7 +243,7 @@ private: /** * @brief Internal streams array */ - QList streams_; + QVector streams_; /** * @brief Internal attached decoder ID diff --git a/app/project/item/footage/stream.cpp b/app/project/item/footage/stream.cpp index 3e4d59fb3..75fb5db94 100644 --- a/app/project/item/footage/stream.cpp +++ b/app/project/item/footage/stream.cpp @@ -26,7 +26,6 @@ namespace olive { Stream::Stream() : - footage_(nullptr), type_(kUnknown), enabled_(true) { @@ -37,22 +36,22 @@ Stream::~Stream() { } -StreamPtr Stream::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt* cancelled) +Stream *Stream::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt* cancelled) { - StreamPtr stream; + Stream* stream = nullptr; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("type")) { Stream::Type type = static_cast(attr.value().toInt()); switch (type) { case Stream::kVideo: - stream = std::make_shared(); + stream = new VideoStream(); break; case Stream::kAudio: - stream = std::make_shared(); + stream = new AudioStream(); break; default: - stream = std::make_shared(); + stream = new Stream(); stream->set_type(type); break; } @@ -62,6 +61,10 @@ StreamPtr Stream::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, con } } + if (!stream) { + return nullptr; + } + while (XMLReadNextStartElement(reader)) { if (reader->name() == QStringLiteral("ptr")) { xml_node_data.footage_ptrs.insert(reader->readElementText().toULongLong(), stream); @@ -121,12 +124,7 @@ void Stream::set_type(const Stream::Type &type) Footage *Stream::footage() const { - return footage_; -} - -void Stream::set_footage(Footage *f) -{ - footage_ = f; + return dynamic_cast(parent()); } const rational &Stream::timebase() const diff --git a/app/project/item/footage/stream.h b/app/project/item/footage/stream.h index e6d850ddf..9e5d055fc 100644 --- a/app/project/item/footage/stream.h +++ b/app/project/item/footage/stream.h @@ -33,8 +33,6 @@ namespace olive { class Footage; -class Stream; -using StreamPtr = std::shared_ptr; struct XMLNodeData; /** @@ -69,7 +67,7 @@ public: */ virtual ~Stream() override; - static StreamPtr Load(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled); + static Stream* Load(QXmlStreamReader* reader, XMLNodeData& xml_node_data, const QAtomicInt* cancelled); void Save(QXmlStreamWriter *writer) const; @@ -79,7 +77,6 @@ public: void set_type(const Type& type); Footage* footage() const; - void set_footage(Footage* f); const rational& timebase() const; void set_timebase(const rational& timebase); @@ -109,8 +106,6 @@ signals: void ParametersChanged(); private: - Footage* footage_; - rational timebase_; int64_t duration_; @@ -127,7 +122,4 @@ private: } -#include -Q_DECLARE_METATYPE(olive::StreamPtr) - #endif // STREAM_H diff --git a/app/project/item/footage/videostream.h b/app/project/item/footage/videostream.h index e6f5f345d..9c5569385 100644 --- a/app/project/item/footage/videostream.h +++ b/app/project/item/footage/videostream.h @@ -174,8 +174,6 @@ private: }; -using VideoStreamPtr = std::shared_ptr; - } #endif // VIDEOSTREAM_H diff --git a/app/project/item/item.cpp b/app/project/item/item.cpp index 33657825e..0495c3729 100644 --- a/app/project/item/item.cpp +++ b/app/project/item/item.cpp @@ -23,7 +23,7 @@ namespace olive { Item::Item() : - parent_(nullptr), + item_parent_(nullptr), project_(nullptr) { } @@ -32,65 +32,6 @@ Item::~Item() { } -void Item::add_child(ItemPtr c) -{ - if (c->parent_ == this) { - return; - } - - if (c->parent_ != nullptr) { - c->parent_->remove_child(c.get()); - } - - children_.append(c); - c->parent_ = this; -} - -void Item::remove_child(Item *c) -{ - if (c->parent_ != this) { - return; - } - - // Remove all instances of this child in the list - for (int i=0;iparent_ = nullptr; -} - -int Item::child_count() const -{ - return children_.size(); -} - -Item *Item::child(int i) const -{ - return children_.at(i).get(); -} - -const QList &Item::children() const -{ - return children_; -} - -ItemPtr Item::get_shared_ptr() const -{ - QList siblings = parent()->children(); - - foreach (ItemPtr s, siblings) { - if (s.get() == this) { - return s; - } - } - - return nullptr; -} - const QString &Item::name() const { return name_; @@ -123,17 +64,12 @@ QString Item::rate() return QString(); } -Item *Item::parent() const -{ - return parent_; -} - const Item *Item::root() const { const Item* item = this; - while (item->parent()) { - item = item->parent(); + while (item->item_parent()) { + item = item->item_parent(); } return item; @@ -151,11 +87,11 @@ void Item::set_project(Project *project) project_ = project; } -QList Item::get_children_of_type(Type type, bool recursive) const +QVector Item::get_children_of_type(Type type, bool recursive) const { - QList list; + QVector list; - foreach (ItemPtr item, children_) { + foreach (Item* item, item_children_) { if (item->type() == type) { list.append(item); } @@ -182,12 +118,31 @@ void Item::NameChangedEvent(const QString &) { } +void Item::childEvent(QChildEvent *event) +{ + QObject::childEvent(event); + + Item* cast_test = dynamic_cast(event->child()); + + if (cast_test) { + if (event->type() == QEvent::ChildAdded) { + + item_children_.append(cast_test); + cast_test->item_parent_ = this; + + } else if (event->type() == QEvent::ChildRemoved) { + + item_children_.removeOne(cast_test); + cast_test->item_parent_ = nullptr; + + } + } +} + bool Item::ChildExistsWithNameInternal(const QString &name, Item *folder) { // Loop through all children - for (int i=0;ichild_count();i++) { - Item* child = folder->child(i); - + foreach (Item* child, folder->item_children_) { // If this child has the same name, return true if (child->name() == name) { return true; diff --git a/app/project/item/item.h b/app/project/item/item.h index efaaaf963..3d64daa32 100644 --- a/app/project/item/item.h +++ b/app/project/item/item.h @@ -37,17 +37,15 @@ namespace olive { class Project; -class Item; -using ItemPtr = std::shared_ptr; - /** * @brief A base-class representing any element in a Project * * Project objects implement a parent-child hierarchy of Items that can be used throughout the Project. The Item class * itself is abstract and will need to be subclassed to be used in a Project. */ -class Item +class Item : public QObject { + Q_OBJECT public: enum Type { kFolder, @@ -65,21 +63,26 @@ public: */ virtual ~Item(); - DISABLE_COPY_MOVE(Item) - virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt *cancelled) = 0; virtual void Save(QXmlStreamWriter* writer) const = 0; virtual Type type() const = 0; - void add_child(ItemPtr c); - void remove_child(Item* c); - int child_count() const; - Item* child(int i) const; - const QList& children() const; + int item_child_count() const + { + return item_children_.size(); + } - ItemPtr get_shared_ptr() const; + Item* item_child(int i) const + { + return item_children_.at(i); + } + + const QVector& children() const + { + return item_children_; + } const QString& name() const; void set_name(const QString& n); @@ -93,13 +96,17 @@ public: virtual QString rate(); - Item *parent() const; + Item *item_parent() const + { + return item_parent_; + } + const Item* root() const; Project* project() const; void set_project(Project* project); - QList get_children_of_type(Type type, bool recursive) const; + QVector get_children_of_type(Type type, bool recursive) const; virtual bool CanHaveChildren() const; @@ -108,12 +115,14 @@ public: protected: virtual void NameChangedEvent(const QString& name); + virtual void childEvent(QChildEvent *event) override; + private: - bool ChildExistsWithNameInternal(const QString& name, Item* folder); + static bool ChildExistsWithNameInternal(const QString& name, Item* folder); - QList children_; + QVector item_children_; - Item* parent_; + Item* item_parent_; Project* project_; diff --git a/app/project/item/sequence/sequence.cpp b/app/project/item/sequence/sequence.cpp index a24d93b85..e2767e537 100644 --- a/app/project/item/sequence/sequence.cpp +++ b/app/project/item/sequence/sequence.cpp @@ -171,12 +171,6 @@ void Sequence::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, uint v // Link blocks XMLLinkBlocks(xml_node_data); - - // Ensure this and all children are in the main thread - // NOTE: It might be good to move the Item system to QObjects so they inherit their thread - if (QThread::currentThread() != qApp->thread()) { - moveToThread(qApp->thread()); - } } void Sequence::Save(QXmlStreamWriter *writer) const @@ -302,7 +296,7 @@ void Sequence::set_parameters_from_footage(const QList footage) bool found_audio_params = false; foreach (Footage* f, footage) { - foreach (StreamPtr s, f->streams()) { + foreach (Stream* s, f->streams()) { if (!s->enabled()) { continue; } @@ -310,7 +304,7 @@ void Sequence::set_parameters_from_footage(const QList footage) switch (s->type()) { case Stream::kVideo: { - VideoStream* vs = static_cast(s.get()); + VideoStream* vs = static_cast(s); // If this is a video stream, use these parameters if (!found_video_params) { @@ -339,7 +333,7 @@ void Sequence::set_parameters_from_footage(const QList footage) } case Stream::kAudio: if (!found_audio_params) { - AudioStream* as = static_cast(s.get()); + AudioStream* as = static_cast(s); set_audio_params(AudioParams(as->sample_rate(), as->channel_layout(), AudioParams::kInternalFormat)); found_audio_params = true; } diff --git a/app/project/item/sequence/sequence.h b/app/project/item/sequence/sequence.h index aab7920df..023f9378f 100644 --- a/app/project/item/sequence/sequence.h +++ b/app/project/item/sequence/sequence.h @@ -31,14 +31,12 @@ namespace olive { -class Sequence; -using SequencePtr = std::shared_ptr; - /** * @brief The main timeline object, an graph of edited clips that forms a complete edit */ -class Sequence : public Item, public NodeGraph, public TimelinePoints +class Sequence : public NodeGraph, public TimelinePoints { + Q_OBJECT public: Sequence(); diff --git a/app/project/project.cpp b/app/project/project.cpp index 84f15dd8b..c29e1b845 100644 --- a/app/project/project.cpp +++ b/app/project/project.cpp @@ -161,7 +161,7 @@ ColorManager *Project::color_manager() return &color_manager_; } -QList Project::get_items_of_type(Item::Type type) const +QVector Project::get_items_of_type(Item::Type type) const { return root_.get_children_of_type(type, true); } @@ -204,12 +204,12 @@ const QString &Project::cache_path(bool default_if_empty) const void Project::ColorConfigChanged() { - QList footage = this->get_items_of_type(Item::kFootage); + QVector footage = this->get_items_of_type(Item::kFootage); - foreach (ItemPtr item, footage) { - foreach (StreamPtr s, std::static_pointer_cast(item)->streams()) { + foreach (Item* item, footage) { + foreach (Stream* s, static_cast(item)->streams()) { if (s->type() == Stream::kVideo) { - std::static_pointer_cast(s)->ColorConfigChanged(); + static_cast(s)->ColorConfigChanged(); } } } @@ -217,12 +217,12 @@ void Project::ColorConfigChanged() void Project::DefaultColorSpaceChanged() { - QList footage = this->get_items_of_type(Item::kFootage); + QVector footage = this->get_items_of_type(Item::kFootage); - foreach (ItemPtr item, footage) { - foreach (StreamPtr s, std::static_pointer_cast(item)->streams()) { + foreach (Item* item, footage) { + foreach (Stream* s, static_cast(item)->streams()) { if (s->type() == Stream::kVideo) { - std::static_pointer_cast(s)->DefaultColorSpaceChanged(); + static_cast(s)->DefaultColorSpaceChanged(); } } } diff --git a/app/project/project.h b/app/project/project.h index d6d801ca5..59501cd97 100644 --- a/app/project/project.h +++ b/app/project/project.h @@ -61,7 +61,7 @@ public: ColorManager* color_manager(); - QList get_items_of_type(Item::Type type) const; + QVector get_items_of_type(Item::Type type) const; bool is_modified() const; void set_modified(bool e); diff --git a/app/project/projectviewmodel.cpp b/app/project/projectviewmodel.cpp index f11135e3e..b709e460a 100644 --- a/app/project/projectviewmodel.cpp +++ b/app/project/projectviewmodel.cpp @@ -64,7 +64,7 @@ QModelIndex ProjectViewModel::index(int row, int column, const QModelIndex &pare Item* item_parent = GetItemObjectFromIndex(parent); // Return an index to this object - return createIndex(row, column, item_parent->child(row)); + return createIndex(row, column, item_parent->item_child(row)); } QModelIndex ProjectViewModel::parent(const QModelIndex &child) const @@ -73,7 +73,7 @@ QModelIndex ProjectViewModel::parent(const QModelIndex &child) const Item* item = GetItemObjectFromIndex(child); // Get Item's parent object - Item* par = item->parent(); + Item* par = item->item_parent(); // If the parent is the root, return an empty index if (par == project_->root()) { @@ -99,11 +99,11 @@ int ProjectViewModel::rowCount(const QModelIndex &parent) const // If the index is the root, return the root child count if (parent == QModelIndex()) { - return project_->root()->child_count(); + return project_->root()->item_child_count(); } // Otherwise, the index must contain a valid pointer, so we just return its child count - return GetItemObjectFromIndex(parent)->child_count(); + return GetItemObjectFromIndex(parent)->item_child_count(); } int ProjectViewModel::columnCount(const QModelIndex &parent) const @@ -375,7 +375,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action // If we didn't drop onto an item, find the nearest parent folder (should eventually terminate at root either way) while (!drop_item->CanHaveChildren()) { - drop_item = drop_item->parent(); + drop_item = drop_item->item_parent(); } // Trigger an import @@ -385,7 +385,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action return false; } -void ProjectViewModel::AddChild(Item *parent, ItemPtr child) +void ProjectViewModel::AddChild(Item *parent, Item *child) { QModelIndex parent_index; @@ -393,14 +393,14 @@ void ProjectViewModel::AddChild(Item *parent, ItemPtr child) parent_index = CreateIndexFromItem(parent); } - beginInsertRows(parent_index, parent->child_count(), parent->child_count()); + beginInsertRows(parent_index, parent->item_child_count(), parent->item_child_count()); - parent->add_child(child); + child->setParent(parent); endInsertRows(); } -void ProjectViewModel::RemoveChild(Item *parent, Item *child) +void ProjectViewModel::RemoveChild(Item *parent, Item *child, QObject *new_parent) { QModelIndex parent_index; @@ -412,7 +412,7 @@ void ProjectViewModel::RemoveChild(Item *parent, Item *child) beginRemoveRows(parent_index, child_row, child_row); - parent->remove_child(child); + child->setParent(new_parent); endRemoveRows(); } @@ -435,11 +435,11 @@ int ProjectViewModel::IndexOfChild(Item *item) const return -1; } - Item* parent = item->parent(); + Item* parent = item->item_parent(); if (parent != nullptr) { - for (int i=0;ichild_count();i++) { - if (parent->child(i) == item) { + for (int i=0;iitem_child_count();i++) { + if (parent->item_child(i) == item) { return i; } } @@ -452,7 +452,7 @@ int ProjectViewModel::ChildCount(const QModelIndex &index) { Item* item = GetItemObjectFromIndex(index); - return item->child_count(); + return item->item_child_count(); } Item *ProjectViewModel::GetItemObjectFromIndex(const QModelIndex &index) const @@ -468,7 +468,7 @@ bool ProjectViewModel::ItemIsParentOfChild(Item *parent, Item *child) const { // Loop through parent hierarchy checking if `parent` is one of its parents do { - child = child->parent(); + child = child->item_parent(); if (parent == child) { return true; @@ -484,11 +484,10 @@ void ProjectViewModel::MoveItemInternal(Item *item, Item *destination) QModelIndex destination_index = CreateIndexFromItem(destination); - beginMoveRows(item_index.parent(), item_index.row(), item_index.row(), destination_index, destination->child_count()); + beginMoveRows(item_index.parent(), item_index.row(), item_index.row(), + destination_index, destination->item_child_count()); - ItemPtr item_ptr = item->get_shared_ptr(); - - destination->add_child(item_ptr); + item->setParent(destination); endMoveRows(); } @@ -553,13 +552,18 @@ void ProjectViewModel::RenameItemCommand::undo_internal() model_->RenameChild(item_, old_name_); } -ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent) : +ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item* folder, Item* child, QUndoCommand* parent) : UndoCommand(parent), model_(model), parent_(folder), - child_(child), - done_(false) + child_(child) { + // Ensure all operations are done in folder's thread + if (memory_manager_.thread() != parent_->thread()) { + memory_manager_.moveToThread(parent_->thread()); + } + + child_->setParent(&memory_manager_); } Project *ProjectViewModel::AddItemCommand::GetRelevantProject() const @@ -570,22 +574,24 @@ Project *ProjectViewModel::AddItemCommand::GetRelevantProject() const void ProjectViewModel::AddItemCommand::redo_internal() { model_->AddChild(parent_, child_); - - done_ = true; } void ProjectViewModel::AddItemCommand::undo_internal() { - model_->RemoveChild(parent_, child_.get()); - - done_ = false; + model_->RemoveChild(parent_, child_, &memory_manager_); } -ProjectViewModel::RemoveItemCommand::RemoveItemCommand(ProjectViewModel *model, ItemPtr item, QUndoCommand *parent) : +ProjectViewModel::RemoveItemCommand::RemoveItemCommand(ProjectViewModel *model, Item *item, QUndoCommand *parent) : UndoCommand(parent), model_(model), item_(item) { + // Ensure all operations are done in folder's thread + parent_ = item_->item_parent(); + + if (memory_manager_.thread() != item_->thread()) { + memory_manager_.moveToThread(item_->thread()); + } } Project *ProjectViewModel::RemoveItemCommand::GetRelevantProject() const @@ -595,8 +601,7 @@ Project *ProjectViewModel::RemoveItemCommand::GetRelevantProject() const void ProjectViewModel::RemoveItemCommand::redo_internal() { - parent_ = item_->parent(); - model_->RemoveChild(parent_, item_.get()); + model_->RemoveChild(parent_, item_, &memory_manager_); } void ProjectViewModel::RemoveItemCommand::undo_internal() diff --git a/app/project/projectviewmodel.h b/app/project/projectviewmodel.h index e524684ba..9f790a96a 100644 --- a/app/project/projectviewmodel.h +++ b/app/project/projectviewmodel.h @@ -100,8 +100,8 @@ public: virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; /** Other model functions */ - void AddChild(Item* parent, ItemPtr child); - void RemoveChild(Item* parent, Item* child); + void AddChild(Item* parent, Item* child); + void RemoveChild(Item* parent, Item* child, QObject* new_parent); void RenameChild(Item* item, const QString& name); /** @@ -157,7 +157,7 @@ public: */ class AddItemCommand : public UndoCommand { public: - AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent = nullptr); + AddItemCommand(ProjectViewModel* model, Item* folder, Item *child, QUndoCommand* parent = nullptr); virtual Project* GetRelevantProject() const override; @@ -169,8 +169,9 @@ public: private: ProjectViewModel* model_; Item* parent_; - ItemPtr child_; - bool done_; + Item* child_; + QObject memory_manager_; + }; /** @@ -178,7 +179,7 @@ public: */ class RemoveItemCommand : public UndoCommand { public: - RemoveItemCommand(ProjectViewModel* model, ItemPtr item, QUndoCommand* parent = nullptr); + RemoveItemCommand(ProjectViewModel* model, Item* item, QUndoCommand* parent = nullptr); virtual Project* GetRelevantProject() const override; @@ -189,10 +190,9 @@ public: private: ProjectViewModel* model_; - - ItemPtr item_; - + Item* item_; Item* parent_; + QObject memory_manager_; }; diff --git a/app/render/renderprocessor.cpp b/app/render/renderprocessor.cpp index 27bd924c9..5c0c4c545 100644 --- a/app/render/renderprocessor.cpp +++ b/app/render/renderprocessor.cpp @@ -153,7 +153,7 @@ void RenderProcessor::Run() } } -DecoderPtr RenderProcessor::ResolveDecoderFromInput(StreamPtr stream) +DecoderPtr RenderProcessor::ResolveDecoderFromInput(Stream *stream) { if (!stream) { qWarning() << "Attempted to resolve the decoder of a null stream"; @@ -162,14 +162,14 @@ DecoderPtr RenderProcessor::ResolveDecoderFromInput(StreamPtr stream) QMutexLocker locker(decoder_cache_->mutex()); - DecoderPtr decoder = decoder_cache_->value(stream.get()); + DecoderPtr decoder = decoder_cache_->value(stream); if (!decoder) { // No decoder decoder = Decoder::CreateFromID(stream->footage()->decoder()); if (decoder->Open(stream)) { - decoder_cache_->insert(stream.get(), decoder); + decoder_cache_->insert(stream, decoder); } else { qWarning() << "Failed to open decoder for" << stream->footage()->filename() << "::" << stream->index(); @@ -262,14 +262,13 @@ NodeValueTable RenderProcessor::GenerateBlockTable(const TrackOutput *track, con } } -QVariant RenderProcessor::ProcessVideoFootage(StreamPtr stream, const rational &input_time) +QVariant RenderProcessor::ProcessVideoFootage(VideoStream *video_stream, const rational &input_time) { TexturePtr value = nullptr; // Check the still frame cache. On large frames such as high resolution still images, uploading // and color managing them for every frame is a waste of time, so we implement a small cache here // to optimize such a situation - VideoStreamPtr video_stream = std::static_pointer_cast(stream); const VideoParams& video_params = ticket_->property("vparam").value(); ColorManager* color_manager = Node::ValueToPtr(ticket_->property("colormanager")); @@ -284,7 +283,7 @@ QVariant RenderProcessor::ProcessVideoFootage(StreamPtr stream, const rational & StillImageCache::EntryPtr want_entry = std::make_shared( nullptr, - stream, + video_stream, ColorProcessor::GenerateID(color_manager, video_stream->colorspace(), color_manager->GetReferenceColorSpace()), video_stream->premultiplied_alpha(), footage_divider, @@ -325,7 +324,7 @@ QVariant RenderProcessor::ProcessVideoFootage(StreamPtr stream, const rational & still_image_cache_->mutex()->unlock(); - DecoderPtr decoder = ResolveDecoderFromInput(stream); + DecoderPtr decoder = ResolveDecoderFromInput(video_stream); if (decoder) { FramePtr frame = decoder->RetrieveVideo(input_time, @@ -367,7 +366,7 @@ QVariant RenderProcessor::ProcessVideoFootage(StreamPtr stream, const rational & return QVariant::fromValue(value); } -QVariant RenderProcessor::ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time) +QVariant RenderProcessor::ProcessAudioFootage(AudioStream *stream, const TimeRange &input_time) { QVariant value; diff --git a/app/render/renderprocessor.h b/app/render/renderprocessor.h index c9df7d109..ddaaf4173 100644 --- a/app/render/renderprocessor.h +++ b/app/render/renderprocessor.h @@ -43,9 +43,9 @@ public: protected: virtual NodeValueTable GenerateBlockTable(const TrackOutput *track, const TimeRange &range) override; - virtual QVariant ProcessVideoFootage(StreamPtr stream, const rational &input_time) override; + virtual QVariant ProcessVideoFootage(VideoStream* video_stream, const rational &input_time) override; - virtual QVariant ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time) override; + virtual QVariant ProcessAudioFootage(AudioStream* stream, const TimeRange &input_time) override; virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override; @@ -62,7 +62,7 @@ private: void Run(); - DecoderPtr ResolveDecoderFromInput(StreamPtr stream); + DecoderPtr ResolveDecoderFromInput(Stream* stream); RenderTicketPtr ticket_; diff --git a/app/render/stillimagecache.h b/app/render/stillimagecache.h index 728247200..e87b36974 100644 --- a/app/render/stillimagecache.h +++ b/app/render/stillimagecache.h @@ -5,7 +5,7 @@ #include #include "common/rational.h" -#include "project/item/footage/stream.h" +#include "project/item/footage/videostream.h" #include "render/texture.h" namespace olive { @@ -14,7 +14,7 @@ class StillImageCache { public: struct Entry { - Entry(TexturePtr t, StreamPtr s, const QString& cs, bool a, int d, const rational& i, bool w) + Entry(TexturePtr t, VideoStream* s, const QString& cs, bool a, int d, const rational& i, bool w) { texture = t; stream = s; @@ -26,7 +26,7 @@ public: } TexturePtr texture; - StreamPtr stream; + VideoStream* stream; QString colorspace; bool alpha_is_associated; int divider; diff --git a/app/task/conform/conform.cpp b/app/task/conform/conform.cpp index b1e546155..eebf57259 100644 --- a/app/task/conform/conform.cpp +++ b/app/task/conform/conform.cpp @@ -24,7 +24,7 @@ namespace olive { -ConformTask::ConformTask(AudioStreamPtr stream, const AudioParams& params) : +ConformTask::ConformTask(AudioStream *stream, const AudioParams& params) : stream_(stream), params_(params) { diff --git a/app/task/conform/conform.h b/app/task/conform/conform.h index 4486cda8f..7e526f740 100644 --- a/app/task/conform/conform.h +++ b/app/task/conform/conform.h @@ -31,13 +31,13 @@ class ConformTask : public Task { Q_OBJECT public: - ConformTask(AudioStreamPtr stream, const AudioParams& params); + ConformTask(AudioStream* stream, const AudioParams& params); protected: virtual bool Run() override; private: - AudioStreamPtr stream_; + AudioStream* stream_; AudioParams params_; diff --git a/app/task/precache/precachetask.cpp b/app/task/precache/precachetask.cpp index b26568063..708e167f8 100644 --- a/app/task/precache/precachetask.cpp +++ b/app/task/precache/precachetask.cpp @@ -24,7 +24,7 @@ namespace olive { -PreCacheTask::PreCacheTask(VideoStreamPtr footage, Sequence* sequence) : +PreCacheTask::PreCacheTask(VideoStream *footage, Sequence* sequence) : RenderTask(new ViewerOutput(), sequence->video_params(), sequence->audio_params()), footage_(footage) { diff --git a/app/task/precache/precachetask.h b/app/task/precache/precachetask.h index 5f3bf0b74..a1f51734d 100644 --- a/app/task/precache/precachetask.h +++ b/app/task/precache/precachetask.h @@ -32,7 +32,7 @@ class PreCacheTask : public RenderTask { Q_OBJECT public: - PreCacheTask(VideoStreamPtr footage, Sequence* sequence); + PreCacheTask(VideoStream* footage, Sequence* sequence); virtual ~PreCacheTask() override; @@ -44,7 +44,7 @@ protected: virtual void AudioDownloaded(const TimeRange& range, SampleBufferPtr samples, qint64 job_time) override; private: - VideoStreamPtr footage_; + VideoStream* footage_; MediaInput* video_node_; diff --git a/app/task/project/import/import.cpp b/app/task/project/import/import.cpp index be423648f..691b155bf 100644 --- a/app/task/project/import/import.cpp +++ b/app/task/project/import/import.cpp @@ -93,8 +93,9 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte // Only proceed if the empty actually has files in it if (!entry_list.isEmpty()) { // Create a folder corresponding to the directory + Folder* f = new Folder(); - ItemPtr f = std::make_shared(); + f->moveToThread(folder->thread()); f->set_name(file_info.fileName()); @@ -105,22 +106,25 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte parent_command); // Recursively follow this path - Import(static_cast(f.get()), entry_list, counter, parent_command); + Import(f, entry_list, counter, parent_command); } } else { - FootagePtr item = Decoder::Probe(model_->project(), file_info.absoluteFilePath(), - &IsCancelled()); + Footage* footage = Decoder::Probe(model_->project(), file_info.absoluteFilePath(), + &IsCancelled()); + + if (footage) { + // Move footage to main thread + footage->moveToThread(folder->thread()); - if (item) { // See if this footage is an image sequence - ValidateImageSequence(item, import, i); + ValidateImageSequence(footage, import, i); // Create undoable command that adds the items to the model new ProjectViewModel::AddItemCommand(model_, folder, - item, + footage, parent_command); } else { // Add to list so we can tell the user about it later @@ -135,15 +139,10 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte } } -void ProjectImportTask::ValidateImageSequence(ItemPtr item, QFileInfoList& info_list, int index) +void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& info_list, int index) { // Heuristically determine whether this file is part of an image sequence or not - if (!ItemIsStillImageFootageOnly(item)) { - return; - } - - FootagePtr footage = std::static_pointer_cast(item); - VideoStreamPtr video_stream = std::static_pointer_cast(footage->streams().first()); + VideoStream* video_stream = static_cast(footage->streams().first()); // By this point we've established that video contains a single still image stream. Now we'll // see if it ends with numbers. @@ -159,8 +158,8 @@ void ProjectImportTask::ValidateImageSequence(ItemPtr item, QFileInfoList& info_ // See if the same decoder can retrieve surrounding files DecoderPtr decoder = Decoder::CreateFromID(footage->decoder()); - ItemPtr previous_file = decoder->Probe(previous_img_fn, nullptr); - ItemPtr next_file = decoder->Probe(next_img_fn, nullptr); + Footage* previous_file = decoder->Probe(previous_img_fn, nullptr); + Footage* next_file = decoder->Probe(next_img_fn, nullptr); // Finally see if these files have the same dimensions if ((previous_file && CompareStillImageSize(previous_file, dim)) @@ -218,15 +217,8 @@ void ProjectImportTask::ValidateImageSequence(ItemPtr item, QFileInfoList& info_ } } -bool ProjectImportTask::ItemIsStillImageFootageOnly(ItemPtr item) +bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage* footage) { - if (item->type() != Item::kFootage) { - // Item isn't footage, definitely isn't an image sequence - return false; - } - - FootagePtr footage = std::static_pointer_cast(item); - if (footage->stream_count() != 1) { // Footage with more than one stream (usually video+audio) most likely isn't an image sequence return false; @@ -237,7 +229,7 @@ bool ProjectImportTask::ItemIsStillImageFootageOnly(ItemPtr item) return false; } - VideoStreamPtr video_stream = std::static_pointer_cast(footage->streams().first()); + VideoStream* video_stream = static_cast(footage->streams().first()); if (video_stream->video_type() != VideoStream::kVideoTypeStill) { // If video type is not a still, this definitely isn't a video stream @@ -247,14 +239,13 @@ bool ProjectImportTask::ItemIsStillImageFootageOnly(ItemPtr item) return true; } -bool ProjectImportTask::CompareStillImageSize(ItemPtr item, const QSize &sz) +bool ProjectImportTask::CompareStillImageSize(Footage* footage, const QSize &sz) { - if (!ItemIsStillImageFootageOnly(item)) { + if (!ItemIsStillImageFootageOnly(footage)) { return false; } - FootagePtr footage = std::static_pointer_cast(item); - VideoStreamPtr video_stream = std::static_pointer_cast(footage->streams().first()); + VideoStream* video_stream = static_cast(footage->streams().first()); return video_stream->width() == sz.width() && video_stream->height() == sz.height(); } diff --git a/app/task/project/import/import.h b/app/task/project/import/import.h index 9dd44b65e..a8546ffcb 100644 --- a/app/task/project/import/import.h +++ b/app/task/project/import/import.h @@ -59,11 +59,11 @@ protected: private: void Import(Folder* folder, QFileInfoList import, int& counter, QUndoCommand *parent_command); - void ValidateImageSequence(ItemPtr item, QFileInfoList &info_list, int index); + void ValidateImageSequence(Footage *footage, QFileInfoList &info_list, int index); - static bool ItemIsStillImageFootageOnly(ItemPtr item); + static bool ItemIsStillImageFootageOnly(Footage *footage); - static bool CompareStillImageSize(ItemPtr item, const QSize& sz); + static bool CompareStillImageSize(Footage *footage, const QSize& sz); static int64_t GetImageSequenceLimit(const QString &start_fn, int64_t start, bool up); diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index 9c557df0f..3d374c0cb 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -76,12 +76,12 @@ bool LoadOTIOTask::Run() } // Keep track of imported footage - QMap imported_footage; + QMap imported_footage; foreach (auto timeline, timelines) { - SequencePtr sequence = std::make_shared(); + Sequence* sequence = new Sequence(); sequence->set_name(QString::fromStdString(timeline->name())); - project_->root()->add_child(sequence); + sequence->setParent(project_->root()); ViewerOutput* seq_viewer = sequence->viewer_output(); @@ -160,22 +160,22 @@ bool LoadOTIOTask::Run() // Link footage QString footage_url = QString::fromStdString(static_cast(otio_clip->media_reference())->target_url()); - FootagePtr probed_item; + Footage* probed_item; if (imported_footage.contains(footage_url)) { probed_item = imported_footage.value(footage_url); } else { probed_item = Decoder::Probe(project_, footage_url, &IsCancelled()); imported_footage.insert(footage_url, probed_item); - project_->root()->add_child(probed_item); + probed_item->setParent(project_->root()); } if (probed_item && probed_item->type() == Item::kFootage) { MediaInput* media = new MediaInput(); if (track->track_type() == Timeline::kTrackTypeVideo) { - media->SetStream(probed_item->get_first_stream_of_type(Stream::kVideo)); + media->SetStream(probed_item->get_first_enabled_stream_of_type(Stream::kVideo)); } else { - media->SetStream(probed_item->get_first_stream_of_type(Stream::kAudio)); + media->SetStream(probed_item->get_first_enabled_stream_of_type(Stream::kAudio)); } sequence->AddNode(media); @@ -188,19 +188,8 @@ bool LoadOTIOTask::Run() } } - - sequence->moveToThread(qApp->thread()); } - // Ugly hack to move footage streams to main thread - /*foreach (ItemPtr item, imported_footage) { - if (item && item->type() == Item::kFootage) { - foreach (StreamPtr stream, std::static_pointer_cast(item)->streams()) { - stream->moveToThread(qApp->thread()); - } - } - }*/ - project_->moveToThread(qApp->thread()); return true; diff --git a/app/task/project/saveotio/saveotio.cpp b/app/task/project/saveotio/saveotio.cpp index 3b42839c0..bca7e07e5 100644 --- a/app/task/project/saveotio/saveotio.cpp +++ b/app/task/project/saveotio/saveotio.cpp @@ -39,7 +39,7 @@ SaveOTIOTask::SaveOTIOTask(Project *project) : bool SaveOTIOTask::Run() { - QList sequences = project_->get_items_of_type(Item::kSequence); + QVector sequences = project_->get_items_of_type(Item::kSequence); if (sequences.isEmpty()) { SetError(tr("Project contains no sequences to export.")); @@ -48,8 +48,8 @@ bool SaveOTIOTask::Run() std::vector serialized; - foreach (ItemPtr item, sequences) { - SequencePtr seq = std::static_pointer_cast(item); + foreach (Item* item, sequences) { + Sequence* seq = static_cast(item); auto otio_timeline = SerializeTimeline(seq); @@ -91,7 +91,7 @@ bool SaveOTIOTask::Run() return (es == opentimelineio::v1_0::ErrorStatus::OK); } -opentimelineio::v1_0::Timeline *SaveOTIOTask::SerializeTimeline(SequencePtr sequence) +opentimelineio::v1_0::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence) { auto otio_timeline = new opentimelineio::v1_0::Timeline(sequence->name().toStdString()); diff --git a/app/task/project/saveotio/saveotio.h b/app/task/project/saveotio/saveotio.h index 4acffb796..bad9ef050 100644 --- a/app/task/project/saveotio/saveotio.h +++ b/app/task/project/saveotio/saveotio.h @@ -39,7 +39,7 @@ protected: virtual bool Run() override; private: - opentimelineio::v1_0::Timeline* SerializeTimeline(SequencePtr sequence); + opentimelineio::v1_0::Timeline* SerializeTimeline(Sequence* sequence); opentimelineio::v1_0::Track* SerializeTrack(TrackOutput* track); diff --git a/app/widget/CMakeLists.txt b/app/widget/CMakeLists.txt index 32c4c88cd..83659ae8e 100644 --- a/app/widget/CMakeLists.txt +++ b/app/widget/CMakeLists.txt @@ -24,11 +24,11 @@ add_subdirectory(curvewidget) add_subdirectory(flowlayout) add_subdirectory(focusablelineedit) add_subdirectory(footagecombobox) +add_subdirectory(handmovableview) add_subdirectory(keyframeview) add_subdirectory(manageddisplay) add_subdirectory(menu) add_subdirectory(nodecombobox) -add_subdirectory(nodecopypaste) add_subdirectory(nodetableview) add_subdirectory(nodetreeview) add_subdirectory(nodeparamview) diff --git a/app/widget/curvewidget/curvewidget.h b/app/widget/curvewidget/curvewidget.h index 127987289..da930b09c 100644 --- a/app/widget/curvewidget/curvewidget.h +++ b/app/widget/curvewidget/curvewidget.h @@ -31,7 +31,7 @@ #include "widget/nodeparamview/nodeparamviewkeyframecontrol.h" #include "widget/nodeparamview/nodeparamviewwidgetbridge.h" #include "widget/nodetreeview/nodetreeview.h" -#include "widget/timebased/timebased.h" +#include "widget/timebased/timebasedwidget.h" namespace olive { diff --git a/app/widget/footagecombobox/footagecombobox.cpp b/app/widget/footagecombobox/footagecombobox.cpp index 684eeeca2..5cdb36c1d 100644 --- a/app/widget/footagecombobox/footagecombobox.cpp +++ b/app/widget/footagecombobox/footagecombobox.cpp @@ -38,7 +38,7 @@ FootageComboBox::FootageComboBox(QWidget *parent) : void FootageComboBox::showPopup() { - if (root_ == nullptr || root_->child_count() == 0) { + if (root_ == nullptr || root_->item_child_count() == 0) { return; } @@ -51,7 +51,7 @@ void FootageComboBox::showPopup() QAction* selected = menu.exec(parentWidget()->mapToGlobal(pos())); if (selected != nullptr) { - SetFootage(selected->data().value()); + SetFootage(Node::ValueToPtr(selected->data())); emit FootageChanged(footage_); } @@ -69,12 +69,7 @@ void FootageComboBox::SetOnlyShowReadyFootage(bool e) only_show_ready_footage_ = e; } -StreamPtr FootageComboBox::SelectedFootage() -{ - return footage_; -} - -void FootageComboBox::SetFootage(StreamPtr f) +void FootageComboBox::SetFootage(Stream *f) { // Remove existing single item used to show the footage name footage_ = f; @@ -82,10 +77,9 @@ void FootageComboBox::SetFootage(StreamPtr f) UpdateText(); } -void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m) +void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m) const { - for (int i=0;ichild_count();i++) { - Item* child = f->child(i); + foreach (Item* child, f->children()) { if (child->CanHaveChildren()) { @@ -102,13 +96,15 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m) Menu* stream_menu = new Menu(footage->name(), m); m->addMenu(stream_menu); - foreach (StreamPtr stream, footage->streams()) { - QAction* stream_action = stream_menu->addAction(FootageToString(stream.get())); - stream_action->setData(QVariant::fromValue(stream)); + foreach (Stream* stream, footage->streams()) { + QAction* stream_action = stream_menu->addAction(FootageToString(stream)); + stream_action->setData(Node::PtrToValue(stream)); stream_action->setIcon(stream->icon()); } } + } + } } @@ -119,7 +115,7 @@ void FootageComboBox::UpdateText() if (footage_) { // Use combobox functions to show the footage name - addItem(FootageToString(footage_.get())); + addItem(FootageToString(footage_)); } } diff --git a/app/widget/footagecombobox/footagecombobox.h b/app/widget/footagecombobox/footagecombobox.h index 2d96f4a6f..3c0c59548 100644 --- a/app/widget/footagecombobox/footagecombobox.h +++ b/app/widget/footagecombobox/footagecombobox.h @@ -41,16 +41,19 @@ public: void SetOnlyShowReadyFootage(bool e); - StreamPtr SelectedFootage(); + Stream* SelectedFootage() const + { + return footage_; + } public slots: - void SetFootage(StreamPtr f); + void SetFootage(Stream* f); signals: - void FootageChanged(StreamPtr f); + void FootageChanged(Stream* f); private: - void TraverseFolder(const Folder *f, QMenu* m); + void TraverseFolder(const Folder *f, QMenu* m) const; void UpdateText(); @@ -58,7 +61,7 @@ private: const Folder* root_; - StreamPtr footage_; + Stream* footage_; bool only_show_ready_footage_; }; diff --git a/app/widget/handmovableview/CMakeLists.txt b/app/widget/handmovableview/CMakeLists.txt new file mode 100644 index 000000000..d586c64fd --- /dev/null +++ b/app/widget/handmovableview/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2020 Olive Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + widget/handmovableview/handmovableview.h + widget/handmovableview/handmovableview.cpp + PARENT_SCOPE +) diff --git a/app/widget/timelinewidget/view/handmovableview.cpp b/app/widget/handmovableview/handmovableview.cpp similarity index 100% rename from app/widget/timelinewidget/view/handmovableview.cpp rename to app/widget/handmovableview/handmovableview.cpp diff --git a/app/widget/timelinewidget/view/handmovableview.h b/app/widget/handmovableview/handmovableview.h similarity index 100% rename from app/widget/timelinewidget/view/handmovableview.h rename to app/widget/handmovableview/handmovableview.h diff --git a/app/widget/keyframeview/keyframeviewbase.cpp b/app/widget/keyframeview/keyframeviewbase.cpp index 7850ada79..e2b6888e3 100644 --- a/app/widget/keyframeview/keyframeviewbase.cpp +++ b/app/widget/keyframeview/keyframeviewbase.cpp @@ -33,7 +33,7 @@ namespace olive { KeyframeViewBase::KeyframeViewBase(QWidget *parent) : - TimelineViewBase(parent), + TimeBasedView(parent), dragging_bezier_point_(nullptr), currently_autoselecting_(false) { @@ -275,7 +275,7 @@ void KeyframeViewBase::mouseReleaseEvent(QMouseEvent *event) void KeyframeViewBase::ScaleChangedEvent(const double &scale) { - TimelineViewBase::ScaleChangedEvent(scale); + TimeBasedView::ScaleChangedEvent(scale); QMap::const_iterator iterator; diff --git a/app/widget/keyframeview/keyframeviewbase.h b/app/widget/keyframeview/keyframeviewbase.h index 113a14895..c81686a96 100644 --- a/app/widget/keyframeview/keyframeviewbase.h +++ b/app/widget/keyframeview/keyframeviewbase.h @@ -25,12 +25,12 @@ #include "node/keyframe.h" #include "widget/curvewidget/beziercontrolpointitem.h" #include "widget/menu/menu.h" -#include "widget/timelinewidget/view/timelineviewbase.h" +#include "widget/timebased/timebasedview.h" #include "widget/timetarget/timetarget.h" namespace olive { -class KeyframeViewBase : public TimelineViewBase, public TimeTargetObject +class KeyframeViewBase : public TimeBasedView, public TimeTargetObject { Q_OBJECT public: diff --git a/app/widget/nodeparamview/nodeparamview.cpp b/app/widget/nodeparamview/nodeparamview.cpp index 597ef7d61..69b37a310 100644 --- a/app/widget/nodeparamview/nodeparamview.cpp +++ b/app/widget/nodeparamview/nodeparamview.cpp @@ -125,7 +125,7 @@ NodeParamView::NodeParamView(QWidget *parent) : // Set a default scale - FIXME: Hardcoded SetScale(120); - SetMaximumScale(TimelineViewBase::kMaximumScale); + SetMaximumScale(TimeBasedView::kMaximumScale); // Pickup on widget focus changes connect(qApp, diff --git a/app/widget/nodeparamview/nodeparamview.h b/app/widget/nodeparamview/nodeparamview.h index 1bbefbf52..9c45fadfb 100644 --- a/app/widget/nodeparamview/nodeparamview.h +++ b/app/widget/nodeparamview/nodeparamview.h @@ -28,7 +28,7 @@ #include "node/node.h" #include "nodeparamviewitem.h" #include "widget/keyframeview/keyframeview.h" -#include "widget/timebased/timebased.h" +#include "widget/timebased/timebasedwidget.h" namespace olive { diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 59559d5c4..0717d6135 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -517,7 +517,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() break; } case NodeParam::kFootage: - static_cast(widgets_.first())->SetFootage(input_->get_value_at_time(node_time).value()); + static_cast(widgets_.first())->SetFootage(Node::ValueToPtr(input_->get_value_at_time(node_time))); break; } } diff --git a/app/widget/nodetableview/nodetabletraverser.cpp b/app/widget/nodetableview/nodetabletraverser.cpp index cd94ee5f8..07238ee3f 100644 --- a/app/widget/nodetableview/nodetabletraverser.cpp +++ b/app/widget/nodetableview/nodetabletraverser.cpp @@ -22,10 +22,8 @@ namespace olive { -QVariant NodeTableTraverser::ProcessVideoFootage(StreamPtr stream, const rational &input_time) +QVariant NodeTableTraverser::ProcessVideoFootage(VideoStream *video_stream, const rational &input_time) { - VideoStreamPtr video_stream = std::static_pointer_cast(stream); - return QVariant::fromValue(VideoParams(video_stream->width(), video_stream->height(), video_stream->timebase(), @@ -34,10 +32,8 @@ QVariant NodeTableTraverser::ProcessVideoFootage(StreamPtr stream, const rationa video_stream->pixel_aspect_ratio())); } -QVariant NodeTableTraverser::ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time) +QVariant NodeTableTraverser::ProcessAudioFootage(AudioStream *audio_stream, const TimeRange &input_time) { - AudioStreamPtr audio_stream = std::static_pointer_cast(stream); - return QVariant::fromValue(AudioParams(audio_stream->sample_rate(), audio_stream->channel_layout(), AudioParams::kInternalFormat)); diff --git a/app/widget/nodetableview/nodetabletraverser.h b/app/widget/nodetableview/nodetabletraverser.h index dbfc531cd..fa5dd25d9 100644 --- a/app/widget/nodetableview/nodetabletraverser.h +++ b/app/widget/nodetableview/nodetabletraverser.h @@ -31,9 +31,9 @@ public: NodeTableTraverser() = default; protected: - virtual QVariant ProcessVideoFootage(StreamPtr stream, const rational &input_time); + virtual QVariant ProcessVideoFootage(VideoStream* video_stream, const rational &input_time); - virtual QVariant ProcessAudioFootage(StreamPtr stream, const TimeRange &input_time); + virtual QVariant ProcessAudioFootage(AudioStream* audio_stream, const TimeRange &input_time); }; diff --git a/app/widget/nodetableview/nodetablewidget.h b/app/widget/nodetableview/nodetablewidget.h index b2e39210a..a68db7371 100644 --- a/app/widget/nodetableview/nodetablewidget.h +++ b/app/widget/nodetableview/nodetablewidget.h @@ -22,7 +22,7 @@ #define NODETABLEWIDGET_H #include "nodetableview.h" -#include "widget/timebased/timebased.h" +#include "widget/timebased/timebasedwidget.h" namespace olive { diff --git a/app/widget/nodeview/nodeview.h b/app/widget/nodeview/nodeview.h index 09c255468..9341cac9d 100644 --- a/app/widget/nodeview/nodeview.h +++ b/app/widget/nodeview/nodeview.h @@ -25,9 +25,9 @@ #include #include "node/graph.h" +#include "node/nodecopypaste.h" #include "nodeviewscene.h" -#include "widget/timelinewidget/view/handmovableview.h" -#include "widget/nodecopypaste/nodecopypaste.h" +#include "widget/handmovableview/handmovableview.h" namespace olive { @@ -37,7 +37,7 @@ namespace olive { * This widget takes a NodeGraph object and constructs a QGraphicsScene representing its data, viewing and allowing * the user to make modifications to it. */ -class NodeView : public HandMovableView, public NodeCopyPasteWidget +class NodeView : public HandMovableView, public NodeCopyPasteService { Q_OBJECT public: diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index a9c38820e..8162065e6 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -307,7 +307,7 @@ void ProjectExplorer::ShowContextMenu() bool all_items_are_footage_or_sequence = true; foreach (Item* i, context_menu_items_) { - if (i->type() == Item::kFootage && !static_cast(i)->HasStreamsOfType(Stream::kVideo)) { + if (i->type() == Item::kFootage && !static_cast(i)->HasEnabledStreamsOfType(Stream::kVideo)) { all_items_have_video_streams = false; } @@ -324,15 +324,15 @@ void ProjectExplorer::ShowContextMenu() Menu* proxy_menu = new Menu(tr("Pre-Cache"), &menu); menu.addMenu(proxy_menu); - QList sequences = project()->get_items_of_type(Item::kSequence); + QVector sequences = project()->get_items_of_type(Item::kSequence); if (sequences.isEmpty()) { QAction* a = proxy_menu->addAction(tr("No sequences exist in project")); a->setEnabled(false); } else { - foreach (ItemPtr i, sequences) { + foreach (Item* i, sequences) { QAction* a = proxy_menu->addAction(tr("For \"%1\"").arg(i->name())); - a->setData(Node::PtrToValue(i.get())); + a->setData(Node::PtrToValue(i)); } connect(proxy_menu, &Menu::triggered, this, &ProjectExplorer::ContextMenuStartProxy); @@ -416,11 +416,12 @@ void ProjectExplorer::OpenContextMenuItemInNewWindow() void ProjectExplorer::ContextMenuStartProxy(QAction *a) { - QList video_streams; + QVector video_streams; // To get here, the `context_menu_items_` must be all kFootage foreach (Item* i, context_menu_items_) { - VideoStreamPtr s = std::static_pointer_cast(static_cast(i)->get_first_stream_of_type(Stream::kVideo)); + Footage* f = static_cast(i); + VideoStream* s = static_cast(f->get_first_enabled_stream_of_type(Stream::kVideo)); if (s) { video_streams.append(s); @@ -430,7 +431,7 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a) Sequence* sequence = Node::ValueToPtr(a->data()); // Start a background task for proxying - foreach (VideoStreamPtr video_stream, video_streams) { + foreach (VideoStream* video_stream, video_streams) { PreCacheTask* proxy_task = new PreCacheTask(video_stream, sequence); TaskManager::instance()->AddTask(proxy_task); } @@ -501,7 +502,7 @@ Folder *ProjectExplorer::GetSelectedFolder() const // If this item is not a folder, presumably it's parent is if (!sel_item->CanHaveChildren()) { - sel_item = sel_item->parent(); + sel_item = sel_item->item_parent(); Q_ASSERT(sel_item->CanHaveChildren()); } @@ -545,11 +546,11 @@ QList ProjectExplorer::GetMediaNodesUsingFootage(Footage *item) QList list; // Get all sequences. - QList sequences = model_.project()->get_items_of_type(Item::kSequence); + QVector sequences = model_.project()->get_items_of_type(Item::kSequence); // Footage can contain multiple streams, all of which need to be dealt with - foreach (ItemPtr s, sequences) { - const QList& nodes = static_cast(s.get())->nodes(); + foreach (Item* s, sequences) { + const QList& nodes = static_cast(s)->nodes(); foreach (Node* n, nodes) { if (n->IsMedia()) { MediaInput* media_node = static_cast(n); @@ -677,7 +678,7 @@ void ProjectExplorer::DeleteSelected() break; } - new ProjectViewModel::RemoveItemCommand(&model_, item->get_shared_ptr(), command); + new ProjectViewModel::RemoveItemCommand(&model_, item, command); } Core::instance()->undo_stack()->pushIfHasChildren(command); diff --git a/app/widget/projectexplorer/projectexplorerundo.h b/app/widget/projectexplorer/projectexplorerundo.h index fbab93992..2148e4b87 100644 --- a/app/widget/projectexplorer/projectexplorerundo.h +++ b/app/widget/projectexplorer/projectexplorerundo.h @@ -41,7 +41,7 @@ protected: virtual void undo_internal() override; private: - QMap stream_data_; + QMap stream_data_; Project* project_; diff --git a/app/widget/resizablescrollbar/resizabletimelinescrollbar.h b/app/widget/resizablescrollbar/resizabletimelinescrollbar.h index 6c82a5dd9..034509174 100644 --- a/app/widget/resizablescrollbar/resizabletimelinescrollbar.h +++ b/app/widget/resizablescrollbar/resizabletimelinescrollbar.h @@ -23,11 +23,11 @@ #include "resizablescrollbar.h" #include "timeline/timelinepoints.h" -#include "widget/timelinewidget/timelinescaledobject.h" +#include "widget/timebased/timescaledobject.h" namespace olive { -class ResizableTimelineScrollBar : public ResizableScrollBar, public TimelineScaledObject +class ResizableTimelineScrollBar : public ResizableScrollBar, public TimeScaledObject { Q_OBJECT public: diff --git a/app/widget/nodecopypaste/CMakeLists.txt b/app/widget/snapservice/CMakeLists.txt similarity index 90% rename from app/widget/nodecopypaste/CMakeLists.txt rename to app/widget/snapservice/CMakeLists.txt index 808abbac5..f98998c57 100644 --- a/app/widget/nodecopypaste/CMakeLists.txt +++ b/app/widget/snapservice/CMakeLists.txt @@ -16,7 +16,7 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - widget/nodecopypaste/nodecopypaste.h - widget/nodecopypaste/nodecopypaste.cpp + widget/snapservice/snapservice.cpp + widget/snapservice/snapservice.h PARENT_SCOPE ) diff --git a/app/widget/timelinewidget/snapservice.cpp b/app/widget/snapservice/snapservice.cpp similarity index 100% rename from app/widget/timelinewidget/snapservice.cpp rename to app/widget/snapservice/snapservice.cpp diff --git a/app/widget/timelinewidget/snapservice.h b/app/widget/snapservice/snapservice.h similarity index 100% rename from app/widget/timelinewidget/snapservice.h rename to app/widget/snapservice/snapservice.h diff --git a/app/widget/timebased/CMakeLists.txt b/app/widget/timebased/CMakeLists.txt index 8719d0f0a..1a13a2123 100644 --- a/app/widget/timebased/CMakeLists.txt +++ b/app/widget/timebased/CMakeLists.txt @@ -16,7 +16,11 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - widget/timebased/timebased.h - widget/timebased/timebased.cpp + widget/timebased/timebasedview.cpp + widget/timebased/timebasedview.h + widget/timebased/timebasedwidget.cpp + widget/timebased/timebasedwidget.h + widget/timebased/timescaledobject.cpp + widget/timebased/timescaledobject.h PARENT_SCOPE ) diff --git a/app/widget/timelinewidget/view/timelineviewbase.cpp b/app/widget/timebased/timebasedview.cpp similarity index 83% rename from app/widget/timelinewidget/view/timelineviewbase.cpp rename to app/widget/timebased/timebasedview.cpp index a252a867a..54ad04826 100644 --- a/app/widget/timelinewidget/view/timelineviewbase.cpp +++ b/app/widget/timebased/timebasedview.cpp @@ -18,7 +18,7 @@ ***/ -#include "timelineviewbase.h" +#include "timebasedview.h" #include #include @@ -30,9 +30,9 @@ namespace olive { -const double TimelineViewBase::kMaximumScale = 8192; +const double TimeBasedView::kMaximumScale = 8192; -TimelineViewBase::TimelineViewBase(QWidget *parent) : +TimeBasedView::TimeBasedView(QWidget *parent) : HandMovableView(parent), playhead_(0), playhead_scene_left_(-1), @@ -53,7 +53,7 @@ TimelineViewBase::TimelineViewBase(QWidget *parent) : SetDefaultDragMode(NoDrag); // Signal to update bounding rect when the scene changes - connect(&scene_, &QGraphicsScene::changed, this, &TimelineViewBase::UpdateSceneRect); + connect(&scene_, &QGraphicsScene::changed, this, &TimeBasedView::UpdateSceneRect); // Always enforce maximum scale SetMaximumScale(kMaximumScale); @@ -64,13 +64,13 @@ TimelineViewBase::TimelineViewBase(QWidget *parent) : setViewportUpdateMode(QGraphicsView::FullViewportUpdate); } -void TimelineViewBase::TimebaseChangedEvent(const rational &) +void TimeBasedView::TimebaseChangedEvent(const rational &) { // Timebase influences position/visibility of playhead viewport()->update(); } -void TimelineViewBase::EnableSnap(const QList &points) +void TimeBasedView::EnableSnap(const QList &points) { snapped_ = true; snap_time_ = points; @@ -78,28 +78,28 @@ void TimelineViewBase::EnableSnap(const QList &points) viewport()->update(); } -void TimelineViewBase::DisableSnap() +void TimeBasedView::DisableSnap() { snapped_ = false; viewport()->update(); } -void TimelineViewBase::SetSnapService(SnapService *service) +void TimeBasedView::SetSnapService(SnapService *service) { snap_service_ = service; } -const double &TimelineViewBase::GetYScale() const +const double &TimeBasedView::GetYScale() const { return y_scale_; } -void TimelineViewBase::VerticalScaleChangedEvent(double) +void TimeBasedView::VerticalScaleChangedEvent(double) { } -void TimelineViewBase::SetYScale(const double &y_scale) +void TimeBasedView::SetYScale(const double &y_scale) { y_scale_ = y_scale; @@ -110,7 +110,7 @@ void TimelineViewBase::SetYScale(const double &y_scale) } } -void TimelineViewBase::SetTime(const int64_t time) +void TimeBasedView::SetTime(const int64_t time) { playhead_ = time; @@ -118,7 +118,7 @@ void TimelineViewBase::SetTime(const int64_t time) viewport()->update(); } -void TimelineViewBase::drawForeground(QPainter *painter, const QRectF &rect) +void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect) { QGraphicsView::drawForeground(painter, rect); @@ -154,12 +154,12 @@ void TimelineViewBase::drawForeground(QPainter *painter, const QRectF &rect) } } -rational TimelineViewBase::GetPlayheadTime() const +rational TimeBasedView::GetPlayheadTime() const { return Timecode::timestamp_to_time(playhead_, timebase()); } -bool TimelineViewBase::PlayheadPress(QMouseEvent *event) +bool TimeBasedView::PlayheadPress(QMouseEvent *event) { QPointF scene_pos = mapToScene(event->pos()); @@ -170,7 +170,7 @@ bool TimelineViewBase::PlayheadPress(QMouseEvent *event) return dragging_playhead_; } -bool TimelineViewBase::PlayheadMove(QMouseEvent *event) +bool TimeBasedView::PlayheadMove(QMouseEvent *event) { if (!dragging_playhead_) { return false; @@ -198,7 +198,7 @@ bool TimelineViewBase::PlayheadMove(QMouseEvent *event) return true; } -bool TimelineViewBase::PlayheadRelease(QMouseEvent*) +bool TimeBasedView::PlayheadRelease(QMouseEvent*) { if (dragging_playhead_) { dragging_playhead_ = false; @@ -213,19 +213,19 @@ bool TimelineViewBase::PlayheadRelease(QMouseEvent*) return false; } -qreal TimelineViewBase::GetPlayheadX() +qreal TimeBasedView::GetPlayheadX() { return TimeToScene(Timecode::timestamp_to_time(playhead_, timebase())); } -void TimelineViewBase::SetEndTime(const rational &length) +void TimeBasedView::SetEndTime(const rational &length) { end_time_ = length; UpdateSceneRect(); } -void TimelineViewBase::UpdateSceneRect() +void TimeBasedView::UpdateSceneRect() { QRectF bounding_rect = scene_.itemsBoundingRect(); @@ -244,16 +244,16 @@ void TimelineViewBase::UpdateSceneRect() } } -void TimelineViewBase::resizeEvent(QResizeEvent *event) +void TimeBasedView::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); UpdateSceneRect(); } -void TimelineViewBase::ScaleChangedEvent(const double &scale) +void TimeBasedView::ScaleChangedEvent(const double &scale) { - TimelineScaledObject::ScaleChangedEvent(scale); + TimeScaledObject::ScaleChangedEvent(scale); // Update scene rect UpdateSceneRect(); @@ -262,7 +262,7 @@ void TimelineViewBase::ScaleChangedEvent(const double &scale) viewport()->update(); } -bool TimelineViewBase::HandleZoomFromScroll(QWheelEvent *event) +bool TimeBasedView::HandleZoomFromScroll(QWheelEvent *event) { if (WheelEventIsAZoomEvent(event)) { // If CTRL is held (or a preference is set to swap CTRL behavior), we zoom instead of scrolling @@ -326,7 +326,7 @@ bool TimelineViewBase::HandleZoomFromScroll(QWheelEvent *event) return false; } -bool TimelineViewBase::WheelEventIsAZoomEvent(QWheelEvent *event) +bool TimeBasedView::WheelEventIsAZoomEvent(QWheelEvent *event) { return (static_cast(event->modifiers() & Qt::ControlModifier) == !Config::Current()["ScrollZooms"].toBool()); } diff --git a/app/widget/timelinewidget/view/timelineviewbase.h b/app/widget/timebased/timebasedview.h similarity index 91% rename from app/widget/timelinewidget/view/timelineviewbase.h rename to app/widget/timebased/timebasedview.h index 4ae847391..f6549afa2 100644 --- a/app/widget/timelinewidget/view/timelineviewbase.h +++ b/app/widget/timebased/timebasedview.h @@ -24,17 +24,17 @@ #include #include "core.h" -#include "handmovableview.h" -#include "widget/timelinewidget/snapservice.h" -#include "widget/timelinewidget/timelinescaledobject.h" +#include "timescaledobject.h" +#include "widget/handmovableview/handmovableview.h" +#include "widget/snapservice/snapservice.h" namespace olive { -class TimelineViewBase : public HandMovableView, public TimelineScaledObject +class TimeBasedView : public HandMovableView, public TimeScaledObject { Q_OBJECT public: - TimelineViewBase(QWidget* parent = nullptr); + TimeBasedView(QWidget* parent = nullptr); static const double kMaximumScale; diff --git a/app/widget/timebased/timebased.cpp b/app/widget/timebased/timebasedwidget.cpp similarity index 99% rename from app/widget/timebased/timebased.cpp rename to app/widget/timebased/timebasedwidget.cpp index 90296bd64..d0c0a6152 100644 --- a/app/widget/timebased/timebased.cpp +++ b/app/widget/timebased/timebasedwidget.cpp @@ -18,7 +18,7 @@ ***/ -#include "timebased.h" +#include "timebasedwidget.h" #include #include @@ -132,7 +132,7 @@ void TimeBasedWidget::UpdateMaximumScroll() scrollbar_->setMaximum(qMax(0, qCeil(TimeToScene(length)) - width())); } - foreach (TimelineViewBase* base, timeline_views_) { + foreach (TimeBasedView* base, timeline_views_) { base->SetEndTime(length); } } @@ -238,7 +238,7 @@ TimelinePoints *TimeBasedWidget::GetConnectedTimelinePoints() const return points_; } -void TimeBasedWidget::ConnectTimelineView(TimelineViewBase *base) +void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base) { timeline_views_.append(base); } diff --git a/app/widget/timebased/timebased.h b/app/widget/timebased/timebasedwidget.h similarity index 97% rename from app/widget/timebased/timebased.h rename to app/widget/timebased/timebasedwidget.h index ddca58835..089e5a209 100644 --- a/app/widget/timebased/timebased.h +++ b/app/widget/timebased/timebasedwidget.h @@ -26,7 +26,7 @@ #include "node/output/viewer/viewer.h" #include "timeline/timelinecommon.h" #include "widget/resizablescrollbar/resizabletimelinescrollbar.h" -#include "widget/timelinewidget/timelinescaledobject.h" +#include "widget/timebased/timescaledobject.h" #include "widget/timelinewidget/view/timelineview.h" #include "widget/timeruler/timeruler.h" @@ -121,7 +121,7 @@ protected: TimelinePoints* GetConnectedTimelinePoints() const; - void ConnectTimelineView(TimelineViewBase* base); + void ConnectTimelineView(TimeBasedView* base); void PassWheelEventsToScrollBar(QObject* object); @@ -194,7 +194,7 @@ private: TimelinePoints* points_; - QList timeline_views_; + QList timeline_views_; bool toggle_show_all_; diff --git a/app/widget/timelinewidget/timelinescaledobject.cpp b/app/widget/timebased/timescaledobject.cpp similarity index 66% rename from app/widget/timelinewidget/timelinescaledobject.cpp rename to app/widget/timebased/timescaledobject.cpp index 28453c391..e3aeab08d 100644 --- a/app/widget/timelinewidget/timelinescaledobject.cpp +++ b/app/widget/timebased/timescaledobject.cpp @@ -18,7 +18,7 @@ ***/ -#include "timelinescaledobject.h" +#include "timescaledobject.h" #include #include @@ -27,9 +27,9 @@ namespace olive { -const int TimelineScaledObject::kCalculateDimensionsPadding = 10; +const int TimeScaledObject::kCalculateDimensionsPadding = 10; -TimelineScaledObject::TimelineScaledObject() : +TimeScaledObject::TimeScaledObject() : scale_(1.0), min_scale_(0), max_scale_(DBL_MAX) @@ -37,7 +37,7 @@ TimelineScaledObject::TimelineScaledObject() : } -void TimelineScaledObject::SetTimebase(const rational &timebase) +void TimeScaledObject::SetTimebase(const rational &timebase) { timebase_ = timebase; timebase_dbl_ = timebase_.toDouble(); @@ -45,17 +45,17 @@ void TimelineScaledObject::SetTimebase(const rational &timebase) TimebaseChangedEvent(timebase); } -const rational &TimelineScaledObject::timebase() const +const rational &TimeScaledObject::timebase() const { return timebase_; } -const double &TimelineScaledObject::timebase_dbl() const +const double &TimeScaledObject::timebase_dbl() const { return timebase_dbl_; } -rational TimelineScaledObject::SceneToTime(const double &x, const double &x_scale, const rational &timebase, bool round) +rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale, const rational &timebase, bool round) { double unscaled_time = x / x_scale / timebase.toDouble(); @@ -72,17 +72,17 @@ rational TimelineScaledObject::SceneToTime(const double &x, const double &x_scal return rational(rounded_x_mvmt * timebase.numerator(), timebase.denominator()); } -double TimelineScaledObject::TimeToScene(const rational &time) +double TimeScaledObject::TimeToScene(const rational &time) { return time.toDouble() * scale_; } -rational TimelineScaledObject::SceneToTime(const double &x, bool round) +rational TimeScaledObject::SceneToTime(const double &x, bool round) { return SceneToTime(x, scale_, timebase_, round); } -void TimelineScaledObject::SetMaximumScale(const double &max) +void TimeScaledObject::SetMaximumScale(const double &max) { max_scale_ = max; @@ -91,7 +91,7 @@ void TimelineScaledObject::SetMaximumScale(const double &max) } } -void TimelineScaledObject::SetMinimumScale(const double &min) +void TimeScaledObject::SetMinimumScale(const double &min) { min_scale_ = min; @@ -100,12 +100,12 @@ void TimelineScaledObject::SetMinimumScale(const double &min) } } -const double& TimelineScaledObject::GetScale() const +const double& TimeScaledObject::GetScale() const { return scale_; } -void TimelineScaledObject::SetScale(const double& scale) +void TimeScaledObject::SetScale(const double& scale) { Q_ASSERT(scale > 0); @@ -114,17 +114,17 @@ void TimelineScaledObject::SetScale(const double& scale) ScaleChangedEvent(scale_); } -void TimelineScaledObject::SetScaleFromDimensions(double viewport_width, double content_width) +void TimeScaledObject::SetScaleFromDimensions(double viewport_width, double content_width) { SetScale(CalculateScaleFromDimensions(viewport_width, content_width)); } -double TimelineScaledObject::CalculateScaleFromDimensions(double viewport_sz, double content_sz) +double TimeScaledObject::CalculateScaleFromDimensions(double viewport_sz, double content_sz) { return static_cast(viewport_sz / kCalculateDimensionsPadding * (kCalculateDimensionsPadding-1)) / static_cast(content_sz); } -double TimelineScaledObject::CalculatePaddingFromDimensionScale(double viewport_sz) +double TimeScaledObject::CalculatePaddingFromDimensionScale(double viewport_sz) { return (viewport_sz / (kCalculateDimensionsPadding * 2)); } diff --git a/app/widget/timelinewidget/timelinescaledobject.h b/app/widget/timebased/timescaledobject.h similarity index 89% rename from app/widget/timelinewidget/timelinescaledobject.h rename to app/widget/timebased/timescaledobject.h index 8e96ec122..ad90cb608 100644 --- a/app/widget/timelinewidget/timelinescaledobject.h +++ b/app/widget/timebased/timescaledobject.h @@ -27,11 +27,14 @@ namespace olive { -class TimelineScaledObject +/** + * @brief Provides base functionality for any object that uses time and scale + */ +class TimeScaledObject { public: - TimelineScaledObject(); - virtual ~TimelineScaledObject() = default; + TimeScaledObject(); + virtual ~TimeScaledObject() = default; void SetTimebase(const rational &timebase); @@ -75,7 +78,7 @@ private: }; -class TimelineScaledWidget : public QWidget, public TimelineScaledObject +class TimelineScaledWidget : public QWidget, public TimeScaledObject { Q_OBJECT public: diff --git a/app/widget/timelinewidget/CMakeLists.txt b/app/widget/timelinewidget/CMakeLists.txt index 86173dc1b..563fa03dd 100644 --- a/app/widget/timelinewidget/CMakeLists.txt +++ b/app/widget/timelinewidget/CMakeLists.txt @@ -21,12 +21,8 @@ add_subdirectory(view) set(OLIVE_SOURCES ${OLIVE_SOURCES} - widget/timelinewidget/snapservice.h - widget/timelinewidget/snapservice.cpp widget/timelinewidget/timelineandtrackview.h widget/timelinewidget/timelineandtrackview.cpp - widget/timelinewidget/timelinescaledobject.h - widget/timelinewidget/timelinescaledobject.cpp widget/timelinewidget/timelinewidget.h widget/timelinewidget/timelinewidget.cpp widget/timelinewidget/timelinewidgetselections.h diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 05baf88b6..de6a66d86 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -160,7 +160,7 @@ TimelineWidget::TimelineWidget(QWidget *parent) : // FIXME: Magic number SetScale(90.0); - SetMaximumScale(TimelineViewBase::kMaximumScale); + SetMaximumScale(TimeBasedView::kMaximumScale); SetAutoSetTimebase(false); connect(Core::instance(), &Core::ToolChanged, this, &TimelineWidget::ToolChanged); diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index 3c5e728cf..5078a5a02 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -27,13 +27,13 @@ #include "core.h" #include "node/block/transition/transition.h" +#include "node/nodecopypaste.h" #include "node/output/viewer/viewer.h" -#include "snapservice.h" #include "timeline/timelinecommon.h" #include "timelineandtrackview.h" -#include "widget/nodecopypaste/nodecopypaste.h" #include "widget/slider/timeslider.h" -#include "widget/timebased/timebased.h" +#include "widget/snapservice/snapservice.h" +#include "widget/timebased/timebasedwidget.h" #include "widget/timelinewidget/timelinewidgetselections.h" #include "widget/timelinewidget/tool/import.h" #include "widget/timelinewidget/tool/tool.h" @@ -45,7 +45,7 @@ namespace olive { * * Encapsulates TimelineViews, TimeRulers, and scrollbars for a complete widget to manipulate Timelines */ -class TimelineWidget : public TimeBasedWidget, public NodeCopyPasteWidget, public SnapService +class TimelineWidget : public TimeBasedWidget, public NodeCopyPasteService, public SnapService { Q_OBJECT public: diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index ff9a6a2b3..cebd75b18 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -224,7 +224,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QListstreams()) { + foreach (Stream* stream, footage.footage()->streams()) { Timeline::TrackType track_type = TrackTypeFromStreamType(stream->type()); quint64 cached_enabled_streams = enabled_streams; @@ -239,7 +239,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QListtype() == Stream::kVideo - && std::static_pointer_cast(stream)->video_type() == VideoStream::kVideoTypeStill) { + && static_cast(stream)->video_type() == VideoStream::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; @@ -260,7 +260,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const QListSetData(TimelineViewGhostItem::kAttachedFootage, QVariant::fromValue(stream)); + ghost->SetData(TimelineViewGhostItem::kAttachedFootage, Node::PtrToValue(stream)); ghost->SetMode(Timeline::kMove); footage_ghosts.append(ghost); @@ -353,7 +353,7 @@ void ImportTool::DropGhosts(bool insert) Project* active_project = Core::instance()->GetActiveProject(); if (active_project) { - SequencePtr new_sequence = Core::instance()->CreateNewSequenceForProject(active_project); + Sequence* new_sequence = Core::instance()->CreateNewSequenceForProject(active_project); new_sequence->set_default_parameters(); @@ -371,7 +371,7 @@ void ImportTool::DropGhosts(bool insert) } else { - SequenceDialog sd(new_sequence.get(), SequenceDialog::kNew, parent()); + SequenceDialog sd(new_sequence, SequenceDialog::kNew, parent()); sd.SetUndoable(false); if (sd.exec() != QDialog::Accepted) { @@ -390,11 +390,15 @@ void ImportTool::DropGhosts(bool insert) FootageToGhosts(0, dragged_footage_, new_sequence->video_params().time_base(), 0); - dst_graph = new_sequence.get(); + dst_graph = new_sequence; viewer_node = new_sequence->viewer_output(); // Set this as the sequence to open - open_sequence = new_sequence.get(); + open_sequence = new_sequence; + } else { + // If the sequence is valid, ownership is passed to AddItemCommand. + // Otherwise, we're responsible for deleting it. + delete new_sequence; } } } @@ -412,7 +416,7 @@ void ImportTool::DropGhosts(bool insert) for (int i=0;iGetGhostItems().size();i++) { TimelineViewGhostItem* ghost = parent()->GetGhostItems().at(i); - StreamPtr footage_stream = ghost->GetData(TimelineViewGhostItem::kAttachedFootage).value(); + Stream* footage_stream = Node::ValueToPtr(ghost->GetData(TimelineViewGhostItem::kAttachedFootage)); ClipBlock* clip = new ClipBlock(); clip->set_media_in(ghost->GetMediaIn()); @@ -475,7 +479,7 @@ void ImportTool::DropGhosts(bool insert) // Link any clips so far that share the same Footage with this one for (int j=0;jGetGhostItems().at(j)->GetData(TimelineViewGhostItem::kAttachedFootage).value(); + Stream* footage_compare = Node::ValueToPtr(parent()->GetGhostItems().at(j)->GetData(TimelineViewGhostItem::kAttachedFootage)); if (footage_compare->footage() == footage_stream->footage()) { Block::Link(block_items.at(j), clip); diff --git a/app/widget/timelinewidget/tool/zoom.cpp b/app/widget/timelinewidget/tool/zoom.cpp index 063a4afc6..58cf96d83 100644 --- a/app/widget/timelinewidget/tool/zoom.cpp +++ b/app/widget/timelinewidget/tool/zoom.cpp @@ -68,7 +68,7 @@ void ZoomTool::MouseRelease(TimelineViewMouseEvent *event) // Normalize scale to 1.0 scale double scene_width = (scene_right - scene_left) / parent()->GetScale(); - double new_scale = qMin(TimelineViewBase::kMaximumScale, static_cast(reference_view->viewport()->width()) / scene_width); + double new_scale = qMin(TimeBasedView::kMaximumScale, static_cast(reference_view->viewport()->width()) / scene_width); parent()->SetScale(new_scale); diff --git a/app/widget/timelinewidget/view/CMakeLists.txt b/app/widget/timelinewidget/view/CMakeLists.txt index 929652ed7..2c67d5378 100644 --- a/app/widget/timelinewidget/view/CMakeLists.txt +++ b/app/widget/timelinewidget/view/CMakeLists.txt @@ -16,19 +16,15 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - widget/timelinewidget/view/handmovableview.h - widget/timelinewidget/view/handmovableview.cpp - widget/timelinewidget/view/timelineview.h widget/timelinewidget/view/timelineview.cpp - widget/timelinewidget/view/timelineviewmouseevent.h + widget/timelinewidget/view/timelineview.h widget/timelinewidget/view/timelineviewmouseevent.cpp - widget/timelinewidget/view/timelineviewrect.h + widget/timelinewidget/view/timelineviewmouseevent.h widget/timelinewidget/view/timelineviewrect.cpp - widget/timelinewidget/view/timelineviewbase.h - widget/timelinewidget/view/timelineviewbase.cpp - widget/timelinewidget/view/timelineviewblockitem.h + widget/timelinewidget/view/timelineviewrect.h widget/timelinewidget/view/timelineviewblockitem.cpp - widget/timelinewidget/view/timelineviewghostitem.h + widget/timelinewidget/view/timelineviewblockitem.h widget/timelinewidget/view/timelineviewghostitem.cpp + widget/timelinewidget/view/timelineviewghostitem.h PARENT_SCOPE ) diff --git a/app/widget/timelinewidget/view/timelineview.cpp b/app/widget/timelinewidget/view/timelineview.cpp index cb2930866..094b80b64 100644 --- a/app/widget/timelinewidget/view/timelineview.cpp +++ b/app/widget/timelinewidget/view/timelineview.cpp @@ -36,7 +36,7 @@ namespace olive { TimelineView::TimelineView(Qt::Alignment vertical_alignment, QWidget *parent) : - TimelineViewBase(parent), + TimeBasedView(parent), selections_(nullptr), ghosts_(nullptr), show_beam_cursor_(false), @@ -59,7 +59,7 @@ void TimelineView::mousePressEvent(QMouseEvent *event) } if (dragMode() != GetDefaultDragMode()) { - TimelineViewBase::mousePressEvent(event); + TimeBasedView::mousePressEvent(event); return; } @@ -76,7 +76,7 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) } if (dragMode() != GetDefaultDragMode()) { - TimelineViewBase::mouseMoveEvent(event); + TimeBasedView::mouseMoveEvent(event); return; } @@ -93,7 +93,7 @@ void TimelineView::mouseReleaseEvent(QMouseEvent *event) } if (dragMode() != GetDefaultDragMode()) { - TimelineViewBase::mouseReleaseEvent(event); + TimeBasedView::mouseReleaseEvent(event); return; } @@ -283,7 +283,7 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect) } // Draw standard TimelineViewBase things (such as playhead) - TimelineViewBase::drawForeground(painter, rect); + TimeBasedView::drawForeground(painter, rect); } void TimelineView::ToolChangedEvent(Tool::Item tool) diff --git a/app/widget/timelinewidget/view/timelineview.h b/app/widget/timelinewidget/view/timelineview.h index 71d6eb1d8..999a32157 100644 --- a/app/widget/timelinewidget/view/timelineview.h +++ b/app/widget/timelinewidget/view/timelineview.h @@ -28,10 +28,10 @@ #include #include "node/block/clip/clip.h" -#include "timelineviewbase.h" #include "timelineviewblockitem.h" #include "timelineviewmouseevent.h" #include "timelineviewghostitem.h" +#include "widget/timebased/timebasedview.h" #include "widget/timelinewidget/undo/undo.h" #include "undo/undostack.h" @@ -42,7 +42,7 @@ namespace olive { * * This widget primarily exposes users to viewing and modifying Block nodes, usually through a TimelineOutput node. */ -class TimelineView : public TimelineViewBase +class TimelineView : public TimeBasedView { Q_OBJECT public: diff --git a/app/widget/timelinewidget/view/timelineviewghostitem.cpp b/app/widget/timelinewidget/view/timelineviewghostitem.cpp index 7762fbafb..6c0064343 100644 --- a/app/widget/timelinewidget/view/timelineviewghostitem.cpp +++ b/app/widget/timelinewidget/view/timelineviewghostitem.cpp @@ -26,7 +26,6 @@ namespace olive { TimelineViewGhostItem::TimelineViewGhostItem() : track_adj_(0), - stream_(nullptr), mode_(Timeline::kNone), can_have_zero_length_(true), can_move_tracks_(true), diff --git a/app/widget/timelinewidget/view/timelineviewghostitem.h b/app/widget/timelinewidget/view/timelineviewghostitem.h index 9f734e45f..4c920d3b3 100644 --- a/app/widget/timelinewidget/view/timelineviewghostitem.h +++ b/app/widget/timelinewidget/view/timelineviewghostitem.h @@ -127,8 +127,6 @@ private: int track_adj_; - StreamPtr stream_; - Timeline::MovementMode mode_; bool can_have_zero_length_; diff --git a/app/widget/timelinewidget/view/timelineviewmouseevent.cpp b/app/widget/timelinewidget/view/timelineviewmouseevent.cpp index 61e697d63..d0d451f5b 100644 --- a/app/widget/timelinewidget/view/timelineviewmouseevent.cpp +++ b/app/widget/timelinewidget/view/timelineviewmouseevent.cpp @@ -22,7 +22,7 @@ #include -#include "widget/timelinewidget/timelinescaledobject.h" +#include "widget/timebased/timescaledobject.h" namespace olive { @@ -48,14 +48,14 @@ TimelineCoordinate TimelineViewMouseEvent::GetCoordinates(bool round_time) const return TimelineCoordinate(GetFrame(round_time), track_); } -const Qt::KeyboardModifiers TimelineViewMouseEvent::GetModifiers() const +const Qt::KeyboardModifiers &TimelineViewMouseEvent::GetModifiers() const { return modifiers_; } rational TimelineViewMouseEvent::GetFrame(bool round) const { - return TimelineScaledObject::SceneToTime(scene_x_, scale_x_, timebase_, round); + return TimeScaledObject::SceneToTime(scene_x_, scale_x_, timebase_, round); } const TrackReference &TimelineViewMouseEvent::GetTrack() const diff --git a/app/widget/timelinewidget/view/timelineviewmouseevent.h b/app/widget/timelinewidget/view/timelineviewmouseevent.h index f4371660e..8c466e426 100644 --- a/app/widget/timelinewidget/view/timelineviewmouseevent.h +++ b/app/widget/timelinewidget/view/timelineviewmouseevent.h @@ -40,7 +40,7 @@ public: const Qt::KeyboardModifiers& modifiers = Qt::NoModifier); TimelineCoordinate GetCoordinates(bool round_time = false) const; - const Qt::KeyboardModifiers GetModifiers() const; + const Qt::KeyboardModifiers& GetModifiers() const; /** * @brief Gets the time at this cursor point diff --git a/app/widget/timelinewidget/view/timelineviewrect.cpp b/app/widget/timelinewidget/view/timelineviewrect.cpp index 1145671ea..1fa9d7b11 100644 --- a/app/widget/timelinewidget/view/timelineviewrect.cpp +++ b/app/widget/timelinewidget/view/timelineviewrect.cpp @@ -50,14 +50,14 @@ void TimelineViewRect::SetTrack(const TrackReference &track) void TimelineViewRect::ScaleChangedEvent(const double &scale) { - TimelineScaledObject::ScaleChangedEvent(scale); + TimeScaledObject::ScaleChangedEvent(scale); UpdateRect(); } void TimelineViewRect::TimebaseChangedEvent(const rational &tb) { - TimelineScaledObject::TimebaseChangedEvent(tb); + TimeScaledObject::TimebaseChangedEvent(tb); UpdateRect(); } diff --git a/app/widget/timelinewidget/view/timelineviewrect.h b/app/widget/timelinewidget/view/timelineviewrect.h index 14311264a..974fc4364 100644 --- a/app/widget/timelinewidget/view/timelineviewrect.h +++ b/app/widget/timelinewidget/view/timelineviewrect.h @@ -24,14 +24,14 @@ #include #include "timeline/timelinecoordinate.h" -#include "../timelinescaledobject.h" +#include "widget/timebased/timescaledobject.h" namespace olive { /** * @brief A base class for graphical representations of Block nodes */ -class TimelineViewRect : public QGraphicsRectItem, public TimelineScaledObject +class TimelineViewRect : public QGraphicsRectItem, public TimeScaledObject { public: TimelineViewRect(QGraphicsItem* parent = nullptr); diff --git a/app/widget/timeruler/seekablewidget.h b/app/widget/timeruler/seekablewidget.h index b508e688c..6f884be39 100644 --- a/app/widget/timeruler/seekablewidget.h +++ b/app/widget/timeruler/seekablewidget.h @@ -23,8 +23,8 @@ #include "common/rational.h" #include "timeline/timelinepoints.h" -#include "widget/timelinewidget/snapservice.h" -#include "widget/timelinewidget/timelinescaledobject.h" +#include "widget/snapservice/snapservice.h" +#include "widget/timebased/timescaledobject.h" namespace olive { diff --git a/app/widget/viewer/footageviewer.cpp b/app/widget/viewer/footageviewer.cpp index 2dc2b2f7b..b8328fc78 100644 --- a/app/widget/viewer/footageviewer.cpp +++ b/app/widget/viewer/footageviewer.cpp @@ -75,20 +75,20 @@ void FootageViewerWidget::SetFootage(Footage *footage) sequence_.set_parameters_from_footage({footage_}); // Use first of each stream - VideoStreamPtr video_stream = nullptr; - AudioStreamPtr audio_stream = nullptr; + VideoStream* video_stream = nullptr; + AudioStream* audio_stream = nullptr; - foreach (StreamPtr s, footage_->streams()) { + foreach (Stream* s, footage_->streams()) { if (!s->enabled()) { continue; } if (!audio_stream && s->type() == Stream::kAudio) { - audio_stream = std::static_pointer_cast(s); + audio_stream = static_cast(s); } if (!video_stream && s->type() == Stream::kVideo) { - video_stream = std::static_pointer_cast(s); + video_stream = static_cast(s); } if (audio_stream && video_stream) { @@ -142,7 +142,7 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl if (!enable_video || !enable_audio) { quint64 stream_disabler = 0x1; - foreach (StreamPtr s, GetFootage()->streams()) { + foreach (Stream* s, GetFootage()->streams()) { if ((s->type() == Stream::kVideo && !enable_video) || (s->type() == Stream::kAudio && !enable_audio)) { enabled_stream_flags &= ~stream_disabler; diff --git a/app/widget/viewer/gizmotraverser.cpp b/app/widget/viewer/gizmotraverser.cpp index 8105a7338..4e9f44954 100644 --- a/app/widget/viewer/gizmotraverser.cpp +++ b/app/widget/viewer/gizmotraverser.cpp @@ -22,11 +22,11 @@ namespace olive { -QVariant GizmoTraverser::ProcessVideoFootage(StreamPtr stream, const rational &input_time) +QVariant GizmoTraverser::ProcessVideoFootage(VideoStream *stream, const rational &input_time) { Q_UNUSED(input_time) - VideoStreamPtr image_stream = std::static_pointer_cast(stream); + VideoStream* image_stream = static_cast(stream); return QVector2D(image_stream->width() * image_stream->pixel_aspect_ratio().toDouble(), image_stream->height()); diff --git a/app/widget/viewer/gizmotraverser.h b/app/widget/viewer/gizmotraverser.h index 3f3e5b715..7fe8ec29d 100644 --- a/app/widget/viewer/gizmotraverser.h +++ b/app/widget/viewer/gizmotraverser.h @@ -34,7 +34,7 @@ public: } protected: - virtual QVariant ProcessVideoFootage(StreamPtr stream, const rational &input_time) override; + virtual QVariant ProcessVideoFootage(VideoStream* stream, const rational &input_time) override; virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override; diff --git a/app/widget/viewer/viewer.h b/app/widget/viewer/viewer.h index 40bdc7053..7f24c46fa 100644 --- a/app/widget/viewer/viewer.h +++ b/app/widget/viewer/viewer.h @@ -40,7 +40,7 @@ #include "viewersizer.h" #include "viewerwindow.h" #include "widget/playbackcontrols/playbackcontrols.h" -#include "widget/timebased/timebased.h" +#include "widget/timebased/timebasedwidget.h" namespace olive { diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 662e31d75..c6244d299 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -329,10 +329,10 @@ void MainWindow::ProjectOpen(Project *p) void MainWindow::ProjectClose(Project *p) { // Close any open sequences from project - QList open_sequences = p->get_items_of_type(Item::kSequence); + QVector open_sequences = p->get_items_of_type(Item::kSequence); - foreach (ItemPtr item, open_sequences) { - Sequence* seq = static_cast(item.get()); + foreach (Item* item, open_sequences) { + Sequence* seq = static_cast(item); if (IsSequenceOpen(seq)) { CloseSequence(seq); @@ -340,15 +340,15 @@ void MainWindow::ProjectClose(Project *p) } // Close any open footage in footage viewer - QList footage = p->get_items_of_type(Item::kFootage); + QVector footage = p->get_items_of_type(Item::kFootage); QList footage_in_viewer = footage_viewer_panel_->GetSelectedFootage(); if (!footage_in_viewer.isEmpty()) { // FootageViewer only has the one footage item Footage* f = footage_in_viewer.first(); - foreach (ItemPtr i, footage) { - if (f == i.get()) { + foreach (Item* i, footage) { + if (f == i) { footage_viewer_panel_->SetFootage(nullptr); break; }