annotate libvo/vo_xvidix.c @ 4190:2ed90891750e

added a few notes about formats 0x61 and 0x62
author melanson
date Wed, 16 Jan 2002 03:39:37 +0000
parents 7134f727e3c6
children 37c35f4ef9e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
1 /*
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
2 VIDIX accelerated overlay in a X window
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
3
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
4 (C) Alex Beregszaszi & Nick Kurshev
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
5
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
6 WS window manager by Pontscho/Fresh!
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
7
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
8 Based on vo_gl.c and vo_vesa.c
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
9 */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
10
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
11 #include <stdio.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
12 #include <stdlib.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
13 #include <string.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
14 #include <math.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
15 #include <errno.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
16
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
17 #include "config.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
18 #include "video_out.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
19 #include "video_out_internal.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
20
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
21 #include <X11/Xlib.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
22 #include <X11/Xutil.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
23 //#include <X11/keysym.h>
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
24
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
25 #include "x11_common.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
26 #include "aspect.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
27 #include "mp_msg.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
28
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
29 #include "vosub_vidix.h"
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
30
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
31 LIBVO_EXTERN(xvidix)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
32
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
33 static vo_info_t vo_info =
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
34 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
35 "X11 (VIDIX)",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
36 "xvidix",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
37 "Alex Beregszaszi",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
38 ""
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
39 };
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
40
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
41 /* X11 related variables */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
42 static Window mywindow;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
43 static int X_already_started = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
44
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
45 /* VIDIX related stuff */
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
46 static const char *vidix_name = (char *)(-1);
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
47 static int pre_init_err = 0;
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
48
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
49 /* Image parameters */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
50 static uint32_t image_width;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
51 static uint32_t image_height;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
52 static uint32_t image_format;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
53 static uint32_t image_depth;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
54
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
55 /* Window parameters */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
56 static uint32_t window_x, window_y;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
57 static uint32_t window_width, window_height;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
58
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
59 /* used by XGetGeometry & XTranslateCoordinates */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
60 static Window mRoot;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
61 static uint32_t drwX, drwY, drwWidth, drwHeight, drwBorderWidth,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
62 drwDepth, drwcX, drwcY, dwidth, dheight, mFullscreen;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
63
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
64 static void resize(int x, int y)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
65 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
66 XGetGeometry(mDisplay, mywindow, &mRoot, &drwX, &drwY, &drwWidth,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
67 &drwHeight, &drwBorderWidth, &drwDepth);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
68 drwX = drwY = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
69 XTranslateCoordinates(mDisplay, mywindow, mRoot, 0, 0, &drwcX, &drwcY, &mRoot);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
70
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
71 mp_msg(MSGT_VO, MSGL_DBG2, "[xvidix] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
72 drwcX, drwcY, drwX, drwY, drwWidth, drwHeight);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
73
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
74 if ((window_x != drwcX) || (window_y != drwcY) ||
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
75 (window_width != drwWidth) || (window_height != drwHeight))
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
76 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
77 /* FIXME: implement runtime resize/move if possible, this way is very ugly! */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
78 vidix_term();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
79 vidix_preinit(vidix_name, &video_out_xvidix);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
80 if (vidix_init(image_width, image_height, window_x, window_y,
4133
7134f727e3c6 Still one bit of bugs fixed
nick
parents: 4132
diff changeset
81 window_width, window_height, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
82 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
83 mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s: %s\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
84 vidix_name, strerror(errno));
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
85 vidix_term();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
86 uninit();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
87 exit(1); /* !!! */
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
88 x = window_width;
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
89 y = window_height;
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
90 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
91 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
92
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
93 window_x = drwcX;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
94 window_y = drwcY;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
95 window_width = drwWidth;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
96 window_height = drwHeight;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
97
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
98 mp_msg(MSGT_VO, MSGL_INFO, "[xvidix] window properties: pos: %dx%d, size: %dx%d\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
99 window_x, window_y, window_width, window_height);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
100
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
101 return;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
102 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
103
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
104 /* connect to server, create and map window,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
105 * allocate colors and (shared) memory
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
106 */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
107 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
108 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
109 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
110 unsigned int fg, bg;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
111 XVisualInfo vinfo;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
112 XEvent xev;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
113 XSizeHints hint;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
114 XSetWindowAttributes xswa;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
115 unsigned long xswamask;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
116 XWindowAttributes attribs;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
117 int window_depth;
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
118
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
119 if(pre_init_err)
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
120 {
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
121 mp_msg(MSGT_VO, MSGL_INFO, "[xvidix] Quiting due preinit error\n");
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
122 return -1;
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
123 }
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
124 // if (title)
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
125 // free(title);
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
126 title = strdup("MPlayer VIDIX X11 Overlay");
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
127
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
128 image_height = height;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
129 image_width = width;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
130 image_format = format;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
131
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
132 if (IMGFMT_IS_RGB(format))
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
133 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
134 image_depth = IMGFMT_RGB_DEPTH(format);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
135 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
136 else
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
137 if (IMGFMT_IS_BGR(format))
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
138 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
139 image_depth = IMGFMT_BGR_DEPTH(format);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
140 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
141 else
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
142 switch(format)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
143 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
144 case IMGFMT_IYUV:
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
145 case IMGFMT_I420:
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
146 case IMGFMT_YV12:
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
147 image_depth = 12;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
148 break;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
149 case IMGFMT_YUY2:
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
150 image_depth = 16;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
151 break;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
152 default:
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
153 mp_msg(MSGT_VO, MSGL_FATAL, "Unknown image format: %s",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
154 vo_format_name(format));
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
155 return(-1);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
156 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
157
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
158 if (X_already_started)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
159 return(-1);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
160 if (!vo_init())
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
161 return(-1);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
162
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
163 aspect_save_orig(width,height);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
164 aspect_save_prescale(d_width,d_height);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
165 aspect_save_screenres(vo_screenwidth,vo_screenheight);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
166
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
167 X_already_started++;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
168
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
169 aspect(&d_width, &d_height, A_NOZOOM);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
170 #ifdef X11_FULLSCREEN
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
171 if (flags & 0x01) /* fullscreen */
4131
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
172 if(flags & 0x04) aspect(&d_width, &d_height, A_ZOOM);
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
173 else
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
174 {
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
175 d_width = vo_screenwidth;
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
176 d_height = vo_screenheight;
e3c69a00a6f9 Minor changes: -fs key and vidix params
nick
parents: 4125
diff changeset
177 }
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
178 #endif
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
179
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
180 hint.x = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
181 hint.y = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
182 hint.width = d_width;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
183 hint.height = d_height;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
184 hint.flags = PPosition | PSize;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
185
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
186 /* Get some colors */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
187 bg = WhitePixel(mDisplay, mScreen);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
188 fg = BlackPixel(mDisplay, mScreen);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
189
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
190 /* Make the window */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
191 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
192
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
193 /* from vo_x11 */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
194 window_depth = attribs.depth;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
195 if ((window_depth != 15) && (window_depth != 16) && (window_depth != 24)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
196 && (window_depth != 32))
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
197 window_depth = 24;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
198 XMatchVisualInfo(mDisplay, mScreen, window_depth, TrueColor, &vinfo);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
199
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
200 xswa.background_pixel = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
201 xswa.border_pixel = 1;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
202 xswa.colormap = XCreateColormap(mDisplay, RootWindow(mDisplay, mScreen),
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
203 vinfo.visual, AllocNone);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
204 xswamask = CWBackPixel | CWBorderPixel | CWColormap;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
205 // xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
206
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
207 if (WinID >= 0)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
208 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
209 mywindow = WinID ? ((Window)WinID) : RootWindow(mDisplay, mScreen);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
210 XUnmapWindow(mDisplay, mywindow);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
211 XChangeWindowAttributes(mDisplay, mywindow, xswamask, &xswa);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
212 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
213 else
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
214 mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay, mScreen),
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
215 hint.x, hint.y, hint.width, hint.height, xswa.border_pixel,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
216 vinfo.depth, CopyFromParent, vinfo.visual, xswamask, &xswa);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
217
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
218 vo_x11_classhint(mDisplay, mywindow, "xvidix");
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
219 vo_hidecursor(mDisplay, mywindow);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
220
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
221 if (flags & 0x01) /* fullscreen */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
222 vo_x11_decoration(mDisplay, mywindow, 0);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
223
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
224 XSelectInput(mDisplay, mywindow, StructureNotifyMask);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
225
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
226 /* Tell other applications about this window */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
227 XSetStandardProperties(mDisplay, mywindow, title, title, None, NULL, 0, &hint);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
228
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
229 /* Map window. */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
230 XMapWindow(mDisplay, mywindow);
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
231 #if 0
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
232 #ifdef HAVE_XINERAMA
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
233 vo_x11_xinerama_move(mDisplay, mywindow);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
234 #endif
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
235 #endif
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
236
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
237 /* Wait for map. */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
238 do
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
239 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
240 XNextEvent(mDisplay, &xev);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
241 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
242 while ((xev.type != MapNotify) || (xev.xmap.event != mywindow));
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
243
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
244 XSelectInput(mDisplay, mywindow, NoEventMask);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
245
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
246 XGetGeometry(mDisplay, mywindow, &mRoot, &drwX, &drwY, &drwWidth,
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
247 &drwHeight, &drwBorderWidth, &drwDepth);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
248 drwX = drwY = 0;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
249 XTranslateCoordinates(mDisplay, mywindow, mRoot, 0, 0, &drwcX, &drwcY, &mRoot);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
250
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
251 window_x = drwcX;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
252 window_y = drwcY;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
253 window_width = drwWidth;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
254 window_height = drwHeight;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
255
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
256 mp_msg(MSGT_VO, MSGL_INFO, "[xvidix] image properties: %dx%d depth: %d\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
257 image_width, image_height, image_depth);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
258 mp_msg(MSGT_VO, MSGL_INFO, "[xvidix] window properties: pos: %dx%d, size: %dx%d\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
259 window_x, window_y, window_width, window_height);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
260
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
261 if (vidix_init(image_width, image_height, window_x, window_y, window_width,
4133
7134f727e3c6 Still one bit of bugs fixed
nick
parents: 4132
diff changeset
262 window_height, format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
263 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
264 mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s: %s\n",
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
265 vidix_name, strerror(errno));
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
266 vidix_term();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
267 return(-1);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
268 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
269
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
270 XFlush(mDisplay);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
271 XSync(mDisplay, False);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
272
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
273 XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask );
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
274
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
275 saver_off(mDisplay); /* turning off screen saver */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
276
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
277 return(0);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
278 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
279
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
280 static const vo_info_t *get_info(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
281 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
282 return(&vo_info);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
283 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
284
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
285 static void Terminate_Display_Process(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
286 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
287 getchar(); /* wait for enter to remove window */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
288 vidix_term();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
289 XDestroyWindow(mDisplay, mywindow);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
290 XCloseDisplay(mDisplay);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
291 X_already_started = 0;
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
292
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
293 return;
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
294 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
295
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
296 static void check_events(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
297 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
298 const int event = vo_x11_check_events(mDisplay);
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
299
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
300 if (event & VO_EVENT_RESIZE)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
301 resize(vo_dwidth, vo_dheight);
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
302 return;
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
303 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
304
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
305 /* draw_osd, flip_page, draw_slice, draw_frame should be
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
306 overwritten with vidix functions (vosub_vidix.c) */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
307 static void draw_osd(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
308 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
309 mp_msg(MSGT_VO, MSGL_FATAL, "[xvidix] error: didn't used vidix draw_osd!\n");
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
310 return;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
311 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
312
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
313 static void flip_page(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
314 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
315 mp_msg(MSGT_VO, MSGL_FATAL, "[xvidix] error: didn't used vidix flip_page!\n");
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
316 return;
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
317 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
318
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
319 static uint32_t draw_slice(uint8_t *src[], int stride[],
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
320 int w, int h, int x, int y)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
321 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
322 mp_msg(MSGT_VO, MSGL_FATAL, "[xvidix] error: didn't used vidix draw_slice!\n");
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
323 return(0);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
324 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
325
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
326 static uint32_t draw_frame(uint8_t *src[])
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
327 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
328 mp_msg(MSGT_VO, MSGL_FATAL, "[xvidix] error: didn't used vidix draw_frame!\n");
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
329 return(0);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
330 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
331
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
332 static uint32_t query_format(uint32_t format)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
333 {
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
334 static int first = 1;
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
335 if(first)
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
336 {
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
337 first = 0;
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
338 if (vidix_name == (char *)(-1))
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
339 {
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
340 if (vo_subdevice)
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
341 vidix_name = strdup(vo_subdevice);
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
342 else
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
343 {
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
344 mp_msg(MSGT_VO, MSGL_INFO, "No vidix driver name provided, probing available drivers!\n");
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
345 vidix_name = NULL;
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
346 }
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
347 }
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
348
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
349 if (vidix_preinit(vidix_name, &video_out_xvidix) != 0)
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
350 {
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
351 pre_init_err = 1;
4125
88de258b3ea9 fixed vidix_name handling (subdevice)
alex
parents: 4123
diff changeset
352 return(0);
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
353 }
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
354 }
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4131
diff changeset
355 return pre_init_err ? 0 : vidix_query_fourcc(format);
4123
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
356 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
357
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
358
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
359 static void uninit(void)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
360 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
361 #ifdef HAVE_NEW_GUI
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
362 if (vo_window == None)
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
363 #endif
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
364 {
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
365 vidix_term();
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
366 saver_on(mDisplay); /* screen saver back on */
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
367 XDestroyWindow(mDisplay, mywindow);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
368 // XCloseDisplay(mDisplay);
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
369 }
467a7141f5c9 added X11/VIDIX
alex
parents:
diff changeset
370 }