finished prototype for float pix fmt converter

This commit is contained in:
itsmattkc
2019-05-30 21:50:18 +10:00
parent c8fe9c9fc7
commit 707ad3c264
28 changed files with 671 additions and 300 deletions
+10 -2
View File
@@ -45,11 +45,16 @@ void NodeGraph::SetTime(const rational &d)
emit TimeChanged();
}
MemoryCache *NodeGraph::memory_cache()
ImageCache *NodeGraph::memory_cache()
{
return &memory_cache_;
}
QOpenGLContext *NodeGraph::GLContext()
{
return ctx_;
}
const int &NodeGraph::width()
{
return width_;
@@ -74,5 +79,8 @@ void NodeGraph::set_height(const int& h)
void NodeGraph::SetGLContext(QOpenGLContext *ctx)
{
memory_cache_.SetParameters(ctx, width_, height_);
if (ctx_ != ctx) {
ctx_ = ctx;
memory_cache_.SetParameters(ctx, width_, height_);
}
}
+3 -3
View File
@@ -5,7 +5,7 @@
#include <QObject>
#include "nodes/node.h"
#include "rendering/memorycache.h"
#include "rendering/imagecache.h"
class NodeGraph : public QObject
{
@@ -51,7 +51,7 @@ public:
const rational &Time();
void SetTime(const rational& d);
MemoryCache* memory_cache();
ImageCache* memory_cache();
QOpenGLContext* GLContext();
void SetGLContext(QOpenGLContext* ctx);
@@ -67,7 +67,7 @@ protected:
private:
Node* output_node_;
MemoryCache memory_cache_;
ImageCache memory_cache_;
QOpenGLContext* ctx_;
int width_;
+50 -8
View File
@@ -3,11 +3,16 @@
#include <QDebug>
#include "nodes/nodegraph.h"
#include "decoders/ffmpegvideodecoder.h"
#include "decoders/pixelformatconverter.h"
#include "global/config.h"
#include "global/global.h"
NodeMedia::NodeMedia(NodeGraph* c) :
Node(c),
media_(nullptr),
buffer_(c->memory_cache()),
img_buffer_(c->memory_cache()),
tex_buffer_(c->memory_cache()),
decoder_(nullptr)
{
matrix_input_ = new NodeIO(this, "matrix", tr("Matrix"), true, false);
@@ -29,21 +34,58 @@ QString NodeMedia::id()
void NodeMedia::Process(const rational &time)
{
Q_UNUSED(time)
QOpenGLFunctions* f = ParentGraph()->GLContext()->functions();
buffer_.buffer()->BindBuffer();
tex_buffer_.buffer()->BindBuffer();
glClearColor(0.5, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
f->glClearColor(0.0, 0.5, 0.0, 0.0);
f->glClear(GL_COLOR_BUFFER_BIT);
buffer_.buffer()->ReleaseBuffer();
tex_buffer_.buffer()->ReleaseBuffer();
texture_output_->SetValue(buffer_.buffer()->texture());
FramePtr frame = decoder_->Retrieve(time);
olive::pix_fmt_conv->AVFrameToPipeline(frame->data(),
frame->linesize(),
frame->width(),
frame->height(),
static_cast<AVPixelFormat>(frame->format()),
img_buffer_.buffer()->data(),
olive::Global->effective_bit_depth());
const olive::PixelFormatInfo& pix_fmt_info = olive::pixel_formats.at(olive::Global->effective_bit_depth());
tex_buffer_.buffer()->BindTexture();
f->glTexSubImage2D(GL_TEXTURE_2D,
0,
0,
0,
frame->width(),
frame->height(),
pix_fmt_info.pixel_format,
pix_fmt_info.pixel_type,
img_buffer_.buffer()->data()
);
tex_buffer_.buffer()->ReleaseTexture();
qDebug() << "Uploaded to texture" << tex_buffer_.buffer()->texture();
texture_output_->SetValue(tex_buffer_.buffer()->texture());
}
void NodeMedia::SetMedia(Media *f)
void NodeMedia::SetMedia(FootageStream *f)
{
// TODO method of finding the decoder we need
decoder_ = std::make_shared<FFmpegVideoDecoder>();
media_ = f;
decoder_->set_stream(media_);
img_buffer_.SetSize(f->video_width, f->video_height);
}
NodeIO *NodeMedia::matrix_input()
+5 -4
View File
@@ -2,7 +2,7 @@
#define MEDIANODE_H
#include "nodes/node.h"
#include "rendering/memorycache.h"
#include "rendering/imagecache.h"
#include "project/media.h"
#include "decoders/decoder.h"
@@ -29,7 +29,7 @@ public:
virtual void Process(const rational& time) override;
void SetMedia(Media* f);
void SetMedia(FootageStream* f);
NodeIO* matrix_input();
NodeIO* texture_output();
@@ -42,11 +42,12 @@ private:
NodeIO* texture_output_;
// Media object to display
Media* media_;
FootageStream* media_;
// Texture buffer
// TODO Probable cache point
MemoryCache::Reference buffer_;
ImageCache::ImgRef img_buffer_;
ImageCache::TexRef tex_buffer_;
// Decoder
DecoderPtr decoder_;