change: change code style to Linux style except indent.
This commit is contained in:
@@ -28,239 +28,246 @@
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
#define super Node
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::default_config_ = nullptr;
|
||||
|
||||
ColorManager::ColorManager(Project *project) :
|
||||
QObject(project),
|
||||
config_(nullptr)
|
||||
ColorManager::ColorManager(Project *project)
|
||||
: QObject(project)
|
||||
, config_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorManager::Init()
|
||||
{
|
||||
// Set config to our built-in default
|
||||
config_ = GetDefaultConfig();
|
||||
SetDefaultInputColorSpace(config_->getCanonicalName(OCIO::ROLE_DEFAULT));
|
||||
project()->SetColorReferenceSpace(OCIO::ROLE_SCENE_LINEAR);
|
||||
// Set config to our built-in default
|
||||
config_ = GetDefaultConfig();
|
||||
SetDefaultInputColorSpace(config_->getCanonicalName(OCIO::ROLE_DEFAULT));
|
||||
project()->SetColorReferenceSpace(OCIO::ROLE_SCENE_LINEAR);
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
{
|
||||
return config_;
|
||||
return config_;
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
OCIO::ConstConfigRcPtr
|
||||
ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
{
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
|
||||
QString ColorManager::GetConfigFilename() const
|
||||
{
|
||||
return project()->GetColorConfigFilename();
|
||||
return project()->GetColorConfigFilename();
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
{
|
||||
return default_config_;
|
||||
return default_config_;
|
||||
}
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
{
|
||||
if (!qEnvironmentVariableIsEmpty("OCIO")) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
if (!qEnvironmentVariableIsEmpty("OCIO")) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
|
||||
return;
|
||||
} catch (OCIO::Exception& e) {
|
||||
qWarning() << "Failed to load config from OCIO environment variable config:" << e.what();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} catch (OCIO::Exception &e) {
|
||||
qWarning()
|
||||
<< "Failed to load config from OCIO environment variable config:"
|
||||
<< e.what();
|
||||
}
|
||||
}
|
||||
|
||||
// Extract OCIO config - kind of hacky, but it'll work
|
||||
QString dir = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).filePath(QStringLiteral("ocioconf"));
|
||||
// Extract OCIO config - kind of hacky, but it'll work
|
||||
QString dir =
|
||||
QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.filePath(QStringLiteral("ocioconf"));
|
||||
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
|
||||
dir,
|
||||
true);
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"), dir, true);
|
||||
|
||||
qDebug() << "Extracting default OCIO config to" << dir;
|
||||
qDebug() << "Extracting default OCIO config to" << dir;
|
||||
|
||||
default_config_ = CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
default_config_ =
|
||||
CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
}
|
||||
|
||||
void ColorManager::SetConfigFilename(const QString &filename)
|
||||
{
|
||||
project()->SetColorConfigFilename(filename);
|
||||
project()->SetColorConfigFilename(filename);
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableDisplays()
|
||||
{
|
||||
QStringList displays;
|
||||
QStringList displays;
|
||||
|
||||
int number_of_displays = config_->getNumDisplays();
|
||||
int number_of_displays = config_->getNumDisplays();
|
||||
|
||||
for (int i=0;i<number_of_displays;i++) {
|
||||
displays.append(config_->getDisplay(i));
|
||||
}
|
||||
for (int i = 0; i < number_of_displays; i++) {
|
||||
displays.append(config_->getDisplay(i));
|
||||
}
|
||||
|
||||
return displays;
|
||||
return displays;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultDisplay()
|
||||
{
|
||||
return config_->getDefaultDisplay();
|
||||
return config_->getDefaultDisplay();
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableViews(QString display)
|
||||
{
|
||||
QStringList views;
|
||||
QStringList views;
|
||||
|
||||
int number_of_views = config_->getNumViews(display.toUtf8());
|
||||
int number_of_views = config_->getNumViews(display.toUtf8());
|
||||
|
||||
for (int i=0;i<number_of_views;i++) {
|
||||
views.append(config_->getView(display.toUtf8(), i));
|
||||
}
|
||||
for (int i = 0; i < number_of_views; i++) {
|
||||
views.append(config_->getView(display.toUtf8(), i));
|
||||
}
|
||||
|
||||
return views;
|
||||
return views;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultView(const QString &display)
|
||||
{
|
||||
return config_->getDefaultView(display.toUtf8());
|
||||
return config_->getDefaultView(display.toUtf8());
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableLooks()
|
||||
{
|
||||
QStringList looks;
|
||||
QStringList looks;
|
||||
|
||||
int number_of_looks = config_->getNumLooks();
|
||||
int number_of_looks = config_->getNumLooks();
|
||||
|
||||
for (int i=0;i<number_of_looks;i++) {
|
||||
looks.append(config_->getLookNameByIndex(i));
|
||||
}
|
||||
for (int i = 0; i < number_of_looks; i++) {
|
||||
looks.append(config_->getLookNameByIndex(i));
|
||||
}
|
||||
|
||||
return looks;
|
||||
return looks;
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableColorspaces() const
|
||||
{
|
||||
return ListAvailableColorspaces(config_);
|
||||
return ListAvailableColorspaces(config_);
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultInputColorSpace() const
|
||||
{
|
||||
return project()->GetDefaultInputColorSpace();
|
||||
return project()->GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
void ColorManager::SetDefaultInputColorSpace(const QString &s)
|
||||
{
|
||||
project()->SetDefaultInputColorSpace(s);
|
||||
project()->SetDefaultInputColorSpace(s);
|
||||
}
|
||||
|
||||
QString ColorManager::GetReferenceColorSpace() const
|
||||
{
|
||||
return project()->GetColorReferenceSpace();
|
||||
return project()->GetColorReferenceSpace();
|
||||
}
|
||||
|
||||
QString ColorManager::GetCompliantColorSpace(const QString &s)
|
||||
{
|
||||
if (ListAvailableColorspaces().contains(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return GetDefaultInputColorSpace();
|
||||
}
|
||||
if (ListAvailableColorspaces().contains(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return GetDefaultInputColorSpace();
|
||||
}
|
||||
}
|
||||
|
||||
ColorTransform ColorManager::GetCompliantColorSpace(const ColorTransform &transform, bool force_display)
|
||||
ColorTransform
|
||||
ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
bool force_display)
|
||||
{
|
||||
if (transform.is_display() || force_display) {
|
||||
// Get display information
|
||||
QString display = transform.display();
|
||||
QString view = transform.view();
|
||||
QString look = transform.look();
|
||||
if (transform.is_display() || force_display) {
|
||||
// Get display information
|
||||
QString display = transform.display();
|
||||
QString view = transform.view();
|
||||
QString look = transform.look();
|
||||
|
||||
// Check if display still exists in config
|
||||
if (!ListAvailableDisplays().contains(display)) {
|
||||
display = GetDefaultDisplay();
|
||||
}
|
||||
// Check if display still exists in config
|
||||
if (!ListAvailableDisplays().contains(display)) {
|
||||
display = GetDefaultDisplay();
|
||||
}
|
||||
|
||||
// Check if view still exists in display
|
||||
if (!ListAvailableViews(display).contains(view)) {
|
||||
view = GetDefaultView(display);
|
||||
}
|
||||
// Check if view still exists in display
|
||||
if (!ListAvailableViews(display).contains(view)) {
|
||||
view = GetDefaultView(display);
|
||||
}
|
||||
|
||||
// Check if looks still exists
|
||||
if (!ListAvailableLooks().contains(look)) {
|
||||
look.clear();
|
||||
}
|
||||
// Check if looks still exists
|
||||
if (!ListAvailableLooks().contains(look)) {
|
||||
look.clear();
|
||||
}
|
||||
|
||||
return ColorTransform(display, view, look);
|
||||
return ColorTransform(display, view, look);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
QString output = transform.output();
|
||||
|
||||
QString output = transform.output();
|
||||
if (!ListAvailableColorspaces().contains(output)) {
|
||||
output = GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
if (!ListAvailableColorspaces().contains(output)) {
|
||||
output = GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
return ColorTransform(output);
|
||||
|
||||
}
|
||||
return ColorTransform(output);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
QStringList
|
||||
ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
{
|
||||
QStringList spaces;
|
||||
QStringList spaces;
|
||||
|
||||
if (config) {
|
||||
int number_of_colorspaces = config->getNumColorSpaces();
|
||||
if (config) {
|
||||
int number_of_colorspaces = config->getNumColorSpaces();
|
||||
|
||||
for (int i=0;i<number_of_colorspaces;i++) {
|
||||
spaces.append(config->getColorSpaceNameByIndex(i));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < number_of_colorspaces; i++) {
|
||||
spaces.append(config->getColorSpaceNameByIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
return spaces;
|
||||
return spaces;
|
||||
}
|
||||
|
||||
void ColorManager::GetDefaultLumaCoefs(double *rgb) const
|
||||
{
|
||||
config_->getDefaultLumaCoefs(rgb);
|
||||
config_->getDefaultLumaCoefs(rgb);
|
||||
}
|
||||
|
||||
Project *ColorManager::project() const
|
||||
{
|
||||
return static_cast<Project*>(parent());
|
||||
return static_cast<Project *>(parent());
|
||||
}
|
||||
|
||||
void ColorManager::UpdateConfigFromFilename()
|
||||
{
|
||||
try {
|
||||
QString config_filename = GetConfigFilename();
|
||||
QString old_default_cs = GetDefaultInputColorSpace();
|
||||
try {
|
||||
QString config_filename = GetConfigFilename();
|
||||
QString old_default_cs = GetDefaultInputColorSpace();
|
||||
|
||||
config_ = OCIO::Config::CreateFromFile(config_filename.toUtf8());
|
||||
config_ = OCIO::Config::CreateFromFile(config_filename.toUtf8());
|
||||
|
||||
// Set new default colorspace appropriately
|
||||
QString new_default = old_default_cs;
|
||||
QStringList available_cs = ListAvailableColorspaces();
|
||||
for (int i=0; i<available_cs.size(); i++) {
|
||||
const QString &c = available_cs.at(i);
|
||||
if (c.compare(old_default_cs, Qt::CaseInsensitive)) {
|
||||
new_default = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetDefaultInputColorSpace(new_default);
|
||||
// Set new default colorspace appropriately
|
||||
QString new_default = old_default_cs;
|
||||
QStringList available_cs = ListAvailableColorspaces();
|
||||
for (int i = 0; i < available_cs.size(); i++) {
|
||||
const QString &c = available_cs.at(i);
|
||||
if (c.compare(old_default_cs, Qt::CaseInsensitive)) {
|
||||
new_default = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetDefaultInputColorSpace(new_default);
|
||||
|
||||
emit ConfigChanged(config_filename);
|
||||
} catch (OCIO::Exception&) {}
|
||||
emit ConfigChanged(config_filename);
|
||||
} catch (OCIO::Exception &) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,70 +28,70 @@
|
||||
#include "node/node.h"
|
||||
#include "render/colorprocessor.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ColorManager : public QObject
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ColorManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorManager(Project *project);
|
||||
ColorManager(Project *project);
|
||||
|
||||
void Init();
|
||||
void Init();
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString& filename);
|
||||
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString &filename);
|
||||
|
||||
QString GetConfigFilename() const;
|
||||
QString GetConfigFilename() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
|
||||
static void SetUpDefaultConfig();
|
||||
static void SetUpDefaultConfig();
|
||||
|
||||
void SetConfigFilename(const QString& filename);
|
||||
void SetConfigFilename(const QString &filename);
|
||||
|
||||
QStringList ListAvailableDisplays();
|
||||
QStringList ListAvailableDisplays();
|
||||
|
||||
QString GetDefaultDisplay();
|
||||
QString GetDefaultDisplay();
|
||||
|
||||
QStringList ListAvailableViews(QString display);
|
||||
QStringList ListAvailableViews(QString display);
|
||||
|
||||
QString GetDefaultView(const QString& display);
|
||||
QString GetDefaultView(const QString &display);
|
||||
|
||||
QStringList ListAvailableLooks();
|
||||
QStringList ListAvailableLooks();
|
||||
|
||||
QStringList ListAvailableColorspaces() const;
|
||||
QStringList ListAvailableColorspaces() const;
|
||||
|
||||
QString GetDefaultInputColorSpace() const;
|
||||
QString GetDefaultInputColorSpace() const;
|
||||
|
||||
void SetDefaultInputColorSpace(const QString& s);
|
||||
void SetDefaultInputColorSpace(const QString &s);
|
||||
|
||||
QString GetReferenceColorSpace() const;
|
||||
QString GetReferenceColorSpace() const;
|
||||
|
||||
QString GetCompliantColorSpace(const QString& s);
|
||||
QString GetCompliantColorSpace(const QString &s);
|
||||
|
||||
ColorTransform GetCompliantColorSpace(const ColorTransform& transform, bool force_display = false);
|
||||
ColorTransform GetCompliantColorSpace(const ColorTransform &transform,
|
||||
bool force_display = false);
|
||||
|
||||
static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
|
||||
void GetDefaultLumaCoefs(double *rgb) const;
|
||||
void GetDefaultLumaCoefs(double *rgb) const;
|
||||
|
||||
Project *project() const;
|
||||
Project *project() const;
|
||||
|
||||
void UpdateConfigFromFilename();
|
||||
void UpdateConfigFromFilename();
|
||||
|
||||
signals:
|
||||
void ConfigChanged(const QString &s);
|
||||
void ConfigChanged(const QString &s);
|
||||
|
||||
void ReferenceSpaceChanged(const QString &s);
|
||||
void ReferenceSpaceChanged(const QString &s);
|
||||
|
||||
void DefaultInputChanged(const QString &s);
|
||||
void DefaultInputChanged(const QString &s);
|
||||
|
||||
private:
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
|
||||
static OCIO::ConstConfigRcPtr default_config_;
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
|
||||
static OCIO::ConstConfigRcPtr default_config_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString DisplayTransformNode::kDisplayInput = QStringLiteral("display_in");
|
||||
const QString DisplayTransformNode::kDisplayInput =
|
||||
QStringLiteral("display_in");
|
||||
const QString DisplayTransformNode::kViewInput = QStringLiteral("view_in");
|
||||
const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in");
|
||||
|
||||
@@ -32,113 +34,123 @@ const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in");
|
||||
|
||||
DisplayTransformNode::DisplayTransformNode()
|
||||
{
|
||||
AddInput(kDisplayInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
AddInput(kDisplayInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
|
||||
AddInput(kViewInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
AddInput(kViewInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Name() const
|
||||
{
|
||||
return tr("Display Transform");
|
||||
return tr("Display Transform");
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.displaytransform");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.displaytransform");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> DisplayTransformNode::Category() const
|
||||
{
|
||||
return {kCategoryColor};
|
||||
return { kCategoryColor };
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Description() const
|
||||
{
|
||||
return tr("Converts an image to or from a display color space.");
|
||||
return tr("Converts an image to or from a display color space.");
|
||||
}
|
||||
|
||||
void DisplayTransformNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kDisplayInput, tr("Display"));
|
||||
SetInputName(kViewInput, tr("View"));
|
||||
SetInputName(kDirectionInput, tr("Direction"));
|
||||
SetComboBoxStrings(kDirectionInput, {tr("Forward"), tr("Inverse")});
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kDisplayInput, tr("Display"));
|
||||
SetInputName(kViewInput, tr("View"));
|
||||
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 == kDisplayInput || input == kDirectionInput || input == kViewInput) {
|
||||
if (input == kDisplayInput) {
|
||||
UpdateViews();
|
||||
}
|
||||
GenerateProcessor();
|
||||
}
|
||||
Q_UNUSED(element);
|
||||
if (input == kDisplayInput || input == kDirectionInput ||
|
||||
input == kViewInput) {
|
||||
if (input == kDisplayInput) {
|
||||
UpdateViews();
|
||||
}
|
||||
GenerateProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetDisplay() const
|
||||
{
|
||||
if (manager()) {
|
||||
int index = GetStandardValue(kDisplayInput).toInt();
|
||||
if (index < manager()->ListAvailableDisplays().size()) {
|
||||
return manager()->ListAvailableDisplays().at(index);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
if (manager()) {
|
||||
int index = GetStandardValue(kDisplayInput).toInt();
|
||||
if (index < manager()->ListAvailableDisplays().size()) {
|
||||
return manager()->ListAvailableDisplays().at(index);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetView() const
|
||||
{
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
ColorProcessor::Direction DisplayTransformNode::GetDirection() const
|
||||
{
|
||||
return static_cast<ColorProcessor::Direction>(GetStandardValue(kDirectionInput).toInt());;
|
||||
return static_cast<ColorProcessor::Direction>(
|
||||
GetStandardValue(kDirectionInput).toInt());
|
||||
;
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateDisplays()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays());
|
||||
}
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays());
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateViews()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kViewInput, manager()->ListAvailableViews(GetDisplay()));
|
||||
}
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kViewInput,
|
||||
manager()->ListAvailableViews(GetDisplay()));
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::ConfigChanged()
|
||||
{
|
||||
UpdateDisplays();
|
||||
UpdateViews();
|
||||
GenerateProcessor();
|
||||
UpdateDisplays();
|
||||
UpdateViews();
|
||||
GenerateProcessor();
|
||||
}
|
||||
|
||||
void DisplayTransformNode::GenerateProcessor()
|
||||
{
|
||||
if (manager()) {
|
||||
ColorTransform transform(GetDisplay(), GetView(), QString());
|
||||
set_processor(ColorProcessor::Create(manager(), manager()->GetReferenceColorSpace(), transform, GetDirection()));
|
||||
}
|
||||
if (manager()) {
|
||||
ColorTransform transform(GetDisplay(), GetView(), QString());
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager(), manager()->GetReferenceColorSpace(), transform,
|
||||
GetDirection()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,42 +24,42 @@
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class DisplayTransformNode : public OCIOBaseNode
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DisplayTransformNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(DisplayTransformNode)
|
||||
class DisplayTransformNode : public OCIOBaseNode {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DisplayTransformNode();
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
NODE_DEFAULT_FUNCTIONS(DisplayTransformNode)
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input, int element) override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
QString GetDisplay() const;
|
||||
QString GetView() const;
|
||||
ColorProcessor::Direction GetDirection() const;
|
||||
virtual void Retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
|
||||
static const QString kDisplayInput;
|
||||
static const QString kViewInput;
|
||||
static const QString kDirectionInput;
|
||||
QString GetDisplay() const;
|
||||
QString GetView() const;
|
||||
ColorProcessor::Direction GetDirection() const;
|
||||
|
||||
static const QString kDisplayInput;
|
||||
static const QString kViewInput;
|
||||
static const QString kDirectionInput;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void ConfigChanged() override;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
void GenerateProcessor();
|
||||
|
||||
void UpdateDisplays();
|
||||
|
||||
void UpdateViews();
|
||||
void UpdateDisplays();
|
||||
|
||||
void UpdateViews();
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
@@ -23,48 +23,53 @@
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
#include "node/project.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOBaseNode::kTextureInput = QStringLiteral("tex_in");
|
||||
|
||||
OCIOBaseNode::OCIOBaseNode() :
|
||||
manager_(nullptr),
|
||||
processor_(nullptr)
|
||||
OCIOBaseNode::OCIOBaseNode()
|
||||
: manager_(nullptr)
|
||||
, processor_(nullptr)
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
SetEffectInput(kTextureInput);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
SetFlag(kVideoEffect);
|
||||
}
|
||||
|
||||
void OCIOBaseNode::AddedToGraphEvent(Project *p)
|
||||
{
|
||||
manager_ = p->color_manager();
|
||||
connect(manager_, &ColorManager::ConfigChanged, this, &OCIOBaseNode::ConfigChanged);
|
||||
ConfigChanged();
|
||||
manager_ = p->color_manager();
|
||||
connect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
ConfigChanged();
|
||||
}
|
||||
|
||||
void OCIOBaseNode::RemovedFromGraphEvent(Project *p)
|
||||
{
|
||||
if (manager_) {
|
||||
disconnect(manager_, &ColorManager::ConfigChanged, this, &OCIOBaseNode::ConfigChanged);
|
||||
manager_ = nullptr;
|
||||
}
|
||||
if (manager_) {
|
||||
disconnect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
manager_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
auto tex_met = value[kTextureInput];
|
||||
TexturePtr t = tex_met.toTexture();
|
||||
if (t && processor_) {
|
||||
ColorTransformJob job;
|
||||
auto tex_met = value[kTextureInput];
|
||||
TexturePtr t = tex_met.toTexture();
|
||||
if (t && processor_) {
|
||||
ColorTransformJob job;
|
||||
|
||||
job.SetColorProcessor(processor_);
|
||||
job.SetInputTexture(tex_met);
|
||||
job.SetColorProcessor(processor_);
|
||||
job.SetInputTexture(tex_met);
|
||||
|
||||
table->Push(NodeValue::kTexture, t->toJob(job), this);
|
||||
}
|
||||
table->Push(NodeValue::kTexture, t->toJob(job), this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,35 +24,44 @@
|
||||
#include "node/node.h"
|
||||
#include "render/job/colortransformjob.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class OCIOBaseNode : public Node
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class OCIOBaseNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OCIOBaseNode();
|
||||
OCIOBaseNode();
|
||||
|
||||
virtual void AddedToGraphEvent(Project *p) override;
|
||||
virtual void RemovedFromGraphEvent(Project *p) override;
|
||||
virtual void AddedToGraphEvent(Project *p) override;
|
||||
virtual void RemovedFromGraphEvent(Project *p) override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kTextureInput;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() = 0;
|
||||
virtual void ConfigChanged() = 0;
|
||||
|
||||
protected:
|
||||
ColorManager *manager() const { return manager_; }
|
||||
ColorManager *manager() const
|
||||
{
|
||||
return manager_;
|
||||
}
|
||||
|
||||
ColorProcessorPtr processor() const { return processor_; }
|
||||
void set_processor(ColorProcessorPtr p) { processor_ = p; }
|
||||
ColorProcessorPtr processor() const
|
||||
{
|
||||
return processor_;
|
||||
}
|
||||
void set_processor(ColorProcessorPtr p)
|
||||
{
|
||||
processor_ = p;
|
||||
}
|
||||
|
||||
private:
|
||||
ColorManager *manager_;
|
||||
|
||||
ColorProcessorPtr processor_;
|
||||
ColorManager *manager_;
|
||||
|
||||
ColorProcessorPtr processor_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,192 +27,236 @@
|
||||
#include "render/colorprocessor.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOGradingTransformLinearNode::kContrastInput = QStringLiteral("ocio_grading_primary_contrast");
|
||||
const QString OCIOGradingTransformLinearNode::kOffsetInput = QStringLiteral("ocio_grading_primary_offset");
|
||||
const QString OCIOGradingTransformLinearNode::kExposureInput = QStringLiteral("ocio_grading_primary_exposure");
|
||||
const QString OCIOGradingTransformLinearNode::kSaturationInput = QStringLiteral("ocio_grading_primary_saturation");
|
||||
const QString OCIOGradingTransformLinearNode::kPivotInput = QStringLiteral("ocio_grading_primary_pivot");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackEnableInput = QStringLiteral("clamp_black_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackInput = QStringLiteral("ocio_grading_primary_clampBlack");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteEnableInput = QStringLiteral("clamp_white_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteInput = QStringLiteral("ocio_grading_primary_clampWhite");
|
||||
const QString OCIOGradingTransformLinearNode::kContrastInput =
|
||||
QStringLiteral("ocio_grading_primary_contrast");
|
||||
const QString OCIOGradingTransformLinearNode::kOffsetInput =
|
||||
QStringLiteral("ocio_grading_primary_offset");
|
||||
const QString OCIOGradingTransformLinearNode::kExposureInput =
|
||||
QStringLiteral("ocio_grading_primary_exposure");
|
||||
const QString OCIOGradingTransformLinearNode::kSaturationInput =
|
||||
QStringLiteral("ocio_grading_primary_saturation");
|
||||
const QString OCIOGradingTransformLinearNode::kPivotInput =
|
||||
QStringLiteral("ocio_grading_primary_pivot");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackEnableInput =
|
||||
QStringLiteral("clamp_black_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackInput =
|
||||
QStringLiteral("ocio_grading_primary_clampBlack");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteEnableInput =
|
||||
QStringLiteral("clamp_white_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteInput =
|
||||
QStringLiteral("ocio_grading_primary_clampWhite");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
OCIOGradingTransformLinearNode::OCIOGradingTransformLinearNode()
|
||||
{
|
||||
AddInput(kContrastInput, NodeValue::kVec4, QVector4D{1.0, 1.0, 1.0, 1.0});
|
||||
// Minimum based on OCIO::GradingPrimary::validate
|
||||
SetInputProperty(kContrastInput, QStringLiteral("min"), QVector4D{0.01f, 0.01f, 0.01f, 0.01f});
|
||||
SetInputProperty(kContrastInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kContrastInput);
|
||||
AddInput(kContrastInput, NodeValue::kVec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 });
|
||||
// Minimum based on OCIO::GradingPrimary::validate
|
||||
SetInputProperty(kContrastInput, QStringLiteral("min"),
|
||||
QVector4D{ 0.01f, 0.01f, 0.01f, 0.01f });
|
||||
SetInputProperty(kContrastInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kContrastInput);
|
||||
|
||||
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
|
||||
SetInputProperty(kOffsetInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kOffsetInput);
|
||||
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kOffsetInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kOffsetInput);
|
||||
|
||||
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{0.0, 0.0, 0.0, 0.0});
|
||||
SetInputProperty(kExposureInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kExposureInput);
|
||||
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kExposureInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kExposureInput);
|
||||
|
||||
AddInput(kSaturationInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0);
|
||||
AddInput(kSaturationInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kPivotInput, NodeValue::kFloat, 0.18); // Default listed in OCIO::GradingPrimary
|
||||
SetInputProperty(kPivotInput, QStringLiteral("base"), 0.01);
|
||||
AddInput(kPivotInput, NodeValue::kFloat,
|
||||
0.18); // Default listed in OCIO::GradingPrimary
|
||||
SetInputProperty(kPivotInput, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampBlackEnableInput, NodeValue::kBoolean, false);
|
||||
AddInput(kClampBlackEnableInput, NodeValue::kBoolean, false);
|
||||
|
||||
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"), GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("base"), 0.01);
|
||||
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampWhiteEnableInput, NodeValue::kBoolean, false);
|
||||
AddInput(kClampWhiteEnableInput, NodeValue::kBoolean, false);
|
||||
|
||||
AddInput(kClampWhiteInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"), GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("base"), 0.01);
|
||||
AddInput(kClampWhiteInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("base"), 0.01);
|
||||
|
||||
// FIXME: Temporarily disabled. This will break if "clamp black" is keyframed or connected to
|
||||
// something and there's currently no solution to remedy that. If there is in the future,
|
||||
// we can look into re-enabling this.
|
||||
//SetInputProperty(kClampWhiteInput, QStringLiteral("min"), GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
// FIXME: Temporarily disabled. This will break if "clamp black" is keyframed or connected to
|
||||
// something and there's currently no solution to remedy that. If there is in the future,
|
||||
// we can look into re-enabling this.
|
||||
//SetInputProperty(kClampWhiteInput, QStringLiteral("min"), GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Name() const
|
||||
{
|
||||
return tr("OCIO Color Grading (Linear)");
|
||||
return tr("OCIO Color Grading (Linear)");
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ociogradingtransformlinear");
|
||||
return QStringLiteral(
|
||||
"org.olivevideoeditor.Olive.ociogradingtransformlinear");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> OCIOGradingTransformLinearNode::Category() const
|
||||
{
|
||||
return {kCategoryColor};
|
||||
return { kCategoryColor };
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Description() const
|
||||
{
|
||||
return tr("Simple linear color grading using OpenColorIO.");
|
||||
return tr("Simple linear color grading using OpenColorIO.");
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kContrastInput, tr("Contrast"));
|
||||
SetInputName(kOffsetInput, tr("Offset"));
|
||||
SetInputName(kExposureInput, tr("Exposure"));
|
||||
SetInputProperty(kExposureInput, QStringLiteral("tooltip"), tr("Exposure increments in stops."));
|
||||
SetInputName(kSaturationInput, tr("Saturation"));
|
||||
SetInputName(kPivotInput, tr("Pivot"));
|
||||
SetInputName(kClampBlackEnableInput, tr("Enable Black Clamp"));
|
||||
SetInputName(kClampBlackInput, tr("Black Clamp"));
|
||||
SetInputName(kClampWhiteEnableInput, tr("Enable White Clamp"));
|
||||
SetInputName(kClampWhiteInput, tr("White Clamp"));
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kContrastInput, tr("Contrast"));
|
||||
SetInputName(kOffsetInput, tr("Offset"));
|
||||
SetInputName(kExposureInput, tr("Exposure"));
|
||||
SetInputProperty(kExposureInput, QStringLiteral("tooltip"),
|
||||
tr("Exposure increments in stops."));
|
||||
SetInputName(kSaturationInput, tr("Saturation"));
|
||||
SetInputName(kPivotInput, tr("Pivot"));
|
||||
SetInputName(kClampBlackEnableInput, tr("Enable Black Clamp"));
|
||||
SetInputName(kClampBlackInput, tr("Black Clamp"));
|
||||
SetInputName(kClampWhiteEnableInput, tr("Enable White Clamp"));
|
||||
SetInputName(kClampWhiteInput, tr("White Clamp"));
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::InputValueChangedEvent(const QString &input, int element)
|
||||
void OCIOGradingTransformLinearNode::InputValueChangedEvent(
|
||||
const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element);
|
||||
Q_UNUSED(element);
|
||||
|
||||
if (input == kClampWhiteEnableInput) {
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"), GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
} else if (input == kClampBlackEnableInput) {
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"), GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
} else if (input == kClampBlackInput) {
|
||||
// Ensure the white clamp is always greater than the black clamp as per OCIO::GradingPrimary::validate
|
||||
// FIXME: Temporarily disabled. This will break if "clamp black" is keyframed or connected to
|
||||
// something and there's currently no solution to remedy that. If there is in the future,
|
||||
// we can look into re-enabling this.
|
||||
//SetInputProperty(kClampWhiteInput, QStringLiteral("min"), GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
}
|
||||
if (input == kClampWhiteEnableInput) {
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
} else if (input == kClampBlackEnableInput) {
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
} else if (input == kClampBlackInput) {
|
||||
// Ensure the white clamp is always greater than the black clamp as per OCIO::GradingPrimary::validate
|
||||
// FIXME: Temporarily disabled. This will break if "clamp black" is keyframed or connected to
|
||||
// something and there's currently no solution to remedy that. If there is in the future,
|
||||
// we can look into re-enabling this.
|
||||
//SetInputProperty(kClampWhiteInput, QStringLiteral("min"), GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
}
|
||||
|
||||
GenerateProcessor();
|
||||
GenerateProcessor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::GenerateProcessor()
|
||||
{
|
||||
if (manager()) {
|
||||
OCIO::GradingPrimaryTransformRcPtr gp = OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
|
||||
gp->makeDynamic();
|
||||
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
if (manager()) {
|
||||
OCIO::GradingPrimaryTransformRcPtr gp =
|
||||
OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
|
||||
gp->makeDynamic();
|
||||
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
|
||||
try {
|
||||
set_processor(ColorProcessor::Create(manager()->GetConfig()->getProcessor(gp)));
|
||||
} catch (const OCIO::Exception &e) {
|
||||
std::cerr << std::endl << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
try {
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager()->GetConfig()->getProcessor(gp)));
|
||||
} catch (const OCIO::Exception &e) {
|
||||
std::cerr << std::endl << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (processor()) {
|
||||
ColorTransformJob job(value);
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (processor()) {
|
||||
ColorTransformJob job(value);
|
||||
|
||||
job.SetColorProcessor(processor());
|
||||
job.SetInputTexture(value[kTextureInput]);
|
||||
job.SetColorProcessor(processor());
|
||||
job.SetInputTexture(value[kTextureInput]);
|
||||
|
||||
const int MASTER_CHANNEL = 0;
|
||||
const int RED_CHANNEL = 1;
|
||||
const int GREEN_CHANNEL = 2;
|
||||
const int BLUE_CHANNEL = 3;
|
||||
const int MASTER_CHANNEL = 0;
|
||||
const int RED_CHANNEL = 1;
|
||||
const int GREEN_CHANNEL = 2;
|
||||
const int BLUE_CHANNEL = 3;
|
||||
|
||||
// Oddly, OCIO uses RGBMs when setting the GradingPrimary on the CPU, but uses vec3s on the GPU.
|
||||
// Even more oddly, the conversion from RGBM to vec3 does not appear to have a public API.
|
||||
// Therefore, this code has been duplicated from OCIO here:
|
||||
// https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/3abbe5b20521169580fcfe3692aca81859859953/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp#L157
|
||||
QVector4D offset = value[kOffsetInput].toVec4();
|
||||
offset[RED_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[GREEN_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[BLUE_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
job.Insert(kOffsetInput, NodeValue(NodeValue::kVec3, QVector3D(offset[RED_CHANNEL], offset[GREEN_CHANNEL], offset[BLUE_CHANNEL])));
|
||||
// Oddly, OCIO uses RGBMs when setting the GradingPrimary on the CPU, but uses vec3s on the GPU.
|
||||
// Even more oddly, the conversion from RGBM to vec3 does not appear to have a public API.
|
||||
// Therefore, this code has been duplicated from OCIO here:
|
||||
// https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/3abbe5b20521169580fcfe3692aca81859859953/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp#L157
|
||||
QVector4D offset = value[kOffsetInput].toVec4();
|
||||
offset[RED_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[GREEN_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
offset[BLUE_CHANNEL] += offset[MASTER_CHANNEL];
|
||||
job.Insert(kOffsetInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(offset[RED_CHANNEL],
|
||||
offset[GREEN_CHANNEL],
|
||||
offset[BLUE_CHANNEL])));
|
||||
|
||||
QVector4D exposure = value[kExposureInput].toVec4();
|
||||
exposure[RED_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[RED_CHANNEL]);
|
||||
exposure[GREEN_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[GREEN_CHANNEL]);
|
||||
exposure[BLUE_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[BLUE_CHANNEL]);
|
||||
job.Insert(kExposureInput, NodeValue(NodeValue::kVec3, QVector3D(exposure[RED_CHANNEL], exposure[GREEN_CHANNEL], exposure[BLUE_CHANNEL])));
|
||||
QVector4D exposure = value[kExposureInput].toVec4();
|
||||
exposure[RED_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] +
|
||||
exposure[RED_CHANNEL]);
|
||||
exposure[GREEN_CHANNEL] = std::pow(
|
||||
2.0f, exposure[MASTER_CHANNEL] + exposure[GREEN_CHANNEL]);
|
||||
exposure[BLUE_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] +
|
||||
exposure[BLUE_CHANNEL]);
|
||||
job.Insert(kExposureInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(exposure[RED_CHANNEL],
|
||||
exposure[GREEN_CHANNEL],
|
||||
exposure[BLUE_CHANNEL])));
|
||||
|
||||
QVector4D contrast = value[kContrastInput].toVec4();
|
||||
contrast[RED_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[GREEN_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[BLUE_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
job.Insert(kContrastInput, NodeValue(NodeValue::kVec3, QVector3D(contrast[RED_CHANNEL], contrast[GREEN_CHANNEL], contrast[BLUE_CHANNEL])));
|
||||
QVector4D contrast = value[kContrastInput].toVec4();
|
||||
contrast[RED_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[GREEN_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
contrast[BLUE_CHANNEL] *= contrast[MASTER_CHANNEL];
|
||||
job.Insert(kContrastInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
QVector3D(contrast[RED_CHANNEL],
|
||||
contrast[GREEN_CHANNEL],
|
||||
contrast[BLUE_CHANNEL])));
|
||||
|
||||
if (!value[kClampBlackEnableInput].toBool()) {
|
||||
job.Insert(kClampBlackInput, NodeValue(NodeValue::kFloat, OCIO::GradingPrimary::NoClampBlack()));
|
||||
}
|
||||
if (!value[kClampBlackEnableInput].toBool()) {
|
||||
job.Insert(kClampBlackInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
OCIO::GradingPrimary::NoClampBlack()));
|
||||
}
|
||||
|
||||
if (!value[kClampWhiteEnableInput].toBool()) {
|
||||
job.Insert(kClampWhiteInput, NodeValue(NodeValue::kFloat, OCIO::GradingPrimary::NoClampWhite()));
|
||||
}
|
||||
if (!value[kClampWhiteEnableInput].toBool()) {
|
||||
job.Insert(kClampWhiteInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
OCIO::GradingPrimary::NoClampWhite()));
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
}
|
||||
}
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::ConfigChanged()
|
||||
{
|
||||
GenerateProcessor();
|
||||
GenerateProcessor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::SetVec4InputColors(const QString &input)
|
||||
{
|
||||
SetInputProperty(input, QStringLiteral("color0"), QColor(192, 192, 192).name());
|
||||
SetInputProperty(input, QStringLiteral("color1"), QColor(255, 0, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color2"), QColor(0, 255, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color3"), QColor(0, 0, 255).name());
|
||||
SetInputProperty(input, QStringLiteral("color0"),
|
||||
QColor(192, 192, 192).name());
|
||||
SetInputProperty(input, QStringLiteral("color1"), QColor(255, 0, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color2"), QColor(0, 255, 0).name());
|
||||
SetInputProperty(input, QStringLiteral("color3"), QColor(0, 0, 255).name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,43 +24,44 @@
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class OCIOGradingTransformLinearNode : public OCIOBaseNode
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OCIOGradingTransformLinearNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOGradingTransformLinearNode)
|
||||
class OCIOGradingTransformLinearNode : public OCIOBaseNode {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OCIOGradingTransformLinearNode();
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOGradingTransformLinearNode)
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input, int element) override;
|
||||
void GenerateProcessor();
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
void GenerateProcessor();
|
||||
|
||||
static const QString kContrastInput;
|
||||
static const QString kOffsetInput;
|
||||
static const QString kExposureInput;
|
||||
static const QString kSaturationInput;
|
||||
static const QString kPivotInput;
|
||||
static const QString kClampBlackEnableInput;
|
||||
static const QString kClampBlackInput;
|
||||
static const QString kClampWhiteEnableInput;
|
||||
static const QString kClampWhiteInput;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kContrastInput;
|
||||
static const QString kOffsetInput;
|
||||
static const QString kExposureInput;
|
||||
static const QString kSaturationInput;
|
||||
static const QString kPivotInput;
|
||||
static const QString kClampBlackEnableInput;
|
||||
static const QString kClampBlackInput;
|
||||
static const QString kClampWhiteEnableInput;
|
||||
static const QString kClampWhiteInput;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void ConfigChanged() override;
|
||||
|
||||
private:
|
||||
void SetVec4InputColors(const QString &input);
|
||||
|
||||
void SetVec4InputColors(const QString &input);
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
Reference in New Issue
Block a user