aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdoc/pdp_vloopback-help.pd16
-rwxr-xr-xmodules/pdp_vloopback.c27
2 files changed, 38 insertions, 5 deletions
diff --git a/doc/pdp_vloopback-help.pd b/doc/pdp_vloopback-help.pd
index 62a84ae..4401d72 100755
--- a/doc/pdp_vloopback-help.pd
+++ b/doc/pdp_vloopback-help.pd
@@ -1,4 +1,4 @@
-#N canvas 261 169 712 664 10;
+#N canvas 265 177 760 664 10;
#X obj 159 72 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
-1;
#X msg 217 112 open \$1;
@@ -38,12 +38,16 @@ that supports v4l input ( skype \, webcamstudio \, ... );
#X msg 66 97 loop 1;
#X obj 217 409 pdp_xv;
#X text 382 374 default /dev/video1;
-#X msg 357 306 open /dev/video1;
-#X msg 359 334 close;
-#X text 464 304 open a vloopback device;
-#X text 400 334 close a vloopback device;
+#X msg 362 274 open /dev/video1;
+#X msg 364 302 close;
+#X text 469 272 open a vloopback device;
+#X text 405 302 close a vloopback device;
#X floatatom 369 410 5 0 0 0 - - -;
#X text 411 407 number of frames written;
+#X msg 365 332 invert \$1;
+#X obj 433 333 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+1;
+#X text 455 331 invert red and blue channels ( default : 1 );
#X connect 0 0 6 0;
#X connect 1 0 7 0;
#X connect 2 0 1 0;
@@ -73,3 +77,5 @@ that supports v4l input ( skype \, webcamstudio \, ... );
#X connect 29 0 7 0;
#X connect 32 0 17 0;
#X connect 33 0 17 0;
+#X connect 38 0 17 0;
+#X connect 39 0 38 0;
diff --git a/modules/pdp_vloopback.c b/modules/pdp_vloopback.c
index 12f9e31..c475d6f 100755
--- a/modules/pdp_vloopback.c
+++ b/modules/pdp_vloopback.c
@@ -59,6 +59,7 @@ typedef struct pdp_vloopback_struct
t_outlet *x_outlet1;
int x_nbframes;
+ int x_invertrb;
struct video_window x_vidwin;
struct video_picture x_vidpic;
@@ -201,6 +202,8 @@ static void pdp_vloopback_process_rgb(t_pdp_vloopback *x)
{
t_pdp *header = pdp_packet_header(x->x_packet0);
char *data = (char *)pdp_packet_data(x->x_packet0);
+ char cvalue;
+ unsigned int px,py;
int written, flength;
if ( !x->x_initialized )
@@ -218,6 +221,20 @@ static void pdp_vloopback_process_rgb(t_pdp_vloopback *x)
// output the image
flength = x->x_width*x->x_height*3;
+ // invert red and blue channels ( with webcamstudio module )
+ if ( x->x_invertrb )
+ {
+ for ( py=0; py<x->x_height; py++ )
+ {
+ for ( px=0; px<x->x_width; px++ )
+ {
+ cvalue=*(data+3*py*x->x_width+3*px);
+ *(data+3*py*x->x_width+3*px)=*(data+3*py*x->x_width+3*px+2);
+ *(data+3*py*x->x_width+3*px+2)=cvalue;
+ }
+ }
+ }
+
if ( ( written = write(x->x_vlfd, data, flength) ) != flength )
{
post( "pdp_vloopback : problem writing frame...closing" );
@@ -278,6 +295,14 @@ static void pdp_vloopback_input_0(t_pdp_vloopback *x, t_symbol *s, t_floatarg f)
}
}
+static void pdp_vloopback_invertrb(t_pdp_vloopback *x, t_floatarg finvert)
+{
+ if ( ((int)finvert == 0) || ((int)finvert == 1) )
+ {
+ x->x_invertrb = (int)finvert;
+ }
+}
+
static void pdp_vloopback_free(t_pdp_vloopback *x)
{
pdp_vloopback_close(x);
@@ -294,6 +319,7 @@ void *pdp_vloopback_new(t_symbol *vdev)
x->x_initialized = false;
x->x_nbframes = 0;
+ x->x_invertrb = 1;
x->x_packet0 = -1;
x->x_packet1 = -1;
@@ -330,6 +356,7 @@ void pdp_vloopback_setup(void)
class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_close, gensym("close"), A_NULL);
class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_open, gensym("open"), A_SYMBOL, A_NULL);
class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL);
+ class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_invertrb, gensym("invert"), A_DEFFLOAT, A_NULL);
}