Support rendering YUV formatted frames

This commit is contained in:
Martijn Braam
2023-11-24 16:28:25 +01:00
parent 8a3f1a5540
commit 9d189b88b4
10 changed files with 146 additions and 53 deletions

32
data/yuv.frag Normal file
View File

@@ -0,0 +1,32 @@
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D texture;
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;
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.
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.x, samples.y, samples.z);
color *= color_matrix;
vec3 gamma_color = pow(color, vec3(inv_gamma));
gl_FragColor = vec4(gamma_color, 1);
}