jit.brcosa with colormode uyvy

May 25, 2006 at 6:32pm

jit.brcosa with colormode uyvy

Hi list,

I want to use jit.brcosa with colormode uyvy, however when I use that
colormode I loose a intuitive use of jit.brcosa, Is there another way
to achieve brightness contrast and saturation adjustments besides
doing it in argb mode?

Thanks,

Maarten

#26155
May 25, 2006 at 6:57pm

Have you taken a look at the stuff on color tinting
and saturation in Tutorial 49? At the very least,
it’s quite a good description of what you’re actually
*doing* in the other colorspace (besides trying to
increase performance :-) ).

#77775
May 25, 2006 at 7:01pm

On May 25, 2006, at 11:32 AM, Maarten Zeinstra wrote:

> I want to use jit.brcosa with colormode uyvy, however when I use that
> colormode I loose a intuitive use of jit.brcosa, Is there another way
> to achieve brightness contrast and saturation adjustments besides
> doing it in argb mode?

jit.brcosa is ARGB specific. We do not provide UYVY objects for the
CPU, as we use it primarily as a mechanism for fast transfer to the
GPU (where more significant video processing performance boosts
occur). You can of course do this processing with generic math
objects on the CPU if you desire to. Or perform these operations on
the GPU with jit.gl.slab.

On the CPU, for fastest processing in this fashion on UYVY data, I
might suggest jit.charmap. Brightness + contrast as a linear ramp
applied to the two YY planes, and saturation as a linear ramp applied
to the U and V planes. A two minute hack from jit.charmap.help which
illustrates the concept is below. For more information. I would
suggest reading the colorspace tutorial, and checking out jitter-
examples/video/uyvy/, and reading online literature on the YUV
colorspace.

For most spatial operations (such as rotation, or convolution) on the
chroma reduced UYVY data, you typically want to move to a full chroma
format such as AYUV or ARGB before applying them.

