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