Rewrite YUV processing pipeline.

Use a 4-channel texture instead for packed YUV data so
every pixel in the texture has all the 4:2:2 color data
available.
This commit is contained in:
Martijn Braam
2024-12-23 17:29:46 +01:00
parent 1b5a871641
commit 8fbea82b2b
5 changed files with 55 additions and 37 deletions

View File

@@ -7,26 +7,24 @@ uniform mat3 color_matrix;
uniform float inv_gamma;
uniform float blacklevel;
varying vec2 top_left_uv;
varying vec2 top_right_uv;
varying vec2 bottom_left_uv;
varying vec2 bottom_right_uv;
varying vec2 texture_coord;
void
main()
{
// Note the coordinates for texture samples need to be a varying, as the
// Mali-400 has this as a fast path allowing 32-bit floats. Otherwise
// they end up as 16-bit floats and that's not accurate enough.
// Sample format: Y,U,Y,V
vec4 samples = texture2D(texture, texture_coord);
float y = samples.x;
float u = samples.y-0.5;
float v = samples.w-0.5;
vec4 samples = vec4(texture2D(texture, top_left_uv).r,
texture2D(texture, top_right_uv).r,
texture2D(texture, bottom_left_uv).r,
texture2D(texture, bottom_right_uv).r);
vec3 color = vec3(samples.z, samples.z, samples.z);
vec3 rgb;
rgb.r = y + (1.403 * v);
rgb.g = y - (0.344 * u) - (0.714 * v);
rgb.b = y + (1.770 * u);
//color *= color_matrix;
vec3 gamma_color = pow(color, vec3(inv_gamma));
vec3 gamma_color = pow(rgb, vec3(inv_gamma));
gl_FragColor = vec4(gamma_color, 1);
}