From: Good Guy Date: Thu, 26 Mar 2020 03:47:47 +0000 (-0600) Subject: fix aspect ratio on split screen drag handle, add videoscope to editpanel in cwindow... X-Git-Tag: 2020-03~6 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=b5bfe3e40a7255ae60a21d885587ada6e145e3d5;p=goodguy%2Fcinelerra.git fix aspect ratio on split screen drag handle, add videoscope to editpanel in cwindow,vwindow --- diff --git a/cinelerra-5.1/cinelerra/canvas.C b/cinelerra-5.1/cinelerra/canvas.C index 2319f14b..a1f45854 100644 --- a/cinelerra-5.1/cinelerra/canvas.C +++ b/cinelerra-5.1/cinelerra/canvas.C @@ -690,6 +690,7 @@ int Canvas::keypress_event(BC_WindowBase *caller) return 1; } +// process_scope uses the refresh frame for opengl void Canvas::update_refresh(VideoDevice *device, VFrame *output_frame) { int best_color_model = output_frame->get_color_model(); @@ -734,6 +735,20 @@ void Canvas::update_refresh(VideoDevice *device, VFrame *output_frame) refresh_frame->transfer_from(output_frame, -1); } +void Canvas::process_scope(VideoDevice *video, VFrame *frame) +{ + if( !scope_on() ) return; + int use_opengl = + video->out_config->driver == PLAYBACK_X11_GL && + frame->get_opengl_state() != VFrame::RAM; + if( use_opengl ) { + update_refresh(video, frame); + frame = refresh_frame; + } + if( frame ) + draw_scope(frame); +} + void Canvas::clear(int flash) { BC_WindowBase *window = get_canvas(); diff --git a/cinelerra-5.1/cinelerra/canvas.h b/cinelerra-5.1/cinelerra/canvas.h index dd3b574d..c3cb2831 100644 --- a/cinelerra-5.1/cinelerra/canvas.h +++ b/cinelerra-5.1/cinelerra/canvas.h @@ -126,6 +126,10 @@ public: // Redraws the refresh_frame virtual void draw_refresh(int flush = 1) {}; virtual void clear(int flash=1); +// draw scope + virtual int scope_on() { return 0; } + virtual void draw_scope(VFrame *frame) {} + void process_scope(VideoDevice *video, VFrame *frame); // Get top left offset of canvas relative to output. // Normally negative. Can be positive if output is smaller than canvas. diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index c0d64487..7cb5a100 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -758,7 +758,8 @@ CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) 1, // use_cut 0, // use_commerical 0, // use_goto - 1) // use_clk2play + 1, // use_clk2play + 1) // use_scope { this->mwindow = mwindow; this->cwindow = cwindow; @@ -1091,6 +1092,18 @@ int CWindowCanvas::do_scroll(EDL *edl, float cursor_x, float cursor_y) return 1; } +int CWindowCanvas::scope_on() +{ + return !gui->edit_panel->scope_dialog ? 0 : + gui->edit_panel->scope_dialog->running(); +} + +void CWindowCanvas::draw_scope(VFrame *output) +{ + if( gui->edit_panel->scope_dialog ) + gui->edit_panel->scope_dialog->process(output); +} + void CWindowCanvas::draw_refresh(int flush) { BC_WindowBase *window = get_canvas(); diff --git a/cinelerra-5.1/cinelerra/cwindowgui.h b/cinelerra-5.1/cinelerra/cwindowgui.h index fad225f3..e663c351 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.h +++ b/cinelerra-5.1/cinelerra/cwindowgui.h @@ -304,6 +304,8 @@ public: void reset_projector(); void draw_crophandle(int x, int y); int set_fullscreen(int on, int unlock); + int scope_on(); + void draw_scope(VFrame *output); // Draw the camera/projector overlay in different colors. void draw_outlines(int do_camera); diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index 2cb6b27f..74aa53c9 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -34,18 +34,21 @@ #include "language.h" #include "localsession.h" #include "mainclock.h" +#include "mainsession.h" #include "mainundo.h" +#include "manualgoto.h" #include "mbuttons.h" #include "meterpanel.h" #include "mwindow.h" #include "mwindowgui.h" #include "playbackengine.h" +#include "preferences.h" +#include "scopewindow.h" #include "theme.h" #include "timebar.h" #include "trackcanvas.h" #include "transportque.h" #include "zoombar.h" -#include "manualgoto.h" @@ -70,7 +73,8 @@ EditPanel::EditPanel(MWindow *mwindow, int use_cut, int use_commercial, int use_goto, - int use_clk2play) + int use_clk2play, + int use_scope) { this->window_id = window_id; this->editing_mode = editing_mode; @@ -92,6 +96,7 @@ EditPanel::EditPanel(MWindow *mwindow, this->use_commercial = use_commercial; this->use_goto = use_goto; this->use_clk2play = use_clk2play; + this->use_scope = use_scope; this->x = x; this->y = y; @@ -121,11 +126,14 @@ EditPanel::EditPanel(MWindow *mwindow, this->span_keyframe = 0; this->mangoto = 0; this->click2play = 0; + this->scope = 0; + this->scope_dialog = 0; locklabels = 0; } EditPanel::~EditPanel() { + delete scope_dialog; } void EditPanel::set_meters(MeterPanel *meter_panel) @@ -310,11 +318,18 @@ void EditPanel::create_buttons() } if( use_clk2play ) { - click2play = new EditClick2Play(mwindow, this, x1, y1+5); + click2play = new EditClick2Play(mwindow, this, x1, y1+yS(3)); subwindow->add_subwindow(click2play); x1 += click2play->get_w(); } + if( use_scope ) { + scope = new EditPanelScope(mwindow, this, x1, y1-yS(1)); + subwindow->add_subwindow(scope); + x1 += scope->get_w(); + scope_dialog = new EditPanelScopeDialog(mwindow, this); + } + if( use_commercial ) { commercial = new EditCommercial(mwindow, this, x1, y1); subwindow->add_subwindow(commercial); @@ -423,9 +438,13 @@ void EditPanel::reposition_buttons(int x, int y) x1 += mangoto->get_w(); } if( use_clk2play ) { - click2play->reposition_window(x1, y1+5); + click2play->reposition_window(x1, y1+yS(3)); x1 += click2play->get_w(); } + if( use_scope ) { + scope->reposition_window(x1, y1-yS(1)); + x1 += scope->get_w(); + } } void EditPanel::create_objects() @@ -1131,3 +1150,128 @@ int EditRedo::handle_event() return 1; } + +EditPanelScopeDialog::EditPanelScopeDialog(MWindow *mwindow, EditPanel *panel) + : BC_DialogThread() +{ + this->mwindow = mwindow; + this->panel = panel; + scope_gui = 0; + gui_lock = new Mutex("EditPanelScopeDialog::gui_lock"); +} + +EditPanelScopeDialog::~EditPanelScopeDialog() +{ + close_window(); + delete gui_lock; +} + +void EditPanelScopeDialog::handle_done_event(int result) +{ + gui_lock->lock("EditPanelScopeDialog::handle_done_event"); + scope_gui = 0; + gui_lock->unlock(); + + panel->subwindow->lock_window("EditPanelScopeDialog::handle_done_event"); + panel->scope->update(0); + panel->subwindow->unlock_window(); +} + +BC_Window* EditPanelScopeDialog::new_gui() +{ + EditPanelScopeGUI *gui = new EditPanelScopeGUI(mwindow, this); + gui->create_objects(); + scope_gui = gui; + return gui; +} + +void EditPanelScopeDialog::process(VFrame *output_frame) +{ + if( panel->scope_dialog ) { + panel->scope_dialog->gui_lock->lock("EditPanelScopeDialog::process"); + if( panel->scope_dialog->scope_gui ) { + EditPanelScopeGUI *gui = panel->scope_dialog->scope_gui; + gui->process(output_frame); + } + panel->scope_dialog->gui_lock->unlock(); + } +} + +EditPanelScopeGUI::EditPanelScopeGUI(MWindow *mwindow, EditPanelScopeDialog *dialog) + : ScopeGUI(mwindow->theme, + mwindow->session->scope_x, mwindow->session->scope_y, + mwindow->session->scope_w, mwindow->session->scope_h, + mwindow->preferences->processors) +{ + this->mwindow = mwindow; + this->dialog = dialog; +} + +EditPanelScopeGUI::~EditPanelScopeGUI() +{ +} + +void EditPanelScopeGUI::create_objects() +{ + MainSession *session = mwindow->session; + use_hist = session->use_hist; + use_wave = session->use_wave; + use_vector = session->use_vector; + use_hist_parade = session->use_hist_parade; + use_wave_parade = session->use_wave_parade; + ScopeGUI::create_objects(); +} + +void EditPanelScopeGUI::toggle_event() +{ + MainSession *session = mwindow->session; + session->use_hist = use_hist; + session->use_wave = use_wave; + session->use_vector = use_vector; + session->use_hist_parade = use_hist_parade; + session->use_wave_parade = use_wave_parade; +} + +int EditPanelScopeGUI::translation_event() +{ + ScopeGUI::translation_event(); + MainSession *session = mwindow->session; + session->scope_x = get_x(); + session->scope_y = get_y(); + return 0; +} + +int EditPanelScopeGUI::resize_event(int w, int h) +{ + ScopeGUI::resize_event(w, h); + MainSession *session = mwindow->session; + session->scope_w = w; + session->scope_h = h; + return 0; +} + +EditPanelScope::EditPanelScope(MWindow *mwindow, EditPanel *panel, int x, int y) + : BC_Toggle(x, y, mwindow->theme ? + mwindow->theme->get_image_set("scope_toggle") : 0, 0) +{ + this->mwindow = mwindow; + this->panel = panel; + set_tooltip(_("View scope")); +} + +EditPanelScope::~EditPanelScope() +{ +} + +int EditPanelScope::handle_event() +{ + unlock_window(); + int v = get_value(); + if( v ) + panel->scope_dialog->start(); + else + panel->scope_dialog->close_window(); + lock_window("EditPanelScope::handle_event"); + return 1; +} + diff --git a/cinelerra-5.1/cinelerra/editpanel.h b/cinelerra-5.1/cinelerra/editpanel.h index 67ab431d..9e0d3bcb 100644 --- a/cinelerra-5.1/cinelerra/editpanel.h +++ b/cinelerra-5.1/cinelerra/editpanel.h @@ -22,11 +22,15 @@ #ifndef EDITPANEL_H #define EDITPANEL_H +#include "bcdialog.h" #include "guicast.h" #include "editpanel.inc" #include "meterpanel.inc" #include "mwindow.inc" #include "manualgoto.inc" +#include "scopewindow.h" + + class EditPanel; @@ -341,6 +345,49 @@ public: }; +class EditPanelScopeGUI : public ScopeGUI +{ +public: + EditPanelScopeGUI(MWindow *mwindow, EditPanelScopeDialog *dialog); + ~EditPanelScopeGUI(); + + void create_objects(); + void toggle_event(); + int translation_event(); + int resize_event(int w, int h); + + MWindow *mwindow; + EditPanelScopeDialog *dialog; +}; + +class EditPanelScopeDialog : public BC_DialogThread +{ +public: + EditPanelScopeDialog(MWindow *mwindow, EditPanel *panel); + ~EditPanelScopeDialog(); + + void handle_done_event(int result); + BC_Window* new_gui(); + void process(VFrame *output_frame); + + MWindow *mwindow; + EditPanel *panel; + EditPanelScopeGUI *scope_gui; + Mutex *gui_lock; + VFrame *output_frame; +}; + +class EditPanelScope : public BC_Toggle +{ +public: + EditPanelScope(MWindow *mwindow, EditPanel *panel, int x, int y); + ~EditPanelScope(); + int handle_event(); + EditPanel *panel; + MWindow *mwindow; +}; + + class EditPanel { public: @@ -362,7 +409,8 @@ public: int use_cut, int use_commerical, int use_goto, - int use_clk2play); + int use_clk2play, + int use_scope); ~EditPanel(); void set_meters(MeterPanel *meter_panel); @@ -424,6 +472,7 @@ public: int use_commercial; int use_goto; int use_clk2play; + int use_scope; EditFit *fit; EditFitAutos *fit_autos; @@ -438,6 +487,8 @@ public: EditCommercial *commercial; EditManualGoto *mangoto; EditClick2Play *click2play; + EditPanelScope *scope; + EditPanelScopeDialog *scope_dialog; EditCopy *copy; EditPaste *paste; EditLabelbutton *labelbutton; diff --git a/cinelerra-5.1/cinelerra/editpanel.inc b/cinelerra-5.1/cinelerra/editpanel.inc index 8b0c4147..f9910135 100644 --- a/cinelerra-5.1/cinelerra/editpanel.inc +++ b/cinelerra-5.1/cinelerra/editpanel.inc @@ -52,6 +52,10 @@ class EditNextEdit; class ArrowButton; class IBeamButton; class KeyFrameButton; +class SpanKeyFrameButton; class LockLabelsButton; +class EditPanelScopeGUI; +class EditPanelScopeDialog; +class EditPanelScope; #endif diff --git a/cinelerra-5.1/cinelerra/mbuttons.C b/cinelerra-5.1/cinelerra/mbuttons.C index 5aa8677e..b863a313 100644 --- a/cinelerra-5.1/cinelerra/mbuttons.C +++ b/cinelerra-5.1/cinelerra/mbuttons.C @@ -142,7 +142,8 @@ MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y) 1, // use_cut mwindow->has_commercials(), // use_commerical 1, // use_goto - 0) // use_clk2play + 0, // use_clk2play + 0) // use_scope { this->mwindow = mwindow; this->mbuttons = mbuttons; diff --git a/cinelerra-5.1/cinelerra/playback3d.C b/cinelerra-5.1/cinelerra/playback3d.C index 295ce6fe..9eee736f 100644 --- a/cinelerra-5.1/cinelerra/playback3d.C +++ b/cinelerra-5.1/cinelerra/playback3d.C @@ -509,63 +509,63 @@ void Playback3D::copy_from_sync(Playback3DCommand *command) if( window ) { window->enable_opengl(); glFinish(); + int copy_to_ram = 0; int w = command->input->get_w(); int h = command->input->get_h(); - - if(command->input->get_opengl_state() == VFrame::SCREEN && - w == command->frame->get_w() && h == command->frame->get_h()) - { + if( command->input->get_opengl_state() == VFrame::SCREEN && + w == command->frame->get_w() && h == command->frame->get_h() ) { // printf("Playback3D::copy_from_sync 1 %d %d %d %d %d\n", -// command->input->get_w(), -// command->input->get_h(), -// command->frame->get_w(), -// command->frame->get_h(), +// command->input->get_w(), command->input->get_h(), +// command->frame->get_w(), command->frame->get_h(), // command->frame->get_color_model()); #ifdef GLx4 // With NVidia at least - if(w % 4) - { + if(w % 4) { printf("Playback3D::copy_from_sync: w=%d not supported because it is not divisible by 4.\n", w); } else #endif // Copy to texture - if(command->want_texture) - { + if( command->want_texture ) { //printf("Playback3D::copy_from_sync 1 dst=%p src=%p\n", command->frame, command->input); // Screen_to_texture requires the source pbuffer enabled. command->input->enable_opengl(); command->frame->screen_to_texture(); command->frame->set_opengl_state(VFrame::TEXTURE); } - else -// Copy to RAM - { + else { command->input->to_texture(); - command->input->bind_texture(0); - command->frame->enable_opengl(); - command->frame->init_screen(); - unsigned int shader = BC_CModels::is_yuv(command->input->get_color_model()) ? - VFrame::make_shader(0, yuv_to_rgb_frag, 0) : 0; - if( shader > 0 ) { - glUseProgram(shader); - int variable = glGetUniformLocation(shader, "tex"); - glUniform1i(variable, 0); - BC_GL_YUV_TO_RGB(shader); - } - else - glUseProgram(0); - command->input->draw_texture(1); - command->frame->screen_to_ram(); - glUseProgram(0); + copy_to_ram = 1; } } - else - { + else if( command->input->get_opengl_state() == VFrame::TEXTURE && + w == command->frame->get_w() && h == command->frame->get_h() ) { + copy_to_ram = 1; + } + else { printf("Playback3D::copy_from_sync: invalid formats opengl_state=%d %dx%d -> %dx%d\n", command->input->get_opengl_state(), w, h, command->frame->get_w(), command->frame->get_h()); } + + if( copy_to_ram ) { + command->input->bind_texture(0); + command->frame->enable_opengl(); + command->frame->init_screen(); + unsigned int shader = BC_CModels::is_yuv(command->input->get_color_model()) ? + VFrame::make_shader(0, yuv_to_rgb_frag, 0) : 0; + if( shader > 0 ) { + glUseProgram(shader); + int variable = glGetUniformLocation(shader, "tex"); + glUniform1i(variable, 0); + BC_GL_YUV_TO_RGB(shader); + } + else + glUseProgram(0); + command->input->draw_texture(1); + command->frame->screen_to_ram(); + glUseProgram(0); + } } command->canvas->unlock_canvas(); #endif diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index dd03089c..0d8b0634 100644 --- a/cinelerra-5.1/cinelerra/renderengine.C +++ b/cinelerra-5.1/cinelerra/renderengine.C @@ -24,6 +24,7 @@ #include "asset.h" #include "audiodevice.h" #include "bcsignals.h" +#include "canvas.h" #include "condition.h" #include "edl.h" #include "edlsession.h" @@ -491,3 +492,11 @@ void RenderEngine::wait_done() render_active->unlock(); } +void RenderEngine::update_scope(VFrame *frame) +{ + if( !video || !output || !output->scope_on() ) return; + output->lock_canvas("RenderEngine::update_scope"); + output->process_scope(video, frame); + output->unlock_canvas(); +} + diff --git a/cinelerra-5.1/cinelerra/renderengine.h b/cinelerra-5.1/cinelerra/renderengine.h index d3853a1d..abe7b707 100644 --- a/cinelerra-5.1/cinelerra/renderengine.h +++ b/cinelerra-5.1/cinelerra/renderengine.h @@ -87,6 +87,8 @@ public: // Update preferences window void update_framerate(float framerate); +// update canvas scope gui + void update_scope(VFrame *frame); // Copy of command TransportCommand *command; @@ -99,7 +101,6 @@ public: // Canvas if being used for CWindow Canvas *output; - // Lock out new commands until completion Condition *input_lock; // Lock out interrupts until started diff --git a/cinelerra-5.1/cinelerra/scopewindow.C b/cinelerra-5.1/cinelerra/scopewindow.C index 4de87436..25e386f4 100644 --- a/cinelerra-5.1/cinelerra/scopewindow.C +++ b/cinelerra-5.1/cinelerra/scopewindow.C @@ -26,21 +26,13 @@ #include "scopewindow.h" #include "theme.h" - #include - - ScopePackage::ScopePackage() : LoadPackage() { } - - - - - ScopeUnit::ScopeUnit(ScopeGUI *gui, ScopeEngine *server) : LoadClient(server) @@ -48,16 +40,8 @@ ScopeUnit::ScopeUnit(ScopeGUI *gui, this->gui = gui; } - - - - void ScopeUnit::draw_point(unsigned char **rows, - int x, - int y, - int r, - int g, - int b) + int x, int y, int r, int g, int b) { unsigned char *pixel = rows[y] + x * 4; pixel[0] = b; @@ -65,18 +49,14 @@ void ScopeUnit::draw_point(unsigned char **rows, pixel[2] = r; } -#define PROCESS_PIXEL(column) \ -{ \ +#define PROCESS_PIXEL(column) { \ /* Calculate histogram */ \ - if(use_hist) \ - { \ + if(use_hist) { \ int v_i = (intensity - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \ CLAMP(v_i, 0, TOTAL_BINS - 1); \ bins[3][v_i]++; \ } \ - else \ - if(use_hist_parade) \ - { \ + else if(use_hist_parade) { \ int r_i = (r - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \ int g_i = (g - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \ int b_i = (b - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \ @@ -87,123 +67,74 @@ void ScopeUnit::draw_point(unsigned char **rows, bins[1][g_i]++; \ bins[2][b_i]++; \ } \ - \ /* Calculate waveform */ \ - if(use_wave || use_wave_parade) \ - { \ - x = (column) * wave_w / w; \ - if(x >= 0 && x < wave_w) \ - { \ - if(use_wave_parade) \ - { \ - y = wave_h - \ - (int)((r - FLOAT_MIN) / \ - (FLOAT_MAX - FLOAT_MIN) * \ - wave_h); \ - \ - if(y >= 0 && y < wave_h) \ - draw_point(waveform_rows, x / 3, y, 0xff, 0x0, 0x0); \ - \ - y = wave_h - \ - (int)((g - FLOAT_MIN) / \ - (FLOAT_MAX - FLOAT_MIN) * \ - wave_h); \ - \ - if(y >= 0 && y < wave_h) \ - draw_point(waveform_rows, x / 3 + wave_w / 3, y, 0x0, 0xff, 0x0); \ - \ - y = wave_h - \ - (int)((b - FLOAT_MIN) / \ - (FLOAT_MAX - FLOAT_MIN) * \ - wave_h); \ - \ - if(y >= 0 && y < wave_h) \ - draw_point(waveform_rows, x / 3 + wave_w / 3 * 2, y, 0x0, 0x0, 0xff); \ - \ + if(use_wave || use_wave_parade) { \ + int ix = (column) * wave_w / w; \ + if(ix >= 0 && ix < wave_w) { \ + if(use_wave_parade) { \ + int iy = wave_h - (int)((r - FLOAT_MIN) / \ + (FLOAT_MAX - FLOAT_MIN) * wave_h); \ + if(iy >= 0 && iy < wave_h) \ + draw_point(waveform_rows, ix / 3, iy, 0xff, 0x0, 0x0); \ + iy = wave_h - (int)((g - FLOAT_MIN) / \ + (FLOAT_MAX - FLOAT_MIN) * wave_h); \ + if(iy >= 0 && iy < wave_h) \ + draw_point(waveform_rows, ix / 3 + wave_w / 3, iy, 0x0, 0xff, 0x0); \ + iy = wave_h - (int)((b - FLOAT_MIN) / \ + (FLOAT_MAX - FLOAT_MIN) * wave_h); \ + if(iy >= 0 && iy < wave_h) \ + draw_point(waveform_rows, ix / 3 + wave_w / 3 * 2, iy, 0x0, 0x0, 0xff); \ } \ - else \ - { \ - y = wave_h - \ - (int)((intensity - FLOAT_MIN) / \ - (FLOAT_MAX - FLOAT_MIN) * \ - wave_h); \ - \ - if(y >= 0 && y < wave_h) \ - draw_point(waveform_rows, \ - x, \ - y, \ - 0xff, \ - 0xff, \ - 0xff); \ + else { \ + int iy = wave_h - (int)((intensity - FLOAT_MIN) / \ + (FLOAT_MAX - FLOAT_MIN) * wave_h); \ + if(iy >= 0 && iy < wave_h) \ + draw_point(waveform_rows, ix, iy, 0xff, 0xff, 0xff); \ } \ } \ } \ - \ /* Calculate vectorscope */ \ - if(use_vector) \ - { \ + if(use_vector) { \ float adjacent = cos((h + 90) / 360 * 2 * M_PI); \ float opposite = sin((h + 90) / 360 * 2 * M_PI); \ - \ - x = (int)(vector_w / 2 + \ - adjacent * (s) / (FLOAT_MAX) * radius); \ - \ - y = (int)(vector_h / 2 - \ - opposite * (s) / (FLOAT_MAX) * radius); \ - \ - \ - CLAMP(x, 0, vector_w - 1); \ + int ix = vector_w / 2 + adjacent * (s) / (FLOAT_MAX) * radius; \ + int y = vector_h / 2 - opposite * (s) / (FLOAT_MAX) * radius; \ + CLAMP(ix, 0, vector_w - 1); \ CLAMP(y, 0, vector_h - 1); \ - \ /* Get color with full saturation & value */ \ float r_f, g_f, b_f; \ - HSV::hsv_to_rgb(r_f, \ - g_f, \ - b_f, \ - h, \ - s, \ - 1); \ - \ - draw_point(vector_rows, \ - x, \ - y, \ + HSV::hsv_to_rgb(r_f, g_f, b_f, h, s, 1); \ + draw_point(vector_rows, ix, y, \ (int)(CLIP(r_f, 0, 1) * 255), \ (int)(CLIP(g_f, 0, 1) * 255), \ (int)(CLIP(b_f, 0, 1) * 255)); \ } \ } -#define PROCESS_RGB_PIXEL(column, max) \ -{ \ +#define PROCESS_RGB_PIXEL(column, max) { \ r = (float)*row++ / max; \ g = (float)*row++ / max; \ b = (float)*row++ / max; \ - HSV::rgb_to_hsv(r, \ - g, \ - b, \ - h, \ - s, \ - v); \ + HSV::rgb_to_hsv(r, g, b, h, s, v); \ intensity = v; \ PROCESS_PIXEL(column) \ } -#define PROCESS_YUV_PIXEL(column, \ - y_in, \ - u_in, \ - v_in) \ -{ \ - YUV::yuv.yuv_to_rgb_f(r, g, b, (float)y_in / 255, (float)(u_in - 0x80) / 255, (float)(v_in - 0x80) / 255); \ - HSV::rgb_to_hsv(r, \ - g, \ - b, \ - h, \ - s, \ - v); \ +#define PROCESS_BGR_PIXEL(column, max) { \ + b = (float)*row++ / max; \ + g = (float)*row++ / max; \ + r = (float)*row++ / max; \ + HSV::rgb_to_hsv(r, g, b, h, s, v); \ intensity = v; \ PROCESS_PIXEL(column) \ } +#define PROCESS_YUV_PIXEL(column, y_in, u_in, v_in) { \ + YUV::yuv.yuv_to_rgb_f(r, g, b, (float)y_in / 255, (float)(u_in - 0x80) / 255, (float)(v_in - 0x80) / 255); \ + HSV::rgb_to_hsv(r, g, b, h, s, v); \ + intensity = v; \ + PROCESS_PIXEL(column) \ +} void ScopeUnit::process_package(LoadPackage *package) { @@ -211,7 +142,6 @@ void ScopeUnit::process_package(LoadPackage *package) float r, g, b; float h, s, v; - int x, y; float intensity; int use_hist = gui->use_hist; int use_hist_parade = gui->use_hist_parade; @@ -227,133 +157,115 @@ void ScopeUnit::process_package(LoadPackage *package) int w = gui->output_frame->get_w(); float radius = MIN(gui->vector_w / 2, gui->vector_h / 2); - - - - unsigned char **waveform_rows = waveform_bitmap->get_row_pointers(); unsigned char **vector_rows = vector_bitmap->get_row_pointers(); - - - switch(gui->output_frame->get_color_model()) - { - case BC_RGB888: - for(int i = pkg->row1; i < pkg->row2; i++) - { - unsigned char *row = gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_RGB_PIXEL(j, 255) - } + unsigned char **rows = gui->output_frame->get_rows(); + + switch( gui->output_frame->get_color_model() ) { + case BC_RGB888: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - unsigned char *row = gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_RGB_PIXEL(j, 255) - row++; - } + } + break; + case BC_RGBA8888: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - float *row = (float*)gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_RGB_PIXEL(j, 1.0) - } + } + break; + case BC_BGR888: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; yrow2; ++y ) { + float *row = (float*)rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - float *row = (float*)gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_RGB_PIXEL(j, 1.0) - row++; - } + } + break; + case BC_RGBA_FLOAT: + for( int y=pkg->row1; yrow2; ++y ) { + float *row = (float*)rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - unsigned char *row = gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_YUV_PIXEL(j, row[0], row[1], row[2]) - row += 3; - } + } + break; + case BC_YUV888: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - unsigned char *row = gui->output_frame->get_rows()[i]; - for(int j = 0; j < w; j++) - { - PROCESS_YUV_PIXEL(j, row[0], row[1], row[2]) - row += 4; - } + } + break; + + case BC_YUVA8888: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xrow1; i < pkg->row2; i++) - { - unsigned char *y_row = gui->output_frame->get_y() + i * gui->output_frame->get_w(); - unsigned char *u_row = gui->output_frame->get_u() + (i / 2) * (gui->output_frame->get_w() / 2); - unsigned char *v_row = gui->output_frame->get_v() + (i / 2) * (gui->output_frame->get_w() / 2); - for(int j = 0; j < w; j += 2) - { - PROCESS_YUV_PIXEL(j, *y_row, *u_row, *v_row); - y_row++; - PROCESS_YUV_PIXEL(j + 1, *y_row, *u_row, *v_row); - y_row++; - - u_row++; - v_row++; - } + } + break; + case BC_YUV420P: { + unsigned char *yp = gui->output_frame->get_y(); + unsigned char *up = gui->output_frame->get_u(); + unsigned char *vp = gui->output_frame->get_v(); + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *y_row = yp + y * w; + unsigned char *u_row = up + (y / 2) * (w / 2); + unsigned char *v_row = vp + (y / 2) * (w / 2); + for( int x=0; xrow1; i < pkg->row2; i++) - { - unsigned char *row = gui->output_frame->get_rows()[i]; - for(int j = 0; j < gui->output_frame->get_w(); j += 2) - { - PROCESS_YUV_PIXEL(j, row[0], row[1], row[3]); - PROCESS_YUV_PIXEL(j + 1, row[2], row[1], row[3]); - row += 4; - } + } + break; } + case BC_YUV422: + for( int y=pkg->row1; yrow2; ++y ) { + unsigned char *row = rows[y]; + for( int x=0; xoutput_frame->get_color_model()); - break; + default: + printf("ScopeUnit::process_package %d: color_model=%d unrecognized\n", + __LINE__, gui->output_frame->get_color_model()); + break; } - } - - - - ScopeEngine::ScopeEngine(ScopeGUI *gui, int cpus) : LoadServer(cpus, cpus) { @@ -367,17 +279,16 @@ ScopeEngine::~ScopeEngine() void ScopeEngine::init_packages() { - for(int i = 0; i < LoadServer::get_total_packages(); i++) - { + int y = 0, h = gui->output_frame->get_h(); + for( int i=0,n=LoadServer::get_total_packages(); irow1 = gui->output_frame->get_h() * i / LoadServer::get_total_packages(); - pkg->row2 = gui->output_frame->get_h() * (i + 1) / LoadServer::get_total_packages(); + pkg->row1 = y; + pkg->row2 = y = (++i * h) / n; } - for(int i = 0; i < get_total_clients(); i++) - { + for( int i=0,n=LoadServer::get_total_packages(); ibins[j], sizeof(int) * TOTAL_BINS); } } @@ -400,13 +311,10 @@ void ScopeEngine::process() for(int i = 0; i < HIST_SECTIONS; i++) bzero(gui->bins[i], sizeof(int) * TOTAL_BINS); - for(int i = 0; i < get_total_clients(); i++) - { + for(int i=0,n=get_total_clients(); ibins[j][k] += unit->bins[j][k]; } } @@ -414,21 +322,10 @@ void ScopeEngine::process() } - ScopeGUI::ScopeGUI(Theme *theme, - int x, - int y, - int w, - int h, - int cpus) + int x, int y, int w, int h, int cpus) : PluginClientWindow(_(PROGRAM_NAME ": Scopes"), - x, - y, - w, - h, - MIN_SCOPE_W, - MIN_SCOPE_H, - 1) + x, y, w, h, MIN_SCOPE_W, MIN_SCOPE_H, 1) { this->x = x; this->y = y; @@ -439,15 +336,8 @@ ScopeGUI::ScopeGUI(Theme *theme, reset(); } -ScopeGUI::ScopeGUI(PluginClient *plugin, - int w, - int h) - : PluginClientWindow(plugin, - w, - h, - MIN_SCOPE_W, - MIN_SCOPE_H, - 1) +ScopeGUI::ScopeGUI(PluginClient *plugin, int w, int h) + : PluginClientWindow(plugin, w, h, MIN_SCOPE_W, MIN_SCOPE_H, 1) { this->x = get_x(); this->y = get_y(); @@ -485,53 +375,27 @@ void ScopeGUI::reset() void ScopeGUI::create_objects() { - if(use_hist && use_hist_parade) - { + if( use_hist && use_hist_parade ) use_hist = 0; - } - - if(use_wave && use_wave_parade) - { + if( use_wave && use_wave_parade ) use_wave = 0; - } - - if(!engine) engine = new ScopeEngine(this, - cpus); + if( !engine ) engine = new ScopeEngine(this, cpus); lock_window("ScopeGUI::create_objects"); - - int x = theme->widget_border; int y = theme->widget_border; - - - add_subwindow(hist_on = new ScopeToggle(this, - x, - y, - &use_hist)); + add_subwindow(hist_on = new ScopeToggle(this, x, y, &use_hist)); x += hist_on->get_w() + theme->widget_border; - add_subwindow(hist_parade_on = new ScopeToggle(this, - x, - y, - &use_hist_parade)); + add_subwindow(hist_parade_on = new ScopeToggle(this, x, y, &use_hist_parade)); x += hist_parade_on->get_w() + theme->widget_border; - add_subwindow(waveform_on = new ScopeToggle(this, - x, - y, - &use_wave)); + add_subwindow(waveform_on = new ScopeToggle(this, x, y, &use_wave)); x += waveform_on->get_w() + theme->widget_border; - add_subwindow(waveform_parade_on = new ScopeToggle(this, - x, - y, - &use_wave_parade)); + add_subwindow(waveform_parade_on = new ScopeToggle(this, x, y, &use_wave_parade)); x += waveform_parade_on->get_w() + theme->widget_border; - add_subwindow(vector_on = new ScopeToggle(this, - x, - y, - &use_vector)); + add_subwindow(vector_on = new ScopeToggle(this, x, y, &use_vector)); x += vector_on->get_w() + theme->widget_border; add_subwindow(value_text = new BC_Title(x, y, "")); @@ -539,117 +403,66 @@ void ScopeGUI::create_objects() y += vector_on->get_h() + theme->widget_border; - -//PRINT_TRACE - create_panels(); -//PRINT_TRACE - - - - - - update_toggles(); show_window(); unlock_window(); } - - void ScopeGUI::create_panels() { calculate_sizes(get_w(), get_h()); - - - if((use_wave || use_wave_parade)) - { - if(!waveform) - { + if( (use_wave || use_wave_parade) ) { + if( !waveform ) { add_subwindow(waveform = new ScopeWaveform(this, - wave_x, - wave_y, - wave_w, - wave_h)); + wave_x, wave_y, wave_w, wave_h)); waveform->create_objects(); } - else - { - waveform->reposition_window(wave_x, - wave_y, - wave_w, - wave_h); + else { + waveform->reposition_window( + wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } } - else - if(!(use_wave || use_wave_parade) && waveform) - { - delete waveform; - waveform = 0; + else if( !(use_wave || use_wave_parade) && waveform ) { + delete waveform; waveform = 0; } - if(use_vector) - { - if(!vectorscope) - { + if( use_vector ) { + if( !vectorscope ) { add_subwindow(vectorscope = new ScopeVectorscope(this, - vector_x, - vector_y, - vector_w, - vector_h)); + vector_x, vector_y, vector_w, vector_h)); vectorscope->create_objects(); } - else - { - vectorscope->reposition_window(vector_x, - vector_y, - vector_w, - vector_h); + else { + vectorscope->reposition_window( + vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } } - else - if(!use_vector && vectorscope) - { - delete vectorscope; - vectorscope = 0; + else if( !use_vector && vectorscope ) { + delete vectorscope; vectorscope = 0; } - if((use_hist || use_hist_parade)) - { - if(!histogram) - { -// printf("ScopeGUI::create_panels %d %d %d %d %d\n", __LINE__, hist_x, -// hist_y, -// hist_w, -// hist_h); + if( (use_hist || use_hist_parade) ) { + if( !histogram ) { +// printf("ScopeGUI::create_panels %d %d %d %d %d\n", __LINE__, +// hist_x, hist_y, hist_w, hist_h); add_subwindow(histogram = new ScopeHistogram(this, - hist_x, - hist_y, - hist_w, - hist_h)); + hist_x, hist_y, hist_w, hist_h)); histogram->create_objects(); } - else - { - histogram->reposition_window(hist_x, - hist_y, - hist_w, - hist_h); + else { + histogram->reposition_window( + hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } } - else - if(!(use_hist || use_hist_parade)) - { - delete histogram; - histogram = 0; + else if( !(use_hist || use_hist_parade) ) { + delete histogram; histogram = 0; } - - allocate_bitmaps(); clear_points(0); draw_overlays(1, 1, 0); @@ -657,17 +470,22 @@ void ScopeGUI::create_panels() void ScopeGUI::clear_points(int flash) { - if(histogram) histogram->clear_point(); - if(waveform) waveform->clear_point(); - if(vectorscope) vectorscope->clear_point(); - if(histogram && flash) histogram->flash(0); - if(waveform && flash) waveform->flash(0); - if(vectorscope && flash) vectorscope->flash(0); + if( histogram ) + histogram->clear_point(); + if( waveform ) + waveform->clear_point(); + if( vectorscope ) + vectorscope->clear_point(); + if( histogram && flash ) + histogram->flash(0); + if( waveform && flash ) + waveform->flash(0); + if( vectorscope && flash ) + vectorscope->flash(0); } void ScopeGUI::toggle_event() { - } void ScopeGUI::calculate_sizes(int w, int h) @@ -683,38 +501,33 @@ void ScopeGUI::calculate_sizes(int w, int h) // Vectorscope determines the size of everything else // Always last panel vector_w = 0; - if(use_vector) - { + if( use_vector ) { vector_x = w - panel_w + text_w; vector_w = w - margin - vector_x; vector_y = vector_on->get_h() + margin * 2; vector_h = h - vector_y - margin; - if(vector_w > vector_h) - { + if( vector_w > vector_h ) { vector_w = vector_h; vector_x = w - theme->widget_border - vector_w; } - - total_panels--; + --total_panels; if(total_panels > 0) panel_w = (vector_x - text_w - margin) / total_panels; } // Histogram is always 1st panel - if(use_hist || use_hist_parade) - { + if( use_hist || use_hist_parade ) { hist_x = x; hist_y = vector_on->get_h() + margin * 2; hist_w = panel_w - margin; hist_h = h - hist_y - margin; - total_panels--; + --total_panels; x += panel_w; } - if(use_wave || use_wave_parade) - { + if( use_wave || use_wave_parade ) { wave_x = x + text_w; wave_y = vector_on->get_h() + margin * 2; wave_w = panel_w - margin - text_w; @@ -729,14 +542,9 @@ void ScopeGUI::allocate_bitmaps() if(waveform_bitmap) delete waveform_bitmap; if(vector_bitmap) delete vector_bitmap; - int w; - int h; -// printf("ScopeGUI::allocate_bitmaps %d %d %d %d %d\n", -// __LINE__, -// wave_w, -// wave_h, -// vector_w, -// vector_h); + int w, h; +//printf("ScopeGUI::allocate_bitmaps %d %d %d %d %d\n", __LINE__, +// wave_w, wave_h, vector_w, vector_h); int xs16 = xS(16), ys16 = yS(16); w = MAX(wave_w, xs16); h = MAX(wave_h, ys16); @@ -754,30 +562,24 @@ int ScopeGUI::resize_event(int w, int h) this->h = h; calculate_sizes(w, h); - if(waveform) - { + if( waveform ) { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } - if(histogram) - { + if( histogram ) { histogram->reposition_window(hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } - if(vectorscope) - { + if( vectorscope ) { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } allocate_bitmaps(); - - clear_points(0); draw_overlays(1, 1, 1); - return 1; } @@ -785,7 +587,6 @@ int ScopeGUI::translation_event() { x = get_x(); y = get_y(); - PluginClientWindow::translation_event(); return 0; } @@ -795,32 +596,24 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) { BC_Resources *resources = BC_WindowBase::get_resources(); int text_color = GREEN; - if(resources->bg_color == 0xffffff) - { + if( resources->bg_color == 0xffffff ) { text_color = BLACK; } - if(overlays && borders) - { + if( overlays && borders ) { clear_box(0, 0, get_w(), get_h()); } - if(overlays) - { + if( overlays ) { set_line_dashes(1); set_color(text_color); set_font(SMALLFONT); - if(histogram && (use_hist || use_hist_parade)) - { - histogram->draw_line(hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), - 0, - hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), - hist_h); - histogram->draw_line(hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), - 0, - hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), - hist_h); + if( histogram && (use_hist || use_hist_parade) ) { + histogram->draw_line(hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), 0, + hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), hist_h); + histogram->draw_line(hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), 0, + hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), hist_h); set_line_dashes(0); histogram->draw_point(); set_line_dashes(1); @@ -828,17 +621,14 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) } // Waveform overlay - if(waveform && (use_wave || use_wave_parade)) - { + if( waveform && (use_wave || use_wave_parade) ) { set_color(text_color); - for(int i = 0; i <= WAVEFORM_DIVISIONS; i++) - { + for( int i=0; i<=WAVEFORM_DIVISIONS; ++i ) { int y = wave_h * i / WAVEFORM_DIVISIONS; int text_y = y + wave_y + get_text_ascent(SMALLFONT) / 2; CLAMP(text_y, waveform->get_y() + get_text_ascent(SMALLFONT), waveform->get_y() + waveform->get_h() - 1); char string[BCTEXTLEN]; - sprintf(string, "%d", - (int)((FLOAT_MAX - + sprintf(string, "%d", (int)((FLOAT_MAX - i * (FLOAT_MAX - FLOAT_MIN) / WAVEFORM_DIVISIONS) * 100)); int text_x = wave_x - get_text_width(SMALLFONT, string) - theme->widget_border; draw_text(text_x, text_y, string); @@ -855,12 +645,10 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) // Vectorscope overlay - if(vectorscope && use_vector) - { + if( vectorscope && use_vector ) { set_color(text_color); int radius = MIN(vector_w / 2, vector_h / 2); - for(int i = 1; i <= VECTORSCOPE_DIVISIONS; i += 2) - { + for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) { int x = vector_w / 2 - radius * i / VECTORSCOPE_DIVISIONS; int y = vector_h / 2 - radius * i / VECTORSCOPE_DIVISIONS; int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2; @@ -892,42 +680,18 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) set_line_dashes(0); } - if(borders) - { - if(use_hist || use_hist_parade) - { - draw_3d_border(hist_x - 2, - hist_y - 2, - hist_w + 4, - hist_h + 4, - get_bg_color(), - BLACK, - MDGREY, - get_bg_color()); + if( borders ) { + if( use_hist || use_hist_parade ) { + draw_3d_border(hist_x - 2, hist_y - 2, hist_w + 4, hist_h + 4, + get_bg_color(), BLACK, MDGREY, get_bg_color()); } - - if(use_wave || use_wave_parade) - { - draw_3d_border(wave_x - 2, - wave_y - 2, - wave_w + 4, - wave_h + 4, - get_bg_color(), - BLACK, - MDGREY, - get_bg_color()); + if( use_wave || use_wave_parade ) { + draw_3d_border(wave_x - 2, wave_y - 2, wave_w + 4, wave_h + 4, + get_bg_color(), BLACK, MDGREY, get_bg_color()); } - - if(use_vector) - { - draw_3d_border(vector_x - 2, - vector_y - 2, - vector_w + 4, - vector_h + 4, - get_bg_color(), - BLACK, - MDGREY, - get_bg_color()); + if( use_vector ) { + draw_3d_border(vector_x - 2, vector_y - 2, vector_w + 4, vector_h + 4, + get_bg_color(), BLACK, MDGREY, get_bg_color()); } } @@ -943,33 +707,16 @@ void ScopeGUI::process(VFrame *output_frame) this->output_frame = output_frame; frame_w = output_frame->get_w(); //float radius = MIN(vector_w / 2, vector_h / 2); - bzero(waveform_bitmap->get_data(), waveform_bitmap->get_data_size()); bzero(vector_bitmap->get_data(), vector_bitmap->get_data_size()); - - engine->process(); - if(histogram) - { + if( histogram ) histogram->draw(0, 0); - } - - if(waveform) - { - waveform->draw_bitmap(waveform_bitmap, - 1, - 0, - 0); - } - - if(vectorscope) - { - vectorscope->draw_bitmap(vector_bitmap, - 1, - 0, - 0); - } + if( waveform ) + waveform->draw_bitmap(waveform_bitmap, 1, 0, 0); + if( vectorscope ) + vectorscope->draw_bitmap(vector_bitmap, 1, 0, 0); draw_overlays(1, 0, 1); unlock_window(); @@ -986,19 +733,7 @@ void ScopeGUI::update_toggles() } - - - - - - - - -ScopePanel::ScopePanel(ScopeGUI *gui, - int x, - int y, - int w, - int h) +ScopePanel::ScopePanel(ScopeGUI *gui, int x, int y, int w, int h) : BC_SubWindow(x, y, w, h, BLACK) { this->gui = gui; @@ -1025,10 +760,8 @@ void ScopePanel::clear_point() int ScopePanel::button_press_event() { - if(is_event_win() && cursor_inside()) - { + if( is_event_win() && cursor_inside() ) { gui->clear_points(1); - is_dragging = 1; int x = get_cursor_x(); int y = get_cursor_y(); @@ -1043,8 +776,7 @@ int ScopePanel::button_press_event() int ScopePanel::cursor_motion_event() { - if(is_dragging) - { + if( is_dragging ) { int x = get_cursor_x(); int y = get_cursor_y(); CLAMP(x, 0, get_w() - 1); @@ -1058,8 +790,7 @@ int ScopePanel::cursor_motion_event() int ScopePanel::button_release_event() { - if(is_dragging) - { + if( is_dragging ) { is_dragging = 0; return 1; } @@ -1067,18 +798,8 @@ int ScopePanel::button_release_event() } - - - - - - - ScopeWaveform::ScopeWaveform(ScopeGUI *gui, - int x, - int y, - int w, - int h) + int x, int y, int w, int h) : ScopePanel(gui, x, y, w, h) { drag_x = -1; @@ -1092,12 +813,10 @@ void ScopeWaveform::update_point(int x, int y) drag_y = y; int frame_x = x * gui->frame_w / get_w(); - if(gui->use_wave_parade) - { - if(x > get_w() / 3 * 2) + if( gui->use_wave_parade ) { + if( x > get_w() / 3 * 2 ) frame_x = (x - get_w() / 3 * 2) * gui->frame_w / (get_w() / 3); - else - if(x > get_w() / 3) + else if( x > get_w() / 3 ) frame_x = (x - get_w() / 3) * gui->frame_w / (get_w() / 3); else frame_x = x * gui->frame_w / (get_w() / 3); @@ -1115,8 +834,7 @@ void ScopeWaveform::update_point(int x, int y) void ScopeWaveform::draw_point() { - if(drag_x >= 0) - { + if( drag_x >= 0 ) { set_inverse(); set_color(0xffffff); set_line_width(2); @@ -1134,17 +852,8 @@ void ScopeWaveform::clear_point() drag_y = -1; } - - - - - - ScopeVectorscope::ScopeVectorscope(ScopeGUI *gui, - int x, - int y, - int w, - int h) + int x, int y, int w, int h) : ScopePanel(gui, x, y, w, h) { drag_radius = 0; @@ -1172,7 +881,7 @@ void ScopeVectorscope::update_point(int x, int y) float saturation = (float)drag_radius / radius * FLOAT_MAX; float hue = -drag_angle * 360 / 2 / M_PI - 90; - if(hue < 0) hue += 360; + if( hue < 0 ) hue += 360; char string[BCTEXTLEN]; sprintf(string, "Hue: %.3f Sat: %.3f", hue, saturation); @@ -1185,19 +894,14 @@ void ScopeVectorscope::update_point(int x, int y) void ScopeVectorscope::draw_point() { - if(drag_radius > 0) - { + if( drag_radius > 0 ) { int radius = MIN(get_w() / 2, get_h() / 2); set_inverse(); set_color(0xff0000); set_line_width(2); - draw_circle(get_w() / 2 - drag_radius, - get_h() / 2 - drag_radius, - drag_radius * 2, - drag_radius * 2); - - draw_line(get_w() / 2, - get_h() / 2, + draw_circle(get_w() / 2 - drag_radius, get_h() / 2 - drag_radius, + drag_radius * 2, drag_radius * 2); + draw_line(get_w() / 2, get_h() / 2, get_w() / 2 + radius * cos(drag_angle), get_h() / 2 + radius * sin(drag_angle)); set_line_width(1); @@ -1208,10 +912,7 @@ void ScopeVectorscope::draw_point() ScopeHistogram::ScopeHistogram(ScopeGUI *gui, - int x, - int y, - int w, - int h) + int x, int y, int w, int h) : ScopePanel(gui, x, y, w, h) { drag_x = -1; @@ -1226,8 +927,7 @@ void ScopeHistogram::clear_point() void ScopeHistogram::draw_point() { - if(drag_x >= 0) - { + if( drag_x >= 0 ) { set_inverse(); set_color(0xffffff); set_line_width(2); @@ -1257,30 +957,21 @@ void ScopeHistogram::draw_mode(int mode, int color, int y, int h) { // Highest of all bins int normalize = 0; - for(int i = 0; i < TOTAL_BINS; i++) - { + for( int i=0; ibins[mode][i] > normalize) normalize = gui->bins[mode][i]; } - - - set_color(color); - for(int i = 0; i < get_w(); i++) - { + for( int i=0; ibins[mode][k], max); } - -// max = max * h / normalize; +// max = max * h / normalize; max = (int)(log(max) / log(normalize) * h); - draw_line(i, y + h - max, i, y + h); } } @@ -1289,14 +980,12 @@ void ScopeHistogram::draw(int flash, int flush) { clear_box(0, 0, get_w(), get_h()); - if(gui->use_hist_parade) - { + if( gui->use_hist_parade ) { draw_mode(0, 0xff0000, 0, get_h() / 3); draw_mode(1, 0x00ff00, get_h() / 3, get_h() / 3); draw_mode(2, 0x0000ff, get_h() / 3 * 2, get_h() / 3); } - else - { + else { draw_mode(3, LTGREY, 0, get_h()); } @@ -1304,70 +993,44 @@ void ScopeHistogram::draw(int flash, int flush) if(flush) this->flush(); } - - - - - -ScopeToggle::ScopeToggle(ScopeGUI *gui, - int x, - int y, - int *value) - : BC_Toggle(x, - y, - get_image_set(gui, value), - *value) +ScopeToggle::ScopeToggle(ScopeGUI *gui, int x, int y, int *value) + : BC_Toggle(x, y, get_image_set(gui, value), *value) { this->gui = gui; this->value = value; - if(value == &gui->use_hist_parade) - { + if( value == &gui->use_hist_parade ) { set_tooltip(_("Histogram Parade")); } - else - if(value == &gui->use_hist) + else if( value == &gui->use_hist ) { set_tooltip(_("Histogram")); } - else - if(value == &gui->use_wave_parade) - { + else if( value == &gui->use_wave_parade ) { set_tooltip(_("Waveform Parade")); } - else - if(value == &gui->use_wave) - { + else if( value == &gui->use_wave ) { set_tooltip(_("Waveform")); } - else - { + else { set_tooltip(_("Vectorscope")); } } VFrame** ScopeToggle::get_image_set(ScopeGUI *gui, int *value) { - if(value == &gui->use_hist_parade) - { + if( value == &gui->use_hist_parade ) { return gui->theme->get_image_set("histogram_rgb_toggle"); } - else - if(value == &gui->use_hist) - { + else if( value == &gui->use_hist ) { return gui->theme->get_image_set("histogram_toggle"); } - else - if(value == &gui->use_wave_parade) - { + else if( value == &gui->use_wave_parade ) { return gui->theme->get_image_set("waveform_rgb_toggle"); } - else - if(value == &gui->use_wave) - { + else if( value == &gui->use_wave ) { return gui->theme->get_image_set("waveform_toggle"); } - else - { + else { return gui->theme->get_image_set("scope_toggle"); } } @@ -1375,27 +1038,19 @@ VFrame** ScopeToggle::get_image_set(ScopeGUI *gui, int *value) int ScopeToggle::handle_event() { *value = get_value(); - if(value == &gui->use_hist_parade) - { - if(get_value()) gui->use_hist = 0; + if( value == &gui->use_hist_parade ) { + if( get_value() ) gui->use_hist = 0; } - else - if(value == &gui->use_hist) + else if( value == &gui->use_hist ) { - if(get_value()) gui->use_hist_parade = 0; + if( get_value() ) gui->use_hist_parade = 0; } - else - if(value == &gui->use_wave_parade) - { - if(get_value()) gui->use_wave = 0; + else if( value == &gui->use_wave_parade ) { + if( get_value() ) gui->use_wave = 0; } - else - if(value == &gui->use_wave) - { - if(get_value()) gui->use_wave_parade = 0; + else if( value == &gui->use_wave ) { + if( get_value() ) gui->use_wave_parade = 0; } - - gui->toggle_event(); gui->update_toggles(); gui->create_panels(); @@ -1403,5 +1058,3 @@ int ScopeToggle::handle_event() return 1; } - - diff --git a/cinelerra-5.1/cinelerra/theme.C b/cinelerra-5.1/cinelerra/theme.C index efb513f0..20e66688 100644 --- a/cinelerra-5.1/cinelerra/theme.C +++ b/cinelerra-5.1/cinelerra/theme.C @@ -708,7 +708,7 @@ void Theme::draw_mwindow_bg(MWindowGUI *gui) void Theme::get_cwindow_sizes(CWindowGUI *gui, int cwindow_controls) { - int total_buttons = !use_commercials ? 15 : 16; + int total_buttons = !use_commercials ? 17 : 18; int edit_w = EditPanel::calculate_w(mwindow, 1, total_buttons); int transport_w = PlayTransport::get_transport_width(mwindow) + toggle_margin; int zoom_w = ZoomPanel::calculate_w(czoom_w); @@ -733,57 +733,32 @@ SET_TRACE cmeter_x = mwindow->session->cwindow_w + widget_border; } - int buttons_h; - - if(edit_w + - widget_border * 2 + - transport_w + widget_border + - zoom_w + widget_border + - division_w + - status_w > cmeter_x) - { - buttons_h = get_image("cbuttons_left")->get_h(); - - cedit_x = widget_border; - cedit_y = mwindow->session->cwindow_h - - buttons_h + - ctimebar_h + - widget_border; - + int edit_panel_h = EditPanel::calculate_h(mwindow); + int buttons_h = 0; + if( edit_w + widget_border * 2 + transport_w + widget_border + + zoom_w + widget_border + division_w + status_w > cmeter_x ) { + buttons_h = (widget_border + edit_panel_h) * 2; ctransport_x = widget_border; - ctransport_y = mwindow->session->cwindow_h - - get_image_set("autokeyframe")[0]->get_h() - - widget_border; - + ctransport_y = mwindow->session->cwindow_h - buttons_h; czoom_x = ctransport_x + transport_w + widget_border; - czoom_y = ctransport_y + widget_border; - - cstatus_x = xS(426); - cstatus_y = mwindow->session->cwindow_h - - get_image("cwindow_active")->get_h() - yS(30); + czoom_y = ctransport_y; + cedit_x = widget_border; + cedit_y = ctransport_y + edit_panel_h + widget_border; } - else - { - buttons_h = ctimebar_h + - widget_border + - EditPanel::calculate_h(mwindow) + - widget_border; + else { + buttons_h = widget_border + edit_panel_h; ctransport_x = widget_border; - ctransport_y = mwindow->session->cwindow_h - - buttons_h + - ctimebar_h + - widget_border; - + ctransport_y = mwindow->session->cwindow_h - buttons_h; cedit_x = ctransport_x + transport_w + widget_border; cedit_y = ctransport_y; - czoom_x = cedit_x + edit_w + widget_border; - czoom_y = cedit_y + widget_border; -//printf("Theme::get_cwindow_sizes %d %d %d\n", __LINE__, czoom_x, zoom_w); - cstatus_x = czoom_x + zoom_w + division_w; - cstatus_y = ctransport_y; + czoom_y = ctransport_y; } + buttons_h += ctimebar_h + widget_border; + cstatus_x = mwindow->session->cwindow_w - xS(50); + cstatus_y = mwindow->session->cwindow_h - + get_image("cwindow_active")->get_h() - yS(5); ccomposite_x = xS(0); ccomposite_y = yS(5); @@ -927,7 +902,7 @@ void Theme::draw_resource_bg(TrackCanvas *canvas, ResourcePixmap *pixmap, int co void Theme::get_vwindow_sizes(VWindowGUI *gui) { - int edit_w = EditPanel::calculate_w(mwindow, 0, 10); + int edit_w = EditPanel::calculate_w(mwindow, 0, 12); int transport_w = PlayTransport::get_transport_width(mwindow) + toggle_margin; // Space between buttons & time int division_w = xS(30); diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 88e07d81..a4faec2b 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -3882,13 +3882,17 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode) delete video_cache; mwindow->cwindow->gui->lock_window("TrackCanvas::render_handle_frame 0"); Canvas *canvas = mwindow->cwindow->gui->canvas; - int w = canvas->w, h = canvas->h, w2 = w/2, h2 = h/2; - int lx = 0, ly = h2/2, rx = w2, ry = h2/2; + float ox1, oy1, ox2, oy2, cx1, cy1, cx2, cy2; + canvas->get_transfers(edl, ox1, oy1, ox2, oy2, cx1, cy1, cx2, cy2); + float cw = canvas->w/2, ch = canvas->h/2; + float cdx = (cx2 - cx1)/2, cdy = (cy2 - cy1)/2; + int cx = cx1/2, cy = cy1/2 + ch/2; + int ow = ox2 - ox2, oh = oy2 - oy1; BC_WindowBase *window = canvas->get_canvas(); window->set_color(BLACK); window->clear_box(0,0, window->get_w(),window->get_h()); - window->draw_vframe(&vlt, lx,ly, w2,h2, 0,0,vlt.get_w(),vlt.get_h()); - window->draw_vframe(&vrt, rx,ry, w2,h2, 0,0,vrt.get_w(),vrt.get_h()); + window->draw_vframe(&vlt, cx,cy, cdx,cdy, ox1,oy1, ow,oh); cx += cw; + window->draw_vframe(&vrt, cx,cy, cdx,cdy, ox1,oy1, ow,oh); window->flash(1); mwindow->cwindow->gui->unlock_window(); break; } diff --git a/cinelerra-5.1/cinelerra/vrender.C b/cinelerra-5.1/cinelerra/vrender.C index 3aa1b24d..43893b27 100644 --- a/cinelerra-5.1/cinelerra/vrender.C +++ b/cinelerra-5.1/cinelerra/vrender.C @@ -22,6 +22,7 @@ #include "asset.h" #include "bcsignals.h" #include "cache.h" +#include "canvas.h" #include "clip.h" #include "condition.h" #include "datatype.h" @@ -98,10 +99,9 @@ Module* VRender::new_module(Track *track) int VRender::flash_output() { - if(video_out) - return renderengine->video->write_buffer(video_out, renderengine->get_edl()); - else - return 0; + if( !video_out ) return 0; + renderengine->update_scope(video_out); + return renderengine->video->write_buffer(video_out, renderengine->get_edl()); } int VRender::process_buffer(VFrame *video_out, diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index eb42c679..7fcd19ad 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -557,7 +557,8 @@ VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow) 0, // use_cut 0, // use_commerical 0, // use_goto - 1) // use_clk2play + 1, // use_clk2play + 1) // use_scope { this->mwindow = mwindow; this->vwindow = vwindow; @@ -826,6 +827,17 @@ void VWindowCanvas::close_source() gui->vwindow->delete_source(1, 1); } +int VWindowCanvas::scope_on() +{ + return !gui->edit_panel->scope_dialog ? 0 : + gui->edit_panel->scope_dialog->running(); +} + +void VWindowCanvas::draw_scope(VFrame *output) +{ + if( gui->edit_panel->scope_dialog ) + gui->edit_panel->scope_dialog->process(output); +} void VWindowCanvas::draw_refresh(int flush) { diff --git a/cinelerra-5.1/cinelerra/vwindowgui.h b/cinelerra-5.1/cinelerra/vwindowgui.h index 6836293f..a62a3015 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.h +++ b/cinelerra-5.1/cinelerra/vwindowgui.h @@ -114,6 +114,8 @@ public: VWindowCanvas(MWindow *mwindow, VWindowGUI *gui); void create_objects(EDL *edl); void zoom_resize_window(float percentage); + int scope_on(); + void draw_scope(VFrame *output); void draw_refresh(int flush = 1); int need_overlays(); void draw_overlays();