aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN.N. <sevyves@users.sourceforge.net>2003-10-25 02:06:30 +0000
committerN.N. <sevyves@users.sourceforge.net>2003-10-25 02:06:30 +0000
commit2cd6e7055d448319b39d2619e4886089d4fe2794 (patch)
tree6b5c56d5c6394068d9899407b26c17b30029999f
parent32cf526237040a10eb5b2ccb8eb1f3026c7a7705 (diff)
Optimized pdp_canvas
svn path=/trunk/externals/pidip/; revision=1134
-rw-r--r--CHANGES.LOG1
-rw-r--r--doc/help-pdp_canvas.pd57
-rw-r--r--modules/pdp_canvas.c108
3 files changed, 82 insertions, 84 deletions
diff --git a/CHANGES.LOG b/CHANGES.LOG
index 5046876..89630c0 100644
--- a/CHANGES.LOG
+++ b/CHANGES.LOG
@@ -1,4 +1,5 @@
0.12.10
+ optimized pdp_canvas ( but overlapping has disappeared )
added pdp_fqt : fast quicktime reader ( frames are cached in memory and no audio decoding )
added pdp_fcqt : fast quicktime reader ( same as pdp_fqt but frames are compressed )
added help patches for pdp_yqt, pdp_fqt and pdp_fcqt
diff --git a/doc/help-pdp_canvas.pd b/doc/help-pdp_canvas.pd
index b351f10..900e8f2 100644
--- a/doc/help-pdp_canvas.pd
+++ b/doc/help-pdp_canvas.pd
@@ -3,7 +3,7 @@
#X obj 227 100 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
-1;
#X msg 123 139 loop \$1;
-#X obj 124 117 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1
+#X obj 124 117 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0
1;
#X msg 119 80 open \$1;
#X obj 118 56 openpanel;
@@ -31,7 +31,7 @@
#X obj 470 99 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
-1;
#X msg 366 138 loop \$1;
-#X obj 367 116 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1
+#X obj 367 116 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0
1;
#X msg 362 79 open \$1;
#X obj 361 55 openpanel;
@@ -47,7 +47,7 @@
#X obj 735 96 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1
-1;
#X msg 631 135 loop \$1;
-#X obj 632 113 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1
+#X obj 632 113 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0
1;
#X msg 627 76 open \$1;
#X obj 626 52 openpanel;
@@ -84,24 +84,19 @@
#X msg 83 393 dim 640 480;
#X obj 234 432 pdp_canvas 640 480 3;
#X obj 234 497 route press drag release;
-#X msg 546 428 average \$1;
-#X obj 629 429 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
-1;
-#X text 544 451 Average sources at intersections;
-#X text 544 463 ( default = 0 );
-#X obj 367 177 pdp_fqt;
-#X obj 121 177 pdp_fqt;
-#X obj 632 174 pdp_fqt;
#X obj 187 138 metro 40;
#X obj 431 137 metro 40;
+#X obj 121 177 pdp_yqt;
+#X obj 367 177 pdp_yqt;
+#X obj 632 174 pdp_yqt;
#X connect 0 0 69 0;
-#X connect 1 0 77 0;
-#X connect 2 0 75 0;
+#X connect 1 0 70 0;
+#X connect 2 0 72 0;
#X connect 3 0 2 0;
-#X connect 4 0 75 0;
+#X connect 4 0 72 0;
#X connect 5 0 4 0;
#X connect 6 0 5 0;
-#X connect 7 0 77 0;
+#X connect 7 0 70 0;
#X connect 8 0 64 0;
#X connect 9 0 8 0;
#X connect 10 0 9 0;
@@ -110,32 +105,32 @@
#X connect 13 0 16 0;
#X connect 14 0 13 0;
#X connect 16 0 15 0;
-#X connect 18 0 75 1;
-#X connect 22 0 78 0;
-#X connect 23 0 74 0;
+#X connect 18 0 72 1;
+#X connect 22 0 71 0;
+#X connect 23 0 73 0;
#X connect 24 0 23 0;
-#X connect 25 0 74 0;
+#X connect 25 0 73 0;
#X connect 26 0 25 0;
#X connect 27 0 26 0;
-#X connect 28 0 78 0;
+#X connect 28 0 71 0;
#X connect 29 0 65 0;
#X connect 30 0 29 0;
#X connect 31 0 30 0;
#X connect 32 0 30 0;
-#X connect 33 0 74 1;
+#X connect 33 0 73 1;
#X connect 34 0 41 0;
-#X connect 35 0 76 0;
+#X connect 35 0 74 0;
#X connect 36 0 35 0;
-#X connect 37 0 76 0;
+#X connect 37 0 74 0;
#X connect 38 0 37 0;
#X connect 39 0 38 0;
#X connect 40 0 41 0;
-#X connect 41 0 76 0;
+#X connect 41 0 74 0;
#X connect 42 0 66 0;
#X connect 43 0 42 0;
#X connect 44 0 43 0;
#X connect 45 0 43 0;
-#X connect 46 0 76 1;
+#X connect 46 0 74 1;
#X connect 50 0 56 0;
#X connect 51 0 50 0;
#X connect 52 0 53 0;
@@ -160,10 +155,8 @@
#X connect 69 0 58 0;
#X connect 69 1 59 0;
#X connect 69 2 60 0;
-#X connect 70 0 68 0;
-#X connect 71 0 70 0;
-#X connect 74 0 65 0;
-#X connect 75 0 64 0;
-#X connect 76 0 66 0;
-#X connect 77 0 75 0;
-#X connect 78 0 74 0;
+#X connect 70 0 72 0;
+#X connect 71 0 73 0;
+#X connect 72 0 64 0;
+#X connect 73 0 65 0;
+#X connect 74 0 66 0;
diff --git a/modules/pdp_canvas.c b/modules/pdp_canvas.c
index d86f57c..a099da1 100644
--- a/modules/pdp_canvas.c
+++ b/modules/pdp_canvas.c
@@ -46,8 +46,6 @@ typedef struct pdp_canvas_struct
t_float x_xmouse;
t_float x_ymouse;
- t_int x_average;
-
t_int *x_packets;
t_int *x_widths;
t_int *x_heights;
@@ -66,11 +64,12 @@ static void pdp_canvas_process_yv12(t_pdp_canvas *x)
{
t_int px, py, ppx, ppy, ii, nbs;
short int *pY, *pU, *pV;
- short int *piY, *piU, *piV;
+ short int *ppY, *ppU, *ppV;
t_pdp *oheader;
- short int *odata;
+ short int *odata, *pdata;
t_pdp *iheader;
short int *idata;
+ t_int mx, dx, my, dy;
x->x_opacket = pdp_packet_new_image_YCrCb( x->x_owidth, x->x_oheight );
oheader = pdp_packet_header(x->x_opacket);
@@ -85,46 +84,61 @@ static void pdp_canvas_process_yv12(t_pdp_canvas *x)
pY = odata;
pV = odata+x->x_osize;
pU = odata+x->x_osize+(x->x_osize>>2);
- for ( py=0; py<x->x_oheight; py++ )
+ for ( ii=0; ii<x->x_nbinputs; ii++)
{
- for ( px=0; px<x->x_owidth; px++ )
+ if ( x->x_packets[ii] != -1 )
{
- nbs=0;
- for ( ii=0; ii<x->x_nbinputs; ii++)
- {
- if ( x->x_packets[ii] != -1 )
- {
- if ( (px >= (int)x->x_xoffsets[ii]) && ( px < (int)x->x_xoffsets[ii] + x->x_widths[ii] )
- && (py >= (int)x->x_yoffsets[ii]) && ( py < (int)x->x_yoffsets[ii] + x->x_heights[ii] )
- )
- {
- nbs++;
- idata = (short int *)pdp_packet_data(x->x_packets[ii]);
- piY = idata;
- piV = idata+x->x_sizes[ii];
- piU = idata+x->x_sizes[ii]+(x->x_sizes[ii]>>2);
- ppx = px-(int)x->x_xoffsets[ii];
- ppy = py-(int)x->x_yoffsets[ii];
- *(pY+py*x->x_owidth+px) += *(piY+ppy*x->x_widths[ii]+ppx);
- if ( (px%2==0) && (py%2==0) )
- {
- *(pU+(py>>1)*(x->x_owidth>>1)+(px>>1)) +=
- *(piU+(ppy>>1)*(x->x_widths[ii]>>1)+(ppx>>1));
- *(pV+(py>>1)*(x->x_owidth>>1)+(px>>1)) +=
- *(piV+(ppy>>1)*(x->x_widths[ii]>>1)+(ppx>>1));
- }
- }
- }
- }
- if ( ( nbs != 0 ) && x->x_average )
- {
- *(pY+py*x->x_owidth+px) /= nbs;
- if ( (px%2==0) && (py%2==0) )
- {
- *(pU+(py>>1)*(x->x_owidth>>1)+(px>>1)) /= nbs;
- *(pV+(py>>1)*(x->x_owidth>>1)+(px>>1)) /= nbs;
- }
- }
+ if ( x->x_xoffsets[ii] < -x->x_widths[ii] ) continue;
+ if ( x->x_xoffsets[ii] > x->x_owidth ) continue;
+ if ( x->x_yoffsets[ii] < -x->x_heights[ii] ) continue;
+ if ( x->x_yoffsets[ii] > x->x_oheight ) continue;
+
+ pdata = (short int *)pdp_packet_data(x->x_packets[ii]);
+ ppY = pdata;
+ ppV = pdata+x->x_sizes[ii];
+ ppU = pdata+x->x_sizes[ii]+(x->x_sizes[ii]>>2);
+
+ if ( x->x_xoffsets[ii] < 0 )
+ {
+ mx = -x->x_xoffsets[ii];
+ dx = x->x_widths[ii]+x->x_xoffsets[ii];
+ }
+ else if ( x->x_xoffsets[ii] > x->x_owidth - x->x_widths[ii] )
+ {
+ mx = 0;
+ dx = x->x_owidth-x->x_xoffsets[ii];
+ }
+ else
+ {
+ mx = 0;
+ dx = x->x_widths[ii];
+ }
+
+ if ( x->x_yoffsets[ii] < 0 )
+ {
+ my = -x->x_yoffsets[ii];
+ dy = x->x_heights[ii]+x->x_yoffsets[ii];
+ }
+ else if ( x->x_yoffsets[ii] > x->x_oheight - x->x_heights[ii] )
+ {
+ my = 0;
+ dy = x->x_oheight-x->x_yoffsets[ii];
+ }
+ else
+ {
+ my = 0;
+ dy = x->x_heights[ii];
+ }
+
+ for ( py=x->x_yoffsets[ii]+my; py<x->x_yoffsets[ii]+dy; py++)
+ {
+ memcpy( pY+(py*x->x_owidth)+(t_int)x->x_xoffsets[ii]+mx,
+ ppY+(py-(t_int)x->x_yoffsets[ii])*x->x_widths[ii]+mx, dx*sizeof(short int) );
+ memcpy( pU+((py>>1)*(x->x_owidth>>1))+((t_int)(x->x_xoffsets[ii]+mx)>>1),
+ ppU+((py-(t_int)x->x_yoffsets[ii])>>1)*(x->x_widths[ii]>>1)+(mx>>1), dx );
+ memcpy( pV+((py>>1)*(x->x_owidth>>1))+((t_int)(x->x_xoffsets[ii]+mx)>>1),
+ ppV+((py-(t_int)x->x_yoffsets[ii])>>1)*(x->x_widths[ii]>>1)+(mx>>1), dx );
+ }
}
}
@@ -218,14 +232,6 @@ static void pdp_canvas_unselect(t_pdp_canvas *x)
x->x_current = -1;
}
-static void pdp_canvas_average(t_pdp_canvas *x, t_floatarg bvalue)
-{
- if ( ( bvalue == 0.0 ) || ( bvalue == 1.0 ) )
- {
- x->x_average = (int) bvalue;
- }
-}
-
static void pdp_canvas_input(t_pdp_canvas *x, t_symbol *s, t_floatarg f, t_int ni)
{
t_pdp *header;
@@ -393,7 +399,6 @@ void *pdp_canvas_new(t_symbol *s, int argc, t_atom *argv)
x->x_yoffsets[ii] = 0.;
}
x->x_current = -1;
- x->x_average = 0;
x->x_outlet0 = outlet_new(&x->x_obj, &s_anything);
return (void *)x;
@@ -429,7 +434,6 @@ void pdp_canvas_setup(void)
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_select, gensym("select"), A_DEFFLOAT, A_DEFFLOAT, A_NULL);
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_drag, gensym("drag"), A_DEFFLOAT, A_DEFFLOAT, A_NULL);
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_unselect, gensym("unselect"), A_NULL);
- class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_average, gensym("average"), A_DEFFLOAT, A_NULL);
}