Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 15152:4e9072d08d91
Sync with 1.934
1.934: remove x264 option "cabacidc", because the default is always best.
1.933: misc corrections and clarifications in x264 options.
author | gpoirier |
---|---|
date | Wed, 13 Apr 2005 19:42:43 +0000 |
parents | 05eab20de476 |
children | 8abf1eed90f3 |
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 |
12582 | 191 if (flags & 0x02) |
192 vm = 1; | |
4978 | 193 #endif |
12582 | 194 flip_flag = flags & 8; |
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); |
334 if (flags & 1) | |
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); | |
349 if (flags & 1 && !vo_fs) | |
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); |
408 if (((flags & 1) && (WinID <= 0)) || vo_fs) | |
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 |
12582 | 429 XClearWindow(mDisplay, vo_window); |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
430 #if 0 |
9161 | 431 #ifdef HAVE_SHM |
12582 | 432 if (Shmem_Flag) |
433 { | |
434 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
435 xvimage[current_buf], 0, 0, image_width, | |
436 image_height, drwX, drwY, 1, 1, False); | |
437 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
438 xvimage[current_buf], 0, 0, image_width, | |
439 image_height, drwX, drwY, vo_dwidth, | |
440 (vo_fs ? vo_dheight - 1 : vo_dheight), False); | |
441 } else | |
9161 | 442 #endif |
12582 | 443 { |
444 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
445 xvimage[current_buf], 0, 0, image_width, image_height, | |
446 drwX, drwY, 1, 1); | |
447 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
448 xvimage[current_buf], 0, 0, image_width, image_height, | |
449 drwX, drwY, vo_dwidth, | |
450 (vo_fs ? vo_dheight - 1 : vo_dheight)); | |
451 } | |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
452 #endif |
12582 | 453 |
454 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
455 drwY, vo_dwidth, vo_dheight); | |
5945 | 456 |
12582 | 457 if (vo_ontop) |
458 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 459 |
12582 | 460 return 0; |
1 | 461 } |
462 | |
182 | 463 static void allocate_xvimage(int foo) |
1 | 464 { |
12582 | 465 /* |
466 * allocate XvImages. FIXME: no error checking, without | |
467 * mit-shm this will bomb... trzing to fix ::atmos | |
468 */ | |
6416 | 469 #ifdef HAVE_SHM |
12582 | 470 if (mLocalDisplay && XShmQueryExtension(mDisplay)) |
471 Shmem_Flag = 1; | |
472 else | |
473 { | |
474 Shmem_Flag = 0; | |
475 mp_msg(MSGT_VO, MSGL_INFO, | |
476 "Shared memory not supported\nReverting to normal Xv\n"); | |
477 } | |
478 if (Shmem_Flag) | |
479 { | |
480 xvimage[foo] = | |
481 (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, | |
482 NULL, image_width, image_height, | |
483 &Shminfo[foo]); | |
1 | 484 |
12582 | 485 Shminfo[foo].shmid = |
486 shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); | |
487 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
488 Shminfo[foo].readOnly = False; | |
1 | 489 |
12582 | 490 xvimage[foo]->data = Shminfo[foo].shmaddr; |
491 XShmAttach(mDisplay, &Shminfo[foo]); | |
492 XSync(mDisplay, False); | |
493 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); | |
494 } else | |
6416 | 495 #endif |
12582 | 496 { |
497 xvimage[foo] = | |
498 (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, | |
499 image_width, image_height); | |
500 xvimage[foo]->data = malloc(xvimage[foo]->data_size); | |
501 XSync(mDisplay, False); | |
502 } | |
503 memset(xvimage[foo]->data, 128, xvimage[foo]->data_size); | |
504 return; | |
1 | 505 } |
506 | |
1794 | 507 static void deallocate_xvimage(int foo) |
508 { | |
6416 | 509 #ifdef HAVE_SHM |
12582 | 510 if (Shmem_Flag) |
511 { | |
512 XShmDetach(mDisplay, &Shminfo[foo]); | |
513 shmdt(Shminfo[foo].shmaddr); | |
514 } else | |
6416 | 515 #endif |
12582 | 516 { |
517 free(xvimage[foo]->data); | |
518 } | |
519 XFree(xvimage[foo]); | |
520 | |
521 XSync(mDisplay, False); | |
522 return; | |
1794 | 523 } |
524 | |
14782 | 525 static inline void put_xvimage( XvImage * xvi ) |
526 { | |
527 #ifdef HAVE_SHM | |
528 if (Shmem_Flag) | |
529 { | |
530 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
531 xvi, 0, 0, image_width, | |
532 image_height, drwX - (vo_panscan_x >> 1), | |
533 drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x, | |
534 vo_dheight + vo_panscan_y, | |
535 False); | |
536 } else | |
537 #endif | |
538 { | |
539 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
540 xvi, 0, 0, image_width, image_height, | |
541 drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1), | |
542 vo_dwidth + vo_panscan_x, | |
543 vo_dheight + vo_panscan_y); | |
544 } | |
545 } | |
546 | |
31 | 547 static void check_events(void) |
1 | 548 { |
12582 | 549 int e = vo_x11_check_events(mDisplay); |
550 | |
551 if (e & VO_EVENT_RESIZE) | |
552 { | |
553 XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &vo_dwidth, | |
554 &vo_dheight, &drwBorderWidth, &drwDepth); | |
555 drwX = drwY = 0; | |
556 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
557 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
|
558 |
12582 | 559 aspect(&dwidth, &dheight, A_NOZOOM); |
560 if (vo_fs) | |
561 { | |
562 aspect(&dwidth, &dheight, A_ZOOM); | |
563 drwX = | |
564 (vo_screenwidth - | |
565 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth)) / 2; | |
566 drwY = | |
567 (vo_screenheight - | |
568 (dheight > | |
569 vo_screenheight ? vo_screenheight : dheight)) / 2; | |
570 vo_dwidth = | |
571 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth); | |
572 vo_dheight = | |
573 (dheight > vo_screenheight ? vo_screenheight : dheight); | |
574 mp_msg(MSGT_VO, MSGL_V, | |
575 "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", drwX, drwY, | |
576 vo_dwidth, vo_dheight); | |
577 } | |
578 } | |
1 | 579 |
14742 | 580 if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) |
581 { | |
582 vo_xv_draw_colorkey(drwX,drwY,vo_dwidth,vo_dheight); | |
583 } | |
584 | |
12582 | 585 if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) |
14782 | 586 { |
587 /* did we already draw a buffer */ | |
588 if ( visible_buf != -1 ) | |
589 { | |
590 /* redraw the last visible buffer */ | |
591 put_xvimage( xvimage[visible_buf] ); | |
592 } | |
593 } | |
1 | 594 } |
595 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
596 static void draw_osd(void) |
12582 | 597 { |
598 vo_draw_text(image_width - | |
599 image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x), | |
600 image_height, draw_alpha_fnc); | |
601 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
602 |
182 | 603 static void flip_page(void) |
1 | 604 { |
14782 | 605 put_xvimage( xvimage[current_buf] ); |
6304
ee65527096c2
pan&scan support with -vo xv by ?? <mplayer@svennevid.net>
arpi
parents:
6295
diff
changeset
|
606 |
14782 | 607 /* remember the currently visible buffer */ |
608 visible_buf = current_buf; | |
609 | |
12582 | 610 if (num_buffers > 1) |
611 { | |
612 current_buf = | |
613 vo_directrendering ? 0 : ((current_buf + 1) % num_buffers); | |
614 XFlush(mDisplay); | |
615 } else | |
616 XSync(mDisplay, False); | |
617 return; | |
1 | 618 } |
619 | |
12582 | 620 static uint32_t draw_slice(uint8_t * image[], int stride[], int w, int h, |
621 int x, int y) | |
1 | 622 { |
12582 | 623 uint8_t *dst; |
182 | 624 |
12582 | 625 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] + |
626 xvimage[current_buf]->pitches[0] * y + x; | |
627 memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0], | |
628 stride[0]); | |
182 | 629 |
12582 | 630 x /= 2; |
631 y /= 2; | |
632 w /= 2; | |
633 h /= 2; | |
1 | 634 |
12582 | 635 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] + |
636 xvimage[current_buf]->pitches[1] * y + x; | |
637 if (image_format != IMGFMT_YV12) | |
638 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
639 stride[1]); | |
640 else | |
641 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
642 stride[2]); | |
5316 | 643 |
12582 | 644 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] + |
645 xvimage[current_buf]->pitches[2] * y + x; | |
646 if (image_format == IMGFMT_YV12) | |
647 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
648 stride[1]); | |
649 else | |
650 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
651 stride[2]); | |
6231 | 652 |
12582 | 653 return 0; |
1 | 654 } |
655 | |
12582 | 656 static uint32_t draw_frame(uint8_t * src[]) |
657 { | |
7684 | 658 printf("draw_frame() called!!!!!!"); |
659 return -1; | |
1 | 660 } |
661 | |
12582 | 662 static uint32_t draw_image(mp_image_t * mpi) |
663 { | |
664 if (mpi->flags & MP_IMGFLAG_DIRECT) | |
665 { | |
666 // direct rendering: | |
667 current_buf = (int) (mpi->priv); // hack! | |
668 return VO_TRUE; | |
6760 | 669 } |
12582 | 670 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
671 return VO_TRUE; // done | |
672 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
673 { | |
674 draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); | |
675 return VO_TRUE; | |
7684 | 676 } |
12582 | 677 if (mpi->flags & MP_IMGFLAG_YUV) |
678 { | |
679 // packed YUV: | |
680 memcpy_pic(xvimage[current_buf]->data + | |
681 xvimage[current_buf]->offsets[0], mpi->planes[0], | |
682 mpi->w * (mpi->bpp / 8), mpi->h, | |
683 xvimage[current_buf]->pitches[0], mpi->stride[0]); | |
684 return VO_TRUE; | |
7684 | 685 } |
12582 | 686 return VO_FALSE; // not (yet) supported |
6760 | 687 } |
688 | |
12582 | 689 static uint32_t get_image(mp_image_t * mpi) |
690 { | |
691 int buf = current_buf; // we shouldn't change current_buf unless we do DR! | |
692 | |
693 if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1) | |
694 return VO_FALSE; // it is not static | |
695 if (mpi->imgfmt != image_format) | |
696 return VO_FALSE; // needs conversion :( | |
4980 | 697 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
12582 | 698 if (mpi->flags & MP_IMGFLAG_READABLE && |
699 (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) | |
700 { | |
701 // reference (I/P) frame of IP or IPB: | |
702 if (num_buffers < 2) | |
703 return VO_FALSE; // not enough | |
704 current_ip_buf ^= 1; | |
705 // for IPB with 2 buffers we can DR only one of the 2 P frames: | |
706 if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3 | |
707 && current_ip_buf) | |
708 return VO_FALSE; | |
709 buf = current_ip_buf; | |
710 if (mpi->type == MP_IMGTYPE_IPB) | |
711 ++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
|
712 } |
12582 | 713 if (mpi->height > xvimage[buf]->height) |
714 return VO_FALSE; //buffer to small | |
715 if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0]) | |
716 return VO_FALSE; //buffer to small | |
717 if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) | |
718 || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0])) | |
719 { | |
720 current_buf = buf; | |
721 mpi->planes[0] = | |
722 xvimage[current_buf]->data + xvimage[current_buf]->offsets[0]; | |
723 mpi->stride[0] = xvimage[current_buf]->pitches[0]; | |
724 mpi->width = mpi->stride[0] / (mpi->bpp / 8); | |
725 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
726 { | |
727 if (mpi->flags & MP_IMGFLAG_SWAPPED) | |
728 { | |
729 // I420 | |
730 mpi->planes[1] = | |
731 xvimage[current_buf]->data + | |
732 xvimage[current_buf]->offsets[1]; | |
733 mpi->planes[2] = | |
734 xvimage[current_buf]->data + | |
735 xvimage[current_buf]->offsets[2]; | |
736 mpi->stride[1] = xvimage[current_buf]->pitches[1]; | |
737 mpi->stride[2] = xvimage[current_buf]->pitches[2]; | |
738 } else | |
739 { | |
740 // YV12 | |
741 mpi->planes[1] = | |
742 xvimage[current_buf]->data + | |
743 xvimage[current_buf]->offsets[2]; | |
744 mpi->planes[2] = | |
745 xvimage[current_buf]->data + | |
746 xvimage[current_buf]->offsets[1]; | |
747 mpi->stride[1] = xvimage[current_buf]->pitches[2]; | |
748 mpi->stride[2] = xvimage[current_buf]->pitches[1]; | |
749 } | |
750 } | |
751 mpi->flags |= MP_IMGFLAG_DIRECT; | |
752 mpi->priv = (void *) current_buf; | |
753 // printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
754 return VO_TRUE; | |
4980 | 755 } |
756 return VO_FALSE; | |
757 } | |
758 | |
182 | 759 static uint32_t query_format(uint32_t format) |
1 | 760 { |
10855 | 761 uint32_t i; |
12582 | 762 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 |
763 | |
764 /* check image formats */ | |
765 for (i = 0; i < formats; i++) | |
766 { | |
767 if (fo[i].id == format) | |
768 return flag; //xv_format = fo[i].id; | |
769 } | |
770 return 0; | |
1 | 771 } |
772 | |
12582 | 773 static void uninit(void) |
1852 | 774 { |
12582 | 775 int i; |
776 | |
777 if (!vo_config_count) | |
778 return; | |
14782 | 779 visible_buf = -1; |
12582 | 780 XvFreeAdaptorInfo(ai); |
781 ai = NULL; | |
13953 | 782 if(fo){ |
783 XFree(fo); | |
784 fo=NULL; | |
785 } | |
12582 | 786 for (i = 0; i < num_buffers; i++) |
787 deallocate_xvimage(i); | |
6016 | 788 #ifdef HAVE_XF86VM |
12582 | 789 vo_vm_close(mDisplay); |
6016 | 790 #endif |
12582 | 791 vo_x11_uninit(); |
322
4e69a8e2700a
Screensaver and monitor powersafe function is switched off when playing a
laaz
parents:
249
diff
changeset
|
792 } |
1 | 793 |
4352 | 794 static uint32_t preinit(const char *arg) |
795 { | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
796 XvPortID xv_p; |
12582 | 797 int busy_ports = 0; |
10855 | 798 unsigned int i; |
14742 | 799 strarg_t ck_src_arg = { 0, NULL }; |
800 strarg_t ck_method_arg = { 0, NULL }; | |
801 | |
802 opt_t subopts[] = | |
803 { | |
804 /* name arg type arg var test */ | |
805 { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos }, | |
806 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, | |
807 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | |
808 { NULL } | |
809 }; | |
12582 | 810 |
10826 | 811 xv_port = 0; |
812 | |
14742 | 813 /* parse suboptions */ |
814 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
|
815 { |
14742 | 816 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
|
817 } |
14742 | 818 |
819 /* modify colorkey settings according to the given options */ | |
820 xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); | |
821 | |
12582 | 822 if (!vo_init()) |
823 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
824 |
12582 | 825 /* check for Xvideo extension */ |
826 if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err)) | |
827 { | |
828 mp_msg(MSGT_VO, MSGL_ERR, | |
829 "Sorry, Xv not supported by this X11 version/driver\n"); | |
830 mp_msg(MSGT_VO, MSGL_ERR, | |
831 "******** Try with -vo x11 or -vo sdl *********\n"); | |
832 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
833 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
834 |
12582 | 835 /* check for Xvideo support */ |
836 if (Success != | |
837 XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors, | |
838 &ai)) | |
839 { | |
840 mp_msg(MSGT_VO, MSGL_ERR, "Xv: XvQueryAdaptors failed\n"); | |
841 return -1; | |
842 } | |
843 | |
844 /* check adaptors */ | |
845 if (xv_port) | |
846 { | |
10839 | 847 int port_found; |
12582 | 848 |
849 for (port_found = 0, i = 0; !port_found && i < adaptors; i++) | |
850 { | |
851 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
852 { | |
853 for (xv_p = ai[i].base_id; | |
854 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
855 { | |
856 if (xv_p == xv_port) | |
857 { | |
10839 | 858 port_found = 1; |
859 break; | |
860 } | |
861 } | |
862 } | |
863 } | |
12582 | 864 if (port_found) |
865 { | |
10839 | 866 if (XvGrabPort(mDisplay, xv_port, CurrentTime)) |
867 xv_port = 0; | |
12582 | 868 } else |
869 { | |
870 mp_msg(MSGT_VO, MSGL_WARN, | |
871 "Xv: Invalid port parameter, overriding with port 0\n"); | |
10839 | 872 xv_port = 0; |
873 } | |
10826 | 874 } |
12582 | 875 |
876 for (i = 0; i < adaptors && xv_port == 0; i++) | |
877 { | |
878 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
879 { | |
880 for (xv_p = ai[i].base_id; | |
881 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
882 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) | |
883 { | |
884 xv_port = xv_p; | |
885 break; | |
886 } else | |
887 { | |
888 mp_msg(MSGT_VO, MSGL_WARN, | |
889 "Xv: could not grab port %i\n", (int) xv_p); | |
890 ++busy_ports; | |
891 } | |
892 } | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
893 } |
12582 | 894 if (!xv_port) |
895 { | |
896 if (busy_ports) | |
897 mp_msg(MSGT_VO, MSGL_ERR, | |
898 "Could not find free Xvideo port - maybe another process is already using it.\n" | |
899 "Close all video applications, and try again. If that does not help,\n" | |
900 "see 'mplayer -vo help' for other (non-xv) video out drivers.\n"); | |
901 else | |
902 mp_msg(MSGT_VO, MSGL_ERR, | |
903 "It seems there is no Xvideo support for your video card available.\n" | |
13914 | 904 "Run 'xvinfo' to verify its Xv support and read DOCS/HTML/en/video.html#xv!\n" |
12582 | 905 "See 'mplayer -vo help' for other (non-xv) video out drivers. Try -vo x11\n"); |
906 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
907 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
908 |
14742 | 909 if ( !vo_xv_init_colorkey() ) |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
910 { |
14742 | 911 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
|
912 } |
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
913 |
12582 | 914 fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); |
5566 | 915 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
916 return 0; |
4352 | 917 } |
1 | 918 |
4596 | 919 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
|
920 { |
12582 | 921 switch (request) |
922 { | |
923 case VOCTRL_PAUSE: | |
924 return (int_pause = 1); | |
925 case VOCTRL_RESUME: | |
926 return (int_pause = 0); | |
927 case VOCTRL_QUERY_FORMAT: | |
928 return query_format(*((uint32_t *) data)); | |
929 case VOCTRL_GET_IMAGE: | |
930 return get_image(data); | |
931 case VOCTRL_DRAW_IMAGE: | |
932 return draw_image(data); | |
933 case VOCTRL_GUISUPPORT: | |
934 return VO_TRUE; | |
935 case VOCTRL_GET_PANSCAN: | |
936 if (!vo_config_count || !vo_fs) | |
937 return VO_FALSE; | |
938 return VO_TRUE; | |
939 case VOCTRL_FULLSCREEN: | |
940 vo_x11_fullscreen(); | |
941 /* indended, fallthrough to update panscan on fullscreen/windowed switch */ | |
942 case VOCTRL_SET_PANSCAN: | |
943 if ((vo_fs && (vo_panscan != vo_panscan_amount)) | |
944 || (!vo_fs && vo_panscan_amount)) | |
945 { | |
946 int old_y = vo_panscan_y; | |
947 | |
948 panscan_calc(); | |
949 | |
950 if (old_y != vo_panscan_y) | |
951 { | |
952 vo_x11_clearwindow_part(mDisplay, vo_window, | |
953 vo_dwidth + vo_panscan_x - 1, | |
954 vo_dheight + vo_panscan_y - 1, | |
955 1); | |
956 flip_page(); | |
957 } | |
958 } | |
959 return VO_TRUE; | |
960 case VOCTRL_SET_EQUALIZER: | |
961 { | |
962 va_list ap; | |
963 int value; | |
964 | |
965 va_start(ap, data); | |
966 value = va_arg(ap, int); | |
967 | |
968 va_end(ap); | |
969 | |
970 return (vo_xv_set_eq(xv_port, data, value)); | |
971 } | |
972 case VOCTRL_GET_EQUALIZER: | |
973 { | |
974 va_list ap; | |
975 int *value; | |
976 | |
977 va_start(ap, data); | |
978 value = va_arg(ap, int *); | |
979 | |
980 va_end(ap); | |
981 | |
982 return (vo_xv_get_eq(xv_port, data, value)); | |
983 } | |
984 case VOCTRL_ONTOP: | |
985 vo_x11_ontop(); | |
986 return VO_TRUE; | |
987 } | |
988 return VO_NOTIMPL; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
989 } |