qt: playlist: use item title if available
[vlc.git] / modules / video_output / win32 / builtin_shaders.h
blob3a87ce279c2ba7afb02862cef09a2bf4a1cfbf50
1 /*****************************************************************************
2 * builtin_shaders.h: Builtin HLSL shader functions.
3 *****************************************************************************
4 * Copyright (C) 2014 the VideoLAN team
6 * Authors: Sasha Koruga <skoruga@gmail.com>,
7 * Felix Abecassis <felix.abecassis@gmail.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 static const char shader_disabled_source[] =
24 "sampler2D screen;\n"
25 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR\n"
26 "{\n"
27 " return saturate(tex2D(screen, screenCoords.xy));\n"
28 "}\n";
30 static const char shader_invert_source[] =
31 "sampler2D screen;\n"
32 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR\n"
33 "{\n"
34 " float4 color = tex2D(screen, screenCoords.xy);\n"
35 " color.r = 1.0 - color.r;\n"
36 " color.g = 1.0 - color.g;\n"
37 " color.b = 1.0 - color.b;\n"
38 " return color;\n"
39 "}\n";
41 static const char shader_grayscale_source[] =
42 "sampler2D screen;\n"
43 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
44 "{\n"
45 " float4 color = tex2D(screen, screenCoords.xy);\n"
46 " float gray = 0.2989 * color.r + 0.5870 * color.g + 0.1140 * color.b;\n"
47 " color.r = color.g = color.b = gray;\n"
48 " return color;\n"
49 "}\n";
51 static const char shader_convert601to709_source[] =
52 "sampler2D screen;\n"
53 "float4 rgb_to_yuv601(float4 RGB)\n"
54 "{\n"
55 " float Kr = 0.299;\n"
56 " float Kg = 0.587;\n"
57 " float Kb = 0.114;\n"
58 " float Y = Kr*RGB.r + Kg*RGB.g + Kb*RGB.b;\n"
59 " float V = (RGB.r-Y)/(1-Kr);\n"
60 " float U = (RGB.b-Y)/(1-Kb);\n"
61 " return float4(Y,U,V,1);\n"
62 "}\n"
64 "float4 yuv709_to_rgb(float4 YUV)\n"
65 "{\n"
66 " float Kr = 0.2125;\n"
67 " float Kg = 0.7154;\n"
68 " float Kb = 0.0721;\n"
69 " float Y = YUV.x;\n"
70 " float U = YUV.y;\n"
71 " float V = YUV.z;\n"
72 " float R = Y + V*(1-Kr);\n"
73 " float G = Y - U*(1-Kb)*Kb/Kg - V*(1-Kr)*Kr/Kg;\n"
74 " float B = Y + U*(1-Kb);\n"
75 " return float4(R,G,B,1);\n"
76 "}\n"
78 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
79 "{\n"
80 " float4 color = tex2D(screen, screenCoords.xy);\n"
81 " return yuv709_to_rgb(rgb_to_yuv601(color));\n"
82 "}\n";
84 static const char shader_gammacorrection18_source[] =
85 "sampler2D screen;\n"
86 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
87 "{\n"
88 " float4 color = tex2D( screen, screenCoords.xy);\n"
89 " color = pow(color,1.0/1.8);\n"
90 " return color;\n"
91 "}\n";
93 static const char shader_gammacorrection22_source[] =
94 "sampler2D screen;\n"
95 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
96 "{\n"
97 " float4 color = tex2D( screen, screenCoords.xy);\n"
98 " color = pow(color,1.0/2.2);\n"
99 " return color;\n"
100 "}\n";
102 static const char shader_gammacorrectionbt709_source[] =
103 "sampler2D screen;\n"
104 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
105 "{\n"
106 " float4 color = tex2D(screen, screenCoords.xy);\n"
107 " if(color.r > 0.018)\n"
108 " color.r = 1.099 * pow(color.r,0.45) - 0.099;\n"
109 " else\n"
110 " color.r = 4.5138 * color.r;\n"
111 " if(color.g > 0.018)\n"
112 " color.g = 1.099 * pow(color.g,0.45) - 0.099;\n"
113 " else\n"
114 " color.g = 4.5138 * color.g;\n"
115 " if(color.b > 0.018)\n"
116 " color.b = 1.099 * pow(color.b,0.45) - 0.099;\n"
117 " else\n"
118 " color.b = 4.5138 * color.b;\n"
119 " return color;\n"
120 "}\n";
122 static const char shader_widencolorspace_source[] =
123 "sampler2D screen;\n"
124 "float4 main(float2 screenCoords : TEXCOORD0) : COLOR0\n"
125 "{\n"
126 " float4 color = tex2D(screen, screenCoords.xy);\n"
127 " color.r = max(color.r - 0.0627450980392157,0) * 1.164383561643836;\n"
128 " color.g = max(color.g - 0.0627450980392157,0) * 1.164383561643836;\n"
129 " color.b = max(color.b - 0.0627450980392157,0) * 1.164383561643836;\n"
130 " return saturate(color);\n"
131 "}\n";
133 typedef struct
135 const char *name;
136 const char *code;
137 } builtin_shader_t;
139 static const builtin_shader_t builtin_shaders[] =
141 { "Disabled", shader_disabled_source },
142 { "Invert", shader_invert_source },
143 { "Grayscale", shader_grayscale_source },
144 { "Convert601to709", shader_convert601to709_source },
145 { "GammaCorrection18", shader_gammacorrection18_source },
146 { "GammaCorrection22", shader_gammacorrection22_source },
147 { "GammaCorrectionBT709", shader_gammacorrectionbt709_source },
148 { "WidenColorSpace", shader_widencolorspace_source },
150 #define BUILTIN_SHADERS_COUNT (sizeof(builtin_shaders)/sizeof(builtin_shaders[0]))