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