From 2d6d164028679a48b137ec4761e5d9d93eb7f29e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 4 Oct 2015 19:52:26 +0200 Subject: [PATCH] Hook up the cut button to something that is not really cut, but is more useful than nothing. --- mainwindow.cpp | 11 +++++++-- mainwindow.h | 7 ++++-- mixer.cpp | 63 +++++++++++++++++++++++++++++++++++--------------- mixer.h | 7 ++++++ 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index e47118c..b8d9e67 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,6 +11,13 @@ using std::thread; MainWindow::MainWindow() { - Ui::MainWindow *window = new Ui::MainWindow; - window->setupUi(this); + Ui::MainWindow *ui = new Ui::MainWindow; + ui->setupUi(this); + connect(ui->cut_btn, SIGNAL(clicked()), this, SLOT(cut())); +} + +void MainWindow::cut() +{ + static int i = 0; + mixer_cut(Source((++i) % 3)); } diff --git a/mainwindow.h b/mainwindow.h index fd60640..3f3d8b6 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,10 +5,13 @@ class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - MainWindow(); + MainWindow(); + +public slots: + void cut(); }; #endif diff --git a/mixer.cpp b/mixer.cpp index 10350a5..0c36c48 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -57,7 +57,7 @@ using namespace movit; using namespace std; using namespace std::placeholders; -static float t = 0.0f; +Source current_source = SOURCE_INPUT1; ResourcePool *resource_pool; @@ -305,7 +305,6 @@ void mixer_thread_func(QSurface *surface, QSurface *surface2, QSurface *surface3 GLint input_tex_pbo = (GLint)(intptr_t)bmusb_current_rendering_frame[card_index].userdata; input[card_index]->set_pixel_data(0, nullptr, input_tex_pbo); input[card_index]->set_pixel_data(1, nullptr, input_tex_pbo); - check_error(); } //chain.enable_phase_timing(true); @@ -350,22 +349,43 @@ void mixer_thread_func(QSurface *surface, QSurface *surface2, QSurface *surface3 float right1 = 1280 - 16; float top1 = bottom1 - height1; float left1 = right1 - width1; - - float t = 0.5 + 0.5 * cos(frame * 0.006); - //float t = 0.0; - float scale0 = 1.0 + t * (1280.0 / 848.0 - 1.0); - float tx0 = 0.0 + t * (-16.0 * scale0); - float ty0 = 0.0 + t * (-48.0 * scale0); - - top0 = top0 * scale0 + ty0; - bottom0 = bottom0 * scale0 + ty0; - left0 = left0 * scale0 + tx0; - right0 = right0 * scale0 + tx0; - - top1 = top1 * scale0 + ty0; - bottom1 = bottom1 * scale0 + ty0; - left1 = left1 * scale0 + tx0; - right1 = right1 * scale0 + tx0; + + if (current_source == SOURCE_INPUT1) { + top0 = 0.0; + bottom0 = HEIGHT; + left0 = 0.0; + right0 = WIDTH; + + top1 = HEIGHT + 10; + bottom1 = HEIGHT + 20; + left1 = WIDTH + 10; + right1 = WIDTH + 20; + } else if (current_source == SOURCE_INPUT2) { + top1 = 0.0; + bottom1 = HEIGHT; + left1 = 0.0; + right1 = WIDTH; + + top0 = HEIGHT + 10; + bottom0 = HEIGHT + 20; + left0 = WIDTH + 10; + right0 = WIDTH + 20; + } else { + float t = 0.5 + 0.5 * cos(frame * 0.006); + float scale0 = 1.0 + t * (1280.0 / 848.0 - 1.0); + float tx0 = 0.0 + t * (-16.0 * scale0); + float ty0 = 0.0 + t * (-48.0 * scale0); + + top0 = top0 * scale0 + ty0; + bottom0 = bottom0 * scale0 + ty0; + left0 = left0 * scale0 + tx0; + right0 = right0 * scale0 + tx0; + + top1 = top1 * scale0 + ty0; + bottom1 = bottom1 * scale0 + ty0; + left1 = left1 * scale0 + tx0; + right1 = right1 * scale0 + tx0; + } place_rectangle(resample_effect, padding_effect, left0, top0, right0, bottom0); place_rectangle(resample2_effect, padding2_effect, left1, top1, right1, bottom1); @@ -403,6 +423,7 @@ void mixer_thread_func(QSurface *surface, QSurface *surface2, QSurface *surface3 // knowing when the current one is released.) input_frames_to_release.push_back(bmusb_current_rendering_frame[card_index]); bmusb_current_rendering_frame[card_index] = card->new_frame; + check_error(); // The new texture might still be uploaded, // tell the GPU to wait until it's there. @@ -527,6 +548,7 @@ void mixer_thread_func(QSurface *surface, QSurface *surface2, QSurface *surface3 start = now; } #endif + check_error(); } glDeleteVertexArrays(1, &vao); resource_pool->release_glsl_program(cbcr_program_num); @@ -579,3 +601,8 @@ void mixer_quit() quit = true; mixer_thread.join(); } + +void mixer_cut(Source source) +{ + current_source = source; +} diff --git a/mixer.h b/mixer.h index 8bd023d..2c6e51c 100644 --- a/mixer.h +++ b/mixer.h @@ -7,6 +7,13 @@ class QSurface; void start_mixer(QSurface *surface, QSurface *surface2, QSurface *surface3, QSurface *surface4); void mixer_quit(); +enum Source { + SOURCE_INPUT1, + SOURCE_INPUT2, + SOURCE_SBS, +}; +void mixer_cut(Source source); + struct DisplayFrame { GLuint texnum; RefCountedGLsync ready_fence; // Asserted when the texture is done rendering. -- 2.39.2