-Joshua

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 165 247 80 196617 read dozer.mov;
#P toggle 122 173 15 0;
#P newex 122 216 51 196617 qmetro 2;
#P window linecount 2;
#P comment 497 49 100 196617 saturation+hue adjust;
#P window linecount 1;
#P newex 420 243 77 196617 jit.fill lookup 3;
#P newex 577 243 77 196617 jit.fill lookup 2;
#P comment 622 41 139 196617 linear (restore original map);
#P hidden message 622 41 14 196617 0;
#P button 602 40 15 0;
#N vpatcher 50 40 450 340;
#P window setfont “Sans Serif” 9.;
#P newex 71 121 20 196617 t b;
#P newex 71 70 21 196617 t 1;
#P newex 71 94 55 196617 bondo 2 20;
#P outlet 71 147 15 0;
#P inlet 71 51 15 0;
#P connect 0 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 1 0;
#P pop;
#P newobj 288 266 41 196617 p group;
#P button 602 62 15 0;
#P hidden message 665 44 14 196617 1;
#P flonum 622 62 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 664 62 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 663 28 45 196617 loadbang;
#P flonum 618 85 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 573 85 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 437 38 875 430;
#P window setfont “Sans Serif” 9.;
#P newex 141 167 27 196617 – 1;
#P newex 141 271 39 196617 * 255.;
#P button 56 62 15 0;
#P newex 56 81 62 196617 speedlim 30;
#P newex 223 171 85 196617 expr ($f1-1.)/2.;
#P newex 141 249 27 196617 – 0.;
#P newex 141 229 27 196617 * 1.;
#P newex 141 208 27 196617 + 0.;
#P newex 141 188 38 196617 / 255.;
#P newex 89 312 63 196617 pack set 0 0;
#P newex 141 291 60 196617 clip 0. 255.;
#P newex 89 127 62 196617 t b i i;
#P outlet 89 338 15 0;
#P newex 57 101 43 196617 Uzi 256;
#P inlet 223 46 15 0;
#P inlet 107 46 15 0;
#P connect 1 0 13 0;
#P connect 0 0 13 0;
#P connect 13 0 12 0;
#P connect 12 0 2 0;
#P connect 2 2 4 0;
#P connect 4 0 6 0;
#P fasten 2 1 3 0 78 334 94 334;
#P connect 6 0 3 0;
#P connect 4 1 6 1;
#P connect 4 2 15 0;
#P connect 15 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 14 0;
#P connect 14 0 5 0;
#P connect 5 0 6 2;
#P connect 0 0 8 1;
#P connect 1 0 9 1;
#P connect 11 0 10 1;
#P connect 1 0 11 0;
#P pop;
#P newobj 573 105 55 196617 p brco;
#P flonum 461 85 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 416 85 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 437 38 875 430;
#P window setfont “Sans Serif” 9.;
#P newex 141 167 27 196617 – 1;
#P newex 141 271 39 196617 * 255.;
#P button 56 62 15 0;
#P newex 56 81 62 196617 speedlim 30;
#P newex 223 171 85 196617 expr ($f1-1.)/2.;
#P newex 141 249 27 196617 – 0.;
#P newex 141 229 27 196617 * 1.;
#P newex 141 208 27 196617 + 0.;
#P newex 141 188 38 196617 / 255.;
#P newex 89 312 63 196617 pack set 0 0;
#P newex 141 291 60 196617 clip 0. 255.;
#P newex 89 127 62 196617 t b i i;
#P outlet 89 338 15 0;
#P newex 57 101 43 196617 Uzi 256;
#P inlet 223 46 15 0;
#P inlet 107 46 15 0;
#P connect 1 0 13 0;
#P connect 0 0 13 0;
#P connect 13 0 12 0;
#P connect 12 0 2 0;
#P connect 2 2 4 0;
#P connect 4 0 6 0;
#P fasten 2 1 3 0 78 334 94 334;
#P connect 6 0 3 0;
#P connect 4 1 6 1;
#P connect 4 2 15 0;
#P connect 15 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 14 0;
#P connect 14 0 5 0;
#P connect 5 0 6 2;
#P connect 0 0 8 1;
#P connect 1 0 9 1;
#P connect 11 0 10 1;
#P connect 1 0 11 0;
#P pop;
#P newobj 416 105 55 196617 p brco;
#P newex 342 243 77 196617 jit.fill lookup 1;
#P button 499 85 15 0;
#N vpatcher 50 40 720 575;
#P window setfont “Sans Serif” 9.;
#P message 386 337 14 196617 2;
#P button 431 315 15 0;
#P button 548 291 15 0;
#P newex 356 336 27 196617 + 2;
#P newex 256 299 27 196617 t b i;
#P newex 170 300 27 196617 t b i;
#P newex 87 300 27 196617 t b i;
#P newex 363 370 63 196617 pack set 0 0;
#P newex 172 129 40 196617 t b b b;
#P inlet 172 76 15 0;
#P inlet 415 102 15 0;
#P newex 240 128 40 196617 t b b b;
#P newex 395 232 170 196617 t b b b;
#P newex 496 310 91 196617 + 0.;
#P newex 415 334 91 196617 + 0.;
#P newex 577 265 27 196617 / 3.;
#P newex 496 265 27 196617 / 3.;
#P newex 415 265 27 196617 / 3.;
#P newex 577 289 38 196617 float 0;
#P newex 496 289 38 196617 float 0;
#P newex 415 289 38 196617 float 0;
#P message 440 180 31 196617 set 0;
#P newex 415 203 173 196617 cycle 3;
#P outlet 167 451 15 0;
#P newex 94 192 27 196617 + 3;
#P message 124 194 31 196617 set 0;
#P newex 172 101 146 196617 t b b b;
#P message 308 299 14 196617 3;
#P message 238 298 14 196617 2;
#P message 155 298 14 196617 1;
#P newex 94 217 162 196617 cycle 3;
#P newex 249 326 63 196617 pack fetch 0;
#P newex 62 173 43 196617 Uzi 253;
#P newex 170 326 63 196617 pack fetch 0;
#P newex 87 326 63 196617 pack fetch 0;
#P connect 26 0 2 0;
#P connect 4 0 28 0;
#P connect 5 0 28 0;
#P connect 23 2 0 0;
#P connect 28 0 0 0;
#P connect 2 2 10 0;
#P connect 10 0 4 0;
#P fasten 9 0 4 0 129 213 99 213;
#P connect 26 2 9 0;
#P connect 28 1 0 1;
#P fasten 8 2 5 0 313 249 160 249;
#P connect 0 0 11 0;
#P connect 3 0 11 0;
#P connect 1 0 11 0;
#P connect 27 0 11 0;
#P fasten 2 1 11 0 83 449 172 449;
#P connect 4 1 29 0;
#P connect 6 0 29 0;
#P connect 23 1 1 0;
#P connect 29 0 1 0;
#P connect 25 0 8 0;
#P connect 8 0 26 0;
#P connect 29 1 1 1;
#P fasten 8 2 6 0 313 249 243 249;
#P connect 8 1 23 0;
#P connect 23 0 3 0;
#P connect 30 0 3 0;
#P connect 4 2 30 0;
#P connect 7 0 30 0;
#P connect 30 1 3 1;
#P connect 8 2 7 0;
#P connect 2 2 31 0;
#P fasten 2 0 27 0 67 292 368 292;
#P connect 26 1 27 0;
#P connect 8 2 34 0;
#P connect 31 0 27 1;
#P connect 34 0 27 1;
#P connect 26 2 22 0;
#P connect 24 0 12 0;
#P fasten 13 0 12 0 445 199 420 199;
#P connect 12 0 17 0;
#P connect 17 0 14 0;
#P connect 22 0 14 0;
#P connect 14 0 20 0;
#P connect 33 0 20 0;
#P connect 20 0 27 2;
#P connect 21 0 33 0;
#P connect 8 2 13 0;
#P connect 12 1 18 0;
#P connect 18 0 15 0;
#P connect 22 1 15 0;
#P connect 15 0 21 0;
#P connect 32 0 21 0;
#P connect 21 0 20 1;
#P connect 16 0 32 0;
#P connect 12 2 19 0;
#P connect 19 0 16 0;
#P connect 22 2 16 0;
#P connect 16 0 21 1;
#P pop;
#P newobj 499 105 48 196617 p smooth;
#P button 342 85 15 0;
#N vpatcher 50 40 720 575;
#P window setfont “Sans Serif” 9.;
#P message 386 337 14 196617 2;
#P button 431 315 15 0;
#P button 548 291 15 0;
#P newex 356 336 27 196617 + 2;
#P newex 256 299 27 196617 t b i;
#P newex 170 300 27 196617 t b i;
#P newex 87 300 27 196617 t b i;
#P newex 363 370 63 196617 pack set 0 0;
#P newex 172 129 40 196617 t b b b;
#P inlet 172 76 15 0;
#P inlet 415 102 15 0;
#P newex 240 128 40 196617 t b b b;
#P newex 395 232 170 196617 t b b b;
#P newex 496 310 91 196617 + 0.;
#P newex 415 334 91 196617 + 0.;
#P newex 577 265 27 196617 / 3.;
#P newex 496 265 27 196617 / 3.;
#P newex 415 265 27 196617 / 3.;
#P newex 577 289 38 196617 float 0;
#P newex 496 289 38 196617 float 0;
#P newex 415 289 38 196617 float 0;
#P message 440 180 31 196617 set 0;
#P newex 415 203 173 196617 cycle 3;
#P outlet 167 451 15 0;
#P newex 94 192 27 196617 + 3;
#P message 124 194 31 196617 set 0;
#P newex 172 101 146 196617 t b b b;
#P message 308 299 14 196617 3;
#P message 238 298 14 196617 2;
#P message 155 298 14 196617 1;
#P newex 94 217 162 196617 cycle 3;
#P newex 249 326 63 196617 pack fetch 0;
#P newex 62 173 43 196617 Uzi 253;
#P newex 170 326 63 196617 pack fetch 0;
#P newex 87 326 63 196617 pack fetch 0;
#P connect 26 0 2 0;
#P connect 5 0 28 0;
#P connect 4 0 28 0;
#P connect 28 0 0 0;
#P connect 23 2 0 0;
#P connect 2 2 10 0;
#P fasten 9 0 4 0 129 213 99 213;
#P connect 10 0 4 0;
#P connect 26 2 9 0;
#P connect 28 1 0 1;
#P fasten 8 2 5 0 313 249 160 249;
#P fasten 2 1 11 0 83 449 172 449;
#P connect 27 0 11 0;
#P connect 1 0 11 0;
#P connect 3 0 11 0;
#P connect 0 0 11 0;
#P connect 6 0 29 0;
#P connect 4 1 29 0;
#P connect 29 0 1 0;
#P connect 23 1 1 0;
#P connect 25 0 8 0;
#P connect 8 0 26 0;
#P connect 29 1 1 1;
#P fasten 8 2 6 0 313 249 243 249;
#P connect 8 1 23 0;
#P connect 30 0 3 0;
#P connect 23 0 3 0;
#P connect 7 0 30 0;
#P connect 4 2 30 0;
#P connect 30 1 3 1;
#P connect 8 2 7 0;
#P connect 2 2 31 0;
#P connect 26 1 27 0;
#P fasten 2 0 27 0 67 292 368 292;
#P connect 8 2 34 0;
#P connect 34 0 27 1;
#P connect 31 0 27 1;
#P connect 26 2 22 0;
#P fasten 13 0 12 0 445 199 420 199;
#P connect 24 0 12 0;
#P connect 12 0 17 0;
#P connect 22 0 14 0;
#P connect 17 0 14 0;
#P connect 33 0 20 0;
#P connect 14 0 20 0;
#P connect 20 0 27 2;
#P connect 21 0 33 0;
#P connect 8 2 13 0;
#P connect 12 1 18 0;
#P connect 22 1 15 0;
#P connect 18 0 15 0;
#P connect 32 0 21 0;
#P connect 15 0 21 0;
#P connect 21 0 20 1;
#P connect 16 0 32 0;
#P connect 12 2 19 0;
#P connect 22 2 16 0;
#P connect 19 0 16 0;
#P connect 16 0 21 1;
#P pop;
#P newobj 342 105 48 196617 p smooth;
#P newex 499 243 77 196617 jit.fill lookup 0;
#P newex 288 288 135 196617 jit.matrix lookup 4 char 256;
#P user multiSlider 342 128 154 103 0. 255. 256 2921 47 0 0 2 0 0 1;
#M frgb 93 93 93;
#M brgb 194 194 194;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P user multiSlider 499 128 154 103 0. 255. 256 2921 47 0 0 2 0 0 1;
#M frgb 150 50 50;
#M brgb 250 150 150;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 122 331 62 196617 jit.charmap;
#P newex 122 395 141 196617 jit.window @colormode uyvy;
#P newex 122 274 146 196617 jit.qt.movie @colormode uyvy;
#P comment 340 50 100 196617 brightness/contrast;
#P connect 32 0 31 0;
#P connect 33 0 1 0;
#P connect 31 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P fasten 6 0 3 1 293 314 179 314;
#P fasten 12 0 24 0 347 263 293 263;
#P fasten 7 0 24 0 504 263 293 263;
#P fasten 29 0 24 0 425 263 293 263;
#P fasten 28 0 24 0 582 263 293 263;
#P connect 24 0 6 0;
#P fasten 23 0 9 0 607 81 347 81;
#P connect 9 0 8 0;
#P fasten 13 0 5 0 421 124 347 124;
#P connect 8 0 5 0;
#P fasten 5 0 12 0 347 237 347 237;
#P hidden connect 5 1 8 1;
#P fasten 21 0 14 0 627 81 421 81;
#P lcolor 8;
#P connect 14 0 13 0;
#P connect 5 0 29 0;
#P fasten 20 0 15 0 669 81 466 81;
#P lcolor 11;
#P connect 15 0 13 1;
#P fasten 23 0 11 0 607 81 504 81;
#P connect 11 0 10 0;
#P fasten 16 0 4 0 578 125 504 125;
#P connect 10 0 4 0;
#P fasten 4 0 7 0 504 237 504 237;
#P hidden connect 4 1 10 1;
#P fasten 21 0 17 0 627 81 578 81;
#P lcolor 8;
#P connect 17 0 16 0;
#P connect 4 0 28 0;
#P fasten 20 0 18 0 669 81 623 81;
#P lcolor 11;
#P connect 18 0 16 1;
#P hidden connect 25 0 26 0;
#P hidden connect 26 0 21 0;
#P hidden connect 22 0 20 0;
#P hidden connect 25 0 22 0;
#P hidden connect 19 0 22 0;
#P window clipboard copycount 34;

