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