pixelsampler: added pixel sampler panel

When visible, this panel will show the current reference and display transformed
color under the cursor of any viewer.
This commit is contained in:
itsmattkc
2020-04-01 16:57:10 +11:00
parent 76f260cb3a
commit 6ea6dd810e
25 changed files with 390 additions and 48 deletions
+2
View File
@@ -20,6 +20,8 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
render/audioparams.h
render/audioparams.cpp
render/color.h
render/color.cpp
render/colormanager.h
render/colormanager.cpp
render/colorprocessor.h
@@ -87,7 +87,7 @@ void OpenGLFramebuffer::Release()
context_->functions()->glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void OpenGLFramebuffer::Attach(OpenGLTexturePtr texture, bool clear)
void OpenGLFramebuffer::Attach(OpenGLTexture *texture, bool clear)
{
if (context_ == nullptr) {
return;
@@ -115,6 +115,11 @@ void OpenGLFramebuffer::Attach(OpenGLTexturePtr texture, bool clear)
f->glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void OpenGLFramebuffer::Attach(OpenGLTexturePtr texture, bool clear)
{
Attach(texture.get(), clear);
}
void OpenGLFramebuffer::Detach()
{
if (context_ == nullptr) {
@@ -43,6 +43,7 @@ public:
void Release();
void Attach(OpenGLTexture* texture, bool clear = false);
void Attach(OpenGLTexturePtr texture, bool clear = false);
void Detach();
@@ -57,7 +58,7 @@ private:
GLuint buffer_;
OpenGLTexturePtr texture_;
OpenGLTexture* texture_;
};
#endif // OPENGLFRAMEBUFFER_H
+14
View File
@@ -0,0 +1,14 @@
#include "color.h"
Color::Color(const char *data, const PixelFormat::Format &format)
{
OIIO::convert_type(PixelFormat::GetOIIOTypeDesc(format),
data,
PixelFormat::GetOIIOTypeDesc(PixelFormat::PIX_FMT_RGB32F),
data_,
PixelFormat::FormatHasAlphaChannel(format) ? kRGBAChannels : kRGBChannels);
if (!PixelFormat::FormatHasAlphaChannel(format)) {
set_alpha(1.0f);
}
}
+50
View File
@@ -0,0 +1,50 @@
#ifndef COLOR_H
#define COLOR_H
#include "common/define.h"
#include "render/pixelformat.h"
/**
* @brief High precision 32-bit float based RGBA color value
*/
class Color
{
public:
Color()
{
for (int i=0;i<kRGBAChannels;i++) {
data_[i] = 0;
}
}
Color(const float& r, const float& g, const float& b, const float& a = 1.0f)
{
data_[0] = r;
data_[1] = g;
data_[2] = b;
data_[3] = a;
}
Color(const char *data, const PixelFormat::Format &format);
const float& red() const {return data_[0];}
const float& green() const {return data_[1];}
const float& blue() const {return data_[2];}
const float& alpha() const {return data_[3];}
void set_red(const float& red) {data_[0] = red;}
void set_green(const float& green) {data_[1] = green;}
void set_blue(const float& blue) {data_[2] = blue;}
void set_alpha(const float& alpha) {data_[3] = alpha;}
float* data() {return data_;}
const float* data() const {return data_;}
static Color fromData(const char* data, const PixelFormat::Format& format);
private:
float data_[kRGBAChannels];
};
#endif // COLOR_H
+6
View File
@@ -43,6 +43,12 @@ void ColorProcessor::ConvertFrame(FramePtr f)
processor->apply(img);
}
Color ColorProcessor::ConvertColor(Color in)
{
processor->applyRGBA(in.data());
return in;
}
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
{
return std::make_shared<ColorProcessor>(config, source_space, dest_space);
+3 -1
View File
@@ -6,7 +6,7 @@ namespace OCIO = OCIO_NAMESPACE::v1;
#include "codec/frame.h"
#include "common/constructors.h"
#include "render/color.h"
class ColorProcessor;
using ColorProcessorPtr = std::shared_ptr<ColorProcessor>;
@@ -35,6 +35,8 @@ public:
void ConvertFrame(FramePtr f);
Color ConvertColor(Color in);
private:
OCIO::ConstProcessorRcPtr processor;
-44
View File
@@ -140,50 +140,6 @@ PixelFormat::Format PixelFormat::OIIOFormatToOliveFormat(OIIO::TypeDesc desc, bo
return PixelFormat::PIX_FMT_INVALID;
}
/*PixelFormat::Info PixelFormat::GetPixelFormatInfo(const PixelFormat::Format &format)
{
PixelFormat::Info info;
switch (format) {
case PixelFormat::PIX_FMT_RGB8:
case PixelFormat::PIX_FMT_RGBA8:
info.name = tr("8-bit");
info.internal_format = (format == PixelFormat::PIX_FMT_RGB8) ? GL_RGB8 : GL_RGBA8;
info.gl_pixel_type = GL_UNSIGNED_BYTE;
info.oiio_desc = OIIO::TypeDesc::UINT8;
break;
case PixelFormat::PIX_FMT_RGB16U:
case PixelFormat::PIX_FMT_RGBA16U:
info.name = tr("16-bit Integer");
info.internal_format = (format == PixelFormat::PIX_FMT_RGB16U) ? GL_RGB8 : GL_RGBA16;
info.gl_pixel_type = GL_UNSIGNED_SHORT;
info.oiio_desc = OIIO::TypeDesc::UINT16;
break;
case PixelFormat::PIX_FMT_RGB16F:
case PixelFormat::PIX_FMT_RGBA16F:
info.name = tr("Half-Float (16-bit)");
info.internal_format = (format == PixelFormat::PIX_FMT_RGB8) ? GL_RGB8 : GL_RGBA16F;
info.gl_pixel_type = GL_HALF_FLOAT;
info.oiio_desc = OIIO::TypeDesc::HALF;
break;
case PixelFormat::PIX_FMT_RGB32F:
case PixelFormat::PIX_FMT_RGBA32F:
info.name = tr("Full-Float (32-bit)");
info.internal_format = (format == PixelFormat::PIX_FMT_RGB8) ? GL_RGB8 : GL_RGBA32F;
info.gl_pixel_type = GL_FLOAT;
info.oiio_desc = OIIO::TypeDesc::FLOAT;
break;
case PixelFormat::PIX_FMT_INVALID:
case PixelFormat::PIX_FMT_COUNT:
qFatal("Invalid pixel format requested");
}
info.pixel_format = GL_RGBA;
info.bytes_per_pixel = BytesPerPixel(format);
return info;
}*/
int PixelFormat::GetBufferSize(const PixelFormat::Format &format, const int &width, const int &height)
{
return BytesPerPixel(format) * width * height;