merge of long discussed new pipeline

This commit is contained in:
itsmattkc
2019-05-04 10:48:20 +10:00
382 changed files with 22362 additions and 11653 deletions
+30 -32
View File
@@ -1,20 +1,20 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
@@ -29,13 +29,11 @@ extern "C" {
#include <QApplication>
#include <QOffscreenSurface>
#include <QOpenGLFramebufferObject>
#include <QOpenGLPaintDevice>
#include <QPainter>
#include <QtMath>
#include "global/global.h"
#include "timeline/sequence.h"
#include "panels/panels.h"
#include "ui/viewerwidget.h"
#include "rendering/renderthread.h"
@@ -162,7 +160,8 @@ bool ExportThread::SetupVideo() {
break;
}
break;
default:
break;
}
// Set export to be multithreaded
@@ -193,16 +192,16 @@ 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 = params_.sequence->width;
video_frame->height = params_.sequence->height;
av_frame_get_buffer(video_frame, 0);
av_init_packet(&video_pkt);
// Set up conversion context
sws_ctx = sws_getContext(
olive::ActiveSequence->width,
olive::ActiveSequence->height,
params_.sequence->width,
params_.sequence->height,
AV_PIX_FMT_RGBA,
params_.video_width,
params_.video_height,
@@ -289,7 +288,7 @@ bool ExportThread::SetupAudio() {
acodec_ctx->channel_layout,
acodec_ctx->sample_fmt,
acodec_ctx->sample_rate,
olive::ActiveSequence->audio_layout,
params_.sequence->audio_layout,
AV_SAMPLE_FMT_S16,
acodec_ctx->sample_rate,
0,
@@ -408,14 +407,14 @@ void ExportThread::Export()
long remaining_frames, frame_count = 1;
// Use Sequence Viewer's render thread - TODO separate this into a new render thread for background rendering
RenderThread* renderer = panel_sequence_viewer->viewer_widget->get_renderer();
RenderThread* renderer = panel_sequence_viewer->viewer_widget()->get_renderer();
// Override connection from RenderThread
disconnect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget, SLOT(queue_repaint()));
disconnect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget(), SLOT(queue_repaint()));
connect(renderer, SIGNAL(ready()), this, SLOT(wake()));
// Loop from now (set to the beginning frame earlier) to the end of the frame
while (olive::ActiveSequence->playhead <= params_.end_frame && !interrupt_) {
while (params_.sequence->playhead <= params_.end_frame && !interrupt_) {
// Start timing how long this frame will take
frame_start_time = QDateTime::currentMSecsSinceEpoch();
@@ -424,14 +423,14 @@ void ExportThread::Export()
if (params_.audio_enabled) {
waiting_for_audio_ = true;
SetAudioWakeObject(this);
olive::rendering::compose_audio(nullptr, olive::ActiveSequence.get(), 1, true);
olive::rendering::compose_audio(nullptr, params_.sequence, 1, true);
}
// If we're exporting video, trigger a render on the RenderThread
if (params_.video_enabled) {
do {
// TODO optimize by rendering the next frame while encoding the last
renderer->start_render(nullptr, olive::ActiveSequence.get(), 1, nullptr, video_frame->data[0], video_frame->linesize[0]/4);
renderer->start_render(nullptr, params_.sequence, 1, nullptr, video_frame->data[0], video_frame->linesize[0]/4);
// Wait for RenderThread to return
waitCond.wait(&mutex);
@@ -450,7 +449,7 @@ void ExportThread::Export()
}
// Get the current sequence playhead in seconds (used for timestamp calculations later on)
double timecode_secs = double(olive::ActiveSequence->playhead - params_.start_frame) / olive::ActiveSequence->frame_rate;
double timecode_secs = double(params_.sequence->playhead - params_.start_frame) / params_.sequence->frame_rate;
// If we're exporting video, construct an AVFrame in the destination codec's pixel format to convert the raw RGBA
// OpenGL buffer to
@@ -536,15 +535,15 @@ void ExportThread::Export()
// Generating encoding statistics (e.g. the time it took to encode this frame/estimated remaining time)
frame_time = (QDateTime::currentMSecsSinceEpoch()-frame_start_time);
total_time += frame_time;
remaining_frames = (params_.end_frame - olive::ActiveSequence->playhead);
remaining_frames = (params_.end_frame - params_.sequence->playhead);
avg_time = (total_time/frame_count);
eta = (remaining_frames*avg_time);
// Emit a signal for the percent of the sequence that's been encoded so far
emit ProgressChanged(qRound((double(olive::ActiveSequence->playhead - params_.start_frame) / double(params_.end_frame - params_.start_frame)) * 100.0), eta);
emit ProgressChanged(qRound((double(params_.sequence->playhead - params_.start_frame) / double(params_.end_frame - params_.start_frame)) * 100.0), eta);
// Increment sequence playhead
olive::ActiveSequence->playhead++;
params_.sequence->playhead++;
// Increment frame count (used for generating encoding statistics above)
frame_count++;
@@ -552,7 +551,7 @@ void ExportThread::Export()
// Restore original connection from RenderThread
disconnect(renderer, SIGNAL(ready()), this, SLOT(wake()));
connect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget, SLOT(queue_repaint()));
connect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget(), SLOT(queue_repaint()));
if (interrupt_) {
return;
@@ -561,8 +560,7 @@ void ExportThread::Export()
if (params_.video_enabled) vpkt_alloc = true;
if (params_.audio_enabled) apkt_alloc = true;
olive::Global->set_rendering_state(false);
close_active_clips(olive::ActiveSequence.get());
olive::Global->set_export_state(false);
// If audio is enabled, flush the rest of the audio out of swresample
if (params_.audio_enabled) {