use decoder ID in media node

This commit is contained in:
itsmattkc
2019-08-08 15:52:53 +10:00
parent f3b60369aa
commit c6dfab4caf
5 changed files with 30 additions and 19 deletions
-8
View File
@@ -157,14 +157,6 @@ public:
*/ */
virtual void Close() = 0; 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: protected:
bool open_; bool open_;
+19 -11
View File
@@ -27,10 +27,12 @@
// FIXME: Test code only // FIXME: Test code only
#include "decoder/ffmpeg/ffmpegdecoder.h" #include "decoder/ffmpeg/ffmpegdecoder.h"
#include "decoder/probeserver.h"
#include "render/pixelservice.h" #include "render/pixelservice.h"
// End test code // End test code
MediaInput::MediaInput() MediaInput::MediaInput() :
decoder_(nullptr)
{ {
footage_input_ = new NodeInput(); footage_input_ = new NodeInput();
footage_input_->add_data_input(NodeInput::kFootage); footage_input_->add_data_input(NodeInput::kFootage);
@@ -39,10 +41,6 @@ MediaInput::MediaInput()
texture_output_ = new NodeOutput(); texture_output_ = new NodeOutput();
texture_output_->set_data_type(NodeOutput::kTexture); texture_output_->set_data_type(NodeOutput::kTexture);
AddParameter(texture_output_); AddParameter(texture_output_);
// FIXME: Test code only
decoder_ = new FFmpegDecoder(); // FIXME: Doesn't ever get free'd
// End test code
} }
QString MediaInput::Name() QString MediaInput::Name()
@@ -65,6 +63,12 @@ QString MediaInput::Description()
return tr("Import a footage stream."); return tr("Import a footage stream.");
} }
void MediaInput::Release()
{
delete decoder_;
decoder_ = nullptr;
}
NodeOutput *MediaInput::texture_output() NodeOutput *MediaInput::texture_output()
{ {
return texture_output_; return texture_output_;
@@ -72,23 +76,29 @@ NodeOutput *MediaInput::texture_output()
void MediaInput::Process(const rational &time) 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 // Get currently selected Footage
Footage* footage = ValueToPtr<Footage>(footage_input_->get_value(time)); Footage* footage = ValueToPtr<Footage>(footage_input_->get_value(time));
// If no footage is selected, return nothing // If no footage is selected, return nothing
if (footage == nullptr) { if (footage == nullptr) {
texture_output_->set_value(0);
return; return;
} }
// Otherwise try to get frame of footage from decoder // Otherwise try to get frame of footage from decoder
// Determine which decoder to use // 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) { if (decoder_->stream() == nullptr) {
decoder_->set_stream(footage->stream(0)); decoder_->set_stream(footage->stream(0));
@@ -97,8 +107,6 @@ void MediaInput::Process(const rational &time)
FramePtr frame = decoder_->Retrieve(time); FramePtr frame = decoder_->Retrieve(time);
if (frame == nullptr) { if (frame == nullptr) {
texture_output_->set_value(0);
return; return;
} }
+2
View File
@@ -47,6 +47,8 @@ public:
virtual QString Category() override; virtual QString Category() override;
virtual QString Description() override; virtual QString Description() override;
virtual void Release() override;
NodeOutput* texture_output(); NodeOutput* texture_output();
public slots: public slots:
+4
View File
@@ -38,6 +38,10 @@ QString Node::Description()
return QString(); return QString();
} }
void Node::Release()
{
}
void Node::AddParameter(NodeParam *param) void Node::AddParameter(NodeParam *param)
{ {
param->setParent(this); param->setParent(this);
+5
View File
@@ -82,6 +82,11 @@ public:
*/ */
virtual QString Description(); 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 * @brief Return the parameter at a given index
*/ */