fix audiospect ratio in scale per andrew, upgrade dav1d to 0.6.0, fix shapewipe black...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / shapewipe / shapewipe.C
index 0cd3bbe002b7249ac6d4be345dff6f057a647d65..b11006d078d48b1371eca3bbe598b597e3d862ee 100644 (file)
@@ -164,7 +164,7 @@ ShapeWipeFeather::ShapeWipeFeather(ShapeWipeMain *client,
                ShapeWipeWindow *window, int x, int y)
  : BC_TumbleTextBox(window,
                bclip(client->config.feather, SHAPE_FMIN, SHAPE_FMAX),
-               SHAPE_FMIN, SHAPE_FMAX, x, y, 64, 3)
+               SHAPE_FMIN, SHAPE_FMAX, x, y, xS(64), yS(3))
 {
        this->client = client;
        this->window = window;
@@ -222,13 +222,6 @@ int ShapeWipeReset::handle_event()
        return 1;
 }
 
-int ShapeWipeReset::calculate_w(ShapeWipeMain *client)
-{
-       VFrame **reset_images = client->get_theme()->get_image_set("reset_button");
-       return reset_images[0]->get_w();
-}
-
-
 ShapeWipeShape::ShapeWipeShape(ShapeWipeMain *client,
                ShapeWipeWindow *window, int x, int y,
                int text_w, int list_h)
@@ -248,7 +241,7 @@ int ShapeWipeShape::handle_event()
 
 
 ShapeWipeWindow::ShapeWipeWindow(ShapeWipeMain *plugin)
- : PluginClientWindow(plugin, 425, 215, 425, 215, 0)
+ : PluginClientWindow(plugin, xS(425), yS(215), xS(425), yS(215), 0)
 {
        this->plugin = plugin;
        shape_feather = 0;
@@ -265,7 +258,7 @@ void ShapeWipeWindow::create_objects()
 {
        BC_Title *title = 0;
        lock_window("ShapeWipeWindow::create_objects");
-       int pad = 10, margin = 10;
+       int pad = xS(10), margin = xS(10);
        int x = margin, y = margin;
        int ww = get_w() - 2*margin;
 
@@ -275,20 +268,15 @@ void ShapeWipeWindow::create_objects()
        }
 
        BC_TitleBar *bar;
-       add_subwindow(bar = new BC_TitleBar(x, y, ww, x+ww/12,
-               pad, _("Wipe"), MEDIUMFONT));
+       add_subwindow(bar = new BC_TitleBar(x, y, ww, xS(20), yS(10),
+               _("Wipe"), MEDIUMFONT));
        y += bar->get_h() + pad;
 
        add_subwindow(title = new BC_Title(x, y, _("Shape:")));
-       int x1 = get_w()/5;
-       x = x1;
-       int tw = ww - x1 - ShapeWipeTumble::calculate_w() - pad -
-               BC_WindowBase::get_resources()->listbox_button[0]->get_w();
-       shape_text = new ShapeWipeShape(plugin, this, x1, y, tw, 200);
+       int x1 = xS(85), x2 = xS(355), x3 = xS(386);
+       shape_text = new ShapeWipeShape(plugin, this, x1, y, x2-x1, yS(200));
        shape_text->create_objects();
-       x += shape_text->get_w() + pad;
-       add_subwindow(new ShapeWipeTumble(plugin,
-               this, x, y));
+       add_subwindow(new ShapeWipeTumble(plugin, this, x3, y));
        y += shape_text->get_h() + pad;
 
        x = margin;
@@ -298,10 +286,8 @@ void ShapeWipeWindow::create_objects()
        shape_feather->create_objects();
        shape_feather->set_log_floatincrement(1);
        x += shape_feather->get_w() + 2*pad;
-       int sw = ww - ShapeWipeReset::calculate_w(plugin) - pad - x;
-       add_subwindow(shape_fslider = new ShapeWipeFSlider(plugin, this, x, y, sw));
-       x += shape_fslider->get_w() + 2*pad;
-       add_subwindow(shape_reset = new ShapeWipeReset(plugin, this, x, y));
+       add_subwindow(shape_fslider = new ShapeWipeFSlider(plugin, this, x, y, x2-x));
+       add_subwindow(shape_reset = new ShapeWipeReset(plugin, this, x3, y));
        y += shape_fslider->get_h() + pad;
 
        x = margin;
@@ -310,8 +296,8 @@ void ShapeWipeWindow::create_objects()
                plugin, this, x, y));
        y += aspect_ratio->get_h() + pad;
 
