From 64d6c3a87417cd3b9e7876a04d2135fb176fcb57 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 22 Sep 2018 22:05:38 +1000 Subject: [PATCH] added backend for autoscale --- dialogs/speeddialog.cpp | 2 +- mainwindow.cpp | 3 +-- project/clip.cpp | 3 ++- project/clip.h | 1 + ui/viewerwidget.cpp | 7 +++++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index 51be88cc9..1a8d5878b 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -35,6 +35,6 @@ SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) { reverseLayout->addWidget(reverse); layout->addLayout(reverseLayout, 3, 0, 2, 1); - QDialogButtonBox* buttonBox = new QDialogButtonBox(this, QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); layout->addWidget(buttonBox, 4, 0, 2, 1); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 0df4f6abf..2bab9482a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -426,8 +426,7 @@ void MainWindow::on_actionProject_triggered() project_url.clear(); panel_project->new_project(); updateTitle(""); - panel_timeline->redraw_all_clips(false); - sequence->playhead = 0; + panel_timeline->redraw_all_clips(false); } } diff --git a/project/clip.cpp b/project/clip.cpp index c6e42d215..5c5c02cab 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -29,7 +29,8 @@ Clip::Clip(Sequence* s) : pkt(new AVPacket()), replaced(false), texture(NULL), - fbo(NULL) + fbo(NULL), + autoscale(false) { reset(); } diff --git a/project/clip.h b/project/clip.h index 3612fa8db..8b14806ef 100644 --- a/project/clip.h +++ b/project/clip.h @@ -103,6 +103,7 @@ struct Clip QOpenGLFramebufferObject** fbo; QOpenGLTexture* texture; long texture_frame; + bool autoscale; // audio playback variables SwrContext* swr_ctx; diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index ecc2452b2..9308d3153 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -302,6 +302,13 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { coords.textureTopLeftY = coords.textureTopRightY = coords.textureTopLeftX = coords.textureBottomLeftX = 0; coords.textureBottomLeftY = coords.textureBottomRightY = coords.textureTopRightX = coords.textureBottomRightX = 1.0; + if (c->autoscale && (video_width != s->width || video_height != s->height)) { + double width_multiplier = (double) s->width / (double) video_width; + double height_multiplier = (double) s->height / (double) video_height; + double scale_multiplier = qMin(width_multiplier, height_multiplier); + glScalef(scale_multiplier, scale_multiplier, 1); + } + // EFFECT CODE START for (int j=0;jeffects.size();j++) { Effect* e = c->effects.at(j);