Page 1 of 1

YUV to RGB compute BT709 coeff...

Posted: 26 Apr 2014 08:59
by wcoder
Hi,

I'am try to found how coeff was calculated on YUV to RGB shader on OpenGl.c module...and what is the last column factor ?

// [R/G/B][Y U V O] from TV range to full range XXX we could also do hue/brightness/constrast/gamma by simply changing the coefficients
const float matrix_bt709_tv2full[12] = {
1.164383561643836, 0.0000, 1.792741071428571, -0.972945075016308,
1.164383561643836, -0.21324861427373, -0.532909328559444, 0.301482665475862,
1.164383561643836, 2.112401785714286, 0.0000, -1.133402217873451 };

Thanks

Re: YUV to RGB compute BT709 coeff...

Posted: 26 Apr 2014 18:42
by Jean-Baptiste Kempf
It's based on the standard.

Re: YUV to RGB compute BT709 coeff...

Posted: 29 Apr 2014 12:26
by wcoder
I known but it's not my question (allez un petit effort camarade ^_^), i found a lot of site like :
http://www.fourcc.org/fccyvrgb.php
http://www.equasys.de/colorconversion.html

So I made my own basic shader using this coeff from fourcc (LUMINANCE texture) :

float fY = 1.164 * ( texture2D ( TextureY, gl_TexCoord [0].st ).r - 0.0625 );
float fU = texture2D ( TextureU, gl_TexCoord [1].st ).r - 0.5;
float fV = texture2D ( TextureV, gl_TexCoord [2].st ).r - 0.5;

vec4 rgbColor;
rgbColor.x = fY + 1.793 * fV;
rgbColor.y = fY - 0.213 * fU + 0.533 * fV;
rgbColor.z = fY + 2.112 * fU;

gl_FragColor = rgbColor;

It's work, but i want to undestand how use info from spec to calculate coeff with a full précision : http://www.itu.int/rec/R-REC-BT.709-5-200204-I/en
Like you, i want to undestand too : what is the last column i supose for the moment it's a brightnes & constrast adjustement
1.164383561643836, 0.0000, 1.792741071428571, -0.972945075016308,
1.164383561643836, -0.21324861427373, -0.532909328559444, 0.301482665475862,
1.164383561643836, 2.112401785714286, 0.0000, -1.133402217873451 };

Thanks by advance,

WCdr