first commit of big refactor
This commit is contained in:
+18
-17
@@ -1,10 +1,11 @@
|
||||
#include "exportthread.h"
|
||||
|
||||
#include "oliveglobal.h"
|
||||
|
||||
#include "project/sequence.h"
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "panels/timeline.h"
|
||||
#include "panels/viewer.h"
|
||||
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "ui/renderthread.h"
|
||||
#include "ui/renderfunctions.h"
|
||||
@@ -162,15 +163,15 @@ bool ExportThread::setupVideo() {
|
||||
video_frame = av_frame_alloc();
|
||||
av_frame_make_writable(video_frame);
|
||||
video_frame->format = AV_PIX_FMT_RGBA;
|
||||
video_frame->width = sequence->width;
|
||||
video_frame->height = sequence->height;
|
||||
video_frame->width = Olive::ActiveSequence->width;
|
||||
video_frame->height = Olive::ActiveSequence->height;
|
||||
av_frame_get_buffer(video_frame, 0);
|
||||
|
||||
av_init_packet(&video_pkt);
|
||||
|
||||
sws_ctx = sws_getContext(
|
||||
sequence->width,
|
||||
sequence->height,
|
||||
Olive::ActiveSequence->width,
|
||||
Olive::ActiveSequence->height,
|
||||
AV_PIX_FMT_RGBA,
|
||||
params.video_width,
|
||||
params.video_height,
|
||||
@@ -253,9 +254,9 @@ bool ExportThread::setupAudio() {
|
||||
acodec_ctx->channel_layout,
|
||||
acodec_ctx->sample_fmt,
|
||||
acodec_ctx->sample_rate,
|
||||
sequence->audio_layout,
|
||||
Olive::ActiveSequence->audio_layout,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
sequence->audio_frequency,
|
||||
Olive::ActiveSequence->audio_frequency,
|
||||
0,
|
||||
nullptr
|
||||
);
|
||||
@@ -263,7 +264,7 @@ bool ExportThread::setupAudio() {
|
||||
|
||||
// initialize raw audio frame
|
||||
audio_frame = av_frame_alloc();
|
||||
audio_frame->sample_rate = sequence->audio_frequency;
|
||||
audio_frame->sample_rate = Olive::ActiveSequence->audio_frequency;
|
||||
audio_frame->nb_samples = acodec_ctx->frame_size;
|
||||
if (audio_frame->nb_samples == 0) audio_frame->nb_samples = 256; // should possibly be smaller?
|
||||
audio_frame->format = AV_SAMPLE_FMT_S16;
|
||||
@@ -345,16 +346,16 @@ void ExportThread::run() {
|
||||
|
||||
mutex.lock();
|
||||
|
||||
while (sequence->playhead <= params.end_frame && continueEncode) {
|
||||
while (Olive::ActiveSequence->playhead <= params.end_frame && continueEncode) {
|
||||
start_time = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
if (params.audio_enabled) {
|
||||
compose_audio(nullptr, sequence, true, false);
|
||||
compose_audio(nullptr, Olive::ActiveSequence, true, false);
|
||||
}
|
||||
if (params.video_enabled) {
|
||||
do {
|
||||
// TODO optimize by rendering the next frame while encoding the last
|
||||
renderer->start_render(nullptr, sequence, nullptr, video_frame->data[0], video_frame->linesize[0]/4);
|
||||
renderer->start_render(nullptr, Olive::ActiveSequence, nullptr, video_frame->data[0], video_frame->linesize[0]/4);
|
||||
waitCond.wait(&mutex);
|
||||
if (!continueEncode) break;
|
||||
} while (renderer->did_texture_fail());
|
||||
@@ -362,7 +363,7 @@ void ExportThread::run() {
|
||||
}
|
||||
|
||||
// encode last frame while rendering next frame
|
||||
double timecode_secs = double(sequence->playhead - params.start_frame) / sequence->frame_rate;
|
||||
double timecode_secs = double(Olive::ActiveSequence->playhead - params.start_frame) / Olive::ActiveSequence->frame_rate;
|
||||
if (params.video_enabled) {
|
||||
// create sws_frame for converting pixel format
|
||||
|
||||
@@ -423,12 +424,12 @@ void ExportThread::run() {
|
||||
// generating encoding statistics (time it took to encode this frame/estimated remaining time)
|
||||
frame_time = (QDateTime::currentMSecsSinceEpoch()-start_time);
|
||||
total_time += frame_time;
|
||||
remaining_frames = (params.end_frame - sequence->playhead);
|
||||
remaining_frames = (params.end_frame - Olive::ActiveSequence->playhead);
|
||||
avg_time = (total_time/frame_count);
|
||||
eta = (remaining_frames*avg_time);
|
||||
|
||||
emit progress_changed(qRound((double(sequence->playhead - params.start_frame) / double(params.end_frame - params.start_frame)) * 100.0), eta);
|
||||
sequence->playhead++;
|
||||
emit progress_changed(qRound((double(Olive::ActiveSequence->playhead - params.start_frame) / double(params.end_frame - params.start_frame)) * 100.0), eta);
|
||||
Olive::ActiveSequence->playhead++;
|
||||
frame_count++;
|
||||
}
|
||||
|
||||
@@ -442,7 +443,7 @@ void ExportThread::run() {
|
||||
if (params.audio_enabled) apkt_alloc = true;
|
||||
}
|
||||
|
||||
mainWindow->set_rendering_state(false);
|
||||
Olive::Global.data()->set_rendering_state(false);
|
||||
|
||||
if (params.audio_enabled && continueEncode) {
|
||||
// flush swresample
|
||||
|
||||
+18
-19
@@ -1,19 +1,17 @@
|
||||
#include "loadthread.h"
|
||||
|
||||
#include "oliveglobal.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "panels/project.h"
|
||||
#include "project/footage.h"
|
||||
|
||||
#include "project/projectelements.h"
|
||||
|
||||
#include "io/config.h"
|
||||
#include "project/clip.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/transition.h"
|
||||
#include "project/effect.h"
|
||||
#include "playback/playback.h"
|
||||
#include "io/previewgenerator.h"
|
||||
#include "dialogs/loaddialog.h"
|
||||
#include "project/media.h"
|
||||
#include "effects/internal/voideffect.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -575,7 +573,7 @@ Media* LoadThread::find_loaded_folder_by_id(int id) {
|
||||
void LoadThread::run() {
|
||||
mutex.lock();
|
||||
|
||||
QFile file(project_url);
|
||||
QFile file(Olive::ActiveProjectFilename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "Could not open file";
|
||||
return;
|
||||
@@ -586,9 +584,9 @@ void LoadThread::run() {
|
||||
* case the project file has moved without the footage,
|
||||
* we check both
|
||||
*/
|
||||
proj_dir = QFileInfo(project_url).absoluteDir();
|
||||
internal_proj_dir = QFileInfo(project_url).absoluteDir();
|
||||
internal_proj_url = project_url;
|
||||
proj_dir = QFileInfo(Olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_dir = QFileInfo(Olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_url = Olive::ActiveProjectFilename;
|
||||
|
||||
QXmlStreamReader stream(&file);
|
||||
|
||||
@@ -696,7 +694,7 @@ void LoadThread::cancel() {
|
||||
|
||||
void LoadThread::question_func(const QString &title, const QString &text, int buttons) {
|
||||
question_btn = QMessageBox::warning(
|
||||
mainWindow,
|
||||
Olive::MainWindow,
|
||||
title,
|
||||
text,
|
||||
static_cast<enum QMessageBox::StandardButton>(buttons));
|
||||
@@ -706,12 +704,12 @@ void LoadThread::question_func(const QString &title, const QString &text, int bu
|
||||
void LoadThread::error_func() {
|
||||
if (xml_error) {
|
||||
qCritical() << "Error parsing XML." << error_str;
|
||||
QMessageBox::critical(mainWindow,
|
||||
QMessageBox::critical(Olive::MainWindow,
|
||||
tr("XML Parsing Error"),
|
||||
tr("Couldn't load '%1'. %2").arg(project_url, error_str),
|
||||
tr("Couldn't load '%1'. %2").arg(Olive::ActiveProjectFilename, error_str),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
QMessageBox::critical(mainWindow,
|
||||
QMessageBox::critical(Olive::MainWindow,
|
||||
tr("Project Load Error"),
|
||||
tr("Error loading project: %1").arg(error_str),
|
||||
QMessageBox::Ok);
|
||||
@@ -733,12 +731,13 @@ void LoadThread::success_func() {
|
||||
orig_filename.insert(insert_index, " (" + recover_text + ")");
|
||||
counter++;
|
||||
}
|
||||
mainWindow->updateTitle(orig_filename);
|
||||
|
||||
Olive::Global.data()->update_project_filename(orig_filename);
|
||||
} else {
|
||||
panel_project->add_recent_project(project_url);
|
||||
panel_project->add_recent_project(Olive::ActiveProjectFilename);
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(autorecovery);
|
||||
Olive::MainWindow->setWindowModified(autorecovery);
|
||||
if (open_seq != nullptr) set_sequence(open_seq);
|
||||
update_ui(false);
|
||||
}
|
||||
|
||||
+37
-15
@@ -8,41 +8,56 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
QString get_app_dir() {
|
||||
QString get_app_path() {
|
||||
return QCoreApplication::applicationDirPath();
|
||||
}
|
||||
|
||||
QDir get_app_dir() {
|
||||
return QDir(get_app_path());
|
||||
}
|
||||
|
||||
QString get_data_path() {
|
||||
QString app_dir = get_app_dir();
|
||||
if (QFileInfo::exists(app_dir + "/portable")) {
|
||||
return app_dir;
|
||||
QDir app_dir = get_app_dir();
|
||||
if (QFileInfo::exists(app_dir.filePath("portable"))) {
|
||||
return app_dir.absolutePath();
|
||||
} else {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
}
|
||||
}
|
||||
|
||||
QDir get_data_dir() {
|
||||
return QDir(get_data_path());
|
||||
}
|
||||
|
||||
QString get_config_path() {
|
||||
QString app_dir = get_app_dir();
|
||||
if (QFileInfo::exists(app_dir + "/portable")) {
|
||||
return app_dir;
|
||||
QDir app_dir = get_app_dir();
|
||||
if (QFileInfo::exists(app_dir.filePath("portable"))) {
|
||||
return app_dir.absolutePath();
|
||||
} else {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
}
|
||||
}
|
||||
|
||||
QDir get_config_dir() {
|
||||
return QDir(get_config_path());
|
||||
}
|
||||
|
||||
QList<QString> get_effects_paths() {
|
||||
// returns a list of the effects paths to search
|
||||
|
||||
QList<QString> effects_paths;
|
||||
|
||||
// get current app working directory
|
||||
QDir app_dir = get_app_dir();
|
||||
|
||||
// "effects" subfolder in program folder - best for Windows
|
||||
effects_paths.append(get_app_dir() + "/effects");
|
||||
effects_paths.append(app_dir.filePath("effects"));
|
||||
|
||||
// "Effects" folder one level above the program's directory - best for Mac
|
||||
effects_paths.append(get_app_dir() + "/../Effects");
|
||||
effects_paths.append(app_dir.filePath("../Effects"));
|
||||
|
||||
// folder in share folder - best for Linux
|
||||
effects_paths.append(get_app_dir() + "/../share/olive-editor/effects");
|
||||
effects_paths.append(app_dir.filePath("/../share/olive-editor/effects"));
|
||||
|
||||
// Olive will also accept a manually provided folder with an environment variable
|
||||
QString env_path(qgetenv("OLIVE_EFFECTS_PATH"));
|
||||
@@ -52,22 +67,29 @@ QList<QString> get_effects_paths() {
|
||||
}
|
||||
|
||||
QString get_file_hash(const QString& filename) {
|
||||
QFileInfo file_info(filename);
|
||||
QString cache_file = filename.mid(filename.lastIndexOf('/')+1) + QString::number(file_info.size()) + QString::number(file_info.lastModified().toMSecsSinceEpoch());
|
||||
QFileInfo file_info(filename);
|
||||
|
||||
QString cache_file = filename.mid(filename.lastIndexOf('/')+1)
|
||||
+ QString::number(file_info.size())
|
||||
+ QString::number(file_info.lastModified().toMSecsSinceEpoch());
|
||||
|
||||
return QCryptographicHash::hash(cache_file.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
|
||||
QList<QString> get_language_paths() {
|
||||
QList<QString> language_paths;
|
||||
|
||||
// get current app working directory
|
||||
QDir app_dir = get_app_dir();
|
||||
|
||||
// subfolder in program folder - best for Windows (or compiling+running from source dir)
|
||||
language_paths.append(get_app_dir() + "/ts");
|
||||
language_paths.append(app_dir.filePath("ts"));
|
||||
|
||||
// folder one level above the program's directory - best for Mac
|
||||
language_paths.append(get_app_dir() + "/../Translations");
|
||||
language_paths.append(app_dir.filePath("../Translations"));
|
||||
|
||||
// folder in share folder - best for Linux
|
||||
language_paths.append(get_app_dir() + "/../share/olive-editor/ts");
|
||||
language_paths.append(app_dir.filePath("../share/olive-editor/ts"));
|
||||
|
||||
// Olive will also accept a manually provided folder with an environment variable
|
||||
QString env_path(qgetenv("OLIVE_LANG_PATH"));
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
#define PATH_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
|
||||
QString get_app_dir();
|
||||
QString get_app_path();
|
||||
QString get_data_path();
|
||||
QDir get_data_dir();
|
||||
QString get_config_path();
|
||||
QDir get_config_dir();
|
||||
QList<QString> get_effects_paths();
|
||||
QList<QString> get_language_paths();
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ void ProxyGenerator::transcode(const ProxyInfo& info) {
|
||||
info.footage->proxy_path = info.path;
|
||||
|
||||
qInfo() << "Finished creating proxy for" << info.footage->url;
|
||||
QMetaObject::invokeMethod(mainWindow->statusBar(),
|
||||
QMetaObject::invokeMethod(Olive::MainWindow->statusBar(),
|
||||
"showMessage",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, tr("Finished generating proxy for \"%1\"").arg(info.footage->url)));
|
||||
|
||||
Reference in New Issue
Block a user