Lines 26-60
Link Here
|
26 |
class OpenGLFilter |
26 |
class OpenGLFilter |
27 |
{ |
27 |
{ |
28 |
public: |
28 |
public: |
29 |
GLuint fragmentProgram; |
29 |
vector<GLuint> fragmentPrograms; |
30 |
uint numInputs; |
30 |
uint numInputs; |
31 |
bool rotateFrameBuffers; |
|
|
32 |
vector<GLuint> frameBuffers; |
31 |
vector<GLuint> frameBuffers; |
33 |
vector<GLuint> frameBufferTextures; |
32 |
vector<GLuint> frameBufferTextures; |
34 |
DisplayBuffer outputBuffer; |
33 |
DisplayBuffer outputBuffer; |
35 |
}; |
34 |
}; |
36 |
|
35 |
|
37 |
OpenGLVideo::OpenGLVideo() : |
36 |
OpenGLVideo::OpenGLVideo() : |
38 |
gl_context(NULL), videoSize(0,0), |
37 |
gl_context(NULL), video_dim(0,0), |
39 |
viewportSize(0,0), masterViewportSize(0,0), |
38 |
actual_video_dim(0,0), viewportSize(0,0), |
40 |
visibleRect(0,0,0,0), videoRect(0,0,0,0), |
39 |
masterViewportSize(0,0), display_visible_rect(0,0,0,0), |
41 |
frameRect(0,0,0,0), |
40 |
display_video_rect(0,0,0,0), video_rect(0,0,0,0), |
42 |
frameBufferRect(0,0,0,0), invertVideo(false), |
41 |
frameBufferRect(0,0,0,0), softwareDeinterlacer(QString::null), |
43 |
softwareDeinterlacer(QString::null), |
42 |
hardwareDeinterlacer(QString::null), hardwareDeinterlacing(false), |
44 |
hardwareDeinterlacing(false), |
|
|
45 |
useColourControl(false), viewportControl(false), |
43 |
useColourControl(false), viewportControl(false), |
46 |
frameBuffer(0), frameBufferTexture(0), |
|
|
47 |
inputTextureSize(0,0), currentFrameNum(0), |
44 |
inputTextureSize(0,0), currentFrameNum(0), |
48 |
inputUpdated(false), |
45 |
inputUpdated(false), |
49 |
|
46 |
textureRects(false), textureType(GL_TEXTURE_2D), |
|
|
47 |
helperTexture(0), defaultUpsize(kGLFilterResize), |
50 |
convertSize(0,0), convertBuf(NULL), |
48 |
convertSize(0,0), convertBuf(NULL), |
51 |
|
49 |
videoResize(false), videoResizeRect(0,0,0,0), |
52 |
videoResize(false), videoResizeRect(0,0,0,0) |
50 |
gl_features(0) |
53 |
{ |
51 |
{ |
54 |
} |
52 |
} |
55 |
|
53 |
|
56 |
OpenGLVideo::~OpenGLVideo() |
54 |
OpenGLVideo::~OpenGLVideo() |
57 |
{ |
55 |
{ |
|
|
56 |
OpenGLContextLocker ctx_lock(gl_context); |
58 |
Teardown(); |
57 |
Teardown(); |
59 |
} |
58 |
} |
60 |
|
59 |
|
Lines 63-117
Link Here
|
63 |
{ |
62 |
{ |
64 |
ShutDownYUV2RGB(); |
63 |
ShutDownYUV2RGB(); |
65 |
|
64 |
|
66 |
gl_context->MakeCurrent(true); |
65 |
if (helperTexture) |
67 |
|
66 |
gl_context->DeleteTexture(helperTexture); |
68 |
if (frameBuffer) |
67 |
helperTexture = 0; |
69 |
gl_context->DeleteFrameBuffer(frameBuffer); |
|
|
70 |
|
68 |
|
71 |
if (frameBufferTexture) |
69 |
DeleteTextures(&inputTextures); |
72 |
gl_context->DeleteTexture(frameBufferTexture); |
70 |
DeleteTextures(&referenceTextures); |
73 |
|
|
|
74 |
for (uint i = 0; i < inputTextures.size(); i++) |
75 |
gl_context->DeleteTexture(inputTextures[i]); |
76 |
inputTextures.clear(); |
77 |
|
71 |
|
78 |
if (!filters.empty()) |
72 |
if (!filters.empty()) |
79 |
{ |
73 |
{ |
80 |
glfilt_map_t::iterator it; |
74 |
glfilt_map_t::iterator it; |
81 |
for (it = filters.begin(); it != filters.end(); ++it) |
75 |
for (it = filters.begin(); it != filters.end(); it++) |
82 |
{ |
76 |
{ |
83 |
if (it->second->fragmentProgram) |
77 |
RemoveFilter(it->first); |
84 |
gl_context->DeleteFragmentProgram(it->second->fragmentProgram); |
|
|
85 |
vector<GLuint> temp = it->second->frameBuffers; |
86 |
for (uint i = 0; i < temp.size(); i++) |
87 |
gl_context->DeleteFrameBuffer(temp[i]); |
88 |
temp = it->second->frameBufferTextures; |
89 |
for (uint i = 0; i < temp.size(); i++) |
90 |
gl_context->DeleteTexture((temp[i])); |
91 |
} |
78 |
} |
92 |
} |
79 |
} |
93 |
filters.clear(); |
80 |
filters.clear(); |
94 |
|
|
|
95 |
gl_context->MakeCurrent(false); |
96 |
} |
81 |
} |
97 |
|
82 |
|
98 |
// locking ok |
83 |
// locking ok |
99 |
bool OpenGLVideo::Init(OpenGLContext *glcontext, bool colour_control, |
84 |
bool OpenGLVideo::Init(OpenGLContext *glcontext, bool colour_control, |
100 |
bool onscreen, QSize video_size, QRect visible_rect, |
85 |
QSize videoDim, QRect displayVisibleRect, |
101 |
QRect video_rect, QRect frame_rect, |
86 |
QRect displayVideoRect, QRect videoRect, |
102 |
bool viewport_control, bool osd) |
87 |
bool viewport_control, QString options, bool osd) |
103 |
{ |
88 |
{ |
104 |
gl_context = glcontext; |
89 |
gl_context = glcontext; |
105 |
videoSize = video_size; |
90 |
if (!gl_context) |
106 |
visibleRect = visible_rect; |
91 |
return false; |
107 |
videoRect = video_rect; |
|
|
108 |
frameRect = frame_rect; |
109 |
masterViewportSize = QSize(1920, 1080); |
110 |
|
92 |
|
111 |
QSize rect = GetTextureSize(videoSize); |
93 |
OpenGLContextLocker ctx_lock(gl_context); |
112 |
|
94 |
|
113 |
frameBufferRect = QRect(QPoint(0,0), rect); |
95 |
actual_video_dim = videoDim; |
114 |
invertVideo = true; |
96 |
video_dim = videoDim; |
|
|
97 |
if (video_dim.height() == 1088) |
98 |
video_dim.setHeight(1080); |
99 |
display_visible_rect = displayVisibleRect; |
100 |
display_video_rect = displayVideoRect; |
101 |
video_rect = videoRect; |
102 |
masterViewportSize = QSize(1920, 1080); |
103 |
frameBufferRect = QRect(QPoint(0,0), video_dim); |
115 |
softwareDeinterlacer = ""; |
104 |
softwareDeinterlacer = ""; |
116 |
hardwareDeinterlacing = false; |
105 |
hardwareDeinterlacing = false; |
117 |
useColourControl = colour_control; |
106 |
useColourControl = colour_control; |
Lines 120-173
Link Here
|
120 |
convertSize = QSize(0,0); |
109 |
convertSize = QSize(0,0); |
121 |
videoResize = false; |
110 |
videoResize = false; |
122 |
videoResizeRect = QRect(0,0,0,0); |
111 |
videoResizeRect = QRect(0,0,0,0); |
123 |
frameBuffer = 0; |
|
|
124 |
currentFrameNum = -1; |
112 |
currentFrameNum = -1; |
125 |
inputUpdated = false; |
113 |
inputUpdated = false; |
126 |
|
114 |
|
127 |
if (!onscreen) |
115 |
gl_features = ParseOptions(options) & |
128 |
{ |
116 |
gl_context->GetFeatures(); |
129 |
QSize fb_size = GetTextureSize(visibleRect.size()); |
117 |
|
130 |
if (!AddFrameBuffer(frameBuffer, frameBufferTexture, fb_size)) |
118 |
if (viewportControl) |
131 |
return false; |
119 |
gl_context->SetFeatures(gl_features); |
132 |
} |
120 |
|
|
|
121 |
if (options.contains("openglbicubic")) |
122 |
defaultUpsize = kGLFilterBicubic; |
123 |
|
124 |
if ((defaultUpsize != kGLFilterBicubic) && (gl_features & kGLExtRect)) |
125 |
gl_context->GetTextureType(textureType, textureRects); |
126 |
|
127 |
SetViewPort(display_visible_rect.size()); |
133 |
|
128 |
|
134 |
SetViewPort(visibleRect.size()); |
129 |
bool use_pbo = gl_features & kGLExtPBufObj; |
135 |
InitOpenGL(); |
|
|
136 |
|
130 |
|
137 |
if (osd) |
131 |
if (osd) |
138 |
{ |
132 |
{ |
139 |
QSize osdsize = visibleRect.size(); |
133 |
QSize osdsize = display_visible_rect.size(); |
140 |
QSize half_size(osdsize.width() >> 1, osdsize.height() >>1); |
134 |
GLuint tex = CreateVideoTexture(osdsize, inputTextureSize, use_pbo); |
141 |
GLuint alphatex = CreateVideoTexture(osdsize, inputTextureSize); |
135 |
|
142 |
GLuint utex = CreateVideoTexture(half_size, inputTextureSize); |
136 |
if (tex && |
143 |
GLuint vtex = CreateVideoTexture(half_size, inputTextureSize); |
137 |
AddFilter(kGLFilterYUV2RGBA) && |
144 |
GLuint ytex = CreateVideoTexture(osdsize, inputTextureSize); |
138 |
AddFilter(kGLFilterResize)) |
145 |
|
139 |
{ |
146 |
if ((alphatex && ytex && utex && vtex) && AddFilter(kGLFilterYUV2RGBA)) |
140 |
inputTextures.push_back(tex); |
147 |
{ |
141 |
} |
148 |
inputTextures.push_back(ytex); |
142 |
else |
149 |
inputTextures.push_back(utex); |
143 |
{ |
150 |
inputTextures.push_back(vtex); |
144 |
Teardown(); |
151 |
inputTextures.push_back(alphatex); |
|
|
152 |
if (!AddFilter(kGLFilterResize)) |
153 |
{ |
154 |
Teardown(); |
155 |
return false; |
156 |
} |
157 |
} |
145 |
} |
158 |
} |
146 |
} |
159 |
else |
147 |
else |
160 |
{ |
148 |
{ |
161 |
QSize half_size(videoSize.width() >> 1, videoSize.height() >>1); |
149 |
GLuint tex = CreateVideoTexture(actual_video_dim, |
162 |
GLuint utex = CreateVideoTexture(half_size, inputTextureSize); |
150 |
inputTextureSize, use_pbo); |
163 |
GLuint vtex = CreateVideoTexture(half_size, inputTextureSize); |
151 |
|
164 |
GLuint ytex = CreateVideoTexture(videoSize, inputTextureSize);; |
152 |
if (tex && AddFilter(kGLFilterYUV2RGB)) |
165 |
|
153 |
{ |
166 |
if ((ytex && utex && vtex) && AddFilter(kGLFilterYUV2RGB)) |
154 |
inputTextures.push_back(tex); |
167 |
{ |
155 |
} |
168 |
inputTextures.push_back(ytex); |
156 |
else |
169 |
inputTextures.push_back(utex); |
157 |
{ |
170 |
inputTextures.push_back(vtex); |
158 |
Teardown(); |
171 |
} |
159 |
} |
172 |
} |
160 |
} |
173 |
|
161 |
|
Lines 184-194
Link Here
|
184 |
"Falling back to software conversion.\n\t\t\t" |
172 |
"Falling back to software conversion.\n\t\t\t" |
185 |
"Any opengl filters will also be disabled."); |
173 |
"Any opengl filters will also be disabled."); |
186 |
|
174 |
|
187 |
GLuint rgb24tex = CreateVideoTexture(videoSize, inputTextureSize); |
175 |
GLuint bgra32tex = CreateVideoTexture(actual_video_dim, |
|
|
176 |
inputTextureSize, use_pbo); |
188 |
|
177 |
|
189 |
if (rgb24tex && AddFilter(kGLFilterResize)) |
178 |
if (bgra32tex && AddFilter(kGLFilterResize)) |
190 |
{ |
179 |
{ |
191 |
inputTextures.push_back(rgb24tex); |
180 |
inputTextures.push_back(bgra32tex); |
192 |
} |
181 |
} |
193 |
else |
182 |
else |
194 |
{ |
183 |
{ |
Lines 198-265
Link Here
|
198 |
} |
187 |
} |
199 |
} |
188 |
} |
200 |
|
189 |
|
|
|
190 |
#ifdef MMX |
191 |
bool mmx = true; |
192 |
#else |
193 |
bool mmx = false; |
194 |
#endif |
195 |
|
196 |
CheckResize(false); |
197 |
|
198 |
VERBOSE(VB_PLAYBACK, LOC + |
199 |
QString("Using packed textures with%1 mmx and with%2 PBOs") |
200 |
.arg(mmx ? "" : "out").arg(use_pbo ? "" : "out")); |
201 |
|
201 |
return true; |
202 |
return true; |
202 |
} |
203 |
} |
203 |
|
204 |
|
204 |
OpenGLFilterType OpenGLVideo::GetDeintFilter(void) const |
205 |
void OpenGLVideo::CheckResize(bool deinterlacing) |
205 |
{ |
206 |
{ |
206 |
if (filters.count(kGLFilterKernelDeint)) |
207 |
// to improve performance on slower cards |
207 |
return kGLFilterKernelDeint; |
208 |
bool resize_up = (video_dim.height() < display_video_rect.height()) || |
208 |
if (filters.count(kGLFilterLinearBlendDeint)) |
209 |
(video_dim.width() < display_video_rect.width()); |
209 |
return kGLFilterLinearBlendDeint; |
|
|
210 |
if (filters.count(kGLFilterOneFieldDeint)) |
211 |
return kGLFilterOneFieldDeint; |
212 |
if (filters.count(kGLFilterBobDeintDFR)) |
213 |
return kGLFilterBobDeintDFR; |
214 |
if (filters.count(kGLFilterOneFieldDeintDFR)) |
215 |
return kGLFilterOneFieldDeintDFR; |
216 |
if (filters.count(kGLFilterLinearBlendDeintDFR)) |
217 |
return kGLFilterLinearBlendDeintDFR; |
218 |
if (filters.count(kGLFilterKernelDeintDFR)) |
219 |
return kGLFilterKernelDeintDFR; |
220 |
if (filters.count(kGLFilterFieldOrderDFR)) |
221 |
return kGLFilterFieldOrderDFR; |
222 |
|
210 |
|
223 |
return kGLFilterNone; |
211 |
// to ensure deinterlacing works correctly |
224 |
} |
212 |
bool resize_down = (video_dim.height() > display_video_rect.height()) && |
|
|
213 |
deinterlacing; |
225 |
|
214 |
|
226 |
bool OpenGLVideo::OptimiseFilters(void) |
215 |
if (resize_up && (defaultUpsize == kGLFilterBicubic)) |
227 |
{ |
|
|
228 |
// if video height does not match display rect height, add resize stage |
229 |
// to preserve field information N.B. assumes interlaced |
230 |
// if video rectangle is smaller than display rectangle, add resize stage |
231 |
// to improve performance |
232 |
|
233 |
bool needResize = ((videoSize.height() != videoRect.height()) || |
234 |
(videoSize.width() < videoRect.width())); |
235 |
if (needResize && !filters.count(kGLFilterResize) && |
236 |
!(AddFilter(kGLFilterResize))) |
237 |
{ |
216 |
{ |
238 |
return false; |
217 |
RemoveFilter(kGLFilterResize); |
|
|
218 |
filters.erase(kGLFilterResize); |
219 |
AddFilter(kGLFilterBicubic); |
220 |
return; |
221 |
} |
222 |
|
223 |
if ((resize_up && (defaultUpsize == kGLFilterResize)) || resize_down) |
224 |
{ |
225 |
RemoveFilter(kGLFilterBicubic); |
226 |
filters.erase(kGLFilterBicubic); |
227 |
AddFilter(kGLFilterResize); |
228 |
return; |
239 |
} |
229 |
} |
240 |
|
230 |
|
|
|
231 |
if (!filters.count(kGLFilterYUV2RGBA)) |
232 |
{ |
233 |
RemoveFilter(kGLFilterResize); |
234 |
filters.erase(kGLFilterResize); |
235 |
} |
236 |
|
237 |
RemoveFilter(kGLFilterBicubic); |
238 |
filters.erase(kGLFilterBicubic); |
239 |
|
240 |
OptimiseFilters(); |
241 |
} |
242 |
|
243 |
bool OpenGLVideo::OptimiseFilters(void) |
244 |
{ |
241 |
glfilt_map_t::reverse_iterator it; |
245 |
glfilt_map_t::reverse_iterator it; |
242 |
|
246 |
|
243 |
// add/remove required frame buffer objects |
247 |
// add/remove required frame buffer objects |
244 |
// and link filters |
248 |
// and link filters |
245 |
uint buffers_needed = 1; |
249 |
uint buffers_needed = 1; |
246 |
bool last_filter = true; |
250 |
bool last_filter = true; |
247 |
bool needtorotate = false; |
|
|
248 |
for (it = filters.rbegin(); it != filters.rend(); it++) |
251 |
for (it = filters.rbegin(); it != filters.rend(); it++) |
249 |
{ |
252 |
{ |
250 |
it->second->outputBuffer = kFrameBufferObject; |
|
|
251 |
it->second->rotateFrameBuffers = needtorotate; |
252 |
if (!last_filter) |
253 |
if (!last_filter) |
253 |
{ |
254 |
{ |
|
|
255 |
it->second->outputBuffer = kFrameBufferObject; |
254 |
uint buffers_have = it->second->frameBuffers.size(); |
256 |
uint buffers_have = it->second->frameBuffers.size(); |
255 |
int buffers_diff = buffers_needed - buffers_have; |
257 |
int buffers_diff = buffers_needed - buffers_have; |
256 |
if (buffers_diff > 0) |
258 |
if (buffers_diff > 0) |
257 |
{ |
259 |
{ |
258 |
uint tmp_buf, tmp_tex; |
260 |
uint tmp_buf, tmp_tex; |
259 |
QSize fb_size = GetTextureSize(videoSize); |
261 |
QSize fb_size = GetTextureSize(video_dim); |
260 |
for (int i = 0; i < buffers_diff; i++) |
262 |
for (int i = 0; i < buffers_diff; i++) |
261 |
{ |
263 |
{ |
262 |
if (!AddFrameBuffer(tmp_buf, tmp_tex, fb_size)) |
264 |
if (!AddFrameBuffer(tmp_buf, fb_size, tmp_tex, video_dim)) |
263 |
return false; |
265 |
return false; |
264 |
else |
266 |
else |
265 |
{ |
267 |
{ |
Lines 286-310
Link Here
|
286 |
} |
288 |
} |
287 |
else |
289 |
else |
288 |
{ |
290 |
{ |
|
|
291 |
it->second->outputBuffer = kDefaultBuffer; |
289 |
last_filter = false; |
292 |
last_filter = false; |
290 |
} |
293 |
} |
291 |
|
|
|
292 |
buffers_needed = it->second->numInputs; |
294 |
buffers_needed = it->second->numInputs; |
293 |
needtorotate = (it->first == kGLFilterKernelDeint || |
|
|
294 |
it->first == kGLFilterLinearBlendDeint || |
295 |
it->first == kGLFilterOneFieldDeintDFR || |
296 |
it->first == kGLFilterLinearBlendDeintDFR || |
297 |
it->first == kGLFilterKernelDeintDFR || |
298 |
it->first == kGLFilterFieldOrderDFR); |
299 |
|
300 |
} |
295 |
} |
301 |
|
296 |
|
302 |
bool deinterlacing = hardwareDeinterlacing; |
297 |
SetFiltering(); |
303 |
hardwareDeinterlacing = true; |
|
|
304 |
|
305 |
SetDeinterlacing(false); |
306 |
if (deinterlacing) |
307 |
SetDeinterlacing(deinterlacing); |
308 |
|
298 |
|
309 |
return true; |
299 |
return true; |
310 |
} |
300 |
} |
Lines 314-388
Link Here
|
314 |
{ |
304 |
{ |
315 |
// filter settings included for performance only |
305 |
// filter settings included for performance only |
316 |
// no (obvious) quality improvement over GL_LINEAR throughout |
306 |
// no (obvious) quality improvement over GL_LINEAR throughout |
317 |
if (filters.empty()) |
307 |
if (filters.empty() || filters.size() == 1) |
318 |
return; |
|
|
319 |
|
320 |
if (filters.size() == 1) |
321 |
{ |
308 |
{ |
322 |
SetTextureFilters(&inputTextures, GL_LINEAR); |
309 |
SetTextureFilters(&inputTextures, GL_LINEAR, GL_CLAMP_TO_EDGE); |
323 |
return; |
310 |
return; |
324 |
} |
311 |
} |
325 |
|
312 |
|
326 |
SetTextureFilters(&inputTextures, GL_NEAREST); |
313 |
SetTextureFilters(&inputTextures, GL_NEAREST, GL_CLAMP_TO_EDGE); |
327 |
vector<GLuint> textures; |
|
|
328 |
glfilt_map_t::iterator it; |
329 |
for (it = filters.begin(); it != filters.end(); it++) |
330 |
SetTextureFilters(&(it->second->frameBufferTextures), GL_NEAREST); |
331 |
|
314 |
|
332 |
// resize or last active (ie don't need resize) need GL_LINEAR |
|
|
333 |
glfilt_map_t::reverse_iterator rit; |
315 |
glfilt_map_t::reverse_iterator rit; |
334 |
bool next = false; |
316 |
int last_filter = 0; |
335 |
bool resize = filters.count(kGLFilterResize); |
317 |
|
336 |
for (rit = filters.rbegin(); rit != filters.rend(); rit++) |
318 |
for (rit = filters.rbegin(); rit != filters.rend(); rit++) |
337 |
{ |
319 |
{ |
338 |
if (next && (rit->second->outputBuffer != kNoBuffer)) |
320 |
if (last_filter == 1) |
339 |
{ |
321 |
{ |
340 |
SetTextureFilters(&(rit->second->frameBufferTextures), GL_LINEAR); |
322 |
SetTextureFilters(&(rit->second->frameBufferTextures), |
341 |
return; |
323 |
GL_LINEAR, GL_CLAMP_TO_EDGE); |
342 |
} |
324 |
} |
343 |
|
325 |
else if (last_filter > 1) |
344 |
if (resize) |
|
|
345 |
{ |
326 |
{ |
346 |
next |= ((rit->first == kGLFilterResize) || |
327 |
SetTextureFilters(&(rit->second->frameBufferTextures), |
347 |
(rit->second->outputBuffer == kDefaultBuffer)); |
328 |
GL_NEAREST, GL_CLAMP_TO_EDGE); |
348 |
} |
329 |
} |
349 |
} |
330 |
} |
350 |
|
|
|
351 |
SetTextureFilters(&inputTextures, GL_LINEAR); |
352 |
} |
353 |
|
354 |
// locking ok |
355 |
bool OpenGLVideo::ReInit(OpenGLContext *glcontext, bool colour_control, |
356 |
bool onscreen, QSize video_size, QRect visible_rect, |
357 |
QRect video_rect, QRect frame_rect, |
358 |
bool viewport_control, bool osd) |
359 |
{ |
360 |
VERBOSE(VB_PLAYBACK, LOC + "Reinit"); |
361 |
|
362 |
gl_context->MakeCurrent(true); |
363 |
|
364 |
QString harddeint = GetDeinterlacer(); // only adds back deinterlacer |
365 |
QString softdeint = softwareDeinterlacer; |
366 |
bool interlacing = hardwareDeinterlacing; |
367 |
bool resize = videoResize; |
368 |
QRect resize_rect = videoResizeRect; |
369 |
|
370 |
Teardown(); |
371 |
|
372 |
bool success = Init(glcontext, colour_control, onscreen, video_size, |
373 |
visible_rect, video_rect, frame_rect, |
374 |
viewport_control, osd); |
375 |
|
376 |
if (harddeint != "") |
377 |
success &= AddDeinterlacer(harddeint); |
378 |
|
379 |
softwareDeinterlacer = softdeint; |
380 |
SetDeinterlacing(interlacing); |
381 |
|
382 |
if (resize) |
383 |
SetVideoResize(resize_rect); |
384 |
|
385 |
return success; |
386 |
} |
331 |
} |
387 |
|
332 |
|
388 |
// locking ok |
333 |
// locking ok |
Lines 391-444
Link Here
|
391 |
if (filters.count(filter)) |
336 |
if (filters.count(filter)) |
392 |
return true; |
337 |
return true; |
393 |
|
338 |
|
|
|
339 |
bool success = true; |
340 |
|
394 |
VERBOSE(VB_PLAYBACK, LOC + QString("Creating %1 filter.") |
341 |
VERBOSE(VB_PLAYBACK, LOC + QString("Creating %1 filter.") |
395 |
.arg(FilterToString(filter))); |
342 |
.arg(FilterToString(filter))); |
396 |
|
343 |
|
397 |
gl_context->MakeCurrent(true); |
|
|
398 |
|
399 |
OpenGLFilter *temp = new OpenGLFilter(); |
344 |
OpenGLFilter *temp = new OpenGLFilter(); |
400 |
|
345 |
|
401 |
temp->numInputs = 1; |
346 |
temp->numInputs = 1; |
|
|
347 |
GLuint program = 0; |
402 |
|
348 |
|
403 |
if ((filter == kGLFilterLinearBlendDeint) || |
349 |
if (filter == kGLFilterBicubic) |
404 |
(filter == kGLFilterKernelDeint) || |
|
|
405 |
(filter == kGLFilterFieldOrderDFR)) |
406 |
{ |
407 |
temp->numInputs = 2; |
408 |
} |
409 |
else if ((filter == kGLFilterYUV2RGB) || |
410 |
(filter == kGLFilterOneFieldDeintDFR) || |
411 |
(filter == kGLFilterKernelDeintDFR) || |
412 |
(filter == kGLFilterLinearBlendDeintDFR)) |
413 |
{ |
350 |
{ |
414 |
temp->numInputs = 3; |
351 |
if (helperTexture) |
415 |
} |
352 |
gl_context->DeleteTexture(helperTexture); |
416 |
else if ((filter == kGLFilterYUV2RGBA)) |
353 |
|
417 |
{ |
354 |
helperTexture = gl_context->CreateHelperTexture(); |
418 |
temp->numInputs = 4; |
355 |
if (!helperTexture) |
|
|
356 |
success = false; |
419 |
} |
357 |
} |
420 |
|
358 |
|
421 |
GLuint program = 0; |
|
|
422 |
if (filter != kGLFilterNone && filter != kGLFilterResize) |
359 |
if (filter != kGLFilterNone && filter != kGLFilterResize) |
423 |
{ |
360 |
{ |
424 |
program = AddFragmentProgram(filter); |
361 |
program = AddFragmentProgram(filter); |
425 |
if (!program) |
362 |
if (!program) |
426 |
return false; |
363 |
success = false; |
|
|
364 |
else |
365 |
temp->fragmentPrograms.push_back(program); |
427 |
} |
366 |
} |
428 |
|
367 |
|
429 |
temp->fragmentProgram = program; |
|
|
430 |
temp->outputBuffer = kDefaultBuffer; |
368 |
temp->outputBuffer = kDefaultBuffer; |
431 |
temp->rotateFrameBuffers = false; |
|
|
432 |
|
369 |
|
433 |
temp->frameBuffers.clear(); |
370 |
temp->frameBuffers.clear(); |
434 |
temp->frameBufferTextures.clear(); |
371 |
temp->frameBufferTextures.clear(); |
435 |
|
372 |
|
436 |
filters[filter] = temp; |
373 |
filters[filter] = temp; |
437 |
|
374 |
|
438 |
if (OptimiseFilters()) |
375 |
success &= OptimiseFilters(); |
|
|
376 |
|
377 |
if (success) |
439 |
return true; |
378 |
return true; |
440 |
|
379 |
|
441 |
RemoveFilter(filter); |
380 |
RemoveFilter(filter); |
|
|
381 |
filters.erase(filter); |
442 |
|
382 |
|
443 |
return false; |
383 |
return false; |
444 |
} |
384 |
} |
Lines 449-531
Link Here
|
449 |
if (!filters.count(filter)) |
389 |
if (!filters.count(filter)) |
450 |
return true; |
390 |
return true; |
451 |
|
391 |
|
452 |
VERBOSE(VB_PLAYBACK, QString("Removing %1 filter") |
392 |
VERBOSE(VB_PLAYBACK, LOC + QString("Removing %1 filter") |
453 |
.arg(FilterToString(filter))); |
393 |
.arg(FilterToString(filter))); |
454 |
|
394 |
|
455 |
gl_context->MakeCurrent(true); |
|
|
456 |
|
457 |
gl_context->DeleteFragmentProgram(filters[filter]->fragmentProgram); |
458 |
|
459 |
vector<GLuint> temp; |
395 |
vector<GLuint> temp; |
460 |
vector<GLuint>::iterator it; |
396 |
vector<GLuint>::iterator it; |
461 |
|
397 |
|
462 |
temp = filters[filter]->frameBuffers; |
398 |
temp = filters[filter]->fragmentPrograms; |
463 |
for (it = temp.begin(); it != temp.end(); it++) |
399 |
for (it = temp.begin(); it != temp.end(); it++) |
464 |
gl_context->DeleteFrameBuffer(*it); |
400 |
gl_context->DeleteFragmentProgram(*it); |
|
|
401 |
filters[filter]->fragmentPrograms.clear(); |
465 |
|
402 |
|
466 |
temp = filters[filter]->frameBufferTextures; |
403 |
temp = filters[filter]->frameBuffers; |
467 |
for (it = temp.begin(); it != temp.end(); it++) |
404 |
for (it = temp.begin(); it != temp.end(); it++) |
468 |
gl_context->DeleteTexture((*(it))); |
405 |
gl_context->DeleteFrameBuffer(*it); |
|
|
406 |
filters[filter]->frameBuffers.clear(); |
469 |
|
407 |
|
470 |
filters.erase(filter); |
408 |
DeleteTextures(&(filters[filter]->frameBufferTextures)); |
471 |
|
409 |
|
472 |
gl_context->MakeCurrent(false); |
410 |
delete filters[filter]; |
473 |
|
411 |
|
474 |
return true; |
412 |
return true; |
475 |
} |
413 |
} |
476 |
|
414 |
|
477 |
// locking ok |
415 |
// locking ok |
478 |
bool OpenGLVideo::AddDeinterlacer(const QString &filter) |
416 |
void OpenGLVideo::TearDownDeinterlacer(void) |
479 |
{ |
417 |
{ |
480 |
QString current_deinterlacer = GetDeinterlacer(); |
418 |
if (!filters.count(kGLFilterYUV2RGB)) |
|
|
419 |
return; |
481 |
|
420 |
|
482 |
if (current_deinterlacer == filter) |
421 |
OpenGLFilter *tmp = filters[kGLFilterYUV2RGB]; |
|
|
422 |
|
423 |
if (tmp->fragmentPrograms.size() == 3) |
424 |
{ |
425 |
gl_context->DeleteFragmentProgram(tmp->fragmentPrograms[2]); |
426 |
tmp->fragmentPrograms.pop_back(); |
427 |
} |
428 |
|
429 |
if (tmp->fragmentPrograms.size() == 2) |
430 |
{ |
431 |
gl_context->DeleteFragmentProgram(tmp->fragmentPrograms[1]); |
432 |
tmp->fragmentPrograms.pop_back(); |
433 |
} |
434 |
|
435 |
DeleteTextures(&referenceTextures); |
436 |
} |
437 |
|
438 |
bool OpenGLVideo::AddDeinterlacer(const QString &deinterlacer) |
439 |
{ |
440 |
OpenGLContextLocker ctx_lock(gl_context); |
441 |
|
442 |
if (!filters.count(kGLFilterYUV2RGB)) |
443 |
return false; |
444 |
|
445 |
if (hardwareDeinterlacer == deinterlacer) |
483 |
return true; |
446 |
return true; |
484 |
|
447 |
|
485 |
if (!current_deinterlacer.isEmpty()) |
448 |
TearDownDeinterlacer(); |
486 |
RemoveFilter(current_deinterlacer); |
449 |
|
|
|
450 |
bool success = true; |
487 |
|
451 |
|
488 |
return AddFilter(filter); |
452 |
uint ref_size = 2; |
|
|
453 |
|
454 |
if (deinterlacer == "openglbobdeint" || |
455 |
deinterlacer == "openglonefield" || |
456 |
deinterlacer == "opengldoubleratefieldorder") |
457 |
{ |
458 |
ref_size = 0; |
459 |
} |
460 |
|
461 |
if (ref_size > 0) |
462 |
{ |
463 |
bool use_pbo = gl_features & kGLExtPBufObj; |
464 |
|
465 |
for (; ref_size > 0; ref_size--) |
466 |
{ |
467 |
GLuint tex = CreateVideoTexture(actual_video_dim, inputTextureSize, use_pbo); |
468 |
if (tex) |
469 |
{ |
470 |
referenceTextures.push_back(tex); |
471 |
} |
472 |
else |
473 |
{ |
474 |
success = false; |
475 |
} |
476 |
} |
477 |
} |
478 |
|
479 |
uint prog1 = AddFragmentProgram(kGLFilterYUV2RGB, |
480 |
deinterlacer, kScan_Interlaced); |
481 |
uint prog2 = AddFragmentProgram(kGLFilterYUV2RGB, |
482 |
deinterlacer, kScan_Intr2ndField); |
483 |
|
484 |
if (prog1 && prog2) |
485 |
{ |
486 |
filters[kGLFilterYUV2RGB]->fragmentPrograms.push_back(prog1); |
487 |
filters[kGLFilterYUV2RGB]->fragmentPrograms.push_back(prog2); |
488 |
} |
489 |
else |
490 |
{ |
491 |
success = false; |
492 |
} |
493 |
|
494 |
if (success) |
495 |
{ |
496 |
CheckResize(hardwareDeinterlacing); |
497 |
hardwareDeinterlacer = deinterlacer; |
498 |
return true; |
499 |
} |
500 |
|
501 |
hardwareDeinterlacer = ""; |
502 |
TearDownDeinterlacer(); |
503 |
|
504 |
return false; |
489 |
} |
505 |
} |
490 |
|
506 |
|
491 |
// locking ok |
507 |
// locking ok |
492 |
uint OpenGLVideo::AddFragmentProgram(OpenGLFilterType name) |
508 |
uint OpenGLVideo::AddFragmentProgram(OpenGLFilterType name, |
|
|
509 |
QString deint, FrameScanType field) |
493 |
{ |
510 |
{ |
494 |
if (!gl_context->IsFeatureSupported(kGLExtFragProg)) |
511 |
if (!(gl_features & kGLExtFragProg)) |
495 |
{ |
512 |
{ |
496 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Fragment programs not supported"); |
513 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Fragment programs not supported"); |
497 |
return 0; |
514 |
return 0; |
498 |
} |
515 |
} |
499 |
|
516 |
|
500 |
QString program = GetProgramString(name); |
517 |
QString program = GetProgramString(name, deint, field); |
501 |
QString texType = (gl_context->IsFeatureSupported(kGLExtRect)) ? "RECT" : "2D"; |
|
|
502 |
program.replace("%1", texType); |
503 |
|
518 |
|
504 |
uint ret; |
519 |
uint ret; |
505 |
if (gl_context->CreateFragmentProgram(program, ret)) |
520 |
if (gl_context->CreateFragmentProgram(program, ret)) |
506 |
{ |
|
|
507 |
VERBOSE(VB_PLAYBACK, LOC + QString("Created fragment program %1.") |
508 |
.arg(FilterToString(name))); |
509 |
|
510 |
return ret; |
521 |
return ret; |
511 |
} |
|
|
512 |
|
522 |
|
513 |
return 0; |
523 |
return 0; |
514 |
} |
524 |
} |
515 |
|
525 |
|
516 |
// locking ok |
526 |
// locking ok |
517 |
bool OpenGLVideo::AddFrameBuffer(uint &framebuffer, |
527 |
bool OpenGLVideo::AddFrameBuffer(uint &framebuffer, QSize fb_size, |
518 |
uint &texture, QSize size) |
528 |
uint &texture, QSize vid_size) |
519 |
{ |
529 |
{ |
520 |
if (!gl_context->IsFeatureSupported(kGLExtFBufObj)) |
530 |
if (!(gl_features & kGLExtFBufObj)) |
521 |
{ |
531 |
{ |
522 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Framebuffer binding not supported."); |
532 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Framebuffer binding not supported."); |
523 |
return false; |
533 |
return false; |
524 |
} |
534 |
} |
525 |
|
535 |
|
526 |
texture = gl_context->CreateTexture(); |
536 |
texture = gl_context->CreateTexture(fb_size, vid_size, false, textureType); |
527 |
|
537 |
|
528 |
bool ok = gl_context->CreateFrameBuffer(framebuffer, texture, size); |
538 |
bool ok = gl_context->CreateFrameBuffer(framebuffer, texture); |
529 |
|
539 |
|
530 |
if (!ok) |
540 |
if (!ok) |
531 |
gl_context->DeleteTexture(texture); |
541 |
gl_context->DeleteTexture(texture); |
Lines 536-543
Link Here
|
536 |
// locking ok |
546 |
// locking ok |
537 |
void OpenGLVideo::SetViewPort(const QSize &viewPortSize) |
547 |
void OpenGLVideo::SetViewPort(const QSize &viewPortSize) |
538 |
{ |
548 |
{ |
539 |
uint w = max(viewPortSize.width(), videoSize.width()); |
549 |
uint w = max(viewPortSize.width(), video_dim.width()); |
540 |
uint h = max(viewPortSize.height(), videoSize.height()); |
550 |
uint h = max(viewPortSize.height(), video_dim.height()); |
541 |
|
551 |
|
542 |
viewportSize = QSize(w, h); |
552 |
viewportSize = QSize(w, h); |
543 |
|
553 |
|
Lines 546-605
Link Here
|
546 |
|
556 |
|
547 |
VERBOSE(VB_PLAYBACK, LOC + QString("Viewport: %1x%2") |
557 |
VERBOSE(VB_PLAYBACK, LOC + QString("Viewport: %1x%2") |
548 |
.arg(w).arg(h)); |
558 |
.arg(w).arg(h)); |
549 |
|
559 |
gl_context->SetViewPort(viewportSize); |
550 |
SetViewPortPrivate(viewportSize); |
|
|
551 |
} |
552 |
|
553 |
void OpenGLVideo::SetViewPortPrivate(const QSize &viewPortSize) |
554 |
{ |
555 |
glViewport(0, 0, viewPortSize.width(), viewPortSize.height()); |
556 |
glMatrixMode(GL_PROJECTION); |
557 |
glLoadIdentity(); |
558 |
glOrtho(0, viewPortSize.width() - 1, |
559 |
0, viewPortSize.height() - 1, 1, -1); // aargh... |
560 |
glMatrixMode(GL_MODELVIEW); |
561 |
glLoadIdentity(); |
562 |
} |
563 |
|
564 |
// locking ok |
565 |
void OpenGLVideo::InitOpenGL(void) |
566 |
{ |
567 |
gl_context->MakeCurrent(true); |
568 |
glDisable(GL_BLEND); |
569 |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // for gl osd |
570 |
glDisable(GL_DEPTH_TEST); |
571 |
glDepthMask(GL_FALSE); |
572 |
glDisable(GL_CULL_FACE); |
573 |
gl_context->EnableTextures();; |
574 |
glShadeModel(GL_FLAT); |
575 |
glDisable(GL_POLYGON_SMOOTH); |
576 |
glDisable(GL_LINE_SMOOTH); |
577 |
glDisable(GL_POINT_SMOOTH); |
578 |
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
579 |
glClear(GL_COLOR_BUFFER_BIT); |
580 |
glFlush(); |
581 |
gl_context->MakeCurrent(false); |
582 |
} |
560 |
} |
583 |
|
561 |
|
584 |
// locking ok |
562 |
// locking ok |
585 |
uint OpenGLVideo::CreateVideoTexture(QSize size, QSize &tex_size) |
563 |
uint OpenGLVideo::CreateVideoTexture(QSize size, QSize &tex_size, |
|
|
564 |
bool use_pbo) |
586 |
{ |
565 |
{ |
587 |
uint tmp_tex = gl_context->CreateTexture(); |
|
|
588 |
|
589 |
QSize temp = GetTextureSize(size); |
566 |
QSize temp = GetTextureSize(size); |
|
|
567 |
uint tmp_tex = gl_context->CreateTexture(temp, size, use_pbo, |
568 |
textureType); |
590 |
|
569 |
|
591 |
if ((temp.width() > (int)gl_context->GetMaxTexSize()) || |
570 |
if (!tmp_tex) |
592 |
(temp.height() > (int)gl_context->GetMaxTexSize()) || |
|
|
593 |
!gl_context->SetupTexture(temp, tmp_tex, GL_LINEAR)) |
594 |
{ |
571 |
{ |
595 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Could not create texture."); |
572 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Could not create texture."); |
596 |
gl_context->DeleteTexture(tmp_tex); |
|
|
597 |
return 0; |
573 |
return 0; |
598 |
} |
574 |
} |
599 |
|
575 |
|
600 |
tex_size = temp; |
576 |
tex_size = temp; |
601 |
|
577 |
|
602 |
VERBOSE(VB_PLAYBACK, LOC + QString("Created main input texture %1x%2") |
578 |
VERBOSE(VB_PLAYBACK, LOC + QString("Created texture (%1x%2)") |
603 |
.arg(temp.width()).arg(temp.height())); |
579 |
.arg(temp.width()).arg(temp.height())); |
604 |
|
580 |
|
605 |
return tmp_tex; |
581 |
return tmp_tex; |
Lines 608-614
Link Here
|
608 |
// locking ok |
584 |
// locking ok |
609 |
QSize OpenGLVideo::GetTextureSize(const QSize &size) |
585 |
QSize OpenGLVideo::GetTextureSize(const QSize &size) |
610 |
{ |
586 |
{ |
611 |
if (gl_context->IsFeatureSupported(kGLExtRect)) |
587 |
if (textureRects) |
612 |
return size; |
588 |
return size; |
613 |
|
589 |
|
614 |
int w = 64; |
590 |
int w = 64; |
Lines 628-637
Link Here
|
628 |
} |
604 |
} |
629 |
|
605 |
|
630 |
// locking ok |
606 |
// locking ok |
631 |
void OpenGLVideo::UpdateInputFrame(const VideoFrame *frame) |
607 |
void OpenGLVideo::UpdateInputFrame(const VideoFrame *frame, bool soft_bob) |
632 |
{ |
608 |
{ |
633 |
if (frame->width != videoSize.width() || |
609 |
OpenGLContextLocker ctx_lock(gl_context); |
634 |
frame->height != videoSize.height() || |
610 |
|
|
|
611 |
if (frame->width != actual_video_dim.width() || |
612 |
frame->height != actual_video_dim.height() || |
635 |
frame->width < 1 || |
613 |
frame->width < 1 || |
636 |
frame->height < 1) |
614 |
frame->height < 1) |
637 |
{ |
615 |
{ |
Lines 641-704
Link Here
|
641 |
|
619 |
|
642 |
if (filters.count(kGLFilterYUV2RGB) && (frame->codec == FMT_YV12)) |
620 |
if (filters.count(kGLFilterYUV2RGB) && (frame->codec == FMT_YV12)) |
643 |
{ |
621 |
{ |
644 |
UpdateInput(frame->buf, frame->offsets, 0, FMT_YV12, videoSize); |
622 |
if (hardwareDeinterlacing) |
|
|
623 |
RotateTextures(); |
624 |
|
625 |
gl_context->UpdateTexture(inputTextures[0], frame->buf, |
626 |
frame->offsets, frame->pitches, FMT_YV12, |
627 |
frame->interlaced_frame && !soft_bob); |
628 |
inputUpdated = true; |
645 |
return; |
629 |
return; |
646 |
} |
630 |
} |
647 |
|
631 |
|
648 |
// software yuv2rgb |
632 |
// software yuv2rgb |
649 |
if (convertSize != videoSize) |
633 |
if (convertSize != actual_video_dim) |
650 |
{ |
634 |
{ |
651 |
ShutDownYUV2RGB(); |
635 |
ShutDownYUV2RGB(); |
652 |
|
636 |
|
653 |
VERBOSE(VB_PLAYBACK, LOC + "Init software conversion."); |
637 |
VERBOSE(VB_PLAYBACK, LOC + "Init software conversion."); |
654 |
|
638 |
|
655 |
convertSize = videoSize; |
639 |
convertSize = actual_video_dim; |
656 |
convertBuf = new unsigned char[ |
640 |
convertBuf = new unsigned char[ |
657 |
(videoSize.width() * videoSize.height() * 3) + 128]; |
641 |
(actual_video_dim.width() * actual_video_dim.height() * 4) + 128]; |
658 |
} |
642 |
} |
659 |
|
643 |
|
660 |
if (convertBuf) |
644 |
if (convertBuf) |
661 |
{ |
645 |
{ |
662 |
AVPicture img_in, img_out; |
646 |
AVPicture img_in, img_out; |
663 |
|
647 |
|
664 |
avpicture_fill(&img_out, (uint8_t *)convertBuf, PIX_FMT_RGB24, |
648 |
avpicture_fill(&img_out, (uint8_t *)convertBuf, PIX_FMT_BGRA, |
665 |
convertSize.width(), convertSize.height()); |
649 |
convertSize.width(), convertSize.height()); |
666 |
avpicture_fill(&img_in, (uint8_t *)frame->buf, PIX_FMT_YUV420P, |
650 |
avpicture_fill(&img_in, (uint8_t *)frame->buf, PIX_FMT_YUV420P, |
667 |
convertSize.width(), convertSize.height()); |
651 |
convertSize.width(), convertSize.height()); |
668 |
img_convert(&img_out, PIX_FMT_RGB24, |
652 |
img_convert(&img_out, PIX_FMT_BGRA, |
669 |
&img_in, PIX_FMT_YUV420P, |
653 |
&img_in, PIX_FMT_YUV420P, |
670 |
convertSize.width(), convertSize.height()); |
654 |
convertSize.width(), convertSize.height()); |
671 |
|
655 |
|
672 |
int offset = 0; |
656 |
int offset = 0; |
673 |
UpdateInput(convertBuf, &offset, 0, FMT_RGB24, convertSize); |
657 |
gl_context->UpdateTexture(inputTextures[0], convertBuf, |
|
|
658 |
&offset, &offset, FMT_BGRA); |
674 |
} |
659 |
} |
|
|
660 |
|
661 |
inputUpdated = true; |
675 |
} |
662 |
} |
676 |
|
663 |
|
677 |
// locking ok |
664 |
// locking ok |
678 |
void OpenGLVideo::UpdateInput(const unsigned char *buf, const int *offsets, |
665 |
void OpenGLVideo::UpdateInput(const unsigned char *buf, const int *offsets, |
679 |
uint texture_index, int format, QSize size) |
666 |
int format, QSize size, |
|
|
667 |
const unsigned char *alpha) |
680 |
{ |
668 |
{ |
681 |
inputUpdated = false; |
669 |
OpenGLContextLocker ctx_lock(gl_context); |
682 |
|
670 |
|
683 |
if (texture_index >= inputTextures.size()) |
671 |
if (size.width() != actual_video_dim.width() || |
|
|
672 |
size.height() != actual_video_dim.height() || |
673 |
format != FMT_YV12 || !alpha) |
684 |
return; |
674 |
return; |
685 |
|
675 |
|
686 |
copy_pixels_to_texture( |
676 |
int pitches[3] = {size.width(), size.width() >> 1, size.width() >> 1}; |
687 |
buf + offsets[0], format, size, |
677 |
|
688 |
inputTextures[texture_index], gl_context->GetTextureType()); |
678 |
gl_context->UpdateTexture(inputTextures[0], buf, |
689 |
|
679 |
offsets, pitches, FMT_YV12, |
690 |
if (FMT_YV12 == format) |
680 |
false, alpha); |
691 |
{ |
|
|
692 |
QSize chroma_size(size.width() >> 1, size.height() >> 1); |
693 |
copy_pixels_to_texture( |
694 |
buf + offsets[1], format, chroma_size, |
695 |
inputTextures[texture_index + 1], |
696 |
gl_context->GetTextureType()); |
697 |
copy_pixels_to_texture( |
698 |
buf + offsets[2], format, chroma_size, |
699 |
inputTextures[texture_index + 2], |
700 |
gl_context->GetTextureType()); |
701 |
} |
702 |
|
681 |
|
703 |
inputUpdated = true; |
682 |
inputUpdated = true; |
704 |
} |
683 |
} |
Lines 718-731
Link Here
|
718 |
// TODO shouldn't this take a QSize, not QRect? |
697 |
// TODO shouldn't this take a QSize, not QRect? |
719 |
void OpenGLVideo::SetVideoResize(const QRect &rect) |
698 |
void OpenGLVideo::SetVideoResize(const QRect &rect) |
720 |
{ |
699 |
{ |
721 |
bool abort = ((rect.right() > videoSize.width()) || |
700 |
OpenGLContextLocker ctx_lock(gl_context); |
722 |
(rect.bottom() > videoSize.height()) || |
701 |
|
723 |
(rect.width() > videoSize.width()) || |
702 |
bool abort = ((rect.right() > video_dim.width()) || |
724 |
(rect.height() > videoSize.height())); |
703 |
(rect.bottom() > video_dim.height()) || |
|
|
704 |
(rect.width() > video_dim.width()) || |
705 |
(rect.height() > video_dim.height())); |
725 |
|
706 |
|
726 |
// if resize == existing frame, no need to carry on |
707 |
// if resize == existing frame, no need to carry on |
727 |
|
708 |
|
728 |
abort |= !rect.left() && !rect.top() && (rect.size() == videoSize); |
709 |
abort |= !rect.left() && !rect.top() && (rect.size() == video_dim); |
729 |
|
710 |
|
730 |
if (!abort) |
711 |
if (!abort) |
731 |
{ |
712 |
{ |
Lines 740-745
Link Here
|
740 |
// locking ok |
721 |
// locking ok |
741 |
void OpenGLVideo::DisableVideoResize(void) |
722 |
void OpenGLVideo::DisableVideoResize(void) |
742 |
{ |
723 |
{ |
|
|
724 |
OpenGLContextLocker ctx_lock(gl_context); |
725 |
|
743 |
videoResize = false; |
726 |
videoResize = false; |
744 |
videoResizeRect = QRect(0, 0, 0, 0); |
727 |
videoResizeRect = QRect(0, 0, 0, 0); |
745 |
} |
728 |
} |
Lines 749-767
Link Here
|
749 |
{ |
732 |
{ |
750 |
// FIXME video aspect == display aspect |
733 |
// FIXME video aspect == display aspect |
751 |
|
734 |
|
752 |
if ((videoSize.height() <= 0) || (videoSize.width() <= 0)) |
735 |
if ((video_dim.height() <= 0) || (video_dim.width() <= 0)) |
753 |
return; |
736 |
return; |
754 |
|
737 |
|
755 |
float height = visibleRect.height(); |
738 |
float height = display_visible_rect.height(); |
756 |
float new_top = height - ((float)videoResizeRect.bottom() / |
739 |
float new_top = height - ((float)videoResizeRect.bottom() / |
757 |
(float)videoSize.height()) * height; |
740 |
(float)video_dim.height()) * height; |
758 |
float new_bottom = height - ((float)videoResizeRect.top() / |
741 |
float new_bottom = height - ((float)videoResizeRect.top() / |
759 |
(float)videoSize.height()) * height; |
742 |
(float)video_dim.height()) * height; |
760 |
|
743 |
|
761 |
left = (((float) videoResizeRect.left() / (float) videoSize.width()) * |
744 |
left = (((float) videoResizeRect.left() / (float) video_dim.width()) * |
762 |
visibleRect.width()); |
745 |
display_visible_rect.width()); |
763 |
right = (((float) videoResizeRect.right() / (float) videoSize.width()) * |
746 |
right = (((float) videoResizeRect.right() / (float) video_dim.width()) * |
764 |
visibleRect.width()); |
747 |
display_visible_rect.width()); |
765 |
|
748 |
|
766 |
top = new_top; |
749 |
top = new_top; |
767 |
bottom = new_bottom; |
750 |
bottom = new_bottom; |
Lines 773-809
Link Here
|
773 |
if (deinterlacing == hardwareDeinterlacing) |
756 |
if (deinterlacing == hardwareDeinterlacing) |
774 |
return; |
757 |
return; |
775 |
|
758 |
|
776 |
VERBOSE(VB_PLAYBACK, LOC + QString("Turning %1 deinterlacing.") |
|
|
777 |
.arg(deinterlacing ? "on" : "off")); |
778 |
|
779 |
hardwareDeinterlacing = deinterlacing; |
759 |
hardwareDeinterlacing = deinterlacing; |
780 |
|
760 |
|
781 |
glfilt_map_t::iterator it = filters.begin(); |
761 |
OpenGLContextLocker ctx_lock(gl_context); |
782 |
for (; it != filters.end(); it++) |
762 |
CheckResize(hardwareDeinterlacing); |
783 |
{ |
|
|
784 |
it->second->outputBuffer = kFrameBufferObject; |
785 |
|
786 |
if ((it->first >= kGLFilterLinearBlendDeint) && |
787 |
(it->first <= kGLFilterOneFieldDeintDFR) && |
788 |
!deinterlacing) |
789 |
{ |
790 |
it->second->outputBuffer = kNoBuffer; |
791 |
} |
792 |
} |
793 |
|
794 |
glfilt_map_t::reverse_iterator rit = filters.rbegin(); |
795 |
for (; rit != filters.rend(); rit++) |
796 |
{ |
797 |
if (rit->second->outputBuffer == kFrameBufferObject) |
798 |
{ |
799 |
rit->second->outputBuffer = kDefaultBuffer; |
800 |
break; |
801 |
} |
802 |
} |
803 |
|
804 |
gl_context->MakeCurrent(true); |
805 |
SetFiltering(); |
806 |
gl_context->MakeCurrent(false); |
807 |
} |
763 |
} |
808 |
|
764 |
|
809 |
// locking ok |
765 |
// locking ok |
Lines 813-836
Link Here
|
813 |
if (inputTextures.empty() || filters.empty()) |
769 |
if (inputTextures.empty() || filters.empty()) |
814 |
return; |
770 |
return; |
815 |
|
771 |
|
|
|
772 |
OpenGLContextLocker ctx_lock(gl_context); |
773 |
|
774 |
// enable correct texture type |
775 |
gl_context->EnableTextures(inputTextures[0]); |
776 |
|
816 |
vector<GLuint> inputs = inputTextures; |
777 |
vector<GLuint> inputs = inputTextures; |
817 |
QSize inputsize = inputTextureSize; |
778 |
QSize inputsize = inputTextureSize; |
|
|
779 |
QSize realsize = GetTextureSize(video_dim); |
818 |
uint numfilters = filters.size(); |
780 |
uint numfilters = filters.size(); |
819 |
|
781 |
|
820 |
glfilt_map_t::iterator it; |
782 |
glfilt_map_t::iterator it; |
821 |
for (it = filters.begin(); it != filters.end(); it++) |
783 |
for (it = filters.begin(); it != filters.end(); it++) |
822 |
{ |
784 |
{ |
823 |
if (it->second->rotateFrameBuffers && |
|
|
824 |
!(it->first == kGLFilterYUV2RGB && scan == kScan_Intr2ndField)) |
825 |
{ |
826 |
Rotate(&(it->second->frameBufferTextures)); |
827 |
Rotate(&(it->second->frameBuffers)); |
828 |
} |
829 |
|
830 |
// skip disabled filters |
831 |
if (it->second->outputBuffer == kNoBuffer) |
832 |
continue; |
833 |
|
834 |
OpenGLFilterType type = it->first; |
785 |
OpenGLFilterType type = it->first; |
835 |
OpenGLFilter *filter = it->second; |
786 |
OpenGLFilter *filter = it->second; |
836 |
|
787 |
|
Lines 838-874
Link Here
|
838 |
if (!inputUpdated && type == kGLFilterYUV2RGBA) |
789 |
if (!inputUpdated && type == kGLFilterYUV2RGBA) |
839 |
{ |
790 |
{ |
840 |
inputs = filter->frameBufferTextures; |
791 |
inputs = filter->frameBufferTextures; |
841 |
inputsize = videoSize; |
792 |
inputsize = realsize; |
842 |
continue; |
|
|
843 |
} |
844 |
|
845 |
// skip colour conversion for frames already in frame buffer |
846 |
if (!inputUpdated && (frame == currentFrameNum) && |
847 |
(type == kGLFilterYUV2RGB) && (frame != 0) && |
848 |
(!(softwareDeinterlacing && softwareDeinterlacer == "bobdeint"))) |
849 |
{ |
850 |
inputs = filter->frameBufferTextures; |
851 |
inputsize = videoSize; |
852 |
continue; |
793 |
continue; |
853 |
} |
794 |
} |
854 |
|
795 |
|
855 |
// texture coordinates |
796 |
// texture coordinates |
856 |
float t_right = (float)videoSize.width(); |
797 |
float t_right = (float)video_dim.width(); |
857 |
float t_bottom = (float)videoSize.height(); |
798 |
float t_bottom = (float)video_dim.height(); |
858 |
float t_top = 0.0f; |
799 |
float t_top = 0.0f; |
859 |
float t_left = 0.0f; |
800 |
float t_left = 0.0f; |
860 |
float trueheight = (float)videoSize.height(); |
801 |
float trueheight = (float)video_dim.height(); |
861 |
|
802 |
|
862 |
// only apply overscan on last filter |
803 |
// only apply overscan on last filter |
863 |
if (filter->outputBuffer == kDefaultBuffer) |
804 |
if (filter->outputBuffer == kDefaultBuffer) |
864 |
{ |
805 |
{ |
865 |
t_left = (float)frameRect.left(); |
806 |
t_left = (float)video_rect.left(); |
866 |
t_right = (float)frameRect.width() + t_left; |
807 |
t_right = (float)video_rect.width() + t_left; |
867 |
t_top = (float)frameRect.top(); |
808 |
t_top = (float)video_rect.top(); |
868 |
t_bottom = (float)frameRect.height() + t_top; |
809 |
t_bottom = (float)video_rect.height() + t_top; |
869 |
} |
810 |
} |
870 |
|
811 |
|
871 |
if (!gl_context->IsFeatureSupported(kGLExtRect) && |
812 |
if (!textureRects && |
872 |
(inputsize.width() > 0) && (inputsize.height() > 0)) |
813 |
(inputsize.width() > 0) && (inputsize.height() > 0)) |
873 |
{ |
814 |
{ |
874 |
t_right /= inputsize.width(); |
815 |
t_right /= inputsize.width(); |
Lines 878-913
Link Here
|
878 |
trueheight /= inputsize.height(); |
819 |
trueheight /= inputsize.height(); |
879 |
} |
820 |
} |
880 |
|
821 |
|
881 |
float line_height = (trueheight / (float)videoSize.height()); |
822 |
// software bobdeint |
882 |
float bob = line_height / 2.0f; |
823 |
if ((softwareDeinterlacer == "bobdeint") && |
883 |
|
824 |
softwareDeinterlacing && |
884 |
if (type == kGLFilterBobDeintDFR) |
825 |
(filter->outputBuffer == kDefaultBuffer)) |
885 |
{ |
826 |
{ |
886 |
if (scan == kScan_Interlaced) |
827 |
float bob = (trueheight / (float)video_dim.height()) / 4.0f; |
887 |
{ |
|
|
888 |
t_bottom += bob; |
889 |
t_top += bob; |
890 |
} |
891 |
if (scan == kScan_Intr2ndField) |
828 |
if (scan == kScan_Intr2ndField) |
892 |
{ |
829 |
{ |
893 |
t_bottom -= bob; |
|
|
894 |
t_top -= bob; |
895 |
} |
896 |
} |
897 |
|
898 |
if (softwareDeinterlacer == "bobdeint" && |
899 |
softwareDeinterlacing && (type == kGLFilterYUV2RGB || |
900 |
(type == kGLFilterResize && numfilters == 1))) |
901 |
{ |
902 |
bob = line_height / 4.0f; |
903 |
if (scan == kScan_Interlaced) |
904 |
{ |
905 |
t_top /= 2; |
830 |
t_top /= 2; |
906 |
t_bottom /= 2; |
831 |
t_bottom /= 2; |
907 |
t_bottom += bob; |
832 |
t_bottom += bob; |
908 |
t_top += bob; |
833 |
t_top += bob; |
909 |
} |
834 |
} |
910 |
if (scan == kScan_Intr2ndField) |
835 |
if (scan == kScan_Interlaced) |
911 |
{ |
836 |
{ |
912 |
t_top = (trueheight / 2) + (t_top / 2); |
837 |
t_top = (trueheight / 2) + (t_top / 2); |
913 |
t_bottom = (trueheight / 2) + (t_bottom / 2); |
838 |
t_bottom = (trueheight / 2) + (t_bottom / 2); |
Lines 916-951
Link Here
|
916 |
} |
841 |
} |
917 |
} |
842 |
} |
918 |
|
843 |
|
919 |
float t_right_uv = t_right; |
|
|
920 |
float t_top_uv = t_top; |
921 |
float t_bottom_uv = t_bottom; |
922 |
float t_left_uv = t_left; |
923 |
|
924 |
if (gl_context->IsFeatureSupported(kGLExtRect)) |
925 |
{ |
926 |
t_right_uv /= 2; |
927 |
t_top_uv /= 2; |
928 |
t_bottom_uv /= 2; |
929 |
t_left_uv /= 2; |
930 |
} |
931 |
|
932 |
// vertex coordinates |
844 |
// vertex coordinates |
933 |
QRect display = (filter->frameBuffers.empty() || |
845 |
QRect display = (filter->frameBuffers.empty() || |
934 |
filter->outputBuffer == kDefaultBuffer) ? |
846 |
filter->outputBuffer == kDefaultBuffer) ? |
935 |
videoRect : frameBufferRect; |
847 |
display_video_rect : frameBufferRect; |
936 |
|
848 |
|
937 |
float vleft = display.left(); |
849 |
float vleft = display.left(); |
938 |
float vright = display.right(); |
850 |
float vright = display.right(); |
939 |
float vtop = display.top(); |
851 |
float vtop = display.top(); |
940 |
float vbot = display.bottom(); |
852 |
float vbot = display.bottom(); |
941 |
|
853 |
|
|
|
854 |
// hardware bobdeint |
855 |
if (filter->outputBuffer == kDefaultBuffer && |
856 |
hardwareDeinterlacing && |
857 |
hardwareDeinterlacer == "openglbobdeint") |
858 |
{ |
859 |
float bob = ((float)display.height() / (float)video_dim.height()) |
860 |
/ 2.0f; |
861 |
if (scan == kScan_Interlaced) |
862 |
{ |
863 |
vbot -= bob; |
864 |
vtop -= bob; |
865 |
} |
866 |
if (scan == kScan_Intr2ndField) |
867 |
{ |
868 |
vbot += bob; |
869 |
vtop += bob; |
870 |
} |
871 |
} |
872 |
|
942 |
// resize for interactive tv |
873 |
// resize for interactive tv |
943 |
if (videoResize && filter->outputBuffer == kDefaultBuffer) |
874 |
if (videoResize && filter->outputBuffer == kDefaultBuffer) |
944 |
CalculateResize(vleft, vtop, vright, vbot); |
875 |
CalculateResize(vleft, vtop, vright, vbot); |
945 |
|
876 |
|
946 |
if (invertVideo && |
877 |
// invert horizontally |
947 |
((type == kGLFilterYUV2RGB) || (type == kGLFilterYUV2RGBA)) || |
878 |
if (((type == kGLFilterYUV2RGB) || (type == kGLFilterYUV2RGBA)) || |
948 |
((type == kGLFilterResize) && (numfilters == 1))) |
879 |
(filter->outputBuffer == kDefaultBuffer && numfilters == 1)) |
949 |
{ |
880 |
{ |
950 |
float temp = vtop; |
881 |
float temp = vtop; |
951 |
vtop = vbot; |
882 |
vtop = vbot; |
Lines 956-973
Link Here
|
956 |
switch (filter->outputBuffer) |
887 |
switch (filter->outputBuffer) |
957 |
{ |
888 |
{ |
958 |
case kDefaultBuffer: |
889 |
case kDefaultBuffer: |
959 |
if (frameBuffer) |
|
|
960 |
gl_context->BindFramebuffer(frameBuffer); |
961 |
|
962 |
// clear the buffer |
890 |
// clear the buffer |
963 |
if (viewportControl) |
891 |
if (viewportControl) |
964 |
{ |
892 |
{ |
965 |
glClear(GL_COLOR_BUFFER_BIT); |
893 |
glClear(GL_COLOR_BUFFER_BIT); |
966 |
SetViewPortPrivate(visibleRect.size()); |
894 |
gl_context->SetViewPort(display_visible_rect.size()); |
967 |
} |
895 |
} |
968 |
else |
896 |
else |
969 |
{ |
897 |
{ |
970 |
SetViewPortPrivate(masterViewportSize); |
898 |
gl_context->SetViewPort(masterViewportSize); |
971 |
} |
899 |
} |
972 |
|
900 |
|
973 |
break; |
901 |
break; |
Lines 976-1031
Link Here
|
976 |
if (!filter->frameBuffers.empty()) |
904 |
if (!filter->frameBuffers.empty()) |
977 |
{ |
905 |
{ |
978 |
gl_context->BindFramebuffer(filter->frameBuffers[0]); |
906 |
gl_context->BindFramebuffer(filter->frameBuffers[0]); |
979 |
SetViewPortPrivate(frameBufferRect.size()); |
907 |
gl_context->SetViewPort(frameBufferRect.size()); |
980 |
} |
908 |
} |
981 |
break; |
909 |
break; |
982 |
|
910 |
|
983 |
case kNoBuffer: |
911 |
default: |
984 |
continue; |
912 |
continue; |
985 |
} |
913 |
} |
986 |
|
914 |
|
987 |
// bind correct textures |
915 |
// bind correct textures |
988 |
for (uint i = 0; i < inputs.size(); i++) |
916 |
uint active_tex = 0; |
|
|
917 |
for (; active_tex < inputs.size(); active_tex++) |
989 |
{ |
918 |
{ |
990 |
glActiveTexture(GL_TEXTURE0 + i); |
919 |
glActiveTexture(GL_TEXTURE0 + active_tex); |
991 |
glBindTexture(gl_context->GetTextureType(), inputs[i]); |
920 |
glBindTexture(textureType, inputs[active_tex]); |
|
|
921 |
} |
922 |
|
923 |
if (!referenceTextures.empty() && |
924 |
hardwareDeinterlacing && |
925 |
type == kGLFilterYUV2RGB) |
926 |
{ |
927 |
uint max = inputs.size() + referenceTextures.size(); |
928 |
uint ref = 0; |
929 |
for (; active_tex < max; active_tex++, ref++) |
930 |
{ |
931 |
glActiveTexture(GL_TEXTURE0 + active_tex); |
932 |
glBindTexture(textureType, referenceTextures[ref]); |
933 |
} |
934 |
} |
935 |
|
936 |
if (helperTexture && type == kGLFilterBicubic) |
937 |
{ |
938 |
glActiveTexture(GL_TEXTURE0 + active_tex); |
939 |
glBindTexture(GL_TEXTURE_1D/*N.B.*/, helperTexture); |
992 |
} |
940 |
} |
993 |
|
941 |
|
994 |
// enable fragment program and set any environment variables |
942 |
// enable fragment program and set any environment variables |
995 |
if ((type != kGLFilterNone) && (type != kGLFilterResize)) |
943 |
if ((type != kGLFilterNone) && (type != kGLFilterResize)) |
996 |
{ |
944 |
{ |
997 |
glEnable(GL_FRAGMENT_PROGRAM_ARB); |
945 |
glEnable(GL_FRAGMENT_PROGRAM_ARB); |
998 |
gl_context->BindFragmentProgram(filter->fragmentProgram); |
946 |
GLuint program = 0; |
999 |
float field = -line_height; |
947 |
|
|
|
948 |
if (type == kGLFilterYUV2RGB) |
949 |
{ |
950 |
if (hardwareDeinterlacing && |
951 |
filter->fragmentPrograms.size() == 3) |
952 |
{ |
953 |
if (scan == kScan_Interlaced) |
954 |
program = 1; |
955 |
else if (scan == kScan_Intr2ndField) |
956 |
program = 2; |
957 |
} |
958 |
} |
959 |
|
960 |
gl_context->BindFragmentProgram(filter->fragmentPrograms[program]); |
1000 |
|
961 |
|
1001 |
switch (type) |
962 |
switch (type) |
1002 |
{ |
963 |
{ |
1003 |
case kGLFilterYUV2RGB: |
964 |
case kGLFilterYUV2RGB: |
1004 |
case kGLFilterYUV2RGBA: |
965 |
case kGLFilterYUV2RGBA: |
1005 |
if (useColourControl) |
966 |
if (useColourControl) |
1006 |
{ |
967 |
gl_context->SetColourParams(); |
1007 |
gl_context->InitFragmentParams( |
|
|
1008 |
0, |
1009 |
pictureAttribs[kPictureAttribute_Brightness], |
1010 |
pictureAttribs[kPictureAttribute_Contrast], |
1011 |
pictureAttribs[kPictureAttribute_Colour], |
1012 |
0.0f); |
1013 |
} |
1014 |
break; |
1015 |
|
1016 |
case kGLFilterBobDeintDFR: |
1017 |
case kGLFilterOneFieldDeintDFR: |
1018 |
case kGLFilterKernelDeintDFR: |
1019 |
case kGLFilterFieldOrderDFR: |
1020 |
case kGLFilterLinearBlendDeintDFR: |
1021 |
if (scan == kScan_Intr2ndField) |
1022 |
field *= -1; |
1023 |
|
1024 |
case kGLFilterOneFieldDeint: |
1025 |
case kGLFilterKernelDeint: |
1026 |
case kGLFilterLinearBlendDeint: |
1027 |
gl_context->InitFragmentParams( |
1028 |
0, line_height * 2.0f, field, 0.0f, 0.0f); |
1029 |
break; |
968 |
break; |
1030 |
|
969 |
|
1031 |
case kGLFilterNone: |
970 |
case kGLFilterNone: |
Lines 1041-1083
Link Here
|
1041 |
// draw quad |
980 |
// draw quad |
1042 |
glBegin(GL_QUADS); |
981 |
glBegin(GL_QUADS); |
1043 |
glTexCoord2f(t_left, t_top); |
982 |
glTexCoord2f(t_left, t_top); |
1044 |
if (type == kGLFilterYUV2RGB || type == kGLFilterYUV2RGBA) |
|
|
1045 |
{ |
1046 |
glMultiTexCoord2f(GL_TEXTURE1, t_left_uv, t_top_uv); |
1047 |
glMultiTexCoord2f(GL_TEXTURE2, t_left_uv, t_top_uv); |
1048 |
if (type == kGLFilterYUV2RGBA) |
1049 |
glMultiTexCoord2f(GL_TEXTURE3, t_left_uv, t_top_uv); |
1050 |
} |
1051 |
glVertex2f(vleft, vtop); |
983 |
glVertex2f(vleft, vtop); |
1052 |
|
984 |
|
1053 |
glTexCoord2f(t_right, t_top); |
985 |
glTexCoord2f(t_right, t_top); |
1054 |
if (type == kGLFilterYUV2RGB || type == kGLFilterYUV2RGBA) |
|
|
1055 |
{ |
1056 |
glMultiTexCoord2f(GL_TEXTURE1, t_right_uv, t_top_uv); |
1057 |
glMultiTexCoord2f(GL_TEXTURE2, t_right_uv, t_top_uv); |
1058 |
if (type == kGLFilterYUV2RGBA) |
1059 |
glMultiTexCoord2f(GL_TEXTURE3, t_right, t_top); |
1060 |
} |
1061 |
glVertex2f(vright, vtop); |
986 |
glVertex2f(vright, vtop); |
1062 |
|
987 |
|
1063 |
glTexCoord2f(t_right, t_bottom); |
988 |
glTexCoord2f(t_right, t_bottom); |
1064 |
if (type == kGLFilterYUV2RGB || type == kGLFilterYUV2RGBA) |
|
|
1065 |
{ |
1066 |
glMultiTexCoord2f(GL_TEXTURE1, t_right_uv, t_bottom_uv); |
1067 |
glMultiTexCoord2f(GL_TEXTURE2, t_right_uv, t_bottom_uv); |
1068 |
if (type == kGLFilterYUV2RGBA) |
1069 |
glMultiTexCoord2f(GL_TEXTURE3, t_right, t_bottom); |
1070 |
} |
1071 |
glVertex2f(vright, vbot); |
989 |
glVertex2f(vright, vbot); |
1072 |
|
990 |
|
1073 |
glTexCoord2f(t_left, t_bottom); |
991 |
glTexCoord2f(t_left, t_bottom); |
1074 |
if (type == kGLFilterYUV2RGB || type == kGLFilterYUV2RGBA) |
|
|
1075 |
{ |
1076 |
glMultiTexCoord2f(GL_TEXTURE1, t_left_uv, t_bottom_uv); |
1077 |
glMultiTexCoord2f(GL_TEXTURE2, t_left_uv, t_bottom_uv); |
1078 |
if (type == kGLFilterYUV2RGBA) |
1079 |
glMultiTexCoord2f(GL_TEXTURE3, t_left_uv, t_bottom); |
1080 |
} |
1081 |
glVertex2f(vleft, vbot); |
992 |
glVertex2f(vleft, vbot); |
1082 |
glEnd(); |
993 |
glEnd(); |
1083 |
|
994 |
|
Lines 1093-1168
Link Here
|
1093 |
} |
1004 |
} |
1094 |
|
1005 |
|
1095 |
// switch back to default framebuffer |
1006 |
// switch back to default framebuffer |
1096 |
if (filter->outputBuffer != kDefaultBuffer || frameBuffer) |
1007 |
if (filter->outputBuffer != kDefaultBuffer) |
1097 |
gl_context->BindFramebuffer(0); |
1008 |
gl_context->BindFramebuffer(0); |
1098 |
|
1009 |
|
1099 |
inputs = filter->frameBufferTextures; |
1010 |
inputs = filter->frameBufferTextures; |
1100 |
inputsize = videoSize; |
1011 |
inputsize = realsize; |
1101 |
} |
1012 |
} |
1102 |
|
1013 |
|
1103 |
currentFrameNum = frame; |
1014 |
currentFrameNum = frame; |
1104 |
inputUpdated = false; |
1015 |
inputUpdated = false; |
1105 |
} |
1016 |
} |
1106 |
|
1017 |
|
1107 |
void OpenGLVideo::Rotate(vector<GLuint> *target) |
1018 |
void OpenGLVideo::RotateTextures(void) |
1108 |
{ |
1019 |
{ |
1109 |
if (target->size() < 2) |
1020 |
if (referenceTextures.size() < 2) |
1110 |
return; |
1021 |
return; |
1111 |
|
1022 |
|
1112 |
GLuint tmp = (*target)[target->size() - 1]; |
1023 |
GLuint tmp = referenceTextures[referenceTextures.size() - 1]; |
1113 |
for (uint i = target->size() - 1; i > 0; i--) |
|
|
1114 |
(*target)[i] = (*target)[i - 1]; |
1115 |
|
1024 |
|
1116 |
(*target)[0] = tmp; |
1025 |
for (uint i = referenceTextures.size() - 1; i > 0; i--) |
|
|
1026 |
referenceTextures[i] = referenceTextures[i - 1]; |
1027 |
|
1028 |
referenceTextures[0] = inputTextures[0]; |
1029 |
inputTextures[0] = tmp; |
1117 |
} |
1030 |
} |
1118 |
|
1031 |
|
1119 |
// locking ok |
1032 |
void OpenGLVideo::DeleteTextures(vector<uint> *textures) |
1120 |
int OpenGLVideo::SetPictureAttribute( |
|
|
1121 |
PictureAttribute attribute, int newValue) |
1122 |
{ |
1033 |
{ |
1123 |
if (!useColourControl) |
1034 |
if ((*textures).empty()) |
1124 |
return -1; |
1035 |
return; |
1125 |
|
|
|
1126 |
int ret = -1; |
1127 |
switch (attribute) |
1128 |
{ |
1129 |
case kPictureAttribute_Brightness: |
1130 |
ret = newValue; |
1131 |
pictureAttribs[attribute] = (newValue * 0.02f) - 0.5f; |
1132 |
break; |
1133 |
case kPictureAttribute_Contrast: |
1134 |
case kPictureAttribute_Colour: |
1135 |
ret = newValue; |
1136 |
pictureAttribs[attribute] = (newValue * 0.02f); |
1137 |
break; |
1138 |
case kPictureAttribute_Hue: // not supported yet... |
1139 |
break; |
1140 |
default: |
1141 |
break; |
1142 |
} |
1143 |
|
1144 |
return ret; |
1145 |
} |
1146 |
|
1036 |
|
1147 |
PictureAttributeSupported |
1037 |
for (uint i = 0; i < (*textures).size(); i++) |
1148 |
OpenGLVideo::GetSupportedPictureAttributes(void) const |
1038 |
gl_context->DeleteTexture((*textures)[i]); |
1149 |
{ |
1039 |
(*textures).clear(); |
1150 |
return (!useColourControl) ? |
|
|
1151 |
kPictureAttributeSupported_None : |
1152 |
(PictureAttributeSupported) |
1153 |
(kPictureAttributeSupported_Brightness | |
1154 |
kPictureAttributeSupported_Contrast | |
1155 |
kPictureAttributeSupported_Colour); |
1156 |
} |
1040 |
} |
1157 |
|
1041 |
|
1158 |
// locking ok |
1042 |
// locking ok |
1159 |
void OpenGLVideo::SetTextureFilters(vector<GLuint> *textures, int filt) |
1043 |
void OpenGLVideo::SetTextureFilters(vector<GLuint> *textures, |
|
|
1044 |
int filt, int wrap) |
1160 |
{ |
1045 |
{ |
1161 |
if (textures->empty()) |
1046 |
if (textures->empty()) |
1162 |
return; |
1047 |
return; |
1163 |
|
1048 |
|
1164 |
for (uint i = 0; i < textures->size(); i++) |
1049 |
for (uint i = 0; i < textures->size(); i++) |
1165 |
gl_context->SetupTextureFilters((*textures)[i], filt); |
1050 |
gl_context->SetTextureFilters((*textures)[i], filt, wrap); |
1166 |
} |
1051 |
} |
1167 |
|
1052 |
|
1168 |
// locking ok |
1053 |
// locking ok |
Lines 1174-1197
Link Here
|
1174 |
ret = kGLFilterYUV2RGB; |
1059 |
ret = kGLFilterYUV2RGB; |
1175 |
else if (filter.contains("osd")) |
1060 |
else if (filter.contains("osd")) |
1176 |
ret = kGLFilterYUV2RGBA; |
1061 |
ret = kGLFilterYUV2RGBA; |
1177 |
else if (filter.contains("openglkerneldeint")) |
|
|
1178 |
ret = kGLFilterKernelDeint; |
1179 |
else if (filter.contains("opengllinearblend")) |
1180 |
ret = kGLFilterLinearBlendDeint; |
1181 |
else if (filter.contains("openglonefield")) |
1182 |
ret = kGLFilterOneFieldDeint; |
1183 |
else if (filter.contains("openglbobdeint")) |
1184 |
ret = kGLFilterBobDeintDFR; |
1185 |
else if (filter.contains("opengldoubleratelinearblend")) |
1186 |
ret = kGLFilterLinearBlendDeintDFR; |
1187 |
else if (filter.contains("opengldoubleratekerneldeint")) |
1188 |
ret = kGLFilterKernelDeintDFR; |
1189 |
else if (filter.contains("opengldoublerateonefield")) |
1190 |
ret = kGLFilterOneFieldDeintDFR; |
1191 |
else if (filter.contains("opengldoubleratefieldorder")) |
1192 |
ret = kGLFilterFieldOrderDFR; |
1193 |
else if (filter.contains("resize")) |
1062 |
else if (filter.contains("resize")) |
1194 |
ret = kGLFilterResize; |
1063 |
ret = kGLFilterResize; |
|
|
1064 |
else if (filter.contains("bicubic")) |
1065 |
ret = kGLFilterBicubic; |
1195 |
|
1066 |
|
1196 |
return ret; |
1067 |
return ret; |
1197 |
} |
1068 |
} |
Lines 1207-1500
Link Here
|
1207 |
return "master"; |
1078 |
return "master"; |
1208 |
case kGLFilterYUV2RGBA: |
1079 |
case kGLFilterYUV2RGBA: |
1209 |
return "osd"; |
1080 |
return "osd"; |
1210 |
case kGLFilterKernelDeint: |
|
|
1211 |
return "openglkerneldeint"; |
1212 |
case kGLFilterLinearBlendDeint: |
1213 |
return "opengllinearblend"; |
1214 |
case kGLFilterOneFieldDeint: |
1215 |
return "openglonefield"; |
1216 |
case kGLFilterBobDeintDFR: |
1217 |
return "openglbobdeint"; |
1218 |
case kGLFilterLinearBlendDeintDFR: |
1219 |
return "opengldoubleratelinearblend"; |
1220 |
case kGLFilterKernelDeintDFR: |
1221 |
return "opengldoubleratekerneldeint"; |
1222 |
case kGLFilterOneFieldDeintDFR: |
1223 |
return "opengldoublerateonefield"; |
1224 |
case kGLFilterFieldOrderDFR: |
1225 |
return "opengldoubleratefieldorder"; |
1226 |
case kGLFilterResize: |
1081 |
case kGLFilterResize: |
1227 |
return "resize"; |
1082 |
return "resize"; |
|
|
1083 |
case kGLFilterBicubic: |
1084 |
return "bicubic"; |
1228 |
} |
1085 |
} |
1229 |
|
1086 |
|
1230 |
return ""; |
1087 |
return ""; |
1231 |
} |
1088 |
} |
1232 |
|
1089 |
|
1233 |
static const QString yuv2rgb1a = |
1090 |
static const QString attrib_fast = |
1234 |
"ATTRIB ytex = fragment.texcoord[0];" |
1091 |
"ATTRIB tex = fragment.texcoord[0];\n"; |
1235 |
"ATTRIB uvtex = fragment.texcoord[1];" |
|
|
1236 |
"TEMP res, tmp;"; |
1237 |
|
1238 |
static const QString yuv2rgb1b = |
1239 |
"TEMP alpha;" |
1240 |
"TEX alpha, ytex, texture[3], %1;"; |
1241 |
|
1242 |
static const QString yuv2rgb1c = |
1243 |
"TEX res, ytex, texture[0], %1;" |
1244 |
"TEX tmp.x, uvtex, texture[1], %1;" |
1245 |
"TEX tmp.y, uvtex, texture[2], %1;"; |
1246 |
|
1247 |
static const QString yuv2rgb2 = |
1248 |
"PARAM adj = program.env[0];" |
1249 |
"SUB res, res, 0.5;" |
1250 |
"MAD res, res, adj.yyyy, adj.xxxx;" |
1251 |
"SUB tmp, tmp, { 0.5, 0.5 };" |
1252 |
"MAD tmp, adj.zzzz, tmp, 0.5;"; |
1253 |
|
1254 |
static const QString yuv2rgb3 = |
1255 |
"MAD res, res, 1.164, -0.063;" |
1256 |
"SUB tmp, tmp, { 0.5, 0.5 };" |
1257 |
"MAD res, { 0, -.392, 2.017 }, tmp.xxxw, res;"; |
1258 |
|
1259 |
static const QString yuv2rgb4 = |
1260 |
"MAD result.color, { 1.596, -.813, 0, 0 }, tmp.yyyw, res;"; |
1261 |
|
1092 |
|
1262 |
static const QString yuv2rgb5 = |
1093 |
static const QString var_alpha = |
1263 |
"MAD result.color, { 0, -.813, 1.596, 0 }, tmp.yyyw, res.bgra;"; |
1094 |
"TEMP alpha;\n"; |
1264 |
|
1095 |
|
1265 |
static const QString yuv2rgb6 = |
1096 |
static const QString tex_alpha = |
1266 |
"MOV result.color.a, alpha.a;"; |
1097 |
"TEX alpha, tex, texture[3], %1;\n"; |
1267 |
|
1098 |
|
1268 |
// locking ok |
1099 |
static const QString tex_fast = |
1269 |
QString OpenGLVideo::GetProgramString(OpenGLFilterType name) |
1100 |
"TEX res, tex, texture[0], %1;\n"; |
|
|
1101 |
|
1102 |
static const QString param_colour = |
1103 |
"PARAM adj = program.env[0];\n"; |
1104 |
|
1105 |
static const QString calc_colour_fast = |
1106 |
"SUB res, res, 0.5;\n" |
1107 |
"MAD res, res, adj.zzzy, adj.wwwx;\n"; |
1108 |
|
1109 |
static const QString end_alpha = |
1110 |
"MOV result.color.a, alpha.a;\n"; |
1111 |
|
1112 |
static const QString var_fast = |
1113 |
"TEMP tmp, res;\n"; |
1114 |
|
1115 |
static const QString calc_fast_alpha = |
1116 |
"MOV result.color.a, res.g;\n"; |
1117 |
|
1118 |
static const QString end_fast = |
1119 |
"SUB tmp, res.rbgg, { 0.5, 0.5 };\n" |
1120 |
"MAD res, res.a, 1.164, -0.063;\n" |
1121 |
"MAD res, { 0, -.392, 2.017 }, tmp.xxxw, res;\n" |
1122 |
"MAD result.color, { 1.596, -.813, 0, 0 }, tmp.yyyw, res;\n"; |
1123 |
|
1124 |
static const QString end_fast_alpha = |
1125 |
"SUB tmp, res.rbgg, { 0.5, 0.5 };\n" |
1126 |
"MAD res, res.a, 1.164, -0.063;\n" |
1127 |
"MAD res, { 0, -.392, 2.017 }, tmp.xxxw, res;\n" |
1128 |
"MAD result.color.rgb, { 1.596, -.813, 0, 0 }, tmp.yyyw, res;\n"; |
1129 |
|
1130 |
static const QString var_deint = |
1131 |
"TEMP other, current, mov, prev;\n"; |
1132 |
|
1133 |
static const QString field_calc = |
1134 |
"MUL prev, tex.yyyy, %2;\n" |
1135 |
"FRC prev, prev;\n" |
1136 |
"SUB prev, prev, 0.5;\n"; |
1137 |
|
1138 |
static const QString bobdeint[2] = { |
1139 |
field_calc + |
1140 |
"ADD other, tex, {0.0, %3, 0.0, 0.0};\n" |
1141 |
"TEX other, other, texture[0], %1;\n" |
1142 |
"CMP res, prev, res, other;\n", |
1143 |
field_calc + |
1144 |
"SUB other, tex, {0.0, %3, 0.0, 0.0};\n" |
1145 |
"TEX other, other, texture[0], %1;\n" |
1146 |
"CMP res, prev, other, res;\n" |
1147 |
}; |
1148 |
|
1149 |
static const QString deint_end_top = |
1150 |
"CMP other, mov, current, other;\n" |
1151 |
"CMP res, prev, current, other;\n"; |
1152 |
|
1153 |
static const QString deint_end_bot = |
1154 |
"CMP other, mov, current, other;\n" |
1155 |
"CMP res, prev, other, current;\n"; |
1156 |
|
1157 |
static const QString motion_calc = |
1158 |
"ABS mov, mov;\n" |
1159 |
"SUB mov, mov, 0.07;\n"; |
1160 |
|
1161 |
static const QString motion_top = |
1162 |
"SUB mov, prev, current;\n" + motion_calc; |
1163 |
|
1164 |
static const QString motion_bot = |
1165 |
"SUB mov, res, current;\n" + motion_calc; |
1166 |
|
1167 |
static const QString doublerateonefield[2] = { |
1168 |
"TEX current, tex, texture[1], %1;\n" |
1169 |
"TEX prev, tex, texture[2], %1;\n" |
1170 |
"ADD other, tex, {0.0, %3, 0.0, 0.0};\n" |
1171 |
"TEX other, other, texture[1], %1;\n" |
1172 |
+ motion_top + field_calc + deint_end_top, |
1173 |
|
1174 |
"TEX current, tex, texture[1], %1;\n" |
1175 |
"SUB other, tex, {0.0, %3, 0.0, 0.0};\n" |
1176 |
"TEX other, other, texture[1], %1;\n" |
1177 |
+ motion_bot + field_calc + deint_end_bot |
1178 |
}; |
1179 |
|
1180 |
static const QString linearblend[2] = { |
1181 |
"TEX current, tex, texture[1], %1;\n" |
1182 |
"TEX prev, tex, texture[2], %1;\n" |
1183 |
"ADD other, tex, {0.0, %3, 0.0, 0.0};\n" |
1184 |
"TEX other, other, texture[1], %1;\n" |
1185 |
"SUB mov, tex, {0.0, %3, 0.0, 0.0};\n" |
1186 |
"TEX mov, mov, texture[1], %1;\n" |
1187 |
"LRP other, 0.5, other, mov;\n" |
1188 |
+ motion_top + field_calc + deint_end_top, |
1189 |
|
1190 |
"TEX current, tex, texture[1], %1;\n" |
1191 |
"SUB other, tex, {0.0, %3, 0.0, 0.0};\n" |
1192 |
"TEX other, other, texture[1], %1;\n" |
1193 |
"ADD mov, tex, {0.0, %3, 0.0, 0.0};\n" |
1194 |
"TEX mov, mov, texture[1], %1;\n" |
1195 |
"LRP other, 0.5, other, mov;\n" |
1196 |
+ motion_bot + field_calc + deint_end_bot |
1197 |
}; |
1198 |
|
1199 |
static const QString kerneldeint[2] = { |
1200 |
"TEX current, tex, texture[1], %1;\n" |
1201 |
"TEX prev, tex, texture[2], %1;\n" |
1202 |
+ motion_top + |
1203 |
"MUL other, 0.125, prev;\n" |
1204 |
"MAD other, 0.125, current, other;\n" |
1205 |
"ADD prev, tex, {0.0, %3, 0.0, 0.0};\n" |
1206 |
"TEX prev, prev, texture[1], %1;\n" |
1207 |
"MAD other, 0.5, prev, other;\n" |
1208 |
"SUB prev, tex, {0.0, %3, 0.0, 0.0};\n" |
1209 |
"TEX prev, prev, texture[1], %1;\n" |
1210 |
"MAD other, 0.5, prev, other;\n" |
1211 |
"ADD prev, tex, {0.0, %4, 0.0, 0.0};\n" |
1212 |
"TEX mov, prev, texture[1], %1;\n" |
1213 |
"MAD other, -0.0625, mov, other;\n" |
1214 |
"TEX mov, prev, texture[2], %1;\n" |
1215 |
"MAD other, -0.0625, mov, other;\n" |
1216 |
"SUB prev, tex, {0.0, %4, 0.0, 0.0};\n" |
1217 |
"TEX mov, prev, texture[1], %1;\n" |
1218 |
"MAD other, -0.0625, mov, other;\n" |
1219 |
"TEX mov, prev, texture[2], %1;\n" |
1220 |
"MAD other, -0.0625, mov, other;\n" |
1221 |
+ field_calc + deint_end_top, |
1222 |
|
1223 |
"TEX current, tex, texture[1], %1;\n" |
1224 |
+ motion_bot + |
1225 |
"MUL other, 0.125, res;\n" |
1226 |
"MAD other, 0.125, current, other;\n" |
1227 |
"ADD prev, tex, {0.0, %3, 0.0, 0.0};\n" |
1228 |
"TEX prev, prev, texture[1], %1;\n" |
1229 |
"MAD other, 0.5, prev, other;\n" |
1230 |
"SUB prev, tex, {0.0, %3, 0.0, 0.0};\n" |
1231 |
"TEX prev, prev, texture[1], %1;\n" |
1232 |
"MAD other, 0.5, prev, other;\n" |
1233 |
"ADD prev, tex, {0.0, %4, 0.0, 0.0};\n" |
1234 |
"TEX mov, prev, texture[1], %1;\n" |
1235 |
"MAD other, -0.0625, mov, other;\n" |
1236 |
"TEX mov, prev, texture[0], %1;\n" |
1237 |
"MAD other, -0.0625, mov, other;\n" |
1238 |
"SUB prev, tex, {0.0, %4, 0.0, 0.0};\n" |
1239 |
"TEX mov, prev, texture[1], %1;\n" |
1240 |
"MAD other, -0.0625, mov, other;\n" |
1241 |
"TEX mov, prev, texture[0], %1;\n" |
1242 |
"MAD other, -0.0625, mov, other;\n" |
1243 |
+ field_calc + deint_end_bot |
1244 |
}; |
1245 |
|
1246 |
static const QString yadif_setup = |
1247 |
"TEMP a,b,c,e,f,g,h,j,k,l;\n" |
1248 |
"TEMP a1,b1,f1,g1,h1,i1,j1,l1,m1,n1;\n" |
1249 |
"ALIAS d1 = f;\n" |
1250 |
"ALIAS k1 = g;\n" |
1251 |
"ALIAS c1 = prev;\n" |
1252 |
"ALIAS e1 = mov;\n" |
1253 |
"ALIAS p0 = res;\n" |
1254 |
"ALIAS p1 = c;\n" |
1255 |
"ALIAS p3 = h;\n" |
1256 |
"ALIAS spred1 = a;\n" |
1257 |
"ALIAS spred2 = b;\n" |
1258 |
"ALIAS spred3 = c;\n" |
1259 |
"ALIAS spred4 = e;\n" |
1260 |
"ALIAS spred5 = f;\n" |
1261 |
"ALIAS sscore = g;\n" |
1262 |
"ALIAS score1 = h;\n" |
1263 |
"ALIAS score2 = j;\n" |
1264 |
"ALIAS score3 = k;\n" |
1265 |
"ALIAS score4 = l;\n" |
1266 |
"ALIAS if1 = a1;\n" |
1267 |
"ALIAS if2 = b1;\n" |
1268 |
"TEMP p2, p4;\n" |
1269 |
"ALIAS diff1 = a;\n" |
1270 |
"ALIAS diff2 = b;\n" |
1271 |
"TEMP diff0;\n"; |
1272 |
|
1273 |
static const QString yadif_spatial_sample = |
1274 |
"ADD tmp, tex, {%5, %3, 0.0, 0.0};\n" |
1275 |
"TEX e1, tmp, texture[1], %1;\n" |
1276 |
"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1277 |
"TEX f1, tmp, texture[1], %1;\n" |
1278 |
"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1279 |
"TEX g1, tmp, texture[1], %1;\n" |
1280 |
"SUB tmp, tmp, {0.0, %4, 0.0, 0.0};\n" |
1281 |
"TEX n1, tmp, texture[1], %1;\n" |
1282 |
"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1283 |
"TEX m1, tmp, texture[1], %1;\n" |
1284 |
"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1285 |
"TEX l1, tmp, texture[1], %1;\n" |
1286 |
|
1287 |
"SUB tmp, tex, {%5, %3, 0.0, 0.0};\n" |
1288 |
"TEX j1, tmp, texture[1], %1;\n" |
1289 |
"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1290 |
"TEX i1, tmp, texture[1], %1;\n" |
1291 |
"SUB tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1292 |
"TEX h1, tmp, texture[1], %1;\n" |
1293 |
"ADD tmp, tmp, {0.0, %4, 0.0, 0.0};\n" |
1294 |
"TEX a1, tmp, texture[1], %1;\n" |
1295 |
"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1296 |
"TEX b1, tmp, texture[1], %1;\n" |
1297 |
"ADD tmp, tmp, {%5, 0.0, 0.0, 0.0};\n" |
1298 |
"TEX c1, tmp, texture[1], %1;\n"; |
1299 |
|
1300 |
static const QString yadif_calc = |
1301 |
"LRP p0, 0.5, c, h;\n" |
1302 |
"MOV p1, f;\n" |
1303 |
"LRP p2, 0.5, d, i;\n" |
1304 |
"MOV p3, g;\n" |
1305 |
"LRP p4, 0.5, e, j;\n" |
1306 |
|
1307 |
"SUB diff0, d, i;\n" |
1308 |
"ABS diff0, diff0;\n" |
1309 |
"SUB tmp, a, f;\n" |
1310 |
"ABS tmp, tmp;\n" |
1311 |
"SUB diff1, b, g;\n" |
1312 |
"ABS diff1, diff1;\n" |
1313 |
"LRP diff1, 0.5, diff1, tmp;\n" |
1314 |
"SUB tmp, k, f;\n" |
1315 |
"ABS tmp, tmp;\n" |
1316 |
"SUB diff2, g, l;\n" |
1317 |
"ABS diff2, diff2;\n" |
1318 |
"LRP diff2, 0.5, diff2, tmp;\n" |
1319 |
"MAX diff0, diff0, diff1;\n" |
1320 |
"MAX diff0, diff0, diff2;\n" |
1321 |
|
1322 |
// mode < 2 |
1323 |
"SUB tmp, p0, p1;\n" |
1324 |
"SUB other, p4, p3;\n" |
1325 |
"MIN spred1, tmp, other;\n" |
1326 |
"MAX spred2, tmp, other;\n" |
1327 |
"SUB tmp, p2, p1;\n" |
1328 |
"SUB other, p2, p3;\n" |
1329 |
"MAX spred1, spred1, tmp;\n" |
1330 |
"MAX spred1, spred1, other;\n" |
1331 |
"MIN spred2, spred2, tmp;\n" |
1332 |
"MIN spred2, spred2, other;\n" |
1333 |
"MAX spred1, spred2, -spred1;\n" |
1334 |
"MAX diff0, diff0, spred1;\n" |
1335 |
|
1336 |
// spatial prediction |
1337 |
"LRP spred1, 0.5, d1, k1;\n" |
1338 |
"LRP spred2, 0.5, c1, l1;\n" |
1339 |
"LRP spred3, 0.5, b1, m1;\n" |
1340 |
"LRP spred4, 0.5, e1, j1;\n" |
1341 |
"LRP spred5, 0.5, f1, i1;\n" |
1342 |
|
1343 |
"SUB sscore, c1, j1;\n" |
1344 |
"ABS sscore, sscore;\n" |
1345 |
"SUB tmp, d1, k1;\n" |
1346 |
"ABS tmp, tmp;\n" |
1347 |
"ADD sscore, sscore, tmp;\n" |
1348 |
"SUB tmp, e1, l1;\n" |
1349 |
"ABS tmp, tmp;\n" |
1350 |
"ADD sscore, sscore, tmp;\n" |
1351 |
"SUB sscore, sscore, 1.0;\n" |
1352 |
|
1353 |
"SUB score1, b1, k1;\n" |
1354 |
"ABS score1, score1;\n" |
1355 |
"SUB tmp, c1, l1;\n" |
1356 |
"ABS tmp, tmp;\n" |
1357 |
"ADD score1, score1, tmp;\n" |
1358 |
"SUB tmp, d1, m1;\n" |
1359 |
"ABS tmp, tmp;\n" |
1360 |
"ADD score1, score1, tmp;\n" |
1361 |
|
1362 |
"SUB score2, a1, l1;\n" |
1363 |
"ABS score2, score2;\n" |
1364 |
"SUB tmp, b1, m1;\n" |
1365 |
"ABS tmp, tmp;\n" |
1366 |
"ADD score2, score2, tmp;\n" |
1367 |
"SUB tmp, c1, n1;\n" |
1368 |
"ABS tmp, tmp;\n" |
1369 |
"ADD score2, score2, tmp;\n" |
1370 |
|
1371 |
"SUB score3, d1, i1;\n" |
1372 |
"ABS score3, score3;\n" |
1373 |
"SUB tmp, e1, j1;\n" |
1374 |
"ABS tmp, tmp;\n" |
1375 |
"ADD score3, score3, tmp;\n" |
1376 |
"SUB tmp, f1, k1;\n" |
1377 |
"ABS tmp, tmp;\n" |
1378 |
"ADD score3, score3, tmp;\n" |
1379 |
|
1380 |
"SUB score4, e1, h1;\n" |
1381 |
"ABS score4, score4;\n" |
1382 |
"SUB tmp, f1, i1;\n" |
1383 |
"ABS tmp, tmp;\n" |
1384 |
"ADD score4, score4, tmp;\n" |
1385 |
"SUB tmp, g1, j1;\n" |
1386 |
"ABS tmp, tmp;\n" |
1387 |
"ADD score4, score4, tmp;\n" |
1388 |
"SUB if1, sscore, score1;\n" |
1389 |
"SUB if2, score1, score2;\n" |
1390 |
"CMP if2, if1, -1.0, if2;\n" |
1391 |
"CMP spred1, if1, spred1, spred2;\n" |
1392 |
"CMP spred1, if2, spred1, spred3;\n" |
1393 |
"CMP sscore, if1, sscore, score1;\n" |
1394 |
"CMP sscore, if2, sscore, score2;\n" |
1395 |
"SUB if1, sscore, score3;\n" |
1396 |
"SUB if2, score3, score4;\n" |
1397 |
"CMP if2, if1, -1.0, if2;\n" |
1398 |
"CMP spred1, if1, spred1, spred4;\n" |
1399 |
"CMP spred1, if2, spred1, spred5;\n" |
1400 |
"ADD spred4, p2, diff0;\n" |
1401 |
"SUB spred5, p2, diff0;\n" |
1402 |
"SUB if1, spred4, spred1;\n" |
1403 |
"SUB if2, spred1, spred5;\n" |
1404 |
"CMP spred1, if1, spred4, spred1;\n" |
1405 |
"CMP spred1, if2, spred5, spred1;\n"; |
1406 |
|
1407 |
static const QString yadif[2] = { |
1408 |
yadif_setup + |
1409 |
"TEMP d;\n" |
1410 |
"ALIAS i = current;\n" |
1411 |
"TEX current, tex, texture[1], %1;\n" |
1412 |
"TEX d, tex, texture[2], %1;\n" |
1413 |
"ADD tmp, tex, {0.0, %3, 0.0, 0.0};\n" |
1414 |
"TEX a, tmp, texture[2], %1;\n" |
1415 |
"TEX f, tmp, texture[1], %1;\n" |
1416 |
"TEX k, tmp, texture[0], %1;\n" |
1417 |
"ADD tmp, tex, {0.0, %4, 0.0, 0.0};\n" |
1418 |
"TEX c, tmp, texture[2], %1;\n" |
1419 |
"TEX h, tmp, texture[1], %1;\n" |
1420 |
"SUB tmp, tex, {0.0, %3, 0.0, 0.0};\n" |
1421 |
"TEX b, tmp, texture[2], %1;\n" |
1422 |
"TEX g, tmp, texture[1], %1;\n" |
1423 |
"TEX l, tmp, texture[0], %1;\n" |
1424 |
"SUB tmp, tex, {0.0, %4, 0.0, 0.0};\n" |
1425 |
"TEX e, tmp, texture[2], %1;\n" |
1426 |
"TEX j, tmp, texture[1], %1;\n" |
1427 |
+ yadif_spatial_sample |
1428 |
+ yadif_calc |
1429 |
+ field_calc + |
1430 |
"CMP res, prev, current, spred1;\n" |
1431 |
, |
1432 |
yadif_setup + |
1433 |
"TEMP i;\n" |
1434 |
"ALIAS d = current;\n" |
1435 |
"TEX current, tex, texture[1], %1;\n" |
1436 |
"TEX i, tex, texture[0], %1;\n" |
1437 |
"ADD tmp, tex, {0.0, %3, 0.0, 0.0};\n" |
1438 |
"TEX a, tmp, texture[2], %1;\n" |
1439 |
"TEX f, tmp, texture[1], %1;\n" |
1440 |
"TEX k, tmp, texture[0], %1;\n" |
1441 |
"ADD tmp, tex, {0.0, %4, 0.0, 0.0};\n" |
1442 |
"TEX c, tmp, texture[1], %1;\n" |
1443 |
"TEX h, tmp, texture[0], %1;\n" |
1444 |
"SUB tmp, tex, {0.0, %3, 0.0, 0.0};\n" |
1445 |
"TEX b, tmp, texture[2], %1;\n" |
1446 |
"TEX g, tmp, texture[1], %1;\n" |
1447 |
"TEX l, tmp, texture[0], %1;\n" |
1448 |
"SUB tmp, tex, {0.0, %4, 0.0, 0.0};\n" |
1449 |
"TEX e, tmp, texture[1], %1;\n" |
1450 |
"TEX j, tmp, texture[0], %1;\n" |
1451 |
+ yadif_spatial_sample |
1452 |
+ yadif_calc |
1453 |
+ field_calc + |
1454 |
"CMP res, prev, spred1, current;\n" |
1455 |
}; |
1456 |
|
1457 |
static const QString bicubic = |
1458 |
"TEMP coord, coord2, cdelta, parmx, parmy, a, b, c, d;\n" |
1459 |
"MAD coord.xy, fragment.texcoord[0], {%6, %7}, {0.5, 0.5};\n" |
1460 |
"TEX parmx, coord.x, texture[1], 1D;\n" |
1461 |
"TEX parmy, coord.y, texture[1], 1D;\n" |
1462 |
"MUL cdelta.xz, parmx.rrgg, {-%5, 0, %5, 0};\n" |
1463 |
"MUL cdelta.yw, parmy.rrgg, {0, -%3, 0, %3};\n" |
1464 |
"ADD coord, fragment.texcoord[0].xyxy, cdelta.xyxw;\n" |
1465 |
"ADD coord2, fragment.texcoord[0].xyxy, cdelta.zyzw;\n" |
1466 |
"TEX a, coord.xyxy, texture[0], 2D;\n" |
1467 |
"TEX b, coord.zwzw, texture[0], 2D;\n" |
1468 |
"TEX c, coord2.xyxy, texture[0], 2D;\n" |
1469 |
"TEX d, coord2.zwzw, texture[0], 2D;\n" |
1470 |
"LRP a, parmy.b, a, b;\n" |
1471 |
"LRP c, parmy.b, c, d;\n" |
1472 |
"LRP result.color, parmx.b, a, c;\n"; |
1473 |
|
1474 |
QString OpenGLVideo::GetProgramString(OpenGLFilterType name, |
1475 |
QString deint, FrameScanType field) |
1270 |
{ |
1476 |
{ |
1271 |
QString ret = |
1477 |
QString ret = |
1272 |
"!!ARBfp1.0\n" |
1478 |
"!!ARBfp1.0\n" |
1273 |
"OPTION ARB_precision_hint_fastest;"; |
1479 |
"OPTION ARB_precision_hint_fastest;\n"; |
1274 |
|
1480 |
|
1275 |
switch (name) |
1481 |
switch (name) |
1276 |
{ |
1482 |
{ |
1277 |
case kGLFilterYUV2RGB: |
1483 |
case kGLFilterYUV2RGB: |
1278 |
ret = ret + yuv2rgb1a + yuv2rgb1c; |
1484 |
{ |
1279 |
if (useColourControl) |
1485 |
bool need_tex = true; |
1280 |
ret += yuv2rgb2; |
1486 |
QString deint_bit = ""; |
1281 |
ret += yuv2rgb3; |
1487 |
if (deint != "") |
1282 |
ret += frameBuffer ? yuv2rgb5 : yuv2rgb4; |
1488 |
{ |
1283 |
break; |
1489 |
uint tmp_field = 0; |
|
|
1490 |
if (field == kScan_Intr2ndField) |
1491 |
tmp_field = 1; |
1492 |
if (deint == "openglbobdeint" || |
1493 |
deint == "openglonefield" || |
1494 |
deint == "opengldoubleratefieldorder") |
1495 |
{ |
1496 |
deint_bit = bobdeint[tmp_field]; |
1497 |
} |
1498 |
else if (deint == "opengldoublerateonefield") |
1499 |
{ |
1500 |
deint_bit = doublerateonefield[tmp_field]; |
1501 |
if (!tmp_field) { need_tex = false; } |
1502 |
} |
1503 |
else if (deint == "opengllinearblend" || |
1504 |
deint == "opengldoubleratelinearblend") |
1505 |
{ |
1506 |
deint_bit = linearblend[tmp_field]; |
1507 |
if (!tmp_field) { need_tex = false; } |
1508 |
} |
1509 |
else if (deint == "openglkerneldeint" || |
1510 |
deint == "opengldoubleratekerneldeint") |
1511 |
{ |
1512 |
deint_bit = kerneldeint[tmp_field]; |
1513 |
if (!tmp_field) { need_tex = false; } |
1514 |
} |
1515 |
else if (deint == "openglyadif" || |
1516 |
deint == "opengldoublerateyadif") |
1517 |
{ |
1518 |
deint_bit = yadif[tmp_field]; |
1519 |
need_tex = false; |
1520 |
} |
1521 |
else |
1522 |
{ |
1523 |
VERBOSE(VB_PLAYBACK, LOC + |
1524 |
"Unrecognised OpenGL deinterlacer"); |
1525 |
} |
1526 |
} |
1284 |
|
1527 |
|
1285 |
case kGLFilterYUV2RGBA: |
1528 |
ret += attrib_fast; |
1286 |
ret = ret + yuv2rgb1a + yuv2rgb1b + yuv2rgb1c; |
1529 |
ret += useColourControl ? param_colour : ""; |
1287 |
if (useColourControl) |
1530 |
ret += (deint != "") ? var_deint : ""; |
1288 |
ret += yuv2rgb2; |
1531 |
ret += var_fast + (need_tex ? tex_fast : ""); |
1289 |
ret = ret + yuv2rgb3 + yuv2rgb4 + yuv2rgb6; |
1532 |
ret += deint_bit; |
|
|
1533 |
ret += useColourControl ? calc_colour_fast : ""; |
1534 |
ret += end_fast; |
1535 |
} |
1290 |
break; |
1536 |
break; |
|
|
1537 |
case kGLFilterYUV2RGBA: |
1291 |
|
1538 |
|
1292 |
case kGLFilterKernelDeint: |
1539 |
ret += attrib_fast; |
1293 |
ret += |
1540 |
ret += useColourControl ? param_colour : ""; |
1294 |
"ATTRIB tex = fragment.texcoord[0];" |
1541 |
ret += var_fast + tex_fast + calc_fast_alpha; |
1295 |
"PARAM off = program.env[0];" |
1542 |
ret += useColourControl ? calc_colour_fast : ""; |
1296 |
"TEMP sam, pos, cum, cur, field, mov;" |
1543 |
ret += end_fast_alpha; |
1297 |
"RCP field, off.x;" |
|
|
1298 |
"MUL field, tex.yyyy, field;" |
1299 |
"FRC field, field;" |
1300 |
"SUB field, field, 0.5;" |
1301 |
"TEX sam, tex, texture[1], %1;" |
1302 |
"TEX cur, tex, texture[0], %1;" |
1303 |
"SUB mov, cur, sam;" |
1304 |
"MUL cum, sam, 0.125;" |
1305 |
"MAD cum, cur, 0.125, cum;" |
1306 |
"ABS mov, mov;" |
1307 |
"SUB mov, mov, 0.12;" |
1308 |
"ADD pos, tex, off.wyww;" |
1309 |
"TEX sam, pos, texture[0], %1;" |
1310 |
"MAD cum, sam, 0.5, cum;" |
1311 |
"SUB pos, tex, off.wyww;" |
1312 |
"TEX sam, pos, texture[0], %1;" |
1313 |
"MAD cum, sam, 0.5, cum;" |
1314 |
"MAD pos, off.wyww, 2.0, tex;" |
1315 |
"TEX sam, pos, texture[0], %1;" |
1316 |
"MAD cum, sam, -0.0625, cum;" |
1317 |
"TEX sam, pos, texture[1], %1;" |
1318 |
"MAD cum, sam, -0.0625, cum;" |
1319 |
"MAD pos, off.wyww, -2.0, tex;" |
1320 |
"TEX sam, pos, texture[0], %1;" |
1321 |
"MAD cum, sam, -0.0625, cum;" |
1322 |
"TEX sam, pos, texture[1], %1;" |
1323 |
"MAD cum, sam, -0.0625, cum;" |
1324 |
"CMP cum, mov, cur, cum;" |
1325 |
"CMP result.color, field, cum, cur;"; |
1326 |
break; |
1327 |
|
1544 |
|
1328 |
case kGLFilterLinearBlendDeintDFR: |
|
|
1329 |
ret += |
1330 |
"ATTRIB tex = fragment.texcoord[0];" |
1331 |
"PARAM off = program.env[0];" |
1332 |
"TEMP field, top, bot, current, previous, next, other, mov;" |
1333 |
"TEX next, tex, texture[0], %1;" |
1334 |
"TEX current, tex, texture[1], %1;" |
1335 |
"TEX previous, tex, texture[2], %1;" |
1336 |
"ADD top, tex, off.wyww;" |
1337 |
"TEX other, top, texture[1], %1;" |
1338 |
"SUB top, tex, off.wyww;" |
1339 |
"TEX bot, top, texture[1], %1;" |
1340 |
"LRP other, 0.5, other, bot;" |
1341 |
"RCP field, off.x;" |
1342 |
"MUL field, tex.yyyy, field;" |
1343 |
"FRC field, field;" |
1344 |
"SUB field, field, 0.5;" |
1345 |
"SUB top, current, next;" |
1346 |
"SUB bot, current, previous;" |
1347 |
"CMP mov, field, bot, top;" |
1348 |
"ABS mov, mov;" |
1349 |
"SUB mov, mov, 0.12;" |
1350 |
"CMP other, mov, current, other;" |
1351 |
"CMP top, field, other, current;" |
1352 |
"CMP bot, field, current, other;" |
1353 |
"CMP result.color, off.y, top, bot;"; |
1354 |
break; |
1545 |
break; |
1355 |
|
1546 |
|
1356 |
case kGLFilterOneFieldDeintDFR: |
1547 |
case kGLFilterNone: |
1357 |
ret += |
1548 |
case kGLFilterResize: |
1358 |
"ATTRIB tex = fragment.texcoord[0];" |
|
|
1359 |
"PARAM off = program.env[0];" |
1360 |
"TEMP field, top, bot, current, previous, next, other, mov;" |
1361 |
"TEX next, tex, texture[0], %1;" |
1362 |
"TEX current, tex, texture[1], %1;" |
1363 |
"TEX previous, tex, texture[2], %1;" |
1364 |
"ADD top, tex, off.wyww;" |
1365 |
"TEX other, top, texture[1], %1;" |
1366 |
"RCP field, off.x;" |
1367 |
"MUL field, tex.yyyy, field;" |
1368 |
"FRC field, field;" |
1369 |
"SUB field, field, 0.5;" |
1370 |
"SUB top, current, next;" |
1371 |
"SUB bot, current, previous;" |
1372 |
"CMP mov, field, bot, top;" |
1373 |
"ABS mov, mov;" |
1374 |
"SUB mov, mov, 0.12;" |
1375 |
"CMP other, mov, current, other;" |
1376 |
"CMP top, field, other, current;" |
1377 |
"CMP bot, field, current, other;" |
1378 |
"CMP result.color, off.y, top, bot;"; |
1379 |
break; |
1549 |
break; |
1380 |
|
1550 |
|
1381 |
case kGLFilterKernelDeintDFR: |
1551 |
case kGLFilterBicubic: |
1382 |
ret += |
1552 |
|
1383 |
"ATTRIB tex = fragment.texcoord[0];" |
1553 |
ret += bicubic; |
1384 |
"PARAM off = program.env[0];" |
|
|
1385 |
"TEMP sam, pos, bot, top, cur, pre, nex, field, mov;" |
1386 |
"RCP field, off.x;" |
1387 |
"MUL field, tex.yyyy, field;" |
1388 |
"FRC field, field;" |
1389 |
"SUB field, field, 0.5;" |
1390 |
"TEX pre, tex, texture[2], %1;" // -1,0 |
1391 |
"TEX cur, tex, texture[1], %1;" // 0,0 |
1392 |
"TEX nex, tex, texture[0], %1;" // +1,0 |
1393 |
"SUB top, nex, cur;" |
1394 |
"SUB bot, pre, cur;" |
1395 |
"CMP mov, field, bot, top;" |
1396 |
"ABS mov, mov;" |
1397 |
"SUB mov, mov, 0.12;" |
1398 |
"MUL bot, pre, 0.125;" // BOT -1,0 |
1399 |
"MAD bot, cur, 0.125, bot;" // BOT +1,0 |
1400 |
"MUL top, cur, 0.125;" // TOP -1,0 |
1401 |
"MAD top, nex, 0.125, top;" // TOP +1,0 |
1402 |
"ADD pos, tex, off.wyww;" |
1403 |
"TEX sam, pos, texture[1], %1;" // 0,+1 |
1404 |
"MAD bot, sam, 0.5, bot;" // BOT 0,+1 |
1405 |
"MAD top, sam, 0.5, top;" // TOP 0,+1 |
1406 |
"SUB pos, tex, off.wyww;" |
1407 |
"TEX sam, pos, texture[1], %1;" // 0,-1 |
1408 |
"MAD bot, sam, 0.5, bot;" // BOT 0,-1 |
1409 |
"MAD top, sam, 0.5, top;" // TOP 0,-1 |
1410 |
"MAD pos, off.wyww, 2.0, tex;" |
1411 |
"TEX sam, pos, texture[1], %1;" // 0,+2 |
1412 |
"MAD bot, sam, -0.0625, bot;" // BOT +1,+2 |
1413 |
"MAD top, sam, -0.0625, top;" // TOP -1,+2 |
1414 |
"TEX sam, pos, texture[2], %1;" // -1,+2 |
1415 |
"MAD bot, sam, -0.0625, bot;" // BOT -1,+2 |
1416 |
"TEX sam, pos, texture[0], %1;" // +1,+2 |
1417 |
"MAD top, sam, -0.0625, top;" // TOP +1,+2 |
1418 |
"MAD pos, off.wyww, -2.0, tex;" |
1419 |
"TEX sam, pos, texture[1], %1;" // +1,-2 |
1420 |
"MAD bot, sam, -0.0625, bot;" // BOT +1,-2 |
1421 |
"MAD top, sam, -0.0625, top;" // TOP -1,-2 |
1422 |
"TEX sam, pos, texture[2], %1;" // -1, -2 row |
1423 |
"MAD bot, sam, -0.0625, bot;" // BOT -1,-2 |
1424 |
"TEX sam, pos, texture[0], %1;" // +1,-2 |
1425 |
"MAD top, sam, -0.0625, top;" // TOP +1,-2 |
1426 |
"CMP top, mov, cur, top;" |
1427 |
"CMP bot, mov, cur, bot;" |
1428 |
"CMP top, field, top, cur;" |
1429 |
"CMP bot, field, cur, bot;" |
1430 |
"CMP result.color, off.y, top, bot;"; |
1431 |
break; |
1554 |
break; |
1432 |
|
1555 |
|
1433 |
case kGLFilterBobDeintDFR: |
1556 |
default: |
1434 |
case kGLFilterOneFieldDeint: |
1557 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Unknown fragment program."); |
1435 |
ret += |
|
|
1436 |
"ATTRIB tex = fragment.texcoord[0];" |
1437 |
"PARAM off = program.env[0];" |
1438 |
"TEMP field, top, bottom, current, other;" |
1439 |
"TEX current, tex, texture[0], %1;" |
1440 |
"RCP field, off.x;" |
1441 |
"MUL field, tex.yyyy, field;" |
1442 |
"FRC field, field;" |
1443 |
"SUB field, field, 0.5;" |
1444 |
"ADD top, tex, off.wyww;" |
1445 |
"TEX other, top, texture[0], %1;" |
1446 |
"CMP top, field, other, current;" |
1447 |
"CMP bottom, field, current, other;" |
1448 |
"CMP result.color, off.y, top, bottom;"; |
1449 |
break; |
1558 |
break; |
|
|
1559 |
} |
1450 |
|
1560 |
|
1451 |
case kGLFilterLinearBlendDeint: |
1561 |
QString temp = textureRects ? "RECT" : "2D"; |
1452 |
ret += |
1562 |
ret.replace("%1", temp); |
1453 |
"ATTRIB tex = fragment.texcoord[0];" |
|
|
1454 |
"PARAM off = program.env[0];" |
1455 |
"TEMP mov, field, cur, pre, pos;" |
1456 |
"RCP field, off.x;" |
1457 |
"MUL field, tex.yyyy, field;" |
1458 |
"FRC field, field;" |
1459 |
"SUB field, field, 0.5;" |
1460 |
"TEX cur, tex, texture[0], %1;" |
1461 |
"TEX pre, tex, texture[1], %1;" |
1462 |
"SUB mov, cur, pre;" |
1463 |
"ABS mov, mov;" |
1464 |
"SUB mov, mov, 0.12;" |
1465 |
"ADD pos, tex, off.wyww;" |
1466 |
"TEX pre, pos, texture[0], %1;" |
1467 |
"SUB pos, tex, off.wyww;" |
1468 |
"TEX pos, pos, texture[0], %1;" |
1469 |
"LRP pre, 0.5, pos, pre;" |
1470 |
"CMP pre, field, pre, cur;" |
1471 |
"CMP result.color, mov, cur, pre;"; |
1472 |
break; |
1473 |
|
1563 |
|
1474 |
case kGLFilterFieldOrderDFR: |
1564 |
float lineHeight = 1.0f; |
1475 |
ret += |
1565 |
float colWidth = 1.0f; |
1476 |
"ATTRIB tex = fragment.texcoord[0];" |
1566 |
QSize fb_size = GetTextureSize(video_dim); |
1477 |
"PARAM off = program.env[0];" |
|
|
1478 |
"TEMP field, cur, pre, bot;" |
1479 |
"TEX cur, tex, texture[0], %1;" |
1480 |
"TEX pre, tex, texture[1], %1;" |
1481 |
"RCP field, off.x;" |
1482 |
"MUL field, tex.yyyy, field;" |
1483 |
"FRC field, field;" |
1484 |
"SUB field, field, 0.5;" |
1485 |
"CMP bot, off.y, pre, cur;" |
1486 |
"CMP result.color, field, bot, cur;"; |
1487 |
|
1567 |
|
1488 |
break; |
1568 |
if (!textureRects && |
|
|
1569 |
(inputTextureSize.height() > 0)) |
1570 |
{ |
1571 |
lineHeight /= inputTextureSize.height(); |
1572 |
colWidth /= inputTextureSize.width(); |
1573 |
} |
1489 |
|
1574 |
|
1490 |
case kGLFilterNone: |
1575 |
float fieldSize = 1.0f / (lineHeight * 2.0); |
1491 |
case kGLFilterResize: |
|
|
1492 |
break; |
1493 |
|
1576 |
|
1494 |
default: |
1577 |
ret.replace("%2", temp.setNum(fieldSize, 'f', 8)); |
1495 |
VERBOSE(VB_PLAYBACK, LOC_ERR + "Unknown fragment program."); |
1578 |
ret.replace("%3", temp.setNum(lineHeight, 'f', 8)); |
1496 |
break; |
1579 |
ret.replace("%4", temp.setNum(lineHeight * 2.0, 'f', 8)); |
|
|
1580 |
ret.replace("%5", temp.setNum(colWidth, 'f', 8)); |
1581 |
ret.replace("%6", temp.setNum((float)fb_size.width(), 'f', 1)); |
1582 |
ret.replace("%7", temp.setNum((float)fb_size.height(), 'f', 1)); |
1583 |
|
1584 |
ret += "END"; |
1585 |
|
1586 |
VERBOSE(VB_PLAYBACK, LOC + QString("Created %1 fragment program %2") |
1587 |
.arg(FilterToString(name)).arg(deint)); |
1588 |
|
1589 |
return ret; |
1590 |
} |
1591 |
|
1592 |
uint OpenGLVideo::ParseOptions(QString options) |
1593 |
{ |
1594 |
uint ret = kGLMaxFeat - 1; |
1595 |
|
1596 |
QStringList list = QStringList::split(",", options); |
1597 |
|
1598 |
if (list.empty()) |
1599 |
return ret; |
1600 |
|
1601 |
for (QStringList::Iterator i = list.begin(); |
1602 |
i != list.end(); ++i) |
1603 |
{ |
1604 |
QString name = (*i).section('=', 0, 0); |
1605 |
QString opts = (*i).section('=', 1); |
1606 |
|
1607 |
if (name == "opengloptions") |
1608 |
{ |
1609 |
if (opts.contains("nofinish")) |
1610 |
ret -= kGLFinish; |
1611 |
if (opts.contains("nofence")) |
1612 |
ret -= kGLNVFence; |
1613 |
if (opts.contains("nopbo")) |
1614 |
ret -= kGLExtPBufObj; |
1615 |
if (opts.contains("nopbuf")) |
1616 |
ret -= kGLXPBuffer; |
1617 |
if (opts.contains("nofbo")) |
1618 |
ret -= kGLExtFBufObj; |
1619 |
if (opts.contains("nofrag")) |
1620 |
ret -= kGLExtFragProg; |
1621 |
if (opts.contains("norect")) |
1622 |
ret -= kGLExtRect; |
1623 |
return ret; |
1624 |
} |
1497 |
} |
1625 |
} |
1498 |
|
1626 |
|
1499 |
return ret + "END"; |
1627 |
return ret; |
1500 |
} |
1628 |
} |
|
|
1629 |
|