1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
/*
VIDIX accelerated overlay in a WIN32 window
(C) Sascha Sommer
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include "config.h"
#include "video_out.h"
#include "video_out_internal.h"
#include <windows.h>
#include "../osdep/keycodes.h"
#include "../input/input.h"
#include "aspect.h"
#include "mp_msg.h"
#include "vosub_vidix.h"
#include "../vidix/vidixlib.h"
extern void mplayer_put_key(int code);
static vo_info_t info =
{
"WIN32 (VIDIX)",
"winvidix",
"Sascha Sommer",
""
};
LIBVO_EXTERN(winvidix)
#define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
/* VIDIX related */
static char *vidix_name;
/* Image parameters */
static uint32_t image_width;
static uint32_t image_height;
static uint32_t image_format;
static HWND hWnd;
/* Window parameters */
static HWND hWnd=NULL,hWndFS=NULL;
static vidix_grkey_t gr_key;
extern void set_video_eq( int cap );
extern int vo_config_count;
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message){
case WM_DESTROY:
mp_input_queue_cmd(mp_input_parse_cmd("quit"));
break;
case WM_WINDOWPOSCHANGED:
{
/*calculate new window rect*/
if(!vo_fs){
RECT rd;
POINT point_window;
if(!hWnd)hWnd=hwnd;
ShowCursor(TRUE);
point_window.x = 0;
point_window.y = 0;
ClientToScreen(hWnd,&point_window);
GetClientRect(hWnd,&rd);
vo_dwidth=rd.right - rd.left;
vo_dheight=rd.bottom - rd.top;
vo_dx =point_window.x;
vo_dy =point_window.y;
// aspect(&vo_dwidth, &vo_dheight, A_NOZOOM);
}
else {
if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){}
aspect(&vo_dwidth, &vo_dheight, A_ZOOM);
vo_dx = (vo_screenwidth - vo_dwidth)/2;
vo_dy = (vo_screenheight - vo_dheight)/2;
}
/*update vidix*/
/* FIXME: implement runtime resize/move if possible, this way is very ugly! */
vidix_stop();
if(vidix_init(image_width, image_height, vo_dx, vo_dy, vo_dwidth, vo_dheight, image_format, vo_depthonscreen, vo_screenwidth, vo_screenheight) != 0)
mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno));
/*set colorkey*/
vidix_start();
mp_msg(MSGT_VO, MSGL_V, "[winvidix] window properties: pos: %dx%d, size: %dx%d\n",vo_dx, vo_dy, vo_dwidth, vo_dheight);
if(vidix_grkey_support()){
vidix_grkey_get(&gr_key);
gr_key.key_op = KEYS_PUT;
gr_key.ckey.op = CKEY_TRUE;
if(vo_fs)gr_key.ckey.red = gr_key.ckey.green = gr_key.ckey.blue = 0;
else {
gr_key.ckey.red = gr_key.ckey.blue = 255;
gr_key.ckey.green = 0;
}
vidix_grkey_set(&gr_key);
}
}
break;
case WM_SYSCOMMAND:
switch (wParam){
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break;
case WM_KEYDOWN:
switch (wParam){
case VK_LEFT:
{mplayer_put_key(KEY_LEFT);break;}
case VK_UP:
{mplayer_put_key(KEY_UP);break;}
case VK_RIGHT:
{mplayer_put_key(KEY_RIGHT);break;}
case VK_DOWN:
{mplayer_put_key(KEY_DOWN);break;}
case VK_TAB:
{mplayer_put_key(KEY_TAB);break;}
case VK_CONTROL:
{mplayer_put_key(KEY_CTRL);break;}
case VK_DELETE:
{mplayer_put_key(KEY_DELETE);break;}
case VK_INSERT:
{mplayer_put_key(KEY_INSERT);break;}
case VK_HOME:
{mplayer_put_key(KEY_HOME);break;}
case VK_END:
{mplayer_put_key(KEY_END);break;}
case VK_PRIOR:
{mplayer_put_key(KEY_PAGE_UP);break;}
case VK_NEXT:
{mplayer_put_key(KEY_PAGE_DOWN);break;}
case VK_ESCAPE:
{mplayer_put_key(KEY_ESC);break;}
}
break;
case WM_CHAR:
mplayer_put_key(wParam);
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_height, uint32_t flags, char *title, uint32_t format){
title = "MPlayer VIDIX WIN32 Overlay";
panscan_init();
image_height = height;
image_width = width;
image_format = format;
vo_screenwidth = GetSystemMetrics(SM_CXSCREEN);
vo_screenheight = GetSystemMetrics(SM_CYSCREEN);
vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL);
aspect_save_orig(width, height);
aspect_save_prescale(d_width, d_height);
aspect_save_screenres(vo_screenwidth, vo_screenheight);
vo_dx = 0;
vo_dy = 0;
vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight);
vo_fs = flags&0x01;
aspect(&d_width, &d_height, A_NOZOOM);
vo_dwidth=d_width; vo_dheight=d_height;
if(!vo_config_count){
HINSTANCE hInstance = GetModuleHandle(NULL);
WNDCLASS wc;
RECT rd;
rd.left = vo_dx;
rd.top = vo_dy;
rd.right = rd.left + vo_dwidth;
rd.bottom = rd.top + vo_dheight;
AdjustWindowRect(&rd,WS_OVERLAPPEDWINDOW| WS_SIZEBOX,0);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hIcon =ExtractIcon(hInstance,"mplayer.exe",0);
//LoadIcon(NULL,IDI_APPLICATION);
wc.hbrBackground = CreateSolidBrush(RGB(255,0,255));
wc.lpszClassName = "Mplayer - Movieplayer for Linux";
wc.lpszMenuName = NULL;
RegisterClass(&wc);
hWnd = CreateWindow("MPlayer - Movieplayer for Linux",
title,
WS_OVERLAPPEDWINDOW| WS_SIZEBOX,
rd.left,
rd.top,
rd.right - rd.left,
rd.bottom - rd.top,
NULL,
NULL,
hInstance,
NULL);
wc.hbrBackground = CreateSolidBrush(RGB(0,0,0));
wc.lpszClassName = "MPlayer - Fullscreen";
RegisterClass(&wc);
hWndFS = CreateWindow("MPlayer - Fullscreen","MPlayer VIDIX Fullscreen",WS_POPUP,0,0,vo_screenwidth,vo_screenheight,hWnd,NULL,hInstance,NULL);
}
ShowWindow(hWnd,SW_SHOW);
if(vo_fs)ShowWindow(hWndFS,SW_SHOW);
return(0);
}
static void check_events(void){
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
/* draw_osd, flip_page, draw_slice, draw_frame should be
overwritten with vidix functions (vosub_vidix.c) */
static void draw_osd(void){
mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_osd!\n");
return;
}
static void flip_page(void){
mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix flip_page!\n");
return;
}
static uint32_t draw_slice(uint8_t *src[], int stride[],int w, int h, int x, int y){
UNUSED(src);
UNUSED(stride);
UNUSED(w);
UNUSED(h);
UNUSED(x);
UNUSED(y);
mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_slice!\n");
return(-1);
}
static uint32_t draw_frame(uint8_t *src[]){
UNUSED(src);
mp_msg(MSGT_VO, MSGL_FATAL, "[winvidix] error: didn't use vidix draw_frame!\n");
return(-1);
}
static uint32_t query_format(uint32_t format){
return(vidix_query_fourcc(format));
}
static void uninit(void){
DestroyWindow(hWndFS);
DestroyWindow(hWnd);
if ( !vo_config_count ) return;
vidix_term();
if (vidix_name){
free(vidix_name);
vidix_name = NULL;
}
//
}
static uint32_t preinit(const char *arg){
if (arg)
vidix_name = strdup(arg);
else
{
mp_msg(MSGT_VO, MSGL_INFO, "No vidix driver name provided, probing available ones!\n");
vidix_name = NULL;
}
if (vidix_preinit(vidix_name, &video_out_winvidix) != 0)
return(1);
return(0);
}
static uint32_t control(uint32_t request, void *data, ...){
switch (request) {
case VOCTRL_FULLSCREEN:
if(!vo_fs){vo_fs=1;ShowWindow(hWndFS,SW_SHOW);}
else {vo_fs=0; ShowWindow(hWndFS,SW_HIDE);}
break;
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
case VOCTRL_SET_EQUALIZER:
{
va_list ap;
int value;
va_start(ap, data);
value = va_arg(ap, int);
va_end(ap);
return vidix_control(request, data, (int *)value);
}
case VOCTRL_GET_EQUALIZER:
{
va_list ap;
int *value;
va_start(ap, data);
value = va_arg(ap, int*);
va_end(ap);
return vidix_control(request, data, value);
}
}
return vidix_control(request, data);
// return VO_NOTIMPL;
}
|