moved several files around

Mostly moved classes that became node derivatives into the node/ folder.
This commit is contained in:
itsmattkc
2021-04-08 12:15:59 +10:00
parent 2791e8d738
commit cb75e37e77
115 changed files with 159 additions and 128 deletions
-2
View File
@@ -26,8 +26,6 @@ set(OLIVE_SOURCES
render/audioplaybackcache.h
render/color.cpp
render/color.h
render/colormanager.cpp
render/colormanager.h
render/colorprocessor.cpp
render/colorprocessor.h
render/colorprocessorcache.h
-307
View File
@@ -1,307 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "colormanager.h"
#include <QDir>
#include <QFloat16>
#include <QStandardPaths>
#include "common/define.h"
#include "common/filefunctions.h"
#include "config/config.h"
#include "core.h"
namespace olive {
const QString ColorManager::kConfigFilenameIn = QStringLiteral("config");
const QString ColorManager::kDefaultColorspaceIn = QStringLiteral("default_input");
const QString ColorManager::kReferenceSpaceIn = QStringLiteral("reference_space");
OCIO::ConstConfigRcPtr ColorManager::default_config_;
ColorManager::ColorManager() :
config_(nullptr)
{
// Filename input
AddInput(kConfigFilenameIn, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
// Colorspace input
AddInput(kDefaultColorspaceIn, NodeValue::kCombo, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
// Default reference space is scene linear
AddInput(kReferenceSpaceIn, NodeValue::kCombo, 0, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
// Set config to our built-in default
SetConfig(GetDefaultConfig());
SetDefaultInputColorSpace(QStringLiteral("sRGB OETF"));
}
OCIO::ConstConfigRcPtr ColorManager::GetConfig() const
{
return config_;
}
OCIO::ConstConfigRcPtr ColorManager::CreateConfigFromFile(const QString &filename)
{
OCIO_SET_C_LOCALE_FOR_SCOPE;
return OCIO::Config::CreateFromFile(filename.toUtf8());
}
QString ColorManager::GetConfigFilename() const
{
return GetStandardValue(kConfigFilenameIn).toString();
}
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
{
return default_config_;
}
void ColorManager::SetUpDefaultConfig()
{
if (!qgetenv("OCIO").isEmpty()) {
// Attempt to set config from "OCIO" environment variable
try {
OCIO_SET_C_LOCALE_FOR_SCOPE;
default_config_ = OCIO::Config::CreateFromEnv();
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"));
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
dir,
true);
qDebug() << "Extracting default OCIO config to" << dir;
{
OCIO_SET_C_LOCALE_FOR_SCOPE;
default_config_ = CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")));
}
}
void ColorManager::SetConfigFilename(const QString &filename)
{
SetStandardValue(kConfigFilenameIn, filename);
}
QStringList ColorManager::ListAvailableDisplays()
{
QStringList displays;
int number_of_displays = config_->getNumDisplays();
for (int i=0;i<number_of_displays;i++) {
displays.append(config_->getDisplay(i));
}
return displays;
}
QString ColorManager::GetDefaultDisplay()
{
return config_->getDefaultDisplay();
}
QStringList ColorManager::ListAvailableViews(QString display)
{
QStringList views;
int number_of_views = config_->getNumViews(display.toUtf8());
for (int i=0;i<number_of_views;i++) {
views.append(config_->getView(display.toUtf8(), i));
}
return views;
}
QString ColorManager::GetDefaultView(const QString &display)
{
return config_->getDefaultView(display.toUtf8());
}
QStringList ColorManager::ListAvailableLooks()
{
QStringList looks;
int number_of_looks = config_->getNumLooks();
for (int i=0;i<number_of_looks;i++) {
looks.append(config_->getLookNameByIndex(i));
}
return looks;
}
QStringList ColorManager::ListAvailableColorspaces() const
{
return ListAvailableColorspaces(config_);
}
QString ColorManager::GetDefaultInputColorSpace() const
{
return ListAvailableColorspaces().at(GetStandardValue(kDefaultColorspaceIn).toInt());
}
void ColorManager::SetDefaultInputColorSpace(const QString &s)
{
SetStandardValue(kDefaultColorspaceIn, ListAvailableColorspaces().indexOf(s));
}
QString ColorManager::GetReferenceColorSpace() const
{
ReferenceSpace ref_space = static_cast<ReferenceSpace>(GetStandardValue(kReferenceSpaceIn).toInt());
if (ref_space == kCompositingLog) {
return OCIO::ROLE_COMPOSITING_LOG;
} else {
return OCIO::ROLE_SCENE_LINEAR;
}
}
QString ColorManager::GetCompliantColorSpace(const QString &s)
{
if (ListAvailableColorspaces().contains(s)) {
return s;
} else {
return GetDefaultInputColorSpace();
}
}
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();
// 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 looks still exists
if (!ListAvailableLooks().contains(look)) {
look.clear();
}
return ColorTransform(display, view, look);
} else {
QString output = transform.output();
if (!ListAvailableColorspaces().contains(output)) {
output = GetDefaultInputColorSpace();
}
return ColorTransform(output);
}
}
QStringList ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config)
{
QStringList spaces;
int number_of_colorspaces = config->getNumColorSpaces();
for (int i=0;i<number_of_colorspaces;i++) {
spaces.append(config->getColorSpaceNameByIndex(i));
}
return spaces;
}
void ColorManager::GetDefaultLumaCoefs(double *rgb) const
{
config_->getDefaultLumaCoefs(rgb);
}
Color ColorManager::GetDefaultLumaCoefs() const
{
Color c;
// Just a default value, shouldn't be significant
c.set_alpha(1.0f);
// The float data in Color lines up with the "rgb" param of this function
GetDefaultLumaCoefs(c.data());
return c;
}
void ColorManager::Retranslate()
{
SetInputName(kConfigFilenameIn, tr("Configuration"));
SetInputName(kDefaultColorspaceIn, tr("Default Input"));
SetInputName(kReferenceSpaceIn, tr("Reference Space"));
SetComboBoxStrings(kReferenceSpaceIn, {tr("Scene Linear"), tr("Compositing Log")});
SetInputProperty(kConfigFilenameIn, QStringLiteral("placeholder"), tr("(built-in)"));
}
void ColorManager::InputValueChangedEvent(const QString &input, int element)
{
Q_UNUSED(element)
if (input == kConfigFilenameIn) {
try {
SetConfig(OCIO::Config::CreateFromFile(GetConfigFilename().toUtf8()));
} catch (OCIO::Exception&) {}
}
}
ColorManager::SetLocale::SetLocale(const char* new_locale)
{
old_locale_ = setlocale(LC_NUMERIC, nullptr);
setlocale(LC_NUMERIC, new_locale);
}
ColorManager::SetLocale::~SetLocale()
{
setlocale(LC_NUMERIC, old_locale_.toUtf8());
}
void ColorManager::SetConfig(OCIO::ConstConfigRcPtr config)
{
config_ = config;
SetComboBoxStrings(kDefaultColorspaceIn, ListAvailableColorspaces());
}
}
-149
View File
@@ -1,149 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COLORSERVICE_H
#define COLORSERVICE_H
#include <memory>
#include <QMutex>
#include "codec/frame.h"
#include "colorprocessor.h"
#include "node/node.h"
#define OCIO_SET_C_LOCALE_FOR_SCOPE ColorManager::SetLocale d("C")
namespace olive {
class ColorManager : public Node
{
Q_OBJECT
public:
ColorManager();
virtual QString Name() const override
{
return tr("Color Manager");
}
virtual QString id() const override
{
return QStringLiteral("org.olivevideoeditor.Olive.colormanager");
}
virtual QVector<CategoryID> Category() const override
{
return {kCategoryColor};
}
virtual QString Description() const override
{
return tr("Color management configuration for project.");
}
virtual Node* copy() const override
{
return new ColorManager();
}
OCIO::ConstConfigRcPtr GetConfig() const;
static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString& filename);
QString GetConfigFilename() const;
static OCIO::ConstConfigRcPtr GetDefaultConfig();
static void SetUpDefaultConfig();
void SetConfigFilename(const QString& filename);
QStringList ListAvailableDisplays();
QString GetDefaultDisplay();
QStringList ListAvailableViews(QString display);
QString GetDefaultView(const QString& display);
QStringList ListAvailableLooks();
QStringList ListAvailableColorspaces() const;
QString GetDefaultInputColorSpace() const;
void SetDefaultInputColorSpace(const QString& s);
QString GetReferenceColorSpace() const;
QString GetCompliantColorSpace(const QString& s);
ColorTransform GetCompliantColorSpace(const ColorTransform& transform, bool force_display = false);
static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config);
void GetDefaultLumaCoefs(double *rgb) const;
Color GetDefaultLumaCoefs() const;
class SetLocale
{
public:
SetLocale(const char* new_locale);
~SetLocale();
private:
QString old_locale_;
};
QMutex* mutex()
{
return &mutex_;
}
static const QString kConfigFilenameIn;
static const QString kDefaultColorspaceIn;
static const QString kReferenceSpaceIn;
virtual void Retranslate() override;
protected:
virtual void InputValueChangedEvent(const QString &input, int element) override;
private:
enum ReferenceSpace {
kSceneLinear,
kCompositingLog
};
void SetConfig(OCIO::ConstConfigRcPtr config);
OCIO::ConstConfigRcPtr config_;
QMutex mutex_;
static OCIO::ConstConfigRcPtr default_config_;
};
}
#endif // COLORSERVICE_H
+1 -1
View File
@@ -22,7 +22,7 @@
#include "common/define.h"
#include "common/ocioutils.h"
#include "colormanager.h"
#include "node/color/colormanager/colormanager.h"
namespace olive {
+1 -1
View File
@@ -27,7 +27,7 @@
#include <QTimer>
#include "common/define.h"
#include "project/project.h"
#include "node/project/project.h"
namespace olive {
+1 -1
View File
@@ -21,7 +21,7 @@
#ifndef FOOTAGEJOB_H
#define FOOTAGEJOB_H
#include "project/item/footage/footage.h"
#include "node/project/footage/footage.h"
namespace olive {
+2 -2
View File
@@ -21,8 +21,8 @@
#include "playbackcache.h"
#include "node/output/viewer/viewer.h"
#include "project/item/sequence/sequence.h"
#include "project/project.h"
#include "node/project/project.h"
#include "node/project/sequence/sequence.h"
#include "render/diskmanager.h"
namespace olive {
+1 -1
View File
@@ -3,7 +3,7 @@
#include <QApplication>
#include <QtConcurrent/QtConcurrent>
#include "project/project.h"
#include "node/project/project.h"
#include "render/rendermanager.h"
#include "render/renderprocessor.h"
+2 -2
View File
@@ -5,10 +5,10 @@
#include "config/config.h"
#include "node/graph.h"
#include "node/color/colormanager/colormanager.h"
#include "node/node.h"
#include "node/output/viewer/viewer.h"
#include "project/project.h"
#include "render/colormanager.h"
#include "node/project/project.h"
#include "threading/threadticketwatcher.h"
namespace olive {
+1 -1
View File
@@ -25,7 +25,7 @@
#include <QVector3D>
#include <QVector4D>
#include "project/project.h"
#include "node/project/project.h"
#include "rendermanager.h"
namespace olive {
+1 -1
View File
@@ -6,7 +6,7 @@
#include "codec/decoder.h"
#include "common/rational.h"
#include "project/item/footage/footage.h"
#include "node/project/footage/footage.h"
#include "render/texture.h"
namespace olive {