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