I know how to encode a shader that converts flat data (YUV420 image) to packed (RGB image) using a fragmented shader, but how can I encode RGB for YUV420. I do not need a YUV420 image for rendering, but pass it to the h264 compression code.
From http://www.fourcc.org/fccyvrgb.php :
Convert RGB to YUVY = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128Cb = U = - (0.148 * R) - (0.291 * G) + (0.439 * B) + 128
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
Cb = U = - (0.148 * R) - (0.291 * G) + (0.439 * B) + 128
OpenGL 1/256. , , -.
mat4 RGBtoYUV(0.257, 0.439, -0.148, 0.0, 0.504, -0.368, -0.291, 0.0, 0.098, -0.071, 0.439, 0.0, 0.0625, 0.500, 0.500, 1.0 ); YUV = RGBtoYUV * RGB;
http://en.wikipedia.org/wiki/YUV
YUV , (, ).
, . , ARB_framebuffer_object. , . , , , , .
, framebuffer, 3 renderbuffer ( ) 3 vec4.
RED, .
( ), YUV (, SSE), .
, . , , contiguos.