1 /*****************************************************************************
2 * vout_sdl.c: SDL video output display method
3 *****************************************************************************
4 * Copyright (C) 1998, 1999, 2000 VideoLAN
5 * $Id: vout_sdl.c,v 1.64 2001/10/11 16:12:43 massiot Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Pierre Baillet <oct@zoy.org>
9 * Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 #define MODULE_NAME sdl
27 #include "modules_inner.h"
29 /*****************************************************************************
31 *****************************************************************************/
34 #include <errno.h> /* ENOMEM */
35 #include <stdlib.h> /* free() */
36 #include <string.h> /* strerror() */
38 #include <sys/types.h>
40 # include <netinet/in.h> /* BSD: struct in_addr */
43 #include SDL_INCLUDE_FILE
52 #include "video_output.h"
55 #include "interface.h"
56 /* FIXME: get rid of this */
57 #include "keystrokes.h"
62 #include "modules_export.h"
64 /*****************************************************************************
65 * FIXME: this file is ... *
67 * XXX XXX FIXME XXX XXX XXX XXX *
68 * XXX XXX XXX XXX XXX XXX XXX XXX *
69 * XXX XXX XXX XXX FIXME XXX *
70 * XXX XXX XXX TODO XXX XXX XXX *
71 * XXX XXX XXX XXX XXX XXX *
72 * FIXME FIXME FIXME XXX XXX *
74 *****************************************************************************/
76 /*****************************************************************************
77 * vout_sys_t: video output SDL method descriptor
78 *****************************************************************************
79 * This structure is part of the video output thread descriptor.
80 * It describes the SDL specific properties of an output thread.
81 *****************************************************************************/
82 typedef struct vout_sys_s
87 SDL_Surface * p_display; /* display device */
88 SDL_Overlay * p_overlay; /* overlay device */
92 boolean_t b_reopen_display;
94 boolean_t b_cursor_autohidden;
97 Uint8 * p_sdl_buf[2]; /* Buffer information */
101 /*****************************************************************************
103 *****************************************************************************/
104 static int vout_Probe ( probedata_t *p_data );
105 static int vout_Create ( struct vout_thread_s * );
106 static int vout_Init ( struct vout_thread_s * );
107 static void vout_End ( struct vout_thread_s * );
108 static void vout_Destroy ( struct vout_thread_s * );
109 static int vout_Manage ( struct vout_thread_s * );
110 static void vout_Display ( struct vout_thread_s * );
111 static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
112 u16 *blue, u16 *transp );
114 static int SDLOpenDisplay ( vout_thread_t *p_vout );
115 static void SDLCloseDisplay ( vout_thread_t *p_vout );
116 static void OutputCoords ( const picture_t *p_pic, const boolean_t scale,
117 const int win_w, const int win_h,
118 int *dx, int *dy, int *w, int *h );
120 /*****************************************************************************
121 * Functions exported as capabilities. They are declared as static so that
122 * we don't pollute the namespace too much.
123 *****************************************************************************/
124 void _M( vout_getfunctions )( function_list_t * p_function_list )
126 p_function_list->pf_probe = vout_Probe;
127 p_function_list->functions.vout.pf_create = vout_Create;
128 p_function_list->functions.vout.pf_init = vout_Init;
129 p_function_list->functions.vout.pf_end = vout_End;
130 p_function_list->functions.vout.pf_destroy = vout_Destroy;
131 p_function_list->functions.vout.pf_manage = vout_Manage;
132 p_function_list->functions.vout.pf_display = vout_Display;
133 p_function_list->functions.vout.pf_setpalette = vout_SetPalette;
136 /*****************************************************************************
137 * vout_Probe: probe the video driver and return a score
138 *****************************************************************************
139 * This function tries to initialize SDL and returns a score to the
140 * plugin manager so that it can select the best plugin.
141 *****************************************************************************/
142 static int vout_Probe( probedata_t *p_data )
144 if( TestMethod( VOUT_METHOD_VAR, "sdl" ) )
152 /*****************************************************************************
153 * vout_Create: allocate SDL video thread output method
154 *****************************************************************************
155 * This function allocate and initialize a SDL vout method. It uses some of the
156 * vout properties to choose the correct mode, and change them according to the
157 * mode actually used.
158 *****************************************************************************/
159 static int vout_Create( vout_thread_t *p_vout )
161 /* Allocate structure */
162 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
163 if( p_vout->p_sys == NULL )
165 intf_ErrMsg( "vout error: can't create p_sys (%s)", strerror(ENOMEM) );
169 /* Initialize library */
170 if( SDL_Init( SDL_INIT_VIDEO
172 /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/
173 | SDL_INIT_EVENTTHREAD
176 /* In debug mode you may want vlc to dump a core instead of staying
178 | SDL_INIT_NOPARACHUTE
182 intf_ErrMsg( "vout error: can't initialize SDL (%s)", SDL_GetError() );
183 free( p_vout->p_sys );
187 p_vout->p_sys->b_cursor = 1; /* TODO should be done with a main_GetInt.. */
189 p_vout->p_sys->b_cursor_autohidden = 0;
190 p_vout->p_sys->i_lastmoved = mdate();
192 p_vout->b_fullscreen = main_GetIntVariable( VOUT_FULLSCREEN_VAR,
193 VOUT_FULLSCREEN_DEFAULT );
194 p_vout->p_sys->b_overlay = main_GetIntVariable( VOUT_OVERLAY_VAR,
195 VOUT_OVERLAY_DEFAULT );
196 p_vout->p_sys->i_width = p_vout->i_width;
197 p_vout->p_sys->i_height = p_vout->i_height;
199 p_vout->p_sys->p_display = NULL;
200 p_vout->p_sys->p_overlay = NULL;
202 if( SDLOpenDisplay(p_vout) )
204 intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() );
205 free( p_vout->p_sys );
209 /* FIXME: get rid of this ASAP, it's FUCKING UGLY */
210 { intf_thread_t * p_intf = p_main->p_intf;
211 intf_AssignKey(p_intf, SDLK_q, INTF_KEY_QUIT, 0);
212 intf_AssignKey(p_intf, SDLK_ESCAPE, INTF_KEY_QUIT, 0);
213 /* intf_AssignKey(p_intf,3,'Q'); */
214 intf_AssignKey(p_intf, SDLK_0, INTF_KEY_SET_CHANNEL,0);
215 intf_AssignKey(p_intf, SDLK_1, INTF_KEY_SET_CHANNEL,1);
216 intf_AssignKey(p_intf, SDLK_2, INTF_KEY_SET_CHANNEL,2);
217 intf_AssignKey(p_intf, SDLK_3, INTF_KEY_SET_CHANNEL,3);
218 intf_AssignKey(p_intf, SDLK_4, INTF_KEY_SET_CHANNEL,4);
219 intf_AssignKey(p_intf, SDLK_5, INTF_KEY_SET_CHANNEL,5);
220 intf_AssignKey(p_intf, SDLK_6, INTF_KEY_SET_CHANNEL,6);
221 intf_AssignKey(p_intf, SDLK_7, INTF_KEY_SET_CHANNEL,7);
222 intf_AssignKey(p_intf, SDLK_8, INTF_KEY_SET_CHANNEL,8);
223 intf_AssignKey(p_intf, SDLK_9, INTF_KEY_SET_CHANNEL,9);
224 intf_AssignKey(p_intf, SDLK_PLUS, INTF_KEY_INC_VOLUME, 0);
225 intf_AssignKey(p_intf, SDLK_MINUS, INTF_KEY_DEC_VOLUME, 0);
226 intf_AssignKey(p_intf, SDLK_m, INTF_KEY_TOGGLE_VOLUME, 0);
227 /* intf_AssignKey(p_intf,'M','M'); */
228 intf_AssignKey(p_intf, SDLK_g, INTF_KEY_DEC_GAMMA, 0);
229 /* intf_AssignKey(p_intf,'G','G'); */
230 intf_AssignKey(p_intf, SDLK_c, INTF_KEY_TOGGLE_GRAYSCALE, 0);
231 intf_AssignKey(p_intf, SDLK_SPACE, INTF_KEY_TOGGLE_INTERFACE, 0);
232 intf_AssignKey(p_intf, SDLK_i, INTF_KEY_TOGGLE_INFO, 0);
233 intf_AssignKey(p_intf, SDLK_s, INTF_KEY_TOGGLE_SCALING, 0);
234 intf_AssignKey(p_intf, SDLK_d, INTF_KEY_DUMP_STREAM, 0); }
239 /*****************************************************************************
240 * vout_Init: initialize SDL video thread output method
241 *****************************************************************************
242 * This function initialize the SDL display device.
243 *****************************************************************************/
244 static int vout_Init( vout_thread_t *p_vout )
246 /* This hack is hugly, but hey, you are, too. */
248 SDL_Overlay * p_overlay;
250 p_overlay = SDL_CreateYUVOverlay(
251 main_GetIntVariable( VOUT_WIDTH_VAR,VOUT_WIDTH_DEFAULT ),
252 main_GetIntVariable( VOUT_HEIGHT_VAR,VOUT_HEIGHT_DEFAULT ),
254 p_vout->p_sys->p_display );
256 if( p_overlay == NULL )
258 intf_ErrMsg( "vout error: could not create SDL overlay" );
259 p_vout->b_need_render = 1;
263 intf_WarnMsg( 2, "vout: YUV acceleration %s",
264 p_overlay->hw_overlay ? "activated" : "unavailable !" );
265 p_vout->b_need_render = !p_overlay->hw_overlay;
267 SDL_FreeYUVOverlay( p_overlay );
272 /*****************************************************************************
273 * vout_End: terminate Sys video thread output method
274 *****************************************************************************
275 * Terminate an output method created by vout_SDLCreate
276 *****************************************************************************/
277 static void vout_End( vout_thread_t *p_vout )
279 SDLCloseDisplay( p_vout );
280 SDL_QuitSubSystem( SDL_INIT_VIDEO );
283 /*****************************************************************************
284 * vout_Destroy: destroy Sys video thread output method
285 *****************************************************************************
286 * Terminate an output method created by vout_SDLCreate
287 *****************************************************************************/
288 static void vout_Destroy( vout_thread_t *p_vout )
290 free( p_vout->p_sys );
293 /*****************************************************************************
294 * vout_Manage: handle Sys events
295 *****************************************************************************
296 * This function should be called regularly by video output thread. It returns
297 * a non null value if an error occured.
298 *****************************************************************************/
299 static int vout_Manage( vout_thread_t *p_vout )
301 SDL_Event event; /* SDL event */
305 while( SDL_PollEvent(&event) )
309 case SDL_VIDEORESIZE: /* Resizing of window */
310 p_vout->i_width = event.resize.w;
311 p_vout->i_height = event.resize.h;
312 p_vout->i_changes |= VOUT_SIZE_CHANGE;
315 case SDL_MOUSEMOTION:
316 if( p_vout->p_sys->b_cursor &&
317 (abs(event.motion.xrel) > 2 || abs(event.motion.yrel) > 2) )
319 if( p_vout->p_sys->b_cursor_autohidden )
321 p_vout->p_sys->b_cursor_autohidden = 0;
326 p_vout->p_sys->i_lastmoved = mdate();
331 case SDL_MOUSEBUTTONUP:
332 switch( event.button.button )
334 case SDL_BUTTON_RIGHT:
335 p_main->p_intf->b_menu_change = 1;
340 case SDL_MOUSEBUTTONDOWN:
341 switch( event.button.button )
343 case SDL_BUTTON_MIDDLE:
344 p_vout->i_changes |= VOUT_CURSOR_CHANGE;
350 intf_ProcessKey( p_main->p_intf, SDLK_q );
353 case SDL_KEYDOWN: /* if a key is pressed */
355 switch( event.key.keysym.sym )
357 case SDLK_f: /* switch to fullscreen */
358 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
361 case SDLK_y: /* switch to hard YUV */
362 p_vout->i_changes |= VOUT_YUV_CHANGE;
365 case SDLK_c: /* toggle grayscale */
366 p_vout->b_grayscale = ! p_vout->b_grayscale;
367 p_vout->i_changes |= VOUT_GRAYSCALE_CHANGE;
370 case SDLK_i: /* toggle info */
371 p_vout->b_info = ! p_vout->b_info;
372 p_vout->i_changes |= VOUT_INFO_CHANGE;
375 case SDLK_s: /* toggle scaling */
376 p_vout->b_scale = ! p_vout->b_scale;
377 p_vout->i_changes |= VOUT_SCALE_CHANGE;
380 case SDLK_SPACE: /* toggle interface */
381 p_vout->b_interface = ! p_vout->b_interface;
382 p_vout->i_changes |= VOUT_INTF_CHANGE;
386 network_ChannelJoin( 0 );
389 network_ChannelJoin( 1 );
392 network_ChannelJoin( 2 );
395 network_ChannelJoin( 3 );
398 network_ChannelJoin( 4 );
401 network_ChannelJoin( 5 );
404 network_ChannelJoin( 6 );
407 network_ChannelJoin( 7 );
410 network_ChannelJoin( 8 );
413 network_ChannelJoin( 9 );
417 p_main->p_intf->b_menu_change = 1;
421 p_key = SDL_GetKeyName( event.key.keysym.sym ) ;
422 if( intf_ProcessKey( p_main->p_intf,
423 (char )event.key.keysym.sym ) )
425 intf_DbgMsg( "unhandled key '%c' (%i)",
426 (char)event.key.keysym.sym,
427 event.key.keysym.sym );
441 if( p_vout->i_changes & VOUT_SIZE_CHANGE )
443 p_vout->p_sys->i_width = p_vout->i_width;
444 p_vout->p_sys->i_height = p_vout->i_height;
446 /* Need to reopen display */
447 SDLCloseDisplay( p_vout );
448 if( SDLOpenDisplay( p_vout ) )
450 intf_ErrMsg( "vout error: can't reopen display after resize" );
453 p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
459 if( p_vout->i_changes & VOUT_YUV_CHANGE )
461 p_vout->b_need_render = ! p_vout->b_need_render;
463 /* Need to reopen display */
464 SDLCloseDisplay( p_vout );
465 if( SDLOpenDisplay( p_vout ) )
467 intf_ErrMsg( "error: can't reopen display after YUV change" );
470 p_vout->i_changes &= ~VOUT_YUV_CHANGE;
476 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
478 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
480 SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
482 p_vout->p_sys->b_cursor_autohidden = 0;
483 SDL_ShowCursor( p_vout->p_sys->b_cursor &&
484 ! p_vout->p_sys->b_cursor_autohidden );
486 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
492 if( ! p_vout->p_sys->b_cursor_autohidden &&
493 ( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) )
495 /* Hide the mouse automatically */
496 p_vout->p_sys->b_cursor_autohidden = 1;
500 if( p_vout->i_changes & VOUT_CURSOR_CHANGE )
502 p_vout->p_sys->b_cursor = ! p_vout->p_sys->b_cursor;
504 SDL_ShowCursor( p_vout->p_sys->b_cursor &&
505 ! p_vout->p_sys->b_cursor_autohidden );
507 p_vout->i_changes &= ~VOUT_CURSOR_CHANGE;
513 /*****************************************************************************
514 * vout_SetPalette: sets an 8 bpp palette
515 *****************************************************************************
516 * This function sets the palette given as an argument. It does not return
517 * anything, but could later send information on which colors it was unable
519 *****************************************************************************/
520 static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
521 u16 *blue, u16 *transp)
523 /* Create a display surface with a grayscale palette */
524 SDL_Color colors[256];
527 /* Fill colors with color information */
528 for( i = 0; i < 256; i++ )
530 colors[ i ].r = red[ i ] >> 8;
531 colors[ i ].g = green[ i ] >> 8;
532 colors[ i ].b = blue[ i ] >> 8;
536 if( SDL_SetColors( p_vout->p_sys->p_display, colors, 0, 256 ) == 0 )
538 intf_ErrMsg( "vout error: failed setting palette" );
543 /*****************************************************************************
544 * vout_Display: displays previously rendered output
545 *****************************************************************************
546 * This function send the currently rendered image to the display, wait until
547 * it is displayed and switch the two rendering buffer, preparing next frame.
548 *****************************************************************************/
549 static void vout_Display( vout_thread_t *p_vout )
553 if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display)
555 if( !p_vout->b_need_render )
558 * p_vout->p_rendered_pic->p_y/u/v contains the YUV buffers to
561 /* TODO: support for streams other than 4:2:0 */
562 if( p_vout->p_rendered_pic->i_type != YUV_420_PICTURE )
564 intf_ErrMsg("sdl vout error: no support for that kind of pictures");
567 /* create the overlay if necessary */
568 if( p_vout->p_sys->p_overlay == NULL )
570 p_vout->p_sys->p_overlay = SDL_CreateYUVOverlay(
571 p_vout->p_rendered_pic->i_width,
572 p_vout->p_rendered_pic->i_height,
574 p_vout->p_sys->p_display );
576 if( p_vout->p_sys->p_overlay != NULL )
578 intf_WarnMsg( 2, "vout: YUV acceleration %s",
579 p_vout->p_sys->p_overlay->hw_overlay
580 ? "activated" : "unavailable !" );
584 if( p_vout->p_sys->p_overlay == NULL )
586 /* Overlay allocation failed, switch back to software mode */
587 intf_ErrMsg( "vout error: could not create SDL overlay" );
588 p_vout->b_need_render = 1;
592 int i_x, i_y, i_w, i_h;
594 SDL_LockYUVOverlay( p_vout->p_sys->p_overlay );
595 /* copy the data into video buffers */
597 memcpy( p_vout->p_sys->p_overlay->pixels[0],
598 p_vout->p_rendered_pic->p_y,
599 p_vout->p_sys->p_overlay->h *
600 p_vout->p_sys->p_overlay->pitches[0] );
602 memcpy( p_vout->p_sys->p_overlay->pixels[1],
603 p_vout->p_rendered_pic->p_v,
604 p_vout->p_sys->p_overlay->h *
605 p_vout->p_sys->p_overlay->pitches[1] / 2 );
607 memcpy( p_vout->p_sys->p_overlay->pixels[2],
608 p_vout->p_rendered_pic->p_u,
609 p_vout->p_sys->p_overlay->h *
610 p_vout->p_sys->p_overlay->pitches[2] / 2 );
612 OutputCoords( p_vout->p_rendered_pic, 1,
613 p_vout->p_sys->i_width,
614 p_vout->p_sys->i_height,
622 SDL_DisplayYUVOverlay( p_vout->p_sys->p_overlay , &disp );
623 SDL_UnlockYUVOverlay(p_vout->p_sys->p_overlay);
629 /* Software YUV: change display frame */
630 SDL_Flip( p_vout->p_sys->p_display );
634 /* following functions are local */
636 /*****************************************************************************
637 * SDLOpenDisplay: open and initialize SDL device
638 *****************************************************************************
639 * Open and initialize display according to preferences specified in the vout
641 *****************************************************************************/
642 static int SDLOpenDisplay( vout_thread_t *p_vout )
644 SDL_Rect clipping_rect;
648 * TODO: Check that we can request for a DOUBLEBUF HWSURFACE display
651 /* init flags and cursor */
652 flags = SDL_ANYFORMAT | SDL_HWPALETTE;
654 if( p_vout->b_fullscreen )
656 flags |= SDL_FULLSCREEN;
660 flags |= SDL_RESIZABLE;
663 if( p_vout->b_need_render )
665 flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
669 flags |= SDL_SWSURFACE; /* save video memory */
672 bpp = SDL_VideoModeOK( p_vout->p_sys->i_width,
673 p_vout->p_sys->i_height,
674 p_vout->i_screen_depth, flags );
678 intf_ErrMsg( "vout error: no video mode available" );
682 p_vout->p_sys->p_display = SDL_SetVideoMode(p_vout->p_sys->i_width,
683 p_vout->p_sys->i_height,
686 if( p_vout->p_sys->p_display == NULL )
688 intf_ErrMsg( "vout error: cannot set video mode" );
692 SDL_LockSurface( p_vout->p_sys->p_display );
694 SDL_WM_SetCaption( VOUT_TITLE " (SDL output)",
695 VOUT_TITLE " (SDL output)" );
696 SDL_EventState(SDL_KEYUP , SDL_IGNORE); /* ignore keys up */
698 if( p_vout->b_need_render )
700 p_vout->p_sys->p_sdl_buf[ 0 ] = p_vout->p_sys->p_display->pixels;
701 SDL_Flip(p_vout->p_sys->p_display);
702 p_vout->p_sys->p_sdl_buf[ 1 ] = p_vout->p_sys->p_display->pixels;
703 SDL_Flip(p_vout->p_sys->p_display);
705 /* Set clipping for text */
708 clipping_rect.w = p_vout->p_sys->p_display->w;
709 clipping_rect.h = p_vout->p_sys->p_display->h;
710 SDL_SetClipRect(p_vout->p_sys->p_display, &clipping_rect);
712 /* Set thread information */
713 p_vout->i_width = p_vout->p_sys->p_display->w;
714 p_vout->i_height = p_vout->p_sys->p_display->h;
715 p_vout->i_bytes_per_line = p_vout->p_sys->p_display->pitch;
717 p_vout->i_screen_depth =
718 p_vout->p_sys->p_display->format->BitsPerPixel;
719 p_vout->i_bytes_per_pixel =
720 p_vout->p_sys->p_display->format->BytesPerPixel;
722 p_vout->i_red_mask = p_vout->p_sys->p_display->format->Rmask;
723 p_vout->i_green_mask = p_vout->p_sys->p_display->format->Gmask;
724 p_vout->i_blue_mask = p_vout->p_sys->p_display->format->Bmask;
726 /* FIXME: palette in 8bpp ?? */
727 /* Set and initialize buffers */
728 p_vout->pf_setbuffers( p_vout, p_vout->p_sys->p_sdl_buf[ 0 ],
729 p_vout->p_sys->p_sdl_buf[ 1 ] );
733 p_vout->p_sys->p_sdl_buf[ 0 ] = p_vout->p_sys->p_display->pixels;
734 p_vout->p_sys->p_sdl_buf[ 1 ] = p_vout->p_sys->p_display->pixels;
736 /* Set thread information */
737 p_vout->i_width = p_vout->p_sys->p_display->w;
738 p_vout->i_height = p_vout->p_sys->p_display->h;
739 p_vout->i_bytes_per_line = p_vout->p_sys->p_display->pitch;
741 p_vout->pf_setbuffers( p_vout, p_vout->p_sys->p_sdl_buf[ 0 ],
742 p_vout->p_sys->p_sdl_buf[ 1 ] );
745 p_vout->p_sys->b_reopen_display = 0;
750 /*****************************************************************************
751 * SDLCloseDisplay: close and reset SDL device
752 *****************************************************************************
753 * This function returns all resources allocated by SDLOpenDisplay and restore
754 * the original state of the device.
755 *****************************************************************************/
756 static void SDLCloseDisplay( vout_thread_t *p_vout )
758 if( p_vout->p_sys->p_display != NULL )
760 if( p_vout->p_sys->p_overlay != NULL )
762 SDL_FreeYUVOverlay( p_vout->p_sys->p_overlay );
763 p_vout->p_sys->p_overlay = NULL;
766 SDL_UnlockSurface ( p_vout->p_sys->p_display );
767 SDL_FreeSurface( p_vout->p_sys->p_display );
768 p_vout->p_sys->p_display = NULL;
772 /*****************************************************************************
773 * OutputCoords: compute the dimensions of the destination image
774 *****************************************************************************
775 * This based on some code in SetBufferPicture... , it is also in use in the
776 * the xvideo plugin. Maybe we should think about putting standard video
777 * processing functions in a common library ?
778 *****************************************************************************/
779 static void OutputCoords( const picture_t *p_pic, const boolean_t scale,
780 const int win_w, const int win_h,
781 int *dx, int *dy, int *w, int *h )
785 *w = p_pic->i_width; *h = p_pic->i_height;
790 switch( p_pic->i_aspect_ratio )
796 case AR_16_9_PICTURE:
800 case AR_221_1_PICTURE:
801 *h = win_w * 100 / 221;
804 case AR_SQUARE_PICTURE:
806 *h = win_w * p_pic->i_height / p_pic->i_width;
813 switch( p_pic->i_aspect_ratio )
819 case AR_16_9_PICTURE:
823 case AR_221_1_PICTURE:
824 *w = win_h * 221 / 100;
827 case AR_SQUARE_PICTURE:
829 *w = win_h * p_pic->i_width / p_pic->i_height;
835 /* Set picture position */
836 *dx = (win_w - *w) / 2;
837 *dy = (win_h - *h) / 2;