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
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
*/