switched global to unique ptr and renamed olive namespace
This commit is contained in:
+2
-2
@@ -29,8 +29,8 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
Config Olive::CurrentConfig;
|
||||
RuntimeConfig Olive::CurrentRuntimeConfig;
|
||||
Config olive::CurrentConfig;
|
||||
RuntimeConfig olive::CurrentRuntimeConfig;
|
||||
|
||||
Config::Config()
|
||||
: saved_layout(false),
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ struct RuntimeConfig {
|
||||
QString external_translation_file;
|
||||
};
|
||||
|
||||
namespace Olive {
|
||||
namespace olive {
|
||||
extern Config CurrentConfig;
|
||||
extern RuntimeConfig CurrentRuntimeConfig;
|
||||
}
|
||||
|
||||
+15
-15
@@ -183,15 +183,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 = Olive::ActiveSequence->width;
|
||||
video_frame->height = Olive::ActiveSequence->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(
|
||||
Olive::ActiveSequence->width,
|
||||
Olive::ActiveSequence->height,
|
||||
olive::ActiveSequence->width,
|
||||
olive::ActiveSequence->height,
|
||||
AV_PIX_FMT_RGBA,
|
||||
params.video_width,
|
||||
params.video_height,
|
||||
@@ -274,9 +274,9 @@ bool ExportThread::setupAudio() {
|
||||
acodec_ctx->channel_layout,
|
||||
acodec_ctx->sample_fmt,
|
||||
acodec_ctx->sample_rate,
|
||||
Olive::ActiveSequence->audio_layout,
|
||||
olive::ActiveSequence->audio_layout,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
Olive::ActiveSequence->audio_frequency,
|
||||
olive::ActiveSequence->audio_frequency,
|
||||
0,
|
||||
nullptr
|
||||
);
|
||||
@@ -284,7 +284,7 @@ bool ExportThread::setupAudio() {
|
||||
|
||||
// initialize raw audio frame
|
||||
audio_frame = av_frame_alloc();
|
||||
audio_frame->sample_rate = Olive::ActiveSequence->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;
|
||||
@@ -366,16 +366,16 @@ void ExportThread::run() {
|
||||
|
||||
mutex.lock();
|
||||
|
||||
while (Olive::ActiveSequence->playhead <= params.end_frame && continueEncode) {
|
||||
while (olive::ActiveSequence->playhead <= params.end_frame && continueEncode) {
|
||||
start_time = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
if (params.audio_enabled) {
|
||||
compose_audio(nullptr, Olive::ActiveSequence, 1);
|
||||
compose_audio(nullptr, olive::ActiveSequence, 1);
|
||||
}
|
||||
if (params.video_enabled) {
|
||||
do {
|
||||
// TODO optimize by rendering the next frame while encoding the last
|
||||
renderer->start_render(nullptr, Olive::ActiveSequence, 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());
|
||||
@@ -383,7 +383,7 @@ void ExportThread::run() {
|
||||
}
|
||||
|
||||
// encode last frame while rendering next frame
|
||||
double timecode_secs = double(Olive::ActiveSequence->playhead - params.start_frame) / Olive::ActiveSequence->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
|
||||
|
||||
@@ -444,12 +444,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 - Olive::ActiveSequence->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(Olive::ActiveSequence->playhead - params.start_frame) / double(params.end_frame - params.start_frame)) * 100.0), eta);
|
||||
Olive::ActiveSequence->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++;
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ void ExportThread::run() {
|
||||
if (params.audio_enabled) apkt_alloc = true;
|
||||
}
|
||||
|
||||
Olive::Global.data()->set_rendering_state(false);
|
||||
olive::Global->set_rendering_state(false);
|
||||
|
||||
if (params.audio_enabled && continueEncode) {
|
||||
// flush swresample
|
||||
|
||||
+11
-11
@@ -584,7 +584,7 @@ Media* LoadThread::find_loaded_folder_by_id(int id) {
|
||||
void LoadThread::run() {
|
||||
mutex.lock();
|
||||
|
||||
QFile file(Olive::ActiveProjectFilename);
|
||||
QFile file(olive::ActiveProjectFilename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "Could not open file";
|
||||
return;
|
||||
@@ -595,9 +595,9 @@ void LoadThread::run() {
|
||||
* case the project file has moved without the footage,
|
||||
* we check both
|
||||
*/
|
||||
proj_dir = QFileInfo(Olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_dir = QFileInfo(Olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_url = Olive::ActiveProjectFilename;
|
||||
proj_dir = QFileInfo(olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_dir = QFileInfo(olive::ActiveProjectFilename).absoluteDir();
|
||||
internal_proj_url = olive::ActiveProjectFilename;
|
||||
|
||||
QXmlStreamReader stream(&file);
|
||||
|
||||
@@ -709,7 +709,7 @@ void LoadThread::cancel() {
|
||||
void LoadThread::question_func(const QString &title, const QString &text, int buttons) {
|
||||
mutex.lock();
|
||||
question_btn = QMessageBox::warning(
|
||||
Olive::MainWindow,
|
||||
olive::MainWindow,
|
||||
title,
|
||||
text,
|
||||
static_cast<enum QMessageBox::StandardButton>(buttons));
|
||||
@@ -720,12 +720,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(Olive::MainWindow,
|
||||
QMessageBox::critical(olive::MainWindow,
|
||||
tr("XML Parsing Error"),
|
||||
tr("Couldn't load '%1'. %2").arg(Olive::ActiveProjectFilename, error_str),
|
||||
tr("Couldn't load '%1'. %2").arg(olive::ActiveProjectFilename, error_str),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
QMessageBox::critical(Olive::MainWindow,
|
||||
QMessageBox::critical(olive::MainWindow,
|
||||
tr("Project Load Error"),
|
||||
tr("Error loading project: %1").arg(error_str),
|
||||
QMessageBox::Ok);
|
||||
@@ -748,12 +748,12 @@ void LoadThread::success_func() {
|
||||
counter++;
|
||||
}
|
||||
|
||||
Olive::Global.data()->update_project_filename(orig_filename);
|
||||
olive::Global->update_project_filename(orig_filename);
|
||||
} else {
|
||||
panel_project->add_recent_project(Olive::ActiveProjectFilename);
|
||||
panel_project->add_recent_project(olive::ActiveProjectFilename);
|
||||
}
|
||||
|
||||
Olive::MainWindow->setWindowModified(autorecovery);
|
||||
olive::MainWindow->setWindowModified(autorecovery);
|
||||
if (open_seq != nullptr) set_sequence(open_seq);
|
||||
update_ui(false);
|
||||
}
|
||||
|
||||
@@ -242,8 +242,8 @@ void PreviewGenerator::generate_waveform() {
|
||||
|
||||
// we only generate previews for video and audio
|
||||
// and only if the thumbnail and waveform sizes are > 0
|
||||
if ((fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && Olive::CurrentConfig.thumbnail_resolution > 0)
|
||||
|| (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && Olive::CurrentConfig.waveform_resolution > 0)) {
|
||||
if ((fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && olive::CurrentConfig.thumbnail_resolution > 0)
|
||||
|| (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && olive::CurrentConfig.waveform_resolution > 0)) {
|
||||
AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id);
|
||||
if (codec != nullptr) {
|
||||
|
||||
@@ -318,7 +318,7 @@ void PreviewGenerator::generate_waveform() {
|
||||
if (s != nullptr) {
|
||||
if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
if (!s->preview_done) {
|
||||
int dstH = Olive::CurrentConfig.thumbnail_resolution;
|
||||
int dstH = olive::CurrentConfig.thumbnail_resolution;
|
||||
int dstW = qRound(dstH * (float(temp_frame->width)/float(temp_frame->height)));
|
||||
uint8_t* data = new uint8_t[size_t(dstW*dstH*4)];
|
||||
|
||||
@@ -381,7 +381,7 @@ void PreviewGenerator::generate_waveform() {
|
||||
// `config.waveform_resolution` determines how many samples per second are stored in waveform.
|
||||
// `sample_rate` is samples per second, so `interval` is how many samples are averaged in
|
||||
// each "point" of the waveform
|
||||
int interval = qFloor((temp_frame->sample_rate/Olive::CurrentConfig.waveform_resolution)/4)*4;
|
||||
int interval = qFloor((temp_frame->sample_rate/olive::CurrentConfig.waveform_resolution)/4)*4;
|
||||
|
||||
// get the amount of bytes in an audio sample
|
||||
int sample_size = av_get_bytes_per_sample(static_cast<AVSampleFormat>(swr_frame->format));
|
||||
|
||||
@@ -316,7 +316,7 @@ void ProxyGenerator::transcode(const ProxyInfo& info) {
|
||||
info.footage->proxy_path = info.path;
|
||||
|
||||
qInfo() << "Finished creating proxy for" << info.footage->url;
|
||||
QMetaObject::invokeMethod(Olive::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