Line
Link Here
|
|
1) Swap U and V planes to VdpVideoSurfacePutBitsYCbCr to fix blue-tinged |
|
1) Swap U and V planes to VdpVideoSurfacePutBitsYCbCr to fix blue-tinged |
1 |
videos. |
1 |
videos. |
2 |
. |
2 |
. |
3 |
2) Disable VdpPresentationQueueSetBackgroundColor, so that Flash doesn't |
3 |
2) Disable VdpPresentationQueueSetBackgroundColor, so that Flash doesn't |
4 |
set the background to pure black or pure white, which would cause the |
4 |
set the background to pure black or pure white, which would cause the |
5 |
VDPAU image to bleed through to other parts of the desktop with those |
5 |
VDPAU image to bleed through to other parts of the desktop with those |
6 |
very common colors. |
6 |
very common colors. |
7 |
. |
7 |
. |
8 |
These workarounds are only enabled when running under Flash player, and |
8 |
These workarounds are only enabled when running under Flash player, and |
9 |
may be individually controlled via /etc/vdpau_wrapper.cfg, should they |
9 |
may be individually controlled via /etc/vdpau_wrapper.cfg, should they |
10 |
ever need to be disabled. |
10 |
ever need to be disabled. |
11 |
. |
11 |
. |
12 |
Note that this code stores the VDPAU backend function pointers as global |
12 |
Note that this code stores the VDPAU backend function pointers as global |
13 |
variables, which is technically incorrect. However, the likelihood of |
13 |
variables, which is technically incorrect. However, the likelihood of |
14 |
any known VDPAU implementation ever returning different values for these |
14 |
any known VDPAU implementation ever returning different values for these |
15 |
pointers within a single process is zero. If this becomes a problem, a |
15 |
pointers within a single process is zero. If this becomes a problem, a |
16 |
has table of VdpDevice to the stored pointers should be implemented. |
16 |
has table of VdpDevice to the stored pointers should be implemented. |
17 |
. |
17 |
. |
18 |
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> |
18 |
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> |
19 |
-- libvdpau-0.4.1.orig/src/Makefile.am |
19 |
++ libvdpau-0.4.1/src/Makefile.am |
Lines 1-6
Link Here
|
1 |
AM_CFLAGS = \ |
1 |
AM_CFLAGS = \ |
2 |
-I$(top_srcdir)/include \ |
2 |
-I$(top_srcdir)/include \ |
3 |
-DVDPAU_MODULEDIR="\"$(moduledir)\"" \ |
3 |
-DVDPAU_MODULEDIR="\"$(moduledir)\"" \ |
|
|
4 |
-DVDPAU_SYSCONFDIR="\"$(sysconfdir)\"" \ |
4 |
$(X11_CFLAGS) \ |
5 |
$(X11_CFLAGS) \ |
5 |
$(XEXT_CFLAGS) |
6 |
$(XEXT_CFLAGS) |
6 |
|
7 |
|
Lines 27-29
libvdpauincludedir = $(includedir)/vdpau
Link Here
|
27 |
libvdpauinclude_HEADERS = \ |
28 |
libvdpauinclude_HEADERS = \ |
28 |
$(top_srcdir)/include/vdpau/vdpau.h \ |
29 |
$(top_srcdir)/include/vdpau/vdpau.h \ |
29 |
$(top_srcdir)/include/vdpau/vdpau_x11.h |
30 |
$(top_srcdir)/include/vdpau/vdpau_x11.h |
30 |
-- libvdpau-0.4.1.orig/src/vdpau_wrapper.c |
31 |
|
|
|
32 |
libvdpausysconfdir=$(sysconfdir) |
33 |
libvdpausysconf_DATA = vdpau_wrapper.cfg |
|
|
34 |
++ libvdpau-0.4.1/src/vdpau_wrapper.c |
Lines 222-227
static void _vdp_close_driver(void)
Link Here
|
222 |
_vdp_imp_device_create_x11_proc = NULL; |
222 |
_vdp_imp_device_create_x11_proc = NULL; |
223 |
} |
223 |
} |
224 |
|
224 |
|
|
|
225 |
static VdpGetProcAddress * _imp_get_proc_address; |
226 |
static VdpVideoSurfacePutBitsYCbCr * _imp_vid_put_bits_y_cb_cr; |
227 |
static VdpPresentationQueueSetBackgroundColor * _imp_pq_set_bg_color; |
228 |
static int _inited_fixes; |
229 |
static int _running_under_flash; |
230 |
static int _enable_flash_uv_swap = 1; |
231 |
static int _disable_flash_pq_bg_color = 1; |
232 |
|
233 |
static VdpStatus vid_put_bits_y_cb_cr_swapped( |
234 |
VdpVideoSurface surface, |
235 |
VdpYCbCrFormat source_ycbcr_format, |
236 |
void const * const * source_data, |
237 |
uint32_t const * source_pitches |
238 |
) |
239 |
{ |
240 |
void const * data_reordered[3]; |
241 |
void const * const * data; |
242 |
|
243 |
if (source_ycbcr_format == VDP_YCBCR_FORMAT_YV12) { |
244 |
data_reordered[0] = source_data[0]; |
245 |
data_reordered[1] = source_data[2]; |
246 |
data_reordered[2] = source_data[1]; |
247 |
/* |
248 |
* source_pitches[1] and source_pitches[2] should be equal, |
249 |
* so no need to re-order. |
250 |
*/ |
251 |
data = data_reordered; |
252 |
} |
253 |
else { |
254 |
data = source_data; |
255 |
} |
256 |
|
257 |
return _imp_vid_put_bits_y_cb_cr( |
258 |
surface, |
259 |
source_ycbcr_format, |
260 |
data, |
261 |
source_pitches |
262 |
); |
263 |
} |
264 |
|
265 |
static VdpStatus pq_set_bg_color_noop( |
266 |
VdpPresentationQueue presentation_queue, |
267 |
VdpColor * const background_color |
268 |
) |
269 |
{ |
270 |
return VDP_STATUS_OK; |
271 |
} |
272 |
|
273 |
static VdpStatus vdp_wrapper_get_proc_address( |
274 |
VdpDevice device, |
275 |
VdpFuncId function_id, |
276 |
/* output parameters follow */ |
277 |
void * * function_pointer |
278 |
) |
279 |
{ |
280 |
VdpStatus status; |
281 |
|
282 |
status = _imp_get_proc_address(device, function_id, function_pointer); |
283 |
if (status != VDP_STATUS_OK) { |
284 |
return status; |
285 |
} |
286 |
|
287 |
if (_running_under_flash) { |
288 |
switch (function_id) { |
289 |
case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR: |
290 |
if (_enable_flash_uv_swap) { |
291 |
_imp_vid_put_bits_y_cb_cr = *function_pointer; |
292 |
*function_pointer = vid_put_bits_y_cb_cr_swapped; |
293 |
} |
294 |
break; |
295 |
case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR: |
296 |
if (_disable_flash_pq_bg_color) { |
297 |
_imp_pq_set_bg_color = *function_pointer; |
298 |
*function_pointer = pq_set_bg_color_noop; |
299 |
} |
300 |
break; |
301 |
default: |
302 |
break; |
303 |
} |
304 |
} |
305 |
|
306 |
return VDP_STATUS_OK; |
307 |
} |
308 |
|
309 |
static void init_running_under_flash(void) |
310 |
{ |
311 |
FILE *fp; |
312 |
char buffer[1024]; |
313 |
int ret, i; |
314 |
|
315 |
fp = fopen("/proc/self/cmdline", "r"); |
316 |
if (!fp) { |
317 |
return; |
318 |
} |
319 |
ret = fread(buffer, 1, sizeof(buffer) - 1, fp); |
320 |
fclose(fp); |
321 |
if (ret < 0) { |
322 |
return; |
323 |
} |
324 |
/* |
325 |
* Sometimes the file contains null between arguments. Wipe these out so |
326 |
* strstr doesn't stop early. |
327 |
*/ |
328 |
for (i = 0; i < ret; i++) { |
329 |
if (buffer[i] == '\0') { |
330 |
buffer[i] = 'x'; |
331 |
} |
332 |
} |
333 |
buffer[ret] = '\0'; |
334 |
|
335 |
if (strstr(buffer, "libflashplayer") != NULL) { |
336 |
_running_under_flash = 1; |
337 |
} |
338 |
} |
339 |
|
340 |
void init_config(void) |
341 |
{ |
342 |
FILE *fp; |
343 |
char buffer[1024]; |
344 |
int ret; |
345 |
|
346 |
fp = fopen(VDPAU_SYSCONFDIR "/vdpau_wrapper.cfg", "r"); |
347 |
if (!fp) { |
348 |
return; |
349 |
} |
350 |
|
351 |
while (fgets(buffer, sizeof(buffer), fp) != NULL) { |
352 |
char * equals = strchr(buffer, '='); |
353 |
char * param; |
354 |
|
355 |
if (equals == NULL) { |
356 |
continue; |
357 |
} |
358 |
|
359 |
*equals = '\0'; |
360 |
param = equals + 1; |
361 |
|
362 |
if (!strcmp(buffer, "enable_flash_uv_swap")) { |
363 |
_enable_flash_uv_swap = atoi(param); |
364 |
} |
365 |
else if (!strcmp(buffer, "disable_flash_pq_bg_color")) { |
366 |
_disable_flash_pq_bg_color = atoi(param); |
367 |
} |
368 |
} |
369 |
} |
370 |
|
371 |
void init_fixes(void) |
372 |
{ |
373 |
if (_inited_fixes) { |
374 |
return; |
375 |
} |
376 |
_inited_fixes = 1; |
377 |
|
378 |
init_running_under_flash(); |
379 |
init_config(); |
380 |
} |
381 |
|
225 |
VdpStatus vdp_device_create_x11( |
382 |
VdpStatus vdp_device_create_x11( |
226 |
Display * display, |
383 |
Display * display, |
227 |
int screen, |
384 |
int screen, |
Lines 232-237
VdpStatus vdp_device_create_x11(
Link Here
|
232 |
{ |
389 |
{ |
233 |
VdpStatus status; |
390 |
VdpStatus status; |
234 |
|
391 |
|
|
|
392 |
init_fixes(); |
393 |
|
235 |
if (!_vdp_imp_device_create_x11_proc) { |
394 |
if (!_vdp_imp_device_create_x11_proc) { |
236 |
status = _vdp_open_driver(display, screen); |
395 |
status = _vdp_open_driver(display, screen); |
237 |
if (status != VDP_STATUS_OK) { |
396 |
if (status != VDP_STATUS_OK) { |
Lines 240-249
VdpStatus vdp_device_create_x11(
Link Here
|
240 |
} |
399 |
} |
241 |
} |
400 |
} |
242 |
|
401 |
|
243 |
return _vdp_imp_device_create_x11_proc( |
402 |
status = _vdp_imp_device_create_x11_proc( |
244 |
display, |
403 |
display, |
245 |
screen, |
404 |
screen, |
246 |
device, |
405 |
device, |
247 |
get_proc_address |
406 |
&_imp_get_proc_address |
248 |
); |
407 |
); |
|
|
408 |
if (status != VDP_STATUS_OK) { |
409 |
return status; |
410 |
} |
411 |
|
412 |
*get_proc_address = vdp_wrapper_get_proc_address; |
413 |
|
414 |
return VDP_STATUS_OK; |
249 |
} |
415 |
} |
250 |
-- /dev/null |
416 |
++ libvdpau-0.4.1/src/vdpau_wrapper.cfg |
Line 0
Link Here
|
|
|
1 |
enable_flash_uv_swap=1 |
2 |
disable_flash_pq_bg_color=1 |