diff --git a/app/codec/decoder.cpp b/app/codec/decoder.cpp index 53e728415..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_); diff --git a/app/codec/decoder.h b/app/codec/decoder.h index e57226b16..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 @@ -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 10be95915..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(); @@ -242,7 +242,7 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell 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 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell // 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 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell 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 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell } 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 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell } 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 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell // 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; @@ -446,10 +446,8 @@ Footage *FFmpegDecoder::Probe(const QString& filename, const QAtomicInt* cancell // We actually have footage we can return instead of nullptr 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/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index 49752415e..dc00aaa40 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -77,7 +77,7 @@ Footage *OIIODecoder::Probe(const QString& filename, const QAtomicInt* cancelled 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/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/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/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/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/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 5f59c67b6..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; } @@ -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 39850ef8a..71ec994ea 100644 --- a/app/project/item/footage/footage.h +++ b/app/project/item/footage/footage.h @@ -134,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. @@ -148,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 @@ -196,9 +201,9 @@ 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(Footage* footage, const QString& filename); static bool CompareFootageToItsFilename(Footage* footage); @@ -238,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/sequence/sequence.cpp b/app/project/item/sequence/sequence.cpp index cccc57c72..e2767e537 100644 --- a/app/project/item/sequence/sequence.cpp +++ b/app/project/item/sequence/sequence.cpp @@ -296,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; } @@ -304,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) { @@ -333,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/project.cpp b/app/project/project.cpp index 9aa04a90f..c29e1b845 100644 --- a/app/project/project.cpp +++ b/app/project/project.cpp @@ -207,9 +207,9 @@ void Project::ColorConfigChanged() QVector footage = this->get_items_of_type(Item::kFootage); foreach (Item* item, footage) { - foreach (StreamPtr s, static_cast(item)->streams()) { + foreach (Stream* s, static_cast(item)->streams()) { if (s->type() == Stream::kVideo) { - std::static_pointer_cast(s)->ColorConfigChanged(); + static_cast(s)->ColorConfigChanged(); } } } @@ -220,9 +220,9 @@ void Project::DefaultColorSpaceChanged() QVector footage = this->get_items_of_type(Item::kFootage); foreach (Item* item, footage) { - foreach (StreamPtr s, static_cast(item)->streams()) { + 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/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 267ddd8ca..691b155bf 100644 --- a/app/task/project/import/import.cpp +++ b/app/task/project/import/import.cpp @@ -142,7 +142,7 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& info_list, int index) { // Heuristically determine whether this file is part of an image sequence or not - 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. @@ -229,7 +229,7 @@ bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage* footage) 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 @@ -245,7 +245,7 @@ bool ProjectImportTask::CompareStillImageSize(Footage* footage, const QSize &sz) return false; } - 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/widget/footagecombobox/footagecombobox.cpp b/app/widget/footagecombobox/footagecombobox.cpp index 2eced37a5..5cdb36c1d 100644 --- a/app/widget/footagecombobox/footagecombobox.cpp +++ b/app/widget/footagecombobox/footagecombobox.cpp @@ -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; @@ -101,9 +96,9 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m) const 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()); } } @@ -120,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 fa1038eef..3c0c59548 100644 --- a/app/widget/footagecombobox/footagecombobox.h +++ b/app/widget/footagecombobox/footagecombobox.h @@ -41,13 +41,16 @@ 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) const; @@ -58,7 +61,7 @@ private: const Folder* root_; - StreamPtr footage_; + Stream* footage_; bool only_show_ready_footage_; }; diff --git a/app/widget/nodecopypaste/nodecopypaste.cpp b/app/widget/nodecopypaste/nodecopypaste.cpp index e6949a176..c46a5efda 100644 --- a/app/widget/nodecopypaste/nodecopypaste.cpp +++ b/app/widget/nodecopypaste/nodecopypaste.cpp @@ -146,11 +146,9 @@ QVector NodeCopyPasteWidget::PasteNodesFromClipboard(Sequence *graph, QU bool found = false; foreach (Item* item, footage) { - const QList& streams = static_cast(item)->streams(); - - foreach (StreamPtr s, streams) { - if (s.get() == loaded_stream) { - con.input->set_standard_value(QVariant::fromValue(s)); + foreach (Stream* s, static_cast(item)->streams()) { + if (s == loaded_stream) { + con.input->set_standard_value(Node::PtrToValue(s)); found = true; break; } 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/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index fb200fd27..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; } @@ -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); } 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/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index 288288aad..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); @@ -416,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()); @@ -479,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/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/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;