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