Mercurial > mplayer.hg
annotate libvo/vo_sdl.c @ 165:5ba7d108d659
spanish added
author | gabucino |
---|---|
date | Mon, 19 Mar 2001 20:43:12 +0000 |
parents | cab74dfde6dd |
children | 1d02e6f7c63a |
rev | line source |
---|---|
1 | 1 /* |
2 * video_out_sdl.c | |
3 * | |
4 * Copyright (C) Ryan C. Gordon <icculus@lokigames.com> - April 22, 2000. | |
5 * | |
6 * A mpeg2dec display driver that does output through the | |
7 * Simple DirectMedia Layer (SDL) library. This effectively gives us all | |
8 * sorts of output options: X11, SVGAlib, fbcon, AAlib, GGI. Win32, MacOS | |
9 * and BeOS support, too. Yay. SDL info, source, and binaries can be found | |
10 * at http://slouken.devolution.com/SDL/ | |
11 * | |
12 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
13 * | |
14 * mpeg2dec is free software; you can redistribute it and/or modify | |
15 * it under the terms of the GNU General Public License as published by | |
16 * the Free Software Foundation; either version 2, or (at your option) | |
17 * any later version. | |
18 * | |
19 * mpeg2dec is distributed in the hope that it will be useful, | |
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 * GNU General Public License for more details. | |
23 * | |
24 * You should have received a copy of the GNU General Public License | |
25 * along with GNU Make; see the file COPYING. If not, write to | |
26 * the Free Software Foundation, | |
27 * | |
28 * Changes: | |
29 * Dominik Schnitzer <dominik@schnitzer.at> - November 08, 2000. | |
84 | 30 * - Added resizing support, fullscreen: changed the sdlmodes selection |
1 | 31 * routine. |
32 * - SDL bugfixes: removed the atexit(SLD_Quit), SDL_Quit now resides in | |
33 * the plugin_exit routine. | |
34 * - Commented the source :) | |
35 * - Shortcuts: for switching between Fullscreen/Windowed mode and for | |
36 * cycling between the different Fullscreen modes. | |
37 * - Small bugfixes: proper width/height of movie | |
38 * Dominik Schnitzer <dominik@schnitzer.at> - November 11, 2000. | |
39 * - Cleanup code, more comments | |
40 * - Better error handling | |
41 * Bruno Barreyra <barreyra@ufl.edu> - December 10, 2000. | |
42 * - Eliminated memcpy's for entire frames | |
84 | 43 * Felix Buenemann <Felix.Buenemann@ePost.de> - March 11, 2001 |
44 * - Added aspect-ratio awareness for fullscreen | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
45 * Felix Buenemann <Felix.Buenemann@gmx.de> - March 11, 2001 |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
46 * - Fixed aspect-ratio awareness, did only vertical scaling (black bars above |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
47 * and below), now also does horizontal scaling (black bars left and right), |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
48 * so you get the biggest possible picture with correct aspect-ratio. |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
49 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 12, 2001 |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
50 * - Minor bugfix to aspect-ratio vor non-4:3-resolutions (like 1280x1024) |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
51 * - Bugfix to check_events() to reveal mouse cursor after 'q'-quit in |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
52 * fullscreen-mode |
1 | 53 */ |
54 | |
55 #include <stdio.h> | |
56 #include <stdlib.h> | |
57 #include <string.h> | |
58 #include <inttypes.h> | |
59 | |
60 #include "config.h" | |
61 #include "video_out.h" | |
62 #include "video_out_internal.h" | |
63 | |
64 LIBVO_EXTERN(sdl) | |
65 | |
66 //#include "log.h" | |
67 //#define LOG if(0)printf | |
68 | |
69 static vo_info_t vo_info = | |
70 { | |
84 | 71 "SDL YUV overlay (SDL v1.1.7+ only!)", |
1 | 72 "sdl", |
73 "Ryan C. Gordon <icculus@lokigames.com>", | |
74 "" | |
75 }; | |
76 | |
77 #include <SDL/SDL.h> | |
78 | |
79 /** Private SDL Data structure **/ | |
80 | |
81 static struct sdl_priv_s { | |
82 | |
83 /* SDL YUV surface & overlay */ | |
84 SDL_Surface *surface; | |
85 SDL_Overlay *overlay; | |
86 // SDL_Overlay *current_frame; | |
87 | |
88 /* available fullscreen modes */ | |
89 SDL_Rect **fullmodes; | |
90 | |
91 /* surface attributes for fullscreen and windowed mode */ | |
92 Uint32 sdlflags, sdlfullflags; | |
93 | |
94 /* save the windowed output extents */ | |
95 SDL_Rect windowsize; | |
96 | |
97 /* Bits per Pixel */ | |
98 Uint8 bpp; | |
99 | |
100 /* current fullscreen mode, 0 = highest available fullscreen mode */ | |
101 int fullmode; | |
102 | |
103 /* YUV ints */ | |
104 int framePlaneY, framePlaneUV; | |
105 int stridePlaneY, stridePlaneUV; | |
106 int width,height; | |
107 int format; | |
108 } sdl_priv; | |
109 | |
110 | |
111 /** OMS Plugin functions **/ | |
112 | |
113 | |
114 /** | |
115 * Take a null-terminated array of pointers, and find the last element. | |
116 * | |
117 * params : array == array of which we want to find the last element. | |
118 * returns : index of last NON-NULL element. | |
119 **/ | |
120 | |
121 static inline int findArrayEnd (SDL_Rect **array) | |
122 { | |
123 int i = 0; | |
124 while ( array[i++] ); /* keep loopin' ... */ | |
125 | |
126 /* return the index of the last array element */ | |
127 return i - 1; | |
128 } | |
129 | |
130 | |
131 /** | |
132 * Open and prepare SDL output. | |
133 * | |
134 * params : *plugin == | |
135 * *name == | |
136 * returns : 0 on success, -1 on failure | |
137 **/ | |
138 | |
139 static int sdl_open (void *plugin, void *name) | |
140 { | |
141 struct sdl_priv_s *priv = &sdl_priv; | |
142 const SDL_VideoInfo *vidInfo = NULL; | |
143 static int opened = 0; | |
144 | |
145 if (opened) | |
146 return 0; | |
147 opened = 1; | |
148 | |
149 // LOG (LOG_DEBUG, "SDL video out: Opened Plugin"); | |
150 | |
84 | 151 /* default to no fullscreen mode, we'll set this as soon we have the avail. modes */ |
1 | 152 priv->fullmode = -2; |
153 /* other default values */ | |
154 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT; | |
155 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT; | |
156 priv->surface = NULL; | |
157 priv->overlay = NULL; | |
158 priv->fullmodes = NULL; | |
159 | |
160 /* initialize the SDL Video system */ | |
161 if (SDL_Init (SDL_INIT_VIDEO)) { | |
162 // LOG (LOG_ERROR, "SDL video out: Initializing of SDL failed (SDL_Init). Please use the latest version of SDL."); | |
163 return -1; | |
164 } | |
165 | |
166 /* No Keyrepeats! */ | |
167 SDL_EnableKeyRepeat(0,0); | |
168 | |
169 /* get information about the graphics adapter */ | |
170 vidInfo = SDL_GetVideoInfo (); | |
171 | |
172 /* collect all fullscreen & hardware modes available */ | |
173 if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) { | |
174 | |
175 /* non hardware accelerated fullscreen modes */ | |
176 priv->sdlfullflags &= ~SDL_HWSURFACE; | |
177 priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags); | |
178 } | |
179 | |
180 /* test for normal resizeable & windowed hardware accellerated surfaces */ | |
181 if (!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) { | |
182 | |
183 /* test for NON hardware accelerated resizeable surfaces - poor you. | |
184 * That's all we have. If this fails there's nothing left. | |
185 * Theoretically there could be Fullscreenmodes left - we ignore this for now. | |
186 */ | |
187 priv->sdlflags &= ~SDL_HWSURFACE; | |
188 if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) { | |
189 // LOG (LOG_ERROR, "SDL video out: Couldn't get any acceptable SDL Mode for output. (SDL_ListModes failed)"); | |
190 return -1; | |
191 } | |
192 } | |
193 | |
194 | |
195 /* YUV overlays need at least 16-bit color depth, but the | |
196 * display might less. The SDL AAlib target says it can only do | |
197 * 8-bits, for example. So, if the display is less than 16-bits, | |
198 * we'll force the BPP to 16, and pray that SDL can emulate for us. | |
199 */ | |
200 priv->bpp = vidInfo->vfmt->BitsPerPixel; | |
201 if (priv->bpp < 16) { | |
202 /* | |
203 LOG (LOG_WARNING, "SDL video out: Your SDL display target wants to be at a color depth of (%d), but we need it to be at\ | |
204 least 16 bits, so we need to emulate 16-bit color. This is going to slow things down; you might want to\ | |
205 increase your display's color depth, if possible", priv->bpp); | |
206 */ | |
207 priv->bpp = 16; | |
208 } | |
209 | |
210 /* We dont want those in out event queue */ | |
211 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); | |
212 SDL_EventState(SDL_KEYUP, SDL_IGNORE); | |
213 SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); | |
214 SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); | |
215 SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); | |
216 SDL_EventState(SDL_QUIT, SDL_IGNORE); | |
217 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); | |
218 SDL_EventState(SDL_USEREVENT, SDL_IGNORE); | |
219 | |
220 /* Success! */ | |
221 return 0; | |
222 } | |
223 | |
224 | |
225 /** | |
226 * Close SDL, Cleanups, Free Memory | |
227 * | |
228 * params : *plugin | |
229 * returns : non-zero on success, zero on error. | |
230 **/ | |
231 | |
232 static int sdl_close (void) | |
233 { | |
234 struct sdl_priv_s *priv = &sdl_priv; | |
235 | |
236 // LOG (LOG_DEBUG, "SDL video out: Closed Plugin"); | |
237 // LOG (LOG_INFO, "SDL video out: Closed Plugin"); | |
238 | |
239 /* Cleanup YUV Overlay structure */ | |
240 if (priv->overlay) | |
241 SDL_FreeYUVOverlay(priv->overlay); | |
242 | |
243 /* Free our blitting surface */ | |
244 if (priv->surface) | |
245 SDL_FreeSurface(priv->surface); | |
246 | |
247 /* TODO: cleanup the full_modes array */ | |
248 | |
249 /* Cleanup SDL */ | |
250 SDL_Quit(); | |
251 | |
252 return 0; | |
253 } | |
254 | |
255 | |
256 /** | |
257 * Sets the specified fullscreen mode. | |
258 * | |
259 * params : mode == index of the desired fullscreen mode | |
260 * returns : doesn't return | |
261 **/ | |
262 | |
263 static void set_fullmode (int mode) | |
264 { | |
265 struct sdl_priv_s *priv = &sdl_priv; | |
266 SDL_Surface *newsurface = NULL; | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
267 int haspect, waspect = 0; |
1 | 268 |
269 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */ | |
270 if (mode < 0) | |
271 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1; | |
272 | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
273 /* Calculate proper aspect ratio for fullscreen |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
274 * Height smaller than expected: add horizontal black bars (haspect)*/ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
275 haspect = (priv->width * (float) ((float) priv->fullmodes[mode]->h / (float) priv->fullmodes[mode]->w) - priv->height) * (float) ((float) priv->fullmodes[mode]->w / (float) priv->width); |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
276 /* Height bigger than expected: add vertical black bars (waspect)*/ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
277 if (haspect < 0) { |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
278 haspect = 0; /* set haspect to zero because image will be scaled horizontal instead of vertical */ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
279 waspect = priv->fullmodes[mode]->w - ((float) ((float) priv->fullmodes[mode]->h / (float) priv->height) * (float) priv->width); |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
280 } |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
281 // printf ("W-Aspect: %i H-Aspect: %i\n", waspect, haspect); |
84 | 282 |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
283 /* change to given fullscreen mode and hide the mouse cursor */ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
284 newsurface = SDL_SetVideoMode(priv->fullmodes[mode]->w - waspect, priv->fullmodes[mode]->h - haspect, priv->bpp, priv->sdlfullflags); |
1 | 285 |
286 /* if we were successfull hide the mouse cursor and save the mode */ | |
287 if (newsurface) { | |
288 priv->surface = newsurface; | |
289 SDL_ShowCursor(0); | |
290 } | |
291 } | |
292 | |
293 | |
294 /** | |
295 * Initialize an SDL surface and an SDL YUV overlay. | |
296 * | |
297 * params : width == width of video we'll be displaying. | |
298 * height == height of video we'll be displaying. | |
299 * fullscreen == want to be fullscreen? | |
300 * title == Title for window titlebar. | |
301 * returns : non-zero on success, zero on error. | |
302 **/ | |
303 | |
304 static uint32_t | |
305 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) | |
306 //static int sdl_setup (int width, int height) | |
307 { | |
308 struct sdl_priv_s *priv = &sdl_priv; | |
84 | 309 unsigned int sdl_format, aspectheight; |
1 | 310 |
311 switch(format){ | |
312 case IMGFMT_YV12: sdl_format=SDL_YV12_OVERLAY;break; | |
313 case IMGFMT_YUY2: sdl_format=SDL_YUY2_OVERLAY;break; | |
314 default: | |
315 printf("SDL: Unsupported image format (0x%X)\n",format); | |
316 return -1; | |
317 } | |
318 | |
319 sdl_open (NULL, NULL); | |
320 | |
321 /* Save the original Image size */ | |
84 | 322 |
1 | 323 priv->width = width; |
324 priv->height = height; | |
325 priv->format = format; | |
326 | |
327 if(fullscreen){ | |
328 priv->windowsize.w = width; | |
329 priv->windowsize.h = height; | |
330 priv->surface=NULL; | |
331 set_fullmode(priv->fullmode); | |
332 } else { | |
333 priv->windowsize.w = d_width; | |
334 priv->windowsize.h = d_height; | |
335 priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlflags); | |
336 } | |
337 if(!priv->surface) return -1; // cannot SetVideoMode | |
338 | |
339 /* Initialize and create the YUV Overlay used for video out */ | |
340 if (!(priv->overlay = SDL_CreateYUVOverlay (width, height, sdl_format, priv->surface))) { | |
341 printf ("SDL video out: Couldn't create an SDL-based YUV overlay\n"); | |
342 return -1; | |
343 } | |
344 priv->framePlaneY = width * height; | |
345 priv->framePlaneUV = (width * height) >> 2; | |
346 priv->stridePlaneY = width; | |
347 priv->stridePlaneUV = width/2; | |
348 | |
349 return 0; | |
350 } | |
351 | |
352 | |
353 /** | |
354 * Draw a frame to the SDL YUV overlay. | |
355 * | |
356 * params : *src[] == the Y, U, and V planes that make up the frame. | |
357 * returns : non-zero on success, zero on error. | |
358 **/ | |
359 | |
360 //static int sdl_draw_frame (frame_t *frame) | |
361 static uint32_t draw_frame(uint8_t *src[]) | |
362 { | |
363 struct sdl_priv_s *priv = &sdl_priv; | |
364 uint8_t *dst; | |
365 | |
366 // priv->current_frame = (SDL_Overlay*) frame->private; | |
367 // SDL_UnlockYUVOverlay (priv->current_frame); | |
368 | |
369 if (SDL_LockYUVOverlay (priv->overlay)) { | |
370 // LOG (LOG_ERROR, "SDL video out: Couldn't lock SDL-based YUV overlay"); | |
371 return -1; | |
372 } | |
373 | |
374 switch(priv->format){ | |
375 case IMGFMT_YV12: | |
376 dst = (uint8_t *) *(priv->overlay->pixels); | |
377 memcpy (dst, src[0], priv->framePlaneY); | |
378 dst += priv->framePlaneY; | |
379 memcpy (dst, src[2], priv->framePlaneUV); | |
380 dst += priv->framePlaneUV; | |
381 memcpy (dst, src[1], priv->framePlaneUV); | |
382 break; | |
383 case IMGFMT_YUY2: | |
384 dst = (uint8_t *) *(priv->overlay->pixels); | |
385 memcpy (dst, src[0], priv->width*priv->height*2); | |
386 break; | |
387 } | |
388 | |
389 SDL_UnlockYUVOverlay (priv->overlay); | |
390 | |
391 return 0; | |
392 } | |
393 | |
394 | |
395 /** | |
396 * Draw a slice (16 rows of image) to the SDL YUV overlay. | |
397 * | |
398 * params : *src[] == the Y, U, and V planes that make up the slice. | |
399 * returns : non-zero on error, zero on success. | |
400 **/ | |
401 | |
402 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num) | |
403 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
404 { | |
405 struct sdl_priv_s *priv = &sdl_priv; | |
406 uint8_t *dst; | |
407 uint8_t *src; | |
408 int i; | |
409 | |
410 //priv->current_frame = priv->overlay; | |
411 | |
412 if (SDL_LockYUVOverlay (priv->overlay)) { | |
413 // LOG (LOG_ERROR, "SDL video out: Couldn't lock SDL-based YUV overlay"); | |
414 return -1; | |
415 } | |
416 | |
417 dst = (uint8_t *) *(priv->overlay->pixels) | |
418 + (priv->stridePlaneY * y + x); | |
419 src = image[0]; | |
420 for(i=0;i<h;i++){ | |
421 memcpy(dst,src,w); | |
422 src+=stride[0]; | |
423 dst+=priv->stridePlaneY; | |
424 } | |
425 | |
426 x/=2;y/=2;w/=2;h/=2; | |
427 | |
428 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY | |
429 + (priv->stridePlaneUV * y + x); | |
430 src = image[2]; | |
431 for(i=0;i<h;i++){ | |
432 memcpy(dst,src,w); | |
433 src+=stride[2]; | |
434 dst+=priv->stridePlaneUV; | |
435 } | |
436 | |
437 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY | |
438 + priv->framePlaneUV + (priv->stridePlaneUV * y + x); | |
439 src = image[1]; | |
440 for(i=0;i<h;i++){ | |
441 memcpy(dst,src,w); | |
442 src+=stride[1]; | |
443 dst+=priv->stridePlaneUV; | |
444 } | |
445 | |
446 #if 0 | |
447 dst = (uint8_t *) *(priv->overlay->pixels) + (priv->slicePlaneY * slice_num); | |
448 memcpy (dst, src[0], priv->slicePlaneY); | |
449 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY + (priv->slicePlaneUV * slice_num); | |
450 memcpy (dst, src[2], priv->slicePlaneUV); | |
451 dst += priv->framePlaneUV; | |
452 memcpy (dst, src[1], priv->slicePlaneUV); | |
453 #endif | |
454 | |
455 SDL_UnlockYUVOverlay (priv->overlay); | |
456 | |
457 return 0; | |
458 } | |
459 | |
460 | |
461 | |
462 /** | |
463 * Checks for SDL keypress and window resize events | |
464 * | |
465 * params : none | |
466 * returns : doesn't return | |
467 **/ | |
468 | |
469 #include "../linux/keycodes.h" | |
470 extern void mplayer_put_key(int code); | |
471 | |
472 static void check_events (void) | |
473 { | |
474 struct sdl_priv_s *priv = &sdl_priv; | |
475 SDL_Event event; | |
476 SDLKey keypressed; | |
477 | |
478 /* Poll the waiting SDL Events */ | |
479 while ( SDL_PollEvent(&event) ) { | |
480 switch (event.type) { | |
481 | |
482 /* capture window resize events */ | |
483 case SDL_VIDEORESIZE: | |
484 priv->surface = SDL_SetVideoMode(event.resize.w, event.resize.h, priv->bpp, priv->sdlflags); | |
485 | |
486 /* save video extents, to restore them after going fullscreen */ | |
487 //if(!(priv->surface->flags & SDL_FULLSCREEN)) { | |
488 priv->windowsize.w = priv->surface->w; | |
489 priv->windowsize.h = priv->surface->h; | |
490 //} | |
491 // LOG (LOG_DEBUG, "SDL video out: Window resize"); | |
492 break; | |
493 | |
494 | |
495 /* graphics mode selection shortcuts */ | |
496 case SDL_KEYDOWN: | |
497 keypressed = event.key.keysym.sym; | |
498 | |
499 /* plus key pressed. plus cycles through available fullscreenmodes, if we have some */ | |
500 if ( ((keypressed == SDLK_PLUS) || (keypressed == SDLK_KP_PLUS)) && (priv->fullmodes) ) { | |
501 /* select next fullscreen mode */ | |
502 priv->fullmode++; | |
503 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0; | |
504 set_fullmode(priv->fullmode); | |
505 | |
506 // LOG (LOG_DEBUG, "SDL video out: Set next available fullscreen mode."); | |
507 } | |
508 | |
509 /* return or escape key pressed toggles/exits fullscreenmode */ | |
510 else if ( (keypressed == SDLK_RETURN) || (keypressed == SDLK_ESCAPE) ) { | |
511 if (priv->surface->flags & SDL_FULLSCREEN) { | |
512 priv->surface = SDL_SetVideoMode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags); | |
513 SDL_ShowCursor(1); | |
514 // LOG (LOG_DEBUG, "SDL video out: Windowed mode"); | |
515 } | |
516 else if (priv->fullmodes){ | |
517 set_fullmode(priv->fullmode); | |
518 | |
519 // LOG (LOG_DEBUG, "SDL video out: Set fullscreen mode."); | |
520 } | |
521 } | |
522 | |
523 else switch(keypressed){ | |
524 // case SDLK_q: if(!(priv->surface->flags & SDL_FULLSCREEN))mplayer_put_key('q');break; | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
525 case SDLK_q: SDL_ShowCursor(1); mplayer_put_key('q');break; //F.B.: added ShowCursor |
1 | 526 // case SDLK_p: mplayer_put_key('p');break; |
527 // case SDLK_SPACE: mplayer_put_key(' ');break; | |
528 case SDLK_UP: mplayer_put_key(KEY_UP);break; | |
529 case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break; | |
530 case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break; | |
531 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
532 case SDLK_PLUS: | |
533 case SDLK_KP_PLUS: mplayer_put_key('+');break; | |
534 case SDLK_MINUS: | |
535 case SDLK_KP_MINUS: mplayer_put_key('-');break; | |
536 } | |
537 | |
538 break; | |
539 } | |
540 } | |
541 } | |
542 | |
543 | |
544 /** | |
545 * Display the surface we have written our data to and check for events. | |
546 * | |
547 * params : mode == index of the desired fullscreen mode | |
548 * returns : doesn't return | |
549 **/ | |
550 | |
551 static void flip_page (void) | |
552 { | |
553 struct sdl_priv_s *priv = &sdl_priv; | |
554 | |
555 /* check and react on keypresses and window resizes */ | |
556 check_events(); | |
557 | |
558 /* blit to the YUV overlay */ | |
559 SDL_DisplayYUVOverlay (priv->overlay, &priv->surface->clip_rect); | |
560 | |
561 /* check if we have a double buffered surface and flip() if we do. */ | |
562 if ( priv->surface->flags & SDL_DOUBLEBUF ) | |
563 SDL_Flip(priv->surface); | |
564 | |
565 SDL_LockYUVOverlay (priv->overlay); | |
566 } | |
567 | |
568 #if 0 | |
569 static frame_t* sdl_allocate_image_buffer(int width, int height) | |
570 { | |
571 struct sdl_priv_s *priv = &sdl_priv; | |
572 frame_t *frame; | |
573 | |
574 if (!(frame = malloc (sizeof (frame_t)))) | |
575 return NULL; | |
576 | |
577 if (!(frame->private = (void*) SDL_CreateYUVOverlay (width, height, | |
578 SDL_IYUV_OVERLAY, priv->surface))) | |
579 { | |
580 // LOG (LOG_ERROR, "SDL video out: Couldn't create an SDL-based YUV overlay"); | |
581 return NULL; | |
582 } | |
583 | |
584 frame->base[0] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[0]; | |
585 frame->base[1] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[1]; | |
586 frame->base[2] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[2]; | |
587 | |
588 SDL_LockYUVOverlay ((SDL_Overlay*) frame->private); | |
589 return frame; | |
590 } | |
591 | |
592 static void sdl_free_image_buffer(frame_t* frame) | |
593 { | |
594 SDL_FreeYUVOverlay((SDL_Overlay*) frame->private); | |
595 free(frame); | |
596 } | |
597 #endif | |
598 | |
599 static uint32_t | |
600 query_format(uint32_t format) | |
601 { | |
602 switch(format){ | |
603 case IMGFMT_YV12: | |
604 case IMGFMT_YUY2: | |
605 // case IMGFMT_RGB|24: | |
606 // case IMGFMT_BGR|24: | |
607 return 1; | |
608 } | |
609 return 0; | |
610 } | |
611 | |
612 static const vo_info_t* | |
613 get_info(void) | |
614 { | |
615 return &vo_info; | |
616 } | |
617 | |
618 | |
619 static void | |
620 uninit(void) | |
621 { | |
622 sdl_close(); | |
623 } | |
624 |