style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::default_config_ = nullptr;
|
||||
ocio::ConstConfigRcPtr ColorManager::default_config = nullptr;
|
||||
|
||||
ColorManager::ColorManager(Project *project)
|
||||
: QObject(project)
|
||||
@@ -42,51 +42,51 @@ ColorManager::ColorManager(Project *project)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorManager::Init()
|
||||
void ColorManager::init()
|
||||
{
|
||||
// Set config to our built-in default
|
||||
config_ = GetDefaultConfig();
|
||||
SetDefaultInputColorSpace(config_->getCanonicalName(OCIO::ROLE_DEFAULT));
|
||||
project()->SetColorReferenceSpace(OCIO::ROLE_SCENE_LINEAR);
|
||||
config_ = get_default_config();
|
||||
set_default_input_color_space(config_->getCanonicalName(ocio::ROLE_DEFAULT));
|
||||
project()->set_color_reference_space(ocio::ROLE_SCENE_LINEAR);
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
|
||||
ocio::ConstConfigRcPtr ColorManager::get_config() const
|
||||
{
|
||||
return config_;
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr
|
||||
ColorManager::CreateConfigFromFile(const QString &filename)
|
||||
ocio::ConstConfigRcPtr
|
||||
ColorManager::create_config_from_file(const QString &filename)
|
||||
{
|
||||
return OCIO::Config::CreateFromFile(filename.toUtf8());
|
||||
return ocio::Config::CreateFromFile(filename.toUtf8());
|
||||
}
|
||||
|
||||
QString ColorManager::GetConfigFilename() const
|
||||
QString ColorManager::get_config_filename() const
|
||||
{
|
||||
return project()->GetColorConfigFilename();
|
||||
return project()->get_color_config_filename();
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
ocio::ConstConfigRcPtr ColorManager::get_default_config()
|
||||
{
|
||||
// Set up on first use: Project construction calls ColorManager::Init()
|
||||
// unconditionally, so without this any Project created before
|
||||
// SetUpDefaultConfig() crashed dereferencing a null config.
|
||||
if (!default_config_) {
|
||||
SetUpDefaultConfig();
|
||||
if (!default_config) {
|
||||
set_up_default_config();
|
||||
}
|
||||
|
||||
return default_config_;
|
||||
return default_config;
|
||||
}
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
void ColorManager::set_up_default_config()
|
||||
{
|
||||
if (!qEnvironmentVariableIsEmpty("OCIO")) {
|
||||
// Attempt to set config from "OCIO" environment variable
|
||||
try {
|
||||
default_config_ = OCIO::Config::CreateFromEnv();
|
||||
default_config = ocio::Config::CreateFromEnv();
|
||||
|
||||
return;
|
||||
} catch (OCIO::Exception &e) {
|
||||
} catch (ocio::Exception &e) {
|
||||
qWarning()
|
||||
<< "Failed to load config from OCIO environment variable config:"
|
||||
<< e.what();
|
||||
@@ -98,20 +98,20 @@ void ColorManager::SetUpDefaultConfig()
|
||||
QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.filePath(QStringLiteral("ocioconf"));
|
||||
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"), dir, true);
|
||||
FileFunctions::copy_directory(QStringLiteral(":/ocioconf"), dir, true);
|
||||
|
||||
qDebug() << "Extracting default OCIO config to" << dir;
|
||||
|
||||
default_config_ =
|
||||
CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
default_config =
|
||||
create_config_from_file(QDir(dir).filePath(QStringLiteral("config.ocio")));
|
||||
}
|
||||
|
||||
void ColorManager::SetConfigFilename(const QString &filename)
|
||||
void ColorManager::set_config_filename(const QString &filename)
|
||||
{
|
||||
project()->SetColorConfigFilename(filename);
|
||||
project()->set_color_config_filename(filename);
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableDisplays()
|
||||
QStringList ColorManager::list_available_displays()
|
||||
{
|
||||
QStringList displays;
|
||||
|
||||
@@ -124,12 +124,12 @@ QStringList ColorManager::ListAvailableDisplays()
|
||||
return displays;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultDisplay()
|
||||
QString ColorManager::get_default_display()
|
||||
{
|
||||
return config_->getDefaultDisplay();
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableViews(QString display)
|
||||
QStringList ColorManager::list_available_views(QString display)
|
||||
{
|
||||
QStringList views;
|
||||
|
||||
@@ -142,12 +142,12 @@ QStringList ColorManager::ListAvailableViews(QString display)
|
||||
return views;
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultView(const QString &display)
|
||||
QString ColorManager::get_default_view(const QString &display)
|
||||
{
|
||||
return config_->getDefaultView(display.toUtf8());
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableLooks()
|
||||
QStringList ColorManager::list_available_looks()
|
||||
{
|
||||
QStringList looks;
|
||||
|
||||
@@ -160,37 +160,37 @@ QStringList ColorManager::ListAvailableLooks()
|
||||
return looks;
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableColorspaces() const
|
||||
QStringList ColorManager::list_available_colorspaces() const
|
||||
{
|
||||
return ListAvailableColorspaces(config_);
|
||||
return list_available_colorspaces(config_);
|
||||
}
|
||||
|
||||
QString ColorManager::GetDefaultInputColorSpace() const
|
||||
QString ColorManager::get_default_input_color_space() const
|
||||
{
|
||||
return project()->GetDefaultInputColorSpace();
|
||||
return project()->get_default_input_color_space();
|
||||
}
|
||||
|
||||
void ColorManager::SetDefaultInputColorSpace(const QString &s)
|
||||
void ColorManager::set_default_input_color_space(const QString &s)
|
||||
{
|
||||
project()->SetDefaultInputColorSpace(s);
|
||||
project()->set_default_input_color_space(s);
|
||||
}
|
||||
|
||||
QString ColorManager::GetReferenceColorSpace() const
|
||||
QString ColorManager::get_reference_color_space() const
|
||||
{
|
||||
return project()->GetColorReferenceSpace();
|
||||
return project()->get_color_reference_space();
|
||||
}
|
||||
|
||||
QString ColorManager::GetCompliantColorSpace(const QString &s)
|
||||
QString ColorManager::get_compliant_color_space(const QString &s)
|
||||
{
|
||||
if (ListAvailableColorspaces().contains(s)) {
|
||||
if (list_available_colorspaces().contains(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return GetDefaultInputColorSpace();
|
||||
return get_default_input_color_space();
|
||||
}
|
||||
}
|
||||
|
||||
ColorTransform
|
||||
ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
ColorManager::get_compliant_color_space(const ColorTransform &transform,
|
||||
bool force_display)
|
||||
{
|
||||
if (transform.is_display() || force_display) {
|
||||
@@ -200,17 +200,17 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
QString look = transform.look();
|
||||
|
||||
// Check if display still exists in config
|
||||
if (!ListAvailableDisplays().contains(display)) {
|
||||
display = GetDefaultDisplay();
|
||||
if (!list_available_displays().contains(display)) {
|
||||
display = get_default_display();
|
||||
}
|
||||
|
||||
// Check if view still exists in display
|
||||
if (!ListAvailableViews(display).contains(view)) {
|
||||
view = GetDefaultView(display);
|
||||
if (!list_available_views(display).contains(view)) {
|
||||
view = get_default_view(display);
|
||||
}
|
||||
|
||||
// Check if looks still exists
|
||||
if (!ListAvailableLooks().contains(look)) {
|
||||
if (!list_available_looks().contains(look)) {
|
||||
look.clear();
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
} else {
|
||||
QString output = transform.output();
|
||||
|
||||
if (!ListAvailableColorspaces().contains(output)) {
|
||||
output = GetDefaultInputColorSpace();
|
||||
if (!list_available_colorspaces().contains(output)) {
|
||||
output = get_default_input_color_space();
|
||||
}
|
||||
|
||||
return ColorTransform(output);
|
||||
@@ -228,7 +228,7 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform,
|
||||
}
|
||||
|
||||
QStringList
|
||||
ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
ColorManager::list_available_colorspaces(ocio::ConstConfigRcPtr config)
|
||||
{
|
||||
QStringList spaces;
|
||||
|
||||
@@ -243,7 +243,7 @@ ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
return spaces;
|
||||
}
|
||||
|
||||
void ColorManager::GetDefaultLumaCoefs(double *rgb) const
|
||||
void ColorManager::get_default_luma_coefs(double *rgb) const
|
||||
{
|
||||
config_->getDefaultLumaCoefs(rgb);
|
||||
}
|
||||
@@ -253,17 +253,17 @@ Project *ColorManager::project() const
|
||||
return static_cast<Project *>(parent());
|
||||
}
|
||||
|
||||
void ColorManager::UpdateConfigFromFilename()
|
||||
void ColorManager::update_config_from_filename()
|
||||
{
|
||||
try {
|
||||
QString config_filename = GetConfigFilename();
|
||||
QString old_default_cs = GetDefaultInputColorSpace();
|
||||
QString config_filename = get_config_filename();
|
||||
QString old_default_cs = get_default_input_color_space();
|
||||
|
||||
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();
|
||||
QStringList available_cs = list_available_colorspaces();
|
||||
for (int i = 0; i < available_cs.size(); i++) {
|
||||
const QString &c = available_cs.at(i);
|
||||
if (c.compare(old_default_cs, Qt::CaseInsensitive)) {
|
||||
@@ -271,10 +271,10 @@ void ColorManager::UpdateConfigFromFilename()
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetDefaultInputColorSpace(new_default);
|
||||
set_default_input_color_space(new_default);
|
||||
|
||||
emit ConfigChanged(config_filename);
|
||||
} catch (OCIO::Exception &) {
|
||||
emit config_changed(config_filename);
|
||||
} catch (ocio::Exception &) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSERVICE_H
|
||||
#define COLORSERVICE_H
|
||||
#ifndef OAK_COLORSERVICE_H
|
||||
#define OAK_COLORSERVICE_H
|
||||
|
||||
#include <memory>
|
||||
#include <QMutex>
|
||||
@@ -37,64 +37,64 @@ class ColorManager : public QObject {
|
||||
public:
|
||||
ColorManager(Project *project);
|
||||
|
||||
void Init();
|
||||
void init();
|
||||
|
||||
OCIO::ConstConfigRcPtr GetConfig() const;
|
||||
ocio::ConstConfigRcPtr get_config() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString &filename);
|
||||
static ocio::ConstConfigRcPtr create_config_from_file(const QString &filename);
|
||||
|
||||
QString GetConfigFilename() const;
|
||||
QString get_config_filename() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
static ocio::ConstConfigRcPtr get_default_config();
|
||||
|
||||
static void SetUpDefaultConfig();
|
||||
static void set_up_default_config();
|
||||
|
||||
void SetConfigFilename(const QString &filename);
|
||||
void set_config_filename(const QString &filename);
|
||||
|
||||
QStringList ListAvailableDisplays();
|
||||
QStringList list_available_displays();
|
||||
|
||||
QString GetDefaultDisplay();
|
||||
QString get_default_display();
|
||||
|
||||
QStringList ListAvailableViews(QString display);
|
||||
QStringList list_available_views(QString display);
|
||||
|
||||
QString GetDefaultView(const QString &display);
|
||||
QString get_default_view(const QString &display);
|
||||
|
||||
QStringList ListAvailableLooks();
|
||||
QStringList list_available_looks();
|
||||
|
||||
QStringList ListAvailableColorspaces() const;
|
||||
QStringList list_available_colorspaces() const;
|
||||
|
||||
QString GetDefaultInputColorSpace() const;
|
||||
QString get_default_input_color_space() const;
|
||||
|
||||
void SetDefaultInputColorSpace(const QString &s);
|
||||
void set_default_input_color_space(const QString &s);
|
||||
|
||||
QString GetReferenceColorSpace() const;
|
||||
QString get_reference_color_space() const;
|
||||
|
||||
QString GetCompliantColorSpace(const QString &s);
|
||||
QString get_compliant_color_space(const QString &s);
|
||||
|
||||
ColorTransform GetCompliantColorSpace(const ColorTransform &transform,
|
||||
ColorTransform get_compliant_color_space(const ColorTransform &transform,
|
||||
bool force_display = false);
|
||||
|
||||
static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
static QStringList list_available_colorspaces(ocio::ConstConfigRcPtr config);
|
||||
|
||||
void GetDefaultLumaCoefs(double *rgb) const;
|
||||
void get_default_luma_coefs(double *rgb) const;
|
||||
|
||||
Project *project() const;
|
||||
|
||||
void UpdateConfigFromFilename();
|
||||
void update_config_from_filename();
|
||||
|
||||
signals:
|
||||
void ConfigChanged(const QString &s);
|
||||
void config_changed(const QString &s);
|
||||
|
||||
void ReferenceSpaceChanged(const QString &s);
|
||||
void reference_space_changed(const QString &s);
|
||||
|
||||
void DefaultInputChanged(const QString &s);
|
||||
void default_input_changed(const QString &s);
|
||||
|
||||
private:
|
||||
OCIO::ConstConfigRcPtr config_;
|
||||
ocio::ConstConfigRcPtr config_;
|
||||
|
||||
static OCIO::ConstConfigRcPtr default_config_;
|
||||
static ocio::ConstConfigRcPtr default_config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSERVICE_H
|
||||
#endif // OAK_COLORSERVICE_H
|
||||
|
||||
@@ -26,26 +26,26 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString DisplayTransformNode::kDisplayInput =
|
||||
const QString DisplayTransformNode::k_display_input =
|
||||
QStringLiteral("display_in");
|
||||
const QString DisplayTransformNode::kViewInput = QStringLiteral("view_in");
|
||||
const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in");
|
||||
const QString DisplayTransformNode::k_view_input = QStringLiteral("view_in");
|
||||
const QString DisplayTransformNode::k_direction_input = QStringLiteral("dir_in");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
DisplayTransformNode::DisplayTransformNode()
|
||||
{
|
||||
AddInput(kDisplayInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_display_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kViewInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_view_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_direction_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Name() const
|
||||
QString DisplayTransformNode::name() const
|
||||
{
|
||||
return tr("Display Transform");
|
||||
}
|
||||
@@ -55,58 +55,58 @@ QString DisplayTransformNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.displaytransform");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> DisplayTransformNode::Category() const
|
||||
QVector<Node::CategoryID> DisplayTransformNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::Description() const
|
||||
QString DisplayTransformNode::description() const
|
||||
{
|
||||
return tr("Converts an image to or from a display color space.");
|
||||
}
|
||||
|
||||
void DisplayTransformNode::Retranslate()
|
||||
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") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_display_input, tr("Display"));
|
||||
set_input_name(k_view_input, tr("View"));
|
||||
set_input_name(k_direction_input, tr("Direction"));
|
||||
set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") });
|
||||
}
|
||||
|
||||
void DisplayTransformNode::InputValueChangedEvent(const QString &input,
|
||||
int element)
|
||||
{
|
||||
Q_UNUSED(element);
|
||||
if (input == kDisplayInput || input == kDirectionInput ||
|
||||
input == kViewInput) {
|
||||
if (input == kDisplayInput) {
|
||||
UpdateViews();
|
||||
if (input == k_display_input || input == k_direction_input ||
|
||||
input == k_view_input) {
|
||||
if (input == k_display_input) {
|
||||
update_views();
|
||||
}
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetDisplay() const
|
||||
QString DisplayTransformNode::get_display() const
|
||||
{
|
||||
if (manager()) {
|
||||
int index = GetStandardValue(kDisplayInput).toInt();
|
||||
if (index < manager()->ListAvailableDisplays().size()) {
|
||||
return manager()->ListAvailableDisplays().at(index);
|
||||
int index = get_standard_value(k_display_input).toInt();
|
||||
if (index < manager()->list_available_displays().size()) {
|
||||
return manager()->list_available_displays().at(index);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DisplayTransformNode::GetView() const
|
||||
QString DisplayTransformNode::get_view() const
|
||||
{
|
||||
if (manager()) {
|
||||
QString display = GetDisplay();
|
||||
QString display = get_display();
|
||||
if (!display.isEmpty()) {
|
||||
int index = GetStandardValue(kViewInput).toInt();
|
||||
QStringList views = manager()->ListAvailableViews(display);
|
||||
int index = get_standard_value(k_view_input).toInt();
|
||||
QStringList views = manager()->list_available_views(display);
|
||||
if (index < views.size()) {
|
||||
return views.at(index);
|
||||
}
|
||||
@@ -115,42 +115,42 @@ QString DisplayTransformNode::GetView() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
ColorProcessor::Direction DisplayTransformNode::GetDirection() const
|
||||
ColorProcessor::Direction DisplayTransformNode::get_direction() const
|
||||
{
|
||||
return static_cast<ColorProcessor::Direction>(
|
||||
GetStandardValue(kDirectionInput).toInt());
|
||||
get_standard_value(k_direction_input).toInt());
|
||||
;
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateDisplays()
|
||||
void DisplayTransformNode::update_displays()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays());
|
||||
set_combo_box_strings(k_display_input, manager()->list_available_displays());
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::UpdateViews()
|
||||
void DisplayTransformNode::update_views()
|
||||
{
|
||||
if (manager()) {
|
||||
SetComboBoxStrings(kViewInput,
|
||||
manager()->ListAvailableViews(GetDisplay()));
|
||||
set_combo_box_strings(k_view_input,
|
||||
manager()->list_available_views(get_display()));
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayTransformNode::ConfigChanged()
|
||||
void DisplayTransformNode::config_changed()
|
||||
{
|
||||
UpdateDisplays();
|
||||
UpdateViews();
|
||||
GenerateProcessor();
|
||||
update_displays();
|
||||
update_views();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void DisplayTransformNode::GenerateProcessor()
|
||||
void DisplayTransformNode::generate_processor()
|
||||
{
|
||||
if (manager()) {
|
||||
ColorTransform transform(GetDisplay(), GetView(), QString());
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager(), manager()->GetReferenceColorSpace(), transform,
|
||||
GetDirection()));
|
||||
ColorTransform transform(get_display(), get_view(), QString());
|
||||
set_processor(ColorProcessor::create(
|
||||
manager(), manager()->get_reference_color_space(), transform,
|
||||
get_direction()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DISPLAYTRANSFORMNODE_H
|
||||
#define DISPLAYTRANSFORMNODE_H
|
||||
#ifndef OAK_DISPLAYTRANSFORMNODE_H
|
||||
#define OAK_DISPLAYTRANSFORMNODE_H
|
||||
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
@@ -35,34 +35,34 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(DisplayTransformNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
|
||||
QString GetDisplay() const;
|
||||
QString GetView() const;
|
||||
ColorProcessor::Direction GetDirection() const;
|
||||
QString get_display() const;
|
||||
QString get_view() const;
|
||||
ColorProcessor::Direction get_direction() const;
|
||||
|
||||
static const QString kDisplayInput;
|
||||
static const QString kViewInput;
|
||||
static const QString kDirectionInput;
|
||||
static const QString k_display_input;
|
||||
static const QString k_view_input;
|
||||
static const QString k_direction_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
void generate_processor();
|
||||
|
||||
void UpdateDisplays();
|
||||
void update_displays();
|
||||
|
||||
void UpdateViews();
|
||||
void update_views();
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
#endif // DISPLAYTRANSFORMNODE_H
|
||||
#endif // OAK_DISPLAYTRANSFORMNODE_H
|
||||
|
||||
@@ -27,54 +27,54 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOBaseNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString OCIOBaseNode::k_texture_input = QStringLiteral("tex_in");
|
||||
|
||||
OCIOBaseNode::OCIOBaseNode()
|
||||
: manager_(nullptr)
|
||||
, processor_(nullptr)
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
set_effect_input(k_texture_input);
|
||||
|
||||
SetFlag(kVideoEffect);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void OCIOBaseNode::AddedToGraphEvent(Project *p)
|
||||
{
|
||||
manager_ = p->color_manager();
|
||||
connect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
ConfigChanged();
|
||||
connect(manager_, &ColorManager::config_changed, this,
|
||||
&OCIOBaseNode::config_changed);
|
||||
config_changed();
|
||||
}
|
||||
|
||||
void OCIOBaseNode::RemovedFromGraphEvent(Project *p)
|
||||
{
|
||||
if (manager_) {
|
||||
disconnect(manager_, &ColorManager::ConfigChanged, this,
|
||||
&OCIOBaseNode::ConfigChanged);
|
||||
disconnect(manager_, &ColorManager::config_changed, this,
|
||||
&OCIOBaseNode::config_changed);
|
||||
manager_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void OCIOBaseNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
auto tex_met = value[kTextureInput];
|
||||
TexturePtr t = tex_met.toTexture();
|
||||
auto tex_met = value[k_texture_input];
|
||||
TexturePtr t = tex_met.to_texture();
|
||||
if (t) {
|
||||
if (processor_) {
|
||||
ColorTransformJob job;
|
||||
|
||||
job.SetColorProcessor(processor_);
|
||||
job.SetInputTexture(tex_met);
|
||||
job.set_color_processor(processor_);
|
||||
job.set_input_texture(tex_met);
|
||||
|
||||
table->Push(NodeValue::kTexture, t->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, t->to_job(job), this);
|
||||
} else {
|
||||
// Processor isn't ready yet (e.g. still being generated
|
||||
// asynchronously), pass the input through unchanged.
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(t), this);
|
||||
table->push(NodeValue::k_texture, QVariant::fromValue(t), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOBASENODE_H
|
||||
#define OCIOBASENODE_H
|
||||
#ifndef OAK_OCIOBASENODE_H
|
||||
#define OAK_OCIOBASENODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "render/job/colortransformjob.h"
|
||||
@@ -36,13 +36,13 @@ public:
|
||||
virtual void AddedToGraphEvent(Project *p) override;
|
||||
virtual void RemovedFromGraphEvent(Project *p) override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString k_texture_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() = 0;
|
||||
virtual void config_changed() = 0;
|
||||
|
||||
protected:
|
||||
ColorManager *manager() const
|
||||
@@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // OCIOBASENODE_H
|
||||
#endif // OAK_OCIOBASENODE_H
|
||||
|
||||
@@ -31,74 +31,74 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOGradingTransformLinearNode::kContrastInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_contrast_input =
|
||||
QStringLiteral("ocio_grading_primary_contrast");
|
||||
const QString OCIOGradingTransformLinearNode::kOffsetInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_offset_input =
|
||||
QStringLiteral("ocio_grading_primary_offset");
|
||||
const QString OCIOGradingTransformLinearNode::kExposureInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_exposure_input =
|
||||
QStringLiteral("ocio_grading_primary_exposure");
|
||||
const QString OCIOGradingTransformLinearNode::kSaturationInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_saturation_input =
|
||||
QStringLiteral("ocio_grading_primary_saturation");
|
||||
const QString OCIOGradingTransformLinearNode::kPivotInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_pivot_input =
|
||||
QStringLiteral("ocio_grading_primary_pivot");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackEnableInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_black_enable_input =
|
||||
QStringLiteral("clamp_black_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampBlackInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_black_input =
|
||||
QStringLiteral("ocio_grading_primary_clampBlack");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteEnableInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_white_enable_input =
|
||||
QStringLiteral("clamp_white_enable_in");
|
||||
const QString OCIOGradingTransformLinearNode::kClampWhiteInput =
|
||||
const QString OCIOGradingTransformLinearNode::k_clamp_white_input =
|
||||
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"),
|
||||
add_input(k_contrast_input, NodeValue::k_vec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 });
|
||||
// Minimum based on ocio::GradingPrimary::validate
|
||||
set_input_property(k_contrast_input, QStringLiteral("min"),
|
||||
QVector4D{ 0.01f, 0.01f, 0.01f, 0.01f });
|
||||
SetInputProperty(kContrastInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kContrastInput);
|
||||
set_input_property(k_contrast_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_contrast_input);
|
||||
|
||||
AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kOffsetInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kOffsetInput);
|
||||
add_input(k_offset_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
set_input_property(k_offset_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_offset_input);
|
||||
|
||||
AddInput(kExposureInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
SetInputProperty(kExposureInput, QStringLiteral("base"), 0.01);
|
||||
SetVec4InputColors(kExposureInput);
|
||||
add_input(k_exposure_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 });
|
||||
set_input_property(k_exposure_input, QStringLiteral("base"), 0.01);
|
||||
set_vec4_input_colors(k_exposure_input);
|
||||
|
||||
AddInput(kSaturationInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0);
|
||||
add_input(k_saturation_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_saturation_input, QStringLiteral("view"),
|
||||
FloatSlider::k_percentage);
|
||||
set_input_property(k_saturation_input, QStringLiteral("min"), 0.0);
|
||||
|
||||
AddInput(kPivotInput, NodeValue::kFloat,
|
||||
0.18); // Default listed in OCIO::GradingPrimary
|
||||
SetInputProperty(kPivotInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_pivot_input, NodeValue::k_float,
|
||||
0.18); // Default listed in ocio::GradingPrimary
|
||||
set_input_property(k_pivot_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampBlackEnableInput, NodeValue::kBoolean, false);
|
||||
add_input(k_clamp_black_enable_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kClampBlackInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampBlackEnableInput).toBool());
|
||||
SetInputProperty(kClampBlackInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_clamp_black_input, NodeValue::k_float, 0.0);
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_black_enable_input).toBool());
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
AddInput(kClampWhiteEnableInput, NodeValue::kBoolean, false);
|
||||
add_input(k_clamp_white_enable_input, NodeValue::k_boolean, false);
|
||||
|
||||
AddInput(kClampWhiteInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"),
|
||||
GetStandardValue(kClampWhiteEnableInput).toBool());
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("base"), 0.01);
|
||||
add_input(k_clamp_white_input, NodeValue::k_float, 1.0);
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_white_enable_input).toBool());
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("base"), 0.01);
|
||||
|
||||
// Constrain the white clamp minimum to just above the (static) black clamp
|
||||
// as per OCIO::GradingPrimary::validate. When the black clamp is keyframed
|
||||
// as per ocio::GradingPrimary::validate. When the black clamp is keyframed
|
||||
// or connected, Value() enforces the invariant per frame instead.
|
||||
UpdateClampWhiteMinimum();
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Name() const
|
||||
QString OCIOGradingTransformLinearNode::name() const
|
||||
{
|
||||
return tr("OCIO Color Grading (Linear)");
|
||||
}
|
||||
@@ -109,32 +109,32 @@ QString OCIOGradingTransformLinearNode::id() const
|
||||
"org.olivevideoeditor.Olive.ociogradingtransformlinear");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> OCIOGradingTransformLinearNode::Category() const
|
||||
QVector<Node::CategoryID> OCIOGradingTransformLinearNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString OCIOGradingTransformLinearNode::Description() const
|
||||
QString OCIOGradingTransformLinearNode::description() const
|
||||
{
|
||||
return tr("Simple linear color grading using OpenColorIO.");
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Retranslate()
|
||||
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"),
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_contrast_input, tr("Contrast"));
|
||||
set_input_name(k_offset_input, tr("Offset"));
|
||||
set_input_name(k_exposure_input, tr("Exposure"));
|
||||
set_input_property(k_exposure_input, 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"));
|
||||
set_input_name(k_saturation_input, tr("Saturation"));
|
||||
set_input_name(k_pivot_input, tr("Pivot"));
|
||||
set_input_name(k_clamp_black_enable_input, tr("Enable Black Clamp"));
|
||||
set_input_name(k_clamp_black_input, tr("Black Clamp"));
|
||||
set_input_name(k_clamp_white_enable_input, tr("Enable White Clamp"));
|
||||
set_input_name(k_clamp_white_input, tr("White Clamp"));
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::InputValueChangedEvent(
|
||||
@@ -142,19 +142,19 @@ void OCIOGradingTransformLinearNode::InputValueChangedEvent(
|
||||
{
|
||||
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) {
|
||||
if (input == k_clamp_white_enable_input) {
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_white_enable_input).toBool());
|
||||
} else if (input == k_clamp_black_enable_input) {
|
||||
set_input_property(k_clamp_black_input, QStringLiteral("enabled"),
|
||||
get_standard_value(k_clamp_black_enable_input).toBool());
|
||||
} else if (input == k_clamp_black_input) {
|
||||
// Ensure the white clamp is always greater than the black clamp as per
|
||||
// OCIO::GradingPrimary::validate
|
||||
UpdateClampWhiteMinimum();
|
||||
// ocio::GradingPrimary::validate
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input,
|
||||
@@ -162,8 +162,8 @@ void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input,
|
||||
{
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
|
||||
if (input == kClampBlackInput) {
|
||||
UpdateClampWhiteMinimum();
|
||||
if (input == k_clamp_black_input) {
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,139 +173,139 @@ void OCIOGradingTransformLinearNode::InputDisconnectedEvent(const QString &input
|
||||
{
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
|
||||
if (input == kClampBlackInput) {
|
||||
UpdateClampWhiteMinimum();
|
||||
if (input == k_clamp_black_input) {
|
||||
update_clamp_white_minimum();
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::UpdateClampWhiteMinimum()
|
||||
void OCIOGradingTransformLinearNode::update_clamp_white_minimum()
|
||||
{
|
||||
// A static UI minimum cannot follow an animated black clamp; for keyframed
|
||||
// or connected values the white>black invariant is enforced per frame in
|
||||
// Value() instead
|
||||
if (IsInputKeyframing(kClampBlackInput) ||
|
||||
IsInputConnected(kClampBlackInput)) {
|
||||
if (is_input_keyframing(k_clamp_black_input) ||
|
||||
is_input_connected(k_clamp_black_input)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetInputProperty(kClampWhiteInput, QStringLiteral("min"),
|
||||
GetStandardValue(kClampBlackInput).toDouble() + 0.000001);
|
||||
set_input_property(k_clamp_white_input, QStringLiteral("min"),
|
||||
get_standard_value(k_clamp_black_input).toDouble() + 0.000001);
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::GenerateProcessor()
|
||||
void OCIOGradingTransformLinearNode::generate_processor()
|
||||
{
|
||||
if (manager()) {
|
||||
OCIO::GradingPrimaryTransformRcPtr gp =
|
||||
OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN);
|
||||
ocio::GradingPrimaryTransformRcPtr gp =
|
||||
ocio::GradingPrimaryTransform::Create(ocio::GRADING_LIN);
|
||||
gp->makeDynamic();
|
||||
gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
gp->setDirection(ocio::TransformDirection::TRANSFORM_DIR_FORWARD);
|
||||
|
||||
try {
|
||||
set_processor(ColorProcessor::Create(
|
||||
manager()->GetConfig()->getProcessor(gp)));
|
||||
} catch (const OCIO::Exception &e) {
|
||||
set_processor(ColorProcessor::create(
|
||||
manager()->get_config()->getProcessor(gp)));
|
||||
} catch (const ocio::Exception &e) {
|
||||
std::cerr << std::endl << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value,
|
||||
void OCIOGradingTransformLinearNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
if (processor()) {
|
||||
ColorTransformJob job(value);
|
||||
|
||||
job.SetColorProcessor(processor());
|
||||
job.SetInputTexture(value[kTextureInput]);
|
||||
job.set_color_processor(processor());
|
||||
job.set_input_texture(value[k_texture_input]);
|
||||
|
||||
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])));
|
||||
QVector4D offset = value[k_offset_input].to_vec4();
|
||||
offset[red_channel] += offset[master_channel];
|
||||
offset[green_channel] += offset[master_channel];
|
||||
offset[blue_channel] += offset[master_channel];
|
||||
job.insert(k_offset_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
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[k_exposure_input].to_vec4();
|
||||
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(k_exposure_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
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[k_contrast_input].to_vec4();
|
||||
contrast[red_channel] *= contrast[master_channel];
|
||||
contrast[green_channel] *= contrast[master_channel];
|
||||
contrast[blue_channel] *= contrast[master_channel];
|
||||
job.insert(k_contrast_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
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[k_clamp_black_enable_input].to_bool()) {
|
||||
job.insert(k_clamp_black_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
ocio::GradingPrimary::NoClampBlack()));
|
||||
}
|
||||
|
||||
if (!value[kClampWhiteEnableInput].toBool()) {
|
||||
job.Insert(kClampWhiteInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
OCIO::GradingPrimary::NoClampWhite()));
|
||||
if (!value[k_clamp_white_enable_input].to_bool()) {
|
||||
job.insert(k_clamp_white_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
ocio::GradingPrimary::NoClampWhite()));
|
||||
}
|
||||
|
||||
if (value[kClampBlackEnableInput].toBool() &&
|
||||
value[kClampWhiteEnableInput].toBool()) {
|
||||
// OCIO::GradingPrimary::validate requires the white clamp to be
|
||||
if (value[k_clamp_black_enable_input].to_bool() &&
|
||||
value[k_clamp_white_enable_input].to_bool()) {
|
||||
// ocio::GradingPrimary::validate requires the white clamp to be
|
||||
// greater than the black clamp. Keyframed or connected values
|
||||
// can violate this at arbitrary times, so enforce the invariant
|
||||
// per frame here.
|
||||
const double clamp_black = value[kClampBlackInput].toDouble();
|
||||
const double clamp_white = value[kClampWhiteInput].toDouble();
|
||||
const double clamp_black = value[k_clamp_black_input].to_double();
|
||||
const double clamp_white = value[k_clamp_white_input].to_double();
|
||||
if (clamp_white <= clamp_black) {
|
||||
job.Insert(kClampWhiteInput,
|
||||
NodeValue(NodeValue::kFloat,
|
||||
job.insert(k_clamp_white_input,
|
||||
NodeValue(NodeValue::k_float,
|
||||
clamp_black + 0.000001));
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::ConfigChanged()
|
||||
void OCIOGradingTransformLinearNode::config_changed()
|
||||
{
|
||||
GenerateProcessor();
|
||||
generate_processor();
|
||||
}
|
||||
|
||||
void OCIOGradingTransformLinearNode::SetVec4InputColors(const QString &input)
|
||||
void OCIOGradingTransformLinearNode::set_vec4_input_colors(const QString &input)
|
||||
{
|
||||
SetInputProperty(input, QStringLiteral("color0"),
|
||||
set_input_property(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());
|
||||
set_input_property(input, QStringLiteral("color1"), QColor(255, 0, 0).name());
|
||||
set_input_property(input, QStringLiteral("color2"), QColor(0, 255, 0).name());
|
||||
set_input_property(input, QStringLiteral("color3"), QColor(0, 0, 255).name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#define OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#ifndef OAK_OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
#define OAK_OCIOGRADINGTRANSFORMLINEARNODE_H
|
||||
|
||||
#include "node/color/ociobase/ociobase.h"
|
||||
#include "render/colorprocessor.h"
|
||||
@@ -35,48 +35,48 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOGradingTransformLinearNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
void GenerateProcessor();
|
||||
void generate_processor();
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
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;
|
||||
static const QString k_contrast_input;
|
||||
static const QString k_offset_input;
|
||||
static const QString k_exposure_input;
|
||||
static const QString k_saturation_input;
|
||||
static const QString k_pivot_input;
|
||||
static const QString k_clamp_black_enable_input;
|
||||
static const QString k_clamp_black_input;
|
||||
static const QString k_clamp_white_enable_input;
|
||||
static const QString k_clamp_white_input;
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void SetVec4InputColors(const QString &input);
|
||||
void set_vec4_input_colors(const QString &input);
|
||||
|
||||
/**
|
||||
* @brief Constrains the white clamp UI minimum to just above the black
|
||||
* clamp, as required by OCIO::GradingPrimary::validate
|
||||
* clamp, as required by ocio::GradingPrimary::validate
|
||||
*
|
||||
* Only applies while the black clamp is a static value; when it is
|
||||
* keyframed or connected the invariant is enforced per frame in Value()
|
||||
* instead.
|
||||
*/
|
||||
void UpdateClampWhiteMinimum();
|
||||
void update_clamp_white_minimum();
|
||||
};
|
||||
|
||||
} // olive
|
||||
|
||||
@@ -34,23 +34,23 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString OCIOLutNode::kFileInput = QStringLiteral("lut_file_in");
|
||||
const QString OCIOLutNode::kDirectionInput = QStringLiteral("lut_dir_in");
|
||||
const QString OCIOLutNode::k_file_input = QStringLiteral("lut_file_in");
|
||||
const QString OCIOLutNode::k_direction_input = QStringLiteral("lut_dir_in");
|
||||
|
||||
#define super OCIOBaseNode
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool IsMainProcess()
|
||||
bool is_main_process()
|
||||
{
|
||||
return qobject_cast<QApplication *>(QCoreApplication::instance()) !=
|
||||
nullptr;
|
||||
}
|
||||
|
||||
int ReadDirectionInput(const Node *node)
|
||||
int read_direction_input(const Node *node)
|
||||
{
|
||||
QVariant v = node->GetStandardValue(OCIOLutNode::kDirectionInput);
|
||||
QVariant v = node->get_standard_value(OCIOLutNode::k_direction_input);
|
||||
|
||||
bool ok = false;
|
||||
int direction = v.toInt(&ok);
|
||||
@@ -75,23 +75,23 @@ int ReadDirectionInput(const Node *node)
|
||||
|
||||
OCIOLutNode::OCIOLutNode()
|
||||
{
|
||||
AddInput(kFileInput, NodeValue::kFile, QString(),
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
SetInputProperty(
|
||||
kFileInput, QStringLiteral("filter"),
|
||||
add_input(k_file_input, NodeValue::k_file, QString(),
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
set_input_property(
|
||||
k_file_input, QStringLiteral("filter"),
|
||||
tr("LUT Files (*.cube *.3dl);;Cube LUT (*.cube);;3DL LUT (*.3dl);;All Files (*)"));
|
||||
SetInputProperty(kFileInput, QStringLiteral("placeholder"),
|
||||
set_input_property(k_file_input, QStringLiteral("placeholder"),
|
||||
tr("Select a .cube or .3dl LUT file"));
|
||||
// Allow the UI to offer the global LUT library for this input
|
||||
SetInputProperty(kFileInput, QStringLiteral("lut_library"), true);
|
||||
set_input_property(k_file_input, QStringLiteral("lut_library"), true);
|
||||
|
||||
AddInput(kDirectionInput, NodeValue::kCombo, 0,
|
||||
InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
|
||||
add_input(k_direction_input, NodeValue::k_combo, 0,
|
||||
InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable));
|
||||
|
||||
qRegisterMetaType<olive::ColorProcessorPtr>();
|
||||
}
|
||||
|
||||
QString OCIOLutNode::Name() const
|
||||
QString OCIOLutNode::name() const
|
||||
{
|
||||
return tr("OCIO LUT");
|
||||
}
|
||||
@@ -101,37 +101,37 @@ QString OCIOLutNode::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.ociolut");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> OCIOLutNode::Category() const
|
||||
QVector<Node::CategoryID> OCIOLutNode::category() const
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
QString OCIOLutNode::Description() const
|
||||
QString OCIOLutNode::description() const
|
||||
{
|
||||
return tr("Applies a LUT file through OpenColorIO.");
|
||||
}
|
||||
|
||||
void OCIOLutNode::Retranslate()
|
||||
void OCIOLutNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kFileInput, tr("LUT File"));
|
||||
SetInputName(kDirectionInput, tr("Direction"));
|
||||
SetComboBoxStrings(kDirectionInput, { tr("Forward"), tr("Inverse") });
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_file_input, tr("LUT File"));
|
||||
set_input_name(k_direction_input, tr("Direction"));
|
||||
set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") });
|
||||
}
|
||||
|
||||
void OCIOLutNode::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kFileInput || input == kDirectionInput) {
|
||||
if (input == k_file_input || input == k_direction_input) {
|
||||
// In the worker process, creating the OCIO processor can be slow and we
|
||||
// are often called from LoadGraph while the main process is blocked
|
||||
// waiting for a response. Defer generation to Value() time so the worker
|
||||
// can ack the graph load immediately.
|
||||
if (IsMainProcess()) {
|
||||
GenerateProcessor();
|
||||
if (is_main_process()) {
|
||||
generate_processor();
|
||||
} else {
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
processor_dirty_ = true;
|
||||
@@ -139,60 +139,60 @@ void OCIOLutNode::InputValueChangedEvent(const QString &input, int element)
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::ConfigChanged()
|
||||
void OCIOLutNode::config_changed()
|
||||
{
|
||||
if (IsMainProcess()) {
|
||||
GenerateProcessor();
|
||||
if (is_main_process()) {
|
||||
generate_processor();
|
||||
} else {
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
processor_dirty_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void OCIOLutNode::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Ensure the processor is up-to-date before the base class emits the color
|
||||
// transform job. This is especially important in the render worker, where
|
||||
// processor creation is deferred until the first render.
|
||||
EnsureProcessor();
|
||||
ensure_processor();
|
||||
|
||||
super::Value(value, globals, table);
|
||||
super::value(value, globals, table);
|
||||
}
|
||||
|
||||
void OCIOLutNode::GenerateProcessor()
|
||||
void OCIOLutNode::generate_processor()
|
||||
{
|
||||
EnsureProcessor();
|
||||
ensure_processor();
|
||||
|
||||
// The processor has changed. In the main GUI process, refresh the viewer by
|
||||
// invalidating the cache and cancelling background cache jobs.
|
||||
// Invalidating first ensures any in-flight renders that complete afterwards
|
||||
// won't write stale frames back. The worker process uses QGuiApplication and
|
||||
// has no RenderManager/PreviewAutoCacher, so skip this step to avoid crashing.
|
||||
if (IsMainProcess()) {
|
||||
InvalidateAll(kTextureInput);
|
||||
if (is_main_process()) {
|
||||
invalidate_all(k_texture_input);
|
||||
if (RenderManager *rm = RenderManager::instance()) {
|
||||
if (PreviewAutoCacher *cacher = rm->GetCacher()) {
|
||||
cacher->CancelVideoTasks(false);
|
||||
if (PreviewAutoCacher *cacher = rm->get_cacher()) {
|
||||
cacher->cancel_video_tasks(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOLutNode::EnsureProcessor() const
|
||||
void OCIOLutNode::ensure_processor() const
|
||||
{
|
||||
QMutexLocker locker(&gen_mutex_);
|
||||
|
||||
if (!processor_dirty_ && last_processor_ &&
|
||||
GetStandardValue(kFileInput).toString() == last_path_ &&
|
||||
ReadDirectionInput(this) == last_direction_) {
|
||||
get_standard_value(k_file_input).toString() == last_path_ &&
|
||||
read_direction_input(this) == last_direction_) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateProcessorFromInputs();
|
||||
create_processor_from_inputs();
|
||||
}
|
||||
|
||||
void OCIOLutNode::SetLastError(const QString &error) const
|
||||
void OCIOLutNode::set_last_error(const QString &error) const
|
||||
{
|
||||
if (last_error_ == error) {
|
||||
return;
|
||||
@@ -202,12 +202,12 @@ void OCIOLutNode::SetLastError(const QString &error) const
|
||||
|
||||
// Make the error visible to the user instead of failing silently, but only
|
||||
// from the main process (the render worker has no status bar)
|
||||
if (!error.isEmpty() && IsMainProcess() && Core::instance()) {
|
||||
Core::instance()->ShowStatusBarMessage(error, 10000);
|
||||
if (!error.isEmpty() && is_main_process() && Core::instance()) {
|
||||
Core::instance()->show_status_bar_message(error, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
bool OCIOLutNode::create_processor_from_inputs() const
|
||||
{
|
||||
if (!manager()) {
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
@@ -218,8 +218,8 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString path = GetStandardValue(kFileInput).toString();
|
||||
const int direction = ReadDirectionInput(this);
|
||||
const QString path = get_standard_value(k_file_input).toString();
|
||||
const int direction = read_direction_input(this);
|
||||
|
||||
if (path.isEmpty()) {
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
@@ -227,7 +227,7 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(QString());
|
||||
set_last_error(QString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,19 +245,19 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(tr("OCIO LUT: file does not exist: %1").arg(path));
|
||||
set_last_error(tr("OCIO LUT: file does not exist: %1").arg(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString suffix = info.suffix();
|
||||
if (!LUTLibrary::IsSupportedExtension(suffix)) {
|
||||
if (!LUTLibrary::is_supported_extension(suffix)) {
|
||||
qWarning() << "Unsupported OCIO LUT file extension:" << path;
|
||||
const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
|
||||
last_processor_.reset();
|
||||
last_path_.clear();
|
||||
last_direction_ = -1;
|
||||
processor_dirty_ = false;
|
||||
SetLastError(
|
||||
set_last_error(
|
||||
tr("OCIO LUT: unsupported LUT file extension (expected .cube or "
|
||||
".3dl): %1")
|
||||
.arg(path));
|
||||
@@ -267,29 +267,29 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
|
||||
ColorProcessorPtr processor;
|
||||
try {
|
||||
const bool forward = static_cast<ColorProcessor::Direction>(
|
||||
direction) == ColorProcessor::kNormal;
|
||||
direction) == ColorProcessor::k_normal;
|
||||
qDebug() << "OCIOLutNode: creating processor for" << path
|
||||
<< "direction=" << direction
|
||||
<< "ocio_dir=" << (forward ? "FORWARD" : "INVERSE")
|
||||
<< "process=" << (IsMainProcess() ? "main" : "worker");
|
||||
<< "process=" << (is_main_process() ? "main" : "worker");
|
||||
|
||||
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
|
||||
ocio::FileTransformRcPtr transform = ocio::FileTransform::Create();
|
||||
transform->setSrc(path.toUtf8().constData());
|
||||
transform->setInterpolation(OCIO::INTERP_LINEAR);
|
||||
transform->setDirection(forward ? OCIO::TRANSFORM_DIR_FORWARD :
|
||||
OCIO::TRANSFORM_DIR_INVERSE);
|
||||
transform->setInterpolation(ocio::INTERP_LINEAR);
|
||||
transform->setDirection(forward ? ocio::TRANSFORM_DIR_FORWARD :
|
||||
ocio::TRANSFORM_DIR_INVERSE);
|
||||
|
||||
processor = ColorProcessor::Create(
|
||||
manager()->GetConfig()->getProcessor(transform));
|
||||
processor = ColorProcessor::create(
|
||||
manager()->get_config()->getProcessor(transform));
|
||||
} catch (const std::exception &e) {
|
||||
qWarning() << "OCIO LUT processor error:" << e.what();
|
||||
processor = nullptr;
|
||||
}
|
||||
|
||||
if (!processor) {
|
||||
SetLastError(tr("OCIO LUT: failed to load LUT file: %1").arg(path));
|
||||
set_last_error(tr("OCIO LUT: failed to load LUT file: %1").arg(path));
|
||||
} else {
|
||||
SetLastError(QString());
|
||||
set_last_error(QString());
|
||||
}
|
||||
|
||||
last_path_ = path;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OCIOLUTNODE_H
|
||||
#define OCIOLUTNODE_H
|
||||
#ifndef OAK_OCIOLUTNODE_H
|
||||
#define OAK_OCIOLUTNODE_H
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
@@ -36,19 +36,19 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(OCIOLutNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
virtual void InputValueChangedEvent(const QString &input,
|
||||
int element) override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kFileInput;
|
||||
static const QString kDirectionInput;
|
||||
static const QString k_file_input;
|
||||
static const QString k_direction_input;
|
||||
|
||||
/**
|
||||
* @brief Human-readable description of why no LUT processor is active
|
||||
@@ -63,14 +63,14 @@ public:
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void ConfigChanged() override;
|
||||
virtual void config_changed() override;
|
||||
|
||||
private:
|
||||
void GenerateProcessor();
|
||||
void EnsureProcessor() const;
|
||||
bool CreateProcessorFromInputs() const;
|
||||
void generate_processor();
|
||||
void ensure_processor() const;
|
||||
bool create_processor_from_inputs() const;
|
||||
|
||||
void SetLastError(const QString &error) const;
|
||||
void set_last_error(const QString &error) const;
|
||||
|
||||
mutable QMutex gen_mutex_;
|
||||
mutable bool processor_dirty_ = true;
|
||||
@@ -82,4 +82,4 @@ private:
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#endif // OCIOLUTNODE_H
|
||||
#endif // OAK_OCIOLUTNODE_H
|
||||
|
||||
@@ -31,92 +31,92 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString ThreeWayColorNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString ThreeWayColorNode::kShadowsColorInput =
|
||||
const QString ThreeWayColorNode::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString ThreeWayColorNode::k_shadows_color_input =
|
||||
QStringLiteral("shadows_color_in");
|
||||
const QString ThreeWayColorNode::kMidtonesColorInput =
|
||||
const QString ThreeWayColorNode::k_midtones_color_input =
|
||||
QStringLiteral("midtones_color_in");
|
||||
const QString ThreeWayColorNode::kHighlightsColorInput =
|
||||
const QString ThreeWayColorNode::k_highlights_color_input =
|
||||
QStringLiteral("highlights_color_in");
|
||||
const QString ThreeWayColorNode::kShadowsAmountInput =
|
||||
const QString ThreeWayColorNode::k_shadows_amount_input =
|
||||
QStringLiteral("shadows_amount_in");
|
||||
const QString ThreeWayColorNode::kMidtonesAmountInput =
|
||||
const QString ThreeWayColorNode::k_midtones_amount_input =
|
||||
QStringLiteral("midtones_amount_in");
|
||||
const QString ThreeWayColorNode::kHighlightsAmountInput =
|
||||
const QString ThreeWayColorNode::k_highlights_amount_input =
|
||||
QStringLiteral("highlights_amount_in");
|
||||
const QString ThreeWayColorNode::kLumaCoefficientsInput =
|
||||
const QString ThreeWayColorNode::k_luma_coefficients_input =
|
||||
QStringLiteral("luma_coefficients_in");
|
||||
|
||||
ThreeWayColorNode::ThreeWayColorNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
|
||||
const QVariant neutral = QVariant::fromValue(Color(0.5, 0.5, 0.5, 1.0));
|
||||
AddInput(kShadowsColorInput, NodeValue::kColor, neutral);
|
||||
AddInput(kMidtonesColorInput, NodeValue::kColor, neutral);
|
||||
AddInput(kHighlightsColorInput, NodeValue::kColor, neutral);
|
||||
add_input(k_shadows_color_input, NodeValue::k_color, neutral);
|
||||
add_input(k_midtones_color_input, NodeValue::k_color, neutral);
|
||||
add_input(k_highlights_color_input, NodeValue::k_color, neutral);
|
||||
|
||||
AddInput(kShadowsAmountInput, NodeValue::kFloat, 1.0);
|
||||
AddInput(kMidtonesAmountInput, NodeValue::kFloat, 1.0);
|
||||
AddInput(kHighlightsAmountInput, NodeValue::kFloat, 1.0);
|
||||
add_input(k_shadows_amount_input, NodeValue::k_float, 1.0);
|
||||
add_input(k_midtones_amount_input, NodeValue::k_float, 1.0);
|
||||
add_input(k_highlights_amount_input, NodeValue::k_float, 1.0);
|
||||
|
||||
const QString min = QStringLiteral("min");
|
||||
const QString view = QStringLiteral("view");
|
||||
SetInputProperty(kShadowsAmountInput, min, 0.0);
|
||||
SetInputProperty(kMidtonesAmountInput, min, 0.0);
|
||||
SetInputProperty(kHighlightsAmountInput, min, 0.0);
|
||||
SetInputProperty(kShadowsAmountInput, view, FloatSlider::kPercentage);
|
||||
SetInputProperty(kMidtonesAmountInput, view, FloatSlider::kPercentage);
|
||||
SetInputProperty(kHighlightsAmountInput, view, FloatSlider::kPercentage);
|
||||
set_input_property(k_shadows_amount_input, min, 0.0);
|
||||
set_input_property(k_midtones_amount_input, min, 0.0);
|
||||
set_input_property(k_highlights_amount_input, min, 0.0);
|
||||
set_input_property(k_shadows_amount_input, view, FloatSlider::k_percentage);
|
||||
set_input_property(k_midtones_amount_input, view, FloatSlider::k_percentage);
|
||||
set_input_property(k_highlights_amount_input, view, FloatSlider::k_percentage);
|
||||
|
||||
SetEffectInput(kTextureInput);
|
||||
SetFlag(kVideoEffect);
|
||||
set_effect_input(k_texture_input);
|
||||
set_flag(k_video_effect);
|
||||
}
|
||||
|
||||
void ThreeWayColorNode::Retranslate()
|
||||
void ThreeWayColorNode::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kTextureInput, tr("Input"));
|
||||
SetInputName(kShadowsColorInput, tr("Shadows"));
|
||||
SetInputName(kMidtonesColorInput, tr("Midtones"));
|
||||
SetInputName(kHighlightsColorInput, tr("Highlights"));
|
||||
SetInputName(kShadowsAmountInput, tr("Shadows Amount"));
|
||||
SetInputName(kMidtonesAmountInput, tr("Midtones Amount"));
|
||||
SetInputName(kHighlightsAmountInput, tr("Highlights Amount"));
|
||||
set_input_name(k_texture_input, tr("Input"));
|
||||
set_input_name(k_shadows_color_input, tr("Shadows"));
|
||||
set_input_name(k_midtones_color_input, tr("Midtones"));
|
||||
set_input_name(k_highlights_color_input, tr("Highlights"));
|
||||
set_input_name(k_shadows_amount_input, tr("Shadows Amount"));
|
||||
set_input_name(k_midtones_amount_input, tr("Midtones Amount"));
|
||||
set_input_name(k_highlights_amount_input, tr("Highlights Amount"));
|
||||
}
|
||||
|
||||
ShaderCode ThreeWayColorNode::GetShaderCode(const ShaderRequest &request) const
|
||||
ShaderCode ThreeWayColorNode::get_shader_code(const ShaderRequest &request) const
|
||||
{
|
||||
Q_UNUSED(request)
|
||||
return ShaderCode(
|
||||
FileFunctions::ReadFileAsString(":/shaders/threewaycolor.frag"));
|
||||
FileFunctions::read_file_as_string(":/shaders/threewaycolor.frag"));
|
||||
}
|
||||
|
||||
void ThreeWayColorNode::Value(const NodeValueRow &value,
|
||||
void ThreeWayColorNode::value(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
Q_UNUSED(globals)
|
||||
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
if (TexturePtr tex = value[k_texture_input].to_texture()) {
|
||||
ShaderJob job(value);
|
||||
|
||||
double luma_coeffs[3] = { 0.0, 0.0, 0.0 };
|
||||
if (project() && project()->color_manager()) {
|
||||
project()->color_manager()->GetDefaultLumaCoefs(luma_coeffs);
|
||||
project()->color_manager()->get_default_luma_coefs(luma_coeffs);
|
||||
} else {
|
||||
luma_coeffs[0] = 0.2126;
|
||||
luma_coeffs[1] = 0.7152;
|
||||
luma_coeffs[2] = 0.0722;
|
||||
}
|
||||
job.Insert(kLumaCoefficientsInput,
|
||||
NodeValue(NodeValue::kVec3,
|
||||
job.insert(k_luma_coefficients_input,
|
||||
NodeValue(NodeValue::k_vec3,
|
||||
QVector3D(luma_coeffs[0], luma_coeffs[1],
|
||||
luma_coeffs[2])));
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
table->push(NodeValue::k_texture, tex->to_job(job), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef THREEWAYCOLORNODE_H
|
||||
#define THREEWAYCOLORNODE_H
|
||||
#ifndef OAK_THREEWAYCOLORNODE_H
|
||||
#define OAK_THREEWAYCOLORNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ThreeWayColorNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
virtual QString name() const override
|
||||
{
|
||||
return tr("Three-Way Color");
|
||||
}
|
||||
@@ -44,34 +44,34 @@ public:
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.threewaycolor");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
virtual QVector<CategoryID> category() const override
|
||||
{
|
||||
return { kCategoryColor };
|
||||
return { k_category_color };
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
virtual QString description() const override
|
||||
{
|
||||
return tr("Adjusts shadows, midtones, and highlights separately.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual ShaderCode
|
||||
GetShaderCode(const ShaderRequest &request) const override;
|
||||
get_shader_code(const ShaderRequest &request) const override;
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kShadowsColorInput;
|
||||
static const QString kMidtonesColorInput;
|
||||
static const QString kHighlightsColorInput;
|
||||
static const QString kShadowsAmountInput;
|
||||
static const QString kMidtonesAmountInput;
|
||||
static const QString kHighlightsAmountInput;
|
||||
static const QString kLumaCoefficientsInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_shadows_color_input;
|
||||
static const QString k_midtones_color_input;
|
||||
static const QString k_highlights_color_input;
|
||||
static const QString k_shadows_amount_input;
|
||||
static const QString k_midtones_amount_input;
|
||||
static const QString k_highlights_amount_input;
|
||||
static const QString k_luma_coefficients_input;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // THREEWAYCOLORNODE_H
|
||||
#endif // OAK_THREEWAYCOLORNODE_H
|
||||
|
||||
Reference in New Issue
Block a user