#77776
Mar 22, 2007 at 6:19pm

and for the sake of the archive, here’s a version that uses javascript to calculate the charmap clut….

//———–begin uyvy_brcosa.js

outlets=1;
var brcosa = new JitterMatrix(4,”char”,256,1);

function bcs(b,c,s){
var brcoramp = new Array();
var satramp = new Array();
var c_ = (c-1)/2;
var s_ = (s-1)/2;
for (i=0;i<256;i++){
var i_ = i/255;
var b_ = b+i_;
brcoramp[i]=Math.floor(255*((b_ * c) – c_));
satramp[i]=Math.floor(255*((i_ * s) – s_));
brcosa.setcell(i, 0, “plane”, 1, “val”,brcoramp[i]);
brcosa.setcell(i, 0, “plane”, 3, “val”,brcoramp[i]);
brcosa.setcell(i, 0, “plane”, 0, “val”,satramp[i]);
brcosa.setcell(i, 0, “plane”, 2, “val”,satramp[i]);
}
outlet(0,”jit_matrix”,brcosa.name);
}
//————–end uyvy_brcosa.js

#P window setfont Arial 9.;
#P window linecount 1;
#P newex 83 159 76 131137545 pak bcs 0. 1. 1.;
#P newex 82 182 83 131137545 js uyvy_brcosa.js;
#P message 56 97 80 131137545 read dozer.mov;
#P toggle 13 23 15 0;
#P newex 13 66 51 131137545 qmetro 2;
#P comment 307 100 21 131137545 sat;
#P comment 347 102 139 131137545 linear (restore original map);
#P hidden message 220 61 14 131137545 0;
#P button 331 101 15 0;
#P hidden message 239 59 14 131137545 1;
#P hidden newex 237 43 45 131137545 loadbang;
#P flonum 268 98 35 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 225 97 35 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 180 97 35 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 13 181 62 131137545 jit.charmap;
#P newex 13 245 141 131137545 jit.window @colormode uyvy;
#P newex 13 124 146 131137545 jit.qt.movie @colormode uyvy;
#P comment 172 82 100 131137545 brightness/contrast;
#P hidden connect 8 0 5 0;
#P hidden connect 8 0 6 0;
#P hidden connect 7 0 8 0;
#P hidden connect 9 0 10 0;
#P hidden connect 9 0 8 0;
#P hidden connect 10 0 4 0;
#P connect 6 0 17 3;
#P connect 5 0 17 2;
#P connect 4 0 17 1;
#P connect 17 0 16 0;
#P connect 16 0 3 1;
#P connect 3 0 2 0;
#P connect 1 0 3 0;
#P connect 15 0 1 0;
#P connect 13 0 1 0;
#P connect 14 0 13 0;
#P window clipboard copycount 18;

