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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
#ifndef __YUV2RGB_SHADERS_H__
#define __YUV2RGB_SHADERS_H__
/*
* Copyright (C) 2007-2010 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "guilib/TransformMatrix.h"
#include "cores/VideoRenderers/RenderFormats.h"
void CalculateYUVMatrix(TransformMatrix &matrix
, unsigned int flags
, ERenderFormat format
, float black
, float contrast);
#if defined(HAS_GL) || HAS_GLES == 2
#ifndef __GNUC__
#pragma warning( push )
#pragma warning( disable : 4250 )
#endif
#include "guilib/Shader.h"
namespace Shaders {
class BaseYUV2RGBShader
: virtual public CShaderProgram
{
public:
virtual ~BaseYUV2RGBShader() {};
virtual void SetField(int field) {};
virtual void SetWidth(int width) {};
virtual void SetHeight(int width) {};
virtual void SetBlack(float black) {};
virtual void SetContrast(float contrast) {};
virtual void SetNonLinStretch(float stretch){};
#if HAS_GLES == 2
virtual GLint GetVertexLoc() { return 0; };
virtual GLint GetYcoordLoc() { return 0; };
virtual GLint GetUcoordLoc() { return 0; };
virtual GLint GetVcoordLoc() { return 0; };
virtual void SetMatrices(GLfloat *p, GLfloat *m) {};
virtual void SetAlpha(GLfloat alpha) {};
#endif
};
class BaseYUV2RGBGLSLShader
: public BaseYUV2RGBShader
, public CGLSLShaderProgram
{
public:
BaseYUV2RGBGLSLShader(bool rect, unsigned flags, ERenderFormat format, bool stretch);
~BaseYUV2RGBGLSLShader() {}
virtual void SetField(int field) { m_field = field; }
virtual void SetWidth(int w) { m_width = w; }
virtual void SetHeight(int h) { m_height = h; }
virtual void SetBlack(float black) { m_black = black; }
virtual void SetContrast(float contrast) { m_contrast = contrast; }
virtual void SetNonLinStretch(float stretch) { m_stretch = stretch; }
#if HAS_GLES == 2
virtual GLint GetVertexLoc() { return m_hVertex; }
virtual GLint GetYcoordLoc() { return m_hYcoord; }
virtual GLint GetUcoordLoc() { return m_hUcoord; }
virtual GLint GetVcoordLoc() { return m_hVcoord; }
virtual void SetMatrices(GLfloat *p, GLfloat *m) { m_proj = p; m_model = m; }
virtual void SetAlpha(GLfloat alpha) { m_alpha = alpha; }
#endif
protected:
void OnCompiledAndLinked();
bool OnEnabled();
unsigned m_flags;
ERenderFormat m_format;
int m_width;
int m_height;
int m_field;
float m_black;
float m_contrast;
float m_stretch;
string m_defines;
// shader attribute handles
GLint m_hYTex;
GLint m_hUTex;
GLint m_hVTex;
GLint m_hMatrix;
GLint m_hStretch;
GLint m_hStep;
#if HAS_GLES == 2
GLint m_hVertex;
GLint m_hYcoord;
GLint m_hUcoord;
GLint m_hVcoord;
GLint m_hProj;
GLint m_hModel;
GLint m_hAlpha;
GLfloat *m_proj;
GLfloat *m_model;
GLfloat m_alpha;
#endif
};
#if HAS_GLES != 2 // No ARB Shader when using GLES2.0
class BaseYUV2RGBARBShader
: public BaseYUV2RGBShader
, public CARBShaderProgram
{
public:
BaseYUV2RGBARBShader(unsigned flags, ERenderFormat format);
~BaseYUV2RGBARBShader() {}
virtual void SetField(int field) { m_field = field; }
virtual void SetWidth(int w) { m_width = w; }
virtual void SetHeight(int h) { m_height = h; }
virtual void SetBlack(float black) { m_black = black; }
virtual void SetContrast(float contrast) { m_contrast = contrast; }
protected:
unsigned m_flags;
ERenderFormat m_format;
int m_width;
int m_height;
int m_field;
float m_black;
float m_contrast;
// shader attribute handles
GLint m_hYTex;
GLint m_hUTex;
GLint m_hVTex;
};
class YUV2RGBProgressiveShaderARB : public BaseYUV2RGBARBShader
{
public:
YUV2RGBProgressiveShaderARB(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE);
void OnCompiledAndLinked();
bool OnEnabled();
};
#endif
class YUV2RGBProgressiveShader : public BaseYUV2RGBGLSLShader
{
public:
YUV2RGBProgressiveShader(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE, bool stretch = false);
};
class YUV2RGBBobShader : public BaseYUV2RGBGLSLShader
{
public:
YUV2RGBBobShader(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE);
void OnCompiledAndLinked();
bool OnEnabled();
GLint m_hStepX;
GLint m_hStepY;
GLint m_hField;
};
} // end namespace
#ifndef __GNUC__
#pragma warning( pop )
#endif
#endif
#endif //__YUV2RGB_SHADERS_H__
|