Merge pull request #339 from olive-editor/frei0r

added frei0r support for windows/mac/linux
This commit is contained in:
itsmattkc
2019-01-21 11:55:13 +11:00
committed by GitHub
31 changed files with 1067 additions and 662 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ before_install:
- sudo apt-get update -qq - sudo apt-get update -qq
install: install:
- sudo apt-get -y install qt59base qt59multimedia libavformat-dev libavcodec-dev libavfilter-dev libavutil-dev libswscale-dev libswresample-dev - sudo apt-get -y install qt59base qt59multimedia libavformat-dev libavcodec-dev libavfilter-dev libavutil-dev libswscale-dev libswresample-dev frei0r-plugins-dev frei0r-plugins
- source /opt/qt*/bin/qt*-env.sh - source /opt/qt*/bin/qt*-env.sh
script: script:
+2 -2
View File
@@ -2,12 +2,12 @@ Source: olive-editor
Section: video Section: video
Priority: optional Priority: optional
Maintainer: Olive Team <itsmattkc@gmail.com> Maintainer: Olive Team <itsmattkc@gmail.com>
Build-Depends: debhelper (>=9), build-essential, qt5-default, qtmultimedia5-dev, libqt5opengl5-dev, libqt5multimedia5-plugins, libavformat-dev, libavcodec-dev, libavutil-dev, libswscale-dev, libswresample-dev, libavfilter-dev, libpostproc-dev, git Build-Depends: debhelper (>=9), build-essential, qt5-default, qtmultimedia5-dev, libqt5opengl5-dev, libqt5multimedia5-plugins, libavformat-dev, libavcodec-dev, libavutil-dev, libswscale-dev, libswresample-dev, libavfilter-dev, libpostproc-dev, git, frei0r-plugins-dev
Standards-Version: 3.9.6 Standards-Version: 3.9.6
Homepage: https://olivevideoeditor.org/ Homepage: https://olivevideoeditor.org/
Package: olive-editor Package: olive-editor
Architecture: any Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, libqt5multimedia5-plugins Depends: ${misc:Depends}, ${shlibs:Depends}, libqt5multimedia5-plugins, frei0r-plugins
Description: Nonlinear video editor focused on performance and simplicity Description: Nonlinear video editor focused on performance and simplicity
+176
View File
@@ -0,0 +1,176 @@
#include "frei0reffect.h"
#ifndef NOFREI0R
#include <QMessageBox>
#include <QDir>
typedef f0r_instance_t (*f0rConstructFunc)(unsigned int width, unsigned int height);
typedef int (*f0rInitFunc) ();
typedef void (*f0rDeinitFunc) ();
typedef void (*f0rUpdateFunc) (f0r_instance_t instance,
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);
Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) {
enable_image = true;
// Windows DLL loading routine
QString dll_fn = QDir(em->path).filePath(em->filename);
handle = LibLoad(dll_fn);
if(handle == nullptr) {
QString dll_error;
#ifdef _WIN32
DWORD dll_err = GetLastError();
dll_error = QString::number(dll_err);
#elif __linux__
dll_error = dlerror();
#endif
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);
#ifdef _WIN32
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.");
#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.");
#endif
}
#endif
QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err);
return;
}
f0rInitFunc init = reinterpret_cast<f0rInitFunc>(LibAddress(handle, "f0r_init"));
init();
f0rConstructFunc construct = reinterpret_cast<f0rConstructFunc>(LibAddress(handle, "f0r_construct"));
instance = construct(1920, 1080);
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;
// qDebug() << "Frei0r Name:" << info.name;
// qDebug() << "Frei0r Param Count:" << info.num_params;
// qDebug() << "Frei0r Explanation:" << info.explanation;
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;
}
}
}
}
Frei0rEffect::~Frei0rEffect() {
if (handle != nullptr) {
f0rDestructFunc destruct = reinterpret_cast<f0rDestructFunc>(LibAddress(handle, "f0r_destruct"));
destruct(instance);
f0rDeinitFunc deinit = reinterpret_cast<f0rDeinitFunc>(LibAddress(handle, "f0r_deinit"));
deinit();
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"));
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);
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());
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));
}
#endif
+31
View File
@@ -0,0 +1,31 @@
#ifndef FREI0REFFECT_H
#define FREI0REFFECT_H
#ifndef NOFREI0R
#include "project/effect.h"
#include <frei0r.h>
#include "io/crossplatformlib.h"
typedef void (*f0rGetParamInfo)(f0r_param_info_t * info,
int param_index );
class Frei0rEffect : public Effect {
Q_OBJECT
public:
Frei0rEffect(Clip* c, const EffectMeta* em);
~Frei0rEffect();
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
private:
ModulePtr handle;
f0r_instance_t instance;
int param_count;
f0rGetParamInfo get_param_info;
};
#endif
#endif // FREI0REFFECT_H
+4 -4
View File
@@ -5,15 +5,15 @@ extern "C" {
} }
enum QOpenGLTexture::PixelFormat get_gl_pix_fmt_from_av(int format) { enum QOpenGLTexture::PixelFormat get_gl_pix_fmt_from_av(int format) {
switch (format) { /*switch (format) {
case AV_PIX_FMT_RGB24: return QOpenGLTexture::RGB; case AV_PIX_FMT_RGB24: return QOpenGLTexture::RGB;
} }*/
return QOpenGLTexture::RGBA; return QOpenGLTexture::RGBA;
} }
enum QOpenGLTexture::TextureFormat get_gl_tex_fmt_from_av(int format) { enum QOpenGLTexture::TextureFormat get_gl_tex_fmt_from_av(int format) {
switch (format) { /*switch (format) {
case AV_PIX_FMT_RGB24: return QOpenGLTexture::RGB8_UNorm; case AV_PIX_FMT_RGB24: return QOpenGLTexture::RGB8_UNorm;
} }*/
return QOpenGLTexture::RGBA8_UNorm; return QOpenGLTexture::RGBA8_UNorm;
} }
+2 -2
View File
@@ -3,7 +3,7 @@
#include <QString> #include <QString>
#define SAVE_VERSION 190104 // YYMMDD #define SAVE_VERSION 190120 // YYMMDD
#define MIN_SAVE_VERSION 190104 // lowest compatible project version #define MIN_SAVE_VERSION 190104 // lowest compatible project version
#define TIMECODE_DROP 0 #define TIMECODE_DROP 0
@@ -63,7 +63,7 @@ struct Config {
bool seek_also_selects; bool seek_also_selects;
QString css_path; QString css_path;
int effect_textbox_lines; int effect_textbox_lines;
bool use_software_fallback; bool use_software_fallback;
void load(QString path); void load(QString path);
void save(QString path); void save(QString path);
+23
View File
@@ -0,0 +1,23 @@
#include "crossplatformlib.h"
#include <QDebug>
ModulePtr LibLoad(const QString &filename) {
#ifdef _WIN32
LPCWSTR dll_fn_w = reinterpret_cast<const wchar_t*>(filename.utf16());
return LoadLibrary(dll_fn_w);
#elif defined(__linux__) || defined(__APPLE__)
return dlopen(filename.toUtf8(), RTLD_LAZY);
#else
qWarning() << "Olive doesn't know how to open dynamic libraries on this platform, external libraries will not be functional";
return nullptr;
#endif
}
QStringList LibFilter() {
#ifdef _WIN32
return QStringList("*.dll");
#elif defined(__linux__) || defined(__APPLE__)
return {"*.so", "*.dylib"};
#endif
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef CROSSPLATFORMLIB_H
#define CROSSPLATFORMLIB_H
#include <QString>
#ifdef _WIN32
#include <Windows.h>
#define LibAddress GetProcAddress
#define LibClose FreeModule
#define ModulePtr HMODULE
#elif defined(__linux__) || defined(__APPLE__)
#include <dlfcn.h>
#define LibAddress dlsym
#define LibClose dlclose
#define ModulePtr void*
#endif
ModulePtr LibLoad(const QString& filename);
QStringList LibFilter();
#endif // CROSSPLATFORMLIB_H
+46 -18
View File
@@ -18,7 +18,6 @@
#include "debug.h" #include "debug.h"
#include <QFile> #include <QFile>
#include <QMessageBox>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
struct TransitionData { struct TransitionData {
@@ -35,11 +34,21 @@ LoadThread::LoadThread(LoadDialog* l, bool a) : ld(l), autorecovery(a), cancelle
connect(this, SIGNAL(error()), this, SLOT(error_func())); connect(this, SIGNAL(error()), this, SLOT(error_func()));
connect(this, SIGNAL(start_create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*)), this, SLOT(create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*))); connect(this, SIGNAL(start_create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*)), this, SLOT(create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*)));
connect(this, SIGNAL(start_create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool)), this, SLOT(create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool))); connect(this, SIGNAL(start_create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool)), this, SLOT(create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool)));
connect(this, SIGNAL(start_question(const QString&, const QString &, int)), this, SLOT(question_func(const QString &, const QString &, int)));
} }
const EffectMeta* get_meta_from_name(const QString& name) { const EffectMeta* get_meta_from_name(const QString& input) {
int split_index = input.indexOf('/');
QString category;
if (split_index > -1) {
category = input.left(split_index);
}
QString name = input.mid(split_index + 1);
for (int j=0;j<effects.size();j++) { for (int j=0;j<effects.size();j++) {
if (effects.at(j).name == name) { if (effects.at(j).name == name
&& (effects.at(j).category == category
|| category.isEmpty())) {
return &effects.at(j); return &effects.at(j);
} }
} }
@@ -152,13 +161,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
if (stream.name() == root_search) { if (stream.name() == root_search) {
if (type == LOAD_TYPE_VERSION) { if (type == LOAD_TYPE_VERSION) {
int proj_version = stream.readElementText().toInt(); int proj_version = stream.readElementText().toInt();
if (proj_version < MIN_SAVE_VERSION && proj_version > SAVE_VERSION) { if (proj_version < MIN_SAVE_VERSION || proj_version > SAVE_VERSION) {
if (QMessageBox::warning( emit start_question(
mainWindow, tr("Version Mismatch"),
tr("Version Mismatch"), tr("This project was saved in a different version of Olive and may not be fully compatible with this version. Would you like to attempt loading it anyway?"),
tr("This project was saved in a different version of Olive and may not be fully compatible with this version. Would you like to attempt loading it anyway?"), QMessageBox::Yes | QMessageBox::No
QMessageBox::Yes, );
QMessageBox::No) == QMessageBox::No) { waitCond.wait(&mutex);
if (question_btn == QMessageBox::No) {
show_err = false; show_err = false;
return false; return false;
} }
@@ -444,11 +454,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
if (!found) { if (!found) {
correct_clip->linked.removeAt(j); correct_clip->linked.removeAt(j);
j--; j--;
if (QMessageBox::warning(mainWindow,
tr("Invalid Clip Link"), emit start_question(
tr("This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?"), tr("Invalid Clip Link"),
QMessageBox::Yes, tr("This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?"),
QMessageBox::No) == QMessageBox::No) { QMessageBox::Yes | QMessageBox::No
);
waitCond.wait(&mutex);
if (question_btn == QMessageBox::No) {
delete s; delete s;
return false; return false;
} }
@@ -565,10 +578,14 @@ void LoadThread::run() {
cont = !cancelled; cont = !cancelled;
// find project file version // find project file version
cont = load_worker(file, stream, LOAD_TYPE_VERSION); if (cont) {
cont = load_worker(file, stream, LOAD_TYPE_VERSION);
}
// find project's internal URL // find project's internal URL
cont = load_worker(file, stream, LOAD_TYPE_URL); if (cont) {
cont = load_worker(file, stream, LOAD_TYPE_URL);
}
// load folders first // load folders first
if (cont) { if (cont) {
@@ -605,7 +622,6 @@ void LoadThread::run() {
xml_error = true; xml_error = true;
emit error(); emit error();
cont = false; cont = false;
} else { } else {
// attach nested sequence clips to their sequences // attach nested sequence clips to their sequences
for (int i=0;i<loaded_clips.size();i++) { for (int i=0;i<loaded_clips.size();i++) {
@@ -626,6 +642,9 @@ void LoadThread::run() {
for (int i=0;i<loaded_media_items.size();i++) { for (int i=0;i<loaded_media_items.size();i++) {
panel_project->start_preview_generator(loaded_media_items.at(i), true); panel_project->start_preview_generator(loaded_media_items.at(i), true);
} }
} else {
error_str = tr("User aborted loading");
emit error();
} }
file.close(); file.close();
@@ -638,6 +657,15 @@ void LoadThread::cancel() {
cancelled = true; cancelled = true;
} }
void LoadThread::question_func(const QString &title, const QString &text, int buttons) {
question_btn = QMessageBox::warning(
mainWindow,
title,
text,
static_cast<enum QMessageBox::StandardButton>(buttons));
waitCond.wakeAll();
}
void LoadThread::error_func() { void LoadThread::error_func() {
if (xml_error) { if (xml_error) {
qCritical() << "Error parsing XML." << error_str; qCritical() << "Error parsing XML." << error_str;
+5
View File
@@ -6,6 +6,7 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QMutex> #include <QMutex>
#include <QWaitCondition> #include <QWaitCondition>
#include <QMessageBox>
class Media; class Media;
struct Footage; struct Footage;
@@ -23,12 +24,14 @@ public:
void run(); void run();
void cancel(); void cancel();
signals: signals:
void start_question(const QString &title, const QString &text, int buttons);
void success(); void success();
void error(); void error();
void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta); void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
void report_progress(int p); void report_progress(int p);
private slots: private slots:
void question_func(const QString &title, const QString &text, int buttons);
void error_func(); void error_func();
void success_func(); void success_func();
void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
@@ -67,6 +70,8 @@ private:
bool cancelled; bool cancelled;
bool xml_error; bool xml_error;
QMessageBox::StandardButton question_btn;
}; };
#endif // LOADTHREAD_H #endif // LOADTHREAD_H
+9
View File
@@ -32,3 +32,12 @@ QString get_config_path() {
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
} }
} }
QList<QString> get_effects_paths() {
QList<QString> effects_paths;
effects_paths.append(get_app_dir() + "/effects");
effects_paths.append(get_app_dir() + "/../share/olive-editor/effects");
QString env_path(qgetenv("OLIVE_EFFECTS_PATH"));
if (!env_path.isEmpty()) effects_paths.append(env_path);
return effects_paths;
}
+1
View File
@@ -6,5 +6,6 @@
QString get_app_dir(); QString get_app_dir();
QString get_data_path(); QString get_data_path();
QString get_config_path(); QString get_config_path();
QList<QString> get_effects_paths();
#endif // PATH_H #endif // PATH_H
+7 -4
View File
@@ -20,9 +20,7 @@ int main(int argc, char *argv[]) {
bool launch_fullscreen = false; bool launch_fullscreen = false;
QString load_proj; QString load_proj;
#ifndef NODEBUG bool use_internal_logger = true;
qInstallMessageHandler(debug_message_handler);
#endif
if (argc > 1) { if (argc > 1) {
for (int i=1;i<argc;i++) { for (int i=1;i<argc;i++) {
@@ -40,7 +38,8 @@ int main(int argc, char *argv[]) {
launch_fullscreen = true; launch_fullscreen = true;
} else if (!strcmp(argv[i], "--disable-shaders")) { } else if (!strcmp(argv[i], "--disable-shaders")) {
shaders_are_enabled = false; shaders_are_enabled = false;
} else if (!strcmp(argv[i], "--no-debug")) {
use_internal_logger = false;
} else { } else {
printf("[ERROR] Unknown argument '%s'\n", argv[1]); printf("[ERROR] Unknown argument '%s'\n", argv[1]);
return 1; return 1;
@@ -51,6 +50,10 @@ int main(int argc, char *argv[]) {
} }
} }
if (use_internal_logger) {
qInstallMessageHandler(debug_message_handler);
}
// init ffmpeg subsystem // init ffmpeg subsystem
av_register_all(); av_register_all();
avfilter_register_all(); avfilter_register_all();
+9 -2
View File
@@ -128,7 +128,10 @@ SOURCES += \
ui/renderthread.cpp \ ui/renderthread.cpp \
ui/renderfunctions.cpp \ ui/renderfunctions.cpp \
ui/viewerwindow.cpp \ ui/viewerwindow.cpp \
project/projectfilter.cpp project/projectfilter.cpp \
effects/internal/frei0reffect.cpp \
project/effectloaders.cpp \
io/crossplatformlib.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
@@ -224,7 +227,10 @@ HEADERS += \
ui/renderthread.h \ ui/renderthread.h \
ui/renderfunctions.h \ ui/renderfunctions.h \
ui/viewerwindow.h \ ui/viewerwindow.h \
project/projectfilter.h project/projectfilter.h \
effects/internal/frei0reffect.h \
project/effectloaders.h \
io/crossplatformlib.h
FORMS += FORMS +=
@@ -245,6 +251,7 @@ mac {
unix:!mac { unix:!mac {
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += libavutil libavformat libavcodec libavfilter libswscale libswresample PKGCONFIG += libavutil libavformat libavcodec libavfilter libswscale libswresample
LIBS += -ldl
} }
RESOURCES += \ RESOURCES += \
+6 -6
View File
@@ -59,13 +59,13 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) {
left_tool_layout->addStretch(); left_tool_layout->addStretch();
linear_button = new QPushButton(tr("Linear")); linear_button = new QPushButton(tr("Linear"));
linear_button->setProperty("type", KEYFRAME_TYPE_LINEAR); linear_button->setProperty("type", EFFECT_KEYFRAME_LINEAR);
linear_button->setCheckable(true); linear_button->setCheckable(true);
bezier_button = new QPushButton(tr("Bezier")); bezier_button = new QPushButton(tr("Bezier"));
bezier_button->setProperty("type", KEYFRAME_TYPE_BEZIER); bezier_button->setProperty("type", EFFECT_KEYFRAME_BEZIER);
bezier_button->setCheckable(true); bezier_button->setCheckable(true);
hold_button = new QPushButton(tr("Hold")); hold_button = new QPushButton(tr("Hold"));
hold_button->setProperty("type", KEYFRAME_TYPE_HOLD); hold_button->setProperty("type", EFFECT_KEYFRAME_HOLD);
hold_button->setCheckable(true); hold_button->setCheckable(true);
center_tool_layout->addStretch(); center_tool_layout->addStretch();
@@ -216,11 +216,11 @@ void GraphEditor::select_all() {
void GraphEditor::set_key_button_enabled(bool e, int type) { void GraphEditor::set_key_button_enabled(bool e, int type) {
linear_button->setEnabled(e); linear_button->setEnabled(e);
linear_button->setChecked(type == KEYFRAME_TYPE_LINEAR); linear_button->setChecked(type == EFFECT_KEYFRAME_LINEAR);
bezier_button->setEnabled(e); bezier_button->setEnabled(e);
bezier_button->setChecked(type == KEYFRAME_TYPE_BEZIER); bezier_button->setChecked(type == EFFECT_KEYFRAME_BEZIER);
hold_button->setEnabled(e); hold_button->setEnabled(e);
hold_button->setChecked(type == KEYFRAME_TYPE_HOLD); hold_button->setChecked(type == EFFECT_KEYFRAME_HOLD);
} }
void GraphEditor::passthrough_slider_value() { void GraphEditor::passthrough_slider_value() {
+1
View File
@@ -9,6 +9,7 @@
#include "project/transition.h" #include "project/transition.h"
#include "io/config.h" #include "io/config.h"
#include "grapheditor.h" #include "grapheditor.h"
#include "project/effectloaders.h"
#include "debug.h" #include "debug.h"
#include <QScrollBar> #include <QScrollBar>
+4 -4
View File
@@ -33,7 +33,7 @@ bool audio_rendering = false;
bool recording = false; bool recording = false;
qint8 audio_ibuffer[audio_ibuffer_size]; qint8 audio_ibuffer[audio_ibuffer_size];
int audio_ibuffer_read = 0; unsigned long audio_ibuffer_read = 0;
long audio_ibuffer_frame = 0; long audio_ibuffer_frame = 0;
double audio_ibuffer_timecode = 0; double audio_ibuffer_timecode = 0;
@@ -114,9 +114,9 @@ int current_audio_freq() {
return audio_rendering ? sequence->audio_frequency : audio_output->format().sampleRate(); return audio_rendering ? sequence->audio_frequency : audio_output->format().sampleRate();
} }
int get_buffer_offset_from_frame(double framerate, long frame) { unsigned long get_buffer_offset_from_frame(double framerate, long frame) {
if (frame >= audio_ibuffer_frame) { if (frame >= audio_ibuffer_frame) {
return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); return static_cast<unsigned long>(((double(frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO));
} else { } else {
qWarning() << "Invalid values passed to get_buffer_offset_from_frame"; qWarning() << "Invalid values passed to get_buffer_offset_from_frame";
return 0; return 0;
@@ -168,7 +168,7 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) {
// send audio to device // send audio to device
int actual_write = audio_io_device->write((const char*) audio_ibuffer+offset, max); int actual_write = audio_io_device->write((const char*) audio_ibuffer+offset, max);
int audio_ibuffer_limit = audio_ibuffer_read + actual_write; unsigned long audio_ibuffer_limit = audio_ibuffer_read + actual_write;
// send samples to audio monitor cache // send samples to audio monitor cache
// TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT // TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT
+2 -2
View File
@@ -37,7 +37,7 @@ extern QMutex audio_write_lock;
#define audio_ibuffer_size 192000 #define audio_ibuffer_size 192000
extern qint8 audio_ibuffer[audio_ibuffer_size]; extern qint8 audio_ibuffer[audio_ibuffer_size];
extern int audio_ibuffer_read; extern unsigned long audio_ibuffer_read;
extern long audio_ibuffer_frame; extern long audio_ibuffer_frame;
extern double audio_ibuffer_timecode; extern double audio_ibuffer_timecode;
extern bool audio_scrub; extern bool audio_scrub;
@@ -51,7 +51,7 @@ bool is_audio_device_set();
void init_audio(); void init_audio();
void stop_audio(); void stop_audio();
int get_buffer_offset_from_frame(double framerate, long frame); unsigned long get_buffer_offset_from_frame(double framerate, long frame);
bool start_recording(); bool start_recording();
void stop_recording(); void stop_recording();
+3 -2
View File
@@ -364,7 +364,8 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector<Clip*>& nests) {
if (frame->nb_samples == 0) { if (frame->nb_samples == 0) {
break; break;
} else { } else {
long buffer_timeline_out = get_buffer_offset_from_frame(c->sequence->frame_rate, timeline_out); unsigned long buffer_timeline_out = get_buffer_offset_from_frame(c->sequence->frame_rate, timeline_out);
audio_write_lock.lock(); audio_write_lock.lock();
while (c->frame_sample_index < nb_bytes while (c->frame_sample_index < nb_bytes
@@ -767,7 +768,7 @@ void open_clip_worker(Clip* clip) {
}*/ }*/
enum AVPixelFormat valid_pix_fmts[] = { enum AVPixelFormat valid_pix_fmts[] = {
AV_PIX_FMT_RGB24, // AV_PIX_FMT_RGB24,
AV_PIX_FMT_RGBA, AV_PIX_FMT_RGBA,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
+19 -10
View File
@@ -255,26 +255,35 @@ void get_clip_frame(Clip* c, long playhead, bool& texture_failed) {
int nb_components = av_pix_fmt_desc_get(static_cast<enum AVPixelFormat>(c->pix_fmt))->nb_components; int nb_components = av_pix_fmt_desc_get(static_cast<enum AVPixelFormat>(c->pix_fmt))->nb_components;
glPixelStorei(GL_UNPACK_ROW_LENGTH, target_frame->linesize[0]/nb_components); glPixelStorei(GL_UNPACK_ROW_LENGTH, target_frame->linesize[0]/nb_components);
bool copied = false; // 2 data buffers to ping-pong between
uint8_t* data = target_frame->data[0]; bool using_db_1 = true;
uint8_t* data_buffer_1 = target_frame->data[0];
uint8_t* data_buffer_2 = nullptr;
int frame_size; int frame_size;
for (int i=0;i<c->effects.size();i++) { for (int i=0;i<c->effects.size();i++) {
Effect* e = c->effects.at(i); Effect* e = c->effects.at(i);
if (e->enable_image) { if (e->enable_image && e->is_enabled()) {
if (!copied) { if (data_buffer_1 == target_frame->data[0]) {
frame_size = target_frame->linesize[0]*target_frame->height; frame_size = target_frame->linesize[0]*target_frame->height;
data = new uint8_t[frame_size];
memcpy(data, target_frame->data[0], frame_size); data_buffer_1 = new uint8_t[frame_size];
copied = true; data_buffer_2 = new uint8_t[frame_size];
memcpy(data_buffer_1, target_frame->data[0], frame_size);
} }
e->process_image(get_timecode(c, playhead), data, frame_size); e->process_image(get_timecode(c, playhead), using_db_1 ? data_buffer_1 : data_buffer_2, using_db_1 ? data_buffer_2 : data_buffer_1, frame_size);
using_db_1 = !using_db_1;
} }
} }
c->texture->setData(0, get_gl_pix_fmt_from_av(c->pix_fmt), QOpenGLTexture::UInt8, data); c->texture->setData(0, get_gl_pix_fmt_from_av(c->pix_fmt), QOpenGLTexture::UInt8, using_db_1 ? data_buffer_1 : data_buffer_2);
if (copied) delete [] data; if (data_buffer_1 != target_frame->data[0]) {
delete [] data_buffer_1;
delete [] data_buffer_2;
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
} }
+40 -40
View File
@@ -33,17 +33,17 @@ class QOpenGLTexture;
struct Clip struct Clip
{ {
Clip(Sequence* s); Clip(Sequence* s);
~Clip(); ~Clip();
Clip* copy(Sequence* s); Clip* copy(Sequence* s);
void reset_audio(); void reset_audio();
void reset(); void reset();
void refresh(); void refresh();
long get_clip_in_with_transition(); long get_clip_in_with_transition();
long get_timeline_in_with_transition(); long get_timeline_in_with_transition();
long get_timeline_out_with_transition(); long get_timeline_out_with_transition();
long getLength(); long getLength();
double getMediaFrameRate(); double getMediaFrameRate();
long getMaximumLength(); long getMaximumLength();
void recalculateMaxLength(); void recalculateMaxLength();
int getWidth(); int getWidth();
@@ -56,39 +56,39 @@ struct Clip
void queue_remove_earliest(); void queue_remove_earliest();
// timeline variables (should be copied in copy()) // timeline variables (should be copied in copy())
bool enabled; bool enabled;
long clip_in; long clip_in;
long timeline_in; long timeline_in;
long timeline_out; long timeline_out;
int track; int track;
QString name; QString name;
quint8 color_r; quint8 color_r;
quint8 color_g; quint8 color_g;
quint8 color_b; quint8 color_b;
Media* media; Media* media;
int media_stream; int media_stream;
double speed; double speed;
double cached_fr; double cached_fr;
bool reverse; bool reverse;
bool maintain_audio_pitch; bool maintain_audio_pitch;
bool autoscale; bool autoscale;
// other variables (should be deep copied/duplicated in copy()) // other variables (should be deep copied/duplicated in copy())
QList<Effect*> effects; QList<Effect*> effects;
QVector<int> linked; QVector<int> linked;
int opening_transition; int opening_transition;
Transition* get_opening_transition(); Transition* get_opening_transition();
int closing_transition; int closing_transition;
Transition* get_closing_transition(); Transition* get_closing_transition();
// media handling // media handling
AVFormatContext* formatCtx; AVFormatContext* formatCtx;
AVStream* stream; AVStream* stream;
AVCodec* codec; AVCodec* codec;
AVCodecContext* codecCtx; AVCodecContext* codecCtx;
AVPacket* pkt; AVPacket* pkt;
AVFrame* frame; AVFrame* frame;
AVDictionary* opts; AVDictionary* opts;
long calculated_length; long calculated_length;
// temporary variables // temporary variables
@@ -96,23 +96,23 @@ struct Clip
bool undeletable; bool undeletable;
bool reached_end; bool reached_end;
bool pkt_written; bool pkt_written;
bool open; bool open;
bool finished_opening; bool finished_opening;
bool replaced; bool replaced;
bool ignore_reverse; bool ignore_reverse;
int pix_fmt; int pix_fmt;
// caching functions // caching functions
bool use_existing_frame; bool use_existing_frame;
bool multithreaded; bool multithreaded;
Cacher* cacher; Cacher* cacher;
QWaitCondition can_cache; QWaitCondition can_cache;
int max_queue_size; int max_queue_size;
QVector<AVFrame*> queue; QVector<AVFrame*> queue;
QMutex queue_lock; QMutex queue_lock;
QMutex lock; QMutex lock;
QMutex open_lock; QMutex open_lock;
int64_t last_invalid_ts; int64_t last_invalid_ts;
// converters/filters // converters/filters
AVFilterGraph* filter_graph; AVFilterGraph* filter_graph;
@@ -121,15 +121,15 @@ struct Clip
// video playback variables // video playback variables
QOpenGLFramebufferObject** fbo; QOpenGLFramebufferObject** fbo;
QOpenGLTexture* texture; QOpenGLTexture* texture;
long texture_frame; long texture_frame;
// audio playback variables // audio playback variables
int64_t reverse_target; int64_t reverse_target;
int frame_sample_index; int frame_sample_index;
int audio_buffer_write; unsigned long audio_buffer_write;
bool audio_reset; bool audio_reset;
bool audio_just_reset; bool audio_just_reset;
long audio_target_frame; long audio_target_frame;
}; };
+11 -181
View File
@@ -32,6 +32,7 @@
#include "effects/internal/vsthostwin.h" #include "effects/internal/vsthostwin.h"
#endif #endif
#include "effects/internal/fillleftrighteffect.h" #include "effects/internal/fillleftrighteffect.h"
#include "effects/internal/frei0reffect.h"
#include <QCheckBox> #include <QCheckBox>
#include <QGridLayout> #include <QGridLayout>
@@ -49,10 +50,7 @@ bool shaders_are_enabled = true;
QVector<EffectMeta> effects; QVector<EffectMeta> effects;
Effect* create_effect(Clip* c, const EffectMeta* em) { Effect* create_effect(Clip* c, const EffectMeta* em) {
if (!em->filename.isEmpty()) { if (em->internal >= 0 && em->internal < EFFECT_INTERNAL_COUNT) {
// load effect from file
return new Effect(c, em);
} else if (em->internal >= 0 && em->internal < EFFECT_INTERNAL_COUNT) {
// must be an internal effect // must be an internal effect
switch (em->internal) { switch (em->internal) {
case EFFECT_INTERNAL_TRANSFORM: return new TransformEffect(c, em); case EFFECT_INTERNAL_TRANSFORM: return new TransformEffect(c, em);
@@ -68,8 +66,14 @@ Effect* create_effect(Clip* c, const EffectMeta* em) {
case EFFECT_INTERNAL_FILLLEFTRIGHT: return new FillLeftRightEffect(c, em); case EFFECT_INTERNAL_FILLLEFTRIGHT: return new FillLeftRightEffect(c, em);
#ifdef _WIN32 #ifdef _WIN32
case EFFECT_INTERNAL_VST: return new VSTHostWin(c, em); case EFFECT_INTERNAL_VST: return new VSTHostWin(c, em);
#endif
#ifndef NOFREI0R
case EFFECT_INTERNAL_FREI0R: return new Frei0rEffect(c, em);
#endif #endif
} }
} else if (!em->filename.isEmpty()) {
// load effect from file
return new Effect(c, em);
} else { } else {
qCritical() << "Invalid effect data"; qCritical() << "Invalid effect data";
QMessageBox::critical(mainWindow, QMessageBox::critical(mainWindow,
@@ -88,180 +92,6 @@ const EffectMeta* get_internal_meta(int internal_id, int type) {
return nullptr; return nullptr;
} }
void load_internal_effects() {
if (!shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional";
EffectMeta em;
// internal effects
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Volume";
em.internal = EFFECT_INTERNAL_VOLUME;
effects.append(em);
em.name = "Pan";
em.internal = EFFECT_INTERNAL_PAN;
effects.append(em);
#ifdef _WIN32
em.name = "VST Plugin 2.x";
em.internal = EFFECT_INTERNAL_VST;
effects.append(em);
#endif
em.name = "Tone";
em.internal = EFFECT_INTERNAL_TONE;
effects.append(em);
em.name = "Noise";
em.internal = EFFECT_INTERNAL_NOISE;
effects.append(em);
em.name = "Fill Left/Right";
em.internal = EFFECT_INTERNAL_FILLLEFTRIGHT;
effects.append(em);
em.subtype = EFFECT_TYPE_VIDEO;
em.name = "Transform";
em.category = "Distort";
em.internal = EFFECT_INTERNAL_TRANSFORM;
effects.append(em);
em.name = "Corner Pin";
em.internal = EFFECT_INTERNAL_CORNERPIN;
effects.append(em);
/*em.name = "Mask";
em.internal = EFFECT_INTERNAL_MASK;
effects.append(em);*/
em.name = "Shake";
em.internal = EFFECT_INTERNAL_SHAKE;
effects.append(em);
em.name = "Text";
em.category = "Render";
em.internal = EFFECT_INTERNAL_TEXT;
effects.append(em);
em.name = "Timecode";
em.internal = EFFECT_INTERNAL_TIMECODE;
effects.append(em);
em.name = "Solid";
em.internal = EFFECT_INTERNAL_SOLID;
effects.append(em);
// internal transitions
em.type = EFFECT_TYPE_TRANSITION;
em.category = "";
em.name = "Cross Dissolve";
em.internal = TRANSITION_INTERNAL_CROSSDISSOLVE;
effects.append(em);
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Linear Fade";
em.internal = TRANSITION_INTERNAL_LINEARFADE;
effects.append(em);
em.name = "Exponential Fade";
em.internal = TRANSITION_INTERNAL_EXPONENTIALFADE;
effects.append(em);
em.name = "Logarithmic Fade";
em.internal = TRANSITION_INTERNAL_LOGARITHMICFADE;
effects.append(em);
}
QList<QString> get_effects_paths() {
QList<QString> effects_paths;
effects_paths.append(get_app_dir() + "/effects");
effects_paths.append(get_app_dir() + "/../share/olive-editor/effects");
QString env_path(qgetenv("OLIVE_EFFECTS_PATH"));
if (!env_path.isEmpty()) effects_paths.append(env_path);
return effects_paths;
}
void load_shader_effects() {
QList<QString> effects_paths = get_effects_paths();
for (int h=0;h<effects_paths.size();h++) {
const QString& effects_path = effects_paths.at(h);
QDir effects_dir(effects_path);
if (effects_dir.exists()) {
QList<QString> entries = effects_dir.entryList(QStringList("*.xml"), QDir::Files);
for (int i=0;i<entries.size();i++) {
QFile file(effects_path + "/" + entries.at(i));
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Could not open" << entries.at(i);
return;
}
QXmlStreamReader reader(&file);
while (!reader.atEnd()) {
if (reader.name() == "effect") {
QString effect_name = "";
QString effect_cat = "";
const QXmlStreamAttributes attr = reader.attributes();
for (int j=0;j<attr.size();j++) {
if (attr.at(j).name() == "name") {
effect_name = attr.at(j).value().toString();
} else if (attr.at(j).name() == "category") {
effect_cat = attr.at(j).value().toString();
}
}
if (!effect_name.isEmpty()) {
EffectMeta em;
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.name = effect_name;
em.category = effect_cat;
em.filename = file.fileName();
em.path = effects_path;
em.internal = -1;
effects.append(em);
} else {
qCritical() << "Invalid effect found in" << entries.at(i);
}
break;
}
reader.readNext();
}
file.close();
}
}
}
}
void load_vst_effects() {
}
void init_effects() {
EffectInit* init_thread = new EffectInit();
QObject::connect(init_thread, SIGNAL(finished()), init_thread, SLOT(deleteLater()));
init_thread->start();
}
EffectInit::EffectInit() {
panel_effect_controls->effects_loaded.lock();
}
void EffectInit::run() {
qInfo() << "Initializing effects...";
load_internal_effects();
load_shader_effects();
load_vst_effects();
panel_effect_controls->effects_loaded.unlock();
qInfo() << "Finished initializing effects";
}
Effect::Effect(Clip* c, const EffectMeta *em) : Effect::Effect(Clip* c, const EffectMeta *em) :
parent_clip(c), parent_clip(c),
meta(em), meta(em),
@@ -290,7 +120,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
// set up UI from effect file // set up UI from effect file
container->setText(em->name); container->setText(em->name);
if (!em->filename.isEmpty()) { if (!em->filename.isEmpty() && em->internal == -1) {
QFile effect_file(em->filename); QFile effect_file(em->filename);
if (effect_file.open(QFile::ReadOnly)) { if (effect_file.open(QFile::ReadOnly)) {
QXmlStreamReader reader(&effect_file); QXmlStreamReader reader(&effect_file);
@@ -735,7 +565,7 @@ void Effect::load(QXmlStreamReader& stream) {
void Effect::custom_load(QXmlStreamReader &) {} void Effect::custom_load(QXmlStreamReader &) {}
void Effect::save(QXmlStreamWriter& stream) { void Effect::save(QXmlStreamWriter& stream) {
stream.writeAttribute("name", meta->name); stream.writeAttribute("name", meta->category + "/" + meta->name);
stream.writeAttribute("enabled", QString::number(is_enabled())); stream.writeAttribute("enabled", QString::number(is_enabled()));
for (int i=0;i<rows.size();i++) { for (int i=0;i<rows.size();i++) {
@@ -866,7 +696,7 @@ void Effect::endEffect() {
bound = false; bound = false;
} }
void Effect::process_image(double, uint8_t *, int) {} void Effect::process_image(double, uint8_t *input, uint8_t *output, int) {}
Effect* Effect::copy(Clip* c) { Effect* Effect::copy(Clip* c) {
Effect* copy = create_effect(c, meta); Effect* copy = create_effect(c, meta);
+30 -28
View File
@@ -38,38 +38,40 @@ extern bool shaders_are_enabled;
extern QVector<EffectMeta> effects; extern QVector<EffectMeta> effects;
double log_volume(double linear); double log_volume(double linear);
void init_effects();
Effect* create_effect(Clip* c, const EffectMeta *em); Effect* create_effect(Clip* c, const EffectMeta *em);
const EffectMeta* get_internal_meta(int internal_id, int type); const EffectMeta* get_internal_meta(int internal_id, int type);
#define EFFECT_TYPE_INVALID 0 enum EffectType {
#define EFFECT_TYPE_VIDEO 1 EFFECT_TYPE_INVALID,
#define EFFECT_TYPE_AUDIO 2 EFFECT_TYPE_VIDEO,
#define EFFECT_TYPE_EFFECT 3 EFFECT_TYPE_AUDIO,
#define EFFECT_TYPE_TRANSITION 4 EFFECT_TYPE_EFFECT,
EFFECT_TYPE_TRANSITION
};
#define EFFECT_KEYFRAME_LINEAR 0 enum EffectKeyframeType {
#define EFFECT_KEYFRAME_HOLD 1 EFFECT_KEYFRAME_LINEAR,
#define EFFECT_KEYFRAME_BEZIER 2 EFFECT_KEYFRAME_BEZIER,
EFFECT_KEYFRAME_HOLD
};
#define EFFECT_INTERNAL_TRANSFORM 0 enum EffectInternal {
#define EFFECT_INTERNAL_TEXT 1 EFFECT_INTERNAL_TRANSFORM,
#define EFFECT_INTERNAL_SOLID 2 EFFECT_INTERNAL_TEXT,
#define EFFECT_INTERNAL_NOISE 3 EFFECT_INTERNAL_SOLID,
#define EFFECT_INTERNAL_VOLUME 4 EFFECT_INTERNAL_NOISE,
#define EFFECT_INTERNAL_PAN 5 EFFECT_INTERNAL_VOLUME,
#define EFFECT_INTERNAL_TONE 6 EFFECT_INTERNAL_PAN,
#define EFFECT_INTERNAL_SHAKE 7 EFFECT_INTERNAL_TONE,
#define EFFECT_INTERNAL_TIMECODE 8 EFFECT_INTERNAL_SHAKE,
#define EFFECT_INTERNAL_MASK 9 EFFECT_INTERNAL_TIMECODE,
#define EFFECT_INTERNAL_FILLLEFTRIGHT 10 EFFECT_INTERNAL_MASK,
#define EFFECT_INTERNAL_VST 11 EFFECT_INTERNAL_FILLLEFTRIGHT,
#define EFFECT_INTERNAL_CORNERPIN 12 EFFECT_INTERNAL_VST,
#define EFFECT_INTERNAL_COUNT 13 EFFECT_INTERNAL_CORNERPIN,
EFFECT_INTERNAL_FREI0R,
#define KEYFRAME_TYPE_LINEAR 0 EFFECT_INTERNAL_COUNT
#define KEYFRAME_TYPE_BEZIER 1 };
#define KEYFRAME_TYPE_HOLD 2
struct GLTextureCoords { struct GLTextureCoords {
int grid_size; int grid_size;
@@ -156,7 +158,7 @@ public:
const char* ffmpeg_filter; const char* ffmpeg_filter;
virtual void process_image(double timecode, uint8_t* data, int size); virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
virtual void process_shader(double timecode, GLTextureCoords&); virtual void process_shader(double timecode, GLTextureCoords&);
virtual void process_coords(double timecode, GLTextureCoords& coords, int data); virtual void process_coords(double timecode, GLTextureCoords& coords, int data);
virtual GLuint process_superimpose(double timecode); virtual GLuint process_superimpose(double timecode);
+44 -44
View File
@@ -86,53 +86,53 @@ EffectField::EffectField(EffectRow *parent, int t, const QString &i) :
connect(efc, SIGNAL(changed()), this, SLOT(ui_element_change())); connect(efc, SIGNAL(changed()), this, SLOT(ui_element_change()));
} }
break; break;
} }
} }
double EffectField::get_validated_keyframe_handle(int key, bool post) { double EffectField::get_validated_keyframe_handle(int key, bool post) {
int comp_key = -1; int comp_key = -1;
// find keyframe before or after this one // find keyframe before or after this one
for (int i=0;i<keyframes.size();i++) { for (int i=0;i<keyframes.size();i++) {
if (i != key if (i != key
&& ((keyframes.at(i).time > keyframes.at(key).time) == post) && ((keyframes.at(i).time > keyframes.at(key).time) == post)
&& (comp_key == -1 && (comp_key == -1
|| ((keyframes.at(i).time < keyframes.at(comp_key).time) == post))) { || ((keyframes.at(i).time < keyframes.at(comp_key).time) == post))) {
// compare with next keyframe for post or previous frame for pre // compare with next keyframe for post or previous frame for pre
comp_key = i; comp_key = i;
} }
} }
double adjusted_key = post ? keyframes.at(key).post_handle_x : keyframes.at(key).pre_handle_x; double adjusted_key = post ? keyframes.at(key).post_handle_x : keyframes.at(key).pre_handle_x;
// if this is the earliest/latest keyframe, no validation is required // if this is the earliest/latest keyframe, no validation is required
if (comp_key == -1) { if (comp_key == -1) {
return adjusted_key; return adjusted_key;
} }
double comp = keyframes.at(comp_key).time - keyframes.at(key).time; double comp = keyframes.at(comp_key).time - keyframes.at(key).time;
// if comp keyframe is bezier, validate with its accompanying handle // if comp keyframe is bezier, validate with its accompanying handle
if (keyframes.at(comp_key).type == KEYFRAME_TYPE_BEZIER) { if (keyframes.at(comp_key).type == EFFECT_KEYFRAME_BEZIER) {
double relative_comp_handle = comp + (post ? keyframes.at(comp_key).pre_handle_x : keyframes.at(comp_key).post_handle_x); double relative_comp_handle = comp + (post ? keyframes.at(comp_key).pre_handle_x : keyframes.at(comp_key).post_handle_x);
// return an average // return an average
if ((post && keyframes.at(key).post_handle_x > relative_comp_handle) if ((post && keyframes.at(key).post_handle_x > relative_comp_handle)
|| (!post && keyframes.at(key).pre_handle_x < relative_comp_handle)) { || (!post && keyframes.at(key).pre_handle_x < relative_comp_handle)) {
adjusted_key = (adjusted_key + relative_comp_handle)*0.5; adjusted_key = (adjusted_key + relative_comp_handle)*0.5;
} }
} }
// don't let handle go beyond the compare keyframe's time // don't let handle go beyond the compare keyframe's time
if (post == (adjusted_key > comp)) { if (post == (adjusted_key > comp)) {
return comp; return comp;
} }
if (post == (adjusted_key < 0)) { if (post == (adjusted_key < 0)) {
return 0; return 0;
} }
// original value is valid // original value is valid
return adjusted_key; return adjusted_key;
} }
QVariant EffectField::get_previous_data() { QVariant EffectField::get_previous_data() {
@@ -162,7 +162,7 @@ QVariant EffectField::get_current_data() {
} }
double EffectField::frameToTimecode(long frame) { double EffectField::frameToTimecode(long frame) {
return ((double) frame / parent_row->parent_effect->parent_clip->sequence->frame_rate); return (double(frame) / parent_row->parent_effect->parent_clip->sequence->frame_rate);
} }
long EffectField::timecodeToFrame(double timecode) { long EffectField::timecodeToFrame(double timecode) {
@@ -242,22 +242,22 @@ QVariant EffectField::validate_keyframe_data(double timecode, bool async) {
double before_dbl = before_key.data.toDouble(); double before_dbl = before_key.data.toDouble();
double after_dbl = after_key.data.toDouble(); double after_dbl = after_key.data.toDouble();
if (before_key.type == KEYFRAME_TYPE_HOLD) { if (before_key.type == EFFECT_KEYFRAME_HOLD) {
// hold // hold
value = before_dbl; value = before_dbl;
} else if (before_key.type == KEYFRAME_TYPE_BEZIER || after_key.type == KEYFRAME_TYPE_BEZIER) { } else if (before_key.type == EFFECT_KEYFRAME_BEZIER || after_key.type == EFFECT_KEYFRAME_BEZIER) {
// bezier interpolation // bezier interpolation
if (before_key.type == KEYFRAME_TYPE_BEZIER && after_key.type == KEYFRAME_TYPE_BEZIER) { if (before_key.type == EFFECT_KEYFRAME_BEZIER && after_key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier // cubic bezier
double t = cubic_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+get_validated_keyframe_handle(before_keyframe, true), after_key.time+get_validated_keyframe_handle(after_keyframe, false), after_key.time); double t = cubic_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+get_validated_keyframe_handle(before_keyframe, true), after_key.time+get_validated_keyframe_handle(after_keyframe, false), after_key.time);
value = cubic_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl+after_key.pre_handle_y, after_dbl, t); value = cubic_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl+after_key.pre_handle_y, after_dbl, t);
} else if (after_key.type == KEYFRAME_TYPE_LINEAR) { // quadratic bezier } else if (after_key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one // last keyframe is the bezier one
double t = quad_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+get_validated_keyframe_handle(before_keyframe, true), after_key.time); double t = quad_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+get_validated_keyframe_handle(before_keyframe, true), after_key.time);
value = quad_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl, t); value = quad_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl, t);
} else { } else {
// this keyframe is the bezier one // this keyframe is the bezier one
double t = quad_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, after_key.time+get_validated_keyframe_handle(after_keyframe, false), after_key.time); double t = quad_t_from_x(timecode*parent_row->parent_effect->parent_clip->sequence->frame_rate, before_key.time, after_key.time+get_validated_keyframe_handle(after_keyframe, false), after_key.time);
value = quad_from_t(before_dbl, after_dbl+after_key.pre_handle_y, after_dbl, t); value = quad_from_t(before_dbl, after_dbl+after_key.pre_handle_y, after_dbl, t);
} }
} else { } else {
+248
View File
@@ -0,0 +1,248 @@
#include "effectloaders.h"
#include "project/effect.h"
#include "project/transition.h"
#include "io/path.h"
#include "panels/panels.h"
#include "panels/effectcontrols.h"
#include "io/crossplatformlib.h"
#include <QDir>
#include <QXmlStreamReader>
#include <QDebug>
#ifndef NOFREI0R
#include <frei0r.h>
typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info);
#endif
void load_internal_effects() {
if (!shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional";
EffectMeta em;
// internal effects
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Volume";
em.internal = EFFECT_INTERNAL_VOLUME;
effects.append(em);
em.name = "Pan";
em.internal = EFFECT_INTERNAL_PAN;
effects.append(em);
#ifdef _WIN32
em.name = "VST Plugin 2.x";
em.internal = EFFECT_INTERNAL_VST;
effects.append(em);
#endif
em.name = "Tone";
em.internal = EFFECT_INTERNAL_TONE;
effects.append(em);
em.name = "Noise";
em.internal = EFFECT_INTERNAL_NOISE;
effects.append(em);
em.name = "Fill Left/Right";
em.internal = EFFECT_INTERNAL_FILLLEFTRIGHT;
effects.append(em);
em.subtype = EFFECT_TYPE_VIDEO;
em.name = "Transform";
em.category = "Distort";
em.internal = EFFECT_INTERNAL_TRANSFORM;
effects.append(em);
em.name = "Corner Pin";
em.internal = EFFECT_INTERNAL_CORNERPIN;
effects.append(em);
/*em.name = "Mask";
em.internal = EFFECT_INTERNAL_MASK;
effects.append(em);*/
em.name = "Shake";
em.internal = EFFECT_INTERNAL_SHAKE;
effects.append(em);
em.name = "Text";
em.category = "Render";
em.internal = EFFECT_INTERNAL_TEXT;
effects.append(em);
em.name = "Timecode";
em.internal = EFFECT_INTERNAL_TIMECODE;
effects.append(em);
em.name = "Solid";
em.internal = EFFECT_INTERNAL_SOLID;
effects.append(em);
// internal transitions
em.type = EFFECT_TYPE_TRANSITION;
em.category = "";
em.name = "Cross Dissolve";
em.internal = TRANSITION_INTERNAL_CROSSDISSOLVE;
effects.append(em);
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Linear Fade";
em.internal = TRANSITION_INTERNAL_LINEARFADE;
effects.append(em);
em.name = "Exponential Fade";
em.internal = TRANSITION_INTERNAL_EXPONENTIALFADE;
effects.append(em);
em.name = "Logarithmic Fade";
em.internal = TRANSITION_INTERNAL_LOGARITHMICFADE;
effects.append(em);
}
void load_shader_effects() {
QList<QString> effects_paths = get_effects_paths();
for (int h=0;h<effects_paths.size();h++) {
const QString& effects_path = effects_paths.at(h);
QDir effects_dir(effects_path);
if (effects_dir.exists()) {
QList<QString> entries = effects_dir.entryList(QStringList("*.xml"), QDir::Files);
for (int i=0;i<entries.size();i++) {
QFile file(effects_path + "/" + entries.at(i));
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Could not open" << entries.at(i);
return;
}
QXmlStreamReader reader(&file);
while (!reader.atEnd()) {
if (reader.name() == "effect") {
QString effect_name = "";
QString effect_cat = "";
const QXmlStreamAttributes attr = reader.attributes();
for (int j=0;j<attr.size();j++) {
if (attr.at(j).name() == "name") {
effect_name = attr.at(j).value().toString();
} else if (attr.at(j).name() == "category") {
effect_cat = attr.at(j).value().toString();
}
}
if (!effect_name.isEmpty()) {
EffectMeta em;
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.name = effect_name;
em.category = effect_cat;
em.filename = file.fileName();
em.path = effects_path;
em.internal = -1;
effects.append(em);
} else {
qCritical() << "Invalid effect found in" << entries.at(i);
}
break;
}
reader.readNext();
}
file.close();
}
}
}
}
void init_effects() {
EffectInit* init_thread = new EffectInit();
QObject::connect(init_thread, SIGNAL(finished()), init_thread, SLOT(deleteLater()));
init_thread->start();
}
#ifndef NOFREI0R
void load_frei0r_effects_worker(const QString& dir, EffectMeta& em, QVector<QString>& loaded_names) {
QDir search_dir(dir);
if (search_dir.exists()) {
QList<QString> entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
for (int j=0;j<entry_list.size();j++) {
QString entry_path = search_dir.filePath(entry_list.at(j));
if (QFileInfo(entry_path).isDir()) {
load_frei0r_effects_worker(entry_path, em, loaded_names);
} else {
ModulePtr effect = LibLoad(entry_path);
if (effect != nullptr) {
f0rGetPluginInfo get_info_func = reinterpret_cast<f0rGetPluginInfo>(LibAddress(effect, "f0r_get_plugin_info"));
if (get_info_func != nullptr) {
f0r_plugin_info_t info;
get_info_func(&info);
if (!loaded_names.contains(info.name)
&& info.plugin_type == F0R_PLUGIN_TYPE_FILTER
&& info.color_model == F0R_COLOR_MODEL_RGBA8888) {
em.name = info.name;
em.path = dir;
em.filename = entry_list.at(j);
effects.append(em);
}
// qDebug() << "Found:" << info.name << "by" << info.author;
}
LibClose(effect);
}
// qDebug() << search_dir.filePath(entry_list.at(j));
}
}
}
}
void load_frei0r_effects() {
QList<QString> effect_dirs = get_effects_paths();
int lim = effect_dirs.size();
// add extra search paths for frei0r effects
for (int i=0;i<lim;i++) {
effect_dirs.append(QDir(effect_dirs.at(i)).filePath("frei0r"));
}
// add defined paths for frei0r plugins on unix
#if defined(__APPLE__) || defined(__linux__)
effect_dirs.append(QDir::homePath() + "/.frei0r-1/lib");
effect_dirs.append("/usr/local/lib/frei0r-1");
effect_dirs.append("/usr/lib/frei0r-1");
#endif
QVector<QString> loaded_names;
// search for paths
EffectMeta em;
em.category = "Frei0r";
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.internal = EFFECT_INTERNAL_FREI0R;
for (int i=0;i<effect_dirs.size();i++) {
load_frei0r_effects_worker(effect_dirs.at(i), em, loaded_names);
}
}
#endif
EffectInit::EffectInit() {
panel_effect_controls->effects_loaded.lock();
}
void EffectInit::run() {
qInfo() << "Initializing effects...";
load_internal_effects();
load_shader_effects();
#ifndef NOFREI0R
load_frei0r_effects();
#endif
panel_effect_controls->effects_loaded.unlock();
qInfo() << "Finished initializing effects";
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef EFFECTLOADERS_H
#define EFFECTLOADERS_H
#include <QList>
void init_effects();
#endif // EFFECTLOADERS_H
+1 -1
View File
@@ -197,7 +197,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) {
} }
} }
if (exist_key == -1) { if (exist_key == -1) {
key.type = (f->keyframes.size() == 0) ? KEYFRAME_TYPE_LINEAR : f->keyframes.at(closest_key).type; key.type = (f->keyframes.size() == 0) ? EFFECT_KEYFRAME_LINEAR : f->keyframes.at(closest_key).type;
key.data = f->get_current_data();//f->keyframes.at(closest_key).data; key.data = f->get_current_data();//f->keyframes.at(closest_key).data;
unsafe_keys[i] = f->keyframes.size(); unsafe_keys[i] = f->keyframes.size();
f->keyframes.append(key); f->keyframes.append(key);
+2
View File
@@ -33,6 +33,7 @@ parts:
- qtmultimedia5-dev - qtmultimedia5-dev
- libavformat-dev - libavformat-dev
- libavfilter-dev - libavfilter-dev
- frei0r-plugins-dev
stage-packages: stage-packages:
- ffmpeg - ffmpeg
- libqt5multimedia5 - libqt5multimedia5
@@ -40,6 +41,7 @@ parts:
- libpulse0 - libpulse0
- libslang2 - libslang2
- libglu1-mesa - libglu1-mesa
- frei0r-plugins
override-build: | override-build: |
qmake olive.pro qmake olive.pro
make make
+15 -15
View File
@@ -238,33 +238,33 @@ void GraphView::paintEvent(QPaintEvent *) {
} else { } else {
const EffectKeyframe& last_key = field->keyframes.at(sorted_keys.at(j-1)); const EffectKeyframe& last_key = field->keyframes.at(sorted_keys.at(j-1));
double pre_handle = field->get_validated_keyframe_handle(sorted_keys.at(j), false); double pre_handle = field->get_validated_keyframe_handle(sorted_keys.at(j), false);
double last_post_handle = field->get_validated_keyframe_handle(sorted_keys.at(j-1), true); double last_post_handle = field->get_validated_keyframe_handle(sorted_keys.at(j-1), true);
if (last_key.type == KEYFRAME_TYPE_HOLD) { if (last_key.type == EFFECT_KEYFRAME_HOLD) {
// hold // hold
p.drawLine(last_key_x, last_key_y, key_x, last_key_y); p.drawLine(last_key_x, last_key_y, key_x, last_key_y);
p.drawLine(key_x, last_key_y, key_x, key_y); p.drawLine(key_x, last_key_y, key_x, key_y);
} else if (last_key.type == KEYFRAME_TYPE_BEZIER || key.type == KEYFRAME_TYPE_BEZIER) { } else if (last_key.type == EFFECT_KEYFRAME_BEZIER || key.type == EFFECT_KEYFRAME_BEZIER) {
QPainterPath bezier_path; QPainterPath bezier_path;
bezier_path.moveTo(last_key_x, last_key_y); bezier_path.moveTo(last_key_x, last_key_y);
if (last_key.type == KEYFRAME_TYPE_BEZIER && key.type == KEYFRAME_TYPE_BEZIER) { if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier // cubic bezier
bezier_path.cubicTo( bezier_path.cubicTo(
QPointF(last_key_x+last_post_handle*zoom, last_key_y-last_key.post_handle_y*zoom), QPointF(last_key_x+last_post_handle*zoom, last_key_y-last_key.post_handle_y*zoom),
QPointF(key_x+pre_handle*zoom, key_y-key.pre_handle_y*zoom), QPointF(key_x+pre_handle*zoom, key_y-key.pre_handle_y*zoom),
QPointF(key_x, key_y) QPointF(key_x, key_y)
); );
} else if (key.type == KEYFRAME_TYPE_LINEAR) { // quadratic bezier } else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one // last keyframe is the bezier one
bezier_path.quadTo( bezier_path.quadTo(
QPointF(last_key_x+last_post_handle*zoom, last_key_y-last_key.post_handle_y*zoom), QPointF(last_key_x+last_post_handle*zoom, last_key_y-last_key.post_handle_y*zoom),
QPointF(key_x, key_y) QPointF(key_x, key_y)
); );
} else { } else {
// this keyframe is the bezier one // this keyframe is the bezier one
bezier_path.quadTo( bezier_path.quadTo(
QPointF(key_x+pre_handle*zoom, key_y-key.pre_handle_y*zoom), QPointF(key_x+pre_handle*zoom, key_y-key.pre_handle_y*zoom),
QPointF(key_x, key_y) QPointF(key_x, key_y)
); );
} }
@@ -286,7 +286,7 @@ void GraphView::paintEvent(QPaintEvent *) {
int key_x = get_screen_x(key.time); int key_x = get_screen_x(key.time);
int key_y = get_screen_y(key.data.toDouble()); int key_y = get_screen_y(key.data.toDouble());
if (key.type == KEYFRAME_TYPE_BEZIER) { if (key.type == EFFECT_KEYFRAME_BEZIER) {
p.setPen(Qt::gray); p.setPen(Qt::gray);
// pre handle line // pre handle line
@@ -612,24 +612,24 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
&& event->pos().x() <= key_x) { && event->pos().x() <= key_x) {
QRect mouse_rect(event->pos().x()-BEZIER_LINE_SIZE, event->pos().y()-BEZIER_LINE_SIZE, BEZIER_LINE_SIZE+BEZIER_LINE_SIZE, BEZIER_LINE_SIZE+BEZIER_LINE_SIZE); QRect mouse_rect(event->pos().x()-BEZIER_LINE_SIZE, event->pos().y()-BEZIER_LINE_SIZE, BEZIER_LINE_SIZE+BEZIER_LINE_SIZE, BEZIER_LINE_SIZE+BEZIER_LINE_SIZE);
// NOTE: FILTHY copy/paste from paintEvent // NOTE: FILTHY copy/paste from paintEvent
if (last_key.type == KEYFRAME_TYPE_HOLD) { if (last_key.type == EFFECT_KEYFRAME_HOLD) {
// hold // hold
if (event->pos().y() >= last_key_y-BEZIER_LINE_SIZE if (event->pos().y() >= last_key_y-BEZIER_LINE_SIZE
&& event->pos().y() <= last_key_y+BEZIER_LINE_SIZE) { && event->pos().y() <= last_key_y+BEZIER_LINE_SIZE) {
// dout << "make an HOLD key on field" << i << "after key" << j; // dout << "make an HOLD key on field" << i << "after key" << j;
click_add = true; click_add = true;
} }
} else if (last_key.type == KEYFRAME_TYPE_BEZIER || key.type == KEYFRAME_TYPE_BEZIER) { } else if (last_key.type == EFFECT_KEYFRAME_BEZIER || key.type == EFFECT_KEYFRAME_BEZIER) {
QPainterPath bezier_path; QPainterPath bezier_path;
bezier_path.moveTo(last_key_x, last_key_y); bezier_path.moveTo(last_key_x, last_key_y);
if (last_key.type == KEYFRAME_TYPE_BEZIER && key.type == KEYFRAME_TYPE_BEZIER) { if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier // cubic bezier
bezier_path.cubicTo( bezier_path.cubicTo(
QPointF(last_key_x+last_key.post_handle_x*zoom, last_key_y-last_key.post_handle_y*zoom), QPointF(last_key_x+last_key.post_handle_x*zoom, last_key_y-last_key.post_handle_y*zoom),
QPointF(key_x+key.pre_handle_x*zoom, key_y-key.pre_handle_y*zoom), QPointF(key_x+key.pre_handle_x*zoom, key_y-key.pre_handle_y*zoom),
QPointF(key_x, key_y) QPointF(key_x, key_y)
); );
} else if (key.type == KEYFRAME_TYPE_LINEAR) { // quadratic bezier } else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one // last keyframe is the bezier one
bezier_path.quadTo( bezier_path.quadTo(
QPointF(last_key_x+last_key.post_handle_x*zoom, last_key_y-last_key.post_handle_y*zoom), QPointF(last_key_x+last_key.post_handle_x*zoom, last_key_y-last_key.post_handle_y*zoom),
+3 -3
View File
@@ -14,16 +14,16 @@ void draw_keyframe(QPainter &p, int type, int x, int y, bool darker, int r, int
p.setBrush(QColor(r, g, b)); p.setBrush(QColor(r, g, b));
switch (type) { switch (type) {
case KEYFRAME_TYPE_LINEAR: case EFFECT_KEYFRAME_LINEAR:
{ {
QPoint points[KEYFRAME_POINT_COUNT] = {QPoint(x-KEYFRAME_SIZE, y), QPoint(x, y-KEYFRAME_SIZE), QPoint(x+KEYFRAME_SIZE, y), QPoint(x, y+KEYFRAME_SIZE)}; QPoint points[KEYFRAME_POINT_COUNT] = {QPoint(x-KEYFRAME_SIZE, y), QPoint(x, y-KEYFRAME_SIZE), QPoint(x+KEYFRAME_SIZE, y), QPoint(x, y+KEYFRAME_SIZE)};
p.drawPolygon(points, KEYFRAME_POINT_COUNT); p.drawPolygon(points, KEYFRAME_POINT_COUNT);
} }
break; break;
case KEYFRAME_TYPE_BEZIER: case EFFECT_KEYFRAME_BEZIER:
p.drawEllipse(QPoint(x, y), KEYFRAME_SIZE, KEYFRAME_SIZE); p.drawEllipse(QPoint(x, y), KEYFRAME_SIZE, KEYFRAME_SIZE);
break; break;
case KEYFRAME_TYPE_HOLD: case EFFECT_KEYFRAME_HOLD:
p.drawRect(QRect(x - KEYFRAME_SIZE, y - KEYFRAME_SIZE, KEYFRAME_SIZE*2, KEYFRAME_SIZE*2)); p.drawRect(QRect(x - KEYFRAME_SIZE, y - KEYFRAME_SIZE, KEYFRAME_SIZE*2, KEYFRAME_SIZE*2));
break; break;
} }
+9 -9
View File
@@ -50,12 +50,12 @@ void KeyframeView::show_context_menu(const QPoint& pos) {
if (selected_fields.size() > 0) { if (selected_fields.size() > 0) {
QMenu menu(this); QMenu menu(this);
QAction* linear = menu.addAction(tr("Linear")); QAction* linear = menu.addAction(tr("Linear"));
linear->setData(KEYFRAME_TYPE_LINEAR); linear->setData(EFFECT_KEYFRAME_LINEAR);
QAction* bezier = menu.addAction(tr("Bezier")); QAction* bezier = menu.addAction(tr("Bezier"));
bezier->setData(KEYFRAME_TYPE_BEZIER); bezier->setData(EFFECT_KEYFRAME_BEZIER);
QAction* hold = menu.addAction(tr("Hold")); QAction* hold = menu.addAction(tr("Hold"));
hold->setData(KEYFRAME_TYPE_HOLD); hold->setData(EFFECT_KEYFRAME_HOLD);
menu.addSeparator(); menu.addSeparator();
menu.addAction("Graph Editor"); menu.addAction("Graph Editor");
@@ -199,9 +199,9 @@ void KeyframeView::set_y_scroll(int s) {
} }
void KeyframeView::resize_move(double d) { void KeyframeView::resize_move(double d) {
panel_effect_controls->zoom *= d; panel_effect_controls->zoom *= d;
header->update_zoom(panel_effect_controls->zoom); header->update_zoom(panel_effect_controls->zoom);
update(); update();
} }
void KeyframeView::mousePressEvent(QMouseEvent *event) { void KeyframeView::mousePressEvent(QMouseEvent *event) {