implement color processor job

Refactored code to use a color processor job
This commit is contained in:
itsmattkc
2022-04-15 14:03:06 -07:00
parent 97a210f14b
commit 7f0fc1de90
31 changed files with 518 additions and 413 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ OCIO::BitDepth OCIOUtils::GetOCIOBitDepthFromPixelFormat(VideoParams::Format for
return OCIO::BIT_DEPTH_UNKNOWN;
}
OCIO::GradingRGBM OCIOUtils::QVec4ToRGBM(QVector4D vector)
OCIO::GradingRGBM OCIOUtils::QVec4ToRGBM(const QVector4D &vector)
{
OCIO::GradingRGBM rgbm;
+1 -1
View File
@@ -35,7 +35,7 @@ class OCIOUtils
public:
static OCIO::BitDepth GetOCIOBitDepthFromPixelFormat(VideoParams::Format format);
static OCIO::GradingRGBM QVec4ToRGBM(QVector4D vector);
static OCIO::GradingRGBM QVec4ToRGBM(const QVector4D &vector);
};
}
+1
View File
@@ -16,6 +16,7 @@
add_subdirectory(colormanager)
add_subdirectory(displaytransform)
add_subdirectory(ociobase)
add_subdirectory(ociogradingtransform)
set(OLIVE_SOURCES
@@ -269,6 +269,7 @@ void ColorManager::InputValueChangedEvent(const QString &input, int element)
try {
SetConfig(OCIO::Config::CreateFromFile(GetConfigFilename().toUtf8()));
emit ConfigChanged();
} catch (OCIO::Exception&) {}
}
@@ -124,6 +124,9 @@ public:
virtual void Retranslate() override;
signals:
void ConfigChanged();
protected:
virtual void InputValueChangedEvent(const QString &input, int element) override;
@@ -1,70 +1,42 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "displaytransform.h"
#include "node/project/project.h"
#include "render/colorprocessor.h"
#include "node/color/colormanager/colormanager.h"
namespace olive {
const QString DisplayTransformNode::kTextureInput = QStringLiteral("tex_in");
const QString DisplayTransformNode::kDisplayInput = QStringLiteral("display_in");
const QString DisplayTransformNode::kViewInput = QStringLiteral("view_in");
const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in");
#define super OCIOBaseNode
DisplayTransformNode::DisplayTransformNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kDisplayInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
AddInput(kDisplayInput, NodeValue::kCombo, 0);
AddInput(kViewInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
AddInput(kViewInput, NodeValue::kCombo, 0);
AddInput(kDirectionInput, NodeValue::kCombo, 0);
Retranslate();
}
void DisplayTransformNode::GenerateProcessor()
{
if (!project()) {
return;
}
if (view_.isEmpty()) {
Retranslate();
}
ColorTransform transform(display_, view_, "");
reference_to_display_ = ColorProcessor::Create(project()->color_manager(),
project()->color_manager()->GetReferenceColorSpace(), transform);
// Create shader description
shader_desc_ = OCIO::GpuShaderDesc::CreateShaderDesc();
shader_desc_->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3);
shader_desc_->setFunctionName("DisplayTransform");
shader_desc_->setResourcePrefix("ocio_");
// Generate shader
reference_to_display_->GetProcessor()->getDefaultGPUProcessor()->extractGpuShaderInfo(shader_desc_);
}
Node *DisplayTransformNode::copy() const
{
return new DisplayTransformNode();
AddInput(kDirectionInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
}
QString DisplayTransformNode::Name() const
@@ -74,7 +46,7 @@ QString DisplayTransformNode::Name() const
QString DisplayTransformNode::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.disaplaytransform");
return QStringLiteral("org.olivevideoeditor.Olive.displaytransform");
}
QVector<Node::CategoryID> DisplayTransformNode::Category() const
@@ -89,66 +61,83 @@ QString DisplayTransformNode::Description() const
void DisplayTransformNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kDisplayInput, tr("Display"));
SetInputName(kViewInput, tr("View"));
if (project()) {
SetComboBoxStrings(kDisplayInput, project()->color_manager()->ListAvailableDisplays());
display_ = project()->color_manager()->ListAvailableDisplays().at(
GetSplitStandardValue(kDisplayInput).at(0).toString().toInt());
SetComboBoxStrings(kViewInput, project()->color_manager()->ListAvailableViews(display_));
view_ = project()->color_manager()->ListAvailableViews(display_).at(
GetSplitStandardValue(kViewInput).at(0).toString().toInt());
}
SetInputName(kDirectionInput, tr("Direction"));
SetComboBoxStrings(kDirectionInput, {tr("Forward"), tr("Inverse")});
}
void DisplayTransformNode::InputValueChangedEvent(const QString &input, int element) {
void DisplayTransformNode::InputValueChangedEvent(const QString &input, int element)
{
Q_UNUSED(element);
if (input == kDirectionInput) {
if (input == kDisplayInput || input == kDirectionInput || input == kViewInput) {
if (input == kDisplayInput) {
UpdateViews();
}
GenerateProcessor();
}
if (project()) {
if (input == kDisplayInput) {
display_ = project()->color_manager()->ListAvailableDisplays().at(
GetSplitStandardValue(kDisplayInput).at(0).toString().toInt());
// If we change the display the view menu must be updated
Retranslate();
GenerateProcessor();
}
if (input == kViewInput) {
view_ = project()->color_manager()->ListAvailableViews(display_).at(
GetSplitStandardValue(kViewInput).at(0).toString().toInt());
GenerateProcessor();
}
QString DisplayTransformNode::GetDisplay() const
{
if (manager()) {
int index = GetStandardValue(kDisplayInput).toInt();
if (index < manager()->ListAvailableDisplays().size()) {
return manager()->ListAvailableDisplays().at(index);
}
}
return QString();
}
ShaderCode DisplayTransformNode::GetShaderCode(const QString &shader_id) const
QString DisplayTransformNode::GetView() const
{
Q_UNUSED(shader_id)
// Generate shader code using OCIO stub and our auto-generated name
QString shader_frag = FileFunctions::ReadFileAsString(QStringLiteral(":shaders/displaytransform.frag"))
.arg(shader_desc_->getShaderText());
return ShaderCode(shader_frag);
if (manager()) {
QString display = GetDisplay();
if (!display.isEmpty()) {
int index = GetStandardValue(kViewInput).toInt();
QStringList views = manager()->ListAvailableViews(display);
if (index < views.size()) {
return views.at(index);
}
}
}
return QString();
}
void DisplayTransformNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
ColorProcessor::Direction DisplayTransformNode::GetDirection() const
{
ShaderJob job;
job.InsertValue(value);
job.SetUseOCIO(true);
job.SetShaderDesc(shader_desc_);
job.SetColorProcessor(reference_to_display_);
return static_cast<ColorProcessor::Direction>(GetStandardValue(kDirectionInput).toInt());;
}
// If there's no texture, no need to run an operation
if (!job.GetValue(kTextureInput).data().isNull()) {
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
void DisplayTransformNode::UpdateDisplays()
{
if (manager()) {
SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays());
}
}
void DisplayTransformNode::UpdateViews()
{
if (manager()) {
SetComboBoxStrings(kViewInput, manager()->ListAvailableViews(GetDisplay()));
}
}
void DisplayTransformNode::ConfigChanged()
{
UpdateDisplays();
UpdateViews();
GenerateProcessor();
}
void DisplayTransformNode::GenerateProcessor()
{
if (manager()) {
ColorTransform transform(GetDisplay(), GetView(), QString());
set_processor(ColorProcessor::Create(manager(), manager()->GetReferenceColorSpace(), transform, GetDirection()));
}
}
@@ -1,35 +1,39 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef DISPLAYTRANSFORMNODE_H
#define DISPLAYTRANSFORMNODE_H
#include "node/node.h"
#include "node/color/ociobase/ociobase.h"
#include "render/colorprocessor.h"
namespace olive {
class DisplayTransformNode : public Node {
class DisplayTransformNode : public OCIOBaseNode
{
Q_OBJECT
public:
DisplayTransformNode();
NODE_DEFAULT_DESTRUCTOR(DisplayTransformNode)
void GenerateProcessor();
virtual Node *copy() const override;
NODE_COPY_FUNCTION(DisplayTransformNode)
virtual QString Name() const override;
virtual QString id() const override;
@@ -39,26 +43,26 @@ class DisplayTransformNode : public Node {
virtual void Retranslate() override;
virtual void InputValueChangedEvent(const QString &input, int element) override;
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
QString GetDisplay() const;
QString GetView() const;
ColorProcessor::Direction GetDirection() const;
ColorProcessorPtr GetColorProcessor() { return reference_to_display_; };
OCIO::GpuShaderDescRcPtr GetGPUShaderDesc() { return shader_desc_; };
static const QString kTextureInput;
static const QString kDisplayInput;
static const QString kViewInput;
static const QString kDirectionInput;
const QString shader_text_;
protected slots:
virtual void ConfigChanged() override;
ColorProcessorPtr reference_to_display_;
OCIO::GpuShaderDescRcPtr shader_desc_;
private:
void GenerateProcessor();
void UpdateDisplays();
void UpdateViews();
QString display_;
QString view_;
};
} // olive
#endif
#endif // DISPLAYTRANSFORMNODE_H
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2021 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/color/ociobase/ociobase.cpp
node/color/ociobase/ociobase.h
PARENT_SCOPE
)
+65
View File
@@ -0,0 +1,65 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "ociobase.h"
#include "node/color/colormanager/colormanager.h"
#include "node/project/project.h"
namespace olive {
const QString OCIOBaseNode::kTextureInput = QStringLiteral("tex_in");
OCIOBaseNode::OCIOBaseNode() :
manager_(nullptr),
processor_(nullptr)
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
connect(this, &Node::AddedToGraph, this, &OCIOBaseNode::ParentChanged);
}
void OCIOBaseNode::ParentChanged(NodeGraph *graph)
{
if (manager_) {
disconnect(manager_, &ColorManager::ConfigChanged, this, &OCIOBaseNode::ConfigChanged);
manager_ = nullptr;
}
if (Project *p = dynamic_cast<Project*>(graph)) {
manager_ = p->color_manager();
connect(manager_, &ColorManager::ConfigChanged, this, &OCIOBaseNode::ConfigChanged);
ConfigChanged();
}
}
void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
if (!value[kTextureInput].data().isNull() && processor_) {
ColorTransformJob job;
job.SetColorProcessor(processor_);
job.SetInputTexture(value[kTextureInput].data().value<TexturePtr>());
table->Push(NodeValue::kColorTransformJob, QVariant::fromValue(job), this);
}
}
}
+60
View File
@@ -0,0 +1,60 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OCIOBASENODE_H
#define OCIOBASENODE_H
#include "node/node.h"
#include "render/job/colortransformjob.h"
namespace olive {
class OCIOBaseNode : public Node
{
Q_OBJECT
public:
OCIOBaseNode();
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
static const QString kTextureInput;
protected slots:
virtual void ConfigChanged() = 0;
protected:
ColorManager *manager() const { return manager_; }
ColorProcessorPtr processor() const { return processor_; }
void set_processor(ColorProcessorPtr p) { processor_ = p; }
private:
ColorManager *manager_;
ColorProcessorPtr processor_;
private slots:
void ParentChanged(olive::NodeGraph *graph);
};
}
#endif // OCIOBASENODE_H
@@ -1,16 +1,21 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "ociogradingtransform.h"
@@ -21,7 +26,6 @@
namespace olive {
const QString OCIOGradingTransformNode::kTextureInput = QStringLiteral("tex_in");
const QString OCIOGradingTransformNode::kTypeInput = QStringLiteral("type_in");
const QString OCIOGradingTransformNode::kBrightnessInput = QStringLiteral("brightness_in");
const QString OCIOGradingTransformNode::kContrastInput = QStringLiteral("contrast_in");
@@ -37,88 +41,39 @@ const QString OCIOGradingTransformNode::kPivotWhiteInput = QStringLiteral("pivot
const QString OCIOGradingTransformNode::kClampBlackInput = QStringLiteral("clamp_black_in");
const QString OCIOGradingTransformNode::kClampWhiteInput = QStringLiteral("clamp_white_in");
#define super OCIOBaseNode
OCIOGradingTransformNode::OCIOGradingTransformNode()
{
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
AddInput(kTypeInput, NodeValue::kCombo, 0);
//AddInput(kBrightnessInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
AddInput(kContrastInput, NodeValue::kVec4, QVector4D{1.0, 1.0, 1.0, 1.0});
AddInput(kContrastInput, NodeValue::kVec4, QVector4D{1.0, 1.0, 1.0, 1.0}, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
SetInputProperty(kContrastInput, QStringLiteral("min"), QVector4D{0.001f, 0.001f, 0.001f, 0.001f});
//AddInput(kGammaInput, NodeValue::kVec4, QVector4D{1.0, 1.0, 1.0, 1.0});
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0}, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0}, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
//AddInput(kLiftInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
//AddInput(kGainInput, NodeValue::kVec4, QVector4D{1.0, 1.0, 1.0, 1.0});
AddInput(kSaturationInput, NodeValue::kFloat, 1.0);
AddInput(kSaturationInput, NodeValue::kFloat, 1.0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0);
AddInput(kPivotInput, NodeValue::kFloat, 0.203919098);
AddInput(kPivotInput, NodeValue::kFloat, 0.203919098, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
// AddInput(kPivotBlackInput, NodeValue::kFloat, 0.0);
//AddInput(kPivotWhiteInput, NodeValue::kFloat, 1.0);
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0);
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
AddInput(kClampWhiteInput, NodeValue::kFloat, 200.0);
GenerateProcessor();
}
void OCIOGradingTransformNode::GenerateProcessor()
{
if (!project()) {
return;
}
// Create shader description
shader_desc_ = OCIO::GpuShaderDesc::CreateShaderDesc();
shader_desc_->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_3);
shader_desc_->setFunctionName("OCIOGradingTransform");
shader_desc_->setResourcePrefix("ocio_");
OCIO::GradingPrimaryTransformRcPtr gp = OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
//auto gp = OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
//gp->makeDynamic();
OCIO::GradingPrimary gpdata{OCIO::GRADING_LIN};
//gpdata.m_lift = OCIOUtils::QVec4ToRGBM(GetStandardValue(kLiftInput).value<QVector4D>());
gpdata.m_contrast = OCIOUtils::QVec4ToRGBM(GetStandardValue(kContrastInput).value<QVector4D>());
gpdata.m_exposure = OCIOUtils::QVec4ToRGBM(GetStandardValue(kExposureInput).value<QVector4D>());
//gpdata.m_gamma = OCIOUtils::QVec4ToRGBM(GetStandardValue(kGammaInput).value<QVector4D>());
//gpdata.m_gain = OCIOUtils::QVec4ToRGBM(GetStandardValue(kGainInput).value<QVector4D>());
gpdata.m_offset = OCIOUtils::QVec4ToRGBM(GetStandardValue(kOffsetInput).value<QVector4D>());
gpdata.m_saturation = GetStandardValue(kSaturationInput).value<double>();
gpdata.m_pivot = GetStandardValue(kPivotInput).value<double>();
gpdata.m_clampBlack = GetStandardValue(kClampBlackInput).value<double>();
gpdata.m_clampWhite = GetStandardValue(kClampWhiteInput).value<double>();
//gpdata.m_pivotBlack = GetStandardValue(kPivotBlackInput).value<double>();
//gpdata.m_pivotWhite = GetStandardValue(kPivotWhiteInput).value<double>();
try {
gp->setValue(gpdata);
processor_ = std::make_shared<ColorProcessor>();
processor_->SetProsessor(project()->color_manager()->GetConfig()->getProcessor(gp));
} catch (const OCIO::Exception &e) {
std::cerr << std::endl << e.what() << std::endl;
}
processor_->GetProcessor()->getDefaultGPUProcessor()->extractGpuShaderInfo(shader_desc_);
}
Node *OCIOGradingTransformNode::copy() const
{
return new OCIOGradingTransformNode();
AddInput(kClampWhiteInput, NodeValue::kFloat, 200.0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
}
QString OCIOGradingTransformNode::Name() const
@@ -143,6 +98,8 @@ QString OCIOGradingTransformNode::Description() const
void OCIOGradingTransformNode::Retranslate()
{
super::Retranslate();
SetInputName(kTextureInput, tr("Input"));
SetInputName(kTypeInput, tr("Type"));
//SetInputName(kBrightnessInput, tr("Brightness"));
@@ -165,29 +122,35 @@ void OCIOGradingTransformNode::Retranslate()
void OCIOGradingTransformNode::InputValueChangedEvent(const QString &input, int element)
{
Q_UNUSED(element);
GenerateProcessor();
ConfigChanged();
}
ShaderCode OCIOGradingTransformNode::GetShaderCode(const QString &shader_id) const
void OCIOGradingTransformNode::ConfigChanged()
{
Q_UNUSED(shader_id)
// Generate shader code using OCIO stub and our auto-generated name
QString shader_frag = FileFunctions::ReadFileAsString(QStringLiteral(":shaders/ociogradingtransform.frag"))
.arg(shader_desc_->getShaderText());
return ShaderCode(shader_frag);
}
OCIO::GradingPrimaryTransformRcPtr gp = OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
//auto gp = OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
//gp->makeDynamic();
void OCIOGradingTransformNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
{
ShaderJob job;
job.InsertValue(value);
job.SetUseOCIO(true);
job.SetShaderDesc(shader_desc_);
job.SetColorProcessor(processor_);
OCIO::GradingPrimary gpdata{OCIO::GRADING_LIN};
//gpdata.m_lift = OCIOUtils::QVec4ToRGBM(GetStandardValue(kLiftInput).value<QVector4D>());
gpdata.m_contrast = OCIOUtils::QVec4ToRGBM(GetStandardValue(kContrastInput).value<QVector4D>());
gpdata.m_exposure = OCIOUtils::QVec4ToRGBM(GetStandardValue(kExposureInput).value<QVector4D>());
//gpdata.m_gamma = OCIOUtils::QVec4ToRGBM(GetStandardValue(kGammaInput).value<QVector4D>());
//gpdata.m_gain = OCIOUtils::QVec4ToRGBM(GetStandardValue(kGainInput).value<QVector4D>());
gpdata.m_offset = OCIOUtils::QVec4ToRGBM(GetStandardValue(kOffsetInput).value<QVector4D>());
gpdata.m_saturation = GetStandardValue(kSaturationInput).value<double>();
gpdata.m_pivot = GetStandardValue(kPivotInput).value<double>();
gpdata.m_clampBlack = GetStandardValue(kClampBlackInput).value<double>();
gpdata.m_clampWhite = GetStandardValue(kClampWhiteInput).value<double>();
//gpdata.m_pivotBlack = GetStandardValue(kPivotBlackInput).value<double>();
//gpdata.m_pivotWhite = GetStandardValue(kPivotWhiteInput).value<double>();
try {
gp->setValue(gpdata);
// If there's no texture, no need to run an operation
if (!job.GetValue(kTextureInput).data().isNull()) {
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
set_processor(ColorProcessor::Create(manager()->GetConfig()->getProcessor(gp)));
} catch (const OCIO::Exception &e) {
std::cerr << std::endl << e.what() << std::endl;
}
}
@@ -1,35 +1,39 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OCIOGRADINGTRANSFORMNODE_H
#define OCIOGRADINGTRANSFORMNODE_H
#include "node/node.h"
#include "node/color/ociobase/ociobase.h"
#include "render/colorprocessor.h"
namespace olive {
class OCIOGradingTransformNode : public Node {
class OCIOGradingTransformNode : public OCIOBaseNode
{
Q_OBJECT
public:
OCIOGradingTransformNode();
NODE_DEFAULT_DESTRUCTOR(OCIOGradingTransformNode)
void GenerateProcessor();
virtual Node *copy() const override;
NODE_COPY_FUNCTION(OCIOGradingTransformNode)
virtual QString Name() const override;
virtual QString id() const override;
@@ -39,13 +43,6 @@ class OCIOGradingTransformNode : public Node {
virtual void Retranslate() override;
virtual void InputValueChangedEvent(const QString &input, int element) override;
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
ColorProcessorPtr GetColorProcessor() { return processor_; };
OCIO::GpuShaderDescRcPtr GetGPUShaderDesc() { return shader_desc_; };
static const QString kTextureInput;
static const QString kTypeInput;
static const QString kBrightnessInput;
static const QString kContrastInput;
@@ -61,13 +58,9 @@ class OCIOGradingTransformNode : public Node {
static const QString kClampBlackInput;
static const QString kClampWhiteInput;
const QString shader_text_;
protected slots:
virtual void ConfigChanged() override;
ColorProcessorPtr processor_;
OCIO::GpuShaderDescRcPtr shader_desc_;
QString display_;
QString view_;
};
} // olive
+9 -1
View File
@@ -86,7 +86,7 @@ SampleBufferPtr HashTraverser::ProcessAudioFootage(const FootageJob &stream, con
return buf;
}
TexturePtr HashTraverser::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
TexturePtr HashTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
{
HashGenerateJob(node, &job);
@@ -104,6 +104,14 @@ TexturePtr HashTraverser::ProcessShader(const Node *node, const TimeRange &range
return texture;
}
TexturePtr HashTraverser::ProcessColorTransform(const Node *node, const ColorTransformJob &job)
{
Hash(job.GetColorProcessor()->id());
TexturePtr texture = super::ProcessColorTransform(node, job);
texture_ids_.insert(texture.get(), hash_.result());
return texture;
}
SampleBufferPtr HashTraverser::ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job)
{
SampleBufferPtr buf = super::ProcessSamples(node, range, job);
+3 -1
View File
@@ -37,7 +37,9 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
virtual TexturePtr ProcessColorTransform(const Node *node, const ColorTransformJob& job) override;
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job) override;
+16 -1
View File
@@ -292,7 +292,7 @@ SampleBufferPtr NodeTraverser::ProcessAudioFootage(const FootageJob& stream, con
return SampleBuffer::Create();
}
TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
{
Q_UNUSED(node)
Q_UNUSED(range)
@@ -304,6 +304,13 @@ TexturePtr NodeTraverser::ProcessShader(const Node *node, const TimeRange &range
return CreateDummyTexture(tex_params);
}
TexturePtr NodeTraverser::ProcessColorTransform(const Node *node, const ColorTransformJob &job)
{
Q_UNUSED(node)
return CreateDummyTexture(job.GetInputTexture()->params());
}
SampleBufferPtr NodeTraverser::ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job)
{
Q_UNUSED(node)
@@ -366,6 +373,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
QList<NodeValue> shader_jobs_to_run;
QList<NodeValue> sample_jobs_to_run;
QList<NodeValue> generate_jobs_to_run;
QList<NodeValue> color_transform_jobs_to_run;
for (int i=0; i<output_params.Count(); i++) {
const NodeValue& v = output_params.at(i);
@@ -379,6 +387,8 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
take_this_value_list = &sample_jobs_to_run;
} else if (v.type() == NodeValue::kGenerateJob) {
take_this_value_list = &generate_jobs_to_run;
} else if (v.type() == NodeValue::kColorTransformJob) {
take_this_value_list = &color_transform_jobs_to_run;
}
if (take_this_value_list) {
@@ -410,6 +420,11 @@ void NodeTraverser::PostProcessTable(const Node *node, const Node::ValueHint &hi
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessShader(node, range, v.data().value<ShaderJob>())), node, v.array(), v.tag());
}
// Run color transforms
foreach (const NodeValue& v, color_transform_jobs_to_run) {
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessColorTransform(node, v.data().value<ColorTransformJob>())), node, v.array(), v.tag());
}
// Run generate jobs
foreach (const NodeValue& v, generate_jobs_to_run) {
output_params.Push(NodeValue::kTexture, QVariant::fromValue(ProcessFrameGeneration(node, v.data().value<GenerateJob>())), node, v.array(), v.tag());
+4 -1
View File
@@ -27,6 +27,7 @@
#include "common/cancelableobject.h"
#include "node/output/track/track.h"
#include "render/job/footagejob.h"
#include "render/job/colortransformjob.h"
#include "value.h"
namespace olive {
@@ -76,7 +77,9 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time);
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job);
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job);
virtual TexturePtr ProcessColorTransform(const Node *node, const ColorTransformJob& job);
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job);
+3
View File
@@ -141,6 +141,7 @@ QByteArray NodeValue::ValueToBytes(NodeValue::Type type, const QVariant &value)
case kShaderJob:
case kSampleJob:
case kGenerateJob:
case kColorTransformJob:
case kDataTypeCount:
break;
}
@@ -358,6 +359,7 @@ QString NodeValue::GetPrettyDataTypeName(Type type)
case kShaderJob:
case kSampleJob:
case kGenerateJob:
case kColorTransformJob:
case kDataTypeCount:
break;
}
@@ -410,6 +412,7 @@ QString NodeValue::GetDataTypeName(Type type)
case kShaderJob:
case kSampleJob:
case kGenerateJob:
case kColorTransformJob:
case kDataTypeCount:
break;
}
+9
View File
@@ -208,6 +208,15 @@ public:
*/
kGenerateJob,
/**
* Job type
*
* An internal type used to indicate to the renderer that an accelerated color transform job
* needs to take place. This value will usually be taken from a table and a kTexture value will
* be pushed to take its place.
*/
kColorTransformJob,
/**
* End of list
*/
+17 -14
View File
@@ -25,11 +25,8 @@
#include "node/color/colormanager/colormanager.h"
namespace olive {
ColorProcessor::ColorProcessor()
{
}
ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const ColorTransform &transform)
ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const ColorTransform &transform, Direction direction)
{
QMutexLocker locker(config->mutex());
@@ -44,6 +41,7 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
display_transform->setSrc(input.toUtf8());
display_transform->setDisplay(output.toUtf8());
display_transform->setView(view.toUtf8());
display_transform->setDirection(direction == kNormal ? OCIO::TRANSFORM_DIR_FORWARD : OCIO::TRANSFORM_DIR_INVERSE);
OCIO_SET_C_LOCALE_FOR_SCOPE;
@@ -73,7 +71,11 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
OCIO_SET_C_LOCALE_FOR_SCOPE;
try {
processor_ = config->GetConfig()->getProcessor(input.toUtf8(), output.toUtf8());
if (direction == kNormal) {
processor_ = config->GetConfig()->getProcessor(input.toUtf8(), output.toUtf8());
} else {
processor_ = config->GetConfig()->getProcessor(output.toUtf8(), input.toUtf8());
}
} catch (OCIO::Exception &e) {
qWarning() << "ColorProcessor exception:" << e.what();
}
@@ -81,7 +83,12 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, const
}
cpu_processor_ = processor_->getDefaultCPUProcessor();
id_ = GenerateID(config, input, transform);
}
ColorProcessor::ColorProcessor(OCIO::ConstProcessorRcPtr processor)
{
processor_ = processor;
cpu_processor_ = processor_->getDefaultCPUProcessor();
}
void ColorProcessor::ConvertFrame(Frame *f)
@@ -115,18 +122,14 @@ Color ColorProcessor::ConvertColor(const Color& in)
return Color(c[0], c[1], c[2], c[3]);
}
QString ColorProcessor::GenerateID(ColorManager *config, const QString &input, const ColorTransform &transform)
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& input, const ColorTransform &transform, Direction direction)
{
return QStringLiteral("%1:%2:%3:%4:%5").arg(config->GetConfigFilename(),
input,
transform.display(),
transform.view(),
transform.look());
return std::make_shared<ColorProcessor>(config, input, transform, direction);
}
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& input, const ColorTransform &transform)
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstProcessorRcPtr processor)
{
return std::make_shared<ColorProcessor>(config, input, transform);
return std::make_shared<ColorProcessor>(processor);
}
OCIO::ConstProcessorRcPtr ColorProcessor::GetProcessor()
+6 -10
View File
@@ -41,35 +41,31 @@ public:
kInverse
};
ColorProcessor(ColorManager* config, const QString& input, const ColorTransform& dest_space);
ColorProcessor();
ColorProcessor(ColorManager* config, const QString& input, const ColorTransform& dest_space, Direction direction = kNormal);
ColorProcessor(OCIO::ConstProcessorRcPtr processor);
DISABLE_COPY_MOVE(ColorProcessor)
static ColorProcessorPtr Create(ColorManager* config, const QString& input, const ColorTransform& dest_space);
static ColorProcessorPtr Create(ColorManager* config, const QString& input, const ColorTransform& dest_space, Direction direction = kNormal);
static ColorProcessorPtr Create(OCIO::ConstProcessorRcPtr processor);
OCIO::ConstProcessorRcPtr GetProcessor();
void SetProsessor(OCIO::ConstProcessorRcPtr processor) { processor_ = processor; };
void ConvertFrame(FramePtr f);
void ConvertFrame(Frame* f);
Color ConvertColor(const Color &in);
const QString& id() const
const char *id() const
{
return id_;
return processor_->getCacheID();
}
static QString GenerateID(ColorManager* config, const QString& input, const ColorTransform& dest_space);
private:
OCIO::ConstProcessorRcPtr processor_;
OCIO::ConstCPUProcessorRcPtr cpu_processor_;
QString id_;
};
using ColorProcessorChain = QVector<ColorProcessorPtr>;
+54
View File
@@ -0,0 +1,54 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2021 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COLORTRANSFORMJOB_H
#define COLORTRANSFORMJOB_H
#include "render/colorprocessor.h"
#include "render/texture.h"
namespace olive {
class ColorTransformJob {
public:
ColorTransformJob()
{
processor_ = nullptr;
input_texture_ = nullptr;
}
TexturePtr GetInputTexture() const { return input_texture_; }
void SetInputTexture(TexturePtr tex) { input_texture_ = tex; }
ColorProcessorPtr GetColorProcessor() const { return processor_; }
void SetColorProcessor(ColorProcessorPtr p) { processor_ = p; }
private:
ColorProcessorPtr processor_;
TexturePtr input_texture_;
};
}
Q_DECLARE_METATYPE(olive::ColorTransformJob)
#endif // COLORTRANSFORMJOB_H
-37
View File
@@ -36,7 +36,6 @@ public:
{
iterations_ = 1;
iterative_input_ = nullptr;
use_ocio_ = false;
}
const QString& GetShaderID() const
@@ -90,36 +89,6 @@ public:
interpolation_.insert(id, interp);
}
bool UseOCIO() const
{
return use_ocio_;
}
void SetUseOCIO(bool use_ocio)
{
use_ocio_ = use_ocio;
}
ColorProcessorPtr ColorProcessor()
{
return color_processor_;
}
void SetColorProcessor(ColorProcessorPtr processor)
{
color_processor_ = processor;
}
OCIO::GpuShaderDescRcPtr ShaderDesc()
{
return shader_desc_;
}
void SetShaderDesc(OCIO::GpuShaderDescRcPtr shader_desc)
{
shader_desc_ = shader_desc;
}
void SetVertexCoordinates(const QVector<float> &vertex_coords)
{
vertex_overrides_ = vertex_coords;
@@ -139,12 +108,6 @@ private:
QHash<QString, Texture::Interpolation> interpolation_;
bool use_ocio_;
ColorProcessorPtr color_processor_;
OCIO::GpuShaderDescRcPtr shader_desc_;
QVector<float> vertex_overrides_;
};
+1
View File
@@ -523,6 +523,7 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
case NodeValue::kFootageJob:
case NodeValue::kBezier:
case NodeValue::kNone:
case NodeValue::kColorTransformJob:
case NodeValue::kDataTypeCount:
break;
}
+64 -112
View File
@@ -62,23 +62,6 @@ void Renderer::BlitColorManaged(ColorProcessorPtr color_processor, TexturePtr so
BlitColorManagedInternal(color_processor, source, source_alpha_association, nullptr, params, clear_destination, matrix, crop_matrix);
}
void Renderer::ShaderJobInsertTextures(ColorProcessorPtr color_processor, ShaderJob* job,
OCIO::GpuShaderDescRcPtr shader_desc) {
ColorContext color_ctx;
if (!GetCustomColorContext(color_processor, &color_ctx, shader_desc)) {
return;
}
foreach (const ColorContext::LUT& l, color_ctx.lut3d_textures) {
job->InsertValue(l.name, NodeValue(NodeValue::kTexture, QVariant::fromValue(l.texture)));
job->SetInterpolation(l.name, l.interpolation);
}
foreach (const ColorContext::LUT& l, color_ctx.lut1d_textures) {
job->InsertValue(l.name, NodeValue(NodeValue::kTexture, QVariant::fromValue(l.texture)));
job->SetInterpolation(l.name, l.interpolation);
}
}
TexturePtr Renderer::InterlaceTexture(TexturePtr top, TexturePtr bottom, const VideoParams &params)
{
color_cache_mutex_.lock();
@@ -120,96 +103,6 @@ TexturePtr Renderer::CreateTextureFromNativeHandle(const QVariant &v, const Vide
return std::make_shared<Texture>(this, v, params, type);
}
bool Renderer::GetCustomColorContext(ColorProcessorPtr color_processor, Renderer::ColorContext* ctx,
OCIO::GpuShaderDescRcPtr shader_desc) {
QMutexLocker locker(&color_cache_mutex_);
ColorContext& color_ctx = *ctx;
if (color_cache_.contains(color_processor->id())) {
color_ctx = color_cache_.value(color_processor->id());
return true;
} else {
if (SetupColorContextTextures(color_ctx, shader_desc, color_processor)) {
return true;
} else {
qCritical() << "Failed to allocate OCIO shader textures";
return false;
}
}
}
bool Renderer::SetupColorContextTextures(ColorContext& color_ctx, OCIO::ConstGpuShaderDescRcPtr shader_desc,
ColorProcessorPtr color_processor)
{
color_ctx.lut3d_textures.resize(shader_desc->getNum3DTextures());
for (unsigned int i = 0; i < shader_desc->getNum3DTextures(); i++) {
const char* tex_name = nullptr;
const char* sampler_name = nullptr;
unsigned int edge_len = 0;
OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR;
shader_desc->get3DTexture(i, tex_name, sampler_name, edge_len, interpolation);
if (!tex_name || !*tex_name || !sampler_name || !*sampler_name || !edge_len) {
qCritical() << "3D LUT texture data is corrupted";
return false;
}
const float* values = nullptr;
shader_desc->get3DTextureValues(i, values);
if (!values) {
qCritical() << "3D LUT texture values are missing";
return false;
}
// Allocate 3D LUT
color_ctx.lut3d_textures[i].texture = CreateTexture(
VideoParams(edge_len, edge_len, edge_len, VideoParams::kFormatFloat32, VideoParams::kRGBChannelCount),
Texture::k3D, values);
color_ctx.lut3d_textures[i].name = sampler_name;
color_ctx.lut3d_textures[i].interpolation =
(interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
}
color_ctx.lut1d_textures.resize(shader_desc->getNumTextures());
for (unsigned int i = 0; i < shader_desc->getNumTextures(); i++) {
const char* tex_name = nullptr;
const char* sampler_name = nullptr;
unsigned int width = 0, height = 0;
OCIO::GpuShaderDesc::TextureType channel = OCIO::GpuShaderDesc::TEXTURE_RGB_CHANNEL;
OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR;
shader_desc->getTexture(i, tex_name, sampler_name, width, height, channel, interpolation);
if (!tex_name || !*tex_name || !sampler_name || !*sampler_name || !width) {
qCritical() << "1D LUT texture data is corrupted";
return false;
}
const float* values = nullptr;
shader_desc->getTextureValues(i, values);
if (!values) {
qCritical() << "1D LUT texture values are missing";
return false;
}
// Allocate 1D LUT
color_ctx.lut1d_textures[i].texture = CreateTexture(
VideoParams(width, height, VideoParams::kFormatFloat32,
(channel == OCIO::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? 1 : VideoParams::kRGBChannelCount),
Texture::k2D, values);
color_ctx.lut1d_textures[i].name = sampler_name;
color_ctx.lut1d_textures[i].interpolation =
(interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
}
color_cache_.insert(color_processor->id(), color_ctx);
return true;
}
bool Renderer::GetColorContext(ColorProcessorPtr color_processor, Renderer::ColorContext *ctx)
{
QMutexLocker locker(&color_cache_mutex_);
@@ -244,12 +137,71 @@ bool Renderer::GetColorContext(ColorProcessorPtr color_processor, Renderer::Colo
return false;
}
if (SetupColorContextTextures(color_ctx, shader_desc, color_processor)) {
return true;
} else {
qCritical() << "Failed to allocate OCIO shader textures";
return false;
color_ctx.lut3d_textures.resize(shader_desc->getNum3DTextures());
for (unsigned int i=0; i<shader_desc->getNum3DTextures(); i++) {
const char* tex_name = nullptr;
const char* sampler_name = nullptr;
unsigned int edge_len = 0;
OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR;
shader_desc->get3DTexture(i, tex_name, sampler_name, edge_len, interpolation);
if (!tex_name || !*tex_name
|| !sampler_name || !*sampler_name
|| !edge_len) {
qCritical() << "3D LUT texture data is corrupted";
return false;
}
const float* values = nullptr;
shader_desc->get3DTextureValues(i, values);
if (!values) {
qCritical() << "3D LUT texture values are missing";
return false;
}
// Allocate 3D LUT
color_ctx.lut3d_textures[i].texture = CreateTexture(VideoParams(edge_len, edge_len, edge_len, VideoParams::kFormatFloat32, VideoParams::kRGBChannelCount),
Texture::k3D, values);
color_ctx.lut3d_textures[i].name = sampler_name;
color_ctx.lut3d_textures[i].interpolation = (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
}
color_ctx.lut1d_textures.resize(shader_desc->getNumTextures());
for (unsigned int i=0; i<shader_desc->getNumTextures(); i++) {
const char* tex_name = nullptr;
const char* sampler_name = nullptr;
unsigned int width = 0, height = 0;
OCIO::GpuShaderDesc::TextureType channel = OCIO::GpuShaderDesc::TEXTURE_RGB_CHANNEL;
OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR;
shader_desc->getTexture(i, tex_name, sampler_name, width, height, channel, interpolation);
if (!tex_name || !*tex_name
|| !sampler_name || !*sampler_name
|| !width) {
qCritical() << "1D LUT texture data is corrupted";
return false;
}
const float* values = nullptr;
shader_desc->getTextureValues(i, values);
if (!values) {
qCritical() << "1D LUT texture values are missing";
return false;
}
// Allocate 1D LUT
color_ctx.lut1d_textures[i].texture = CreateTexture(VideoParams(width, height, VideoParams::kFormatFloat32, (channel == OCIO::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? 1 : VideoParams::kRGBChannelCount),
Texture::k2D,
values);
color_ctx.lut1d_textures[i].name = sampler_name;
color_ctx.lut1d_textures[i].interpolation = (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
}
color_cache_.insert(color_processor->id(), color_ctx);
return true;
}
}
-8
View File
@@ -63,8 +63,6 @@ public:
Blit(shader, job, nullptr, params, clear_destination);
}
void ShaderJobInsertTextures(ColorProcessorPtr color_processor, ShaderJob* job, OCIO::GpuShaderDescRcPtr shader_desc);
enum AlphaAssociated {
kAlphaNone,
kAlphaUnassociated,
@@ -130,12 +128,6 @@ private:
bool GetColorContext(ColorProcessorPtr color_processor, ColorContext* ctx);
bool GetCustomColorContext(ColorProcessorPtr color_processor, ColorContext* ctx,
OCIO::GpuShaderDescRcPtr shader_desc);
bool SetupColorContextTextures(ColorContext& color_ctx, OCIO::ConstGpuShaderDescRcPtr shader_desc,
ColorProcessorPtr color_processor);
void BlitColorManagedInternal(ColorProcessorPtr color_processor, TexturePtr source,
AlphaAssociated source_alpha_association,
Texture* destination, VideoParams params, bool clear_destination,
+15 -4
View File
@@ -496,7 +496,7 @@ SampleBufferPtr RenderProcessor::ProcessAudioFootage(const FootageJob &stream, c
return super::ProcessAudioFootage(stream, input_time);
}
TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &range, ShaderJob &job)
TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
{
Q_UNUSED(range)
@@ -507,9 +507,10 @@ TexturePtr RenderProcessor::ProcessShader(const Node *node, const TimeRange &ran
QVariant shader = shader_cache_->value(full_shader_id);
if (shader.isNull()) {
if (job.UseOCIO()) {
render_ctx_->ShaderJobInsertTextures(job.ColorProcessor(), &job, job.ShaderDesc());
}
// FIXME: Reimplement as color job
//if (job.UseOCIO()) {
// render_ctx_->ShaderJobInsertTextures(job.ColorProcessor(), &job, job.ShaderDesc());
//}
// Since we have shader code, compile it now
shader = render_ctx_->CreateNativeShader(node->GetShaderCode(job.GetShaderID()));
@@ -565,6 +566,16 @@ SampleBufferPtr RenderProcessor::ProcessSamples(const Node *node, const TimeRang
return output_buffer;
}
TexturePtr RenderProcessor::ProcessColorTransform(const Node *node, const ColorTransformJob &job)
{
TexturePtr src = job.GetInputTexture();
TexturePtr dest = render_ctx_->CreateTexture(src->params());
render_ctx_->BlitColorManaged(job.GetColorProcessor(), src, Renderer::kAlphaAssociated, dest.get());
return dest;
}
TexturePtr RenderProcessor::ProcessFrameGeneration(const Node *node, const GenerateJob &job)
{
FramePtr frame = Frame::Create();
+3 -1
View File
@@ -48,10 +48,12 @@ protected:
virtual SampleBufferPtr ProcessAudioFootage(const FootageJob &stream, const TimeRange &input_time) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, ShaderJob& job) override;
virtual TexturePtr ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
virtual SampleBufferPtr ProcessSamples(const Node *node, const TimeRange &range, const SampleJob &job) override;
virtual TexturePtr ProcessColorTransform(const Node *node, const ColorTransformJob& job) override;
virtual TexturePtr ProcessFrameGeneration(const Node *node, const GenerateJob& job) override;
virtual bool CanCacheFrames() override;
-13
View File
@@ -1,13 +0,0 @@
uniform sampler2D tex_in;
varying vec2 ove_texcoord;
// Program will replace this with OCIO's auto-generated shader code
%1
void main() {
vec4 col = texture2D(tex_in, ove_texcoord);
col = DisplayTransform(col);
gl_FragColor = col;
}
-13
View File
@@ -1,13 +0,0 @@
uniform sampler2D tex_in;
varying vec2 ove_texcoord;
// Program will replace this with OCIO's auto-generated shader code
%1
void main() {
vec4 col = texture2D(tex_in, ove_texcoord);
col = OCIOGradingTransform(col);
gl_FragColor = col;
}
+13
View File
@@ -0,0 +1,13 @@
uniform sampler2D tex_in;
in vec2 ove_texcoord;
out vec4 frag_color;
%1
void main() {
vec4 col = texture2D(tex_in, ove_texcoord);
col = %2(col);
frag_color = col;
}
@@ -90,6 +90,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
case NodeValue::kShaderJob:
case NodeValue::kSampleJob:
case NodeValue::kGenerateJob:
case NodeValue::kColorTransformJob:
case NodeValue::kVideoParams:
case NodeValue::kAudioParams:
case NodeValue::kDataTypeCount:
@@ -244,6 +245,7 @@ void NodeParamViewWidgetBridge::WidgetCallback()
case NodeValue::kShaderJob:
case NodeValue::kSampleJob:
case NodeValue::kGenerateJob:
case NodeValue::kColorTransformJob:
case NodeValue::kVideoParams:
case NodeValue::kAudioParams:
case NodeValue::kDataTypeCount:
@@ -421,6 +423,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
case NodeValue::kShaderJob:
case NodeValue::kSampleJob:
case NodeValue::kGenerateJob:
case NodeValue::kColorTransformJob:
case NodeValue::kVideoParams:
case NodeValue::kAudioParams:
case NodeValue::kDataTypeCount: