1 /*****************************************************************************
2 * vout_sdl.c: SDL video output display method
3 *****************************************************************************
4 * Copyright (C) 1998-2001 VideoLAN
5 * $Id: vout_sdl.c,v 1.93 2002/06/01 18:04:49 sam 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 /*****************************************************************************
28 *****************************************************************************/
29 #include <errno.h> /* ENOMEM */
30 #include <stdlib.h> /* free() */
31 #include <string.h> /* strerror() */
37 #include <sys/types.h>
39 # include <netinet/in.h> /* BSD: struct in_addr */
42 #include SDL_INCLUDE_FILE
46 #define SDL_MAX_DIRECTBUFFERS 10
47 #define SDL_DEFAULT_BPP 16
49 /*****************************************************************************
50 * vout_sys_t: video output SDL method descriptor
51 *****************************************************************************
52 * This structure is part of the video output thread descriptor.
53 * It describes the SDL specific properties of an output thread.
54 *****************************************************************************/
57 SDL_Surface * p_display; /* display device */
63 SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
69 vlc_bool_t b_cursor_autohidden;
71 mtime_t i_lastpressed; /* to track dbl-clicks */
74 /*****************************************************************************
75 * picture_sys_t: direct buffer method descriptor
76 *****************************************************************************
77 * This structure is part of the picture descriptor, it describes the
78 * SDL specific properties of a direct buffer.
79 *****************************************************************************/
82 SDL_Overlay *p_overlay;
85 /*****************************************************************************
87 *****************************************************************************/
88 static int vout_Create ( vout_thread_t * );
89 static int vout_Init ( vout_thread_t * );
90 static void vout_End ( vout_thread_t * );
91 static void vout_Destroy ( vout_thread_t * );
92 static int vout_Manage ( vout_thread_t * );
93 static void vout_Render ( vout_thread_t *, picture_t * );
94 static void vout_Display ( vout_thread_t *, picture_t * );
96 static int OpenDisplay ( vout_thread_t * );
97 static void CloseDisplay ( vout_thread_t * );
98 static int NewPicture ( vout_thread_t *, picture_t * );
99 static void SetPalette ( vout_thread_t *, u16 *, u16 *, u16 * );
101 /*****************************************************************************
102 * Functions exported as capabilities. They are declared as static so that
103 * we don't pollute the namespace too much.
104 *****************************************************************************/
105 void _M( vout_getfunctions )( function_list_t * p_function_list )
107 p_function_list->functions.vout.pf_create = vout_Create;
108 p_function_list->functions.vout.pf_init = vout_Init;
109 p_function_list->functions.vout.pf_end = vout_End;
110 p_function_list->functions.vout.pf_destroy = vout_Destroy;
111 p_function_list->functions.vout.pf_manage = vout_Manage;
112 p_function_list->functions.vout.pf_render = vout_Render;
113 p_function_list->functions.vout.pf_display = vout_Display;
116 /*****************************************************************************
117 * vout_Create: allocate SDL video thread output method
118 *****************************************************************************
119 * This function allocate and initialize a SDL vout method. It uses some of the
120 * vout properties to choose the correct mode, and change them according to the
121 * mode actually used.
122 *****************************************************************************/
123 static int vout_Create( vout_thread_t *p_vout )
129 if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
134 /* Allocate structure */
135 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
136 if( p_vout->p_sys == NULL )
138 msg_Err( p_vout, "out of memory" );
143 psz_method = config_GetPsz( p_vout, "vout" );
146 while( *psz_method && *psz_method != ':' )
153 setenv( "SDL_VIDEODRIVER", psz_method + 1, 1 );
158 /* Initialize library */
159 if( SDL_Init( SDL_INIT_VIDEO
161 /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/
162 | SDL_INIT_EVENTTHREAD
165 /* In debug mode you may want vlc to dump a core instead of staying
167 | SDL_INIT_NOPARACHUTE
171 msg_Err( p_vout, "cannot initialize SDL (%s)", SDL_GetError() );
172 free( p_vout->p_sys );
176 p_vout->p_sys->b_cursor = 1;
177 p_vout->p_sys->b_cursor_autohidden = 0;
178 p_vout->p_sys->i_lastmoved = mdate();
180 if( OpenDisplay( p_vout ) )
182 msg_Err( p_vout, "cannot set up SDL (%s)", SDL_GetError() );
183 SDL_QuitSubSystem( SDL_INIT_VIDEO );
184 free( p_vout->p_sys );
191 /*****************************************************************************
192 * vout_Init: initialize SDL video thread output method
193 *****************************************************************************
194 * This function initialize the SDL display device.
195 *****************************************************************************/
196 static int vout_Init( vout_thread_t *p_vout )
201 p_vout->p_sys->i_surfaces = 0;
203 I_OUTPUTPICTURES = 0;
205 /* Initialize the output structure */
206 if( p_vout->p_sys->p_overlay == NULL )
208 /* All we have is an RGB image with square pixels */
209 p_vout->output.i_width = p_vout->p_sys->i_width;
210 p_vout->output.i_height = p_vout->p_sys->i_height;
211 p_vout->output.i_aspect = p_vout->output.i_width
213 / p_vout->output.i_height;
217 /* We may need to convert the chroma, but at least we keep the
219 p_vout->output.i_width = p_vout->render.i_width;
220 p_vout->output.i_height = p_vout->render.i_height;
221 p_vout->output.i_aspect = p_vout->render.i_aspect;
224 /* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
225 while( I_OUTPUTPICTURES < SDL_MAX_DIRECTBUFFERS )
229 /* Find an empty picture slot */
230 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
232 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
234 p_pic = p_vout->p_picture + i_index;
239 /* Allocate the picture if we found one */
240 if( p_pic == NULL || NewPicture( p_vout, p_pic ) )
245 p_pic->i_status = DESTROYED_PICTURE;
246 p_pic->i_type = DIRECT_PICTURE;
248 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
256 /*****************************************************************************
257 * vout_End: terminate Sys video thread output method
258 *****************************************************************************
259 * Terminate an output method created by vout_SDLCreate
260 *****************************************************************************/
261 static void vout_End( vout_thread_t *p_vout )
265 /* Free the output buffers we allocated */
266 for( i_index = I_OUTPUTPICTURES ; i_index ; )
269 if( p_vout->p_sys->p_overlay == NULL )
275 SDL_UnlockYUVOverlay(
276 PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
278 PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
280 free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
284 /*****************************************************************************
285 * vout_Destroy: destroy Sys video thread output method
286 *****************************************************************************
287 * Terminate an output method created by vout_SDLCreate
288 *****************************************************************************/
289 static void vout_Destroy( vout_thread_t *p_vout )
291 CloseDisplay( p_vout );
293 SDL_QuitSubSystem( SDL_INIT_VIDEO );
295 free( p_vout->p_sys );
298 /*****************************************************************************
299 * vout_Manage: handle Sys events
300 *****************************************************************************
301 * This function should be called regularly by video output thread. It returns
302 * a non null value if an error occured.
303 *****************************************************************************/
304 static int vout_Manage( vout_thread_t *p_vout )
306 SDL_Event event; /* SDL event */
309 while( SDL_PollEvent(&event) )
313 case SDL_VIDEORESIZE: /* Resizing of window */
314 /* Update dimensions */
315 p_vout->i_changes |= VOUT_SIZE_CHANGE;
316 p_vout->i_window_width = p_vout->p_sys->i_width = event.resize.w;
317 p_vout->i_window_height = p_vout->p_sys->i_height = event.resize.h;
320 case SDL_MOUSEMOTION:
321 if( p_vout->p_sys->b_cursor &&
322 (abs(event.motion.xrel) > 2 || abs(event.motion.yrel) > 2) )
324 if( p_vout->p_sys->b_cursor_autohidden )
326 p_vout->p_sys->b_cursor_autohidden = 0;
331 p_vout->p_sys->i_lastmoved = mdate();
336 case SDL_MOUSEBUTTONUP:
337 switch( event.button.button )
339 case SDL_BUTTON_RIGHT:
341 intf_thread_t *p_intf;
342 p_intf = vlc_object_find( p_vout->p_vlc, VLC_OBJECT_INTF,
346 p_intf->b_menu_change = 1;
347 vlc_object_release( p_intf );
354 case SDL_MOUSEBUTTONDOWN:
355 switch( event.button.button )
357 case SDL_BUTTON_LEFT:
358 /* In this part we will eventually manage
359 * clicks for DVD navigation for instance. */
361 /* detect double-clicks */
362 if( ( mdate() - p_vout->p_sys->i_lastpressed ) < 300000 )
363 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
365 p_vout->p_sys->i_lastpressed = mdate();
369 input_Seek( p_vout, 15, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
373 input_Seek( p_vout, -15, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
379 p_vout->p_vlc->b_die = 1;
382 case SDL_KEYDOWN: /* if a key is pressed */
384 switch( event.key.keysym.sym )
387 if( p_vout->b_fullscreen )
389 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
393 p_vout->p_vlc->b_die = 1;
397 case SDLK_q: /* quit */
398 p_vout->p_vlc->b_die = 1;
401 case SDLK_f: /* switch to fullscreen */
402 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
405 case SDLK_c: /* toggle grayscale */
406 p_vout->b_grayscale = ! p_vout->b_grayscale;
407 p_vout->i_changes |= VOUT_GRAYSCALE_CHANGE;
410 case SDLK_i: /* toggle info */
411 p_vout->b_info = ! p_vout->b_info;
412 p_vout->i_changes |= VOUT_INFO_CHANGE;
415 case SDLK_s: /* toggle scaling */
416 p_vout->b_scale = ! p_vout->b_scale;
417 p_vout->i_changes |= VOUT_SCALE_CHANGE;
420 case SDLK_SPACE: /* toggle interface */
421 p_vout->b_interface = ! p_vout->b_interface;
422 p_vout->i_changes |= VOUT_INTF_CHANGE;
427 intf_thread_t *p_intf;
428 p_intf = vlc_object_find( p_vout->p_vlc, VLC_OBJECT_INTF,
432 p_intf->b_menu_change = 1;
433 vlc_object_release( p_intf );
439 input_Seek( p_vout, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
443 input_Seek( p_vout, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
447 input_Seek( p_vout, 60, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
451 input_Seek( p_vout, -60, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
454 case SDLK_F10: network_ChannelJoin( p_vout, 0 ); break;
455 case SDLK_F1: network_ChannelJoin( p_vout, 1 ); break;
456 case SDLK_F2: network_ChannelJoin( p_vout, 2 ); break;
457 case SDLK_F3: network_ChannelJoin( p_vout, 3 ); break;
458 case SDLK_F4: network_ChannelJoin( p_vout, 4 ); break;
459 case SDLK_F5: network_ChannelJoin( p_vout, 5 ); break;
460 case SDLK_F6: network_ChannelJoin( p_vout, 6 ); break;
461 case SDLK_F7: network_ChannelJoin( p_vout, 7 ); break;
462 case SDLK_F8: network_ChannelJoin( p_vout, 8 ); break;
463 case SDLK_F9: network_ChannelJoin( p_vout, 9 ); break;
475 /* Fullscreen change */
476 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
478 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
480 p_vout->p_sys->b_cursor_autohidden = 0;
481 SDL_ShowCursor( p_vout->p_sys->b_cursor &&
482 ! p_vout->p_sys->b_cursor_autohidden );
484 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
485 p_vout->i_changes |= VOUT_SIZE_CHANGE;
491 if( p_vout->i_changes & VOUT_SIZE_CHANGE )
493 msg_Dbg( p_vout, "video display resized (%dx%d)",
494 p_vout->p_sys->i_width, p_vout->p_sys->i_height );
496 CloseDisplay( p_vout );
497 OpenDisplay( p_vout );
499 /* We don't need to signal the vout thread about the size change if
500 * we can handle rescaling ourselves */
501 if( p_vout->p_sys->p_overlay != NULL )
502 p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
507 if( ! p_vout->p_sys->b_cursor_autohidden &&
508 ( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) )
510 /* Hide the mouse automatically */
511 p_vout->p_sys->b_cursor_autohidden = 1;
518 /*****************************************************************************
519 * vout_Render: render previously calculated output
520 *****************************************************************************/
521 static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
526 /*****************************************************************************
527 * vout_Display: displays previously rendered output
528 *****************************************************************************
529 * This function sends the currently rendered image to the display.
530 *****************************************************************************/
531 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
536 vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
543 if( p_vout->p_sys->p_overlay == NULL )
546 SDL_Flip( p_vout->p_sys->p_display );
550 /* Overlay picture */
551 SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
552 SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
553 SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
557 /* following functions are local */
559 /*****************************************************************************
560 * OpenDisplay: open and initialize SDL device
561 *****************************************************************************
562 * Open and initialize display according to preferences specified in the vout
564 *****************************************************************************/
565 static int OpenDisplay( vout_thread_t *p_vout )
570 /* Set main window's size */
571 p_vout->p_sys->i_width = p_vout->b_fullscreen ? p_vout->output.i_width :
572 p_vout->i_window_width;
573 p_vout->p_sys->i_height = p_vout->b_fullscreen ? p_vout->output.i_height :
574 p_vout->i_window_height;
576 /* Initialize flags and cursor */
577 i_flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE | SDL_DOUBLEBUF;
578 i_flags |= p_vout->b_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE;
580 i_bpp = SDL_VideoModeOK( p_vout->p_sys->i_width, p_vout->p_sys->i_height,
581 SDL_DEFAULT_BPP, i_flags );
584 msg_Err( p_vout, "no video mode available" );
588 p_vout->p_sys->p_display = SDL_SetVideoMode( p_vout->p_sys->i_width,
589 p_vout->p_sys->i_height,
592 if( p_vout->p_sys->p_display == NULL )
594 msg_Err( p_vout, "cannot set video mode" );
598 SDL_LockSurface( p_vout->p_sys->p_display );
600 /* Choose the chroma we will try first. */
601 switch( p_vout->render.i_chroma )
605 p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
610 p_vout->output.i_chroma = SDL_UYVY_OVERLAY;
613 p_vout->output.i_chroma = SDL_YVYU_OVERLAY;
619 p_vout->output.i_chroma = SDL_YV12_OVERLAY;
623 p_vout->p_sys->p_overlay =
624 SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
625 p_vout->p_sys->p_display );
626 /* FIXME: if the first overlay we find is software, don't stop,
627 * because we may find a hardware one later ... */
629 /* If this best choice failed, fall back to other chromas */
630 if( p_vout->p_sys->p_overlay == NULL )
632 p_vout->output.i_chroma = SDL_IYUV_OVERLAY;
633 p_vout->p_sys->p_overlay =
634 SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
635 p_vout->p_sys->p_display );
638 if( p_vout->p_sys->p_overlay == NULL )
640 p_vout->output.i_chroma = SDL_YV12_OVERLAY;
641 p_vout->p_sys->p_overlay =
642 SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
643 p_vout->p_sys->p_display );
646 if( p_vout->p_sys->p_overlay == NULL )
648 p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
649 p_vout->p_sys->p_overlay =
650 SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
651 p_vout->p_sys->p_display );
654 if( p_vout->p_sys->p_overlay == NULL )
656 msg_Warn( p_vout, "no SDL overlay for 0x%.8x (%4.4s)",
657 p_vout->render.i_chroma, (char*)&p_vout->render.i_chroma );
659 switch( p_vout->p_sys->p_display->format->BitsPerPixel )
662 p_vout->output.i_chroma = FOURCC_RGB2;
663 p_vout->output.pf_setpalette = SetPalette;
666 p_vout->output.i_chroma = FOURCC_RV15;
669 p_vout->output.i_chroma = FOURCC_RV16;
672 p_vout->output.i_chroma = FOURCC_RV24;
675 p_vout->output.i_chroma = FOURCC_RV32;
678 msg_Err( p_vout, "unknown screen depth %i",
679 p_vout->p_sys->p_display->format->BitsPerPixel );
680 SDL_UnlockSurface( p_vout->p_sys->p_display );
681 SDL_FreeSurface( p_vout->p_sys->p_display );
685 p_vout->output.i_rmask = p_vout->p_sys->p_display->format->Rmask;
686 p_vout->output.i_gmask = p_vout->p_sys->p_display->format->Gmask;
687 p_vout->output.i_bmask = p_vout->p_sys->p_display->format->Bmask;
689 SDL_WM_SetCaption( VOUT_TITLE " (software RGB SDL output)",
690 VOUT_TITLE " (software RGB SDL output)" );
694 if( p_vout->p_sys->p_overlay->hw_overlay )
696 SDL_WM_SetCaption( VOUT_TITLE " (hardware YUV SDL output)",
697 VOUT_TITLE " (hardware YUV SDL output)" );
701 SDL_WM_SetCaption( VOUT_TITLE " (software YUV SDL output)",
702 VOUT_TITLE " (software YUV SDL output)" );
706 SDL_EventState( SDL_KEYUP, SDL_IGNORE ); /* ignore keys up */
711 /*****************************************************************************
712 * CloseDisplay: close and reset SDL device
713 *****************************************************************************
714 * This function returns all resources allocated by OpenDisplay and restore
715 * the original state of the device.
716 *****************************************************************************/
717 static void CloseDisplay( vout_thread_t *p_vout )
719 SDL_FreeYUVOverlay( p_vout->p_sys->p_overlay );
720 SDL_UnlockSurface ( p_vout->p_sys->p_display );
721 SDL_FreeSurface( p_vout->p_sys->p_display );
724 /*****************************************************************************
725 * NewPicture: allocate a picture
726 *****************************************************************************
727 * Returns 0 on success, -1 otherwise
728 *****************************************************************************/
729 static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
731 int i_width = p_vout->output.i_width;
732 int i_height = p_vout->output.i_height;
734 if( p_vout->p_sys->p_overlay == NULL )
737 if( p_vout->p_sys->i_surfaces )
739 /* We already allocated this surface, return */
743 p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
745 if( p_pic->p_sys == NULL )
750 switch( p_vout->p_sys->p_display->format->BitsPerPixel )
753 p_pic->p->i_pixel_bytes = 1;
757 p_pic->p->i_pixel_bytes = 2;
761 p_pic->p->i_pixel_bytes = 4;
767 p_pic->p->p_pixels = p_vout->p_sys->p_display->pixels;
768 p_pic->p->i_lines = p_vout->p_sys->p_display->h;
769 p_pic->p->i_pitch = p_vout->p_sys->p_display->pitch;
771 if( p_pic->p->i_pitch ==
772 p_pic->p->i_pixel_bytes * p_vout->p_sys->p_display->w )
774 p_pic->p->b_margin = 0;
778 p_pic->p->b_margin = 1;
779 p_pic->p->b_hidden = 1;
780 p_pic->p->i_visible_bytes =
781 p_pic->p->i_pixel_bytes * p_vout->p_sys->p_display->w;
784 p_vout->p_sys->i_surfaces++;
790 p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
792 if( p_pic->p_sys == NULL )
797 p_pic->p_sys->p_overlay =
798 SDL_CreateYUVOverlay( i_width, i_height,
799 p_vout->output.i_chroma,
800 p_vout->p_sys->p_display );
802 if( p_pic->p_sys->p_overlay == NULL )
804 free( p_pic->p_sys );
808 SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
810 p_pic->Y_PIXELS = p_pic->p_sys->p_overlay->pixels[0];
811 p_pic->p[Y_PLANE].i_lines = p_pic->p_sys->p_overlay->h;
812 p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[0];
814 switch( p_vout->output.i_chroma )
816 case SDL_YV12_OVERLAY:
817 p_pic->p[Y_PLANE].i_pixel_bytes = 1;
818 p_pic->p[Y_PLANE].b_margin = 0;
820 p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
821 p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
822 p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
823 p_pic->p[U_PLANE].i_pixel_bytes = 1;
824 p_pic->p[U_PLANE].b_margin = 0;
826 p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
827 p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
828 p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
829 p_pic->p[V_PLANE].i_pixel_bytes = 1;
830 p_pic->p[V_PLANE].b_margin = 0;
835 case SDL_IYUV_OVERLAY:
836 p_pic->p[Y_PLANE].i_pixel_bytes = 1;
837 p_pic->p[Y_PLANE].b_margin = 0;
839 p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
840 p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
841 p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
842 p_pic->p[U_PLANE].i_pixel_bytes = 1;
843 p_pic->p[U_PLANE].b_margin = 0;
845 p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
846 p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
847 p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
848 p_pic->p[V_PLANE].i_pixel_bytes = 1;
849 p_pic->p[V_PLANE].b_margin = 0;
855 p_pic->p[Y_PLANE].i_pixel_bytes = 2;
856 p_pic->p[Y_PLANE].b_margin = 0;
866 /*****************************************************************************
867 * SetPalette: sets an 8 bpp palette
868 *****************************************************************************/
869 static void SetPalette( vout_thread_t *p_vout, u16 *red, u16 *green, u16 *blue )
871 SDL_Color colors[256];
874 /* Fill colors with color information */
875 for( i = 0; i < 256; i++ )
877 colors[ i ].r = red[ i ] >> 8;
878 colors[ i ].g = green[ i ] >> 8;
879 colors[ i ].b = blue[ i ] >> 8;
883 if( SDL_SetColors( p_vout->p_sys->p_display, colors, 0, 256 ) == 0 )
885 msg_Err( p_vout, "failed setting palette" );