-       add_subwindow(bar = new BC_TitleBar(x, y, ww, x+ww/12,
-               pad, _("Direction"), MEDIUMFONT));
+       add_subwindow(bar = new BC_TitleBar(x, y, ww, xS(20), yS(10),
+               _("Direction"), MEDIUMFONT));
        y += bar->get_h() + pad;
        x = margin;
        add_subwindow(left = new ShapeWipeW2B(plugin, this, x, y));
@@ -579,20 +565,40 @@ void ShapeWipeMain::reset_pattern_image()
        float scale = feather ? 1/feather : 0xff; \
        type  **in_rows = (type**)input->get_rows(); \
        type **out_rows = (type**)output->get_rows(); \
-       for( int y=y1; y<y2; ++y ) { \
-               type *in_row = (type*) in_rows[y]; \
-               type *out_row = (type*)out_rows[y]; \
-               unsigned char *pattern_row = pattern_image[y]; \
-               for( int x=0; x<w; ++x ) { \
-                       tmp_type d = (pattern_row[x] - threshold) * scale; \
-                       if( d > 0xff ) d = 0xff; \
-                       else if( d < -0xff ) d = -0xff; \
-                       tmp_type a = (d + 0xff) / 2, b = 0xff - a; \
-                       for( int i=0; i<components; ++i ) { \
-                               type ic = in_row[i], oc = out_row[i]; \
-                               out_row[i] = (ic * a + oc * b) / 0xff; \
+       if( !dir ) { \
+               for( int y=y1; y<y2; ++y ) { \
+                       type *in_row = (type*) in_rows[y]; \
+                       type *out_row = (type*)out_rows[y]; \
+                       unsigned char *pattern_row = pattern_image[y]; \
+                       for( int x=0; x<w; ++x ) { \
+                               tmp_type d = (pattern_row[x] - threshold) * scale; \
+                               if( d > 0xff ) d = 0xff; \
+                               else if( d < -0xff ) d = -0xff; \
+                               tmp_type a = (d + 0xff) / 2, b = 0xff - a; \
+                               for( int i=0; i<components; ++i ) { \
+                                       type ic = in_row[i], oc = out_row[i]; \
+                                       out_row[i] = (ic * a + oc * b) / 0xff; \
+                               } \
+                               in_row += components; out_row += components; \
+                       } \
+               } \
+       } \
+       else { \
+               for( int y=y1; y<y2; ++y ) { \
+                       type *in_row = (type*) in_rows[y]; \
+                       type *out_row = (type*)out_rows[y]; \
+                       unsigned char *pattern_row = pattern_image[y]; \
+                       for( int x=0; x<w; ++x ) { \
+                               tmp_type d = (pattern_row[x] - threshold) * scale; \
+                               if( d > 0xff ) d = 0xff; \
+                               else if( d < -0xff ) d = -0xff; \
+                               tmp_type b = (d + 0xff) / 2, a = 0xff - b; \
+                               for( int i=0; i<components; ++i ) { \
+                                       type ic = in_row[i], oc = out_row[i]; \
+                                       out_row[i] = (ic * a + oc * b) / 0xff; \
+                               } \
+                               in_row += components; out_row += components; \
                        } \
-                       in_row += components; out_row += components; \
                } \
        } \
 }
@@ -660,6 +666,7 @@ void ShapeUnit::process_package(LoadPackage *package)
        VFrame *input = server->plugin->input;
        VFrame *output = server->plugin->output;
        int w = input->get_w();
+       int dir = server->plugin->config.direction;
 
        unsigned char **pattern_image = server->plugin->pattern_image;
        unsigned char threshold = server->plugin->threshold;