In OpenGL ES 2.0 after reading the framebuffer and converting it to RGBA frames. I want to convert it to YUV format.
I tried using this table. Which ignore alpha component. When i do that and see the YUV frame generated its distorted.
Can anyone help me please
yuvdata[i * j *1]= (0.257)*memory[i*j*1] + (0.504)*memory[i*j*2]+(0.098)*memory[i*j*3]+16;
yuvdata[i * j *3]= (0.439)*memory[i*j*1] - (0.368)*memory[i*j*2] -(0.071)*memory[i*j*3]+128;
yuvdata[i * j *2]= -(0.148)*memory[i*j*1] - (0.291)*memory[i*j*2] +(0.439)*memory[i*j*3]+128;
`
Normalization did not help memory store rgba and yuv is free space to store yuv
i used rgb to yuv conversion ignoring alpha component
Friends this problem is resolved. This article is awesomeyuv2rgb. Thanks to Viktor Latypov and Mārtiņš Možeiko
"YUV" is not a complete format.
From this wikipedia article you can get the conversions of YUV411,YUV422,YUV420p to YUV444. Combine the inverse of these transforms with your RGB conversion and you'll get the result.
The thing you are missing: one RGB triple may produce a number (not one) of YUV components this way.
First, YUV422
Y'UV422 to RGB888 conversion
Input: Read 4 bytes of Y'UV (u, y1, v, y2 )
Output: Writes 6 bytes of RGB (R, G, B, R, G, B)
Then YUV4111
Y'UV411 to RGB888 conversion
Input: Read 6 bytes of Y'UV
Output: Writes 12 bytes of RGB
// Extract YUV components
u = yuv[0];
y1 = yuv[1];
y2 = yuv[2];
v = yuv[3];
y3 = yuv[4];
y4 = yuv[5];
rgb1 = Y'UV444toRGB888(y1, u, v);
rgb2 = Y'UV444toRGB888(y2, u, v);
rgb3 = Y'UV444toRGB888(y3, u, v);
rgb4 = Y'UV444toRGB888(y4, u, v);
Similar with 420p, but the YUV values are distributed over the rectangle there - see the Wikipedia's diagram and image for that.
Basically, you should fetch 4 RGB pixels, convert each one of them to YUV (using your hopefully valid 444 converter) and then store the YUV[4] array in a tricky way shown at the wikipedia.