From 80507264ec6a0f15273dd25a6c05b80d0a9b41c4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 21 Jan 2019 11:42:24 +1100 Subject: [PATCH] added correct frei0r overriding and fixed loading message boxes --- effects/internal/frei0reffect.cpp | 6 +-- io/loadthread.cpp | 53 +++++++++++++------- io/loadthread.h | 5 ++ playback/cacher.cpp | 1 - project/clip.h | 80 +++++++++++++++---------------- project/effectloaders.cpp | 79 +++++++++++++++--------------- 6 files changed, 125 insertions(+), 99 deletions(-) diff --git a/effects/internal/frei0reffect.cpp b/effects/internal/frei0reffect.cpp index 5fdde78e9..50ccd6698 100644 --- a/effects/internal/frei0reffect.cpp +++ b/effects/internal/frei0reffect.cpp @@ -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(LibAddress(handle, "f0r_get_param_info")); for (int i=0;i -#include #include 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 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;istart_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(buttons)); + waitCond.wakeAll(); +} + void LoadThread::error_func() { if (xml_error) { qCritical() << "Error parsing XML." << error_str; diff --git a/io/loadthread.h b/io/loadthread.h index f591fb966..3aba462ce 100644 --- a/io/loadthread.h +++ b/io/loadthread.h @@ -6,6 +6,7 @@ #include #include #include +#include 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 diff --git a/playback/cacher.cpp b/playback/cacher.cpp index e11269088..f7deb4334 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -365,7 +365,6 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& 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(); diff --git a/project/clip.h b/project/clip.h index 69e757d5f..99e896472 100644 --- a/project/clip.h +++ b/project/clip.h @@ -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 effects; - QVector linked; - int opening_transition; - Transition* get_opening_transition(); - int closing_transition; - Transition* get_closing_transition(); + QList effects; + QVector 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 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; }; diff --git a/project/effectloaders.cpp b/project/effectloaders.cpp index 2d9ede9fc..83616e3cd 100644 --- a/project/effectloaders.cpp +++ b/project/effectloaders.cpp @@ -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 entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - for (int j=0;j(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& loaded_names) { + QDir search_dir(dir); + if (search_dir.exists()) { + QList entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); + for (int j=0;j(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 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