#include "bcsignals.h"
#include "bccolors.h"
+#include "boxblur.h"
#include "clip.h"
#include "cursors.h"
+#include "file.h"
+#include "filesystem.h"
#include "language.h"
#include "scopewindow.h"
#include "theme.h"
v = *vp+(gv); *vp++ = v>0xff ? 0xff : v; \
v = *vp+(bv); *vp = v>0xff ? 0xff : v; } \
}
+#define decr_points(rows,h, rv,gv,bv) { \
+if(iy >= 0 && iy < h) { \
+ uint8_t *vp = rows[iy] + ix*3; \
+ int v = *vp-(rv); *vp++ = v<0 ? 0 : v; \
+ v = *vp-(gv); *vp++ = v<0 ? 0 : v; \
+ v = *vp-(bv); *vp = v<0 ? 0 : v; } \
+}
#define clip_points(rows,h, rv,gv,bv) { \
if(iy >= 0 && iy < h) { \
uint8_t *vp = rows[iy] + ix*3; \
} \
} \
/* Calculate vectorscope */ \
- if(use_vector) { \
- float th = 90 - h; \
- if( th < 0 ) th += 360; \
- double t = TO_RAD(th); \
- float adjacent = -cos(t), opposite = sin(t); \
- int ix = vector_w / 2 + adjacent * (s) / (FLOAT_MAX) * radius; \
- int iy = vector_h / 2 - opposite * (s) / (FLOAT_MAX) * radius; \
+ if(use_vector > 0) { \
+ double t = TO_RAD(-h); \
+ float adjacent = sin(t), opposite = cos(t); \
+ int ix = vector_cx + adjacent * (s) / (FLOAT_MAX) * radius; \
+ int iy = vector_cy - opposite * (s) / (FLOAT_MAX) * radius; \
CLAMP(ix, 0, vector_w - 1); \
- /* Get color with full saturation & value */ \
- float r_f, g_f, b_f; \
- if( (h=h-90) < 0 ) h += 360; \
- HSV::hsv_to_rgb(r_f, g_f, b_f, h, s, 1); \
- int rv = CLIP(r_f, 0, 1) * vinc + 3; \
- int gv = CLIP(g_f, 0, 1) * vinc + 3; \
- int bv = CLIP(b_f, 0, 1) * vinc + 3; \
+ HSV::hsv_to_rgb(r, g, b, h, s, vincf); \
+ int rv = r + 3; \
+ int gv = g + 3; \
+ int bv = b + 3; \
incr_points(vector_rows,vector_h, rv,gv,bv); \
} \
+ else if(use_vector < 0) { \
+ double t = TO_RAD(-h); \
+ float adjacent = sin(t), opposite = cos(t); \
+ int ix = vector_cx + adjacent * (s) / (FLOAT_MAX) * radius; \
+ int iy = vector_cy - opposite * (s) / (FLOAT_MAX) * radius; \
+ CLAMP(ix, 0, vector_w - 1); \
+ decr_points(vector_rows,vector_h, vinc,vinc,vinc); \
+ } \
}
#define PROCESS_RGB_PIXEL(type,max, column) { \
int use_vector = gui->use_vector;
int use_wave = gui->use_wave;
int use_wave_parade = gui->use_wave_parade;
+ int vector_cx = gui->vector_cx;
+ int vector_cy = gui->vector_cy;
+ int radius = gui->radius;
VFrame *waveform_vframe = gui->waveform_vframe;
VFrame *vector_vframe = gui->vector_vframe;
int wave_h = waveform_vframe->get_h();
int dat_h = gui->data_frame->get_h();
int winc = (wave_w * wave_h) / (dat_w * dat_h);
if( use_wave_parade ) winc *= 3;
- winc += 2; winc *= gui->use_wave_gain;
- int vinc = 3*(vector_w * vector_h) / (dat_w * dat_h) + 2;
- vinc *= gui->use_vect_gain;
- float radius = MIN(gui->vector_w / 2, gui->vector_h / 2);
+ winc += 2; winc = (winc << gui->use_wave_gain) / 4;
+ int vinc = 3*(vector_w * vector_h) / (dat_w * dat_h);
+ vinc += 2; vinc = (vinc << gui->use_vect_gain) / 4;
+ float vincf = vinc;
uint8_t **waveform_rows = waveform_vframe->get_rows();
uint8_t **vector_rows = vector_vframe->get_rows();
uint8_t **rows = gui->data_frame->get_rows();
break;
case BC_RGB_FLOAT:
for( int y=pkg->row1; y<pkg->row2; ++y ) {
- float *row = (float*)rows[y];
+ uint8_t *row = rows[y];
for( int x=0; x<dat_w; ++x ) {
PROCESS_RGB_PIXEL(float,1.f, x)
row += 3*sizeof(float);
break;
case BC_RGBA_FLOAT:
for( int y=pkg->row1; y<pkg->row2; ++y ) {
- float *row = (float*)rows[y];
+ uint8_t *row = rows[y];
for( int x=0; x<dat_w; ++x ) {
PROCESS_RGB_PIXEL(float,1.f, x)
row += 4*sizeof(float);
this->y = y;
this->w = w;
this->h = h;
- this->temp_frame = 0;
this->theme = theme;
this->cpus = cpus;
reset();
this->y = get_y();
this->w = w;
this->h = h;
- this->temp_frame = 0;
this->theme = plugin->get_theme();
this->cpus = plugin->PluginClient::smp + 1;
reset();
{
delete waveform_vframe;
delete vector_vframe;
+ delete wheel_vframe;
delete engine;
delete box_blur;
delete temp_frame;
+ delete wave_slider;
+ delete vect_slider;
+ delete grad_image;
+ delete grad_pixmap;
}
void ScopeGUI::reset()
{
+ waveform_vframe = 0;
+ vector_vframe = 0;
+ wheel_vframe = 0;
+ engine = 0;
+ box_blur = 0;
+ temp_frame = 0;
+ wave_slider = 0;
+ vect_slider = 0;
+ grad_image = 0;
+ grad_pixmap = 0;
+ grad_idx = 0;
+ vect_grads = 0;
+
output_frame = 0;
data_frame = 0;
frame_w = 1;
use_smooth = 1;
use_wave_gain = 5;
use_vect_gain = 5;
- waveform_vframe = 0;
- vector_vframe = 0;
- engine = 0;
- box_blur = 0;
use_hist = 0;
use_wave = 1;
use_vector = 1;
use_hist_parade = 0;
use_wave_parade = 0;
+ use_graticule = 0;
waveform = 0;
vectorscope = 0;
histogram = 0;
wave_w = wave_h = 0;
vector_w = vector_h = 0;
+ vector_cx = vector_cy = 0;
+ radius = 0;
+ text_color = GREEN;
+ dark_color = (text_color>>2) & 0x3f3f3f;
+ BC_Resources *resources = BC_WindowBase::get_resources();
+ if( resources->bg_color == 0xffffff )
+ text_color = dark_color;
}
-
void ScopeGUI::create_objects()
{
if( use_hist && use_hist_parade )
if( use_wave && use_wave_parade )
use_wave = 0;
if( !engine ) engine = new ScopeEngine(this, cpus);
+ grad_idx = use_graticule; // last graticule
+ use_graticule = 0;
lock_window("ScopeGUI::create_objects");
- int x = theme->widget_border;
- int y = theme->widget_border;
+ int margin = theme->widget_border;
+ int x = margin;
+ int y = margin;
add_subwindow(smooth = new ScopeSmooth(this, x, y));
- y += smooth->get_h() + theme->widget_border;
+ y += smooth->get_h() + margin;
add_subwindow(scope_menu = new ScopeMenu(this, x, y));
scope_menu->create_objects();
- x += scope_menu->get_w() + theme->widget_border;
+ x += scope_menu->get_w() + margin;
add_subwindow(value_text = new BC_Title(x, y, ""));
- y += scope_menu->get_h() + theme->widget_border;
+ y += scope_menu->get_h() + margin;
create_panels();
update_toggles();
{
calculate_sizes(get_w(), get_h());
int slider_w = xS(100);
+ int margin = theme->widget_border;
if( (use_wave || use_wave_parade) ) {
int px = wave_x + wave_w - slider_w - xS(5);
- int py = wave_y - ScopeWaveSlider::get_span(0) - yS(5);
+ int py = wave_y - ScopeGain::calculate_h() - yS(5);
if( !waveform ) {
add_subwindow(waveform = new ScopeWaveform(this,
wave_x, wave_y, wave_w, wave_h));
waveform->create_objects();
- add_subwindow(wave_slider = new ScopeWaveSlider(this, px, py, slider_w));
+ wave_slider = new ScopeWaveSlider(this, px, py, slider_w);
+ wave_slider->create_objects();
}
else {
waveform->reposition_window(
if( use_vector ) {
int vx = vector_x + vector_w - slider_w - xS(5);
- int vy = vector_y - ScopeVectSlider::get_span(0) - yS(5);
+ int vy = vector_y - ScopeGain::calculate_h() - yS(5);
if( !vectorscope ) {
add_subwindow(vectorscope = new ScopeVectorscope(this,
vector_x, vector_y, vector_w, vector_h));
vectorscope->create_objects();
- add_subwindow(vect_slider = new ScopeVectSlider(this, vx, vy, slider_w));
+ vect_slider = new ScopeVectSlider(this, vx, vy, slider_w);
+ vect_slider->create_objects();
+ if( use_vector < 0 ) {
+ vect_grads = new ScopeVectGrads(this, vector_x, 2*margin);
+ add_subwindow(vect_grads);
+ vect_grads->create_objects();
+ }
}
else {
vectorscope->reposition_window(
vector_x, vector_y, vector_w, vector_h);
vectorscope->clear_box(0, 0, vector_w, vector_h);
vect_slider->reposition_window(vx, vy);
+ if( use_vector > 0 ) {
+ delete vect_grads; vect_grads = 0;
+ }
+ else if( !vect_grads ) {
+ vect_grads = new ScopeVectGrads(this, vector_x, 2*margin);
+ add_subwindow(vect_grads);
+ vect_grads->create_objects();
+ }
+ else
+ vect_grads->reposition_window(vector_x, 2*margin);
}
}
else if( !use_vector && vectorscope ) {
delete vectorscope; vectorscope = 0;
delete vect_slider; vect_slider = 0;
+ delete vect_grads; vect_grads = 0;
}
if( (use_hist || use_hist_parade) ) {
if( vector_w > vector_h ) {
vector_w = vector_h;
- vector_x = w - theme->widget_border - vector_w;
+ vector_x = w - margin - vector_w;
}
--total_panels;
if(total_panels > 0)
panel_w = (vector_x - text_w - margin) / total_panels;
}
+ vector_cx = vector_w / 2;
+ vector_cy = vector_h / 2;
+ radius = bmin(vector_cx, vector_cy);
// Histogram is always 1st panel
if( use_hist || use_hist_parade ) {
{
if(waveform_vframe) delete waveform_vframe;
if(vector_vframe) delete vector_vframe;
+ if(wheel_vframe) delete wheel_vframe;
int w, h;
//printf("ScopeGUI::allocate_vframes %d %d %d %d %d\n", __LINE__,
w = MAX(vector_w, xs16);
h = MAX(vector_h, ys16);
vector_vframe = new VFrame(w, h, BC_RGB888);
+ wheel_vframe = 0;
}
int vx = vector_x + vector_w - vect_slider->get_w() - margin;
int vy = vector_y - vect_slider->get_h() - margin;
vect_slider->reposition_window(vx, vy);
+ if( vect_grads )
+ vect_grads->reposition_window(vector_x, 2*margin);
}
allocate_vframes();
void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
{
- BC_Resources *resources = BC_WindowBase::get_resources();
- int text_color = GREEN;
- int dark_color = (text_color>>2) & 0x3f3f3f;
- if( resources->bg_color == 0xffffff ) {
- text_color = dark_color;
- }
-
+ int margin = theme->widget_border;
if( overlays && borders ) {
clear_box(0, 0, get_w(), get_h());
}
char string[BCTEXTLEN];
sprintf(string, "%d", (int)lround((FLOAT_MAX -
i * (FLOAT_MAX - FLOAT_MIN) / WAVEFORM_DIVISIONS) * 100));
- int text_x = wave_x - get_text_width(SMALLFONT, string) - theme->widget_border;
+ int text_x = wave_x - get_text_width(SMALLFONT, string) - margin;
set_color(text_color);
draw_text(text_x, text_y, string);
CLAMP(y, 0, waveform->get_h() - 1);
}
// Vectorscope overlay
if( vectorscope && use_vector ) {
- set_line_dashes(1);
- int radius = MIN(vector_w / 2, vector_h / 2);
- for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) {
- int y = vector_h / 2 - radius * i / VECTORSCOPE_DIVISIONS;
- int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
- set_color(text_color);
- char string[BCTEXTLEN];
- sprintf(string, "%d",
- (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
- int text_x = vector_x - get_text_width(SMALLFONT, string) - theme->widget_border;
- draw_text(text_x, text_y, string);
- int x = vector_w / 2 - radius * i / VECTORSCOPE_DIVISIONS;
- int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
- int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
- if( i+2 > VECTORSCOPE_DIVISIONS )
- set_line_dashes(0);
- set_color(dark_color);
- vectorscope->draw_circle(x, y, w, h);
- }
+ draw_graticule();
set_color(text_color);
vectorscope->draw_point();
- set_line_dashes(1);
vectorscope->flash(0);
+ set_line_dashes(1);
}
set_font(MEDIUMFONT);
if(flush) this->flush();
}
+void ScopeGUI::draw_graticule()
+{
+ if( use_vector > 0 ) {
+ int margin = theme->widget_border;
+ set_line_dashes(1);
+ for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) {
+ int y = vector_cy - radius * i / VECTORSCOPE_DIVISIONS;
+ int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
+ set_color(text_color);
+ char string[BCTEXTLEN];
+ sprintf(string, "%d",
+ (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
+ int text_x = vector_x - get_text_width(SMALLFONT, string) - margin;
+ draw_text(text_x, text_y, string);
+ int x = vector_cx - radius * i / VECTORSCOPE_DIVISIONS;
+ int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
+ int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
+ if( i+2 > VECTORSCOPE_DIVISIONS )
+ set_line_dashes(0);
+ set_color(dark_color);
+ vectorscope->draw_circle(x, y, w, h);
+ }
+ float th = TO_RAD(90 + 32.875);
+ vectorscope->draw_radient(th, 0.1f, .75f, dark_color);
+ }
+ else if( use_vector < 0 ) {
+ if( grad_image && grad_idx != use_graticule ) {
+ delete grad_image; grad_image = 0;
+ use_graticule = 0;
+ }
+ if( !grad_image && grad_idx > 0 ) {
+ grad_image = VFramePng::vframe_png(grad_paths[grad_idx]);
+ }
+ int rr = 2*radius;
+ if( grad_pixmap && (!use_graticule ||
+ rr != grad_pixmap->get_w() || rr != grad_pixmap->get_h()) ) {
+ delete grad_pixmap; grad_pixmap = 0;
+ use_graticule = 0;
+ }
+ if( !grad_pixmap && grad_image ) {
+ VFrame grad(rr, rr, BC_RGBA8888);
+ grad.transfer_from(grad_image);
+ grad_pixmap = new BC_Pixmap(this, &grad, PIXMAP_ALPHA);
+ use_graticule = grad_idx;
+ }
+ if( grad_pixmap ) {
+ int px = vector_cx - radius, py = vector_cy - radius;
+ vectorscope->draw_pixmap(grad_pixmap, px, py);
+// vectorscope->flash(0);
+ }
+ }
+}
+
+
+void ScopeGUI::update_graticule(int idx)
+{
+ grad_idx = idx;
+ update_scope();
+ toggle_event();
+}
+
+void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color)
+{
+// downfactor radius to prevent extreme edge from showing behind graticule
+ float cx = vector_cx, cy = vector_cy, rad = radius * 0.99;
+ int color_model = dst->get_color_model();
+ int bpp = BC_CModels::calculate_pixelsize(color_model);
+ int bg_r = (bg_color>>16) & 0xff;
+ int bg_g = (bg_color>> 8) & 0xff;
+ int bg_b = (bg_color>> 0) & 0xff;
+ int w = dst->get_w(), h = dst->get_h();
+ unsigned char **rows = dst->get_rows();
+ for( int y=0; y<h; ++y ) {
+ unsigned char *row = rows[y];
+ for( int x=0; x<w; ++x,row+=bpp ) {
+ int dx = cx-x, dy = cy-y;
+ float d = sqrt(dx*dx + dy*dy);
+ float r, g, b;
+ if( d < rad ) {
+ float h = TO_DEG(atan2(cx-x, cy-y));
+ if( h < 0 ) h += 360;
+ float s = d / rad, v = 255;
+ HSV::hsv_to_rgb(r, g, b, h, s, v);
+ }
+ else {
+ r = bg_r; g = bg_g; b = bg_b;
+ }
+ row[0] = r; row[1] = g; row[2] = b;
+ }
+ }
+}
void ScopeGUI::process(VFrame *output_frame)
else
data_frame = output_frame;
frame_w = data_frame->get_w();
- //float radius = MIN(vector_w / 2, vector_h / 2);
bzero(waveform_vframe->get_data(), waveform_vframe->get_data_size());
- bzero(vector_vframe->get_data(), vector_vframe->get_data_size());
+ if( use_vector > 0 )
+ bzero(vector_vframe->get_data(), vector_vframe->get_data_size());
+ else if( use_vector < 0 ) {
+ if( wheel_vframe && (
+ wheel_vframe->get_w() != vector_w ||
+ wheel_vframe->get_h() != vector_h ) ) {
+ delete wheel_vframe; wheel_vframe = 0;
+ }
+ if( !wheel_vframe ) {
+ wheel_vframe = new VFrame(vector_w, vector_h, BC_RGB888);
+ draw_colorwheel(wheel_vframe, BLACK);
+ }
+ vector_vframe->copy_from(wheel_vframe);
+ }
engine->process();
if( histogram )
{
// Hide it
draw_point();
-
- int radius = MIN(get_w() / 2, get_h() / 2);
- drag_radius = sqrt(SQR(x - get_w() / 2) + SQR(y - get_h() / 2));
- drag_angle = atan2(y - get_h() / 2, x - get_w() / 2);
-
- drag_radius = MIN(drag_radius, radius);
-
- float saturation = (float)drag_radius / radius * FLOAT_MAX;
- float hue = -drag_angle * 360 / 2 / M_PI - 90;
+ int dx = x - gui->vector_cx, dy = y - gui->vector_cy;
+ drag_radius = sqrt(dx*dx + dy*dy);
+ if( drag_radius > gui->radius ) drag_radius = gui->radius;
+ float saturation = (float)drag_radius / gui->radius * FLOAT_MAX;
+ drag_angle = atan2(-dy, dx);
+ float hue = TO_DEG(drag_angle) - 90;
if( hue < 0 ) hue += 360;
char string[BCTEXTLEN];
void ScopeVectorscope::draw_point()
{
- if( drag_radius > 0 ) {
- int radius = MIN(get_w() / 2, get_h() / 2);
- set_inverse();
- set_color(0xff0000);
+ set_inverse();
+ draw_point(drag_angle, drag_radius, RED);
+ set_opaque();
+}
+
+void ScopeVectorscope::draw_point(float th, float r, int color)
+{
+ if( r > 0 ) {
+ set_color(color);
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,
- get_w() / 2 + radius * cos(drag_angle),
- get_h() / 2 + radius * sin(drag_angle));
+ int cx = gui->vector_cx, cy = gui->vector_cy;
+ draw_circle(cx-r, cy-r, r*2, r*2);
set_line_width(1);
- set_opaque();
+ float radius = gui->radius;
+ draw_radient(th, 0.f, drag_radius/radius, color);
}
}
+void ScopeVectorscope::draw_radient(float th, float r1, float r2, int color)
+{
+ if( r2 > 0 && r2 >= r1 ) {
+ set_color(color);
+ set_line_width(2);
+ int r = gui->radius;
+ double cth = r*cos(th), sth = -r*sin(th);
+ int cx = gui->vector_cx, cy = gui->vector_cy;
+ draw_line(cx+r1*cth, cy+r1*sth, cx+r2*cth, cy+r2*sth);
+ set_line_width(1);
+ }
+}
ScopeHistogram::ScopeHistogram(ScopeGUI *gui,
case SCOPE_VECTORSCOPE:
gui->use_vector = v;
break;
+ case SCOPE_VECTORWHEEL:
+ gui->use_vector = -v;
+ break;
}
gui->toggle_event();
gui->update_toggles();
add_item(new BC_MenuItem("-"));
add_item(vect_on =
new ScopeScopesOn(this, _("Vectorscope"), SCOPE_VECTORSCOPE));
+ add_item(vect_wheel =
+ new ScopeScopesOn(this, _("VectorWheel"), SCOPE_VECTORWHEEL));
}
void ScopeMenu::update_toggles()
wave_on->set_checked(gui->use_wave);
wave_rgb_on->set_checked(gui->use_wave_parade>0);
wave_ply_on->set_checked(gui->use_wave_parade<0);
- vect_on->set_checked(gui->use_vector);
+ vect_on->set_checked(gui->use_vector>0);
+ vect_wheel->set_checked(gui->use_vector<0);
}
-ScopeWaveSlider::ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w)
- : BC_ISlider(x, y, 0, w, w, 1, 9, gui->use_wave_gain)
+
+ScopeVectGrads::ScopeVectGrads(ScopeGUI *gui, int x, int y)
+ : BC_PopupMenu(x, y, _("Overlay"))
{
this->gui = gui;
}
-int ScopeWaveSlider::handle_event()
-{
- gui->use_wave_gain = get_value();
- gui->update_scope();
- gui->toggle_event();
- return 1;
+
+#define SCOPE_SEARCHPATH "/scopes"
+void ScopeVectGrads::create_objects()
+{
+ gui->grad_paths.remove_all_objects();
+ ScopeGradItem *item;
+ add_item(item = new ScopeGradItem(this, _("none"), 0));
+ if( item->idx == gui->grad_idx ) item->set_checked(1);
+ gui->grad_paths.append(0);
+ FileSystem fs;
+ fs.set_filter("[*.png]");
+ char scope_path[BCTEXTLEN];
+ sprintf(scope_path, "%s%s", File::get_plugin_path(), SCOPE_SEARCHPATH);
+ fs.update(scope_path);
+ for( int i=0; i<fs.total_files(); ++i ) {
+ FileItem *file_item = fs.get_entry(i);
+ if( file_item->get_is_dir() ) continue;
+ strcpy(scope_path, file_item->get_name());
+ char *cp = strrchr(scope_path, '.');
+ if( cp ) *cp = 0;
+ add_item(item = new ScopeGradItem(this, scope_path, gui->grad_paths.size()));
+ if( item->idx == gui->grad_idx ) item->set_checked(1);
+ gui->grad_paths.append(cstrdup(file_item->get_path()));
+ }
}
-ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w)
- : BC_ISlider(x, y, 0, w, w, 1, 9, gui->use_vect_gain)
+ScopeGradItem::ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx)
+ : BC_MenuItem(text)
{
- this->gui = gui;
+ this->vect_grads = vect_grads;
+ this->idx = idx;
}
-int ScopeVectSlider::handle_event()
+
+int ScopeGradItem::handle_event()
{
- gui->use_vect_gain = get_value();
- gui->update_scope();
- gui->toggle_event();
+ for( int i=0,n=vect_grads->total_items(); i<n; ++i ) {
+ ScopeGradItem *item = (ScopeGradItem *)vect_grads->get_item(i);
+ item->set_checked(item->idx == idx);
+ }
+ vect_grads->gui->update_graticule(idx);
return 1;
}
-ScopeSmooth::ScopeSmooth(ScopeGUI *gui, int x, int y)
- : BC_CheckBox(x, y, gui->use_smooth, _("Smooth"))
+
+ScopeGainReset::ScopeGainReset(ScopeGain *gain, int x, int y)
+ : BC_Button(x, y, gain->gui->theme->get_image_set("reset_button"))
{
- this->gui = gui;
+ this->gain = gain;
}
-int ScopeSmooth::handle_event()
+int ScopeGainReset::calculate_w(BC_Theme *theme)
{
- gui->use_smooth = get_value();
- gui->update_scope();
- gui->toggle_event();
- return 1;
+ VFrame *vfrm = *theme->get_image_set("reset_button");
+ return vfrm->get_w();
}
-// from ffmpeg vf_boxblur
-template<class dst_t, class src_t> static inline
-void blurt(dst_t *dst, int dst_step, src_t *src, int src_step, int len, int radius)
+int ScopeGainReset::handle_event()
{
- const int length = radius*2 + 1;
- const int inv = ((1<<16) + length/2)/length;
- int x, n, sum = src[radius*src_step];
-
- for( x=0; x<radius; ++x )
- sum += src[x*src_step]<<1;
- sum = sum*inv + (1<<15);
-
- for( x=0; x<=radius; ++x ) {
- sum += (src[(radius+x)*src_step] - src[(radius-x)*src_step])*inv;
- dst[x*dst_step] = sum>>16;
- }
- n = len - radius;
- for( ; x<n; ++x ) {
- sum += (src[(radius+x)*src_step] - src[(x-radius-1)*src_step])*inv;
- dst[x*dst_step] = sum >>16;
- }
-
- for ( ; x<len; ++x ) {
- sum += (src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step])*inv;
- dst[x*dst_step] = sum>>16;
- }
-}
-template<class dst_t, class src_t> static inline
-void blur_power(dst_t *dst, int dst_step, src_t *src, int src_step,
- int len, int radius, int power)
-{
- dst_t atemp[len], btemp[len];
- dst_t *a = atemp, *b = btemp;
- blurt(a, 1, src, src_step, len, radius);
- while( power-- > 2 ) {
- blurt(b, 1, a, 1, len, radius);
- dst_t *t = a; a = b; b = t;
- }
- if( power > 1 )
- blurt(dst, dst_step, a, 1, len, radius);
- else
- for( int i = 0; i<len; ++i ) dst[i*dst_step] = a[i];
+ gain->slider->update(5);
+ return gain->handle_event();
}
-
-BoxBlurPackage::BoxBlurPackage()
- : LoadPackage()
+ScopeGainSlider::ScopeGainSlider(ScopeGain *gain, int x, int y, int w)
+ : BC_ISlider(x, y, 0, w, w, 1, 9, *gain->value)
{
+ this->gain = gain;
}
-BoxBlurUnit::BoxBlurUnit(BoxBlur *box_blur)
- : LoadClient(box_blur)
+int ScopeGainSlider::handle_event()
{
+ return gain->handle_event();
}
-template<class dst_t, class src_t>
-void BoxBlurUnit::blurt_package(LoadPackage *package)
+ScopeGain::ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value)
{
- BoxBlur *box_blur = (BoxBlur *)server;
- src_t *src_data = (src_t *)box_blur->src_data;
- dst_t *dst_data = (dst_t *)box_blur->dst_data;
- int radius = box_blur->radius;
- int power = box_blur->power;
- int vlen = box_blur->vlen;
- int c0 = box_blur->c0, c1 = box_blur->c1;
- int src_ustep = box_blur->src_ustep;
- int dst_ustep = box_blur->dst_ustep;
- int src_vstep = box_blur->src_vstep;
- int dst_vstep = box_blur->dst_vstep;
- BoxBlurPackage *pkg = (BoxBlurPackage*)package;
- int u1 = pkg->u1, u2 = pkg->u2;
- for( int u=u1; u<u2; ++u ) {
- src_t *sp = src_data + u*src_ustep;
- dst_t *dp = dst_data + u*dst_ustep;
- for( int c=c0; c<=c1; ++c ) {
- blur_power(dp+c, dst_vstep, sp+c, src_vstep,
- vlen, radius, power);
- }
- }
-}
+ this->gui = gui;
+ this->x = x;
+ this->y = y;
+ this->w = w;
+ this->value = value;
-void BoxBlurUnit::process_package(LoadPackage *package)
+ slider = 0;
+ reset = 0;
+}
+ScopeGain::~ScopeGain()
{
- blurt_package<uint16_t, const uint16_t>(package);
+ delete reset;
+ delete slider;
}
-BoxBlur::BoxBlur(int cpus)
- : LoadServer(cpus, cpus)
+int ScopeGain::calculate_h()
{
+ return BC_ISlider::get_span(0);
}
-BoxBlur::~BoxBlur()
+
+void ScopeGain::create_objects()
{
+ reset_w = ScopeGainReset::calculate_w(gui->theme);
+ gui->add_subwindow(slider = new ScopeGainSlider(this, x, y, w-reset_w-xS(5)));
+ gui->add_subwindow(reset = new ScopeGainReset(this, x+w-reset_w, y));
}
-LoadClient* BoxBlur::new_client() { return new BoxBlurUnit(this); }
-LoadPackage* BoxBlur::new_package() { return new BoxBlurPackage(); }
-
-void BoxBlur::init_packages()
+int ScopeGain::handle_event()
{
- int u = 0;
- for( int i=0,n=LoadServer::get_total_packages(); i<n; ) {
- BoxBlurPackage *pkg = (BoxBlurPackage*)get_package(i);
- pkg->u1 = u;
- pkg->u2 = u = (++i * ulen) / n;
- }
+ *value = slider->get_value();
+ gui->update_scope();
+ gui->toggle_event();
+ return 1;
}
-//dst can equal src, requires geom(dst)==geom(src)
-//uv: 0=hblur, 1=vblur; comp: -1=rgb,0=r,1=g,2=b
-void BoxBlur::process(VFrame *dst, VFrame *src, int uv,
- int radius, int power, int comp)
-{
- this->radius = radius;
- this->power = power;
- int src_w = src->get_w(), src_h = src->get_h();
- ulen = !uv ? src_h : src_w;
- vlen = !uv ? src_w : src_h;
- c0 = comp<0 ? 0 : comp;
- c1 = comp<0 ? 2 : comp;
- src_data = src->get_data();
- dst_data = dst->get_data();
- int src_pixsz = BC_CModels::calculate_pixelsize(src->get_color_model());
- int src_comps = BC_CModels::components(src->get_color_model());
- int src_bpp = src_pixsz / src_comps;
- int dst_pixsz = BC_CModels::calculate_pixelsize(dst->get_color_model());
- int dst_comps = BC_CModels::components(dst->get_color_model());
- int dst_bpp = dst_pixsz / dst_comps;
- int dst_linsz = dst->get_bytes_per_line() / dst_bpp;
- int src_linsz = src->get_bytes_per_line() / src_bpp;
- src_ustep = !uv ? src_linsz : src_comps;
- dst_ustep = !uv ? dst_linsz: dst_comps;
- src_vstep = !uv ? src_comps : src_linsz;
- dst_vstep = !uv ? dst_comps : dst_linsz;
+void ScopeGain::reposition_window(int x, int y)
+{
+ this->x = x; this->y = y;
+ slider->reposition_window(x, y);
+ reset->reposition_window(x+w-reset_w, y);
+}
- process_packages();
+ScopeWaveSlider::ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w)
+ : ScopeGain(gui, x, y, w, &gui->use_wave_gain)
+{
}
-void BoxBlur::hblur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w)
+ : ScopeGain(gui, x, y, w, &gui->use_vect_gain)
{
- process(dst, src, 0, radius, power, comp);
}
-void BoxBlur::vblur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+
+ScopeSmooth::ScopeSmooth(ScopeGUI *gui, int x, int y)
+ : BC_CheckBox(x, y, gui->use_smooth, _("Smooth"))
{
- process(dst, src, 1, radius, power, comp);
+ this->gui = gui;
}
-void BoxBlur::blur(VFrame *dst, VFrame *src, int radius, int power, int comp)
+
+int ScopeSmooth::handle_event()
{
- process(dst, src, 0, radius, power, comp);
- process(dst, dst, 1, radius, power, comp);
+ gui->use_smooth = get_value();
+ gui->update_scope();
+ gui->toggle_event();
+ return 1;
}