mocked up a prototype of decoding data into the node graph

This commit is contained in:
itsmattkc
2019-08-04 14:45:17 +10:00
parent fb8d5df24b
commit 298ae2f36c
15 changed files with 178 additions and 32 deletions
+14
View File
@@ -23,6 +23,7 @@
#include "output.h"
NodeInput::NodeInput() :
keyframing_(false),
can_accept_multiple_inputs_(false)
{
// Have at least one keyframe/value active at any time
@@ -87,6 +88,19 @@ QVariant NodeInput::get_value(const rational &time)
}
}
void NodeInput::set_value(const rational &time, const QVariant &value)
{
if (keyframing()) {
// FIXME: Keyframing code
Q_UNUSED(time)
} else {
keyframes_.first().set_value(value);
// FIXME: Put correct values here
emit ValueChanged(0, 0);
}
}
bool NodeInput::keyframing()
{
return keyframing_;
+11
View File
@@ -29,6 +29,7 @@
*/
class NodeInput : public NodeParam
{
Q_OBJECT
public:
NodeInput();
@@ -81,6 +82,13 @@ public:
*/
QVariant get_value(const rational &time);
/**
* @brief Set the value at a given time
*
* This function will only work if there are no outputs connected.
*/
void set_value(const rational& time, const QVariant& value);
/**
* @brief Return whether keyframing is enabled on this input or not
*/
@@ -96,6 +104,9 @@ public:
*/
const QList<DataType>& inputs();
signals:
void ValueChanged(const rational& start, const rational& end);
private:
/**
* @brief Internal list of accepted data types
+46 -7
View File
@@ -21,11 +21,16 @@
#include "media.h"
#include <QDebug>
#include <QOpenGLPixelTransferOptions>
#include "project/item/footage/footage.h"
// FIXME: Test code only
#include "decoder/ffmpeg/ffmpegdecoder.h"
// End test code
MediaInput::MediaInput() :
texture_(nullptr)
texture_(0)
{
footage_input_ = new NodeInput();
footage_input_->add_data_input(NodeInput::kFootage);
@@ -34,6 +39,10 @@ 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()
@@ -81,13 +90,43 @@ void MediaInput::Process(const rational &time)
// Grab frame from decoder
// FIXME: Test code
if (texture_ == nullptr) {
QImage img("/home/matt/Desktop/oof.png");
texture_ = new QOpenGLTexture(img);
if (decoder_->stream() == nullptr) {
decoder_->set_stream(footage->stream(0));
}
texture_output_->set_value(texture_->textureId());
FramePtr frame = decoder_->Retrieve(time);
if (frame == nullptr) {
texture_output_->set_value(0);
return;
}
// FIXME: Test code
if (texture_ == 0) {
glGenTextures(1, &texture_);
glBindTexture(GL_TEXTURE_2D, texture_);
// Set texture filtering to bilinear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Set texture wrapping to clamp
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
frame->width(),
frame->height(),
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
frame->data()[0]);
}
texture_output_->set_value(texture_);
// End test code
}
+4 -1
View File
@@ -23,6 +23,7 @@
#include <QOpenGLTexture>
#include "decoder/decoder.h"
#include "node/node.h"
/**
@@ -52,7 +53,9 @@ private:
NodeOutput* texture_output_;
QOpenGLTexture* texture_;
GLuint texture_;
Decoder* decoder_;
};
#endif // IMAGE_H