Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 27895:69b4b8d73b5e
Remove a nonsensical "else" for the video mode switching case.
author | reimar |
---|---|
date | Sat, 15 Nov 2008 19:14:09 +0000 |
parents | 761414233746 |
children | 69dd19cdcdc5 |
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 | |
24133 | 42 #include "input/input.h" |
43 | |
27343 | 44 #ifdef CONFIG_GUI |
23077 | 45 #include "gui/interface.h" |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
46 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
47 |
25963 | 48 #include "libavutil/common.h" |
22461
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
49 |
25216 | 50 static const vo_info_t info = { |
12582 | 51 "X11/Xv", |
52 "xv", | |
53 "Gerd Knorr <kraxel@goldbach.in-berlin.de> and others", | |
54 "" | |
1 | 55 }; |
56 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
57 const LIBVO_EXTERN(xv) |
6719
5291d74a60c9
xv support under cygwin - patch by Sycotic Smith <sycotic at linuxmail.org>
alex
parents:
6417
diff
changeset
|
58 #ifdef HAVE_SHM |
1 | 59 #include <sys/ipc.h> |
60 #include <sys/shm.h> | |
61 #include <X11/extensions/XShm.h> | |
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 |
27892 | 92 static uint32_t drwX, drwY; |
16958 | 93 static uint32_t max_width = 0, max_height = 0; // zero means: not set |
1 | 94 |
12582 | 95 static void (*draw_alpha_fnc) (int x0, int y0, int w, int h, |
96 unsigned char *src, unsigned char *srca, | |
97 int stride); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
98 |
12582 | 99 static void draw_alpha_yv12(int x0, int y0, int w, int h, |
100 unsigned char *src, unsigned char *srca, | |
101 int stride) | |
102 { | |
103 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
104 vo_draw_alpha_yv12(w, h, src, srca, stride, | |
105 xvimage[current_buf]->data + | |
106 xvimage[current_buf]->offsets[0] + | |
107 xvimage[current_buf]->pitches[0] * y0 + x0, | |
108 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
109 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
110 |
12582 | 111 static void draw_alpha_yuy2(int x0, int y0, int w, int h, |
112 unsigned char *src, unsigned char *srca, | |
113 int stride) | |
114 { | |
115 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
116 vo_draw_alpha_yuy2(w, h, src, srca, stride, | |
117 xvimage[current_buf]->data + | |
118 xvimage[current_buf]->offsets[0] + | |
119 xvimage[current_buf]->pitches[0] * y0 + 2 * x0, | |
120 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
121 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
122 |
12582 | 123 static void draw_alpha_uyvy(int x0, int y0, int w, int h, |
124 unsigned char *src, unsigned char *srca, | |
125 int stride) | |
126 { | |
127 x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x); | |
128 vo_draw_alpha_yuy2(w, h, src, srca, stride, | |
129 xvimage[current_buf]->data + | |
130 xvimage[current_buf]->offsets[0] + | |
131 xvimage[current_buf]->pitches[0] * y0 + 2 * x0 + 1, | |
132 xvimage[current_buf]->pitches[0]); | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
133 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
134 |
12582 | 135 static void draw_alpha_null(int x0, int y0, int w, int h, |
136 unsigned char *src, unsigned char *srca, | |
137 int stride) | |
138 { | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
139 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
140 |
6786 | 141 |
7757 | 142 static void deallocate_xvimage(int foo); |
143 | |
22461
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
144 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
|
145 *drwX = *drwY = 0; |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
146 if (vo_fs) { |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
147 aspect(&vo_dwidth, &vo_dheight, A_ZOOM); |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
148 vo_dwidth = FFMIN(vo_dwidth, vo_screenwidth); |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
149 vo_dheight = FFMIN(vo_dheight, vo_screenheight); |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
150 *drwX = (vo_screenwidth - vo_dwidth) / 2; |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
151 *drwY = (vo_screenheight - vo_dheight) / 2; |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
152 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
|
153 *drwX, *drwY, vo_dwidth, vo_dheight); |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
154 } else if (WinID == 0) { |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
155 *drwX = vo_dx; |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
156 *drwY = vo_dy; |
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
157 } |
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 |
182 | 160 /* |
161 * connect to server, create and map window, | |
1 | 162 * allocate colors and (shared) memory |
163 */ | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
164 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
12582 | 165 uint32_t d_height, uint32_t flags, char *title, |
166 uint32_t format) | |
1 | 167 { |
12582 | 168 XVisualInfo vinfo; |
169 XGCValues xgcv; | |
170 XSetWindowAttributes xswa; | |
171 XWindowAttributes attribs; | |
172 unsigned long xswamask; | |
173 int depth; | |
174 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
175 #ifdef CONFIG_XF86VM |
12582 | 176 int vm = 0; |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
177 #endif |
1 | 178 |
12582 | 179 image_height = height; |
180 image_width = width; | |
181 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
|
182 |
16958 | 183 if ((max_width != 0 && max_height != 0) && |
184 (image_width > max_width || image_height > max_height)) | |
185 { | |
20765 | 186 mp_msg( MSGT_VO, MSGL_ERR, MSGTR_VO_XV_ImagedimTooHigh, |
16958 | 187 image_width, image_height, max_width, max_height); |
188 return -1; | |
189 } | |
190 | |
12582 | 191 vo_mouse_autohide = 1; |
192 | |
193 int_pause = 0; | |
14782 | 194 visible_buf = -1; |
1 | 195 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
196 #ifdef CONFIG_XF86VM |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
197 if (flags & VOFLAG_MODESWITCHING) |
12582 | 198 vm = 1; |
4978 | 199 #endif |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
15192
diff
changeset
|
200 flip_flag = flags & VOFLAG_FLIPPING; |
12582 | 201 num_buffers = |
202 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
|
203 |
12582 | 204 /* check image formats */ |
205 { | |
206 unsigned int i; | |
10855 | 207 |
12582 | 208 xv_format = 0; |
209 for (i = 0; i < formats; i++) | |
210 { | |
211 mp_msg(MSGT_VO, MSGL_V, | |
212 "Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id, | |
213 (char *) &fo[i].id, | |
214 (fo[i].format == XvPacked) ? "packed" : "planar"); | |
215 if (fo[i].id == format) | |
216 xv_format = fo[i].id; | |
217 } | |
218 if (!xv_format) | |
219 return -1; | |
220 } | |
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
|
221 |
27343 | 222 #ifdef CONFIG_GUI |
12582 | 223 if (use_gui) |
27878 | 224 guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize the window |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
225 else |
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
226 #endif |
723 | 227 { |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
228 #ifdef CONFIG_XF86VM |
12582 | 229 if (vm) |
230 { | |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
231 vo_vm_switch(); |
27895
69b4b8d73b5e
Remove a nonsensical "else" for the video mode switching case.
reimar
parents:
27892
diff
changeset
|
232 } |
12582 | 233 #endif |
234 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), | |
235 &attribs); | |
236 depth = attribs.depth; | |
237 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) | |
238 depth = 24; | |
239 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); | |
723 | 240 |
12582 | 241 xswa.background_pixel = 0; |
14742 | 242 if (xv_ck_info.method == CK_METHOD_BACKGROUND) |
243 { | |
244 xswa.background_pixel = xv_colorkey; | |
245 } | |
12582 | 246 xswa.border_pixel = 0; |
247 xswamask = CWBackPixel | CWBorderPixel; | |
1 | 248 |
12582 | 249 if (WinID >= 0) |
250 { | |
251 vo_window = WinID ? ((Window) WinID) : mRootWin; | |
252 if (WinID) | |
253 { | |
254 XUnmapWindow(mDisplay, vo_window); | |
255 XChangeWindowAttributes(mDisplay, vo_window, xswamask, | |
256 &xswa); | |
257 vo_x11_selectinput_witherr(mDisplay, vo_window, | |
258 StructureNotifyMask | | |
259 KeyPressMask | | |
260 PropertyChangeMask | | |
261 PointerMotionMask | | |
262 ButtonPressMask | | |
263 ButtonReleaseMask | | |
264 ExposureMask); | |
265 XMapWindow(mDisplay, vo_window); | |
27885
9829cfa41d6d
Replace some of the different inconsistent XGetGeometry uses by a
reimar
parents:
27884
diff
changeset
|
266 vo_x11_update_geometry(); |
15540 | 267 aspect_save_prescale(vo_dwidth, vo_dheight); |
12582 | 268 } |
269 } else | |
270 { | |
27891
8742bcad99b5
Use vo_dwidth/vo_dheight for creating the windows instead of d_width/d_height.
reimar
parents:
27890
diff
changeset
|
271 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, vo_dwidth, vo_dheight, |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23077
diff
changeset
|
272 flags, CopyFromParent, "xv", title); |
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23077
diff
changeset
|
273 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); |
12582 | 274 } |
275 | |
276 if (vo_gc != None) | |
277 XFreeGC(mDisplay, vo_gc); | |
278 vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv); | |
279 XSync(mDisplay, False); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
280 #ifdef CONFIG_XF86VM |
12582 | 281 if (vm) |
282 { | |
283 /* Grab the mouse pointer in our window */ | |
284 if (vo_grabpointer) | |
285 XGrabPointer(mDisplay, vo_window, True, 0, | |
286 GrabModeAsync, GrabModeAsync, | |
287 vo_window, None, CurrentTime); | |
288 XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); | |
289 } | |
4426
1ceadec3ea67
using the common -vm code, patch by Santi B«±jar <tiarda@yahoo.es>
arpi
parents:
4406
diff
changeset
|
290 #endif |
12582 | 291 } |
292 | |
293 mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n", | |
294 xv_port); | |
1 | 295 |
12582 | 296 switch (xv_format) |
297 { | |
298 case IMGFMT_YV12: | |
299 case IMGFMT_I420: | |
300 case IMGFMT_IYUV: | |
301 draw_alpha_fnc = draw_alpha_yv12; | |
302 break; | |
303 case IMGFMT_YUY2: | |
304 case IMGFMT_YVYU: | |
305 draw_alpha_fnc = draw_alpha_yuy2; | |
306 break; | |
307 case IMGFMT_UYVY: | |
308 draw_alpha_fnc = draw_alpha_uyvy; | |
309 break; | |
310 default: | |
311 draw_alpha_fnc = draw_alpha_null; | |
312 } | |
182 | 313 |
12582 | 314 if (vo_config_count) |
315 for (current_buf = 0; current_buf < num_buffers; ++current_buf) | |
316 deallocate_xvimage(current_buf); | |
7757 | 317 |
12582 | 318 for (current_buf = 0; current_buf < num_buffers; ++current_buf) |
319 allocate_xvimage(current_buf); | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
320 |
12582 | 321 current_buf = 0; |
322 current_ip_buf = 0; | |
1 | 323 |
22468
ce47c5e803e2
100l, last patch broke window resizing with xv and xvmc.
reimar
parents:
22461
diff
changeset
|
324 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
|
325 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
|
326 calc_drwXY(&drwX, &drwY); |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6366
diff
changeset
|
327 |
12582 | 328 panscan_calc(); |
18384
29a25bcb3d99
Make sure black borders are drawn when switching videos with -fixed-vo.
reimar
parents:
18234
diff
changeset
|
329 |
29a25bcb3d99
Make sure black borders are drawn when switching videos with -fixed-vo.
reimar
parents:
18234
diff
changeset
|
330 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
|
331 drwY - (vo_panscan_y >> 1), |
29a25bcb3d99
Make sure black borders are drawn when switching videos with -fixed-vo.
reimar
parents:
18234
diff
changeset
|
332 vo_dwidth + vo_panscan_x - 1, |
29a25bcb3d99
Make sure black borders are drawn when switching videos with -fixed-vo.
reimar
parents:
18234
diff
changeset
|
333 vo_dheight + vo_panscan_y - 1); |
29a25bcb3d99
Make sure black borders are drawn when switching videos with -fixed-vo.
reimar
parents:
18234
diff
changeset
|
334 |
12582 | 335 mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX, |
336 drwY, vo_dwidth, vo_dheight); | |
5945 | 337 |
12582 | 338 if (vo_ontop) |
339 vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | |
11542 | 340 |
12582 | 341 return 0; |
1 | 342 } |
343 | |
182 | 344 static void allocate_xvimage(int foo) |
1 | 345 { |
12582 | 346 /* |
347 * allocate XvImages. FIXME: no error checking, without | |
348 * mit-shm this will bomb... trzing to fix ::atmos | |
349 */ | |
6416 | 350 #ifdef HAVE_SHM |
12582 | 351 if (mLocalDisplay && XShmQueryExtension(mDisplay)) |
352 Shmem_Flag = 1; | |
353 else | |
354 { | |
355 Shmem_Flag = 0; | |
356 mp_msg(MSGT_VO, MSGL_INFO, | |
20765 | 357 MSGTR_LIBVO_XV_SharedMemoryNotSupported); |
12582 | 358 } |
359 if (Shmem_Flag) | |
360 { | |
361 xvimage[foo] = | |
362 (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, | |
363 NULL, image_width, image_height, | |
364 &Shminfo[foo]); | |
1 | 365 |
12582 | 366 Shminfo[foo].shmid = |
367 shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); | |
368 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
369 Shminfo[foo].readOnly = False; | |
1 | 370 |
12582 | 371 xvimage[foo]->data = Shminfo[foo].shmaddr; |
372 XShmAttach(mDisplay, &Shminfo[foo]); | |
373 XSync(mDisplay, False); | |
374 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); | |
375 } else | |
6416 | 376 #endif |
12582 | 377 { |
378 xvimage[foo] = | |
379 (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, | |
380 image_width, image_height); | |
381 xvimage[foo]->data = malloc(xvimage[foo]->data_size); | |
382 XSync(mDisplay, False); | |
383 } | |
384 memset(xvimage[foo]->data, 128, xvimage[foo]->data_size); | |
385 return; | |
1 | 386 } |
387 | |
1794 | 388 static void deallocate_xvimage(int foo) |
389 { | |
6416 | 390 #ifdef HAVE_SHM |
12582 | 391 if (Shmem_Flag) |
392 { | |
393 XShmDetach(mDisplay, &Shminfo[foo]); | |
394 shmdt(Shminfo[foo].shmaddr); | |
395 } else | |
6416 | 396 #endif |
12582 | 397 { |
398 free(xvimage[foo]->data); | |
399 } | |
400 XFree(xvimage[foo]); | |
401 | |
402 XSync(mDisplay, False); | |
403 return; | |
1794 | 404 } |
405 | |
14782 | 406 static inline void put_xvimage( XvImage * xvi ) |
407 { | |
408 #ifdef HAVE_SHM | |
409 if (Shmem_Flag) | |
410 { | |
411 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
412 xvi, 0, 0, image_width, | |
413 image_height, drwX - (vo_panscan_x >> 1), | |
414 drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x, | |
415 vo_dheight + vo_panscan_y, | |
416 False); | |
417 } else | |
418 #endif | |
419 { | |
420 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, | |
421 xvi, 0, 0, image_width, image_height, | |
422 drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1), | |
423 vo_dwidth + vo_panscan_x, | |
424 vo_dheight + vo_panscan_y); | |
425 } | |
426 } | |
427 | |
31 | 428 static void check_events(void) |
1 | 429 { |
12582 | 430 int e = vo_x11_check_events(mDisplay); |
431 | |
432 if (e & VO_EVENT_RESIZE) | |
433 { | |
22461
c54ad95f852a
Factor out some duplicated code in vo_xv and vo_xvmc
reimar
parents:
22232
diff
changeset
|
434 calc_drwXY(&drwX, &drwY); |
12582 | 435 } |
1 | 436 |
14742 | 437 if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) |
438 { | |
15192 | 439 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
440 drwY - (vo_panscan_y >> 1), | |
441 vo_dwidth + vo_panscan_x - 1, | |
442 vo_dheight + vo_panscan_y - 1); | |
14742 | 443 } |
444 | |
12582 | 445 if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) |
14782 | 446 { |
447 /* did we already draw a buffer */ | |
448 if ( visible_buf != -1 ) | |
449 { | |
450 /* redraw the last visible buffer */ | |
451 put_xvimage( xvimage[visible_buf] ); | |
452 } | |
453 } | |
1 | 454 } |
455 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
456 static void draw_osd(void) |
12582 | 457 { |
458 vo_draw_text(image_width - | |
459 image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x), | |
460 image_height, draw_alpha_fnc); | |
461 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
462 |
182 | 463 static void flip_page(void) |
1 | 464 { |
14782 | 465 put_xvimage( xvimage[current_buf] ); |
6304
ee65527096c2
pan&scan support with -vo xv by ?? <mplayer@svennevid.net>
arpi
parents:
6295
diff
changeset
|
466 |
14782 | 467 /* remember the currently visible buffer */ |
468 visible_buf = current_buf; | |
469 | |
12582 | 470 if (num_buffers > 1) |
471 { | |
472 current_buf = | |
473 vo_directrendering ? 0 : ((current_buf + 1) % num_buffers); | |
474 XFlush(mDisplay); | |
475 } else | |
476 XSync(mDisplay, False); | |
477 return; | |
1 | 478 } |
479 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
480 static int draw_slice(uint8_t * image[], int stride[], int w, int h, |
12582 | 481 int x, int y) |
1 | 482 { |
12582 | 483 uint8_t *dst; |
182 | 484 |
12582 | 485 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] + |
486 xvimage[current_buf]->pitches[0] * y + x; | |
487 memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0], | |
488 stride[0]); | |
182 | 489 |
12582 | 490 x /= 2; |
491 y /= 2; | |
492 w /= 2; | |
493 h /= 2; | |
1 | 494 |
12582 | 495 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] + |
496 xvimage[current_buf]->pitches[1] * y + x; | |
497 if (image_format != IMGFMT_YV12) | |
498 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
499 stride[1]); | |
500 else | |
501 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
502 stride[2]); | |
5316 | 503 |
12582 | 504 dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] + |
505 xvimage[current_buf]->pitches[2] * y + x; | |
506 if (image_format == IMGFMT_YV12) | |
507 memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1], | |
508 stride[1]); | |
509 else | |
510 memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1], | |
511 stride[2]); | |
6231 | 512 |
12582 | 513 return 0; |
1 | 514 } |
515 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
516 static int draw_frame(uint8_t * src[]) |
12582 | 517 { |
27883
96831cf06109
Remove code from unused and since ages deprecated draw_frame function.
reimar
parents:
27882
diff
changeset
|
518 return VO_ERROR; |
1 | 519 } |
520 | |
12582 | 521 static uint32_t draw_image(mp_image_t * mpi) |
522 { | |
523 if (mpi->flags & MP_IMGFLAG_DIRECT) | |
524 { | |
525 // direct rendering: | |
526 current_buf = (int) (mpi->priv); // hack! | |
527 return VO_TRUE; | |
6760 | 528 } |
12582 | 529 if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) |
530 return VO_TRUE; // done | |
531 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
532 { | |
533 draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); | |
534 return VO_TRUE; | |
7684 | 535 } |
12582 | 536 if (mpi->flags & MP_IMGFLAG_YUV) |
537 { | |
538 // packed YUV: | |
539 memcpy_pic(xvimage[current_buf]->data + | |
540 xvimage[current_buf]->offsets[0], mpi->planes[0], | |
541 mpi->w * (mpi->bpp / 8), mpi->h, | |
542 xvimage[current_buf]->pitches[0], mpi->stride[0]); | |
543 return VO_TRUE; | |
7684 | 544 } |
12582 | 545 return VO_FALSE; // not (yet) supported |
6760 | 546 } |
547 | |
12582 | 548 static uint32_t get_image(mp_image_t * mpi) |
549 { | |
550 int buf = current_buf; // we shouldn't change current_buf unless we do DR! | |
551 | |
552 if (mpi->type == MP_IMGTYPE_STATIC && num_buffers > 1) | |
553 return VO_FALSE; // it is not static | |
554 if (mpi->imgfmt != image_format) | |
555 return VO_FALSE; // needs conversion :( | |
4980 | 556 // if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram |
12582 | 557 if (mpi->flags & MP_IMGFLAG_READABLE && |
558 (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) | |
559 { | |
560 // reference (I/P) frame of IP or IPB: | |
561 if (num_buffers < 2) | |
562 return VO_FALSE; // not enough | |
563 current_ip_buf ^= 1; | |
564 // for IPB with 2 buffers we can DR only one of the 2 P frames: | |
565 if (mpi->type == MP_IMGTYPE_IPB && num_buffers < 3 | |
566 && current_ip_buf) | |
567 return VO_FALSE; | |
568 buf = current_ip_buf; | |
569 if (mpi->type == MP_IMGTYPE_IPB) | |
570 ++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
|
571 } |
12582 | 572 if (mpi->height > xvimage[buf]->height) |
573 return VO_FALSE; //buffer to small | |
574 if (mpi->width * (mpi->bpp / 8) > xvimage[buf]->pitches[0]) | |
575 return VO_FALSE; //buffer to small | |
576 if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) | |
577 || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0])) | |
578 { | |
579 current_buf = buf; | |
580 mpi->planes[0] = | |
581 xvimage[current_buf]->data + xvimage[current_buf]->offsets[0]; | |
582 mpi->stride[0] = xvimage[current_buf]->pitches[0]; | |
583 mpi->width = mpi->stride[0] / (mpi->bpp / 8); | |
584 if (mpi->flags & MP_IMGFLAG_PLANAR) | |
585 { | |
586 if (mpi->flags & MP_IMGFLAG_SWAPPED) | |
587 { | |
588 // I420 | |
589 mpi->planes[1] = | |
590 xvimage[current_buf]->data + | |
591 xvimage[current_buf]->offsets[1]; | |
592 mpi->planes[2] = | |
593 xvimage[current_buf]->data + | |
594 xvimage[current_buf]->offsets[2]; | |
595 mpi->stride[1] = xvimage[current_buf]->pitches[1]; | |
596 mpi->stride[2] = xvimage[current_buf]->pitches[2]; | |
597 } else | |
598 { | |
599 // YV12 | |
600 mpi->planes[1] = | |
601 xvimage[current_buf]->data + | |
602 xvimage[current_buf]->offsets[2]; | |
603 mpi->planes[2] = | |
604 xvimage[current_buf]->data + | |
605 xvimage[current_buf]->offsets[1]; | |
606 mpi->stride[1] = xvimage[current_buf]->pitches[2]; | |
607 mpi->stride[2] = xvimage[current_buf]->pitches[1]; | |
608 } | |
609 } | |
610 mpi->flags |= MP_IMGFLAG_DIRECT; | |
611 mpi->priv = (void *) current_buf; | |
612 // printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n"); | |
613 return VO_TRUE; | |
4980 | 614 } |
615 return VO_FALSE; | |
616 } | |
617 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
618 static int query_format(uint32_t format) |
1 | 619 { |
10855 | 620 uint32_t i; |
12582 | 621 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 |
622 | |
623 /* check image formats */ | |
624 for (i = 0; i < formats; i++) | |
625 { | |
626 if (fo[i].id == format) | |
627 return flag; //xv_format = fo[i].id; | |
628 } | |
629 return 0; | |
1 | 630 } |
631 | |
12582 | 632 static void uninit(void) |
1852 | 633 { |
12582 | 634 int i; |
635 | |
636 if (!vo_config_count) | |
637 return; | |
14782 | 638 visible_buf = -1; |
12582 | 639 XvFreeAdaptorInfo(ai); |
640 ai = NULL; | |
13953 | 641 if(fo){ |
642 XFree(fo); | |
643 fo=NULL; | |
644 } | |
12582 | 645 for (i = 0; i < num_buffers; i++) |
646 deallocate_xvimage(i); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
647 #ifdef CONFIG_XF86VM |
27890
a4e2700e9381
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
reimar
parents:
27889
diff
changeset
|
648 vo_vm_close(); |
6016 | 649 #endif |
24133 | 650 mp_input_rm_event_fd(ConnectionNumber(mDisplay)); |
12582 | 651 vo_x11_uninit(); |
322
4e69a8e2700a
Screensaver and monitor powersafe function is switched off when playing a
laaz
parents:
249
diff
changeset
|
652 } |
1 | 653 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
654 static int preinit(const char *arg) |
4352 | 655 { |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
656 XvPortID xv_p; |
12582 | 657 int busy_ports = 0; |
10855 | 658 unsigned int i; |
14742 | 659 strarg_t ck_src_arg = { 0, NULL }; |
660 strarg_t ck_method_arg = { 0, NULL }; | |
26730
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
661 int xv_adaptor = -1; |
14742 | 662 |
663 opt_t subopts[] = | |
664 { | |
665 /* name arg type arg var test */ | |
666 { "port", OPT_ARG_INT, &xv_port, (opt_test_f)int_pos }, | |
26730
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
667 { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg }, |
14742 | 668 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, |
669 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | |
670 { NULL } | |
671 }; | |
12582 | 672 |
10826 | 673 xv_port = 0; |
674 | |
14742 | 675 /* parse suboptions */ |
676 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
|
677 { |
14742 | 678 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
|
679 } |
14742 | 680 |
681 /* modify colorkey settings according to the given options */ | |
682 xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); | |
683 | |
12582 | 684 if (!vo_init()) |
685 return -1; | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
686 |
12582 | 687 /* check for Xvideo extension */ |
688 if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err)) | |
689 { | |
690 mp_msg(MSGT_VO, MSGL_ERR, | |
20765 | 691 MSGTR_LIBVO_XV_XvNotSupportedByX11); |
12582 | 692 return -1; |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
693 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
694 |
12582 | 695 /* check for Xvideo support */ |
696 if (Success != | |
697 XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &adaptors, | |
698 &ai)) | |
699 { | |
20765 | 700 mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_XvQueryAdaptorsFailed); |
12582 | 701 return -1; |
702 } | |
703 | |
704 /* check adaptors */ | |
705 if (xv_port) | |
706 { | |
10839 | 707 int port_found; |
12582 | 708 |
709 for (port_found = 0, i = 0; !port_found && i < adaptors; i++) | |
710 { | |
711 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
712 { | |
713 for (xv_p = ai[i].base_id; | |
714 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
715 { | |
716 if (xv_p == xv_port) | |
717 { | |
10839 | 718 port_found = 1; |
719 break; | |
720 } | |
721 } | |
722 } | |
723 } | |
12582 | 724 if (port_found) |
725 { | |
10839 | 726 if (XvGrabPort(mDisplay, xv_port, CurrentTime)) |
727 xv_port = 0; | |
12582 | 728 } else |
729 { | |
730 mp_msg(MSGT_VO, MSGL_WARN, | |
20765 | 731 MSGTR_LIBVO_XV_InvalidPortParameter); |
10839 | 732 xv_port = 0; |
733 } | |
10826 | 734 } |
12582 | 735 |
736 for (i = 0; i < adaptors && xv_port == 0; i++) | |
737 { | |
26730
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
738 /* check if adaptor number has been specified */ |
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
739 if (xv_adaptor != -1 && xv_adaptor != i) |
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
740 continue; |
41794a5fb100
Add a new suboption to -vo xv and -vo xvmc that allows selection
ben
parents:
25963
diff
changeset
|
741 |
12582 | 742 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) |
743 { | |
744 for (xv_p = ai[i].base_id; | |
745 xv_p < ai[i].base_id + ai[i].num_ports; ++xv_p) | |
746 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) | |
747 { | |
748 xv_port = xv_p; | |
27031
0f7770b2230d
Move message about which adapter is used to verbose mode.
diego
parents:
26755
diff
changeset
|
749 mp_msg(MSGT_VO, MSGL_V, |
0f7770b2230d
Move message about which adapter is used to verbose mode.
diego
parents:
26755
diff
changeset
|
750 "[VO_XV] Using Xv Adapter #%d (%s)\n", |
0f7770b2230d
Move message about which adapter is used to verbose mode.
diego
parents:
26755
diff
changeset
|
751 i, ai[i].name); |
12582 | 752 break; |
753 } else | |
754 { | |
755 mp_msg(MSGT_VO, MSGL_WARN, | |
20765 | 756 MSGTR_LIBVO_XV_CouldNotGrabPort, (int) xv_p); |
12582 | 757 ++busy_ports; |
758 } | |
759 } | |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
760 } |
12582 | 761 if (!xv_port) |
762 { | |
763 if (busy_ports) | |
764 mp_msg(MSGT_VO, MSGL_ERR, | |
20765 | 765 MSGTR_LIBVO_XV_CouldNotFindFreePort); |
12582 | 766 else |
767 mp_msg(MSGT_VO, MSGL_ERR, | |
20765 | 768 MSGTR_LIBVO_XV_NoXvideoSupport); |
12582 | 769 return -1; |
5509
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
770 } |
1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
arpi
parents:
5466
diff
changeset
|
771 |
14742 | 772 if ( !vo_xv_init_colorkey() ) |
7857
3c690d2ad1ac
MPlayer being unable to display video properly on many nVidia graphics cards.
arpi
parents:
7848
diff
changeset
|
773 { |
14742 | 774 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
|
775 } |
15826
db966bdf6f5b
Try to set XV_SYNC_TO_VBLANK to enable vsync on non-overlay xv adapters.
reimar
parents:
15540
diff
changeset
|
776 vo_xv_enable_vsync(); |
16958 | 777 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
|
778 |
12582 | 779 fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); |
5566 | 780 |
24133 | 781 mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events); |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
782 return 0; |
4352 | 783 } |
1 | 784 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15826
diff
changeset
|
785 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
|
786 { |
12582 | 787 switch (request) |
788 { | |
789 case VOCTRL_PAUSE: | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26730
diff
changeset
|
790 return int_pause = 1; |
12582 | 791 case VOCTRL_RESUME: |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26730
diff
changeset
|
792 return int_pause = 0; |
12582 | 793 case VOCTRL_QUERY_FORMAT: |
794 return query_format(*((uint32_t *) data)); | |
795 case VOCTRL_GET_IMAGE: | |
796 return get_image(data); | |
797 case VOCTRL_DRAW_IMAGE: | |
798 return draw_image(data); | |
799 case VOCTRL_GUISUPPORT: | |
800 return VO_TRUE; | |
801 case VOCTRL_GET_PANSCAN: | |
802 if (!vo_config_count || !vo_fs) | |
803 return VO_FALSE; | |
804 return VO_TRUE; | |
805 case VOCTRL_FULLSCREEN: | |
806 vo_x11_fullscreen(); | |
807 /* indended, fallthrough to update panscan on fullscreen/windowed switch */ | |
808 case VOCTRL_SET_PANSCAN: | |
809 if ((vo_fs && (vo_panscan != vo_panscan_amount)) | |
810 || (!vo_fs && vo_panscan_amount)) | |
811 { | |
812 int old_y = vo_panscan_y; | |
813 | |
814 panscan_calc(); | |
815 | |
816 if (old_y != vo_panscan_y) | |
817 { | |
818 vo_x11_clearwindow_part(mDisplay, vo_window, | |
819 vo_dwidth + vo_panscan_x - 1, | |
820 vo_dheight + vo_panscan_y - 1, | |
821 1); | |
15190 | 822 vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1), |
823 drwY - (vo_panscan_y >> 1), | |
824 vo_dwidth + vo_panscan_x - 1, | |
825 vo_dheight + vo_panscan_y - 1); | |
12582 | 826 flip_page(); |
827 } | |
828 } | |
829 return VO_TRUE; | |
830 case VOCTRL_SET_EQUALIZER: | |
831 { | |
832 va_list ap; | |
833 int value; | |
834 | |
835 va_start(ap, data); | |
836 value = va_arg(ap, int); | |
837 | |
838 va_end(ap); | |
839 | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26730
diff
changeset
|
840 return vo_xv_set_eq(xv_port, data, value); |
12582 | 841 } |
842 case VOCTRL_GET_EQUALIZER: | |
843 { | |
844 va_list ap; | |
845 int *value; | |
846 | |
847 va_start(ap, data); | |
848 value = va_arg(ap, int *); | |
849 | |
850 va_end(ap); | |
851 | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26730
diff
changeset
|
852 return vo_xv_get_eq(xv_port, data, value); |
12582 | 853 } |
854 case VOCTRL_ONTOP: | |
855 vo_x11_ontop(); | |
856 return VO_TRUE; | |
22232 | 857 case VOCTRL_UPDATE_SCREENINFO: |
858 update_xinerama_info(); | |
859 return VO_TRUE; | |
12582 | 860 } |
861 return VO_NOTIMPL; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
862 } |