Forums > Jitter

Increasing the performance of a videoplane patch

May 18, 2006 | 4:30 pm

hi there,
I wrote a little patch to play two 1024 x 768px footages, and blend the edges between them (to use two projectors). I use 4 jit.gl.videoplanes. Two for the movies and two for blending alpha values that I generate with adjustable greyscale matrixes. (I draw one video and one blending videoplane on each of the two jit.window objects.) As I am not that much experienced with OpenGL, I would like to know if there is a faster way to achive my goal. I am working pretty much on the edge of my hardware power, so I wouldn’t mind increasing the performance speed a bit.
As I am always filling the hole videoplane and window, does it make any sense to send an ‘erase’ message before every new frame to the jit.gl.render objects?
It would be great to get some comments on the patch how to improve it. (you don’t have to tell me about the movie encoding, I am just intersted in possibilities to boost the speed within the patch.)

thanks a lot

.tom

max v2;
#N vpatcher 89 740 1189 1400;
#P origin -87 -95;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 280 226 87 9109513 pak scale 1. 1. 1.;
#P newex 250 173 34 9109513 * -1.;
#P newex 31 279 112 9109513 jit.op @op !- @val 255;
#P message 164 113 23 9109513 2.2;
#P message 138 113 23 9109513 1.8;
#P flonum 100 113 35 9 1. 3. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 76 90 15 0;
#P message 204 52 26 9109513 512;
#P message 41 51 14 9109513 2;
#P newex 21 22 48 9109513 loadbang;
#P toggle 657 58 15 0;
#P newex 401 228 87 9109513 pak scale 1. 1. 1.;
#P newex 493 228 87 9109513 pak scale 1. 1. 1.;
#P button 579 58 15 0;
#P comment 528 41 30 9109513 STOP;
#P button 536 58 15 0;
#P window linecount 2;
#P comment 419 29 55 9109513 GetDim / SetAspect;
#P button 429 58 15 0;
#P window linecount 1;
#P comment 332 41 85 9109513 read MOVIE Right;
#N vpatcher 304 861 1252 1291;
#P inlet 754 35 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 709 83 76 9109513 clocker 10000;
#P message 301 160 45 9109513 time $1;
#P newex 301 138 38 9109513 r time;
#P newex 645 257 38 9109513 s time;
#P newex 645 234 57 9109513 route time;
#P message 685 109 44 9109513 gettime;
#P inlet 685 35 15 0;
#P outlet 580 365 15 0;
#P comment 582 35 100 9109513 STOP both Movies;
#P inlet 564 35 15 0;
#P inlet 441 35 15 0;
#P comment 334 36 100 9109513 GetDimension;
#P inlet 315 35 15 0;
#P inlet 187 36 15 0;
#P comment 205 36 100 9109513 read MovieRIGHT;
#P inlet 66 37 15 0;
#P outlet 62 364 15 0;
#P outlet 405 365 15 0;
#P outlet 426 365 15 0;
#P outlet 208 365 15 0;
#P comment 246 343 66 9109513 Aspect Ratio;
#P newex 63 161 51 9109513 r movie1;
#P comment 405 147 100 9109513 Movie Right;
#P newex 575 233 62 9109513 print RIGHT;
#P flonum 426 341 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 426 313 27 9109513 / 1.;
#P number 470 291 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 426 291 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 426 263 54 9109513 unpack 1 1;
#P newex 425 243 87 9109513 route moviedim;
#P message 567 163 62 9109513 getmoviedim;
#P newex 405 162 51 9109513 r movie1;
#P message 468 163 28 9109513 read;
#P message 536 163 27 9109513 stop;
#P message 504 163 31 9109513 start;
#P window linecount 2;
#P newex 405 190 230 9109513 jit.qt.movie 1024 768 @colormode uyvy @autostart 0;
#P user panel 398 144 241 85;
#X brgb 255 255 127;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P comment 61 145 100 9109513 Movie Left;
#P newex 89 235 56 9109513 print LEFT;
#P flonum 208 342 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 208 314 27 9109513 / 1.;
#P number 252 292 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 208 292 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 208 263 54 9109513 unpack 1 1;
#P newex 207 243 87 9109513 route moviedim;
#P message 223 161 62 9109513 getmoviedim;
#P message 124 161 28 9109513 read;
#P message 192 161 27 9109513 stop;
#P message 160 161 31 9109513 start;
#P window linecount 2;
#P newex 62 189 228 9109513 jit.qt.movie 1024 768 @colormode uyvy @autostart 0;
#P user panel 54 142 241 85;
#X brgb 255 255 127;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P comment 463 342 66 9109513 Aspect Ratio;
#P comment 84 37 100 9109513 read MovieLEFT;
#P comment 458 36 100 9109513 START both Movies;
#P comment 598 365 100 9109513 Y Dimension;
#P comment 703 35 43 9109513 Frame 0;
#P window linecount 2;
#P comment 774 35 100 9109513 Automatic Sync On/Off;
#P fasten 55 0 7 0 306 182 67 182;
#P fasten 11 0 7 0 228 182 67 182;
#P fasten 9 0 7 0 197 182 67 182;
#P fasten 8 0 7 0 165 182 67 182;
#P fasten 10 0 7 0 129 182 67 182;
#P connect 35 0 7 0;
#P connect 7 0 40 0;
#P fasten 7 1 18 0 285 228 94 228;
#P fasten 41 0 10 0 71 106 129 106;
#P fasten 46 0 8 0 446 84 165 84;
#P fasten 47 0 9 0 569 91 197 91;
#P fasten 7 1 12 0 285 222 212 222;
#P connect 12 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 37 0;
#P fasten 44 0 11 0 320 105 228 105;
#P fasten 15 0 16 1 257 310 230 310;
#P connect 13 1 15 0;
#P connect 54 0 55 0;
#P fasten 51 0 21 0 690 131 410 131;
#P fasten 26 0 21 0 572 184 410 184;
#P fasten 23 0 21 0 541 184 410 184;
#P fasten 22 0 21 0 509 184 410 184;
#P fasten 24 0 21 0 473 184 410 184;
#P fasten 25 0 21 0 410 184 410 184;
#P connect 21 0 39 0;
#P fasten 21 1 27 0 630 224 430 224;
#P connect 27 0 28 0;
#P connect 28 0 29 0;
#P connect 29 0 31 0;
#P connect 31 0 32 0;
#P connect 32 0 38 0;
#P fasten 30 0 31 1 475 309 448 309;
#P fasten 43 0 24 0 192 121 473 121;
#P connect 28 1 30 0;
#P fasten 46 0 22 0 446 84 509 84;
#P fasten 47 0 23 0 569 91 541 91;
#P fasten 44 0 26 0 320 105 572 105;
#P fasten 21 1 33 0 630 231 580 231;
#P fasten 15 0 49 0 257 336 585 336;
#P connect 21 1 52 0;
#P connect 52 0 53 0;
#P fasten 56 0 51 0 714 104 690 104;
#P fasten 50 0 51 0 690 53 690 53;
#P fasten 57 0 56 0 759 66 714 66;
#P pop;
#P newobj 364 104 66 9109513 p MovieLoad;
#P newex 238 336 34 9109513 * -1.;
#P newex 194 420 60 9109513 r edgeright;
#P newex 916 309 60 9109513 s edgeright;
#P newex 181 369 95 9109513 pak position 0. 0. 0.;
#P window linecount 3;
#P newex 181 452 145 9109513 jit.gl.videoplane tom2 @blend_enable 1 @depth_enable 0 @automatic 0;
#P button 487 58 15 0;
#P button 368 58 15 0;
#P button 308 58 15 0;
#P window linecount 1;
#P newex 540 420 63 9109513 r planeright;
#P newex 942 269 63 9109513 s planeright;
#P newex 22 420 54 9109513 r edgeleft;
#P newex 371 419 57 9109513 r planeleft;
#P toggle 884 405 15 0;
#P message 884 423 66 9109513 floating $1;
#P window linecount 3;
#P newex 517 452 180 9109513 jit.gl.videoplane tom2 @colormode uyvy @blend_enable 1 @depth_enable 0 @automatic 0;
#P window linecount 2;
#P newex 884 461 170 9109513 jit.window tom2 @border 1 @pos 650 260 @size 1024 768 @sync 0;
#P button 21 115 15 0;
#P flonum 41 114 35 9 0. 5. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user jit.pwindow 83 198 102 12 0 0 0 0 1 0;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 31 165 153 9240586 jit.matrix 1 char 100 1 @interp 1;
#B color 5;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 206 772 806 1172;
#P inlet 310 80 15 0;
#P inlet 237 81 15 0;
#P outlet 166 291 15 0;
#P inlet 190 82 15 0;
#P window setfont "Sans Serif" 9.;
#P flonum 190 116 35 9 0. 5. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Proportional Serif" 10.;
#P comment 181 138 20 9175050 fill;
#P window setfont "Fixedwidth Serif" 10.;
#N vpatcher 1047 130 1722 772;
#P origin 0 -6;
#P window setfont "Sans Serif" 9.;
#P flonum 377 403 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 367 341 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 0;
#P newex 363 365 30 9109513 !- 1.;
#P newex 106 233 30 9109513 !- 1.;
#P inlet 519 26 15 0;
#P inlet 405 26 15 0;
#P user gswitch2 77 255 39 32 0 0;
#P message 216 303 23 9109513 2.2;
#P message 243 303 23 9109513 1.8;
#P flonum 271 303 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 159 383 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 159 348 122 9109513 expr pow($f1\,(1/$f2));
#P inlet 257 26 15 0;
#P flonum 257 53 35 9 0. 4. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 2;
#P newex 22 395 33 9109513 * 255.;
#P newex 188 152 32 9109513 / 100.;
#P window setfont "Fixedwidth Serif" 10.;
#P window linecount 1;
#P newex 188 113 38 9240586 + 49.;
#P window setfont "Sans Serif" 9.;
#P newex 123 81 40 9109513 uzi 50;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 188 196 200 9240586 expr 1-(0.5*pow(2*(1-$f1)\,$f2));
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P newex 21 148 32 9109513 / 100.;
#N comlet (int) x location in matrix;
#P outlet 391 198 15 0;
#P window setfont "Fixedwidth Serif" 10.;
#P window linecount 1;
#P newex 21 197 164 9240586 expr 0.5*(pow(2*$f1\,$f2));
#P newex 85 109 32 9240586 – 1.;
#P newex 106 52 44 9240586 Uzi 50;
#N comlet (int) value to put in matrix;
#P outlet 22 459 15 0;
#N comlet (bang) fill matrix;
#P inlet 106 21 15 0;
#P window setfont "Proportional Serif" 10.;
#P comment 121 21 116 9175050 bang to fill a 16×12 matrix;
#P window setfont "Sans Serif" 9.;
#P comment 235 384 87 9109513 gamma correction;
#P user panel 147 283 185 137;
#X brgb 224 232 0;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 2;
#P comment 423 26 89 9109513 Gamma Correction On/ Off;
#P window linecount 1;
#P comment 414 198 60 9109513 X Value Out;
#P comment 536 26 66 9109513 Gamma Value;
#P fasten 9 0 12 0 90 136 26 136;
#P fasten 12 0 10 0 26 182 26 182;
#P fasten 20 0 17 0 164 380 27 380;
#P fasten 25 0 17 0 82 341 27 341;
#P connect 17 0 7 0;
#P fasten 26 0 25 0 410 228 82 228;
#P fasten 8 2 9 0 145 80 90 80;
#P connect 6 0 8 0;
#P fasten 10 0 28 0 26 222 111 222;
#P fasten 13 0 28 0 193 222 111 222;
#P fasten 28 0 25 1 111 252 111 252;
#P connect 8 1 14 0;
#P fasten 25 1 20 0 111 317 164 317;
#P connect 20 0 21 0;
#P fasten 18 0 10 1 262 100 180 100;
#P fasten 14 2 15 0 158 106 193 106;
#P connect 15 0 16 0;
#P connect 16 0 13 0;
#P connect 19 0 18 0;
#P fasten 27 0 22 0 524 272 276 272;
#P fasten 22 0 20 1 276 333 276 333;
#P fasten 23 0 20 1 248 333 276 333;
#P fasten 24 0 20 1 221 333 276 333;
#P connect 30 0 29 0;
#P connect 29 0 31 0;
#P fasten 18 0 13 1 262 100 383 100;
#P fasten 9 0 11 0 90 182 396 182;
#P fasten 15 0 11 0 193 149 396 149;
#P pop;
#P newobj 166 156 82 9240586 p fillmatrix;
#P button 166 138 15 0;
#P number 166 220 49 10 0 0 64 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 225 220 35 10 0 100 67 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 166 238 128 9240586 pack 0 0 0;
#P message 166 259 128 9240586 setcell $2 $3 val $1;
#P user panel 161 114 137 66;
#X brgb 255 255 127;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont "Sans Serif" 9.;
#P comment 170 64 44 9109513 gradient;
#P comment 221 64 70 9109513 gamma on/off;
#P comment 295 64 74 9109513 gamma amount;
#P fasten 11 0 8 0 195 135 171 135;
#P fasten 14 0 8 0 242 106 171 106;
#P connect 8 0 9 0;
#P connect 9 0 7 0;
#P connect 7 0 5 0;
#P connect 5 0 4 0;
#P fasten 4 0 13 0 171 283 171 283;
#P connect 12 0 11 0;
#P fasten 11 0 9 1 195 144 195 144;
#P fasten 14 0 9 2 242 135 219 135;
#P fasten 9 1 6 0 243 197 230 197;
#P connect 6 0 5 1;
#P fasten 15 0 9 3 315 143 243 143;
#P pop;
#P newobj 41 139 63 9109513 p gradient;
#P toggle 807 405 15 0;
#P message 807 423 66 9109513 floating $1;
#P number 204 107 35 9 0 1024 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 204 149 40 9109513 / 768.;
#P newex 228 269 60 9109513 !- 1.17647;
#P flonum 204 174 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 192 227 85 9109513 pak scale 1. 1. 1.;
#P flonum 228 307 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 80 372 95 9109513 pak position 0. 0. 0.;
#P newex 929 289 54 9109513 s edgeleft;
#P newex 955 249 57 9109513 s planeleft;
#P newex 968 227 51 9109513 s movie1;
#P window linecount 3;
#P newex 9 452 158 9109513 jit.gl.videoplane tom1 @blend_enable 1 @depth_enable 0 @automatic 0;
#P window linecount 1;
#P newex 31 306 53 9109513 jit.pack;
#P window linecount 3;
#P newex 355 452 157 9109513 jit.gl.videoplane tom1 @colormode uyvy @blend_enable 1 @depth_enable 0 @automatic 0;
#P user jit.fpsgui 988 297 60 9109513 0;
#P number 935 149 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 890 148 15 0;
#P window linecount 1;
#P newex 890 174 55 9109513 qmetro 20;
#P newex 890 196 105 9109513 t b b b b b b b b;
#P newex 903 329 143 9109513 jit.gl.render tom1 @ortho 2;
#P window linecount 2;
#P newex 713 462 163 9109513 jit.window tom1 @border 1 @pos 10 50 @size 1024 768 @sync 0;
#P window linecount 3;
#P comment 240 94 46 9109513 amount blending frames;
#P window linecount 1;
#P newex 890 350 135 9109513 jit.gl.render tom2 @ortho 2;
#P comment 245 41 78 9109513 read MOVIE Left;
#P comment 477 41 36 9109513 START;
#P user panel 880 138 180 247;
#X brgb 1 247 103;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 708 390 353 108;
#X brgb 166 0 0;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 5 408 698 90;
#X brgb 1 197 50;
#X frgb 76 255 74;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 610 42 116 9109513 Automatic Sync On/Off;
#P comment 572 41 33 9109513 Sync;
#P user panel 296 55 392 69;
#X brgb 125 173 255;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 59 74 74 9109513 Gamma On/Off;
#P comment 96 93 74 9109513 Gamma amount;
#P user panel 17 69 174 145;
#X brgb 197 193 1;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P fasten 21 0 22 0 36 328 14 328;
#P fasten 28 0 22 0 197 274 14 274;
#P fasten 45 0 22 0 27 444 14 444;
#P fasten 26 0 22 0 85 415 14 415;
#P fasten 66 0 39 0 26 95 26 95;
#P fasten 35 0 36 0 46 159 36 159;
#P fasten 39 0 36 0 26 158 36 158;
#P fasten 36 0 73 0 36 225 36 225;
#P connect 73 0 21 0;
#P fasten 66 0 67 0 26 44 46 44;
#P connect 67 0 38 0;
#P fasten 38 0 35 0 46 133 46 133;
#P fasten 69 0 35 1 81 132 72 132;
#P fasten 36 0 37 0 36 197 89 197;
#P fasten 70 0 35 2 105 132 98 132;
#P fasten 71 0 35 2 143 133 98 133;
#P fasten 72 0 35 2 169 133 98 133;
#P fasten 66 0 70 0 26 50 105 50;
#P fasten 27 0 26 1 233 354 113 354;
#P fasten 21 0 51 0 36 438 186 438;
#P fasten 52 0 51 0 186 427 186 427;
#P fasten 54 0 51 0 199 444 186 444;
#P fasten 75 0 51 0 285 295 186 295;
#P fasten 66 0 68 0 26 44 209 44;
#P connect 68 0 32 0;
#P connect 32 0 31 0;
#P connect 31 0 29 0;
#P fasten 55 0 52 1 243 362 214 362;
#P fasten 29 0 28 1 209 209 222 209;
#P fasten 29 0 30 0 209 229 233 229;
#P connect 30 0 27 0;
#P fasten 56 4 31 1 425 134 239 134;
#P fasten 30 0 55 0 233 295 243 295;
#P fasten 31 0 74 0 209 170 255 170;
#P fasten 56 1 30 1 383 251 283 251;
#P fasten 74 0 75 1 255 208 310 208;
#P fasten 44 0 20 0 376 444 360 444;
#P fasten 64 0 20 0 406 344 360 344;
#P fasten 56 0 20 0 369 286 360 286;
#P fasten 48 0 56 0 313 88 369 88;
#P fasten 49 0 56 1 373 88 378 88;
#P fasten 58 0 56 2 434 88 387 88;
#P fasten 50 0 56 3 492 88 396 88;
#P fasten 60 0 56 4 541 88 405 88;
#P fasten 62 0 56 5 584 88 414 88;
#P fasten 65 0 56 6 662 88 423 88;
#P fasten 56 1 64 1 383 171 431 171;
#P fasten 47 0 41 0 545 444 522 444;
#P fasten 63 0 41 0 498 344 522 344;
#P fasten 56 2 41 0 397 287 522 287;
#P fasten 56 3 63 1 411 174 523 174;
#P fasten 33 0 13 0 812 450 718 450;
#P connect 34 0 33 0;
#P connect 43 0 42 0;
#P connect 42 0 40 0;
#P connect 17 0 16 0;
#P fasten 16 0 15 0 895 197 895 197;
#P connect 15 0 11 0;
#P fasten 15 1 14 0 908 332 908 332;
#P fasten 15 2 53 0 921 275 921 275;
#P fasten 15 3 25 0 934 261 934 261;
#P connect 18 0 16 1;
#P fasten 15 4 46 0 947 248 947 248;
#P fasten 15 5 24 0 960 237 960 237;
#P fasten 15 6 23 0 973 226 973 226;
#P fasten 15 7 19 0 986 295 993 295;
#P pop;


May 18, 2006 | 5:23 pm

Hi Tom,
It looks like your patch is pretty efficient as is. I do recommend
using an erase message to jit.gl.render before banging the other
objects. Most likely, it is an issue with reading the large movie files
from disk.

FWIW, it wouldn’t be difficult to write a custom shader that added a
linear gradient for the alpha channel, which would eliminate the need
for multiple videoplanes. In the next version of Jitter we will have a
couple of included shaders that will help with this sort of thing.

Also, I should note that the gradient can be generated by simply sending
a "exprfill norm[0]" message to the jit.matrix object. Not really a
performance issue, but certainly more compact.

Cheers,
Andrew B.


Viewing 2 posts - 1 through 2 (of 2 total)