Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 1984:34e1fa21df2f
-av/-vc help display status
author | arpi |
---|---|
date | Thu, 27 Sep 2001 13:19:46 +0000 |
parents | 6185fef2703a |
children | 452f3cb96b32 |
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 | |
31 | 48 #include "x11_common.h" |
616 | 49 #include "sub.h" |
31 | 50 |
182 | 51 #ifdef SHOW_TIME |
100 | 52 #include "../linux/timer.h" |
53 static unsigned int timer=0; | |
54 static unsigned int timerd=0; | |
55 #endif | |
56 | |
1 | 57 static vo_info_t vo_info = |
58 { | |
59 "X11 (Matrox G200/G400 overlay in window using /dev/mga_vid)", | |
60 "xmga", | |
61 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
62 "" | |
63 }; | |
64 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
65 //static Display * mDisplay; |
1 | 66 static Window mWindow; |
67 static GC mGC; | |
68 static XGCValues wGCV; | |
69 | |
70 static XImage * myximage; | |
71 | |
72 static uint32_t mDepth, bpp, mode; | |
73 static XWindowAttributes attribs; | |
74 static uint32_t X_already_started=0; | |
75 | |
76 static uint32_t wndHeight; | |
77 static uint32_t wndWidth; | |
78 static uint32_t wndX; | |
79 static uint32_t wndY; | |
80 | |
81 static uint32_t fgColor; | |
82 | |
83 static uint32_t mvHeight; | |
84 static uint32_t mvWidth; | |
85 | |
86 static Window mRoot; | |
87 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; | |
88 static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; | |
89 | |
1783 | 90 #ifdef HAVE_NEW_GUI |
723 | 91 static uint32_t mdwidth,mdheight; |
92 #endif | |
93 | |
1 | 94 static XSetWindowAttributes xWAttribs; |
95 | |
96 #include "mga_common.c" | |
97 | |
98 static void mDrawColorKey( void ) | |
99 { | |
100 XSetForeground( mDisplay,mGC,fgColor ); | |
101 XFillRectangle( mDisplay,mWindow,mGC,drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight) ); | |
102 XFlush( mDisplay ); | |
103 } | |
104 | |
120 | 105 static void set_window(){ |
106 | |
1783 | 107 #ifdef HAVE_NEW_GUI |
723 | 108 if ( vo_window != None ) |
109 { | |
110 mFullscreen=0; | |
111 dwidth=mdwidth; dheight=mdheight; | |
1852 | 112 if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) |
723 | 113 { |
114 mFullscreen=1; | |
115 dwidth=vo_screenwidth; | |
116 dheight=vo_screenwidth * mdheight / mdwidth; | |
117 } | |
118 } | |
119 #endif | |
120 | |
1852 | 121 XGetGeometry( mDisplay,mWindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
122 drwX=0; drwY=0; // drwWidth=wndWidth; drwHeight=wndHeight; | |
123 XTranslateCoordinates( mDisplay,mWindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); | |
124 fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); | |
125 | |
120 | 126 if ( mFullscreen ) |
127 { | |
128 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; | |
129 drwcX+=drwX; | |
130 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
131 drwcY+=drwY; | |
132 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
133 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
1852 | 134 fprintf( stderr,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
120 | 135 } |
136 | |
137 mDrawColorKey(); | |
138 | |
139 mga_vid_config.x_org=drwcX; | |
140 mga_vid_config.y_org=drwcY; | |
141 mga_vid_config.dest_width=drwWidth; | |
142 mga_vid_config.dest_height=drwHeight; | |
143 | |
144 } | |
145 | |
31 | 146 static void check_events(void) |
1 | 147 { |
31 | 148 int e=vo_x11_check_events(mDisplay); |
1 | 149 |
31 | 150 if(e&VO_EVENT_RESIZE){ |
120 | 151 set_window(); |
1 | 152 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) |
153 { | |
614 | 154 printf( "Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); |
31 | 155 // exit( 0 ); |
1 | 156 } |
31 | 157 |
158 } else | |
159 if(e&VO_EVENT_EXPOSE) mDrawColorKey(); | |
160 | |
1 | 161 } |
162 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
163 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
164 { 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
|
165 |
31 | 166 static void flip_page(void){ |
182 | 167 #ifdef SHOW_TIME |
100 | 168 unsigned int t; |
169 t=GetTimer(); | |
170 printf(" [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); | |
171 timerd=t-timer; | |
172 timer=t; | |
182 | 173 #endif |
100 | 174 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
175 vo_mga_flip_page(); |
31 | 176 } |
1 | 177 |
178 static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format ) | |
179 { | |
180 char * frame_mem; | |
56 | 181 // uint32_t frame_size; |
927 | 182 // int mScreen; |
1 | 183 unsigned int fg, bg; |
184 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
185 char * name=":0.0"; | |
186 XSizeHints hint; | |
187 XVisualInfo vinfo; | |
188 XEvent xev; | |
189 | |
190 XGCValues xgcv; | |
191 unsigned long xswamask; | |
192 | |
1210 | 193 char *devname=vo_subdevice?vo_subdevice:"/dev/mga_vid"; |
194 | |
195 f = open(devname,O_RDWR); | |
196 if(f == -1) | |
197 { | |
1637 | 198 perror("open"); |
1210 | 199 printf("Couldn't open %s\n",devname); |
200 return(-1); | |
201 } | |
1 | 202 |
203 switch(format) | |
204 { | |
182 | 205 case IMGFMT_YV12: |
56 | 206 mga_vid_config.format=MGA_VID_FORMAT_YV12; |
182 | 207 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; |
56 | 208 break; |
470 | 209 case IMGFMT_I420: |
210 mga_vid_config.format=MGA_VID_FORMAT_I420; | |
211 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; | |
212 break; | |
213 case IMGFMT_IYUV: | |
214 mga_vid_config.format=MGA_VID_FORMAT_IYUV; | |
215 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2; | |
216 break; | |
56 | 217 case IMGFMT_YUY2: |
218 mga_vid_config.format=MGA_VID_FORMAT_YUY2; | |
182 | 219 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2; |
56 | 220 break; |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
221 case IMGFMT_UYVY: |
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
384
diff
changeset
|
222 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
|
223 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
|
224 break; |
614 | 225 default: printf("mga: invalid output format %0X\n",format); return (-1); |
1 | 226 } |
227 | |
228 if ( X_already_started ) return -1; | |
229 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
230 if (!vo_init()) return -1; |
1 | 231 |
232 mvWidth=width; mvHeight=height; | |
233 | |
234 wndX=0; wndY=0; | |
235 wndWidth=d_width; wndHeight=d_height; | |
236 dwidth=d_width; dheight=d_height; | |
1783 | 237 #ifdef HAVE_NEW_GUI |
1852 | 238 // mdwidth=d_width; mdheight=d_height; |
239 mdwidth=width; mdheight=height; | |
723 | 240 #endif |
844 | 241 mFullscreen=fullscreen&1; |
1 | 242 |
243 switch ( vo_depthonscreen ) | |
244 { | |
245 case 32: | |
246 case 24: fgColor=0x00ff00ffL; break; | |
247 case 16: fgColor=0xf81fL; break; | |
248 case 15: fgColor=0x7c1fL; break; | |
614 | 249 default: printf( "Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 250 } |
251 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
252 #ifdef HAVE_NEW_GUI |
723 | 253 if ( vo_window == None ) |
254 { | |
255 #endif | |
844 | 256 if ( mFullscreen ) |
723 | 257 { |
258 wndWidth=vo_screenwidth; | |
259 wndHeight=vo_screenheight; | |
260 } | |
261 | |
262 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs ); | |
263 mDepth=attribs.depth; | |
264 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
265 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
266 xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone ); | |
267 xWAttribs.background_pixel=0; | |
268 xWAttribs.border_pixel=0; | |
269 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask; | |
270 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; | |
1 | 271 |
723 | 272 mWindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ), |
273 wndX,wndY, | |
274 wndWidth,wndHeight, | |
275 xWAttribs.border_pixel, | |
276 mDepth, | |
277 InputOutput, | |
278 vinfo.visual,xswamask,&xWAttribs ); | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
927
diff
changeset
|
279 vo_x11_classhint( mDisplay,mWindow,"xmga" ); |
723 | 280 vo_hidecursor(mDisplay,mWindow); |
281 | |
844 | 282 if ( mFullscreen ) vo_x11_decoration( mDisplay,mWindow,0 ); |
1 | 283 |
723 | 284 XGetNormalHints( mDisplay,mWindow,&hint ); |
285 hint.x=wndX; hint.y=wndY; | |
286 hint.width=wndWidth; hint.height=wndHeight; | |
287 hint.base_width=wndWidth; hint.base_height=wndHeight; | |
288 hint.flags=USPosition | USSize; | |
289 XSetNormalHints( mDisplay,mWindow,&hint ); | |
290 XStoreName( mDisplay,mWindow,mTitle ); | |
291 XMapWindow( mDisplay,mWindow ); | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
292 mGC=XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
293 #ifdef HAVE_NEW_GUI |
723 | 294 } |
295 else | |
296 { | |
297 mWindow=vo_window; | |
1852 | 298 // fprintf( stderr,"[xmga] width: %d height: %d d_width: %d d_height: %d\n",width,height,d_width,d_height ); |
299 // if ( vo_screenwidth != d_width ) | |
300 // { | |
301 // XMoveWindow( mDisplay,mWindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 ); | |
302 // XResizeWindow( mDisplay,mWindow,d_width,d_height ); | |
303 // } | |
304 // else mFullscreen=1; | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
305 mGC=vo_gc; //XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); |
723 | 306 } |
307 #endif | |
1 | 308 |
120 | 309 set_window(); |
1 | 310 |
311 mga_vid_config.src_width=width; | |
312 mga_vid_config.src_height=height; | |
313 | |
314 mga_vid_config.colkey_on=1; | |
315 mga_vid_config.colkey_red=255; | |
316 mga_vid_config.colkey_green=0; | |
317 mga_vid_config.colkey_blue=255; | |
318 | |
56 | 319 if(mga_init()) return -1; |
1852 | 320 |
321 set_window(); | |
1 | 322 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
323 #ifdef HAVE_NEW_GUI |
723 | 324 if ( vo_window == None ) |
325 #endif | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
326 { |
723 | 327 XFlush( mDisplay ); |
328 XSync( mDisplay,False ); | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
329 } |
1852 | 330 |
331 #ifdef HAVE_NEW_GUI | |
332 if ( vo_window == None ) | |
333 #endif | |
334 saver_off(mDisplay); | |
324 | 335 |
1 | 336 return 0; |
337 } | |
338 | |
339 static const vo_info_t* get_info( void ) | |
340 { return &vo_info; } | |
341 | |
342 | |
343 static void | |
344 uninit(void) | |
345 { | |
1852 | 346 #ifdef HAVE_NEW_GUI |
347 if ( vo_window == None ) | |
348 #endif | |
1924 | 349 { |
1852 | 350 saver_on(mDisplay); |
1924 | 351 XDestroyWindow( mDisplay,mWindow ); |
352 } | |
1637 | 353 mga_uninit(); |
354 printf("vo: uninit!\n"); | |
1 | 355 } |