Auto *prev_auto = 0;
mask_autos->get_prev_auto(position, PLAY_FORWARD, (Auto *&)prev_auto, 1);
MaskAuto *prev_mask = (MaskAuto *)prev_auto;
- ArrayList<MaskPoint*> points;
+ MaskPoints points;
int update_points = 1;
// Determine the points based on whether
// new keyframes will be generated or drawing is performed.
if(button_press && result) {
#ifdef USE_KEYFRAME_SPANNING
- ArrayList<MaskPoint*> &mask_points = points;
+ MaskPoints &mask_points = points;
#else
SubMask *mask = gui->mask_keyframe->get_submask(mwindow->edl->session->cwindow_mask);
- ArrayList<MaskPoint*> &mask_points = mask->points;
+ MaskPoints &mask_points = mask->points;
#endif
int k = gui->affected_point;
if( k >= 0 && k < mask_points.size() ) {
gui->current_operation != CWINDOW_NONE ) {
// mwindow->undo->update_undo_before(_("mask point"), this);
#ifdef USE_KEYFRAME_SPANNING
- ArrayList<MaskPoint*> &mask_points = points;
+ MaskPoints &mask_points = points;
#else
- ArrayList<MaskPoint*> &mask_points = mask->points;
+ MaskPoints &mask_points = mask->points;
#endif
MaskPoint *point = mask_points.get(gui->affected_point);
// canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
if( !mask_gui->mask_enables[j]->get_value() ) continue;
SubMask *sub_mask = keyframe->get_submask(j);
if( !sub_mask ) continue;
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
for( int i=0; i<points.size(); ++i ) {
MaskPoint *point = points[i];
point->x += dx;
int button_no = get_buttonpress();
double ds = accel/64., dt = accel*M_PI/360.;
double scale = button_no == WHEEL_UP ? 1.+ds : 1.-ds;
+ int mode = mask_gui->scale_mode;
+ double xscale = !rotate && (mode == 0 || mode == 2 ) ? scale : 1.;
+ double yscale = !rotate && (mode == 1 || mode == 2 ) ? scale : 1.;
double theta = button_no == WHEEL_UP ? dt : -dt;
if( rotate ? theta==0 : scale==1 ) break;
float st = sin(theta), ct = cos(theta);
if( !mask_gui->mask_enables[j]->get_value() ) continue;
SubMask *sub_mask = keyframe->get_submask(j);
if( !sub_mask ) continue;
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
for( int i=0; i<points.size(); ++i ) {
MaskPoint *point = points[i];
float px = point->x - gui->x_origin;
float py = point->y - gui->y_origin;
- float nx = !rotate ? px*scale : px*ct + py*st;
- float ny = !rotate ? py*scale : py*ct - px*st;
+ float nx = !rotate ? px*xscale : px*ct + py*st;
+ float ny = !rotate ? py*yscale : py*ct - px*st;
point->x = nx + gui->x_origin;
point->y = ny + gui->y_origin;
px = point->control_x1; py = point->control_y1;
- point->control_x1 = !rotate ? px*scale : px*ct + py*st;
- point->control_y1 = !rotate ? py*scale : py*ct - px*st;
+ point->control_x1 = !rotate ? px*xscale : px*ct + py*st;
+ point->control_y1 = !rotate ? py*yscale : py*ct - px*st;
px = point->control_x2; py = point->control_y2;
- point->control_x2 = !rotate ? px*scale : px*ct + py*st;
- point->control_y2 = !rotate ? py*scale : py*ct - px*st;
+ point->control_x2 = !rotate ? px*xscale : px*ct + py*st;
+ point->control_y2 = !rotate ? py*yscale : py*ct - px*st;
}
}
rerender = 1;
mask_autos->update_parameter(&temp_keyframe);
}
#endif
-
- points.remove_all_objects();
//printf("CWindowCanvas::do_mask 20\n");
+
+ if( draw && draw_boundary && !draw_markers ) {
+ BC_WindowBase *cvs_win = get_canvas();
+ cvs_win->set_inverse();
+ cvs_win->set_color(RED+GREEN);
+ for( int k=0; k<SUBMASKS; ++k ) {
+ if( k == mwindow->edl->session->cwindow_mask ) continue;
+ points.remove_all_objects();
+ if( use_interpolated )
+ mask_autos->get_points(&points, k, position, PLAY_FORWARD);
+ else
+ prev_mask->get_points(&points, k);
+ MaskEdge edge;
+ edge.load(points, 0);
+ for( int i=0; i<edge.size(); ++i ) {
+ MaskCoord a = edge[i];
+ MaskCoord b = i<edge.size()-1 ? edge[i+1] : edge[0];
+ float ax = a.x, ay = a.y;
+ float bx = b.x, by = b.y;
+ output_to_canvas(mwindow->edl, 0, ax, ay);
+ output_to_canvas(mwindow->edl, 0, bx, by);
+ cvs_win->draw_line(ax,ay, bx,by);
+ }
+ }
+ }
+
return result;
}
for(MaskAuto *current = (MaskAuto*)autos->default_auto; current; ) {
SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
memset(submask->name, 0, sizeof(submask->name));
- strncpy(submask->name, get_text(), sizeof(submask->name));
+ strncpy(submask->name, get_text(), sizeof(submask->name)-1);
current = current == (MaskAuto*)autos->default_auto ?
(MaskAuto*)autos->first : (MaskAuto*)NEXT;
}
mask_items.remove_all_objects();
int sz = !keyframe ? 0 : keyframe->masks.size();
for( int i=0; i<SUBMASKS; ++i ) {
- char text[BCSTRLEN];
+ char text[BCSTRLEN]; memset(text, 0, sizeof(text));
if( i < sz ) {
SubMask *sub_mask = keyframe->masks.get(i);
- strncpy(text, sub_mask->name, sizeof(text));
+ strncpy(text, sub_mask->name, sizeof(text)-1);
}
else
sprintf(text, "%d", i);
return 1;
}
+int CWindowMaskFocus::calculate_w(CWindowMaskGUI *gui)
+{
+ int w, h;
+ calculate_extents(gui, &w, &h, _("Focus"));
+ return w;
+}
+
+CWindowMaskScaleXY::CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
+ int x, int y, VFrame **data, int v, int id, const char *tip)
+ : BC_Toggle(x, y, data, v)
+{
+ this->id = id;
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip(tip);
+}
+
+CWindowMaskScaleXY::~CWindowMaskScaleXY()
+{
+}
+
+int CWindowMaskScaleXY::handle_event()
+{
+ gui->scale_mode = id;
+ gui->mask_scale_x->update(id == 0);
+ gui->mask_scale_y->update(id == 1);
+ gui->mask_scale_xy->update(id == 2);
+ return 1;
+}
+
CWindowMaskHelp::CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui, int x, int y)
: BC_CheckBox(x, y, 0, _("Help"))
{
CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
: CWindowToolGUI(mwindow, thread,
- _(PROGRAM_NAME ": Mask"), 430, 700)
+ _(PROGRAM_NAME ": Mask"), 460, 700)
{
this->mwindow = mwindow;
this->thread = thread;
fade = 0;
feather = 0;
focused = 0;
+ scale_mode = 2;
markers = 1;
boundary = 1;
preset_dialog = 0;
void CWindowMaskGUI::create_objects()
{
- int x = 10, y = 10, margin = mwindow->theme->widget_border;
+ Theme *theme = mwindow->theme;
+ int x = 10, y = 10, margin = theme->widget_border;
int clr_w = CWindowMaskClrMask::calculate_w(mwindow);
int clr_x = get_w()-x - clr_w;
int del_w = CWindowMaskDelMask::calculate_w(this,_("Delete"));
add_subwindow(mask_delete = new CWindowMaskDelete(mwindow, this, x2, y, 80));
y += mask_load->get_h() + 2*margin;
BC_Bar *bar;
- add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
- y += bar->get_h() + 2*margin;
+// add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
+// y += bar->get_h() + 2*margin;
add_subwindow(title = new BC_Title(x, y, _("Select:")));
int bw = 0, bh = 0;
mask_blabels[i] = new BC_Title(x2+tx, y, text);
add_subwindow(mask_blabels[i]);
}
+ x2 += margin;
+ add_subwindow(mask_center = new CWindowMaskCenter(mwindow, this, x2, y, 80));
y += mask_blabels[0]->get_h() + margin;
add_subwindow(mask_unclr = new CWindowMaskUnclear(mwindow, this, x, y, x1-x-2*margin));
x2 = x1;
mask_enables[i] = new CWindowMaskEnable(mwindow, this, x2, y, i, 1);
add_subwindow(mask_enables[i]);
}
+ x2 += margin;
+ add_subwindow(mask_normal = new CWindowMaskNormal(mwindow, this, x2, y, 80));
y += mask_enables[0]->get_h() + 2*margin;
add_subwindow(title_bar = new BC_TitleBar(x, y, get_w()-2*x, 20, 10, _("Fade & Feather")));
y += title_bar->get_h() + margin;
float cx = mwindow->edl->session->output_w / 2.f;
focus_x = new CWindowCoord(this, x1, y, cx);
focus_x->create_objects();
- add_subwindow(focus = new CWindowMaskFocus(mwindow, this, del_x, y));
+ x2 = x1 + focus_x->get_w() + 3*margin;
+ add_subwindow(title = new BC_Title(x2, y, _("Scaling Mode:")));
+ x2 = clr_x - 2*margin - CWindowMaskFocus::calculate_w(this);
+ add_subwindow(focus = new CWindowMaskFocus(mwindow, this, x2, y));
add_subwindow(gang_focus = new CWindowMaskGangFocus(mwindow, this, clr_x, y));
y += focus_x->get_h() + margin;
add_subwindow(title = new BC_Title(x, y, "Y:"));
float cy = mwindow->edl->session->output_h / 2.f;
focus_y = new CWindowCoord(this, x1, y, cy);
focus_y->create_objects();
- add_subwindow(mask_center = new CWindowMaskCenter(mwindow, this, x2=x4, y, 80));
- x2 += mask_center->get_w() + 2*margin;
- add_subwindow(mask_normal = new CWindowMaskNormal(mwindow, this, x2, y, 80));
+ x2 = x1 + focus_y->get_w() + 3*margin;
+ add_subwindow(mask_scale_x = new CWindowMaskScaleXY(mwindow, this,
+ x2, y, theme->get_image_set("mask_scale_x"), 0, 0, _("scale x")));
+ x2 += mask_scale_x->get_w() + margin;
+ add_subwindow(mask_scale_y = new CWindowMaskScaleXY(mwindow, this,
+ x2, y, theme->get_image_set("mask_scale_y"), 0, 1, _("scale y")));
+ x2 += mask_scale_y->get_w() + margin;
+ add_subwindow(mask_scale_xy = new CWindowMaskScaleXY(mwindow, this,
+ x2, y, theme->get_image_set("mask_scale_xy"), 1, 2, _("scale xy")));
y += focus_x->get_h() + 2*margin;
add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
y += bar->get_h() + margin;
for( int j=typ<0? 0 : k; j<n; ++j ) {
if( !mask_enables[j]->get_value() ) continue;
SubMask *sub_mask = keyframe->get_submask(j);
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
int psz = points.size();
if( psz < 3 ) continue;
int l = mwindow->cwindow->gui->affected_point;
keyframe = &temp_keyframe;
#endif
SubMask *sub_mask = keyframe->get_submask(k);
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
int psz = points.size();
if( psz > 0 ) {
float cx = 0, cy = 0;
keyframe = &temp_keyframe;
#endif
SubMask *sub_mask = keyframe->get_submask(k);
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
int psz = points.size();
float cx = 0, cy = 0;
double dr = 0;
pgui->preset_dialog->gui->load_masks(masks);
for( int i=0; i<masks.size(); ++i ) {
char text[BCSTRLEN]; memset(text, 0, sizeof(text));
- strncpy(text, masks[i]->name, sizeof(text-1));
+ strncpy(text, masks[i]->name, sizeof(text)-1);
mask_items.append(new CWindowMaskItem(text));
}
masks.remove_all_objects();
double c = 4*(sqrt(2.)-1)/3; // bezier aprox circle
float r2 = r / 2.f, rc = r*c, r4 = r / 4.f;
MaskPoint *pt = 0;
- ArrayList<MaskPoint*> &points = sub_mask->points;
+ MaskPoints &points = sub_mask->points;
points.remove_all_objects();
switch( i ) {
- case 0: // square
+ case MASK_SHAPE_SQUARE:
points.append(pt = new MaskPoint());
pt->x = cx - r; pt->y = cy - r;
points.append(pt = new MaskPoint());
points.append(pt = new MaskPoint());
pt->x = cx - r; pt->y = cy + r;
break;
- case 1: // circle
+ case MASK_SHAPE_CIRCLE:
points.append(pt = new MaskPoint());
pt->x = cx - r; pt->y = cy - r;
pt->control_x1 = -rc; pt->control_y1 = rc;
pt->control_x1 = rc; pt->control_y1 = rc;
pt->control_x2 = -rc; pt->control_y2 = -rc;
break;
- case 2: // triangle
+ case MASK_SHAPE_TRIANGLE:
points.append(pt = new MaskPoint());
pt->x = cx + 0; pt->y = cy - r*(sqrt(3.)-1.);
points.append(pt = new MaskPoint());
points.append(pt = new MaskPoint());
pt->x = cx - r; pt->y = cy + r;
break;
- case 3: // oval
+ case MASK_SHAPE_OVAL:
points.append(pt = new MaskPoint());
pt->x = cx - r; pt->y = cy - r2;
pt->control_x1 = -r2; pt->control_y1 = r4;
// Get existing keyframe
gui->get_keyframe(track, autos, keyframe,
mask, point, create_it);
- int k = get_selection_number(0, 0);
- if( track && k >= 0 ) {
+ CWindowMaskItem *item = (CWindowMaskItem *) get_selection(0, 0);
+ if( track && item ) {
#ifdef USE_KEYFRAME_SPANNING
MaskAuto temp_keyframe(mwindow->edl, autos);
temp_keyframe.copy_data(keyframe);
keyframe = &temp_keyframe;
mask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
#endif
+ int k = item->id;
if( mask ) {
- if( k < 4 )
+ if( k < MASK_SHAPE_BUILTIN )
builtin_shape(k, mask);
else
- load_shape(k-4, mask);
+ load_shape(k-MASK_SHAPE_BUILTIN, mask);
#ifdef USE_KEYFRAME_SPANNING
autos->update_parameter(keyframe);
#endif
void CWindowMaskShape::create_objects()
{
shape_items.remove_all_objects();
- shape_items.append(new BC_ListBoxItem(_("square")));
- shape_items.append(new BC_ListBoxItem(_("circle")));
- shape_items.append(new BC_ListBoxItem(_("triangle")));
- shape_items.append(new BC_ListBoxItem(_("oval")));
+ shape_items.append(new CWindowMaskItem(_("square"), MASK_SHAPE_SQUARE));
+ shape_items.append(new CWindowMaskItem(_("circle"), MASK_SHAPE_CIRCLE));
+ shape_items.append(new CWindowMaskItem(_("triangle"), MASK_SHAPE_TRIANGLE));
+ shape_items.append(new CWindowMaskItem(_("oval"), MASK_SHAPE_OVAL));
ArrayList<SubMask *> masks;
gui->load_masks(masks);
+ int id = MASK_SHAPE_BUILTIN;
for( int i=0; i<masks.size(); ++i )
- shape_items.append(new BC_ListBoxItem(masks[i]->name));
+ shape_items.append(new CWindowMaskItem(masks[i]->name, id++));
masks.remove_all_objects();
update(&shape_items, 0, 0, 1);
}
int handle_event();
MWindow *mwindow;
CWindowMaskGUI *gui;
+ static int calculate_w(CWindowMaskGUI *gui);
+};
+
+class CWindowMaskScaleXY : public BC_Toggle
+{
+public:
+ CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
+ int x, int y, VFrame **data, int v,
+ int id, const char *tip);
+ ~CWindowMaskScaleXY();
+ int handle_event();
+ MWindow *mwindow;
+ CWindowMaskGUI *gui;
+ int id;
};
class CWindowMaskHelp : public BC_CheckBox
class CWindowMaskShape : public BC_ListBox
{
public:
+ enum { MASK_SHAPE_SQUARE, MASK_SHAPE_CIRCLE,
+ MASK_SHAPE_TRIANGLE, MASK_SHAPE_OVAL,
+ MASK_SHAPE_BUILTIN };
CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui);
~CWindowMaskShape();
void create_objects();
CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
CWindowCoord *x, *y;
+ CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
+ int scale_mode;
CWindowMaskFocus *focus;
int focused;
CWindowMaskGangFocus *gang_focus;
class CWindowMaskSmoothButton;
class CWindowMaskAffectedPoint;
class CWindowMaskFocus;
+class CWindowMaskScaleXY;
class CWindowMaskHelp;
class CWindowMaskDrawMarkers;
class CWindowMaskDrawBoundary;
return masks.values[number];
}
-void MaskAuto::get_points(ArrayList<MaskPoint*> *points,
+void MaskAuto::get_points(MaskPoints *points,
int submask)
{
points->remove_all_objects();
}
}
-void MaskAuto::set_points(ArrayList<MaskPoint*> *points,
+void MaskAuto::set_points(MaskPoints *points,
int submask)
{
SubMask *submask_ptr = get_submask(submask);
return min_fader >= 0 && total_points < 2 ? 0 : 1;
}
+static inline double line_dist(float cx,float cy, float tx,float ty)
+{
+ double dx = tx-cx, dy = ty-cy;
+ return sqrt(dx*dx + dy*dy);
+}
+
+void MaskEdge::load(MaskPoints &points, float ofs)
+{
+ remove_all();
+ int first_point = 1;
+// Need to tabulate every vertex in persistent memory because
+// gluTessVertex doesn't copy them.
+ for( int i=0; i<points.total; ++i ) {
+ MaskPoint *point1 = points.values[i];
+ MaskPoint *point2 = (i >= points.total-1) ?
+ points.values[0] : points.values[i+1];
+
+ int segments = 0;
+ if( !point1->control_x2 && !point1->control_y2 &&
+ !point2->control_x1 && !point2->control_y1 )
+ segments = 1;
+
+ float x0 = point1->x, y0 = point1->y;
+ float x1 = point1->x + point1->control_x2;
+ float y1 = point1->y + point1->control_y2;
+ float x2 = point2->x + point2->control_x1;
+ float y2 = point2->y + point2->control_y1;
+ float x3 = point2->x, y3 = point2->y;
+
+ // forward differencing bezier curves implementation taken from GPL code at
+ // http://cvs.sourceforge.net/viewcvs.py/guliverkli/guliverkli/src/subtitles/Rasterizer.cpp?rev=1.3
+
+ float cx3, cx2, cx1, cx0;
+ float cy3, cy2, cy1, cy0;
+
+ // [-1 +3 -3 +1]
+ // [+3 -6 +3 0]
+ // [-3 +3 0 0]
+ // [+1 0 0 0]
+
+ cx3 = - x0 + 3*x1 - 3*x2 + x3;
+ cx2 = 3*x0 - 6*x1 + 3*x2;
+ cx1 = -3*x0 + 3*x1;
+ cx0 = x0;
+
+ cy3 = - y0 + 3*y1 - 3*y2 + y3;
+ cy2 = 3*y0 - 6*y1 + 3*y2;
+ cy1 = -3*y0 + 3*y1;
+ cy0 = y0;
+
+ // This equation is from Graphics Gems I.
+ //
+ // The idea is that since we're approximating a cubic curve with lines,
+ // any error we incur is due to the curvature of the line, which we can
+ // estimate by calculating the maximum acceleration of the curve. For
+ // a cubic, the acceleration (second derivative) is a line, meaning that
+ // the absolute maximum acceleration must occur at either the beginning
+ // (|c2|) or the end (|c2+c3|). Our bounds here are a little more
+ // conservative than that, but that's okay.
+ if( !segments ) {
+ float maxaccel1 = fabs(2*cy2) + fabs(6*cy3);
+ float maxaccel2 = fabs(2*cx2) + fabs(6*cx3);
+ float maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
+ segments = maxaccel > 1.0 ? sqrt(maxaccel) :
+ 1 + line_dist(point1->x,point1->y, point2->x,point2->y);
+ }
+
+ for( int j=0; j<=segments; ++j ) {
+ float t = (float)j / segments;
+ float x = cx0 + t*(cx1 + t*(cx2 + t*cx3));
+ float y = cy0 + t*(cy1 + t*(cy2 + t*cy3));
+
+ if( j > 0 || first_point ) {
+ append(x, y-ofs);
+ first_point = 0;
+ }
+ }
+ }
+}
+
float control_x2, control_y2;
};
+class MaskCoord { public: double x, y, z; };
+
+class MaskEdge : public ArrayList<MaskCoord>
+{
+public:
+ MaskCoord &append() { return ArrayList<MaskCoord>::append(); }
+ MaskCoord &append(double x, double y, double z=0) {
+ MaskCoord &c = append();
+ c.x = x; c.y = y; c.z = z;
+ return c;
+ }
+ void load(MaskPoints &points, float ofs);
+};
+
+class MaskEdges : public ArrayList<MaskEdge*> {
+public:
+ MaskEdges() {}
+ ~MaskEdges() { remove_all_objects(); }
+};
+
+class MaskPoints : public ArrayList<MaskPoint *>
+{
+public:
+ void clear() { remove_all_objects(); }
+ MaskPoints() {}
+ ~MaskPoints() { clear(); }
+};
+
+class MaskPointSets : public ArrayList<MaskPoints*>
+{
+public:
+ void clear() { remove_all_objects(); }
+ MaskPointSets() {}
+ ~MaskPointSets() { clear(); }
+};
+
#define FEATHER_MAX 100
class SubMask
char name[BCSTRLEN];
float fader; // -100 - 100
float feather; // -100 - 100
- ArrayList<MaskPoint*> points;
+ MaskPoints points;
MaskAuto *keyframe;
};
void copy_from(MaskAuto *src);
// Copy data but not position
void copy_data(MaskAuto *src);
- void get_points(ArrayList<MaskPoint*> *points,
+ void get_points(MaskPoints *points,
int submask);
- void set_points(ArrayList<MaskPoint*> *points,
+ void set_points(MaskPoints *points,
int submask);
// Copy parameters to this which differ between ref & src
int disable_opengl_masking;
};
-class MaskCoord { public: double x, y, z; };
-
-class MaskEdge : public ArrayList<MaskCoord>
-{
-public:
- MaskCoord &append() { return ArrayList<MaskCoord>::append(); }
- MaskCoord &append(double x, double y, double z=0) {
- MaskCoord &c = append();
- c.x = x; c.y = y; c.z = z;
- return c;
- }
-};
-
// shader buffer unsized array vec only seems to work for dvec (05/2019)
class MaskSpot { public: double x, y; };
}
};
-class MaskEdges : public ArrayList<MaskEdge*> {
-public:
- MaskEdges() {}
- ~MaskEdges() { remove_all_objects(); }
-};
-
-class MaskPointSet : public ArrayList<MaskPoint*>
-{
-public:
- void clear() { remove_all_objects(); }
- MaskPointSet() {}
- ~MaskPointSet() { clear(); }
-};
-class MaskPointSets : public ArrayList<MaskPointSet*>
-{
-public:
- void clear() { remove_all_objects(); }
- MaskPointSets() {}
- ~MaskPointSets() { clear(); }
-};
-
#endif
#define MASKAUTO_INC
-
-class MaskAuto;
class MaskPoint;
class SubMask;
+class MaskAuto;
+class MaskCoord;
+class MaskEdge;
+class MaskSpot;
+class MaskSpots;
+class MaskEdges;
+class MaskPoints;
+class MaskPointSets;
enum { // no longer used, legacy value
MASK_MULTIPLY_ALPHA,
#define SUBMASKS 8
-
-
#endif
-void MaskAutos::get_points(ArrayList<MaskPoint*> *points,
+void MaskAutos::get_points(MaskPoints *points,
int submask,
int64_t position,
int direction)
int mask_exists(int64_t position, int direction);
// Perform interpolation
- void get_points(ArrayList<MaskPoint*> *points, int submask, int64_t position, int direction);
+ void get_points(MaskPoints *points, int submask, int64_t position, int direction);
double get_feather(int64_t position, int i, int direction);
double get_fader(int64_t position, int i, int direction);
int total_submasks(int64_t position, int direction);
point_sets.remove_all_objects();
}
-int MaskEngine::points_equivalent(ArrayList<MaskPoint*> *new_points,
- ArrayList<MaskPoint*> *points)
+int MaskEngine::points_equivalent(MaskPoints *new_points,
+ MaskPoints *points)
{
//printf("MaskEngine::points_equivalent %d %d\n", new_points->total, points->total);
if( new_points->total != points->total ) return 0;
return 1;
}
-void MaskEngine::draw_edge(MaskEdge &edge, MaskPointSet &points)
-{
- if( points.size() < 2 ) return;
- edge.remove_all();
- for( int i=0; i<points.size(); ++i ) {
- MaskPoint *ap = points[i];
- MaskPoint *bp = (i>=points.size()-1) ?
- points[0] : points[i+1];
- int segments = 0;
- if( ap->control_x2 == 0 && ap->control_y2 == 0 &&
- bp->control_x1 == 0 && bp->control_y1 == 0 )
- segments = 1;
- float x0 = ap->x, y0 = ap->y;
- float x1 = ap->x + ap->control_x2;
- float y1 = ap->y + ap->control_y2;
- float x2 = bp->x + bp->control_x1;
- float y2 = bp->y + bp->control_y1;
- float x3 = bp->x, y3 = bp->y;
-
-// from Playback3D::do_mask_sync
- float cx3 = - x0 + 3*x1 - 3*x2 + x3;
- float cx2 = 3*x0 - 6*x1 + 3*x2;
- float cx1 = -3*x0 + 3*x1;
- float cx0 = x0;
-
- float cy3 = - y0 + 3*y1 - 3*y2 + y3;
- float cy2 = 3*y0 - 6*y1 + 3*y2;
- float cy1 = -3*y0 + 3*y1;
- float cy0 = y0;
-
- if( segments == 0 ) {
- float maxaccel1 = fabs(2*cy2) + fabs(6*cy3);
- float maxaccel2 = fabs(2*cx2) + fabs(6*cx3);
- float maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
- float h = 1.0;
- if( maxaccel > 8.0 ) h = sqrt((8.0) / maxaccel);
- segments = int(1/h);
- }
-
- for( int j = 0; j <= segments; ++j ) {
- float t = (float)j / segments;
- float x = cx0 + t*(cx1 + t*(cx2 + t*cx3));
- float y = cy0 + t*(cy1 + t*(cy2 + t*cy3));
- edge.append(x, y);
- }
- }
-}
-
void MaskEngine::do_mask(VFrame *output,
int64_t start_position_project,
MaskAutos *keyframe_set,
if( new_fader != faders[i] ) { recalculate = 1; break; }
float new_feather = keyframe_set->get_feather(start_position_project, i, PLAY_FORWARD);
if( new_feather != feathers[i] ) { recalculate = 1; break; }
- ArrayList<MaskPoint*> new_points;
+ MaskPoints new_points;
keyframe_set->get_points(&new_points, i,
start_position_project, PLAY_FORWARD);
if( !points_equivalent(&new_points, point_sets[i]) )
recalculate = 1;
- new_points.remove_all_objects();
}
if( recalculate ) {
for( int i = 0; i < point_sets.total; i++ ) {
- ArrayList<MaskPoint*> *points = point_sets[i];
+ MaskPoints *points = point_sets[i];
points->remove_all_objects();
}
point_sets.remove_all_objects();
fade[i+1] = t;
float feather = keyframe_set->get_feather(start_position_project, i, PLAY_FORWARD);
feathers.append(feather);
- MaskPointSet *new_points = new MaskPointSet();
+ MaskPoints *new_points = new MaskPoints();
keyframe_set->get_points(new_points, i, start_position_project, PLAY_FORWARD);
point_sets.append(new_points);
MaskEdge *edge = edges.append(new MaskEdge());
if( !((show_mask>>i) & 1) ) continue;
- draw_edge(*edge, *new_points);
+ edge->load(*new_points, 0);
}
// draw mask
if( !mask ) mask = new VFrame(mask_w, mask_h, mask_model, 0);
MaskAutos *keyframe_set,
MaskAuto *keyframe,
MaskAuto *default_auto);
- int points_equivalent(ArrayList<MaskPoint*> *new_points,
- ArrayList<MaskPoint*> *points);
+ int points_equivalent(MaskPoints *new_points,
+ MaskPoints *points);
void delete_packages();
void init_packages();
LoadClient* new_client();
LoadPackage* new_package();
- void draw_edge(MaskEdge &edge, MaskPointSet &points);
VFrame *output;
VFrame *mask, *temp;
int h = command->frame->get_h();
MaskEdges edges;
float faders[SUBMASKS], feathers[SUBMASKS], bg = 1;
- MaskPointSet point_set[SUBMASKS];
+ MaskPoints point_set[SUBMASKS];
// Draw every submask as a new polygon
int total_submasks = command->keyframe_set->total_submasks(
command->start_position_project, PLAY_FORWARD);
for(int k = 0; k < total_submasks; k++) {
- MaskPointSet &points = point_set[k];
+ MaskPoints &points = point_set[k];
command->keyframe_set->get_points(&points,
k, command->start_position_project, PLAY_FORWARD);
float fader = command->keyframe_set->get_fader(
int show_mask = command->keyframe_set->track->masks;
for(int k = 0; k < total_submasks; k++) {
- MaskPointSet &points = point_set[k];
MaskEdge &edge = *edges.append(new MaskEdge());
if( !((show_mask>>k) & 1) ) continue;
- int first_point = 0;
-// Need to tabulate every vertex in persistent memory because
-// gluTessVertex doesn't copy them.
- for(int i = 0; i < points.total; i++) {
- MaskPoint *point1 = points.values[i];
- MaskPoint *point2 = (i >= points.total - 1) ?
- points.values[0] : points.values[i + 1];
-
- float x, y;
- int segments = 0;
- if( point1->control_x2 == 0 && point1->control_y2 == 0 &&
- point2->control_x1 == 0 && point2->control_y1 == 0 )
- segments = 1;
-
- float x0 = point1->x, y0 = point1->y;
- float x1 = point1->x + point1->control_x2;
- float y1 = point1->y + point1->control_y2;
- float x2 = point2->x + point2->control_x1;
- float y2 = point2->y + point2->control_y1;
- float x3 = point2->x, y3 = point2->y;
-
- // forward differencing bezier curves implementation taken from GPL code at
- // http://cvs.sourceforge.net/viewcvs.py/guliverkli/guliverkli/src/subtitles/Rasterizer.cpp?rev=1.3
-
- float cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
-
- // [-1 +3 -3 +1]
- // [+3 -6 +3 0]
- // [-3 +3 0 0]
- // [+1 0 0 0]
-
- cx3 = - x0 + 3*x1 - 3*x2 + x3;
- cx2 = 3*x0 - 6*x1 + 3*x2;
- cx1 = -3*x0 + 3*x1;
- cx0 = x0;
-
- cy3 = - y0 + 3*y1 - 3*y2 + y3;
- cy2 = 3*y0 - 6*y1 + 3*y2;
- cy1 = -3*y0 + 3*y1;
- cy0 = y0;
-
- // This equation is from Graphics Gems I.
- //
- // The idea is that since we're approximating a cubic curve with lines,
- // any error we incur is due to the curvature of the line, which we can
- // estimate by calculating the maximum acceleration of the curve. For
- // a cubic, the acceleration (second derivative) is a line, meaning that
- // the absolute maximum acceleration must occur at either the beginning
- // (|c2|) or the end (|c2+c3|). Our bounds here are a little more
- // conservative than that, but that's okay.
- if (segments == 0) {
- float maxaccel1 = fabs(2*cy2) + fabs(6*cy3);
- float maxaccel2 = fabs(2*cx2) + fabs(6*cx3);
-
- float maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
- float h = 1.0;
-
- if(maxaccel > 8.0) h = sqrt((8.0) / maxaccel);
- segments = int(1/h);
- }
-
- for(int j = 0; j <= segments; j++) {
- float t = (float)j / segments;
- x = cx0 + t*(cx1 + t*(cx2 + t*cx3));
- y = cy0 + t*(cy1 + t*(cy2 + t*cy3));
-
- if(j > 0 || first_point) {
- edge.append(x, y - h);
- first_point = 0;
- }
- }
- }
+ edge.load(point_set[k], h);
if( edge.size() > 0 ) {
// draw polygon
float fader = faders[k];
[ . ])
PKG_3RD([ffmpeg],[yes],
- [ffmpeg-4.1],
+ [ffmpeg-4.1.4],
[ libavutil/libavutil.a \
libavcodec/libavcodec.a \
libpostproc/libpostproc.a \
int BC_PopupTextBoxText::handle_event()
{
+ popup->list_item = -1;
popup->handle_event();
return 1;
}
}
int BC_PopupTextBoxList::handle_event()
{
- BC_ListBoxItem *item = get_selection(0, 0);
- if(item)
- {
- popup->textbox->update(item->get_text());
+ int k = get_selection_number(0, 0);
+ popup->list_item = k;
+ if( k >= 0 && k < popup->list_items->size() ) {
+ popup->textbox->update(popup->list_items->get(k)->get_text());
popup->textbox->set_text_row(0);
popup->handle_event();
}
void BC_PopupTextBox::update_list(ArrayList<BC_ListBoxItem*> *data)
{
+ list_items = data;
listbox->update(data, 0, 0, 1);
}
const char *BC_PopupTextBox::get_text() { return textbox->get_text(); }
const wchar_t *BC_PopupTextBox::get_wtext() { return textbox->get_wtext(); }
-int BC_PopupTextBox::get_number() { return listbox->get_selection_number(0, 0); }
+int BC_PopupTextBox::get_number() { return list_item; }
int BC_PopupTextBox::get_x() { return x; }
int BC_PopupTextBox::get_y() { return y; }
int BC_PopupTextBox::get_w() { return textbox->get_w() + listbox->get_w(); }
private:
int x, y, text_w, list_h;
- int list_format;
+ int list_format, list_item;
const char *default_text;
const wchar_t *default_wtext;
ArrayList<BC_ListBoxItem*> *list_items;
}
DeScratchMode::DeScratchMode(DeScratchWindow *win, int x, int y, int *value)
- : BC_PopupMenu(x, y, 64, "", 1)
+ : BC_PopupMenu(x, y, 100, "", 1)
{
this->win = win;
this->value = value;
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
+
flush_images();
new_toggle("blank30x30.png",
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
editpanel_up, editpanel_hi, editpanel_checked,
editpanel_dn, editpanel_checkedhi,
"tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
}
void CAKEWALKTHEME::get_vwindow_sizes(VWindowGUI *gui)
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
editpanel_dn, editpanel_checkedhi,
"tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
+
flush_images();
}
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
new_toggle("tan_smooth.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_smooth");
new_toggle("tan_linear.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "tan_linear");
+ new_toggle("mask_scale_x.png", "mask_scale_xup.png", "mask_scale_xuphi.png",
+ "mask_scale_xchkd.png", "mask_scale_xdown.png", "mask_scale_xchkdhi.png",
+ "mask_scale_x");
+ new_toggle("mask_scale_y.png", "mask_scale_yup.png", "mask_scale_yuphi.png",
+ "mask_scale_ychkd.png", "mask_scale_ydown.png", "mask_scale_ychkdhi.png",
+ "mask_scale_y");
+ new_toggle("mask_scale_xy.png", "mask_scale_xyup.png", "mask_scale_xyuphi.png",
+ "mask_scale_xychkd.png", "mask_scale_xydown.png", "mask_scale_xychkdhi.png",
+ "mask_scale_xy");
flush_images();
$(call if_pkg,libvpx,--enable-libvpx) \
$(call if_pkg,x264,--enable-libx264) \
$(call if_pkg,x265,--enable-libx265) \
- --extra-cflags="\
+ --extra-cflags="-Wno-attributes \
$(if $(WANT_NV), $(inc_ffnvcodec)) \
$(call inc_path,twolame,libtwolame) \
$(call inc_path,lame,include) \