On 2019-06-19 11:12, Carl Karsten wrote:
I'm stuck on what constant to use. framebuffer[i] = 0x80108010; /* black in YCbCr 4:2:2*/

Ah, magic constants.

That particular magic constant matches the YCBCR422_BLACK define in:

https://github.com/timvideos/HDMI2USB-litex-firmware/blob/eaab51fd65f2c7276c32e6973ca2c86beb188fb0/firmware/pattern.h#L6-L14

so at least the constant is consistent with the comment....

I'm trying to do this:
YCbCr (84, 130, 213) = debian red https://encycolorpedia.com/d70a53
hex: 54 82 d5

Debian red isn't exactly purple :-)

The pattern.h magic values (above) refer to:

https://github.com/timvideos/HDMI2USB-litex-firmware/blob/master/firmware/pattern.py

as how the values were calculated, and in particular:

https://github.com/timvideos/HDMI2USB-litex-firmware/blob/eaab51fd65f2c7276c32e6973ca2c86beb188fb0/firmware/pattern.py#L1-L12

seems to be the RGB -> Y Cb Cr -> packed Y Cb Cr calculations.

Hacking that script to put in the Debian Red RGB values, and some extra print statements gives:

-=- cut here -=-
ewen@ashram:~$ python3 /tmp/pattern.py
215 10 83 RGB is 79 129 224 Y Cb Cr is 814fe04f
ewen@ashram:~$
-=- cut here -=-

So in theory something like:

framebuffer[i] = 0x814fe04f;  // Debian Red

will get fairly close.

It looks like it's floor()ing the values in the RGB -> Y Cb Cr conversion, rather than round()ing them, and assigning less to the Y value than the online conversion, so you might want to finesse that a bit more if the *exact* red matters to you as the colour model used seems lightly different. But I suspect "colour temperature of the projector" and "colour temperature of the room lighting" will probably make more perceived difference.... :-)

From a glance at the code it looks like the pattern is:

   Cb Y Cr Y

(in big endian format).  Which means:

framebuffer[i] = 0x8254d554;

I think corresponds to the Y Cb Cr values you came up with.

Ewen

PS: I'm dubious about the accuracy of just repeating the 8-bit Y component twice to give it 16 bits, as that seems like something that's only really accurate at the extremes (Y = 0 / Y = 255). But off the top of my head it's probably "close enough" to be recognisably like what you were going for anyway.

--
You received this message because you are subscribed to the Google Groups "hdmi2usb 
- A HDMI capture solution" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to hdmi2usb+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/hdmi2usb/7acc66c4-34ee-cd6a-fea3-03da40f62bf6%40mcneill.gen.nz.

Reply via email to