Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 31919:d9a6b45b8ef9
Deobfuscate mencoder decode_video call.
author | reimar |
---|---|
date | Sat, 21 Aug 2010 11:19:45 +0000 |
parents | 317649676214 |
children | 4a890f542e69 |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
2 * copyright (C) 2001 Zoltan Ponekker |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
3 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
4 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
5 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
9 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
10 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
14 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
15 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27927
diff
changeset
|
19 */ |
100 | 20 |
21 //#define SHOW_TIME | |
1 | 22 |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <string.h> | |
26 | |
27 #include "config.h" | |
6296 | 28 |
1 | 29 #include "video_out.h" |
30 #include "video_out_internal.h" | |
31 | |
32 | |
33 #include <sys/ioctl.h> | |
34 #include <unistd.h> | |
35 #include <fcntl.h> | |
36 #include <sys/mman.h> | |
37 | |
38 #include "drivers/mga_vid.h" | |
39 | |
40 #include <X11/Xlib.h> | |
41 #include <X11/Xutil.h> | |
42 #include <errno.h> | |
43 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
44 #ifdef CONFIG_XINERAMA |
4017 | 45 #include <X11/extensions/Xinerama.h> |
46 #endif | |
47 | |
31 | 48 #include "x11_common.h" |
616 | 49 #include "sub.h" |
2057 | 50 #include "aspect.h" |
31 | 51 |
182 | 52 #ifdef SHOW_TIME |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13056
diff
changeset
|
53 #include "osdep/timer.h" |
12582 | 54 static unsigned int timer = 0; |
55 static unsigned int timerd = 0; | |
100 | 56 #endif |
57 | |
27343 | 58 #ifdef CONFIG_GUI |
23077 | 59 #include "gui/interface.h" |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
60 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
61 |
25216 | 62 static const vo_info_t info = { |
12582 | 63 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)", |
64 "xmga", | |
65 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
66 "" | |
1 | 67 }; |
68 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
69 const LIBVO_EXTERN(xmga) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
70 |
12582 | 71 static uint32_t mDepth; |
72 static XWindowAttributes attribs; | |
10988 | 73 static int colorkey; |
1 | 74 |
12582 | 75 static uint32_t mvHeight; |
76 static uint32_t mvWidth; | |
1 | 77 |
12582 | 78 static Window mRoot; |
1 | 79 |
12582 | 80 static XSetWindowAttributes xWAttribs; |
1 | 81 |
25962 | 82 static int initialized = 0; |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
83 |
4981 | 84 #define VO_XMGA |
31364
317649676214
Rename libvo/mga_common.c --> libvo/mga_template.c.
diego
parents:
28446
diff
changeset
|
85 #include "mga_template.c" |
4981 | 86 #undef VO_XMGA |
1 | 87 |
12582 | 88 static void mDrawColorKey(void) |
1 | 89 { |
12582 | 90 XSetBackground(mDisplay, vo_gc, 0); |
91 XClearWindow(mDisplay, vo_window); | |
92 XSetForeground(mDisplay, vo_gc, colorkey); | |
93 XFillRectangle(mDisplay, vo_window, vo_gc, drwX, drwY, drwWidth, | |
94 (vo_fs ? drwHeight - 1 : drwHeight)); | |
95 XFlush(mDisplay); | |
1 | 96 } |
97 | |
31 | 98 static void check_events(void) |
1 | 99 { |
12582 | 100 int e = vo_x11_check_events(mDisplay); |
101 | |
102 if (!(e & VO_EVENT_RESIZE) && !(e & VO_EVENT_EXPOSE)) | |
103 return; | |
104 set_window(); | |
105 mDrawColorKey(); | |
106 if (ioctl(f, MGA_VID_CONFIG, &mga_vid_config)) | |
107 mp_msg(MSGT_VO, MSGL_WARN, | |
108 "Error in mga_vid_config ioctl (wrong mga_vid.o version?)"); | |
1 | 109 } |
110 | |
12582 | 111 static void flip_page(void) |
112 { | |
182 | 113 #ifdef SHOW_TIME |
100 | 114 unsigned int t; |
12582 | 115 |
116 t = GetTimer(); | |
117 mp_msg(MSGT_VO, MSGL_STATUS, | |
118 " [timer: %08X diff: %6d dd: %6d ] \n", t, t - timer, | |
119 (t - timer) - timerd); | |
120 timerd = t - timer; | |
121 timer = t; | |
182 | 122 #endif |
100 | 123 |
12582 | 124 vo_mga_flip_page(); |
31 | 125 } |
1 | 126 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15540
diff
changeset
|
127 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
12582 | 128 uint32_t d_height, uint32_t flags, char *title, |
129 uint32_t format) | |
1 | 130 { |
12582 | 131 XVisualInfo vinfo; |
132 unsigned long xswamask; | |
133 int r, g, b; | |
134 | |
135 if (mga_init(width, height, format)) | |
136 return -1; // ioctl errors? | |
1 | 137 |
12582 | 138 aspect_save_orig(width, height); |
139 aspect_save_prescale(d_width, d_height); | |
18116 | 140 update_xinerama_info(); |
12582 | 141 |
142 mvWidth = width; | |
143 mvHeight = height; | |
1 | 144 |
12582 | 145 vo_panscan_x = vo_panscan_y = vo_panscan_amount = 0; |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
146 |
18509
94965d83e2b6
do aspect correction of video size before calculating vo_dx and vo_dy.
reimar
parents:
18116
diff
changeset
|
147 aspect(&d_width, &d_height, A_NOZOOM); |
12582 | 148 vo_dx = (vo_screenwidth - d_width) / 2; |
149 vo_dy = (vo_screenheight - d_height) / 2; | |
150 geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, | |
151 vo_screenheight); | |
18116 | 152 vo_dx += xinerama_x; |
153 vo_dy += xinerama_y; | |
12582 | 154 vo_dwidth = d_width; |
155 vo_dheight = d_height; | |
6307 | 156 |
12582 | 157 r = (vo_colorkey & 0x00ff0000) >> 16; |
158 g = (vo_colorkey & 0x0000ff00) >> 8; | |
159 b = vo_colorkey & 0x000000ff; | |
160 switch (vo_depthonscreen) | |
161 { | |
162 case 32: | |
163 colorkey = vo_colorkey; | |
164 break; | |
165 case 24: | |
166 colorkey = vo_colorkey & 0x00ffffff; | |
167 break; | |
168 case 16: | |
169 colorkey = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); | |
170 break; | |
171 case 15: | |
172 colorkey = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); | |
173 break; | |
174 default: | |
175 mp_msg(MSGT_VO, MSGL_ERR, | |
176 "Sorry, this (%d) color depth not supported.\n", | |
177 vo_depthonscreen); | |
178 return -1; | |
179 } | |
13946 | 180 mp_msg(MSGT_VO, MSGL_V, "Using colorkey: %x\n", colorkey); |
1 | 181 |
25962 | 182 initialized = 1; |
1 | 183 |
27343 | 184 #ifdef CONFIG_GUI |
12582 | 185 if (use_gui) |
186 guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize the window | |
187 else | |
5985 | 188 #endif |
12582 | 189 { |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13946
diff
changeset
|
190 if (flags & VOFLAG_FULLSCREEN) |
12582 | 191 aspect(&dwidth, &dheight, A_ZOOM); |
723 | 192 |
12582 | 193 XGetWindowAttributes(mDisplay, mRootWin, &attribs); |
194 mDepth = attribs.depth; | |
195 if (mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32) | |
196 mDepth = 24; | |
197 XMatchVisualInfo(mDisplay, mScreen, mDepth, TrueColor, &vinfo); | |
198 xWAttribs.colormap = | |
199 XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone); | |
200 xWAttribs.background_pixel = 0; | |
201 xWAttribs.border_pixel = 0; | |
27927
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27903
diff
changeset
|
202 xswamask = CWBackPixel | CWBorderPixel | CWColormap; |
1 | 203 |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23077
diff
changeset
|
204 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, |
23822 | 205 flags, xWAttribs.colormap, "xmga", title); |
24348
f96e42d494f9
Fix borders for xmga broken by r23675. Tested by Diego.
reimar
parents:
23822
diff
changeset
|
206 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xWAttribs); |
7679 | 207 |
12582 | 208 } // !GUI |
7679 | 209 |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13946
diff
changeset
|
210 if ((flags & VOFLAG_FULLSCREEN) && (!WinID)) |
12582 | 211 { |
212 vo_dx = 0; | |
213 vo_dy = 0; | |
214 vo_dwidth = vo_screenwidth; | |
215 vo_dheight = vo_screenheight; | |
216 vo_fs = 1; | |
217 } | |
7679 | 218 |
12582 | 219 panscan_calc(); |
6755 | 220 |
12582 | 221 mga_vid_config.colkey_on = 1; |
222 mga_vid_config.colkey_red = r; | |
223 mga_vid_config.colkey_green = g; | |
224 mga_vid_config.colkey_blue = b; | |
225 | |
226 set_window(); // set up mga_vid_config.dest_width etc | |
227 | |
228 XSync(mDisplay, False); | |
229 | |
230 ioctl(f, MGA_VID_ON, 0); | |
231 | |
232 return 0; | |
1 | 233 } |
234 | |
12582 | 235 static void uninit(void) |
236 { | |
237 mp_msg(MSGT_VO, MSGL_V, "vo: uninit!\n"); | |
238 mga_uninit(); | |
25962 | 239 if (!initialized) |
12582 | 240 return; // no window? |
25962 | 241 initialized = 0; |
12582 | 242 vo_x11_uninit(); // destroy the window |
1 | 243 } |