Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 5816:1c1aea3f0362
runtime cpustuff disabled by default - it was tested enough
author | arpi |
---|---|
date | Wed, 24 Apr 2002 20:33:12 +0000 |
parents | b8d8d72776f2 |
children | daa705aff4f3 |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
5 * video_out_xmga.c | |
6 * | |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
10 * | |
11 * mpeg2dec is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2, or (at your option) | |
14 * any later version. | |
15 * | |
16 * mpeg2dec is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with GNU Make; see the file COPYING. If not, write to | |
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 */ | |
26 | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 | |
31 #include "config.h" | |
32 #include "video_out.h" | |
33 #include "video_out_internal.h" | |
34 | |
35 LIBVO_EXTERN( xmga ) | |
36 | |
37 #include <sys/ioctl.h> | |
38 #include <unistd.h> | |
39 #include <fcntl.h> | |
40 #include <sys/mman.h> | |
41 | |
42 #include "drivers/mga_vid.h" | |
43 | |
44 #include <X11/Xlib.h> | |
45 #include <X11/Xutil.h> | |
46 #include <errno.h> | |
47 | |
4017 | 48 #ifdef HAVE_XINERAMA |
49 #include <X11/extensions/Xinerama.h> | |
50 #endif | |
51 | |
31 | 52 #include "x11_common.h" |
616 | 53 #include "sub.h" |
2057 | 54 #include "aspect.h" |
31 | 55 |
182 | 56 #ifdef SHOW_TIME |
100 | 57 #include "../linux/timer.h" |
58 static unsigned int timer=0; | |
59 static unsigned int timerd=0; | |
60 #endif | |
61 | |
1 | 62 static vo_info_t vo_info = |
63 { | |
4993 | 64 "X11 (Matrox G200/G4x0/G550 overlay in window using /dev/mga_vid)", |
1 | 65 "xmga", |
66 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
67 "" | |
68 }; | |
69 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
70 //static Display * mDisplay; |
1 | 71 static XGCValues wGCV; |
72 | |
73 static XImage * myximage; | |
74 | |
75 static uint32_t mDepth, bpp, mode; | |
76 static XWindowAttributes attribs; | |
77 static uint32_t X_already_started=0; | |
78 | |
79 static uint32_t wndHeight; | |
80 static uint32_t wndWidth; | |
81 static uint32_t wndX; | |
82 static uint32_t wndY; | |
83 | |
84 static uint32_t fgColor; | |
85 | |
86 static uint32_t mvHeight; | |
87 static uint32_t mvWidth; | |
88 | |
89 static Window mRoot; | |
90 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; | |
4981 | 91 static uint32_t drwcX,drwcY,dwidth,dheight; |
1 | 92 |
93 static XSetWindowAttributes xWAttribs; | |
94 | |
4981 | 95 #define VO_XMGA |
1 | 96 #include "mga_common.c" |
4981 | 97 #undef VO_XMGA |
1 | 98 |
99 static void mDrawColorKey( void ) | |
100 { | |
4795 | 101 XSetBackground( mDisplay,vo_gc,0 ); |
102 XClearWindow( mDisplay,vo_window ); | |
103 XSetForeground( mDisplay,vo_gc,fgColor ); | |
4981 | 104 XFillRectangle( mDisplay,vo_window,vo_gc,drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight) ); |
1 | 105 XFlush( mDisplay ); |
106 } | |
107 | |
120 | 108 static void set_window(){ |
109 | |
4795 | 110 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
4993 | 111 fprintf( stderr,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); |
1852 | 112 drwX=0; drwY=0; // drwWidth=wndWidth; drwHeight=wndHeight; |
4795 | 113 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); |
1852 | 114 fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
115 | |
3558 | 116 aspect(&dwidth,&dheight,A_NOZOOM); |
4981 | 117 if ( vo_fs ) |
120 | 118 { |
3558 | 119 aspect(&dwidth,&dheight,A_ZOOM); |
120 | 120 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
121 drwcX+=drwX; | |
122 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
123 drwcY+=drwY; | |
124 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
125 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
1852 | 126 fprintf( stderr,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
120 | 127 } |
128 | |
129 mDrawColorKey(); | |
130 | |
4017 | 131 #ifdef HAVE_XINERAMA |
132 if(XineramaIsActive(mDisplay)) | |
133 { | |
134 XineramaScreenInfo *screens; | |
135 int num_screens; | |
136 int i; | |
137 | |
138 screens = XineramaQueryScreens(mDisplay,&num_screens); | |
139 | |
140 /* find the screen we are on */ | |
141 i = 0; | |
142 while(!(screens[i].x_org <= drwcX && screens[i].y_org <= drwcY && | |
143 screens[i].x_org + screens[i].width >= drwcX && | |
144 screens[i].y_org + screens[i].height >= drwcY )) | |
145 { | |
146 i++; | |
147 } | |
148 | |
149 /* set drwcX and drwcY to the right values */ | |
150 drwcX = drwcX - screens[i].x_org; | |
151 drwcY = drwcY - screens[i].y_org; | |
152 XFree(screens); | |
153 } | |
154 | |
155 #endif | |
120 | 156 mga_vid_config.x_org=drwcX; |
157 mga_vid_config.y_org=drwcY; | |
158 mga_vid_config.dest_width=drwWidth; | |
159 mga_vid_config.dest_height=drwHeight; | |
160 | |
161 } | |
162 | |
31 | 163 static void check_events(void) |
1 | 164 { |
4303 | 165 int e=vo_x11_check_events(mDisplay); |
166 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; | |
167 if(e&VO_EVENT_EXPOSE) mDrawColorKey(); | |
168 set_window(); | |
169 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) | |
170 printf( "Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); | |
1 | 171 } |
172 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
173 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
174 { vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);} |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
175 |
31 | 176 static void flip_page(void){ |
182 | 177 #ifdef SHOW_TIME |
100 | 178 unsigned int t; |
179 t=GetTimer(); | |
180 printf(" [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); | |
181 timerd=t-timer; | |
182 timer=t; | |
182 | 183 #endif |
100 | 184 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
185 vo_mga_flip_page(); |
31 | 186 } |
1 | 187 |
5158 | 188 static int inited=0; |
189 | |
4433 | 190 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t* info) |
1 | 191 { |
192 char * frame_mem; | |
56 | 193 // uint32_t frame_size; |
927 | 194 // int mScreen; |
1 | 195 unsigned int fg, bg; |
196 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
197 char * name=":0.0"; | |
198 XSizeHints hint; | |
199 XVisualInfo vinfo; | |
200 XEvent xev; | |
201 | |
202 XGCValues xgcv; | |
203 unsigned long xswamask; | |
204 | |
5007 | 205 width+=width&1; |
206 | |
1 | 207 switch(format) |
208 { | |
182 | 209 case IMGFMT_YV12: |
5007 | 210 height+=height&1; |
5317 | 211 mga_vid_config.format=MGA_VID_FORMAT_IYUV; |
182 | 212 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; |
56 | 213 break; |
470 | 214 case IMGFMT_I420: |
215 case IMGFMT_IYUV: | |
5007 | 216 height+=height&1; |
5317 | 217 mga_vid_config.format=MGA_VID_FORMAT_YV12; |
470 | 218 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; |
219 break; | |
56 | 220 case IMGFMT_YUY2: |
221 mga_vid_config.format=MGA_VID_FORMAT_YUY2; | |
182 | 222 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2; |
56 | 223 break; |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
224 case IMGFMT_UYVY: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
225 mga_vid_config.format=MGA_VID_FORMAT_UYVY; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
226 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2; |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
227 break; |
614 | 228 default: printf("mga: invalid output format %0X\n",format); return (-1); |
1 | 229 } |
230 | |
231 if ( X_already_started ) return -1; | |
232 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
233 if (!vo_init()) return -1; |
1 | 234 |
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
|
235 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
236 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
237 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
238 |
1 | 239 mvWidth=width; mvHeight=height; |
240 | |
241 wndX=0; wndY=0; | |
242 wndWidth=d_width; wndHeight=d_height; | |
4981 | 243 vo_fs=fullscreen&1; |
244 vo_dwidth=d_width; vo_dheight=d_height; | |
245 if ( vo_fs ) | |
246 { vo_old_width=d_width; vo_old_height=d_height; } | |
1 | 247 |
248 switch ( vo_depthonscreen ) | |
249 { | |
250 case 32: | |
251 case 24: fgColor=0x00ff00ffL; break; | |
252 case 16: fgColor=0xf81fL; break; | |
253 case 15: fgColor=0x7c1fL; break; | |
614 | 254 default: printf( "Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 255 } |
256 | |
5158 | 257 inited=1; |
258 | |
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
|
259 aspect(&d_width,&d_height,A_NOZOOM); |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
260 #ifdef HAVE_NEW_GUI |
723 | 261 if ( vo_window == None ) |
262 { | |
263 #endif | |
4981 | 264 if ( vo_fs ) |
723 | 265 { |
266 wndWidth=vo_screenwidth; | |
267 wndHeight=vo_screenheight; | |
2039 | 268 #ifdef X11_FULLSCREEN |
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
|
269 aspect(&d_width,&d_height,A_ZOOM); |
2039 | 270 #endif |
723 | 271 } |
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
|
272 dwidth=d_width; dheight=d_height; |
723 | 273 |
274 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); | |
275 mDepth=attribs.depth; | |
276 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
277 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
278 xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone ); | |
279 xWAttribs.background_pixel=0; | |
280 xWAttribs.border_pixel=0; | |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5433
diff
changeset
|
281 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; |
723 | 282 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
1 | 283 |
3847 | 284 if ( WinID>=0 ){ |
4795 | 285 vo_window = WinID ? ((Window)WinID) : RootWindow(mDisplay,mScreen); |
286 XUnmapWindow( mDisplay,vo_window ); | |
287 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); | |
3847 | 288 } else |
4795 | 289 vo_window=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), |
723 | 290 wndX,wndY, |
291 wndWidth,wndHeight, | |
292 xWAttribs.border_pixel, | |
293 mDepth, | |
294 InputOutput, | |
295 vinfo.visual,xswamask,&xWAttribs ); | |
4795 | 296 vo_x11_classhint( mDisplay,vo_window,"xmga" ); |
297 vo_hidecursor(mDisplay,vo_window); | |
4993 | 298 vo_x11_sizehint( wndX,wndY,wndWidth,wndHeight ); |
723 | 299 |
4981 | 300 if ( vo_fs ) vo_x11_decoration( mDisplay,vo_window,0 ); |
1 | 301 |
4795 | 302 XStoreName( mDisplay,vo_window,mTitle ); |
303 XMapWindow( mDisplay,vo_window ); | |
4762 | 304 |
3990 | 305 #ifdef HAVE_XINERAMA |
4795 | 306 vo_x11_xinerama_move(mDisplay,vo_window); |
3990 | 307 #endif |
4795 | 308 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
309 #ifdef HAVE_NEW_GUI |
723 | 310 } |
311 #endif | |
1 | 312 |
120 | 313 set_window(); |
1 | 314 |
315 mga_vid_config.src_width=width; | |
316 mga_vid_config.src_height=height; | |
317 | |
318 mga_vid_config.colkey_on=1; | |
319 mga_vid_config.colkey_red=255; | |
320 mga_vid_config.colkey_green=0; | |
321 mga_vid_config.colkey_blue=255; | |
322 | |
56 | 323 if(mga_init()) return -1; |
1852 | 324 |
325 set_window(); | |
1 | 326 |
4795 | 327 XFlush( mDisplay ); |
328 XSync( mDisplay,False ); | |
4316 | 329 |
330 saver_off(mDisplay); | |
324 | 331 |
1 | 332 return 0; |
333 } | |
334 | |
335 static const vo_info_t* get_info( void ) | |
336 { return &vo_info; } | |
337 | |
338 | |
339 static void | |
340 uninit(void) | |
341 { | |
5158 | 342 if(!inited) return; |
343 inited=0; | |
5651
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5433
diff
changeset
|
344 XSetBackground( mDisplay,vo_gc,0 ); |
b8d8d72776f2
fix playlist bug with gui and rewrite mousecursor show/hide code
pontscho
parents:
5433
diff
changeset
|
345 XClearWindow( mDisplay,vo_window ); |
5158 | 346 mga_uninit(); |
4316 | 347 saver_on(mDisplay); |
5158 | 348 vo_x11_uninit(mDisplay, vo_window); |
1637 | 349 printf("vo: uninit!\n"); |
1 | 350 } |
4352 | 351 |