Mercurial > mplayer.hg
annotate libvo/vo_winvidix.c @ 27979:5c4dbd36c0cf
Fix HAVE_VIS vs. HAVE_MVI typo, SPARC has MVI, not VIS.
patch by Alexis Ballier, alexis.ballier gmail com
author | diego |
---|---|
date | Mon, 24 Nov 2008 08:29:34 +0000 |
parents | d611a8a200d5 |
children | 9e739bdb049c |
rev | line source |
---|---|
10979 | 1 /* |
2 VIDIX accelerated overlay in a WIN32 window | |
3 | |
4 (C) Sascha Sommer | |
5 | |
6 | |
7 */ | |
8 | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 #include <string.h> | |
12 #include <math.h> | |
13 #include <errno.h> | |
14 | |
15 #include "config.h" | |
16 #include "video_out.h" | |
17 #include "video_out_internal.h" | |
18 | |
19 #include <windows.h> | |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12861
diff
changeset
|
20 #include "osdep/keycodes.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12861
diff
changeset
|
21 #include "input/input.h" |
10979 | 22 |
23 #include "aspect.h" | |
24 #include "mp_msg.h" | |
22823
98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents:
16892
diff
changeset
|
25 #include "mp_fifo.h" |
10979 | 26 |
27 #include "vosub_vidix.h" | |
27079 | 28 #include "vidix/vidix.h" |
10979 | 29 |
30 | |
25216 | 31 static const vo_info_t info = |
10979 | 32 { |
33 "WIN32 (VIDIX)", | |
34 "winvidix", | |
35 "Sascha Sommer", | |
36 "" | |
37 }; | |
38 | |
39 LIBVO_EXTERN(winvidix) | |
40 | |
41 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */ | |
42 | |
43 /* VIDIX related */ | |
44 static char *vidix_name; | |
45 | |
46 /* Image parameters */ | |
47 static uint32_t image_width; | |
48 static uint32_t image_height; | |
49 static uint32_t image_format; | |
50 /* Window parameters */ | |
51 static HWND hWnd=NULL,hWndFS=NULL; | |
15822
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
52 static float window_aspect; |
10979 | 53 |
54 static vidix_grkey_t gr_key; | |
55 | |
56 | |
57 extern void set_video_eq( int cap ); | |
58 | |
59 | |
60 static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |
61 { | |
62 switch (message){ | |
63 case WM_DESTROY: | |
15822
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
64 PostQuitMessage(0); |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
65 return 0; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
66 case WM_CLOSE: |
16892
3470c810527b
libvo input cleanup: remove the dependency on libinput,
albeu
parents:
16280
diff
changeset
|
67 mplayer_put_key(KEY_CLOSE_WIN); |
10979 | 68 break; |
69 case WM_WINDOWPOSCHANGED: | |
70 { | |
15822
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
71 int tmpheight=0; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
72 /*calculate new window rect*/ |
10979 | 73 if(!vo_fs){ |
74 RECT rd; | |
75 POINT point_window; | |
76 if(!hWnd)hWnd=hwnd; | |
77 ShowCursor(TRUE); | |
78 point_window.x = 0; | |
79 point_window.y = 0; | |
80 ClientToScreen(hWnd,&point_window); | |
81 GetClientRect(hWnd,&rd); | |
82 | |
83 vo_dwidth=rd.right - rd.left; | |
84 vo_dheight=rd.bottom - rd.top; | |
85 vo_dx =point_window.x; | |
86 vo_dy =point_window.y; | |
87 // aspect(&vo_dwidth, &vo_dheight, A_NOZOOM); | |
15822
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
88 |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
89 /* keep aspect on resize, borrowed from vo_directx.c */ |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
90 tmpheight = ((float)vo_dwidth/window_aspect); |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
91 tmpheight += tmpheight % 2; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
92 if(tmpheight > vo_dheight) |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
93 { |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
94 vo_dwidth = ((float)vo_dheight*window_aspect); |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
95 vo_dwidth += vo_dwidth % 2; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
96 } |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
97 else vo_dheight = tmpheight; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
98 rd.right = rd.left + vo_dwidth; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
99 rd.bottom = rd.top + vo_dheight; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
100 |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
101 if(rd.left < 0) rd.left = 0; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
102 if(rd.right > vo_screenwidth) rd.right = vo_screenwidth; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
103 if(rd.top < 0) rd.top = 0; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
104 if(rd.bottom > vo_screenheight) rd.bottom = vo_screenheight; |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
105 |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
106 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); |
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
107 SetWindowPos(hWnd, HWND_TOPMOST, vo_dx+rd.left, vo_dy+rd.top, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); |
10979 | 108 } |
109 else { | |
110 if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){} | |
111 aspect(&vo_dwidth, &vo_dheight, A_ZOOM); | |
112 vo_dx = (vo_screenwidth - vo_dwidth)/2; | |
113 vo_dy = (vo_screenheight - vo_dheight)/2; | |
114 } | |
115 /*update vidix*/ | |
116 /* FIXME: implement runtime resize/move if possible, this way is very ugly! */ | |
117 vidix_stop(); | |
118 if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0) | |
119 mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno)); | |
120 /*set colorkey*/ | |
121 vidix_start(); | |
122 mp_msg(MSGT_VO, MSGL_V, "[winvidix] window properties: pos: %dx%d, size: %dx%d\n",vo_dx, vo_dy, vo_dwidth, vo_dheight); | |
123 if(vidix_grkey_support()){ | |
124 vidix_grkey_get(&gr_key); | |
125 gr_key.key_op = KEYS_PUT; | |
126 gr_key.ckey.op = CKEY_TRUE; | |
127 if(vo_fs)gr_key.ckey.red = gr_key.ckey.green = gr_key.ckey.blue = 0; | |
128 else { | |
129 gr_key.ckey.red = gr_key.ckey.blue = 255; | |
130 gr_key.ckey.green = 0; | |
131 } | |
132 vidix_grkey_set(&gr_key); | |
133 } | |
134 | |
135 } | |
136 break; | |
137 case WM_SYSCOMMAND: | |
138 switch (wParam){ | |
139 case SC_SCREENSAVE: | |
140 case SC_MONITORPOWER: | |
141 return 0; | |
142 } | |
143 break; | |
144 case WM_KEYDOWN: | |
145 switch (wParam){ | |
146 case VK_LEFT: | |
147 {mplayer_put_key(KEY_LEFT);break;} | |
148 case VK_UP: | |
149 {mplayer_put_key(KEY_UP);break;} | |
150 case VK_RIGHT: | |
151 {mplayer_put_key(KEY_RIGHT);break;} | |
152 case VK_DOWN: | |
153 {mplayer_put_key(KEY_DOWN);break;} | |
154 case VK_TAB: | |
155 {mplayer_put_key(KEY_TAB);break;} | |
156 case VK_CONTROL: | |
157 {mplayer_put_key(KEY_CTRL);break;} | |
158 case VK_DELETE: | |
159 {mplayer_put_key(KEY_DELETE);break;} | |
160 case VK_INSERT: | |
161 {mplayer_put_key(KEY_INSERT);break;} | |
162 case VK_HOME: | |
163 {mplayer_put_key(KEY_HOME);break;} | |
164 case VK_END: | |
165 {mplayer_put_key(KEY_END);break;} | |
166 case VK_PRIOR: | |
167 {mplayer_put_key(KEY_PAGE_UP);break;} | |
168 case VK_NEXT: | |
169 {mplayer_put_key(KEY_PAGE_DOWN);break;} | |
170 case VK_ESCAPE: | |
171 {mplayer_put_key(KEY_ESC);break;} | |
172 } | |
173 break; | |
174 case WM_CHAR: | |
175 mplayer_put_key(wParam); | |
176 break; | |
177 } | |
178 return DefWindowProc(hwnd, message, wParam, lParam); | |
179 } | |
180 | |
181 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
182 static int config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_height, uint32_t flags, char *title, uint32_t format){ |
10979 | 183 title = "MPlayer VIDIX WIN32 Overlay"; |
184 | |
185 panscan_init(); | |
186 | |
187 image_height = height; | |
188 image_width = width; | |
189 image_format = format; | |
190 vo_screenwidth = GetSystemMetrics(SM_CXSCREEN); | |
191 vo_screenheight = GetSystemMetrics(SM_CYSCREEN); | |
192 vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL); | |
193 | |
194 | |
195 aspect_save_orig(width, height); | |
196 aspect_save_prescale(d_width, d_height); | |
197 aspect_save_screenres(vo_screenwidth, vo_screenheight); | |
198 | |
199 vo_dx = 0; | |
200 vo_dy = 0; | |
201 | |
202 vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2; | |
203 geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight); | |
204 | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13787
diff
changeset
|
205 vo_fs = flags&VOFLAG_FULLSCREEN; |
10979 | 206 |
207 | |
208 aspect(&d_width, &d_height, A_NOZOOM); | |
209 vo_dwidth=d_width; vo_dheight=d_height; | |
15822
0651bf280391
keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
faust3
parents:
15621
diff
changeset
|
210 window_aspect = (float)d_width / (float)d_height; |
10979 | 211 |
212 | |
213 if(!vo_config_count){ | |
214 HINSTANCE hInstance = GetModuleHandle(NULL); | |
215 WNDCLASS wc; | |
216 RECT rd; | |
217 rd.left = vo_dx; | |
218 rd.top = vo_dy; | |
219 rd.right = rd.left + vo_dwidth; | |
220 rd.bottom = rd.top + vo_dheight; | |
221 AdjustWindowRect(&rd,WS_OVERLAPPEDWINDOW| WS_SIZEBOX,0); | |
222 wc.style = CS_HREDRAW | CS_VREDRAW; | |
223 wc.lpfnWndProc = WndProc; | |
224 wc.cbClsExtra = 0; | |
225 wc.cbWndExtra = 0; | |
226 wc.hInstance = hInstance; | |
227 wc.hCursor = LoadCursor(NULL,IDC_ARROW); | |
228 wc.hIcon =ExtractIcon(hInstance,"mplayer.exe",0); | |
229 //LoadIcon(NULL,IDI_APPLICATION); | |
230 wc.hbrBackground = CreateSolidBrush(RGB(255,0,255)); | |
12858 | 231 wc.lpszClassName = "MPlayer - The Movie Player"; |
10979 | 232 wc.lpszMenuName = NULL; |
233 RegisterClass(&wc); | |
12861 | 234 hWnd = CreateWindow("MPlayer - The Movie Player", |
10979 | 235 title, |
236 WS_OVERLAPPEDWINDOW| WS_SIZEBOX, | |
237 rd.left, | |
238 rd.top, | |
239 rd.right - rd.left, | |
240 rd.bottom - rd.top, | |
241 NULL, | |
242 NULL, | |
243 hInstance, | |
244 NULL); | |
245 wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); | |
246 wc.lpszClassName = "MPlayer - Fullscreen"; | |
247 RegisterClass(&wc); | |
248 hWndFS = CreateWindow("MPlayer - Fullscreen","MPlayer VIDIX Fullscreen",WS_POPUP,0,0,vo_screenwidth,vo_screenheight,hWnd,NULL,hInstance,NULL); | |
249 | |
250 | |
251 | |
252 | |
253 | |
254 } | |
255 ShowWindow(hWnd,SW_SHOW); | |
256 if(vo_fs)ShowWindow(hWndFS,SW_SHOW); | |
257 | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
258 return 0; |
10979 | 259 } |
260 | |
261 static void check_events(void){ | |
262 MSG msg; | |
263 while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) | |
264 { | |
265 TranslateMessage(&msg); | |
266 DispatchMessage(&msg); | |
267 } | |
268 } | |
269 | |
270 /* draw_osd, flip_page, draw_slice, draw_frame should be | |
271 overwritten with vidix functions (vosub_vidix.c) */ | |
272 static void draw_osd(void){ | |
273 mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_osd!\n"); | |
274 return; | |
275 } | |
276 | |
277 static void flip_page(void){ | |
278 mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix flip_page!\n"); | |
279 return; | |
280 } | |
281 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
282 static int draw_slice(uint8_t *src[], int stride[],int w, int h, int x, int y){ |
10979 | 283 UNUSED(src); |
284 UNUSED(stride); | |
285 UNUSED(w); | |
286 UNUSED(h); | |
287 UNUSED(x); | |
288 UNUSED(y); | |
289 mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_slice!\n"); | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
290 return -1; |
10979 | 291 } |
292 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
293 static int draw_frame(uint8_t *src[]){ |
10979 | 294 UNUSED(src); |
295 mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_frame!\n"); | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
296 return -1; |
10979 | 297 } |
298 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
299 static int query_format(uint32_t format){ |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
300 return vidix_query_fourcc(format); |
10979 | 301 } |
302 | |
303 static void uninit(void){ | |
304 DestroyWindow(hWndFS); | |
305 DestroyWindow(hWnd); | |
306 if ( !vo_config_count ) return; | |
307 vidix_term(); | |
308 | |
309 if (vidix_name){ | |
310 free(vidix_name); | |
311 vidix_name = NULL; | |
312 } | |
313 // | |
314 } | |
315 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
316 static int preinit(const char *arg){ |
10979 | 317 if (arg) |
318 vidix_name = strdup(arg); | |
319 else | |
320 { | |
11462 | 321 mp_msg(MSGT_VO, MSGL_INFO, "No vidix driver name provided, probing available ones (-v option for details)!\n"); |
10979 | 322 vidix_name = NULL; |
323 } | |
324 | |
325 if (vidix_preinit(vidix_name, &video_out_winvidix) != 0) | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
326 return 1; |
10979 | 327 |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
328 return 0; |
10979 | 329 } |
330 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15822
diff
changeset
|
331 static int control(uint32_t request, void *data, ...){ |
10979 | 332 switch (request) { |
333 case VOCTRL_FULLSCREEN: | |
15621
54e8a5b5d9c4
regain window focus in fullscreen, patch by Erik Lunchpail <enik_27can at yahoo.com>
faust3
parents:
15212
diff
changeset
|
334 if(!vo_fs){vo_fs=1;ShowWindow(hWndFS,SW_SHOW);SetForegroundWindow(hWndFS);} |
10979 | 335 else {vo_fs=0; ShowWindow(hWndFS,SW_HIDE);} |
336 break; | |
337 case VOCTRL_QUERY_FORMAT: | |
338 return query_format(*((uint32_t*)data)); | |
339 case VOCTRL_SET_EQUALIZER: | |
340 { | |
341 va_list ap; | |
342 int value; | |
343 | |
344 va_start(ap, data); | |
345 value = va_arg(ap, int); | |
346 va_end(ap); | |
347 | |
348 return vidix_control(request, data, (int *)value); | |
349 } | |
350 case VOCTRL_GET_EQUALIZER: | |
351 { | |
352 va_list ap; | |
353 int *value; | |
354 | |
355 va_start(ap, data); | |
356 value = va_arg(ap, int*); | |
357 va_end(ap); | |
358 | |
359 return vidix_control(request, data, value); | |
360 } | |
361 } | |
362 return vidix_control(request, data); | |
363 // return VO_NOTIMPL; | |
364 } |