From 5297d4a5f76bebcfc143818b33848644a6cba566 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 12 Jul 2018 16:55:06 +0100 Subject: [PATCH] commit before undo overhaul --- dialogs/exportdialog.cpp | 3 +- mainwindow.cpp | 8 ++++-- olive.pro | 6 ++-- playback/cacher.cpp | 22 ++++++++++----- project/clip.h | 60 +++++++++++++++++++++------------------- project/undo.cpp | 3 ++ project/undo.h | 13 +++++++++ 7 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 project/undo.cpp create mode 100644 project/undo.h diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index f2a5d1f3e..312a9eff4 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -231,7 +231,7 @@ void ExportDialog::on_formatCombobox_currentIndexChanged(int index) format_acodecs.append(AV_CODEC_ID_OPUS); format_acodecs.append(AV_CODEC_ID_VORBIS); - default_acodec = AV_CODEC_ID_VORBIS; + default_acodec = 1; break; case FORMAT_MOV: format_vcodecs.append(AV_CODEC_ID_QTRLE); @@ -356,6 +356,7 @@ void ExportDialog::on_pushButton_clicked() // ext = ""; // ext is determined from codec, but we prevent the switch from going to 'default' here qDebug() << "[INFO] Image export not implemented yet"; + QMessageBox::information(this, "Image sequence support coming soon", "Sorry, image sequence exporting is currently unsupported. Check back soon (or hound GitHub issue #83).", QMessageBox::Ok); return; break; case FORMAT_MP3: diff --git a/mainwindow.cpp b/mainwindow.cpp index 8d88e22ab..dfe428859 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -190,8 +190,12 @@ void MainWindow::on_actionTimeline_Track_Lines_toggled(bool e) void MainWindow::on_actionExport_triggered() { - ExportDialog e(this); - e.exec(); + if (sequence == NULL) { + QMessageBox::information(this, "No active sequence", "Please open the sequence you wish to export.", QMessageBox::Ok); + } else { + ExportDialog e(this); + e.exec(); + } } void MainWindow::on_actionProject_2_toggled(bool arg1) diff --git a/olive.pro b/olive.pro index db6da3f52..82b37cd6f 100644 --- a/olive.pro +++ b/olive.pro @@ -58,7 +58,8 @@ SOURCES += \ dialogs/preferencesdialog.cpp \ effects/transition.cpp \ effects/crossdissolvetransition.cpp \ - ui/audiomonitor.cpp + ui/audiomonitor.cpp \ + project/undo.cpp HEADERS += \ mainwindow.h \ @@ -91,7 +92,8 @@ HEADERS += \ ui/labelslider.h \ dialogs/preferencesdialog.h \ effects/transition.h \ - ui/audiomonitor.h + ui/audiomonitor.h \ + project/undo.h FORMS += \ mainwindow.ui \ diff --git a/playback/cacher.cpp b/playback/cacher.cpp index 60be3d933..a4a5375ba 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -18,6 +18,14 @@ extern "C" { #include #include +void apply_audio_effects(Clip* c, AVFrame* frame, int nb_bytes) { + // perform all audio effects + for (int j=0;jeffects.size();j++) { + Effect* e = c->effects.at(j); + if (e->is_enabled()) e->process_audio(frame->data[0], nb_bytes); + } +} + void cache_audio_worker(Clip* c) { int written = 0; int max_write = 16384; @@ -29,6 +37,7 @@ void cache_audio_worker(Clip* c) { // no more audio left in frame, get a new one if (!c->reached_end) { retrieve_next_frame_raw_data(c, frame); + apply_audio_effects(c, frame, av_samples_get_buffer_size(NULL, frame->channels, frame->nb_samples, static_cast(frame->format), 1)); } else { // set by retrieve_next_frame_raw_data indicating no more frames in file, // but there still may be samples in swresample @@ -55,13 +64,6 @@ void cache_audio_worker(Clip* c) { } else { c->frame_sample_index = 0; } - - // perform all audio effects - int nb_bytes = av_samples_get_buffer_size(NULL, frame->channels, frame->nb_samples, static_cast(frame->format), 1); - for (int j=0;jeffects.size();j++) { - Effect* e = c->effects.at(j); - if (e->is_enabled()) e->process_audio(frame->data[0], nb_bytes); - } } if (frame->nb_samples == 0) { @@ -78,9 +80,11 @@ void cache_audio_worker(Clip* c) { c->frame_sample_index += offset; } } + bool apply_effects = false; while (c->frame_sample_index > nb_bytes) { // get new frame retrieve_next_frame_raw_data(c, frame); + apply_effects = true; nb_bytes = av_samples_get_buffer_size(NULL, frame->channels, frame->nb_samples, static_cast(frame->format), 1); c->frame_sample_index -= nb_bytes; @@ -91,6 +95,10 @@ void cache_audio_worker(Clip* c) { c->frame_sample_index += offset; } } + if (apply_effects) { + apply_audio_effects(c, frame, nb_bytes); + } + while (c->frame_sample_index < nb_bytes) { if (c->audio_buffer_write >= audio_ibuffer_read+half_buffer || c->audio_buffer_write >= get_buffer_offset_from_frame(c->timeline_out)) { written = max_write; diff --git a/project/clip.h b/project/clip.h index a41bac0dd..13a05c0a7 100644 --- a/project/clip.h +++ b/project/clip.h @@ -30,6 +30,10 @@ struct ClipCache { QMutex mutex; }; +/*struct ClipPlayback { + +};*/ + struct Clip { Clip(); @@ -51,9 +55,7 @@ struct Clip quint8 color_r; quint8 color_g; quint8 color_b; - long getLength(); - - // inherited information (should be set to the same references in copy()) + long getLength(); Media* media; // attached media MediaStream* media_stream; Sequence* sequence; @@ -64,39 +66,39 @@ struct Clip Transition* opening_transition; Transition* closing_transition; - // media handling - AVFormatContext* formatCtx; - AVStream* stream; - AVCodec* codec; - AVCodecContext* codecCtx; - AVPacket* pkt; - AVFrame* frame; - bool pkt_written; - bool reached_end; - bool open; + // media handling + AVFormatContext* formatCtx; + AVStream* stream; + AVCodec* codec; + AVCodecContext* codecCtx; + AVPacket* pkt; + AVFrame* frame; + bool pkt_written; + bool reached_end; + bool open; bool finished_opening; - // caching functions - bool multithreaded; - Cacher* cacher; - QWaitCondition can_cache; + // caching functions + bool multithreaded; + Cacher* cacher; + QWaitCondition can_cache; quint16 cache_size; - ClipCache cache_A; - ClipCache cache_B; - QMutex lock; - QMutex open_lock; + ClipCache cache_A; + ClipCache cache_B; + QMutex lock; + QMutex open_lock; - // video playback variables - SwsContext* sws_ctx; - QOpenGLTexture* texture; - long texture_frame; + // video playback variables + SwsContext* sws_ctx; + QOpenGLTexture* texture; + long texture_frame; - // audio playback variables - SwrContext* swr_ctx; + // audio playback variables + SwrContext* swr_ctx; bool need_new_audio_frame; - int frame_sample_index; + int frame_sample_index; int audio_buffer_write; - bool reset_audio; + bool reset_audio; bool audio_just_reset; long audio_target_frame; }; diff --git a/project/undo.cpp b/project/undo.cpp new file mode 100644 index 000000000..8ea9917d9 --- /dev/null +++ b/project/undo.cpp @@ -0,0 +1,3 @@ +#include "undo.h" + +QUndoStack undo_stack; diff --git a/project/undo.h b/project/undo.h new file mode 100644 index 000000000..559a2e113 --- /dev/null +++ b/project/undo.h @@ -0,0 +1,13 @@ +#ifndef UNDO_H +#define UNDO_H + +#include +#include +#include + +#include "project/clip.h" +#include "project/sequence.h" + +extern QUndoStack undo_stack; + +#endif // UNDO_H