Okay, here is a patch implementing my improvements to wipe.  If this isn't
the best way to submit patches, let me know what would be.

I'm mimicked the existing code's semantics in that a wipe with a direction
of "up" means a wipe from the top of the screen down to the bottom.  That
seems counterintuitive to me, but it's consistent with the old code's
definition of a wipe with direction "left" as going from left to right.
Swapping them all would seem more intuitive to me, but might break
existing XML files.
-- 
Matthew Skala
[EMAIL PROTECTED]                    Embrace and defend.
http://ansuz.sooke.bc.ca/
Index: plugins/wipe/wipe.C
===================================================================
--- plugins/wipe/wipe.C (revision 1009)
+++ plugins/wipe/wipe.C (working copy)
@@ -19,46 +19,30 @@
 
 
 
-WipeLeft::WipeLeft(WipeMain *plugin, 
+WipeCtlButton::WipeCtlButton(WipeMain *plugin, 
        WipeWindow *window,
        int x,
-       int y)
+       int y,
+       int direction,
+       char *caption)
  : BC_Radial(x, 
                y, 
-               plugin->direction == 0, 
-               _("Left"))
+               plugin->direction == direction, 
+               caption)
 {
        this->plugin = plugin;
        this->window = window;
+       this->direction = direction;
 }
 
-int WipeLeft::handle_event()
+int WipeCtlButton::handle_event()
 {
-       update(1);
-       plugin->direction = 0;
-       window->right->update(0);
-       plugin->send_configure_change();
-       return 0;
-}
+       int i;
 
-WipeRight::WipeRight(WipeMain *plugin, 
-       WipeWindow *window,
-       int x,
-       int y)
- : BC_Radial(x, 
-               y, 
-               plugin->direction == 1, 
-               _("Right"))
-{
-       this->plugin = plugin;
-       this->window = window;
-}
-
-int WipeRight::handle_event()
-{
-       update(1);
-       plugin->direction = 1;
-       window->left->update(0);
+       for (i=0;i<4;i++) {
+               window->buttons[i]->update(i==this->direction);
+       }
+       plugin->direction = this->direction;
        plugin->send_configure_change();
        return 0;
 }
@@ -66,18 +50,14 @@
 
 
 
-
-
-
-
 WipeWindow::WipeWindow(WipeMain *plugin, int x, int y)
  : BC_Window(plugin->gui_string, 
        x, 
        y, 
        320, 
-       50, 
+       75, 
        320, 
-       50, 
+       75, 
        0, 
        0,
        1)
@@ -97,15 +77,34 @@
        int x = 10, y = 10;
        add_subwindow(new BC_Title(x, y, _("Direction:")));
        x += 100;
-       add_subwindow(left = new WipeLeft(plugin, 
+       add_subwindow(buttons[0] = new WipeCtlButton(plugin, 
                this,
                x,
-               y));
+               y,
+               0,
+               _("Left")));
        x += 100;
-       add_subwindow(right = new WipeRight(plugin, 
+       add_subwindow(buttons[1] = new WipeCtlButton(plugin, 
                this,
                x,
-               y));
+               y,
+               1,
+               _("Right")));
+       x -= 100;
+       y += 25;
+       add_subwindow(buttons[2] = new WipeCtlButton(plugin, 
+               this,
+               x,
+               y,
+               2,
+               _("Up")));
+       x += 100;
+       add_subwindow(buttons[3] = new WipeCtlButton(plugin, 
+               this,
+               x,
+               y,
+               3,
+               _("Down")));
        show_window();
        flush();
 }
@@ -202,53 +201,6 @@
 
 
 
