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