inverted macro so OCIO support is enabled by default

This commit is contained in:
itsmattkc
2019-03-11 02:45:02 +11:00
parent 938224214c
commit a800904580
11 changed files with 188 additions and 162 deletions
+15
View File
@@ -451,6 +451,7 @@ void PreferencesDialog::browse_ocio_config()
QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration"));
if (!fn.isEmpty()) {
ocio_config_file->setText(fn);
enable_color_management->setChecked(true);
}
}
@@ -697,6 +698,14 @@ void PreferencesDialog::setup_ui() {
row = 0;
#ifdef NO_OCIO
QLabel* no_ocio_available_lbl = new QLabel(tr("<html><b>Color management is unavailable because Olive was "
"compiled without OpenColorIO support.</b></html>"));
no_ocio_available_lbl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
color_management_layout->addWidget(no_ocio_available_lbl, row, 0, 1, 3);
row++;
#endif
enable_color_management = new QCheckBox(tr("Enable Color Management"));
enable_color_management->setChecked(olive::CurrentConfig.enable_color_management);
color_management_layout->addWidget(enable_color_management, row, 0, 1, 3);
@@ -713,6 +722,12 @@ void PreferencesDialog::setup_ui() {
connect(ocio_config_browse_btn, SIGNAL(clicked(bool)), this, SLOT(browse_ocio_config()));
color_management_layout->addWidget(ocio_config_browse_btn, row, 2);
#ifdef NO_OCIO
enable_color_management->setEnabled(false);
ocio_config_file->setEnabled(false);
ocio_config_browse_btn->setEnabled(false);
#endif
tabWidget->addTab(color_management_tab, tr("Color Management"));
// Shortcuts
+127 -127
View File
@@ -20,7 +20,7 @@
#include "frei0reffect.h"
#ifndef NOFREI0R
#ifndef NO_FREI0R
#include <QMessageBox>
#include <QDir>
@@ -31,184 +31,184 @@ typedef f0r_instance_t (*f0rConstructFunc)(unsigned int width, unsigned int heig
typedef int (*f0rInitFunc) ();
typedef void (*f0rDeinitFunc) ();
typedef void (*f0rUpdateFunc) (f0r_instance_t instance,
double time, const uint32_t* inframe, uint32_t* outframe);
double time, const uint32_t* inframe, uint32_t* outframe);
typedef void (*f0rDestructFunc)(f0r_instance_t instance);
typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info);
typedef void (*f0rSetParamValue) (f0r_instance_t instance,
f0r_param_t param, int param_index);
f0r_param_t param, int param_index);
Frei0rEffect::Frei0rEffect(Clip* c, const EffectMeta *em) :
Effect(c, em),
open(false)
Effect(c, em),
open(false)
{
enable_image = true;
enable_image = true;
// Windows DLL loading routine
QString dll_fn = QDir(em->path).filePath(em->filename);
// Windows DLL loading routine
QString dll_fn = QDir(em->path).filePath(em->filename);
handle = LibLoad(dll_fn);
if(handle == nullptr) {
QString dll_error;
handle = LibLoad(dll_fn);
if(handle == nullptr) {
QString dll_error;
#ifdef _WIN32
DWORD dll_err = GetLastError();
dll_error = QString::number(dll_err);
DWORD dll_err = GetLastError();
dll_error = QString::number(dll_err);
#elif __linux__
dll_error = dlerror();
dll_error = dlerror();
#endif
qCritical() << "Failed to load Frei0r plugin" << dll_fn << "-" << dll_error;
qCritical() << "Failed to load Frei0r plugin" << dll_fn << "-" << dll_error;
QString msg_err = tr("Failed to load Frei0r plugin \"%1\": %2").arg(dll_fn, dll_error);
QString msg_err = tr("Failed to load Frei0r plugin \"%1\": %2").arg(dll_fn, dll_error);
#ifdef _WIN32
if (dll_err == 193) {
if (dll_err == 193) {
#ifdef _WIN64
msg_err += "\n\n" + tr("NOTE: You can't load 32-bit Frei0r plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive.");
msg_err += "\n\n" + tr("NOTE: You can't load 32-bit Frei0r plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive.");
#elif _WIN32
msg_err += "\n\n" + tr("NOTE: You can't load 64-bit Frei0r plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive.");
msg_err += "\n\n" + tr("NOTE: You can't load 64-bit Frei0r plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive.");
#endif
}
}
#endif
QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err);
QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err);
return;
}
return;
}
f0rInitFunc init = reinterpret_cast<f0rInitFunc>(LibAddress(handle, "f0r_init"));
init();
f0rInitFunc init = reinterpret_cast<f0rInitFunc>(LibAddress(handle, "f0r_init"));
init();
construct_module();
construct_module();
f0r_plugin_info_t info;
f0rGetPluginInfo info_func = reinterpret_cast<f0rGetPluginInfo>(LibAddress(handle, "f0r_get_plugin_info"));
info_func(&info);
f0r_plugin_info_t info;
f0rGetPluginInfo info_func = reinterpret_cast<f0rGetPluginInfo>(LibAddress(handle, "f0r_get_plugin_info"));
info_func(&info);
param_count = info.num_params;
param_count = info.num_params;
get_param_info = reinterpret_cast<f0rGetParamInfo>(LibAddress(handle, "f0r_get_param_info"));
for (int i=0;i<param_count;i++) {
f0r_param_info_t param_info;
get_param_info(&param_info, i);
get_param_info = reinterpret_cast<f0rGetParamInfo>(LibAddress(handle, "f0r_get_param_info"));
for (int i=0;i<param_count;i++) {
f0r_param_info_t param_info;
get_param_info(&param_info, i);
if (param_info.type >= 0 && param_info.type <= F0R_PARAM_STRING) {
EffectRow* row = add_row(param_info.name);
switch (param_info.type) {
case F0R_PARAM_BOOL:
row->add_field(EFFECT_FIELD_BOOL, QString::number(i));
break;
case F0R_PARAM_DOUBLE:
{
EffectField* f = row->add_field(EFFECT_FIELD_DOUBLE, QString::number(i));
f->set_double_minimum_value(0);
f->set_double_maximum_value(100);
}
break;
case F0R_PARAM_COLOR:
row->add_field(EFFECT_FIELD_COLOR, QString::number(i));
break;
case F0R_PARAM_POSITION:
{
EffectField* fx = row->add_field(EFFECT_FIELD_DOUBLE, QString("%1X").arg(QString::number(i)));
fx->set_double_minimum_value(0);
fx->set_double_maximum_value(100);
EffectField* fy = row->add_field(EFFECT_FIELD_DOUBLE, QString("%1Y").arg(QString::number(i)));
fy->set_double_minimum_value(0);
fy->set_double_maximum_value(100);
}
break;
case F0R_PARAM_STRING:
row->add_field(EFFECT_FIELD_STRING, QString::number(i));
break;
}
}
}
if (param_info.type >= 0 && param_info.type <= F0R_PARAM_STRING) {
EffectRow* row = add_row(param_info.name);
switch (param_info.type) {
case F0R_PARAM_BOOL:
row->add_field(EFFECT_FIELD_BOOL, QString::number(i));
break;
case F0R_PARAM_DOUBLE:
{
EffectField* f = row->add_field(EFFECT_FIELD_DOUBLE, QString::number(i));
f->set_double_minimum_value(0);
f->set_double_maximum_value(100);
}
break;
case F0R_PARAM_COLOR:
row->add_field(EFFECT_FIELD_COLOR, QString::number(i));
break;
case F0R_PARAM_POSITION:
{
EffectField* fx = row->add_field(EFFECT_FIELD_DOUBLE, QString("%1X").arg(QString::number(i)));
fx->set_double_minimum_value(0);
fx->set_double_maximum_value(100);
EffectField* fy = row->add_field(EFFECT_FIELD_DOUBLE, QString("%1Y").arg(QString::number(i)));
fy->set_double_minimum_value(0);
fy->set_double_maximum_value(100);
}
break;
case F0R_PARAM_STRING:
row->add_field(EFFECT_FIELD_STRING, QString::number(i));
break;
}
}
}
}
Frei0rEffect::~Frei0rEffect() {
if (handle != nullptr) {
f0rDeinitFunc deinit = reinterpret_cast<f0rDeinitFunc>(LibAddress(handle, "f0r_deinit"));
deinit();
if (handle != nullptr) {
f0rDeinitFunc deinit = reinterpret_cast<f0rDeinitFunc>(LibAddress(handle, "f0r_deinit"));
deinit();
LibClose(handle);
}
LibClose(handle);
}
}
void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *output, int) {
f0rUpdateFunc update_func = reinterpret_cast<f0rUpdateFunc>(LibAddress(handle, "f0r_update"));
f0rUpdateFunc update_func = reinterpret_cast<f0rUpdateFunc>(LibAddress(handle, "f0r_update"));
for (int i=0;i<param_count;i++) {
EffectRow* param_row = row(i);
for (int i=0;i<param_count;i++) {
EffectRow* param_row = row(i);
f0r_param_info_t param_info;
get_param_info(&param_info, i);
f0r_param_info_t param_info;
get_param_info(&param_info, i);
f0rSetParamValue set_param = reinterpret_cast<f0rSetParamValue>(LibAddress(handle, "f0r_set_param_value"));
switch (param_info.type) {
case F0R_PARAM_BOOL:
{
double b = param_row->field(0)->get_bool_value(timecode);
set_param(instance, &b, i);
}
break;
case F0R_PARAM_DOUBLE:
{
double d = param_row->field(0)->get_double_value(timecode)*0.01;
set_param(instance, &d, i);
}
break;
case F0R_PARAM_COLOR:
{
QColor qcolor = param_row->field(0)->get_color_value(timecode);;
f0rSetParamValue set_param = reinterpret_cast<f0rSetParamValue>(LibAddress(handle, "f0r_set_param_value"));
switch (param_info.type) {
case F0R_PARAM_BOOL:
{
double b = param_row->field(0)->get_bool_value(timecode);
set_param(instance, &b, i);
}
break;
case F0R_PARAM_DOUBLE:
{
double d = param_row->field(0)->get_double_value(timecode)*0.01;
set_param(instance, &d, i);
}
break;
case F0R_PARAM_COLOR:
{
QColor qcolor = param_row->field(0)->get_color_value(timecode);;
f0r_param_color fcolor;
fcolor.r = float(qcolor.redF());
fcolor.g = float(qcolor.greenF());
fcolor.b = float(qcolor.blueF());
f0r_param_color fcolor;
fcolor.r = float(qcolor.redF());
fcolor.g = float(qcolor.greenF());
fcolor.b = float(qcolor.blueF());
set_param(instance, &fcolor, i);
}
break;
case F0R_PARAM_POSITION:
{
f0r_param_position pos;
pos.x = param_row->field(0)->get_double_value(timecode);
pos.y = param_row->field(1)->get_double_value(timecode);
set_param(instance, &pos, i);
}
break;
case F0R_PARAM_STRING:
{
QByteArray bytes = param_row->field(0)->get_string_value(timecode).toUtf8();
char* byte_data = bytes.data();
set_param(instance, &byte_data, i);
}
break;
}
}
set_param(instance, &fcolor, i);
}
break;
case F0R_PARAM_POSITION:
{
f0r_param_position pos;
pos.x = param_row->field(0)->get_double_value(timecode);
pos.y = param_row->field(1)->get_double_value(timecode);
set_param(instance, &pos, i);
}
break;
case F0R_PARAM_STRING:
{
QByteArray bytes = param_row->field(0)->get_string_value(timecode).toUtf8();
char* byte_data = bytes.data();
set_param(instance, &byte_data, i);
}
break;
}
}
update_func(instance, timecode, reinterpret_cast<uint32_t*>(input), reinterpret_cast<uint32_t*>(output));
update_func(instance, timecode, reinterpret_cast<uint32_t*>(input), reinterpret_cast<uint32_t*>(output));
}
void Frei0rEffect::refresh() {
destruct_module();
construct_module();
destruct_module();
construct_module();
}
void Frei0rEffect::destruct_module() {
if (open) {
f0rDestructFunc destruct = reinterpret_cast<f0rDestructFunc>(LibAddress(handle, "f0r_destruct"));
destruct(instance);
if (open) {
f0rDestructFunc destruct = reinterpret_cast<f0rDestructFunc>(LibAddress(handle, "f0r_destruct"));
destruct(instance);
open = false;
}
open = false;
}
}
void Frei0rEffect::construct_module() {
f0rConstructFunc construct = reinterpret_cast<f0rConstructFunc>(LibAddress(handle, "f0r_construct"));
f0rConstructFunc construct = reinterpret_cast<f0rConstructFunc>(LibAddress(handle, "f0r_construct"));
instance = construct(parent_clip->media_width(), parent_clip->media_height());
open = true;
open = true;
}
#endif
+13 -13
View File
@@ -21,7 +21,7 @@
#ifndef FREI0REFFECT_H
#define FREI0REFFECT_H
#ifndef NOFREI0R
#ifndef NO_FREI0R
#include "project/effect.h"
@@ -30,25 +30,25 @@
#include "io/crossplatformlib.h"
typedef void (*f0rGetParamInfo)(f0r_param_info_t * info,
int param_index );
int param_index );
class Frei0rEffect : public Effect {
Q_OBJECT
Q_OBJECT
public:
Frei0rEffect(Clip* c, const EffectMeta* em);
~Frei0rEffect();
~Frei0rEffect();
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
virtual void refresh();
virtual void refresh();
private:
ModulePtr handle;
f0r_instance_t instance;
int param_count;
f0rGetParamInfo get_param_info;
void destruct_module();
void construct_module();
bool open;
ModulePtr handle;
f0r_instance_t instance;
int param_count;
f0rGetParamInfo get_param_info;
void destruct_module();
void construct_module();
bool open;
};
#endif
-4
View File
@@ -20,8 +20,6 @@
#include "vsthost.h"
#ifndef NOVST
// adapted from http://teragonaudio.com/article/How-to-make-your-own-VST-host.html
#include <QPushButton>
@@ -396,5 +394,3 @@ void VSTHost::change_plugin() {
}
show_interface_btn->setEnabled(plugin != nullptr);
}
#endif
+7 -1
View File
@@ -294,7 +294,7 @@ TRANSLATIONS += \
win32 {
RC_FILE = packaging/windows/resources.rc
LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 -luser32
contains(DEFINES, OLIVE_OCIO) {
!contains(DEFINES, NO_OCIO) {
LIBS += -lOpenColorIO
}
}
@@ -303,11 +303,17 @@ mac {
LIBS += -L/usr/local/lib -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -framework CoreFoundation
ICON = packaging/macos/olive.icns
INCLUDEPATH = /usr/local/include
!contains(DEFINES, NO_OCIO) {
LIBS += -lOpenColorIO
}
}
unix:!mac {
CONFIG += link_pkgconfig
PKGCONFIG += libavutil libavformat libavcodec libavfilter libswscale libswresample
!contains(DEFINES, NO_OCIO) {
LIBS += -lOpenColorIO
}
}
unix:!mac:!haiku {
LIBS += -ldl
+1 -3
View File
@@ -86,10 +86,8 @@ EffectPtr Effect::Create(Clip* c, const EffectMeta* em) {
case EFFECT_INTERNAL_SHAKE: return EffectPtr(new ShakeEffect(c, em));
case EFFECT_INTERNAL_CORNERPIN: return EffectPtr(new CornerPinEffect(c, em));
case EFFECT_INTERNAL_FILLLEFTRIGHT: return EffectPtr(new FillLeftRightEffect(c, em));
#ifndef NOVST
case EFFECT_INTERNAL_VST: return EffectPtr(new VSTHost(c, em));
#endif
#ifndef NOFREI0R
#ifndef NO_FREI0R
case EFFECT_INTERNAL_FREI0R: return EffectPtr(new Frei0rEffect(c, em));
#endif
}
+3 -5
View File
@@ -35,7 +35,7 @@
QMutex olive::effects_loaded;
#ifndef NOFREI0R
#ifndef NO_FREI0R
#include <frei0r.h>
typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info);
#endif
@@ -59,11 +59,9 @@ void load_internal_effects() {
em.internal = EFFECT_INTERNAL_PAN;
olive::effects.append(em);
#ifndef NOVST
em.name = "VST Plugin 2.x";
em.internal = EFFECT_INTERNAL_VST;
olive::effects.append(em);
#endif
em.name = "Tone";
em.internal = EFFECT_INTERNAL_TONE;
@@ -201,7 +199,7 @@ void init_effects() {
init_thread->start();
}
#ifndef NOFREI0R
#ifndef NO_FREI0R
void load_frei0r_effects_worker(const QString& dir, EffectMeta& em, QVector<QString>& loaded_names) {
QDir search_dir(dir);
if (search_dir.exists()) {
@@ -401,7 +399,7 @@ void EffectInit::run() {
qInfo() << "Initializing effects...";
load_internal_effects();
load_shader_effects();
#ifndef NOFREI0R
#ifndef NO_FREI0R
load_frei0r_effects();
#endif
GenerateBlendingShader();
+2 -2
View File
@@ -29,7 +29,7 @@ extern "C" {
#include <QDesktopWidget>
#include <QDebug>
#ifdef OLIVE_OCIO
#ifndef NO_OCIO
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;
#endif
@@ -376,7 +376,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
fbo_switcher = !fbo_switcher;
}
#ifdef OLIVE_OCIO
#ifndef NO_OCIO
// convert to linear colorspace
if (olive::CurrentConfig.enable_color_management)
{
+2
View File
@@ -193,6 +193,7 @@ struct ComposeSequenceParams {
*/
GLuint backend_attachment2;
#ifndef NO_OCIO
/**
* @brief OpenGL shader containing OpenColorIO shader information
*/
@@ -202,6 +203,7 @@ struct ComposeSequenceParams {
* @brief OpenGL texture containing LUT obtained form OpenColorIO
*/
GLuint ocio_lut_texture;
#endif
};
/**
+9 -1
View File
@@ -26,7 +26,7 @@
#include <QFileInfo>
#include <QDebug>
#ifdef OLIVE_OCIO
#ifndef NO_OCIO
#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;
#endif
@@ -107,6 +107,7 @@ void RenderThread::run() {
blend_mode_program->link();
}
#ifndef NO_OCIO
// If there's no OpenColorIO shader, create it now
if (olive::CurrentConfig.enable_color_management
&& (ocio_shader == nullptr || ocio_loaded_config != olive::CurrentConfig.ocio_config_path)) {
@@ -114,6 +115,7 @@ void RenderThread::run() {
set_up_ocio();
}
#endif
// draw frame
paint();
@@ -153,6 +155,7 @@ const char * g_fragShaderText = ""
" gl_FragColor = OCIODisplay(col, tex2);\n"
"}\n";
#ifndef NO_OCIO
void RenderThread::set_up_ocio()
{
functions.initializeOpenGLFunctions();
@@ -254,6 +257,7 @@ void RenderThread::destroy_ocio()
delete ocio_shader;
ocio_shader = nullptr;
}
#endif
void RenderThread::paint() {
// set up compose_sequence() parameters
@@ -266,7 +270,9 @@ void RenderThread::paint() {
params.wait_for_mutexes = true;
params.playback_speed = 1;
params.blend_mode_program = blend_mode_program;
#ifndef NO_OCIO
params.ocio_shader = ocio_shader;
#endif
params.backend_buffer1 = back_buffer_1.buffer();
params.backend_buffer2 = back_buffer_2.buffer();
params.backend_attachment1 = back_buffer_1.texture();
@@ -400,7 +406,9 @@ void RenderThread::delete_ctx() {
delete_shaders();
delete_buffers();
#ifndef NO_OCIO
destroy_ocio();
#endif
}
delete ctx;
+9 -6
View File
@@ -72,9 +72,18 @@ private:
void delete_buffers();
void delete_shaders();
#ifndef NO_OCIO
// OpenColorIO functions
void set_up_ocio();
void destroy_ocio();
// OpenColorIO variables
float ocio_lut_data[OCIO_NUM_3D_ENTRIES];
GLuint ocio_lut_texture;
QOpenGLShaderProgram* ocio_shader;
QString ocio_loaded_config;
#endif
FramebufferObject front_buffer_1;
QMutex front_mutex1;
@@ -97,12 +106,6 @@ private:
FramebufferObject back_buffer_1;
FramebufferObject back_buffer_2;
// OpenColorIO variables
float ocio_lut_data[OCIO_NUM_3D_ENTRIES];
GLuint ocio_lut_texture;
QOpenGLShaderProgram* ocio_shader;
QString ocio_loaded_config;
SequencePtr seq;
int divider;
int tex_width;