Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 15476:5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
author | nicodvb |
---|---|
date | Sun, 15 May 2005 07:38:42 +0000 |
parents | 05aa13cdf92f |
children | 91d210e8a19c |
rev | line source |
---|---|
7757 | 1 /* vo_xv.c, X11 Xv interface */ |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
2 |
1265 | 3 // Number of buffers _FOR_DOUBLEBUFFERING_MODE_ |
4 // Use option -double to enable double buffering! (default: single buffer) | |
6758
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
5 #define NUM_BUFFERS 3 |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
6 |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
7 /* |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
8 Buffer allocation: |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
9 |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
10 -nodr: |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
11 1: TEMP |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
12 2: 2*TEMP |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
13 |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
14 -dr: |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
15 1: TEMP |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
16 3: 2*STATIC+TEMP |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
17 */ |
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
18 |
1 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 | |
23 #include "config.h" | |
5935 | 24 #include "mp_msg.h" |
1 | 25 #include "video_out.h" |
26 #include "video_out_internal.h" | |
27 | |
28 | |
29 #include <X11/Xlib.h> | |
30 #include <X11/Xutil.h> | |
31 #include <errno.h> | |
32 | |
31 | 33 #include "x11_common.h" |
34 | |
354 | 35 #include "fastmemcpy.h" |
616 | 36 #include "sub.h" |
2054 | 37 #include "aspect.h" |
350 | 38 |
14742 | 39 #include "subopt-helper.h" |
40 | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
41 #ifdef HAVE_NEW_GUI |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13242
diff
changeset
|
42 #include "Gui/interface.h" |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
43 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
44 |
12582 | 45 static vo_info_t info = { |
46 "X11/Xv", | |
47 "xv", | |
48 "Gerd Knorr <kraxel@goldbach.in-berlin.de> and others", | |
49 "" | |
1 | 50 }; |
51 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7857
diff
changeset
|
52 LIBVO_EXTERN(xv) |
6719
5291d74a60c9
xv support under cygwin - patch by Sycotic Smith <sycotic at linuxmail.org>
alex
parents:
6417
diff
changeset
|
53 #ifdef HAVE_SHM |
1 | 54 #include <sys/ipc.h> |
55 #include <sys/shm.h> | |
56 #include <X11/extensions/XShm.h> | |
6416 | 57 /* since it doesn't seem to be defined on some platforms */ |
12582 | 58 int XShmGetEventBase(Display *); |
6416 | 59 |
60 static XShmSegmentInfo Shminfo[NUM_BUFFERS]; | |
6417
44bca09c1edd
100l accidently removed a line too much (Shmem_Flag)
atmos4
parents:
6416
diff
changeset
|
61 static int Shmem_Flag; |
6416 | 62 #endif |
63 | |
10855 | 64 // Note: depends on the inclusion of X11/extensions/XShm.h |
65 #include <X11/extensions/Xv.h> | |
66 #include <X11/extensions/Xvlib.h> | |
67 | |
68 // FIXME: dynamically allocate this stuff | |
69 static void allocate_xvimage(int); | |
12582 | 70 static unsigned int ver, rel, req, ev, err; |
14742 | 71 static unsigned int formats, adaptors, xv_format; |
12582 | 72 static XvAdaptorInfo *ai = NULL; |
13953 | 73 static XvImageFormatValues *fo=NULL; |
10855 | 74 |
12582 | 75 static int current_buf = 0; |
76 static int current_ip_buf = 0; | |
77 static int num_buffers = 1; // default | |
14782 | 78 static int visible_buf = -1; // -1 means: no buffer was drawn yet |
12582 | 79 static XvImage *xvimage[NUM_BUFFERS]; |
10855 | 80 |
81 | |
1 | 82 static uint32_t image_width; |
83 static uint32_t image_height; | |
84 static uint32_t image_format; | |
4629 | 85 static int flip_flag; |
1 | 86 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10359
diff
changeset
|
87 static int int_pause; |
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10359
diff
changeset
|
88 |
12582 | 89 static Window mRoot; |
90 static uint32_t drwX, drwY, drwBorderWidth, drwDepth; | |
91 static uint32_t dwidth, dheight; | |
1 | 92 |
12582 | 93 static void (*draw_alpha_fnc) (int x0, int y0, int w, int h, |
94 unsigned char *src, unsigned char *srca, | |
95 int stride); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
96 |
12582 | 97 static void draw_alpha_yv12(int x0, int y0, int w, int h, |
98 unsigned char *src, unsigned char *srca, | |
99 int stride) | |
100 { | |
101 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
102 vo_draw_alpha_yv12(w, h, src, srca, stride, | |
103 xvimage[current_buf]->data + | |
104 xvimage[current_buf]->offsets[0] + | |
105 xvimage[current_buf]->pitches[0] * y0 + x0, | |
106 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
107 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
108 |
12582 | 109 static void draw_alpha_yuy2(int x0, int y0, int w, int h, |
110 unsigned char *src, unsigned char *srca, | |
111 int stride) | |
112 { | |
113 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
114 vo_draw_alpha_yuy2(w, h, src, srca, stride, | |
115 xvimage[current_buf]->data + | |
116 xvimage[current_buf]->offsets[0] + | |
117 xvimage[current_buf]->pitches[0] * y0 + 2 * x0, | |
118 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
119 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
120 |
12582 | 121 static void draw_alpha_uyvy(int x0, int y0, int w, int h, |
122 unsigned char *src, unsigned char *srca, | |
123 int stride) | |
124 { | |
125 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
126 vo_draw_alpha_yuy2(w, h, src, srca, stride, | |
127 xvimage[current_buf]->data + | |
128 xvimage[current_buf]->offsets[0] + | |
129 xvimage[current_buf]->pitches[0] * y0 + 2 * x0 + 1, | |
130 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
131 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
132 |
12582 | 133 static void draw_alpha_null(int x0, int y0, int w, int h, |
134 unsigned char *src, unsigned char *srca, | |
135 int stride) | |
136 { | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
137 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
138 |
6786 | 139 |
7757 | 140 static void deallocate_xvimage(int foo); |
141 | |
182 | 142 /* |
143 * connect to server, create and map window, | |
1 | 144 * allocate colors and (shared) memory |
145 */ | |
12582 | 146 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
147 uint32_t d_height, uint32_t flags, char *title, | |
148 uint32_t format) | |
1 | 149 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
150 // int screen; |
12582 | 151 char *hello = (title == NULL) ? "Xv render" : title; |
152 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
153 // char *name = ":0.0"; |
12582 | 154 XSizeHints hint; |
155 XVisualInfo vinfo; | |
156 XGCValues xgcv; | |
157 XSetWindowAttributes xswa; | |
158 XWindowAttributes attribs; | |
159 unsigned long xswamask; | |
160 int depth; | |
161 | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
162 #ifdef HAVE_XF86VM |
12582 | 163 int vm = 0; |
164 unsigned int modeline_width, modeline_height; | |
165 static uint32_t vm_width; | |
166 static uint32_t vm_height; | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
167 #endif |
1 | 168 |
12582 | 169 panscan_init(); |
6304
ee65527096c2
pan&scan support with -vo xv by ?? <mplayer@svennevid.net>
arpi
parents:
6295
diff
changeset
|
170 |
12582 | 171 aspect_save_orig(width, height); |
172 aspect_save_prescale(d_width, d_height); | |
173 | |
174 image_height = height; | |
175 image_width = width; | |
176 image_format = format; | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
177 |
12582 | 178 vo_mouse_autohide = 1; |
179 | |
180 int_pause = 0; | |
14782 | 181 visible_buf = -1; |
1 | 182 |
12582 | 183 vo_dx = (vo_screenwidth - d_width) / 2; |
184 vo_dy = (vo_screenheight - d_height) / 2; | |
185 geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, | |
186 vo_screenheight); | |
187 vo_dwidth = d_width; | |
188 vo_dheight = d_height; | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10359
diff
changeset
|
189 |
4978 | 190 #ifdef HAVE_XF86VM |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
191 if (flags & VOFLAG_MODESWITCHING) |
12582 | 192 vm = 1; |
4978 | 193 #endif |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
194 flip_flag = flags & VOFLAG_FLIPPING; |
12582 | 195 num_buffers = |
196 vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
197 |
12582 | 198 /* check image formats */ |
199 { | |
200 unsigned int i; | |
10855 | 201 |
12582 | 202 xv_format = 0; |
203 for (i = 0; i < formats; i++) | |
204 { | |
205 mp_msg(MSGT_VO, MSGL_V, | |
206 "Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id, | |
207 (char *) &fo[i].id, | |
208 (fo[i].format == XvPacked) ? "packed" : "planar"); | |
209 if (fo[i].id == format) | |
210 xv_format = fo[i].id; | |
211 } | |
212 if (!xv_format) | |
213 return -1; | |
214 } | |
215 aspect_save_screenres(vo_screenwidth, vo_screenheight); | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
216 |
1775 | 217 #ifdef HAVE_NEW_GUI |
12582 | 218 if (use_gui) |
219 guiGetEvent(guiSetShVideo, 0); // let the GUI to setup/resize our window | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
220 else |
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
221 #endif |
723 | 222 { |
12582 | 223 hint.x = vo_dx; |
224 hint.y = vo_dy; | |
225 aspect(&d_width, &d_height, A_NOZOOM); | |
226 hint.width = d_width; | |
227 hint.height = d_height; | |
228 #ifdef HAVE_XF86VM | |
229 if (vm) | |
230 { | |
231 if ((d_width == 0) && (d_height == 0)) | |
232 { | |
233 vm_width = image_width; | |
234 vm_height = image_height; | |
235 } else | |
236 { | |
237 vm_width = d_width; | |
238 vm_height = d_height; | |
239 } | |
240 vo_vm_switch(vm_width, vm_height, &modeline_width, | |
241 &modeline_height); | |
242 hint.x = (vo_screenwidth - modeline_width) / 2; | |
243 hint.y = (vo_screenheight - modeline_height) / 2; | |
244 hint.width = modeline_width; | |
245 hint.height = modeline_height; | |
246 aspect_save_screenres(modeline_width, modeline_height); | |
247 } else | |
248 #endif | |
249 if (vo_fs) | |
250 { | |
2054 | 251 #ifdef X11_FULLSCREEN |
12582 | 252 /* this code replaces X11_FULLSCREEN hack in mplayer.c |
253 * aspect() is available through aspect.h for all vos. | |
254 * besides zooming should only be done with -zoom, | |
255 * but I leave the old -fs behaviour so users don't get | |
256 * irritated for now (and send lots o' mails ;) ::atmos | |
257 */ | |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
258 |
12582 | 259 aspect(&d_width, &d_height, A_ZOOM); |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
260 #endif |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
261 |
12582 | 262 } |
5945 | 263 // dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for? |
12582 | 264 vo_dwidth = d_width; |
265 vo_dheight = d_height; | |
266 hint.flags = PPosition | PSize /* | PBaseSize */ ; | |
267 hint.base_width = hint.width; | |
268 hint.base_height = hint.height; | |
269 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), | |
270 &attribs); | |
271 depth = attribs.depth; | |
272 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) | |
273 depth = 24; | |
274 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); | |
723 | 275 |
12582 | 276 xswa.background_pixel = 0; |
14742 | 277 if (xv_ck_info.method == CK_METHOD_BACKGROUND) |
278 { | |
279 xswa.background_pixel = xv_colorkey; | |
280 } | |
12582 | 281 xswa.border_pixel = 0; |
282 xswamask = CWBackPixel | CWBorderPixel; | |
1 | 283 |
12582 | 284 if (WinID >= 0) |
285 { | |
286 vo_window = WinID ? ((Window) WinID) : mRootWin; | |
287 if (WinID) | |
288 { | |
289 XUnmapWindow(mDisplay, vo_window); | |
290 XChangeWindowAttributes(mDisplay, vo_window, xswamask, | |
291 &xswa); | |
292 vo_x11_selectinput_witherr(mDisplay, vo_window, | |
293 StructureNotifyMask | | |
294 KeyPressMask | | |
295 PropertyChangeMask | | |
296 PointerMotionMask | | |
297 ButtonPressMask | | |
298 ButtonReleaseMask | | |
299 ExposureMask); | |
300 XMapWindow(mDisplay, vo_window); | |
301 } else | |
302 { | |
303 drwX = vo_dx; | |
304 drwY = vo_dy; | |
305 } | |
306 } else if (vo_window == None) | |
307 { | |
308 vo_window = | |
309 vo_x11_create_smooth_window(mDisplay, mRootWin, | |
310 vinfo.visual, hint.x, hint.y, | |
311 hint.width, hint.height, depth, | |
312 CopyFromParent); | |
14742 | 313 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); |
3830 | 314 |
12582 | 315 vo_x11_classhint(mDisplay, vo_window, "xv"); |
316 vo_hidecursor(mDisplay, vo_window); | |
3830 | 317 |
12582 | 318 vo_x11_selectinput_witherr(mDisplay, vo_window, |
319 StructureNotifyMask | KeyPressMask | | |
320 PropertyChangeMask | ((WinID == 0) ? | |
321 0 | |
322 : | |
323 (PointerMotionMask | |
324 | | |
325 ButtonPressMask | |
326 | | |
327 ButtonReleaseMask | |
328 | | |
329 ExposureMask))); | |
330 XSetStandardProperties(mDisplay, vo_window, hello, hello, None, | |
331 NULL, 0, &hint); | |
14797
05eab20de476
Always use vo_x11_sizehint function ( even when going fullscreen ) to
al
parents:
14782
diff
changeset
|
332 vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0); |
12582 | 333 XMapWindow(mDisplay, vo_window); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
334 if (flags & VOFLAG_FULLSCREEN) |
12582 | 335 vo_x11_fullscreen(); |
336 else | |
337 { | |
3990 | 338 #ifdef HAVE_XINERAMA |
12582 | 339 vo_x11_xinerama_move(mDisplay, vo_window); |
3990 | 340 #endif |
12582 | 341 } |
342 } else | |
343 { | |
344 // vo_fs set means we were already at fullscreen | |
345 vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0); | |
346 if (!vo_fs) | |
347 XMoveResizeWindow(mDisplay, vo_window, hint.x, hint.y, | |
348 hint.width, hint.height); | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
349 if (flags & VOFLAG_FULLSCREEN && !vo_fs) |
12582 | 350 vo_x11_fullscreen(); // handle -fs on non-first file |
351 } | |
352 | |
9161 | 353 // vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 ); |
12582 | 354 |
355 if (vo_gc != None) | |
356 XFreeGC(mDisplay, vo_gc); | |
357 vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv); | |
358 XSync(mDisplay, False); | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
359 #ifdef HAVE_XF86VM |
12582 | 360 if (vm) |
361 { | |
362 /* Grab the mouse pointer in our window */ | |
363 if (vo_grabpointer) | |
364 XGrabPointer(mDisplay, vo_window, True, 0, | |
365 GrabModeAsync, GrabModeAsync, | |
366 vo_window, None, CurrentTime); | |
367 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); | |
368 } | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
369 #endif |
12582 | 370 } |
371 | |
372 mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n", | |
373 xv_port); | |
1 | 374 |
12582 | 375 switch (xv_format) |
376 { | |
377 case IMGFMT_YV12: | |
378 case IMGFMT_I420: | |
379 case IMGFMT_IYUV: | |
380 draw_alpha_fnc = draw_alpha_yv12; | |
381 break; | |
382 case IMGFMT_YUY2: | |
383 case IMGFMT_YVYU: | |
384 draw_alpha_fnc = draw_alpha_yuy2; | |
385 break; | |
386 case IMGFMT_UYVY: | |
387 draw_alpha_fnc = draw_alpha_uyvy; | |
388 break; | |
389 default: | |
390 draw_alpha_fnc = draw_alpha_null; | |
391 } | |
182 | 392 |
12582 | 393 if (vo_config_count) |
394 for (current_buf = 0; current_buf < num_buffers; ++current_buf) | |
395 deallocate_xvimage(current_buf); | |
7757 | 396 |
12582 | 397 for (current_buf = 0; current_buf < num_buffers; ++current_buf) |
398 allocate_xvimage(current_buf); | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
399 |
12582 | 400 current_buf = 0; |
401 current_ip_buf = 0; | |
1 | 402 |
6764
7755d1d59394
fix hue bug with nvidia's shit. i teszted with g400,radeon7500,tnt2ultra,geforce2mx200
pontscho
parents:
6760
diff
changeset
|
403 #if 0 |
12582 | 404 set_gamma_correction(); |
6764
7755d1d59394
fix hue bug with nvidia's shit. i teszted with g400,radeon7500,tnt2ultra,geforce2mx200
pontscho
parents:
6760
diff
changeset
|
405 #endif |
1818 | 406 |
12582 | 407 aspect(&vo_dwidth, &vo_dheight, A_NOZOOM); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
408 if (((flags & VOFLAG_FULLSCREEN) && (WinID <= 0)) || vo_fs) |
12582 | 409 { |
410 aspect(&vo_dwidth, &vo_dheight, A_ZOOM); | |
411 drwX = | |
412 (vo_screenwidth - | |
413 (vo_dwidth > | |
414 vo_screenwidth ? vo_screenwidth : vo_dwidth)) / 2; | |
415 drwY = | |
416 (vo_screenheight - | |
417 (vo_dheight > | |
418 vo_screenheight ? vo_screenheight : vo_dheight)) / 2; | |
419 vo_dwidth = | |
420 (vo_dwidth > vo_screenwidth ? vo_screenwidth : vo_dwidth); | |
421 vo_dheight = | |
422 (vo_dheight > vo_screenheight ? vo_screenheight : vo_dheight); | |
423 mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", | |
424 drwX, drwY, vo_dwidth, vo_dheight); | |
425 } | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6366
diff
changeset
|
426 |
12582 | 427 panscan_calc(); |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
428 |
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
429 #if 0 |
9161 | 430 #ifdef HAVE_SHM |
12582 | 431 if (Shmem_Flag) |
432 { | |
433 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
434 xvimage[current_buf], 0, 0, image_width, | |
435 image_height, drwX, drwY, 1, 1, False); | |
436 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
437 xvimage[current_buf], 0, 0, image_width, | |
438 image_height, drwX, drwY, vo_dwidth, | |
439 (vo_fs ? vo_dheight - 1 : vo_dheight), False); | |
440 } else | |
9161 | 441 #endif |
12582 | 442 { |
443 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
444 xvimage[current_buf], 0, 0, image_width, image_height, | |
445 drwX, drwY, 1, 1); | |
446 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
447 xvimage[current_buf], 0, 0, image_width, image_height, | |
448 drwX, drwY, vo_dwidth, | |
449 (vo_fs ? vo_dheight - 1 : vo_dheight)); | |
450 } | |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
451 #endif |
12582 | 452 |
453 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
454 drwY, vo_dwidth, vo_dheight); | |
5945 | 455 |
12582 | 456 if (vo_ontop) |
457 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 458 |
12582 | 459 return 0; |
1 | 460 } |
461 | |
182 | 462 static void allocate_xvimage(int foo) |
1 | 463 { |
12582 | 464 /* |
465 * allocate XvImages. FIXME: no error checking, without | |
466 * mit-shm this will bomb... trzing to fix ::atmos | |
467 */ | |
6416 | 468 #ifdef HAVE_SHM |
12582 | 469 if (mLocalDisplay && XShmQueryExtension(mDisplay)) |
470 Shmem_Flag = 1; | |
471 else | |
472 { | |
473 Shmem_Flag = 0; | |
474 mp_msg(MSGT_VO, MSGL_INFO, | |
475 "Shared memory not supported\nReverting to normal Xv\n"); | |
476 } | |
477 if (Shmem_Flag) | |
478 { | |
479 xvimage[foo] = | |
480 (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, | |
481 NULL, image_width, image_height, | |
482 &Shminfo[foo]); | |
1 | 483 |
12582 | 484 Shminfo[foo].shmid = |
485 shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); | |
486 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
487 Shminfo[foo].readOnly = False; | |
1 | 488 |
12582 | 489 xvimage[foo]->data = Shminfo[foo].shmaddr; |
490 XShmAttach(mDisplay, &Shminfo[foo]); | |
491 XSync(mDisplay, False); | |
492 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); | |
493 } else | |
6416 | 494 #endif |
12582 | 495 { |
496 xvimage[foo] = | |
497 (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, | |
498 image_width, image_height); | |
499 xvimage[foo]->data = malloc(xvimage[foo]->data_size); | |
500 XSync(mDisplay, False); | |
501 } | |
502 memset(xvimage[foo]->data, 128, xvimage[foo]->data_size); | |
503 return; | |
1 | 504 } |
505 | |
1794 | 506 static void deallocate_xvimage(int foo) |
507 { | |
6416 | 508 #ifdef HAVE_SHM |
12582 | 509 if (Shmem_Flag) |
510 { | |
511 XShmDetach(mDisplay, &Shminfo[foo]); | |
512 shmdt(Shminfo[foo].shmaddr); | |
513 } else | |
6416 | 514 #endif |
12582 | 515 { |
516 free(xvimage[foo]->data); | |
517 } | |
518 XFree(xvimage[foo]); | |
519 | |
520 XSync(mDisplay, False); | |
521 return; | |
1794 | 522 } |
523 | |
14782 | 524 static inline void put_xvimage( XvImage * xvi ) |
525 { | |
526 #ifdef HAVE_SHM | |
527 if (Shmem_Flag) | |
528 { | |
529 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
530 xvi, 0, 0, image_width, | |
531 image_height, drwX - (vo_panscan_x >> 1), | |
532 drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x, | |
533 vo_dheight + vo_panscan_y, | |
534 False); | |
535 } else | |
536 #endif | |
537 { | |
538 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
539 xvi, 0, 0, image_width, image_height, | |
540 drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1), | |
541 vo_dwidth + vo_panscan_x, | |
542 vo_dheight + vo_panscan_y); | |
543 } | |
544 } | |
545 | |
31 | 546 static void check_events(void) |
1 | 547 { |
12582 | 548 int e = vo_x11_check_events(mDisplay); |
549 | |
550 if (e & VO_EVENT_RESIZE) | |
551 { | |
552 XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &vo_dwidth, | |
553 &vo_dheight, &drwBorderWidth, &drwDepth); | |
554 drwX = drwY = 0; | |
555 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
556 drwY, vo_dwidth, vo_dheight); | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10359
diff
changeset
|
557 |
12582 | 558 aspect(&dwidth, &dheight, A_NOZOOM); |
559 if (vo_fs) | |
560 { | |
561 aspect(&dwidth, &dheight, A_ZOOM); | |
562 drwX = | |
563 (vo_screenwidth - | |
564 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth)) / 2; | |
565 drwY = | |
566 (vo_screenheight - | |
567 (dheight > | |
568 vo_screenheight ? vo_screenheight : dheight)) / 2; | |
569 vo_dwidth = | |
570 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth); | |
571 vo_dheight = | |
572 (dheight > vo_screenheight ? vo_screenheight : dheight); | |
573 mp_msg(MSGT_VO, MSGL_V, | |
574 "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", drwX, drwY, | |
575 vo_dwidth, vo_dheight); | |
576 } | |
577 } | |
1 | 578 |
14742 | 579 if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) |
580 { | |
15192 | 581 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
582 drwY - (vo_panscan_y >> 1), | |
583 vo_dwidth + vo_panscan_x - 1, | |
584 vo_dheight + vo_panscan_y - 1); | |
14742 | 585 } |
586 | |
12582 | 587 if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) |
14782 | 588 { |
589 /* did we already draw a buffer */ | |
590 if ( visible_buf != -1 ) | |
591 { | |
592 /* redraw the last visible buffer */ | |
593 put_xvimage( xvimage[visible_buf] ); | |
594 } | |
595 } | |
1 | 596 } |
597 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
598 static void draw_osd(void) |
12582 | 599 { |
600 vo_draw_text(image_width - | |
601 image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x), | |
602 image_height, draw_alpha_fnc); | |
603 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
604 |
182 | 605 static void flip_page(void) |
1 | 606 { |
14782 | 607 put_xvimage( xvimage[current_buf] ); |
6304
ee65527096c2
pan&scan support with -vo xv by ?? <mplayer@svennevid.net>
arpi
parents:
6295
diff
changeset
|
608 |
14782 | 609 /* remember the currently visible buffer */ |
610 visible_buf = current_buf; | |
611 | |
12582 | 612 if (num_buffers > 1) |
613 { | |
614 current_buf = | |
615 vo_directrendering ? 0 : ((current_buf + 1) % num_buffers); | |
616 XFlush(mDisplay); | |
617 } else | |
618 XSync(mDisplay, False); | |
619 return; | |
1 | 620 } |
621 | |
12582 | 622 static uint32_t draw_slice(uint8_t * image[], int stride[], int w, int h, |
623 int x, int y) | |
1 | 624 { |
12582 | 625 uint8_t *dst; |
182 | 626 |
12582 | 627 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] + |
628 xvimage[current_buf]->pitches[0] * y + x; | |
629 memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0], | |
630 stride[0]); | |
182 | 631 |
12582 | 632 x /= 2; |
633 y /= 2; | |
634 w /= 2; | |
635 h /= 2; | |
1 | 636 |
12582 | 637 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] + |
638 xvimage[current_buf]->pitches[1] * y + x; | |
639 if (image_format != IMGFMT_YV12) | |
640 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
641 stride[1]); | |
642 else | |
643 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
644 stride[2]); | |
5316 | 645 |
12582 | 646 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] + |
647 xvimage[current_buf]->pitches[2] * y + x; | |
648 if (image_format == IMGFMT_YV12) | |
649 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
650 stride[1]); | |
651 else | |
652 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
653 stride[2]); | |
6231 | 654 |
12582 | 655 return 0; |
1 | 656 } |
657 | |
12582 | 658 static uint32_t draw_frame(uint8_t * src[]) |
659 { | |
7684 | 660 printf("draw_frame() called!!!!!!"); |
661 return -1; | |
1 | 662 } |
663 | |
12582 | 664 static uint32_t draw_image(mp_image_t * mpi) |
665 { | |
666 if (mpi->flags & MP_IMGFLAG_DIRECT) | |
667 { | |
668 // direct rendering: | |
669 current_buf = (int) (mpi->priv); // hack! | |
670 return VO_TRUE; | |
6760 | 671 } |
12582 | 672 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
673 return VO_TRUE; // done | |
674 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
675 { | |
676 draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); | |
677 return VO_TRUE; | |
7684 | 678 } |
12582 | 679 if (mpi->flags & MP_IMGFLAG_YUV) |
680 { | |
681 // packed YUV: | |
682 memcpy_pic(xvimage[current_buf]->data + | |
683 xvimage[current_buf]->offsets[0], mpi->planes[0], | |
684 mpi->w * (mpi->bpp / 8), mpi->h, | |
685 xvimage[current_buf]->pitches[0], mpi->stride[0]); | |
686 return VO_TRUE; | |
7684 | 687 } |
12582 | 688 return VO_FALSE; // not (yet) supported |
6760 | 689 } |
690 | |
12582 | 691 static uint32_t get_image(mp_image_t * mpi) |
692 { | |
693 int buf = current_buf; // we shouldn't change current_buf unless we do DR! | |
694 | |
695 if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1) | |
696 return VO_FALSE; // it is not static | |
697 if (mpi->imgfmt != image_format) | |
698 return VO_FALSE; // needs conversion :( | |
4980 | 699 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
12582 | 700 if (mpi->flags & MP_IMGFLAG_READABLE && |
701 (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) | |
702 { | |
703 // reference (I/P) frame of IP or IPB: | |
704 if (num_buffers < 2) | |
705 return VO_FALSE; // not enough | |
706 current_ip_buf ^= 1; | |
707 // for IPB with 2 buffers we can DR only one of the 2 P frames: | |
708 if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3 | |
709 && current_ip_buf) | |
710 return VO_FALSE; | |
711 buf = current_ip_buf; | |
712 if (mpi->type == MP_IMGTYPE_IPB) | |
713 ++buf; // preserve space for B | |
6758
ecc71f27bfd7
DR1 IP/IPB supoprt (I/P only with -double) -- OSD *must be* disabled! :)
arpi
parents:
6755
diff
changeset
|
714 } |
12582 | 715 if (mpi->height > xvimage[buf]->height) |
716 return VO_FALSE; //buffer to small | |
717 if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0]) | |
718 return VO_FALSE; //buffer to small | |
719 if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) | |
720 || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0])) | |
721 { | |
722 current_buf = buf; | |
723 mpi->planes[0] = | |
724 xvimage[current_buf]->data + xvimage[current_buf]->offsets[0]; | |
725 mpi->stride[0] = xvimage[current_buf]->pitches[0]; | |
726 mpi->width = mpi->stride[0] / (mpi->bpp / 8); | |
727 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
728 { | |
729 if (mpi->flags & MP_IMGFLAG_SWAPPED) | |
730 { | |
731 // I420 | |
732 mpi->planes[1] = | |
733 xvimage[current_buf]->data + | |
734 xvimage[current_buf]->offsets[1]; | |
735 mpi->planes[2] = | |
736 xvimage[current_buf]->data + | |
737 xvimage[current_buf]->offsets[2]; | |
738 mpi->stride[1] = xvimage[current_buf]->pitches[1]; | |
739 mpi->stride[2] = xvimage[current_buf]->pitches[2]; | |
740 } else | |
741 { | |
742 // YV12 | |
743 mpi->planes[1] = | |
744 xvimage[current_buf]->data + | |
745 xvimage[current_buf]->offsets[2]; | |
746 mpi->planes[2] = | |
747 xvimage[current_buf]->data + | |
748 xvimage[current_buf]->offsets[1]; | |
749 mpi->stride[1] = xvimage[current_buf]->pitches[2]; | |
750 mpi->stride[2] = xvimage[current_buf]->pitches[1]; | |
751 } | |
752 } | |
753 mpi->flags |= MP_IMGFLAG_DIRECT; | |
754 mpi->priv = (void *) current_buf; | |
755 // printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
756 return VO_TRUE; | |
4980 | 757 } |
758 return VO_FALSE; | |
759 } | |
760 | |
182 | 761 static uint32_t query_format(uint32_t format) |
1 | 762 { |
10855 | 763 uint32_t i; |
12582 | 764 int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN |
765 | |
766 /* check image formats */ | |
767 for (i = 0; i < formats; i++) | |
768 { | |
769 if (fo[i].id == format) | |
770 return flag; //xv_format = fo[i].id; | |
771 } | |
772 return 0; | |
1 | 773 } |
774 | |
12582 | 775 static void uninit(void) |
1852 | 776 { |
12582 | 777 int i; |
778 | |
779 if (!vo_config_count) | |
780 return; | |
14782 | 781 visible_buf = -1; |
12582 | 782 XvFreeAdaptorInfo(ai); |
783 ai = NULL; | |
13953 | 784 if(fo){ |
785 XFree(fo); | |
786 fo=NULL; | |
787 } | |
12582 | 788 for (i = 0; i < num_buffers; i++) |
789 deallocate_xvimage(i); | |
6016 | 790 #ifdef HAVE_XF86VM |
12582 | 791 vo_vm_close(mDisplay); |
6016 | 792 #endif |
12582 | 793 vo_x11_uninit(); |
322
4e69a8e2700a
Screensaver and monitor powersafe function is switched off when playing a
laaz
parents:
249
diff
changeset
|
794 } |
1 | 795 |
4352 | 796 static uint32_t preinit(const char *arg) |
797 { | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
798 XvPortID xv_p; |
12582 | 799 int busy_ports = 0; |
10855 | 800 unsigned int i; |
14742 | 801 strarg_t ck_src_arg = { 0, NULL }; |
802 strarg_t ck_method_arg = { 0, NULL }; | |
803 | |
804 opt_t subopts[] = | |
805 { | |
806 /* name arg type arg var test */ | |
807 { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos }, | |
808 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, | |
809 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | |
810 { NULL } | |
811 }; | |
12582 | 812 |
10826 | 813 xv_port = 0; |
814 | |
14742 | 815 /* parse suboptions */ |
816 if ( subopt_parse( arg, subopts ) != 0 ) | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
817 { |
14742 | 818 return -1; |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
819 } |
14742 | 820 |
821 /* modify colorkey settings according to the given options */ | |
822 xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); | |
823 | |
12582 | 824 if (!vo_init()) |
825 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
826 |
12582 | 827 /* check for Xvideo extension */ |
828 if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err)) | |
829 { | |
830 mp_msg(MSGT_VO, MSGL_ERR, | |
831 "Sorry, Xv not supported by this X11 version/driver\n"); | |
832 mp_msg(MSGT_VO, MSGL_ERR, | |
833 "******** Try with -vo x11 or -vo sdl *********\n"); | |
834 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
835 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
836 |
12582 | 837 /* check for Xvideo support */ |
838 if (Success != | |
839 XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors, | |
840 &ai)) | |
841 { | |
842 mp_msg(MSGT_VO, MSGL_ERR, "Xv: XvQueryAdaptors failed\n"); | |
843 return -1; | |
844 } | |
845 | |
846 /* check adaptors */ | |
847 if (xv_port) | |
848 { | |
10839 | 849 int port_found; |
12582 | 850 |
851 for (port_found = 0, i = 0; !port_found && i < adaptors; i++) | |
852 { | |
853 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
854 { | |
855 for (xv_p = ai[i].base_id; | |
856 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
857 { | |
858 if (xv_p == xv_port) | |
859 { | |
10839 | 860 port_found = 1; |
861 break; | |
862 } | |
863 } | |
864 } | |
865 } | |
12582 | 866 if (port_found) |
867 { | |
10839 | 868 if (XvGrabPort(mDisplay, xv_port, CurrentTime)) |
869 xv_port = 0; | |
12582 | 870 } else |
871 { | |
872 mp_msg(MSGT_VO, MSGL_WARN, | |
873 "Xv: Invalid port parameter, overriding with port 0\n"); | |
10839 | 874 xv_port = 0; |
875 } | |
10826 | 876 } |
12582 | 877 |
878 for (i = 0; i < adaptors && xv_port == 0; i++) | |
879 { | |
880 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
881 { | |
882 for (xv_p = ai[i].base_id; | |
883 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
884 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) | |
885 { | |
886 xv_port = xv_p; | |
887 break; | |
888 } else | |
889 { | |
890 mp_msg(MSGT_VO, MSGL_WARN, | |
891 "Xv: could not grab port %i\n", (int) xv_p); | |
892 ++busy_ports; | |
893 } | |
894 } | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
895 } |
12582 | 896 if (!xv_port) |
897 { | |
898 if (busy_ports) | |
899 mp_msg(MSGT_VO, MSGL_ERR, | |
900 "Could not find free Xvideo port - maybe another process is already using it.\n" | |
901 "Close all video applications, and try again. If that does not help,\n" | |
902 "see 'mplayer -vo help' for other (non-xv) video out drivers.\n"); | |
903 else | |
904 mp_msg(MSGT_VO, MSGL_ERR, | |
905 "It seems there is no Xvideo support for your video card available.\n" | |
13914 | 906 "Run 'xvinfo' to verify its Xv support and read DOCS/HTML/en/video.html#xv!\n" |
12582 | 907 "See 'mplayer -vo help' for other (non-xv) video out drivers. Try -vo x11\n"); |
908 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
909 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
910 |
14742 | 911 if ( !vo_xv_init_colorkey() ) |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
912 { |
14742 | 913 return -1; // bail out, colorkey setup failed |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
914 } |
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
915 |
12582 | 916 fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); |
5566 | 917 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
918 return 0; |
4352 | 919 } |
1 | 920 |
4596 | 921 static uint32_t control(uint32_t request, void *data, ...) |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
922 { |
12582 | 923 switch (request) |
924 { | |
925 case VOCTRL_PAUSE: | |
926 return (int_pause = 1); | |
927 case VOCTRL_RESUME: | |
928 return (int_pause = 0); | |
929 case VOCTRL_QUERY_FORMAT: | |
930 return query_format(*((uint32_t *) data)); | |
931 case VOCTRL_GET_IMAGE: | |
932 return get_image(data); | |
933 case VOCTRL_DRAW_IMAGE: | |
934 return draw_image(data); | |
935 case VOCTRL_GUISUPPORT: | |
936 return VO_TRUE; | |
937 case VOCTRL_GET_PANSCAN: | |
938 if (!vo_config_count || !vo_fs) | |
939 return VO_FALSE; | |
940 return VO_TRUE; | |
941 case VOCTRL_FULLSCREEN: | |
942 vo_x11_fullscreen(); | |
943 /* indended, fallthrough to update panscan on fullscreen/windowed switch */ | |
944 case VOCTRL_SET_PANSCAN: | |
945 if ((vo_fs && (vo_panscan != vo_panscan_amount)) | |
946 || (!vo_fs && vo_panscan_amount)) | |
947 { | |
948 int old_y = vo_panscan_y; | |
949 | |
950 panscan_calc(); | |
951 | |
952 if (old_y != vo_panscan_y) | |
953 { | |
954 vo_x11_clearwindow_part(mDisplay, vo_window, | |
955 vo_dwidth + vo_panscan_x - 1, | |
956 vo_dheight + vo_panscan_y - 1, | |
957 1); | |
15190 | 958 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
959 drwY - (vo_panscan_y >> 1), | |
960 vo_dwidth + vo_panscan_x - 1, | |
961 vo_dheight + vo_panscan_y - 1); | |
12582 | 962 flip_page(); |
963 } | |
964 } | |
965 return VO_TRUE; | |
966 case VOCTRL_SET_EQUALIZER: | |
967 { | |
968 va_list ap; | |
969 int value; | |
970 | |
971 va_start(ap, data); | |
972 value = va_arg(ap, int); | |
973 | |
974 va_end(ap); | |
975 | |
976 return (vo_xv_set_eq(xv_port, data, value)); | |
977 } | |
978 case VOCTRL_GET_EQUALIZER: | |
979 { | |
980 va_list ap; | |
981 int *value; | |
982 | |
983 va_start(ap, data); | |
984 value = va_arg(ap, int *); | |
985 | |
986 va_end(ap); | |
987 | |
988 return (vo_xv_get_eq(xv_port, data, value)); | |
989 } | |
990 case VOCTRL_ONTOP: | |
991 vo_x11_ontop(); | |
992 return VO_TRUE; | |
993 } | |
994 return VO_NOTIMPL; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
995 } |