1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mageia-dev] Fwd: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Fwd%3A%20%5BVDPAU%5D%20%5BPATCH%5D%20Implement%20workarounds%20for%20Adobe%0A%09Flash%20bugs&In-Reply-To=%3C4FA29830.6040609%40mageia.org%3E">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="015265.html">
<LINK REL="Next" HREF="015237.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mageia-dev] Fwd: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs</H1>
<B>Anssi Hannula</B>
<A HREF="mailto:mageia-dev%40mageia.org?Subject=Re%3A%20%5BMageia-dev%5D%20Fwd%3A%20%5BVDPAU%5D%20%5BPATCH%5D%20Implement%20workarounds%20for%20Adobe%0A%09Flash%20bugs&In-Reply-To=%3C4FA29830.6040609%40mageia.org%3E"
TITLE="[Mageia-dev] Fwd: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs">anssi at mageia.org
</A><BR>
<I>Thu May 3 16:37:36 CEST 2012</I>
<P><UL>
<LI>Previous message: <A HREF="015265.html">[Mageia-dev] Freeze push request : bluedevil
</A></li>
<LI>Next message: <A HREF="015237.html">[Mageia-dev] Fwd: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#15236">[ date ]</a>
<a href="thread.html#15236">[ thread ]</a>
<a href="subject.html#15236">[ subject ]</a>
<a href="author.html#15236">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Hi all!
I think we should probably apply the below libvdpau workaround for Adobe
Flash issues, for both mga2 and mga1, WDYT?
(Note: I haven't yet tested it)
--
Anssi Hannula
-------- Alkuperäinen viesti / Orig.Msg. --------
Aihe: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs
Päiväys: Tue, 1 May 2012 21:27:24 -0600
Lähettäjä: Stephen Warren <<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">swarren at wwwdotorg.org</A>>
Vastaanottaja: Aaron Plattner <<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">aplattner at nvidia.com</A>>
CC: <A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">vdpau at lists.freedesktop.org</A>, Stephen Warren <<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">swarren at wwwdotorg.org</A>>
Implement two workarounds:
1) Swap U and V planes to VdpVideoSurfacePutBitsYCbCr to fix blue-tinged
videos.
2) Disable VdpPresentationQueueSetBackgroundColor, so that Flash doesn't
set the background to pure black or pure white, which would cause the
VDPAU image to bleed through to other parts of the desktop with those
very common colors.
These workarounds are only enabled when running under Flash player, and
may be individually controlled via /etc/vdpau_wrapper.cfg, should they
ever need to be disabled.
Note that this code stores the VDPAU backend function pointers as global
variables, which is technically incorrect. However, the likelihood of
any known VDPAU implementation ever returning different values for these
pointers within a single process is zero. If this becomes a problem, a
has table of VdpDevice to the stored pointers should be implemented.
Signed-off-by: Stephen Warren <<A HREF="https://www.mageia.org/mailman/listinfo/mageia-dev">swarren at wwwdotorg.org</A>>
---
src/Makefile.am | 4 +
src/vdpau_wrapper.c | 170
++++++++++++++++++++++++++++++++++++++++++++++++-
src/vdpau_wrapper.cfg | 2 +
3 files changed, 174 insertions(+), 2 deletions(-)
create mode 100644 src/vdpau_wrapper.cfg
diff --git a/src/Makefile.am b/src/Makefile.am
index 48e69a7..9162ffb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,7 @@
AM_CFLAGS = \
-I$(top_srcdir)/include \
-DVDPAU_MODULEDIR="\"$(moduledir)\"" \
+ -DVDPAU_SYSCONFDIR="\"$(sysconfdir)\"" \
$(X11_CFLAGS) \
$(XEXT_CFLAGS)
@@ -26,3 +27,6 @@ libvdpauincludedir = $(includedir)/vdpau
libvdpauinclude_HEADERS = \
$(top_srcdir)/include/vdpau/vdpau.h \
$(top_srcdir)/include/vdpau/vdpau_x11.h
+
+libvdpausysconfdir=$(sysconfdir)
+libvdpausysconf_DATA = vdpau_wrapper.cfg
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index 23de3d4..c955745 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -210,6 +210,163 @@ static void _vdp_close_driver(void)
_vdp_imp_device_create_x11_proc = NULL;
}
+static VdpGetProcAddress * _imp_get_proc_address;
+static VdpVideoSurfacePutBitsYCbCr * _imp_vid_put_bits_y_cb_cr;
+static VdpPresentationQueueSetBackgroundColor * _imp_pq_set_bg_color;
+static int _inited_fixes;
+static int _running_under_flash;
+static int _enable_flash_uv_swap = 1;
+static int _disable_flash_pq_bg_color = 1;
+
+static VdpStatus vid_put_bits_y_cb_cr_swapped(
+ VdpVideoSurface surface,
+ VdpYCbCrFormat source_ycbcr_format,
+ void const * const * source_data,
+ uint32_t const * source_pitches
+)
+{
+ void const * data_reordered[3];
+ void const * const * data;
+
+ if (source_ycbcr_format == VDP_YCBCR_FORMAT_YV12) {
+ data_reordered[0] = source_data[0];
+ data_reordered[1] = source_data[2];
+ data_reordered[2] = source_data[1];
+ /*
+ * source_pitches[1] and source_pitches[2] should be equal,
+ * so no need to re-order.
+ */
+ data = data_reordered;
+ }
+ else {
+ data = source_data;
+ }
+
+ return _imp_vid_put_bits_y_cb_cr(
+ surface,
+ source_ycbcr_format,
+ data,
+ source_pitches
+ );
+}
+
+static VdpStatus pq_set_bg_color_noop(
+ VdpPresentationQueue presentation_queue,
+ VdpColor * const background_color
+)
+{
+ return VDP_STATUS_OK;
+}
+
+static VdpStatus vdp_wrapper_get_proc_address(
+ VdpDevice device,
+ VdpFuncId function_id,
+ /* output parameters follow */
+ void * * function_pointer
+)
+{
+ VdpStatus status;
+
+ status = _imp_get_proc_address(device, function_id, function_pointer);
+ if (status != VDP_STATUS_OK) {
+ return status;
+ }
+
+ if (_running_under_flash) {
+ switch (function_id) {
+ case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
+ if (_enable_flash_uv_swap) {
+ _imp_vid_put_bits_y_cb_cr = *function_pointer;
+ *function_pointer = vid_put_bits_y_cb_cr_swapped;
+ }
+ break;
+ case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
+ if (_disable_flash_pq_bg_color) {
+ _imp_pq_set_bg_color = *function_pointer;
+ *function_pointer = pq_set_bg_color_noop;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return VDP_STATUS_OK;
+}
+
+static void init_running_under_flash(void)
+{
+ FILE *fp;
+ char buffer[1024];
+ int ret, i;
+
+ fp = fopen("/proc/self/cmdline", "r");
+ if (!fp) {
+ return;
+ }
+ ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
+ fclose(fp);
+ if (ret < 0) {
+ return;
+ }
+ /*
+ * Sometimes the file contains null between arguments. Wipe these
out so
+ * strstr doesn't stop early.
+ */
+ for (i = 0; i < ret; i++) {
+ if (buffer[i] == '\0') {
+ buffer[i] = 'x';
+ }
+ }
+ buffer[ret] = '\0';
+
+ if (strstr(buffer, "libflashplayer") != NULL) {
+ _running_under_flash = 1;
+ }
+}
+
+void init_config(void)
+{
+ FILE *fp;
+ char buffer[1024];
+ int ret;
+
+ fp = fopen(VDPAU_SYSCONFDIR "/vdpau_wrapper.cfg", "r");
+ if (!fp) {
+ return;
+ }
+
+ while (fgets(buffer, sizeof(buffer), fp) != NULL) {
+ char * equals = strchr(buffer, '=');
+ char * param;
+
+ if (equals == NULL) {
+ continue;
+ }
+
+ *equals = '\0';
+ param = equals + 1;
+
+ if (!strcmp(buffer, "enable_flash_uv_swap")) {
+ _enable_flash_uv_swap = atoi(param);
+ }
+ else if (!strcmp(buffer, "disable_flash_pq_bg_color")) {
+ _disable_flash_pq_bg_color = atoi(param);
+ }
+ }
+}
+
+void init_fixes(void)
+{
+ if (_inited_fixes) {
+ return;
+ }
+ _inited_fixes = 1;
+
+ init_running_under_flash();
+ init_config();
+}
+
VdpStatus vdp_device_create_x11(
Display * display,
int screen,
@@ -220,6 +377,8 @@ VdpStatus vdp_device_create_x11(
{
VdpStatus status;
+ init_fixes();
+
if (!_vdp_imp_device_create_x11_proc) {
status = _vdp_open_driver(display, screen);
if (status != VDP_STATUS_OK) {
@@ -228,10 +387,17 @@ VdpStatus vdp_device_create_x11(
}
}
- return _vdp_imp_device_create_x11_proc(
+ status = _vdp_imp_device_create_x11_proc(
display,
screen,
device,
- get_proc_address
+ &_imp_get_proc_address
);
+ if (status != VDP_STATUS_OK) {
+ return status;
+ }
+
+ *get_proc_address = vdp_wrapper_get_proc_address;
+
+ return VDP_STATUS_OK;
}
diff --git a/src/vdpau_wrapper.cfg b/src/vdpau_wrapper.cfg
new file mode 100644
index 0000000..21d5b8c
--- /dev/null
+++ b/src/vdpau_wrapper.cfg
@@ -0,0 +1,2 @@
+enable_flash_uv_swap=1
+disable_flash_pq_bg_color=1
--
Anssi Hannula
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="015265.html">[Mageia-dev] Freeze push request : bluedevil
</A></li>
<LI>Next message: <A HREF="015237.html">[Mageia-dev] Fwd: [VDPAU] [PATCH] Implement workarounds for Adobe Flash bugs
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#15236">[ date ]</a>
<a href="thread.html#15236">[ thread ]</a>
<a href="subject.html#15236">[ subject ]</a>
<a href="author.html#15236">[ author ]</a>
</LI>
</UL>
<hr>
<a href="https://www.mageia.org/mailman/listinfo/mageia-dev">More information about the Mageia-dev
mailing list</a><br>
</body></html>
|