-
-#define WIPE(type, components) \
-{ \
-       if(direction == 0) \
-       { \
-               for(int j = 0; j < h; j++) \
-               { \
-                       type *in_row = (type*)incoming->get_rows()[j]; \
-                       type *out_row = (type*)outgoing->get_rows()[j]; \
-                       int x = incoming->get_w() *  \
-                               PluginClient::get_source_position() /  \
-                               PluginClient::get_total_len(); \
- \
-                       for(int k = 0; k < x; k++) \
-                       { \
-                               out_row[k * components + 0] = in_row[k * 
components + 0]; \
-                               out_row[k * components + 1] = in_row[k * 
components + 1]; \
-                               out_row[k * components + 2] = in_row[k * 
components + 2]; \
-                               if(components == 4) out_row[k * components + 3] 
= in_row[k * components + 3]; \
-                       } \
-               } \
-       } \
-       else \
-       { \
-               for(int j = 0; j < h; j++) \
-               { \
-                       type *in_row = (type*)incoming->get_rows()[j]; \
-                       type *out_row = (type*)outgoing->get_rows()[j]; \
-                       int x = incoming->get_w() - incoming->get_w() *  \
-                               PluginClient::get_source_position() /  \
-                               PluginClient::get_total_len(); \
- \
-                       for(int k = x; k < w; k++) \
-                       { \
-                               out_row[k * components + 0] = in_row[k * 
components + 0]; \
-                               out_row[k * components + 1] = in_row[k * 
components + 1]; \
-                               out_row[k * components + 2] = in_row[k * 
components + 2]; \
-                               if(components == 4) out_row[k * components + 3] 
= in_row[k * components + 3]; \
-                       } \
-               } \
-       } \
-}
-
-
-
-
-
 int WipeMain::process_realtime(VFrame *incoming, VFrame *outgoing)
 {
        load_configuration();
@@ -256,31 +208,71 @@
        int w = incoming->get_w();
        int h = incoming->get_h();
 
+       int pixel_size = 0;
 
        switch(incoming->get_color_model())
        {
                case BC_RGB_FLOAT:
-                       WIPE(float, 3)
+                       pixel_size = sizeof(float)*3;
                        break;
                case BC_RGB888:
                case BC_YUV888:
-                       WIPE(unsigned char, 3)
+                       pixel_size = sizeof(unsigned char)*3;
                        break;
                case BC_RGBA_FLOAT:
-                       WIPE(float, 4)
+                       pixel_size = sizeof(float)*4;
                        break;
                case BC_RGBA8888:
                case BC_YUVA8888:
-                       WIPE(unsigned char, 4)
+                       pixel_size = sizeof(unsigned char)*4;
                        break;
                case BC_RGB161616:
                case BC_YUV161616:
-                       WIPE(uint16_t, 3)
+                       pixel_size = sizeof(uint16_t)*3;
                        break;
                case BC_RGBA16161616:
                case BC_YUVA16161616:
-                       WIPE(uint16_t, 4)
+                       pixel_size = sizeof(uint16_t)*4;
                        break;
        }
+
+       int lo_x = 0;
+       int hi_x = w;
+       int lo_y = 0;
+       int hi_y = h;
+
+       switch(direction) {
+               case 0:
+                       hi_x = incoming->get_w() *
+                               PluginClient::get_source_position() /
+                               PluginClient::get_total_len();
+                       break;
+               case 1:
+               default:
+                       lo_x = incoming->get_w() - incoming->get_w() *
+                               PluginClient::get_source_position() /
+                               PluginClient::get_total_len();
+                       break;
+               case 2:
+                       hi_y = incoming->get_h() *
+                               PluginClient::get_source_position() /
+                               PluginClient::get_total_len();
+                       break;
+               case 3:
+                       lo_y = incoming->get_h() - incoming->get_h() *
+                               PluginClient::get_source_position() /
+                               PluginClient::get_total_len();
+                       break;
+       }
+
+       for (int y=lo_y; y<hi_y; y++) {
+               unsigned char *in_row =
+                       (unsigned char *)incoming->get_rows()[y];
+               unsigned char *out_row =
+                       (unsigned char *)outgoing->get_rows()[y];
+               memcpy(out_row+lo_x*pixel_size,in_row+lo_x*pixel_size,
+                       (hi_x-lo_x)*pixel_size);
+       }
+
        return 0;
 }
Index: plugins/wipe/wipe.h
===================================================================
--- plugins/wipe/wipe.h (revision 1009)
+++ plugins/wipe/wipe.h (working copy)
@@ -9,36 +9,22 @@
 #include "pluginvclient.h"
 #include "vframe.inc"
 
-
-
-
-class WipeLeft : public BC_Radial
+class WipeCtlButton : public BC_Radial /* sic */
 {
+       int direction;
 public:
-       WipeLeft(WipeMain *plugin, 
+       WipeCtlButton(WipeMain *plugin,
                WipeWindow *window,
                int x,
-               int y);
+               int y,
+               int direction,
+               char *caption);
        int handle_event();
        WipeMain *plugin;
        WipeWindow *window;
 };
 
-class WipeRight : public BC_Radial
-{
-public:
-       WipeRight(WipeMain *plugin, 
-               WipeWindow *window,
-               int x,
-               int y);
-       int handle_event();
-       WipeMain *plugin;
-       WipeWindow *window;
-};
 
-
-
-
 class WipeWindow : public BC_Window
 {
 public:
@@ -46,8 +32,7 @@
        void create_objects();
        int close_event();
        WipeMain *plugin;
-       WipeLeft *left;
-       WipeRight *right;
+       WipeCtlButton *buttons[4];
 };
 
 

Reply via email to