added correct frei0r overriding and fixed loading message boxes

This commit is contained in:
itsmattkc
2019-01-21 11:42:24 +11:00
parent ae4fdf4846
commit 80507264ec
6 changed files with 125 additions and 99 deletions
+3 -3
View File
@@ -62,9 +62,9 @@ Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) {
param_count = info.num_params;
qDebug() << "Frei0r Name:" << info.name;
qDebug() << "Frei0r Param Count:" << info.num_params;
qDebug() << "Frei0r Explanation:" << info.explanation;
// 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++) {
+36 -17
View File
@@ -18,7 +18,6 @@
#include "debug.h"
#include <QFile>
#include <QMessageBox>
#include <QTreeWidgetItem>
struct TransitionData {
@@ -35,6 +34,7 @@ LoadThread::LoadThread(LoadDialog* l, bool a) : ld(l), autorecovery(a), cancelle
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_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& input) {
@@ -43,7 +43,7 @@ const EffectMeta* get_meta_from_name(const QString& input) {
if (split_index > -1) {
category = input.left(split_index);
}
QString name = input.mid(split_index + 1);
QString name = input.mid(split_index + 1);
for (int j=0;j<effects.size();j++) {
if (effects.at(j).name == name
@@ -161,13 +161,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
if (stream.name() == root_search) {
if (type == LOAD_TYPE_VERSION) {
int proj_version = stream.readElementText().toInt();
if (proj_version < MIN_SAVE_VERSION && proj_version > SAVE_VERSION) {
if (QMessageBox::warning(
mainWindow,
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?"),
QMessageBox::Yes,
QMessageBox::No) == QMessageBox::No) {
if (proj_version < MIN_SAVE_VERSION || proj_version > SAVE_VERSION) {
emit start_question(
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?"),
QMessageBox::Yes | QMessageBox::No
);
waitCond.wait(&mutex);
if (question_btn == QMessageBox::No) {
show_err = false;
return false;
}
@@ -453,11 +454,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
if (!found) {
correct_clip->linked.removeAt(j);
j--;
if (QMessageBox::warning(mainWindow,
tr("Invalid Clip Link"),
tr("This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?"),
QMessageBox::Yes,
QMessageBox::No) == QMessageBox::No) {
emit start_question(
tr("Invalid Clip Link"),
tr("This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?"),
QMessageBox::Yes | QMessageBox::No
);
waitCond.wait(&mutex);
if (question_btn == QMessageBox::No) {
delete s;
return false;
}
@@ -574,10 +578,14 @@ void LoadThread::run() {
cont = !cancelled;
// 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
cont = load_worker(file, stream, LOAD_TYPE_URL);
if (cont) {
cont = load_worker(file, stream, LOAD_TYPE_URL);
}
// load folders first
if (cont) {
@@ -614,7 +622,6 @@ void LoadThread::run() {
xml_error = true;
emit error();
cont = false;
} else {
// attach nested sequence clips to their sequences
for (int i=0;i<loaded_clips.size();i++) {
@@ -635,6 +642,9 @@ void LoadThread::run() {
for (int i=0;i<loaded_media_items.size();i++) {
panel_project->start_preview_generator(loaded_media_items.at(i), true);
}
} else {
error_str = tr("User aborted loading");
emit error();
}
file.close();
@@ -647,6 +657,15 @@ void LoadThread::cancel() {
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() {
if (xml_error) {
qCritical() << "Error parsing XML." << error_str;
+5
View File
@@ -6,6 +6,7 @@
#include <QXmlStreamReader>
#include <QMutex>
#include <QWaitCondition>
#include <QMessageBox>
class Media;
struct Footage;
@@ -23,12 +24,14 @@ public:
void run();
void cancel();
signals:
void start_question(const QString &title, const QString &text, int buttons);
void success();
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_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
void report_progress(int p);
private slots:
void question_func(const QString &title, const QString &text, int buttons);
void error_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);
@@ -67,6 +70,8 @@ private:
bool cancelled;
bool xml_error;
QMessageBox::StandardButton question_btn;
};
#endif // LOADTHREAD_H
-1
View File
@@ -365,7 +365,6 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector<Clip*>& nests) {
break;
} else {
unsigned long buffer_timeline_out = get_buffer_offset_from_frame(c->sequence->frame_rate, timeline_out);
qDebug() << "bto:" << buffer_timeline_out;
audio_write_lock.lock();
+40 -40
View File
@@ -33,17 +33,17 @@ class QOpenGLTexture;
struct Clip
{
Clip(Sequence* s);
Clip(Sequence* s);
~Clip();
Clip* copy(Sequence* s);
void reset_audio();
Clip* copy(Sequence* s);
void reset_audio();
void reset();
void refresh();
long get_clip_in_with_transition();
long get_clip_in_with_transition();
long get_timeline_in_with_transition();
long get_timeline_out_with_transition();
long getLength();
double getMediaFrameRate();
double getMediaFrameRate();
long getMaximumLength();
void recalculateMaxLength();
int getWidth();
@@ -56,39 +56,39 @@ struct Clip
void queue_remove_earliest();
// timeline variables (should be copied in copy())
bool enabled;
long clip_in;
long timeline_in;
long timeline_out;
int track;
bool enabled;
long clip_in;
long timeline_in;
long timeline_out;
int track;
QString name;
quint8 color_r;
quint8 color_g;
quint8 color_b;
Media* media;
int media_stream;
quint8 color_r;
quint8 color_g;
quint8 color_b;
Media* media;
int media_stream;
double speed;
double cached_fr;
double cached_fr;
bool reverse;
bool maintain_audio_pitch;
bool autoscale;
// other variables (should be deep copied/duplicated in copy())
QList<Effect*> effects;
QVector<int> linked;
int opening_transition;
Transition* get_opening_transition();
int closing_transition;
Transition* get_closing_transition();
QList<Effect*> effects;
QVector<int> linked;
int opening_transition;
Transition* get_opening_transition();
int closing_transition;
Transition* get_closing_transition();
// media handling
AVFormatContext* formatCtx;
AVStream* stream;
AVCodec* codec;
AVCodecContext* codecCtx;
AVPacket* pkt;
AVFormatContext* formatCtx;
AVStream* stream;
AVCodec* codec;
AVCodecContext* codecCtx;
AVPacket* pkt;
AVFrame* frame;
AVDictionary* opts;
AVDictionary* opts;
long calculated_length;
// temporary variables
@@ -96,23 +96,23 @@ struct Clip
bool undeletable;
bool reached_end;
bool pkt_written;
bool open;
bool finished_opening;
bool replaced;
bool open;
bool finished_opening;
bool replaced;
bool ignore_reverse;
int pix_fmt;
// caching functions
bool use_existing_frame;
bool multithreaded;
bool multithreaded;
Cacher* cacher;
QWaitCondition can_cache;
QWaitCondition can_cache;
int max_queue_size;
QVector<AVFrame*> queue;
QMutex queue_lock;
QMutex lock;
QMutex lock;
QMutex open_lock;
int64_t last_invalid_ts;
int64_t last_invalid_ts;
// converters/filters
AVFilterGraph* filter_graph;
@@ -121,15 +121,15 @@ struct Clip
// video playback variables
QOpenGLFramebufferObject** fbo;
QOpenGLTexture* texture;
QOpenGLTexture* texture;
long texture_frame;
// audio playback variables
int64_t reverse_target;
int frame_sample_index;
int audio_buffer_write;
bool audio_reset;
bool audio_just_reset;
int frame_sample_index;
unsigned long audio_buffer_write;
bool audio_reset;
bool audio_just_reset;
long audio_target_frame;
};
+41 -38
View File
@@ -166,38 +166,39 @@ void init_effects() {
}
#ifndef NOFREI0R
void load_frei0r_effects_worker(const QString& dir, EffectMeta& em) {
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);
} 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);
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 (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);
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);
}
effects.append(em);
}
// qDebug() << "Found:" << info.name << "by" << info.author;
}
LibClose(effect);
}
}
LibClose(effect);
}
// qDebug() << search_dir.filePath(entry_list.at(j));
}
}
}
}
}
}
}
void load_frei0r_effects() {
@@ -211,20 +212,22 @@ void load_frei0r_effects() {
// 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");
effect_dirs.append(QDir::homePath() + "/.frei0r-1/lib");
effect_dirs.append("/usr/local/lib/frei0r-1");
effect_dirs.append("/usr/lib/frei0r-1");
#endif
// search for paths
EffectMeta em;
em.category = "Frei0r";
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.internal = EFFECT_INTERNAL_FREI0R;
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);
load_frei0r_effects_worker(effect_dirs.at(i), em, loaded_names);
}
}
#endif