#77777
Mar 23, 2007 at 3:01pm

Hello, same problem,

Has someone a jxs file that process brcosa or any in uyvy mode ?
Theres’s noone in shaders folder, it seems out of my competence to write in glgs …
Is there a solution ?

Hey Sir pnyboer, do you think your uyvy_brcosa.js ‘less gluttonous than the .pat one ?

thanks.
Derrick

#77778
Mar 23, 2007 at 6:30pm

On Mar 23, 2007, at 8:01 AM, derrickgiscloux wrote:

> Has someone a jxs file that process brcosa or any in uyvy mode ?
> Theres’s noone in shaders folder, it seems out of my competence to
> write in glgs …
> Is there a solution ?

On the graphics card uyvy is converted to rgba, so there is no need,
unless you are trying to keep your data as uyvy somehow.

For the ambitious, one can masquerade uyvy data as rgba data, process
as such and return to the CPU in uyvy format. For the video to be
rendered to the screen with expected colors on the GPU you have to
perform the uyvy to rgba conversion at some point. Some potentially
useful and illustrative patches below:

- /jitter-examples/render/slab/jit.gl.slab-uyvy-gpu.pat
Perform your own uyvy to rgba conversion on the GPU (highly
recommended on Windows, and even recommended on Mac for color
correction and chroma smoothing which isn’t present in the Apple UYVY
texture implementation). If you don’t want to convert to RGBA for
whatever reason (though as mentioned you’ll need to if you want to
make visible on your monitor), you could eliminate the color
conversion portion of this shader and just exploit he brightness,
contrast, and saturation processing that this shader provides in the
UYVY data.

- /jitter-examples/render/slab/jit.gl.slab-uyvy-readback.pat
Perform your own rgba to uyvy conversion on the GPU, optionally for
readback. This can be useful for improving performance of data
readback patches, and other situations where you want to process the
data in the UYVY format on the GPU. Since OpenGL has no concept of
UYVY, you need to use a shader like this.

- /jitter-examples/render/slab/jit.gl.slab-grgb.pat
Similar to the above, but you can work with chroma reduced GRGB data
(green is the majority of luminosity, so this is the roughly RGB
colorspace equivalent of chroma reduced UYVY data).

Hope this at least gives you some starting points for your
investigations.

-Joshua

#77779

You must be logged in to reply to this topic.