Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 16192:c29fc3d0bf4a
reconcile with earlier fps fix in mpeg header parser
author | rfelker |
---|---|
date | Wed, 10 Aug 2005 01:42:06 +0000 |
parents | fd51fd1ff231 |
children | 3ff863e54b93 |
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 */ | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
146 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
12582 | 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); | |
15540 | 301 XGetGeometry(mDisplay, vo_window, &mRoot, |
302 &drwX, &drwY, &vo_dwidth, &vo_dheight, | |
303 &drwBorderWidth, &drwDepth); | |
304 drwX = drwY = 0; // coordinates need to be local to the window | |
305 aspect_save_prescale(vo_dwidth, vo_dheight); | |
12582 | 306 } else |
307 { | |
308 drwX = vo_dx; | |
309 drwY = vo_dy; | |
310 } | |
311 } else if (vo_window == None) | |
312 { | |
313 vo_window = | |
314 vo_x11_create_smooth_window(mDisplay, mRootWin, | |
315 vinfo.visual, hint.x, hint.y, | |
316 hint.width, hint.height, depth, | |
317 CopyFromParent); | |
14742 | 318 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); |
3830 | 319 |
12582 | 320 vo_x11_classhint(mDisplay, vo_window, "xv"); |
321 vo_hidecursor(mDisplay, vo_window); | |
3830 | 322 |
12582 | 323 vo_x11_selectinput_witherr(mDisplay, vo_window, |
324 StructureNotifyMask | KeyPressMask | | |
325 PropertyChangeMask | ((WinID == 0) ? | |
326 0 | |
327 : | |
328 (PointerMotionMask | |
329 | | |
330 ButtonPressMask | |
331 | | |
332 ButtonReleaseMask | |
333 | | |
334 ExposureMask))); | |
335 XSetStandardProperties(mDisplay, vo_window, hello, hello, None, | |
336 NULL, 0, &hint); | |
14797
05eab20de476
Always use vo_x11_sizehint function ( even when going fullscreen ) to
al
parents:
14782
diff
changeset
|
337 vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0); |
12582 | 338 XMapWindow(mDisplay, vo_window); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
339 if (flags & VOFLAG_FULLSCREEN) |
12582 | 340 vo_x11_fullscreen(); |
341 else | |
342 { | |
3990 | 343 #ifdef HAVE_XINERAMA |
12582 | 344 vo_x11_xinerama_move(mDisplay, vo_window); |
3990 | 345 #endif |
12582 | 346 } |
347 } else | |
348 { | |
349 // vo_fs set means we were already at fullscreen | |
350 vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0); | |
351 if (!vo_fs) | |
352 XMoveResizeWindow(mDisplay, vo_window, hint.x, hint.y, | |
353 hint.width, hint.height); | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
354 if (flags & VOFLAG_FULLSCREEN && !vo_fs) |
12582 | 355 vo_x11_fullscreen(); // handle -fs on non-first file |
356 } | |
357 | |
9161 | 358 // vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 ); |
12582 | 359 |
360 if (vo_gc != None) | |
361 XFreeGC(mDisplay, vo_gc); | |
362 vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv); | |
363 XSync(mDisplay, False); | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
364 #ifdef HAVE_XF86VM |
12582 | 365 if (vm) |
366 { | |
367 /* Grab the mouse pointer in our window */ | |
368 if (vo_grabpointer) | |
369 XGrabPointer(mDisplay, vo_window, True, 0, | |
370 GrabModeAsync, GrabModeAsync, | |
371 vo_window, None, CurrentTime); | |
372 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); | |
373 } | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
374 #endif |
12582 | 375 } |
376 | |
377 mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n", | |
378 xv_port); | |
1 | 379 |
12582 | 380 switch (xv_format) |
381 { | |
382 case IMGFMT_YV12: | |
383 case IMGFMT_I420: | |
384 case IMGFMT_IYUV: | |
385 draw_alpha_fnc = draw_alpha_yv12; | |
386 break; | |
387 case IMGFMT_YUY2: | |
388 case IMGFMT_YVYU: | |
389 draw_alpha_fnc = draw_alpha_yuy2; | |
390 break; | |
391 case IMGFMT_UYVY: | |
392 draw_alpha_fnc = draw_alpha_uyvy; | |
393 break; | |
394 default: | |
395 draw_alpha_fnc = draw_alpha_null; | |
396 } | |
182 | 397 |
12582 | 398 if (vo_config_count) |
399 for (current_buf = 0; current_buf < num_buffers; ++current_buf) | |
400 deallocate_xvimage(current_buf); | |
7757 | 401 |
12582 | 402 for (current_buf = 0; current_buf < num_buffers; ++current_buf) |
403 allocate_xvimage(current_buf); | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
404 |
12582 | 405 current_buf = 0; |
406 current_ip_buf = 0; | |
1 | 407 |
6764
7755d1d59394
fix hue bug with nvidia's shit. i teszted with g400,radeon7500,tnt2ultra,geforce2mx200
pontscho
parents:
6760
diff
changeset
|
408 #if 0 |
12582 | 409 set_gamma_correction(); |
6764
7755d1d59394
fix hue bug with nvidia's shit. i teszted with g400,radeon7500,tnt2ultra,geforce2mx200
pontscho
parents:
6760
diff
changeset
|
410 #endif |
1818 | 411 |
12582 | 412 aspect(&vo_dwidth, &vo_dheight, A_NOZOOM); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
413 if (((flags & VOFLAG_FULLSCREEN) && (WinID <= 0)) || vo_fs) |
12582 | 414 { |
415 aspect(&vo_dwidth, &vo_dheight, A_ZOOM); | |
416 drwX = | |
417 (vo_screenwidth - | |
418 (vo_dwidth > | |
419 vo_screenwidth ? vo_screenwidth : vo_dwidth)) / 2; | |
420 drwY = | |
421 (vo_screenheight - | |
422 (vo_dheight > | |
423 vo_screenheight ? vo_screenheight : vo_dheight)) / 2; | |
424 vo_dwidth = | |
425 (vo_dwidth > vo_screenwidth ? vo_screenwidth : vo_dwidth); | |
426 vo_dheight = | |
427 (vo_dheight > vo_screenheight ? vo_screenheight : vo_dheight); | |
428 mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", | |
429 drwX, drwY, vo_dwidth, vo_dheight); | |
430 } | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6366
diff
changeset
|
431 |
12582 | 432 panscan_calc(); |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
433 |
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
434 #if 0 |
9161 | 435 #ifdef HAVE_SHM |
12582 | 436 if (Shmem_Flag) |
437 { | |
438 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
439 xvimage[current_buf], 0, 0, image_width, | |
440 image_height, drwX, drwY, 1, 1, False); | |
441 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
442 xvimage[current_buf], 0, 0, image_width, | |
443 image_height, drwX, drwY, vo_dwidth, | |
444 (vo_fs ? vo_dheight - 1 : vo_dheight), False); | |
445 } else | |
9161 | 446 #endif |
12582 | 447 { |
448 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
449 xvimage[current_buf], 0, 0, image_width, image_height, | |
450 drwX, drwY, 1, 1); | |
451 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
452 xvimage[current_buf], 0, 0, image_width, image_height, | |
453 drwX, drwY, vo_dwidth, | |
454 (vo_fs ? vo_dheight - 1 : vo_dheight)); | |
455 } | |
9381
007a1bdce1f4
reversed small part of the r1.135 commit, it broke -fs (random black screen)
arpi
parents:
9326
diff
changeset
|
456 #endif |
12582 | 457 |
458 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
459 drwY, vo_dwidth, vo_dheight); | |
5945 | 460 |
12582 | 461 if (vo_ontop) |
462 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 463 |
12582 | 464 return 0; |
1 | 465 } |
466 | |
182 | 467 static void allocate_xvimage(int foo) |
1 | 468 { |
12582 | 469 /* |
470 * allocate XvImages. FIXME: no error checking, without | |
471 * mit-shm this will bomb... trzing to fix ::atmos | |
472 */ | |
6416 | 473 #ifdef HAVE_SHM |
12582 | 474 if (mLocalDisplay && XShmQueryExtension(mDisplay)) |
475 Shmem_Flag = 1; | |
476 else | |
477 { | |
478 Shmem_Flag = 0; | |
479 mp_msg(MSGT_VO, MSGL_INFO, | |
480 "Shared memory not supported\nReverting to normal Xv\n"); | |
481 } | |
482 if (Shmem_Flag) | |
483 { | |
484 xvimage[foo] = | |
485 (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, | |
486 NULL, image_width, image_height, | |
487 &Shminfo[foo]); | |
1 | 488 |
12582 | 489 Shminfo[foo].shmid = |
490 shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); | |
491 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
492 Shminfo[foo].readOnly = False; | |
1 | 493 |
12582 | 494 xvimage[foo]->data = Shminfo[foo].shmaddr; |
495 XShmAttach(mDisplay, &Shminfo[foo]); | |
496 XSync(mDisplay, False); | |
497 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); | |
498 } else | |
6416 | 499 #endif |
12582 | 500 { |
501 xvimage[foo] = | |
502 (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, | |
503 image_width, image_height); | |
504 xvimage[foo]->data = malloc(xvimage[foo]->data_size); | |
505 XSync(mDisplay, False); | |
506 } | |
507 memset(xvimage[foo]->data, 128, xvimage[foo]->data_size); | |
508 return; | |
1 | 509 } |
510 | |
1794 | 511 static void deallocate_xvimage(int foo) |
512 { | |
6416 | 513 #ifdef HAVE_SHM |
12582 | 514 if (Shmem_Flag) |
515 { | |
516 XShmDetach(mDisplay, &Shminfo[foo]); | |
517 shmdt(Shminfo[foo].shmaddr); | |
518 } else | |
6416 | 519 #endif |
12582 | 520 { |
521 free(xvimage[foo]->data); | |
522 } | |
523 XFree(xvimage[foo]); | |
524 | |
525 XSync(mDisplay, False); | |
526 return; | |
1794 | 527 } |
528 | |
14782 | 529 static inline void put_xvimage( XvImage * xvi ) |
530 { | |
531 #ifdef HAVE_SHM | |
532 if (Shmem_Flag) | |
533 { | |
534 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
535 xvi, 0, 0, image_width, | |
536 image_height, drwX - (vo_panscan_x >> 1), | |
537 drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x, | |
538 vo_dheight + vo_panscan_y, | |
539 False); | |
540 } else | |
541 #endif | |
542 { | |
543 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
544 xvi, 0, 0, image_width, image_height, | |
545 drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1), | |
546 vo_dwidth + vo_panscan_x, | |
547 vo_dheight + vo_panscan_y); | |
548 } | |
549 } | |
550 | |
31 | 551 static void check_events(void) |
1 | 552 { |
12582 | 553 int e = vo_x11_check_events(mDisplay); |
554 | |
555 if (e & VO_EVENT_RESIZE) | |
556 { | |
557 XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &vo_dwidth, | |
558 &vo_dheight, &drwBorderWidth, &drwDepth); | |
559 drwX = drwY = 0; | |
560 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, | |
561 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
|
562 |
12582 | 563 aspect(&dwidth, &dheight, A_NOZOOM); |
564 if (vo_fs) | |
565 { | |
566 aspect(&dwidth, &dheight, A_ZOOM); | |
567 drwX = | |
568 (vo_screenwidth - | |
569 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth)) / 2; | |
570 drwY = | |
571 (vo_screenheight - | |
572 (dheight > | |
573 vo_screenheight ? vo_screenheight : dheight)) / 2; | |
574 vo_dwidth = | |
575 (dwidth > vo_screenwidth ? vo_screenwidth : dwidth); | |
576 vo_dheight = | |
577 (dheight > vo_screenheight ? vo_screenheight : dheight); | |
578 mp_msg(MSGT_VO, MSGL_V, | |
579 "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", drwX, drwY, | |
580 vo_dwidth, vo_dheight); | |
581 } | |
582 } | |
1 | 583 |
14742 | 584 if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) |
585 { | |
15192 | 586 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
587 drwY - (vo_panscan_y >> 1), | |
588 vo_dwidth + vo_panscan_x - 1, | |
589 vo_dheight + vo_panscan_y - 1); | |
14742 | 590 } |
591 | |
12582 | 592 if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) |
14782 | 593 { |
594 /* did we already draw a buffer */ | |
595 if ( visible_buf != -1 ) | |
596 { | |
597 /* redraw the last visible buffer */ | |
598 put_xvimage( xvimage[visible_buf] ); | |
599 } | |
600 } | |
1 | 601 } |
602 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
603 static void draw_osd(void) |
12582 | 604 { |
605 vo_draw_text(image_width - | |
606 image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x), | |
607 image_height, draw_alpha_fnc); | |
608 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
609 |
182 | 610 static void flip_page(void) |
1 | 611 { |
14782 | 612 put_xvimage( xvimage[current_buf] ); |
6304
ee65527096c2
pan&scan support with -vo xv by ?? <mplayer@svennevid.net>
arpi
parents:
6295
diff
changeset
|
613 |
14782 | 614 /* remember the currently visible buffer */ |
615 visible_buf = current_buf; | |
616 | |
12582 | 617 if (num_buffers > 1) |
618 { | |
619 current_buf = | |
620 vo_directrendering ? 0 : ((current_buf + 1) % num_buffers); | |
621 XFlush(mDisplay); | |
622 } else | |
623 XSync(mDisplay, False); | |
624 return; | |
1 | 625 } |
626 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
627 static int draw_slice(uint8_t * image[], int stride[], int w, int h, |
12582 | 628 int x, int y) |
1 | 629 { |
12582 | 630 uint8_t *dst; |
182 | 631 |
12582 | 632 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] + |
633 xvimage[current_buf]->pitches[0] * y + x; | |
634 memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0], | |
635 stride[0]); | |
182 | 636 |
12582 | 637 x /= 2; |
638 y /= 2; | |
639 w /= 2; | |
640 h /= 2; | |
1 | 641 |
12582 | 642 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] + |
643 xvimage[current_buf]->pitches[1] * y + x; | |
644 if (image_format != IMGFMT_YV12) | |
645 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
646 stride[1]); | |
647 else | |
648 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
649 stride[2]); | |
5316 | 650 |
12582 | 651 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] + |
652 xvimage[current_buf]->pitches[2] * y + x; | |
653 if (image_format == IMGFMT_YV12) | |
654 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
655 stride[1]); | |
656 else | |
657 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
658 stride[2]); | |
6231 | 659 |
12582 | 660 return 0; |
1 | 661 } |
662 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
663 static int draw_frame(uint8_t * src[]) |
12582 | 664 { |
7684 | 665 printf("draw_frame() called!!!!!!"); |
666 return -1; | |
1 | 667 } |
668 | |
12582 | 669 static uint32_t draw_image(mp_image_t * mpi) |
670 { | |
671 if (mpi->flags & MP_IMGFLAG_DIRECT) | |
672 { | |
673 // direct rendering: | |
674 current_buf = (int) (mpi->priv); // hack! | |
675 return VO_TRUE; | |
6760 | 676 } |
12582 | 677 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
678 return VO_TRUE; // done | |
679 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
680 { | |
681 draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); | |
682 return VO_TRUE; | |
7684 | 683 } |
12582 | 684 if (mpi->flags & MP_IMGFLAG_YUV) |
685 { | |
686 // packed YUV: | |
687 memcpy_pic(xvimage[current_buf]->data + | |
688 xvimage[current_buf]->offsets[0], mpi->planes[0], | |
689 mpi->w * (mpi->bpp / 8), mpi->h, | |
690 xvimage[current_buf]->pitches[0], mpi->stride[0]); | |
691 return VO_TRUE; | |
7684 | 692 } |
12582 | 693 return VO_FALSE; // not (yet) supported |
6760 | 694 } |
695 | |
12582 | 696 static uint32_t get_image(mp_image_t * mpi) |
697 { | |
698 int buf = current_buf; // we shouldn't change current_buf unless we do DR! | |
699 | |
700 if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1) | |
701 return VO_FALSE; // it is not static | |
702 if (mpi->imgfmt != image_format) | |
703 return VO_FALSE; // needs conversion :( | |
4980 | 704 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
12582 | 705 if (mpi->flags & MP_IMGFLAG_READABLE && |
706 (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) | |
707 { | |
708 // reference (I/P) frame of IP or IPB: | |
709 if (num_buffers < 2) | |
710 return VO_FALSE; // not enough | |
711 current_ip_buf ^= 1; | |
712 // for IPB with 2 buffers we can DR only one of the 2 P frames: | |
713 if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3 | |
714 && current_ip_buf) | |
715 return VO_FALSE; | |
716 buf = current_ip_buf; | |
717 if (mpi->type == MP_IMGTYPE_IPB) | |
718 ++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
|
719 } |
12582 | 720 if (mpi->height > xvimage[buf]->height) |
721 return VO_FALSE; //buffer to small | |
722 if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0]) | |
723 return VO_FALSE; //buffer to small | |
724 if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) | |
725 || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0])) | |
726 { | |
727 current_buf = buf; | |
728 mpi->planes[0] = | |
729 xvimage[current_buf]->data + xvimage[current_buf]->offsets[0]; | |
730 mpi->stride[0] = xvimage[current_buf]->pitches[0]; | |
731 mpi->width = mpi->stride[0] / (mpi->bpp / 8); | |
732 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
733 { | |
734 if (mpi->flags & MP_IMGFLAG_SWAPPED) | |
735 { | |
736 // I420 | |
737 mpi->planes[1] = | |
738 xvimage[current_buf]->data + | |
739 xvimage[current_buf]->offsets[1]; | |
740 mpi->planes[2] = | |
741 xvimage[current_buf]->data + | |
742 xvimage[current_buf]->offsets[2]; | |
743 mpi->stride[1] = xvimage[current_buf]->pitches[1]; | |
744 mpi->stride[2] = xvimage[current_buf]->pitches[2]; | |
745 } else | |
746 { | |
747 // YV12 | |
748 mpi->planes[1] = | |
749 xvimage[current_buf]->data + | |
750 xvimage[current_buf]->offsets[2]; | |
751 mpi->planes[2] = | |
752 xvimage[current_buf]->data + | |
753 xvimage[current_buf]->offsets[1]; | |
754 mpi->stride[1] = xvimage[current_buf]->pitches[2]; | |
755 mpi->stride[2] = xvimage[current_buf]->pitches[1]; | |
756 } | |
757 } | |
758 mpi->flags |= MP_IMGFLAG_DIRECT; | |
759 mpi->priv = (void *) current_buf; | |
760 // printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
761 return VO_TRUE; | |
4980 | 762 } |
763 return VO_FALSE; | |
764 } | |
765 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
766 static int query_format(uint32_t format) |
1 | 767 { |
10855 | 768 uint32_t i; |
12582 | 769 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 |
770 | |
771 /* check image formats */ | |
772 for (i = 0; i < formats; i++) | |
773 { | |
774 if (fo[i].id == format) | |
775 return flag; //xv_format = fo[i].id; | |
776 } | |
777 return 0; | |
1 | 778 } |
779 | |
12582 | 780 static void uninit(void) |
1852 | 781 { |
12582 | 782 int i; |
783 | |
784 if (!vo_config_count) | |
785 return; | |
14782 | 786 visible_buf = -1; |
12582 | 787 XvFreeAdaptorInfo(ai); |
788 ai = NULL; | |
13953 | 789 if(fo){ |
790 XFree(fo); | |
791 fo=NULL; | |
792 } | |
12582 | 793 for (i = 0; i < num_buffers; i++) |
794 deallocate_xvimage(i); | |
6016 | 795 #ifdef HAVE_XF86VM |
12582 | 796 vo_vm_close(mDisplay); |
6016 | 797 #endif |
12582 | 798 vo_x11_uninit(); |
322
4e69a8e2700a
Screensaver and monitor powersafe function is switched off when playing a
laaz
parents:
249
diff
changeset
|
799 } |
1 | 800 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
801 static int preinit(const char *arg) |
4352 | 802 { |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
803 XvPortID xv_p; |
12582 | 804 int busy_ports = 0; |
10855 | 805 unsigned int i; |
14742 | 806 strarg_t ck_src_arg = { 0, NULL }; |
807 strarg_t ck_method_arg = { 0, NULL }; | |
808 | |
809 opt_t subopts[] = | |
810 { | |
811 /* name arg type arg var test */ | |
812 { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos }, | |
813 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, | |
814 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | |
815 { NULL } | |
816 }; | |
12582 | 817 |
10826 | 818 xv_port = 0; |
819 | |
14742 | 820 /* parse suboptions */ |
821 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
|
822 { |
14742 | 823 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
|
824 } |
14742 | 825 |
826 /* modify colorkey settings according to the given options */ | |
827 xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); | |
828 | |
12582 | 829 if (!vo_init()) |
830 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
831 |
12582 | 832 /* check for Xvideo extension */ |
833 if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err)) | |
834 { | |
835 mp_msg(MSGT_VO, MSGL_ERR, | |
836 "Sorry, Xv not supported by this X11 version/driver\n"); | |
837 mp_msg(MSGT_VO, MSGL_ERR, | |
838 "******** Try with -vo x11 or -vo sdl *********\n"); | |
839 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
840 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
841 |
12582 | 842 /* check for Xvideo support */ |
843 if (Success != | |
844 XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors, | |
845 &ai)) | |
846 { | |
847 mp_msg(MSGT_VO, MSGL_ERR, "Xv: XvQueryAdaptors failed\n"); | |
848 return -1; | |
849 } | |
850 | |
851 /* check adaptors */ | |
852 if (xv_port) | |
853 { | |
10839 | 854 int port_found; |
12582 | 855 |
856 for (port_found = 0, i = 0; !port_found && i < adaptors; i++) | |
857 { | |
858 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
859 { | |
860 for (xv_p = ai[i].base_id; | |
861 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
862 { | |
863 if (xv_p == xv_port) | |
864 { | |
10839 | 865 port_found = 1; |
866 break; | |
867 } | |
868 } | |
869 } | |
870 } | |
12582 | 871 if (port_found) |
872 { | |
10839 | 873 if (XvGrabPort(mDisplay, xv_port, CurrentTime)) |
874 xv_port = 0; | |
12582 | 875 } else |
876 { | |
877 mp_msg(MSGT_VO, MSGL_WARN, | |
878 "Xv: Invalid port parameter, overriding with port 0\n"); | |
10839 | 879 xv_port = 0; |
880 } | |
10826 | 881 } |
12582 | 882 |
883 for (i = 0; i < adaptors && xv_port == 0; i++) | |
884 { | |
885 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
886 { | |
887 for (xv_p = ai[i].base_id; | |
888 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
889 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) | |
890 { | |
891 xv_port = xv_p; | |
892 break; | |
893 } else | |
894 { | |
895 mp_msg(MSGT_VO, MSGL_WARN, | |
896 "Xv: could not grab port %i\n", (int) xv_p); | |
897 ++busy_ports; | |
898 } | |
899 } | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
900 } |
12582 | 901 if (!xv_port) |
902 { | |
903 if (busy_ports) | |
904 mp_msg(MSGT_VO, MSGL_ERR, | |
905 "Could not find free Xvideo port - maybe another process is already using it.\n" | |
906 "Close all video applications, and try again. If that does not help,\n" | |
907 "see 'mplayer -vo help' for other (non-xv) video out drivers.\n"); | |
908 else | |
909 mp_msg(MSGT_VO, MSGL_ERR, | |
910 "It seems there is no Xvideo support for your video card available.\n" | |
13914 | 911 "Run 'xvinfo' to verify its Xv support and read DOCS/HTML/en/video.html#xv!\n" |
12582 | 912 "See 'mplayer -vo help' for other (non-xv) video out drivers. Try -vo x11\n"); |
913 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
914 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
915 |
14742 | 916 if ( !vo_xv_init_colorkey() ) |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
917 { |
14742 | 918 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
|
919 } |
15826
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15540
diff
changeset
|
920 vo_xv_enable_vsync(); |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
921 |
12582 | 922 fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); |
5566 | 923 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
924 return 0; |
4352 | 925 } |
1 | 926 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
927 static int control(uint32_t request, void *data, ...) |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
928 { |
12582 | 929 switch (request) |
930 { | |
931 case VOCTRL_PAUSE: | |
932 return (int_pause = 1); | |
933 case VOCTRL_RESUME: | |
934 return (int_pause = 0); | |
935 case VOCTRL_QUERY_FORMAT: | |
936 return query_format(*((uint32_t *) data)); | |
937 case VOCTRL_GET_IMAGE: | |
938 return get_image(data); | |
939 case VOCTRL_DRAW_IMAGE: | |
940 return draw_image(data); | |
941 case VOCTRL_GUISUPPORT: | |
942 return VO_TRUE; | |
943 case VOCTRL_GET_PANSCAN: | |
944 if (!vo_config_count || !vo_fs) | |
945 return VO_FALSE; | |
946 return VO_TRUE; | |
947 case VOCTRL_FULLSCREEN: | |
948 vo_x11_fullscreen(); | |
949 /* indended, fallthrough to update panscan on fullscreen/windowed switch */ | |
950 case VOCTRL_SET_PANSCAN: | |
951 if ((vo_fs && (vo_panscan != vo_panscan_amount)) | |
952 || (!vo_fs && vo_panscan_amount)) | |
953 { | |
954 int old_y = vo_panscan_y; | |
955 | |
956 panscan_calc(); | |
957 | |
958 if (old_y != vo_panscan_y) | |
959 { | |
960 vo_x11_clearwindow_part(mDisplay, vo_window, | |
961 vo_dwidth + vo_panscan_x - 1, | |
962 vo_dheight + vo_panscan_y - 1, | |
963 1); | |
15190 | 964 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
965 drwY - (vo_panscan_y >> 1), | |
966 vo_dwidth + vo_panscan_x - 1, | |
967 vo_dheight + vo_panscan_y - 1); | |
12582 | 968 flip_page(); |
969 } | |
970 } | |
971 return VO_TRUE; | |
972 case VOCTRL_SET_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_set_eq(xv_port, data, value)); | |
983 } | |
984 case VOCTRL_GET_EQUALIZER: | |
985 { | |
986 va_list ap; | |
987 int *value; | |
988 | |
989 va_start(ap, data); | |
990 value = va_arg(ap, int *); | |
991 | |
992 va_end(ap); | |
993 | |
994 return (vo_xv_get_eq(xv_port, data, value)); | |
995 } | |
996 case VOCTRL_ONTOP: | |
997 vo_x11_ontop(); | |
998 return VO_TRUE; | |
999 } | |
1000 return VO_NOTIMPL; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
1001 } |