From ee237933ee154cbc8320808462f1632ea05c2690 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 6 Oct 2015 21:26:19 +0200 Subject: [PATCH] Hook up the last previews. --- mainwindow.cpp | 2 ++ mixer.cpp | 71 ++++++++++++++++++++++++++++++++++-------------- mixer.h | 12 ++++++-- ui_mainwindow.ui | 4 +-- 4 files changed, 64 insertions(+), 25 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 65b9580..ad0808c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -17,6 +17,8 @@ MainWindow::MainWindow() ui->me_live->set_output(Mixer::OUTPUT_LIVE); ui->me_preview->set_output(Mixer::OUTPUT_PREVIEW); + ui->preview1->set_output(Mixer::OUTPUT_INPUT0); + ui->preview2->set_output(Mixer::OUTPUT_INPUT1); } void MainWindow::cut() diff --git a/mixer.cpp b/mixer.cpp index 651b459..6de33f0 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -60,6 +60,8 @@ Mixer::Mixer(const QSurfaceFormat &format) resource_pool.reset(new ResourcePool); output_channel[OUTPUT_LIVE].parent = this; output_channel[OUTPUT_PREVIEW].parent = this; + output_channel[OUTPUT_INPUT0].parent = this; + output_channel[OUTPUT_INPUT1].parent = this; ImageFormat inout_format; inout_format.color_space = COLORSPACE_sRGB; @@ -117,14 +119,22 @@ Mixer::Mixer(const QSurfaceFormat &format) display_chain->set_dither_bits(0); // Don't bother. display_chain->finalize(); - // Preview chain (always shows just first input for now). - preview_chain.reset(new EffectChain(WIDTH, HEIGHT, resource_pool.get())); + // Preview chains (always shows just the inputs for now). + preview0_chain.reset(new EffectChain(WIDTH, HEIGHT, resource_pool.get())); check_error(); - preview_input = new YCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR); - preview_chain->add_input(preview_input); - preview_chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); - preview_chain->set_dither_bits(0); // Don't bother. - preview_chain->finalize(); + preview0_input = new YCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR); + preview0_chain->add_input(preview0_input); + preview0_chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); + preview0_chain->set_dither_bits(0); // Don't bother. + preview0_chain->finalize(); + + preview1_chain.reset(new EffectChain(WIDTH, HEIGHT, resource_pool.get())); + check_error(); + preview1_input = new YCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR); + preview1_chain->add_input(preview1_input); + preview1_chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); + preview1_chain->set_dither_bits(0); // Don't bother. + preview1_chain->finalize(); h264_encoder.reset(new H264Encoder(h264_encoder_surface, WIDTH, HEIGHT, "test.mp4")); @@ -474,19 +484,40 @@ void Mixer::thread_func() // The preview frame shows the first input. Note that the textures // are owned by the input frame, not the display frame. - const PBOFrameAllocator::Userdata *input0_userdata = (const PBOFrameAllocator::Userdata *)bmusb_current_rendering_frame[0]->userdata; - GLuint input0_y_tex = input0_userdata->tex_y; - GLuint input0_cbcr_tex = input0_userdata->tex_cbcr; - DisplayFrame preview_frame; - preview_frame.chain = preview_chain.get(); - preview_frame.setup_chain = [this, input0_y_tex, input0_cbcr_tex]{ - preview_input->set_texture_num(0, input0_y_tex); - preview_input->set_texture_num(1, input0_cbcr_tex); - }; - preview_frame.ready_fence = fence; - preview_frame.input_frames = { bmusb_current_rendering_frame[0] }; - preview_frame.temp_textures = {}; - output_channel[OUTPUT_PREVIEW].output_frame(preview_frame); + { + const PBOFrameAllocator::Userdata *input0_userdata = (const PBOFrameAllocator::Userdata *)bmusb_current_rendering_frame[0]->userdata; + GLuint input0_y_tex = input0_userdata->tex_y; + GLuint input0_cbcr_tex = input0_userdata->tex_cbcr; + DisplayFrame preview0_frame; + preview0_frame.chain = preview0_chain.get(); + preview0_frame.setup_chain = [this, input0_y_tex, input0_cbcr_tex]{ + preview0_input->set_texture_num(0, input0_y_tex); + preview0_input->set_texture_num(1, input0_cbcr_tex); + }; + preview0_frame.ready_fence = fence; + preview0_frame.input_frames = { bmusb_current_rendering_frame[0] }; + preview0_frame.temp_textures = {}; + output_channel[OUTPUT_PREVIEW].output_frame(preview0_frame); + output_channel[OUTPUT_INPUT0].output_frame(preview0_frame); + } + + // Same for the other preview. + // TODO: Use a for loop. Gah. + { + const PBOFrameAllocator::Userdata *input1_userdata = (const PBOFrameAllocator::Userdata *)bmusb_current_rendering_frame[1]->userdata; + GLuint input1_y_tex = input1_userdata->tex_y; + GLuint input1_cbcr_tex = input1_userdata->tex_cbcr; + DisplayFrame preview1_frame; + preview1_frame.chain = preview1_chain.get(); + preview1_frame.setup_chain = [this, input1_y_tex, input1_cbcr_tex]{ + preview1_input->set_texture_num(0, input1_y_tex); + preview1_input->set_texture_num(1, input1_cbcr_tex); + }; + preview1_frame.ready_fence = fence; + preview1_frame.input_frames = { bmusb_current_rendering_frame[1] }; + preview1_frame.temp_textures = {}; + output_channel[OUTPUT_INPUT1].output_frame(preview1_frame); + } clock_gettime(CLOCK_MONOTONIC, &now); double elapsed = now.tv_sec - start.tv_sec + diff --git a/mixer.h b/mixer.h index cde9a2f..03aab6d 100644 --- a/mixer.h +++ b/mixer.h @@ -41,6 +41,8 @@ public: enum Output { OUTPUT_LIVE = 0, OUTPUT_PREVIEW, + OUTPUT_INPUT0, + OUTPUT_INPUT1, NUM_OUTPUTS }; @@ -89,7 +91,8 @@ private: std::unique_ptr resource_pool; std::unique_ptr chain; std::unique_ptr display_chain; - std::unique_ptr preview_chain; + std::unique_ptr preview0_chain; + std::unique_ptr preview1_chain; GLuint cbcr_program_num; // Owned by . std::unique_ptr h264_encoder; @@ -101,8 +104,11 @@ private: // Effects part of . Owned by . movit::FlatInput *display_input; - // Effects part of . Owned by . - movit::YCbCrInput *preview_input; + // Effects part of . Owned by . + movit::YCbCrInput *preview0_input; + + // Effects part of . Owned by . + movit::YCbCrInput *preview1_input; Source current_source = SOURCE_INPUT1; int frame = 0; diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 49eab47..c91edec 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -140,7 +140,7 @@ 0 - + 1 @@ -150,7 +150,7 @@ - + 1 -- 2.39.2