From c6dfab4caf8083fa44ae4691104e7ae778f26f11 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 8 Aug 2019 15:52:53 +1000 Subject: [PATCH] use decoder ID in media node --- app/decoder/decoder.h | 8 -------- app/node/input/media/media.cpp | 30 +++++++++++++++++++----------- app/node/input/media/media.h | 2 ++ app/node/node.cpp | 4 ++++ app/node/node.h | 5 +++++ 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/decoder/decoder.h b/app/decoder/decoder.h index 0745f3b07..aebb2950d 100644 --- a/app/decoder/decoder.h +++ b/app/decoder/decoder.h @@ -157,14 +157,6 @@ public: */ virtual void Close() = 0; - /** - * @brief Prepare footage for use by a Decoder later - * - * Needs fleshing out. This functions purpose will be to perform initial analyses of a video file. Any caching, - * indexing, or transcoding to help make this media performant and reliable should be done here. - */ - //virtual void Analyze();// = 0; - protected: bool open_; diff --git a/app/node/input/media/media.cpp b/app/node/input/media/media.cpp index be101a03f..8c015867a 100644 --- a/app/node/input/media/media.cpp +++ b/app/node/input/media/media.cpp @@ -27,10 +27,12 @@ // FIXME: Test code only #include "decoder/ffmpeg/ffmpegdecoder.h" +#include "decoder/probeserver.h" #include "render/pixelservice.h" // End test code -MediaInput::MediaInput() +MediaInput::MediaInput() : + decoder_(nullptr) { footage_input_ = new NodeInput(); footage_input_->add_data_input(NodeInput::kFootage); @@ -39,10 +41,6 @@ MediaInput::MediaInput() texture_output_ = new NodeOutput(); texture_output_->set_data_type(NodeOutput::kTexture); AddParameter(texture_output_); - - // FIXME: Test code only - decoder_ = new FFmpegDecoder(); // FIXME: Doesn't ever get free'd - // End test code } QString MediaInput::Name() @@ -65,6 +63,12 @@ QString MediaInput::Description() return tr("Import a footage stream."); } +void MediaInput::Release() +{ + delete decoder_; + decoder_ = nullptr; +} + NodeOutput *MediaInput::texture_output() { return texture_output_; @@ -72,23 +76,29 @@ NodeOutput *MediaInput::texture_output() void MediaInput::Process(const rational &time) { - // FIXME: Use OIIO and OCIO here + // FIXME: Use OCIO for color management + + // Set default texture to no texture + texture_output_->set_value(0); // Get currently selected Footage Footage* footage = ValueToPtr(footage_input_->get_value(time)); // If no footage is selected, return nothing if (footage == nullptr) { - texture_output_->set_value(0); - return; } // Otherwise try to get frame of footage from decoder // Determine which decoder to use + if (decoder_ == nullptr) { + decoder_ = olive::CreateDecoderFromID(footage->decoder()); - // Grab frame from decoder + if (decoder_ == nullptr) { + return; + } + } if (decoder_->stream() == nullptr) { decoder_->set_stream(footage->stream(0)); @@ -97,8 +107,6 @@ void MediaInput::Process(const rational &time) FramePtr frame = decoder_->Retrieve(time); if (frame == nullptr) { - texture_output_->set_value(0); - return; } diff --git a/app/node/input/media/media.h b/app/node/input/media/media.h index dd5065671..20c8e35ae 100644 --- a/app/node/input/media/media.h +++ b/app/node/input/media/media.h @@ -47,6 +47,8 @@ public: virtual QString Category() override; virtual QString Description() override; + virtual void Release() override; + NodeOutput* texture_output(); public slots: diff --git a/app/node/node.cpp b/app/node/node.cpp index 7c80dc0d1..9122a93d9 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -38,6 +38,10 @@ QString Node::Description() return QString(); } +void Node::Release() +{ +} + void Node::AddParameter(NodeParam *param) { param->setParent(this); diff --git a/app/node/node.h b/app/node/node.h index 1098d8221..5cea5dfee 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -82,6 +82,11 @@ public: */ virtual QString Description(); + /** + * @brief Signals the Node that it won't be used for a while and can deallocate some memory + */ + virtual void Release(); + /** * @brief Return the parameter at a given index */