File: yuv.frag

package info (click to toggle)
megapixels 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,876 kB
  • sloc: ansic: 6,530; python: 442; xml: 367; sh: 116; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D texture;
uniform mat3 color_matrix;
uniform float inv_gamma;
uniform float blacklevel;

varying vec2 texture_coord;

void
main()
{
    // Sample format: Y,U,Y,V
    vec4 raw = texture2D(texture, texture_coord);
    #if defined(FMT_YUYV)
    vec4 samples = raw.xyzw;
    #elif defined(FMT_YVYU)
    vec4 samples = raw.xwzy;
    #elif defined(FMT_UYVY)
    vec4 samples = raw.yzwx;
    #elif defined(FMT_VYUY)
    vec4 samples = raw.wzyx;
    #endif

    float y = samples.x;
    float u = samples.y-0.5;
    float v = samples.w-0.5;

    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(rgb, vec3(inv_gamma));

    gl_FragColor = vec4(gamma_color, 1);
}